|
| 1 | +# Ruff configuration — see .github/workflows/ci.yml for how this runs in CI. |
| 2 | +# |
| 3 | +# Scope is deliberately narrow: syntax errors and Pyflakes (undefined names, |
| 4 | +# unused imports, etc.) rather than Ruff's full default rule set (which also |
| 5 | +# pulls in pyupgrade, flake8-bugbear, flake8-datetimez and a dozen other |
| 6 | +# plugins). Turning all of that on for a codebase that has never been linted |
| 7 | +# produces hundreds of pre-existing findings unrelated to any given PR, which |
| 8 | +# makes the check noise rather than a real gate. Start narrow and correct; |
| 9 | +# widen deliberately later if the team wants stricter style enforcement. |
| 10 | +target-version = "py311" |
| 11 | + |
| 12 | +[lint] |
| 13 | +# E4/E7/E9 = pycodestyle error subset (real mistakes, not style nits). |
| 14 | +# F = Pyflakes (undefined names, unused imports, etc). |
| 15 | +select = ["E4", "E7", "E9", "F"] |
| 16 | + |
| 17 | +[lint.per-file-ignores] |
| 18 | +# Models are imported here purely so Alembic's autogenerate can discover them |
| 19 | +# via `Base.metadata` — the names are never referenced directly in this file. |
| 20 | +"app/models/__init__.py" = ["F401"] |
| 21 | + |
| 22 | +# SQLAlchemy 2.0 `Mapped["ClassName"]` relationship annotations use forward |
| 23 | +# references as plain strings resolved by SQLAlchemy at mapper-configuration |
| 24 | +# time, not by Python's own name resolution — Pyflakes has no way to know |
| 25 | +# that and flags them as undefined names. Known false positive; see |
| 26 | +# https://github.com/astral-sh/ruff/issues/8811. |
| 27 | +"app/models/*.py" = ["F821"] |
| 28 | + |
| 29 | +# alembic/env.py intentionally star-imports every model so Alembic's |
| 30 | +# autogenerate can see them via Base.metadata; Pyflakes can't verify names |
| 31 | +# from a star import. |
| 32 | +"alembic/env.py" = ["F403"] |
| 33 | + |
| 34 | +# Historical, already-applied migrations are immutable — don't hand-edit a |
| 35 | +# shipped revision just to satisfy a linter added long after it merged. |
| 36 | +"alembic/versions/*.py" = ["F401"] |
| 37 | + |
| 38 | +# conftest.py must set POSTGRES_*/RABBITMQ_* environment variables BEFORE |
| 39 | +# importing app.config, since pydantic-settings reads env vars at class-body |
| 40 | +# time. That requires imports after statements — intentional, not an oversight. |
| 41 | +"tests/conftest.py" = ["E402"] |
0 commit comments