fix(lint): E402 is on — the ignore meant for main.py had let 11 late imports in elsewhere
ruff.toml ignored E402 everywhere for main.py's logging setup. Measured: 28 hits, of which 11 had nothing to do with it — runner.py's logger line between its imports, models.py importing canonical_email mid-file, a test constant above its imports, and main.py's own third-party and mimetypes imports. Those are moved up. What stays after configure_logging in main.py is marked per statement (noqa E402, logging is configured first), its comment now says why the order matters (a line logged while importing, not the logger's creation). The register row goes, the ruff key whitelist loses ignore, and a late import is red again. The T20 comment counts the third deliberate print (scripts/e2e_seed.py).
This commit is contained in:
+8
-7
@@ -1,7 +1,8 @@
|
||||
# Ruff config for the Siftlode backend. Keeps ruff's default rule set (E4/E7/E9 + F = the
|
||||
# high-signal pyflakes/pycodestyle checks that catch real dead code + bugs), but ignores E402:
|
||||
# a handful of modules (e.g. main.py) deliberately run setup — logging config, sys.path — before
|
||||
# importing route modules, so "module import not at top of file" is intentional there, not cruft.
|
||||
# high-signal pyflakes/pycodestyle checks that catch real dead code + bugs), all of it on. E402 was
|
||||
# ignored for main.py's logging setup; the ignore had let 11 incidental late imports in elsewhere
|
||||
# (E32 review), so it is on now and main.py marks each deliberate one (`# noqa: E402 — <why>`).
|
||||
# `scripts/e2e_seed.py` edits `sys.path` before its imports, which E402 itself allows.
|
||||
#
|
||||
# line-length 100 (ruff's default is 88): matches the frontend prettier printWidth so both halves of
|
||||
# the repo wrap at the same width, and it's the width `ruff format` enforces (gated via
|
||||
@@ -17,9 +18,10 @@ target-version = "py312"
|
||||
# LOG — stdlib logging misuse (`.warn()`, a logger built by hand, `exc_info` on `.exception`)
|
||||
# G — the call's shape: %-style args, never an f-string the level filter cannot skip, and
|
||||
# never `str(exc)` where `exc_info` would carry the traceback
|
||||
# T20 — `print` instead of a log line. Two deliberate ones remain, each with its `# noqa`
|
||||
# and a why: `downloads/runner.py`'s usage line is for whoever typed it, and
|
||||
# `logsink.py` reports the SINK's own failure, which cannot be logged into the sink.
|
||||
# T20 — `print` instead of a log line. Three deliberate ones remain, each with its `# noqa`
|
||||
# and a why: `downloads/runner.py`'s usage line is for whoever typed it, `logsink.py`
|
||||
# reports the SINK's own failure, which cannot be logged into the sink, and
|
||||
# `scripts/e2e_seed.py` prints the seeded ids for the e2e run that reads them.
|
||||
# TRY400 — `.error()` in an `except` where `.exception()` would keep the traceback
|
||||
# TRY401 — the exception spelled into the message AND passed as `exc_info` (it is in both)
|
||||
# S112 — `except: continue`, the silent swallow inside a loop
|
||||
@@ -45,7 +47,6 @@ target-version = "py312"
|
||||
extend-select = [
|
||||
"LOG", "G", "T20", "TRY400", "TRY401", "S110", "S112", "BLE001", "RUF100", "PLW1510", "B",
|
||||
]
|
||||
ignore = ["E402"]
|
||||
|
||||
[lint.flake8-bugbear]
|
||||
extend-immutable-calls = ["fastapi.Depends", "fastapi.Query"]
|
||||
|
||||
Reference in New Issue
Block a user