Skip to content

Commit 2887f60

Browse files
authored
Use ruff, not pycln, for removing unused imports (#10498)
1 parent 464b71c commit 2887f60

6 files changed

+6
-20
lines changed

.pre-commit-config.yaml

-7
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,6 @@ repos:
99
- id: check-merge-conflict
1010
- id: mixed-line-ending
1111
- id: check-case-conflict
12-
- repo: https://github.com/hadialqattan/pycln
13-
rev: v2.1.6 # must match requirements-tests.txt
14-
hooks:
15-
- id: pycln
16-
args: [--config=pyproject.toml]
17-
types: [file]
18-
types_or: [python, pyi]
1912
- repo: https://github.com/psf/black
2013
rev: 23.7.0 # must match requirements-tests.txt
2114
hooks:

CONTRIBUTING.md

+4-5
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 `pycln`, `black`, `isort` and `ruff`) to fix any formatting issues.
32+
changes to your PR (using `black`, `isort` and `ruff`) 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.
@@ -84,19 +84,18 @@ terminal to install all non-pytype requirements:
8484

8585
## Code formatting
8686

87-
The code is formatted using `black` and `isort`. Unused imports are also
88-
auto-removed using `pycln`, and various other autofixes are performed by `ruff`.
87+
The code is formatted using `black` and `isort`. Various other autofixes are
88+
also performed by `ruff`.
8989

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

9595
That being said, if you *want* to run the checks locally when you commit,
96-
you're free to do so. Either run `pycln`, `isort`, `black` and `ruff` manually...
96+
you're free to do so. Either run `isort`, `black` and `ruff` manually...
9797

9898
```bash
99-
$ pycln --config=pyproject.toml .
10099
$ isort .
101100
$ ruff .
102101
$ black .

pyproject.toml

+1-4
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ exclude = [
7878
# Only enable rules that have safe autofixes;
7979
# only enable rules that are relevant to stubs
8080
select = [
81+
"F401", # Remove unused imports
8182
"UP004", # Remove explicit `object` inheritance
8283
"UP006", # PEP-585 autofixes
8384
"UP007", # PEP-604 autofixes
@@ -95,9 +96,5 @@ select = [
9596
"PYI032", # use `object`, not `Any`, as the second parameter to `__eq__`
9697
]
9798

98-
[tool.pycln]
99-
all = true
100-
disable_all_dunder_policy = true
101-
10299
[tool.typeshed]
103100
pyright_version = "1.1.318"

requirements-tests.txt

-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ flake8-pyi==23.6.0; python_version >= "3.8" # must match .pre-commit-confi
99
isort==5.12.0; python_version >= "3.8" # must match .pre-commit-config.yaml
1010
mypy==1.4.1
1111
pre-commit-hooks==4.4.0 # must match .pre-commit-config.yaml
12-
pycln==2.1.6 # must match .pre-commit-config.yaml
1312
pytype==2023.6.16; platform_system != "Windows" and python_version < "3.11"
1413
ruff==0.0.278 # must match .pre-commit-config.yaml
1514

scripts/runtests.py

-2
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,6 @@ def main() -> None:
7575
pytype_result: subprocess.CompletedProcess[bytes] | None = None
7676

7777
# Run formatters first. Order matters.
78-
print("\nRunning pycln...")
79-
subprocess.run([sys.executable, "-m", "pycln", path, "--config=pyproject.toml"])
8078
print("\nRunning ruff...")
8179
subprocess.run([sys.executable, "-m", "ruff", path])
8280
print("\nRunning isort...")

tests/check_consistent.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
# These type checkers and linters must have exact versions in the requirements file to ensure
2525
# consistent CI runs.
26-
linters = {"black", "flake8", "flake8-bugbear", "flake8-noqa", "flake8-pyi", "isort", "ruff", "mypy", "pycln", "pytype"}
26+
linters = {"black", "flake8", "flake8-bugbear", "flake8-noqa", "flake8-pyi", "isort", "ruff", "mypy", "pytype"}
2727

2828

2929
def assert_consistent_filetypes(

0 commit comments

Comments
 (0)