Skip to content

Commit

Permalink
Added black (code formatting) and isort (import sorting)
Browse files Browse the repository at this point in the history
  • Loading branch information
mdesmet committed Aug 19, 2022
1 parent e3008a7 commit 18757d9
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[flake8]
select =
E
W
F
ignore =
W503 # makes Flake8 work like black
W504
E203 # makes Flake8 work like black
E741
E501
13 changes: 13 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,16 @@ repos:
additional_dependencies:
- "types-pytz"
- "types-requests"

- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
args:
- "--line-length=99"

- repo: https://github.com/pycqa/isort
rev: 5.6.4
hooks:
- id: isort
args: [ "--profile", "black", "--filter-files" ]
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,7 @@ We recommend that you use Python3's `venv` for development:
$ python3 -m venv .venv
$ . .venv/bin/activate
$ pip install -e '.[tests]'
$ pre-commit install
```

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

### `pre-commit` checks

Code is automatically checked on commit by a [pre-commit](https://pre-commit.com/) git hook.

Following checks are performed:

- [`flake8`](https://flake8.pycqa.org/en/latest/) for code linting
- [`black`](https://github.com/psf/black) for code formatting
- [`isort`](https://pycqa.github.io/isort/) for sorting imports
- [`mypy`](https://mypy.readthedocs.io/en/stable/) for static type checking

### Running tests

`trino-python-client` uses [pytest](https://pytest.org/) for its tests. To run
Expand Down
3 changes: 3 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
"pytest",
"pytest-runner",
"click",
"pre-commit",
"black",
"isort",
]

setup(
Expand Down

0 comments on commit 18757d9

Please sign in to comment.