Skip to content

Commit 4de6545

Browse files
[pre-commit] Transition from flake8/autoflake to ruff (#8372)
ruff is faster and support pyproject.toml. flake8-typing-import is not implemented but it checks for things in python version < 3.7.2 that we do not support.
1 parent b5aab35 commit 4de6545

File tree

5 files changed

+20
-51
lines changed

5 files changed

+20
-51
lines changed

.pre-commit-config.yaml

+7-25
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,19 @@ repos:
1515
doc/data/messages/t/trailing-newlines/bad.py|
1616
doc/data/messages/m/missing-final-newline/bad.py|
1717
)$
18-
- repo: https://github.com/PyCQA/autoflake
19-
rev: v2.0.1
18+
- repo: https://github.com/charliermarsh/ruff-pre-commit
19+
rev: "v0.0.253"
2020
hooks:
21-
- id: autoflake
21+
- id: ruff
22+
args: ["--fix"]
2223
exclude: &fixtures tests(/\w*)*/functional/|tests/input|doc/data/messages|tests(/\w*)*data/
23-
args:
24-
- --in-place
25-
- --remove-all-unused-imports
26-
- --expand-star-imports
27-
- --remove-duplicate-keys
28-
- --remove-unused-variables
2924
- repo: https://github.com/charliermarsh/ruff-pre-commit
3025
rev: "v0.0.253"
3126
hooks:
3227
- id: ruff
33-
args: ["--fix"]
34-
exclude: *fixtures
28+
name: line-length-doc
29+
files: doc/data/messages
30+
args: ["--config", "doc/data/ruff.toml"]
3531
- repo: https://github.com/Pierre-Sassoulas/copyright_notice_precommit
3632
rev: 0.1.2
3733
hooks:
@@ -60,20 +56,6 @@ repos:
6056
rev: v1.1.3
6157
hooks:
6258
- id: black-disable-checker
63-
- repo: https://github.com/PyCQA/flake8
64-
rev: 6.0.0
65-
hooks:
66-
- id: flake8
67-
additional_dependencies:
68-
[flake8-bugbear==23.1.20, flake8-typing-imports==1.14.0]
69-
exclude: *fixtures
70-
- repo: https://github.com/PyCQA/flake8
71-
rev: 6.0.0
72-
hooks:
73-
- id: flake8
74-
name: line-length-doc
75-
files: doc/data/messages
76-
args: ["--config", "doc/data/.flake8"]
7759
- repo: local
7860
hooks:
7961
- id: pylint
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
1-
[flake8]
2-
select =
3-
E501,
1+
ignore = []
42
# Reading ease is drastically reduced on read the doc after 103 chars
53
# (Because of horizontal scrolling)
6-
max-line-length=103
4+
line-length = 103
5+
select = ["E501"]

pylint/config/config_initialization.py

+4-3
Original file line numberDiff line numberDiff line change
@@ -125,9 +125,10 @@ def _config_initialization(
125125
# All other options have been removed from the list.
126126
return list(
127127
chain.from_iterable(
128-
# NOTE: 'or [arg]' is needed in the case the input file or directory does not exist and 'glob(arg)' cannot
129-
# find anything. Without this we would not be able to output the fatal import error for this module later
130-
# on, as it would get silently ignored.
128+
# NOTE: 'or [arg]' is needed in the case the input file or directory does
129+
# not exist and 'glob(arg)' cannot find anything. Without this we would
130+
# not be able to output the fatal import error for this module later on,
131+
# as it would get silently ignored.
131132
glob(arg, recursive=True) or [arg]
132133
for arg in parsed_args_list
133134
)

pyproject.toml

+6-3
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,13 @@ module = [
130130
"pytest",
131131
"sphinx.*",
132132
]
133+
133134
[tool.ruff]
134-
select = ["E", "F", "B"]
135+
select = ["E", "F", "W", "B"]
135136
ignore = [
136137
"B905", # Not enforced previousely
137138
]
138-
fixable = ["E", "F", "B"]
139-
line-length = 125
139+
fixable = ["E", "F", "W", "B"]
140+
# ruff is less lenient than pylint and does not make any exceptions
141+
# (for docstrings, strings and comments in particular).
142+
line-length = 115

setup.cfg

-16
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,3 @@
77
license_files =
88
LICENSE
99
CONTRIBUTORS.txt
10-
11-
[flake8]
12-
# Incompatible with black see https://github.com/ambv/black/issues/315
13-
# E203: Whitespace before ':'
14-
# W503: Line break occurred before a binary operator
15-
# B028: consider using the `!r` conversion flag
16-
ignore =
17-
E203,
18-
W503,
19-
B028,
20-
# Flake8 is less lenient than pylint and does not make any exceptions
21-
# (for docstrings, strings and comments in particular).
22-
max-line-length=115
23-
# Required for flake8-typing-imports (v1.12.0)
24-
# The plugin doesn't yet read the value from pyproject.toml
25-
min_python_version = 3.7.2

0 commit comments

Comments
 (0)