Skip to content

Commit 37dcd7d

Browse files
authored
docs: split up ruff config (#682)
Signed-off-by: Henry Schreiner <[email protected]>
1 parent 38a581e commit 37dcd7d

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

docs/pages/guides/style.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,20 @@ won't tell you what or why it fixed things.
214214

215215
{% rr RF001 %} Ruff is configured in your `pyproject.toml`. Here's an example:
216216

217+
{% tabs %} {% tab ruff-simple Simple config %}
218+
219+
```toml
220+
[tool.ruff.lint]
221+
extend-select = [
222+
"B", # flake8-bugbear
223+
"I", # isort
224+
"RUF", # Ruff-specific
225+
"UP", # pyupgrade
226+
]
227+
```
228+
229+
{% endtab %} {% tab ruff-full Full config %}
230+
217231
```toml
218232
[tool.ruff.lint]
219233
extend-select = [
@@ -264,6 +278,38 @@ typing-modules = ["mypackage._compat.typing"]
264278
"tests/**" = ["T20"]
265279
```
266280

281+
{% endtab %} {% tab ruff-ignore Ignore-based config %}
282+
283+
```toml
284+
[tool.ruff.lint]
285+
select = ["ALL"]
286+
ignore = [
287+
"ANN401", # Disallow Any
288+
"PLC0415", # Import should be at top of file
289+
"PLR09", # Too many ...
290+
"PLR2004", # Magic value used in comparison
291+
"PT013", # It's correct to import classes for typing!
292+
"RUF009", # Too easy to get a false positive (function call in dataclass defaults)
293+
"S", # Some subset is okay
294+
"D", # Too many doc requests
295+
"TD", # Todo format
296+
"FIX", # Hacks and todos
297+
"TID252", # Relative imports are fine
298+
"COM", # Trailing commas teach the formatter
299+
"A", # Okay to shadow builtins
300+
"E501", # Line too long
301+
"C90", # Complexity
302+
"SLF001", # Private members are okay to access
303+
"ERA", # Commented out code
304+
]
305+
typing-modules = ["mypackage._compat.typing"]
306+
307+
[tool.ruff.lint.per-file-ignores]
308+
"tests/**" = ["T20"]
309+
```
310+
311+
{% endtab %} {% endtabs %}
312+
267313
Ruff [provides dozens of rule sets](https://beta.ruff.rs/docs/rules/); you can
268314
select what you want from these. Like Flake8, plugins match by whole letter
269315
sequences (with the special exception of pylint's "PL" shortcut), then you can

0 commit comments

Comments
 (0)