|
| 1 | +# Configuration: https://docs.astral.sh/ruff/configuration/ |
| 2 | +# Settings: https://docs.astral.sh/ruff/settings/ |
| 3 | +# Rules definitions: https://docs.astral.sh/ruff/rules/ |
| 4 | + |
| 5 | +# Match our Black formatting |
| 6 | +target-version = "py313" |
| 7 | + |
| 8 | +[lint] |
| 9 | +select = [ |
| 10 | + "B", # flake8-bugbear |
| 11 | + "E", # pycodestyle errors |
| 12 | + "F", # pyflakes |
| 13 | + "FLY", # flynt |
| 14 | + "I", # isort |
| 15 | + "N", # pep8-naming |
| 16 | + "NPY", # numpy-specific |
| 17 | + "PERF", # performance |
| 18 | + "PL", # Pylint |
| 19 | + "S", # flake8-bandit (security checks) |
| 20 | + "UP", # pyupgrade (pre-commit hook for pyupgrade should fix most) |
| 21 | + "W", # pycodestyle warnings |
| 22 | +] |
| 23 | +# TODO consider SLF (SLF001, private-member-access) |
| 24 | +# TODO consider TRY ruleset |
| 25 | +# mishandling exceptions, like raising broad `Exception` or including a `return` inside `try` blocks. |
| 26 | + |
| 27 | +# Ignore certain rules across the entire repo |
| 28 | +# (after selecting a set of rules like 'E', ignore subsets of those rules here) |
| 29 | +ignore = [ |
| 30 | + # Selected ignore rules |
| 31 | + "E203", # whitespace-before-punctuation |
| 32 | + "F401", # unused-import (pycln will remove these) |
| 33 | + "F811", # redefined-while-unused |
| 34 | + "PLR0913", # too-many-arguments |
| 35 | + "S101", # assert (usage of the assert statement) |
| 36 | + "S113", # request-without-timeout |
| 37 | + "S602", # subprocess-popen-with-shell-equals-true |
| 38 | + "S603", # subprocess-without-shell-equals-true |
| 39 | + "S607", # start-process-with-partial-path |
| 40 | + "S608", # hardcoded-sql-expression |
| 41 | + # Rules recommended to avoid when using Ruff formatter |
| 42 | + "COM812", # missing-trailing-comma |
| 43 | + "COM819", # prohibited-trailing-comma |
| 44 | + "D206", # indent-with-spaces |
| 45 | + "D300", # triple-single-quotes |
| 46 | + "E111", # indentation-with-invalid-multiple |
| 47 | + "E114", # indentation-with-invalid-multiple-comment |
| 48 | + "E117", # over-indented |
| 49 | + "ISC001", # single-line-implicit-string-concatenation |
| 50 | + "ISC002", # multi-line-implicit-string-concatenation |
| 51 | + "Q000", # bad-quotes-inline-string |
| 52 | + "Q001", # bad-quotes-multiline-string |
| 53 | + "Q002", # bad-quotes-docstring |
| 54 | + "Q003", # avoidable-escaped-quote |
| 55 | + "W191", # tab-indentation |
| 56 | +] |
| 57 | + |
| 58 | +# Attempt to auto-fix if running `ruff check . --fix` |
| 59 | +fixable = [ |
| 60 | + "I", # isort |
| 61 | + "UP", # pyupgrade |
| 62 | +] |
| 63 | + |
| 64 | +# Avoid fixing these when using `--fix`. |
| 65 | +unfixable = [ |
| 66 | + "B", # flake8-bugbear |
| 67 | +] |
| 68 | + |
| 69 | +# Skip checking any files matching glob patterns: |
| 70 | +# exclude = ["**/test/**/*.*"] |
| 71 | + |
| 72 | +# Exclude rules from being applied to files matching glob patterns: |
| 73 | +[lint.per-file-ignores] |
| 74 | +"**/*test.py" = [ |
| 75 | + "F811", # redefined-while-unused |
| 76 | + "N", # pep8-naming |
| 77 | + "PLR2004", # magic-value-comparison |
| 78 | +] |
0 commit comments