Skip to content

Commit 35616b4

Browse files
authored
Run pycln as a pre-commit hook in CI (#8304)
1 parent 6435952 commit 35616b4

File tree

6 files changed

+14
-6
lines changed

6 files changed

+14
-6
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: [--all, stubs, stdlib, tests, scripts]
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.
@@ -82,17 +82,19 @@ terminal to install all non-pytype requirements:
8282

8383
## Code formatting
8484

85-
The code is formatted using `black` and `isort`.
85+
The code is formatted using `black` and `isort`. Unused imports are also
86+
auto-removed using `pycln`.
8687

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

9293
That being said, if you *want* to run the checks locally when you commit,
93-
you're free to do so. Either run `black` and `isort` manually...
94+
you're free to do so. Either run `pycln`, `black` and `isort` manually...
9495

9596
```
97+
pycln --all .
9698
isort .
9799
black .
98100
```

requirements-tests.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@ 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
1213
packaging==21.3
1314
termcolor

stdlib/tokenize.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import sys
22
from _typeshed import StrOrBytesPath
3-
from builtins import open as _builtin_open
43
from collections.abc import Callable, Generator, Iterable, Sequence
54
from re import Pattern
65
from token import *

stdlib/unittest/loader.pyi

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import unittest.case
2-
import unittest.result
32
import unittest.suite
43
from collections.abc import Callable, Sequence
54
from re import Pattern

stubs/aiofiles/aiofiles/os.pyi

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ from os import stat_result
66
from typing import Any, overload
77
from typing_extensions import TypeAlias
88

9-
from . import ospath as path
9+
from . import ospath
10+
11+
path = ospath
1012

1113
_FdOrAnyPath: TypeAlias = int | StrOrBytesPath
1214

0 commit comments

Comments
 (0)