|
| 1 | +# Ruff configuration |
| 2 | +# https://docs.astral.sh/ruff/ |
| 3 | + |
| 4 | +line-length = 100 |
| 5 | +target-version = "py312" |
| 6 | + |
| 7 | +# Exclude generated files and caches |
| 8 | +exclude = [ |
| 9 | + ".git", |
| 10 | + ".venv", |
| 11 | + "__pycache__", |
| 12 | + "build", |
| 13 | + "dist", |
| 14 | + "*.egg-info", |
| 15 | + "src/parallax/p2p/proto", # Generated protobuf |
| 16 | + "src/frontend/dist", |
| 17 | + "src/frontend/node_modules", |
| 18 | +] |
| 19 | + |
| 20 | +[lint] |
| 21 | +# Enable pycodestyle (E, W), Pyflakes (F), isort (I), and more |
| 22 | +select = [ |
| 23 | + "E", # pycodestyle errors |
| 24 | + "W", # pycodestyle warnings |
| 25 | + "F", # Pyflakes |
| 26 | + "I", # isort |
| 27 | + "N", # pep8-naming |
| 28 | + "UP", # pyupgrade |
| 29 | + "B", # flake8-bugbear |
| 30 | + "C4", # flake8-comprehensions |
| 31 | + "SIM", # flake8-simplify |
| 32 | + "RUF", # Ruff-specific rules |
| 33 | + "TCH", # flake8-type-checking |
| 34 | + "PTH", # flake8-use-pathlib |
| 35 | + "TID", # flake8-tidy-imports |
| 36 | + "ASYNC", # flake8-async |
| 37 | +] |
| 38 | + |
| 39 | +# Allow autofix for all enabled rules |
| 40 | +fixable = ["ALL"] |
| 41 | +unfixable = [] |
| 42 | + |
| 43 | +# Ignore specific rules |
| 44 | +ignore = [ |
| 45 | + "E501", # Line too long (handled by formatter) |
| 46 | + "B008", # Do not perform function calls in argument defaults |
| 47 | + "C901", # Function is too complex |
| 48 | + "SIM108", # Use ternary operator (sometimes less readable) |
| 49 | +] |
| 50 | + |
| 51 | +# Deferred rules - require code changes, to be addressed in follow-up PRs |
| 52 | +# TODO: Remove from extend-ignore as issues are fixed |
| 53 | +extend-ignore = [ |
| 54 | + # === Require refactoring === |
| 55 | + "PTH", # pathlib migration - significant refactor |
| 56 | + "TCH", # TYPE_CHECKING imports - requires careful review |
| 57 | + "UP035", # typing.List -> list - touches many files |
| 58 | + "B006", # mutable-argument-default - needs case-by-case review |
| 59 | + "B023", # function-uses-loop-variable - needs case-by-case review |
| 60 | + "E402", # module-import-not-at-top - sometimes intentional for side effects |
| 61 | + |
| 62 | + # === Stylistic - sometimes the "violation" is clearer === |
| 63 | + "SIM102", # nested if statements |
| 64 | + "SIM105", # suppressible exception (contextlib.suppress) |
| 65 | + "SIM115", # open-file-with-context-handler |
| 66 | + "SIM117", # nested with statements |
| 67 | + "SIM118", # key in dict.keys() -> key in dict |
| 68 | + "E731", # lambda assignment |
| 69 | + |
| 70 | + # === Naming - often intentional (math notation, DSL) === |
| 71 | + "N806", # non-lowercase variable in function |
| 72 | + "N803", # invalid argument name |
| 73 | + "N802", # invalid function name |
| 74 | + "E741", # ambiguous variable name (l, O, I) |
| 75 | + |
| 76 | + # === Low priority / noisy === |
| 77 | + "RUF059", # unused unpacked variable |
| 78 | + "RUF013", # implicit-optional (None default without Optional type) |
| 79 | + "RUF002", # ambiguous unicode in docstring |
| 80 | + "RUF003", # ambiguous unicode in comment |
| 81 | + "RUF012", # mutable class default (needs ClassVar annotation) |
| 82 | + "B018", # useless expression - sometimes intentional for side effects |
| 83 | + "B904", # raise-without-from - needs case-by-case review |
| 84 | + "ASYNC109", # async timeout parameter - needs careful review |
| 85 | +] |
| 86 | + |
| 87 | +[lint.per-file-ignores] |
| 88 | +# Ignore imports in __init__.py files |
| 89 | +"__init__.py" = ["F401", "F403"] |
| 90 | +# Test files can have additional imports |
| 91 | +"tests/**/*.py" = ["F401", "F403", "B018"] |
| 92 | +# Benchmark code has known issues to be fixed separately |
| 93 | +"src/backend/benchmark/**/*.py" = ["F821", "C419"] |
| 94 | + |
| 95 | +[lint.isort] |
| 96 | +known-first-party = ["parallax", "scheduling", "parallax_utils", "backend"] |
| 97 | +combine-as-imports = true |
| 98 | +lines-after-imports = 2 |
| 99 | + |
| 100 | +[format] |
| 101 | +# Use double quotes for strings |
| 102 | +quote-style = "double" |
| 103 | +indent-style = "space" |
| 104 | +skip-magic-trailing-comma = false |
| 105 | +line-ending = "auto" |
| 106 | +docstring-code-format = true |
0 commit comments