Skip to content

Commit 12c2128

Browse files
committed
Add pre-commit hook and improve its rules
1 parent 7d60cbf commit 12c2128

File tree

6 files changed

+64
-46
lines changed

6 files changed

+64
-46
lines changed

.github/workflows/pre-commit.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: pre-commit
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [master]
7+
8+
jobs:
9+
pre-commit:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v2
13+
- uses: actions/setup-python@v2
14+
- uses: pre-commit/action@v2.0.3
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ jobs:
1616
strategy:
1717
matrix:
1818
python-version:
19-
- "2.7"
2019
- "3.5"
2120
- "3.6"
2221
- "3.7"
2322
- "3.8"
2423
- "3.9"
24+
- "3.10"
2525

2626
steps:
2727
- uses: actions/checkout@v2
@@ -33,8 +33,6 @@ jobs:
3333
run: |
3434
python -m pip install --upgrade pip
3535
python -m pip install -r requirements-test.txt
36-
- name: Lint with flake8
37-
run: |
3836
# stop the build if there are Python syntax errors or undefined names
3937
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
4038
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide

.pre-commit-config.yaml

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
repos:
2-
- repo: https://github.com/PyCQA/isort.git
3-
rev: 5.7.0
4-
hooks:
5-
- id: isort
62
- repo: https://github.com/psf/black
7-
rev: 20.8b1
3+
rev: 22.1.0
4+
hooks:
5+
- name: re-format with black
6+
id: black
7+
language_version: python3
8+
9+
- repo: https://github.com/pre-commit/pre-commit-hooks
10+
rev: v4.1.0
811
hooks:
9-
- id: black
10-
language_version: python3
11-
args:
12-
- -l
13-
- "119"
12+
- name: remove whitespaces
13+
id: trailing-whitespace
14+
1415
- repo: https://gitlab.com/pycqa/flake8
15-
rev: 6de8252c035844f1e679f509b5f37340b44d5c39
16+
rev: 21d3c70d676007470908d39b73f0521d39b3b997
1617
hooks:
17-
- id: flake8
18+
- name: check-format with flake8
19+
id: flake8
20+
args:
21+
- --show-source
22+
- --statistics
23+
- --count
24+
- --max-complexity=12

readchar/key.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,32 +8,32 @@
88
ESC = "\x1b"
99

1010
# CTRL
11-
CTRL_A = '\x01'
12-
CTRL_B = '\x02'
13-
CTRL_C = '\x03'
14-
CTRL_D = '\x04'
15-
CTRL_E = '\x05'
16-
CTRL_F = '\x06'
17-
CTRL_G = '\x07'
18-
CTRL_H = '\x08'
19-
CTRL_I = '\t'
20-
CTRL_J = '\n'
21-
CTRL_K = '\x0b'
22-
CTRL_L = '\x0c'
23-
CTRL_M = '\r'
24-
CTRL_N = '\x0e'
25-
CTRL_O = '\x0f'
26-
CTRL_P = '\x10'
27-
CTRL_Q = '\x11'
28-
CTRL_R = '\x12'
29-
CTRL_S = '\x13'
30-
CTRL_T = '\x14'
31-
CTRL_U = '\x15'
32-
CTRL_V = '\x16'
33-
CTRL_W = '\x17'
34-
CTRL_X = '\x18'
35-
CTRL_Y = '\x19'
36-
CTRL_Z = '\x1a'
11+
CTRL_A = "\x01"
12+
CTRL_B = "\x02"
13+
CTRL_C = "\x03"
14+
CTRL_D = "\x04"
15+
CTRL_E = "\x05"
16+
CTRL_F = "\x06"
17+
CTRL_G = "\x07"
18+
CTRL_H = "\x08"
19+
CTRL_I = "\t"
20+
CTRL_J = "\n"
21+
CTRL_K = "\x0b"
22+
CTRL_L = "\x0c"
23+
CTRL_M = "\r"
24+
CTRL_N = "\x0e"
25+
CTRL_O = "\x0f"
26+
CTRL_P = "\x10"
27+
CTRL_Q = "\x11"
28+
CTRL_R = "\x12"
29+
CTRL_S = "\x13"
30+
CTRL_T = "\x14"
31+
CTRL_U = "\x15"
32+
CTRL_V = "\x16"
33+
CTRL_W = "\x17"
34+
CTRL_X = "\x18"
35+
CTRL_Y = "\x19"
36+
CTRL_Z = "\x1a"
3737

3838
# ALT
3939
ALT_A = "\x1b\x61"

readchar/readchar.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@
5353
20960: key.PAGE_DOWN,
5454
18400: key.HOME,
5555
20448: key.END,
56-
18432: key.UP, # 72 * 256
57-
20480: key.DOWN, # 80 * 256
58-
19200: key.LEFT, # 75 * 256
59-
19712: key.RIGHT, # 77 * 256
56+
18432: key.UP, # 72 * 256
57+
20480: key.DOWN, # 80 * 256
58+
19200: key.LEFT, # 75 * 256
59+
19712: key.RIGHT, # 77 * 256
6060
}
6161

6262
def readkey(getchar_fn=None):
@@ -79,7 +79,6 @@ def readkey(getchar_fn=None):
7979
else:
8080
return ch.decode()
8181

82-
8382
else:
8483

8584
def readkey(getchar_fn=None):

0 commit comments

Comments
 (0)