Skip to content

Commit 80c0507

Browse files
committed
Add ruff
Signed-off-by: Cristian Le <cristian.le@mpsd.mpg.de>
1 parent 92fcfe6 commit 80c0507

2 files changed

Lines changed: 137 additions & 16 deletions

File tree

.pre-commit-config.yaml

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,13 @@ repos:
66
hooks:
77
- id: autopep8
88

9-
- repo: https://github.com/PyCQA/isort
10-
rev: "5.12.0"
9+
- repo: https://github.com/charliermarsh/ruff-pre-commit
10+
rev: v0.4.4
1111
hooks:
12-
- id: isort
13-
14-
- repo: https://github.com/pycqa/flake8
15-
rev: "6.0.0"
16-
hooks:
17-
- id: flake8
12+
- id: ruff
1813
args:
19-
- --max-line-length=99
20-
files: >
21-
(?x)^(
22-
bin/.*|
23-
examples/.*|
24-
fmf/.*|
25-
tests/.*
26-
)$
14+
- '--fix'
15+
- '--show-fixes'
2716

2817
- repo: https://github.com/pre-commit/pre-commit-hooks
2918
rev: "v4.6.0"

pyproject.toml

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,3 +110,135 @@ in-place = true
110110
recursive = true
111111
hang-closing = true
112112
aggressive = 2
113+
114+
[tool.ruff]
115+
line-length = 99
116+
src = ["fmf", "tests"]
117+
target-version = "py39"
118+
lint.select = [
119+
"F", # pyflakes
120+
"E", # pycodestyle
121+
"W", # pycodestyle
122+
"I", # isort
123+
"N", # pep8-naming
124+
"D", # pydocstyle
125+
"UP", # pyupgrade
126+
"B", # flake8-bugbear
127+
"C4", # flake8-comprehensions
128+
"YTT", # flake8-2020
129+
"PT", # flake8-pytest-style
130+
"RET", # flake8-return
131+
"SIM", # flake8-simplify
132+
"COM", # flake8-commas
133+
"DTZ", # flake8-datetimez
134+
"T10", # flake8-debugger
135+
"EXE", # flake8-executable
136+
"PIE", # flake8-pie
137+
"RSE", # flake8-raise
138+
"PGH", # pygrep-hooks
139+
"PLC", # pylint-convention
140+
"PLE", # pylint-error
141+
"PLR01", # pylint-refactor
142+
"PLR02",
143+
"PLR04",
144+
"PLR1",
145+
"RUF", # ruff
146+
"D", # pydocstyle
147+
]
148+
lint.ignore = [
149+
"B904", # Within an `except` clause, raise exceptions with `raise ... from err` or `raise ...
150+
"COM812", # Trailing comma missing
151+
# tmt codebase uses `warn` by default - disabling the check, switching to
152+
# `warning` can be done in an extra patch.
153+
"G010", # `warn` is deprecated in favor of `warning`
154+
"PIE790", # Unnecessary `pass` statement
155+
"PLC1901", # `{}` can be simplified to `{}` as an empty string is falsey
156+
"PLE1205", # Too many arguments for `logging` format string
157+
"RUF012", # Mutable class attributes should be annotated with `typing.ClassVar`
158+
"RUF013", # PEP 484 prohibits implicit `Optional`
159+
160+
# pydocstyle
161+
# TODO: the permanent list (drop this comment once the temporary list
162+
# below gets to zero items...)
163+
"D203", # 1 blank line required before class docstring
164+
# TODO: the temporary list - some of these will be enabled in their
165+
# own patches
166+
"D100", # Missing docstring in public module
167+
"D101", # Missing docstring in public class
168+
"D102", # Missing docstring in public method
169+
"D103", # Missing docstring in public function
170+
"D104", # Missing docstring in public package
171+
"D105", # Missing docstring in magic method
172+
"D106", # Missing docstring in public nested class
173+
"D107", # Missing docstring in __init__
174+
"D202", # No blank lines allowed after function docstring
175+
"D205", # 1 blank line required between summary line and description
176+
"D210", # No whitespaces allowed surrounding docstring text
177+
"D212", # Multi-line docstring summary should start at the first line
178+
"D301", # Use r""" if any backslashes in a docstring
179+
"D400", # First line should end with a period
180+
"D401", # First line of docstring should be in imperative mood
181+
"D415", # First line should end with a period, question mark, or exclamation point
182+
# To review
183+
"B007",
184+
"B015",
185+
"B018",
186+
"C403",
187+
"C405",
188+
"C408",
189+
"C409",
190+
"C419",
191+
"E721",
192+
"N818",
193+
"PGH004",
194+
"PT009",
195+
"PT011",
196+
"PT012",
197+
"PT027",
198+
"RET505",
199+
"RET507",
200+
"RUF005",
201+
"RUF017",
202+
"SIM105",
203+
"SIM108",
204+
"SIM117",
205+
"UP006",
206+
"UP008",
207+
"UP028",
208+
"UP029",
209+
"UP030",
210+
"UP031",
211+
"UP035",
212+
# Auto-fixable
213+
"D204",
214+
"F401",
215+
"I001",
216+
"PLR0402",
217+
"PT001",
218+
"PT023",
219+
"RSE102",
220+
"RUF010",
221+
"RUF100",
222+
"UP003",
223+
"UP009",
224+
"UP020",
225+
"UP024",
226+
"UP024",
227+
"UP025",
228+
"UP032",
229+
]
230+
231+
[tool.ruff.lint.flake8-bugbear]
232+
extend-immutable-calls = ["tmt.utils.field"]
233+
234+
[tool.ruff.lint.pydocstyle]
235+
# "The PEP 257 convention includes all D errors apart from: D203, D212,
236+
# D213, D214, D215, D404, D405, D406, D407, D408, D409, D410, D411, D413,
237+
# D415, D416, and D417."
238+
#
239+
# See https://docs.astral.sh/ruff/faq/#does-ruff-support-numpy-or-google-style-docstrings for
240+
# the most up-to-date info.
241+
convention = "pep257"
242+
243+
[tool.ruff.lint.isort]
244+
known-first-party = ["fmf"]

0 commit comments

Comments
 (0)