Skip to content

Commit 96bc62a

Browse files
committed
Run pycln as a pre-commit hook in CI
1 parent 759ea2e commit 96bc62a

File tree

4 files changed

+14
-3
lines changed

4 files changed

+14
-3
lines changed

.pre-commit-config.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
repos:
2+
- repo: https://github.com/hadialqattan/pycln
3+
rev: v2.0.2 # must match requirements-tests.txt
4+
hooks:
5+
- id: pycln
6+
args: [--config=pyproject.toml]
27
- repo: https://github.com/psf/black
38
rev: 22.6.0 # must match requirements-tests.txt
49
hooks:

CONTRIBUTING.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ it takes a bit longer. For more details, read below.
2929
Typeshed runs continuous integration (CI) on all pull requests. This means that
3030
if you file a pull request (PR), our full test suite -- including our linter,
3131
`flake8` -- is run on your PR. It also means that bots will automatically apply
32-
changes to your PR (using `black` and `isort`) to fix any formatting issues.
32+
changes to your PR (using `pycln`, `black` and `isort`) to fix any formatting issues.
3333
This frees you up to ignore all local setup on your side, focus on the
3434
code and rely on the CI to fix everything, or point you to the places that
3535
need fixing.
@@ -92,17 +92,19 @@ pip install termcolor
9292

9393
## Code formatting
9494

95-
The code is formatted using `black` and `isort`.
95+
The code is formatted using `black` and `isort`. Unused imports are also
96+
auto-removed using `pycln`.
9697

9798
The repository is equipped with a [`pre-commit.ci`](https://pre-commit.ci/)
9899
configuration file. This means that you don't *need* to do anything yourself to
99100
run the code formatters. When you push a commit, a bot will run those for you
100101
right away and add a commit to your PR.
101102

102103
That being said, if you *want* to run the checks locally when you commit,
103-
you're free to do so. Either run `black` and `isort` manually...
104+
you're free to do so. Either run `pycln`, `black` and `isort` manually...
104105

105106
```
107+
pycln --all .
106108
isort .
107109
black .
108110
```

pyproject.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,6 @@ extra_standard_library = [
4747
"UserList",
4848
"UserString",
4949
]
50+
51+
[tool.pycln]
52+
all = true

requirements-tests.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ flake8-pyi==22.5.1
99
# must match .pre-commit-config.yaml
1010
isort==5.10.1
1111
tomli==1.2.2
12+
pycln==2.0.2

0 commit comments

Comments
 (0)