Skip to content

Commit 18757d9

Browse files
committed
Added black (code formatting) and isort (import sorting)
1 parent e3008a7 commit 18757d9

File tree

4 files changed

+39
-0
lines changed

4 files changed

+39
-0
lines changed

.flake8

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[flake8]
2+
select =
3+
E
4+
W
5+
F
6+
ignore =
7+
W503 # makes Flake8 work like black
8+
W504
9+
E203 # makes Flake8 work like black
10+
E741
11+
E501

.pre-commit-config.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,16 @@ repos:
1313
additional_dependencies:
1414
- "types-pytz"
1515
- "types-requests"
16+
17+
- repo: https://github.com/psf/black
18+
rev: 22.3.0
19+
hooks:
20+
- id: black
21+
args:
22+
- "--line-length=99"
23+
24+
- repo: https://github.com/pycqa/isort
25+
rev: 5.6.4
26+
hooks:
27+
- id: isort
28+
args: [ "--profile", "black", "--filter-files" ]

README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,7 @@ We recommend that you use Python3's `venv` for development:
424424
$ python3 -m venv .venv
425425
$ . .venv/bin/activate
426426
$ pip install -e '.[tests]'
427+
$ pre-commit install
427428
```
428429

429430
With `-e` passed to `pip install` above pip can reference the code you are
@@ -441,6 +442,17 @@ When the code is ready, submit a Pull Request.
441442
See also Trino's [guidelines](https://github.com/trinodb/trino/blob/master/.github/DEVELOPMENT.md).
442443
Most of them also apply to code in trino-python-client.
443444

445+
### `pre-commit` checks
446+
447+
Code is automatically checked on commit by a [pre-commit](https://pre-commit.com/) git hook.
448+
449+
Following checks are performed:
450+
451+
- [`flake8`](https://flake8.pycqa.org/en/latest/) for code linting
452+
- [`black`](https://github.com/psf/black) for code formatting
453+
- [`isort`](https://pycqa.github.io/isort/) for sorting imports
454+
- [`mypy`](https://mypy.readthedocs.io/en/stable/) for static type checking
455+
444456
### Running tests
445457

446458
`trino-python-client` uses [pytest](https://pytest.org/) for its tests. To run

setup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@
3939
"pytest",
4040
"pytest-runner",
4141
"click",
42+
"pre-commit",
43+
"black",
44+
"isort",
4245
]
4346

4447
setup(

0 commit comments

Comments
 (0)