Skip to content

Commit 5c51bc5

Browse files
[pre-commit] Configure ruff to sort import
I'm not sure if ruff handle first party / third parties, but it's good enough for the doc
1 parent 0d26e3c commit 5c51bc5

File tree

4 files changed

+33
-9
lines changed

4 files changed

+33
-9
lines changed

.pre-commit-config.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ repos:
2525
rev: "v0.0.254"
2626
hooks:
2727
- id: ruff
28-
name: line-length-doc
28+
name: ruff-doc
2929
files: doc/data/messages
3030
args: ["--config", "doc/data/ruff.toml"]
3131
- repo: https://github.com/Pierre-Sassoulas/copyright_notice_precommit
@@ -45,7 +45,7 @@ repos:
4545
rev: 5.12.0
4646
hooks:
4747
- id: isort
48-
exclude: doc/data/messages/(r/reimported|w/wrong-import-order|u/ungrouped-imports|m/misplaced-future|m/multiple-imports)/bad.py
48+
exclude: doc/data/messages/
4949
- repo: https://github.com/psf/black
5050
rev: 23.1.0
5151
hooks:

doc/data/ruff.toml

+9-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,12 @@ ignore = []
22
# Reading ease is drastically reduced on read the doc after 103 chars
33
# (Because of horizontal scrolling)
44
line-length = 103
5-
select = ["E501"]
5+
select = ["E501", "I"]
6+
7+
8+
[per-file-ignores]
9+
"doc/data/messages/r/reimported/bad.py" = ["I"]
10+
"doc/data/messages/w/wrong-import-order/bad.py" = ["I"]
11+
"doc/data/messages/u/ungrouped-imports/bad.py" = ["I"]
12+
"doc/data/messages/m/misplaced-future/bad.py" = ["I"]
13+
"doc/data/messages/m/multiple-imports/bad.py" = ["I"]

pyproject.toml

+21-5
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,27 @@ module = [
132132
]
133133

134134
[tool.ruff]
135-
select = ["E", "F", "W", "B"]
136-
ignore = [
137-
"B905", # Not enforced previousely
138-
]
139-
fixable = ["E", "F", "W", "B"]
135+
140136
# ruff is less lenient than pylint and does not make any exceptions
141137
# (for docstrings, strings and comments in particular).
142138
line-length = 115
139+
140+
select = [
141+
"E", # pycodestyle
142+
"F", # pyflakes
143+
"W", # pycodestyle
144+
"B", # bugbear
145+
"I", # isort
146+
]
147+
148+
ignore = [
149+
"B905", # `zip()` without an explicit `strict=` parameter
150+
]
151+
152+
fixable = [
153+
"E", # pycodestyle
154+
"F", # pyflakes
155+
"W", # pycodestyle
156+
"B", # bugbear
157+
"I", # isort
158+
]

requirements_test_pre_commit.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ pre-commit~=3.1;python_version>='3.8'
44
bandit==1.7.4
55
black==23.1.0
66
flake8==6.0.0;python_version>='3.8'
7-
ruff
7+
ruff==0.0.254
88
flake8-typing-imports==1.14.0;python_version>='3.8'
99
isort==5.12.0;python_version>='3.8'
1010
mypy==1.0.1

0 commit comments

Comments
 (0)