refactor: enable all stable ruff rules - #134
Conversation
|
Important Review skippedToo many files! This PR contains 118 files, which is 18 over the limit of 100. To get a review, narrow the scope: Upgrade to a paid plan to raise the limit. This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry. ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (118)
You can disable this status message by setting the Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #134 +/- ##
===========================================
+ Coverage 99.87% 100.00% +0.12%
===========================================
Files 140 139 -1
Lines 13241 13509 +268
Branches 790 785 -5
===========================================
+ Hits 13224 13509 +285
+ Misses 12 0 -12
+ Partials 5 0 -5 ☔ View full report in Codecov by Harness. |
…M102
Ruff's EM101/EM102 auto-fix split single-line `raise Xxx("msg") # pragma: no cover` into two lines, leaving the `msg = ...` assignment without coverage exclusion. Merge them back to single-line form with `# noqa: EM101, TRY003 # pragma: no cover` to keep both ruff and coverage happy.
PR #134 enabled all stable ruff rules. Resolve the resulting findings by fixing the underlying structure rather than suppressing, except where a real fix is disproportional. PLR0917 (too many positional arguments): - service-status state store + protocol now take the ServiceStatusMessage object instead of unpacking five message fields; the monitor stops hand-unpacking messages at every call site. - BriefingService.__init__ is keyword-only (single production call site). - ServiceStatusMonitor moves the optional language flag to keyword-only. - The parametrized any-llm factory test uses keyword-only parameters. - _briefing_service keeps positional form (37 call sites) and is the only justified PLR0917 suppression. ISC004: wrap implicitly concatenated strings in collections with parens. RUF100: drop the two BLE001 noqas that ruff 0.16 no longer needs.
…136) PR #134 enabled all stable ruff rules, which left 13 lint errors on `master` and blocked renovate PR #131 (and every other PR). This fixes them on a fresh branch off `master`. ## Findings | Rule | Count | Resolution | | --- | --- | --- | | `PLR0917` too many positional args | 8 | structural fixes (see below) | | `ISC004` unparenthesized string concat in collection | 3 | wrapped in parens | | `RUF100` unused `BLE001` noqa | 2 | removed (ruff 0.16 no longer flags those sites) | ## PLR0917 — fixed by structure, not suppression The feedback on an earlier attempt was to avoid extending `noqa` whitelists where a real fix exists. Each site was evaluated individually: - **service-status state store + protocol** (`observe_service_status_message` / `mark_service_status_message_handled`): the monitor was hand-unpacking five `message` fields into every call. The store now takes the `ServiceStatusMessage` object directly. This removes the unpacking smell, not just the lint. Removes `# noqa: PLR0913` entirely. - **`BriefingService.__init__`**: made keyword-only — the only production call site (`cli.py`) now wires collaborators by name. - **`ServiceStatusMonitor.__init__`**: the optional `language` flag moves to keyword-only (idiomatic for defaulted params); 3 call sites updated. - **`test_factory_normalizes_provider_native_request_errors`**: parametrize dimensions moved to keyword-only (pytest 9 supports this). - **`_briefing_service` test factory**: **the only `PLR0917` suppression kept**, with an inline justification. It mirrors `BriefingService` but has 37 positional call sites across `test_service.py`; forcing keyword-only there would be disproportional churn with no structural benefit. ## Infra Also bumps the prek ruff hook to v0.16.0 to match the uv lockfile, so local hooks and CI agree on whether `BLE001` fires (the root cause of the `RUF100` findings). ## Verification - `uv run ruff check .` — clean - `prek run --all-files` — clean - `uv run pytest --cov --cov-branch` — 1338 passed; coverage unaffected (pure refactor, no tests removed) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **Refactor** * Improved service-status message handling for more consistent validation and persistence. * Standardized service configuration and language settings to reduce setup ambiguity. * Preserved existing briefing, notification, geocoding, and service-status behavior. * **Chores** * Updated development linting tools and streamlined code quality checks. * **Tests** * Refined automated coverage to reflect the updated service and message-handling interfaces. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
Summary
Enable all stable ruff rules (
select = ["ALL"]) and resolve 4070 errors to zero.Changes
Configuration (
pyproject.toml):select = ["ALL"]tests/**per-file-ignores for rules fundamentally incompatible with test code (S101, ANN*, ARG*, PLR2004, RUF001, SLF001, PLC0415, FBT*, D100-D107 only — D family narrowed from blanket"D"exemption)Application code fixes:
TYPE_CHECKING(TC001-003)Warning→WeatherWarningto avoid shadowing builtin (A001/A004)__enter__return types →Self(PYI034)returnstatements moved toelse:blocks (TRY300)# noqafor intentional patterns (BLE001, TRY004, S603/S607/S608, TRY400, S311, PLR2004, TRY301, PLR091x, C901)Test code fixes:
_FAKE_TOKENconstant extraction + per-line# noqa: S106parametrizevalues normalized (PT007)Verification
ruff check .✅ruff format --check .✅prek run --all-files✅pytest --cov --cov-branch --cov-report=xml✅ 1337 passed