Skip to content

refactor: enable all stable ruff rules - #134

Merged
IceCodeNew merged 2 commits into
masterfrom
lint
Aug 3, 2026
Merged

refactor: enable all stable ruff rules#134
IceCodeNew merged 2 commits into
masterfrom
lint

Conversation

@IceCodeNew

Copy link
Copy Markdown
Owner

Summary

Enable all stable ruff rules (select = ["ALL"]) and resolve 4070 errors to zero.

Changes

Configuration (pyproject.toml):

  • Switch from narrow rule selection to select = ["ALL"]
  • Targeted 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:

  • Relative → absolute imports (TID252)
  • Type-only imports moved under TYPE_CHECKING (TC001-003)
  • Exception messages extracted to variables (EM101/EM102/TRY003)
  • WarningWeatherWarning to avoid shadowing builtin (A001/A004)
  • Boolean positional args converted to keyword-only (FBT001)
  • __enter__ return types → Self (PYI034)
  • Function-level imports hoisted to top-level (PLC0415)
  • return statements moved to else: blocks (TRY300)
  • Per-line # noqa for intentional patterns (BLE001, TRY004, S603/S607/S608, TRY400, S311, PLR2004, TRY301, PLR091x, C901)

Test code fixes:

  • _FAKE_TOKEN constant extraction + per-line # noqa: S106
  • parametrize values normalized (PT007)
  • Composite assertions split (PT018)
  • Regex metacharacters escaped (RUF043)

Verification

  • ruff check .
  • ruff format --check .
  • prek run --all-files
  • pytest --cov --cov-branch --cov-report=xml ✅ 1337 passed

@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown

Important

Review skipped

Too many files!

This PR contains 118 files, which is 18 over the limit of 100.

To get a review, narrow the scope:
• coderabbit review --committed # exclude uncommitted changes
• coderabbit review --dir # limit to a subdirectory
• coderabbit review --base # compare against a closer base

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 configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 619ca384-cd6a-4ae3-aa8c-e16cafb0226d

📥 Commits

Reviewing files that changed from the base of the PR and between 73095c8 and 0333c81.

📒 Files selected for processing (118)
  • pyproject.toml
  • tests/test_air_quality.py
  • tests/test_any_llm_provider.py
  • tests/test_api_client.py
  • tests/test_bark_publisher.py
  • tests/test_capabilities.py
  • tests/test_cli.py
  • tests/test_collection.py
  • tests/test_config.py
  • tests/test_geocoding.py
  • tests/test_http_headers.py
  • tests/test_languages.py
  • tests/test_llm.py
  • tests/test_llm_fallback.py
  • tests/test_notification_decision.py
  • tests/test_persistence_locking.py
  • tests/test_prompts.py
  • tests/test_publishers.py
  • tests/test_reference_data.py
  • tests/test_regional_weather.py
  • tests/test_render.py
  • tests/test_service.py
  • tests/test_service_status.py
  • tests/test_sources.py
  • tests/test_state.py
  • tests/test_summarization.py
  • tests/test_weather_context.py
  • weather_briefing/air_quality.py
  • weather_briefing/allergen.py
  • weather_briefing/api_client.py
  • weather_briefing/application/briefing_settings.py
  • weather_briefing/application/briefing_validation.py
  • weather_briefing/application/collection.py
  • weather_briefing/application/context_history.py
  • weather_briefing/application/notification.py
  • weather_briefing/application/payloads.py
  • weather_briefing/application/summarization.py
  • weather_briefing/capabilities.py
  • weather_briefing/cli.py
  • weather_briefing/command_parser.py
  • weather_briefing/composition/delivery.py
  • weather_briefing/composition/llm.py
  • weather_briefing/composition/notifications.py
  • weather_briefing/composition/weather.py
  • weather_briefing/config/environment.py
  • weather_briefing/config/feeds.py
  • weather_briefing/config/files.py
  • weather_briefing/config/http_headers.py
  • weather_briefing/config/locations.py
  • weather_briefing/config/settings.py
  • weather_briefing/content_cleaners.py
  • weather_briefing/data/prompts.py
  • weather_briefing/data/resources.py
  • weather_briefing/delivery/bark.py
  • weather_briefing/delivery/bark_crypto.py
  • weather_briefing/delivery/bark_renderer.py
  • weather_briefing/delivery/base.py
  • weather_briefing/delivery/plain_renderer.py
  • weather_briefing/delivery/rendering.py
  • weather_briefing/delivery/stdout.py
  • weather_briefing/delivery/telegram.py
  • weather_briefing/delivery/telegram_reference.py
  • weather_briefing/delivery/telegram_renderer.py
  • weather_briefing/geocoding/base.py
  • weather_briefing/geocoding/composition.py
  • weather_briefing/geocoding/matching.py
  • weather_briefing/geocoding/nominatim.py
  • weather_briefing/geocoding/open_meteo.py
  • weather_briefing/geocoding/resolver.py
  • weather_briefing/languages.py
  • weather_briefing/llm/any_llm.py
  • weather_briefing/llm/any_llm_transport.py
  • weather_briefing/llm/fallback.py
  • weather_briefing/llm/lazy.py
  • weather_briefing/llm/result.py
  • weather_briefing/llm/schema.py
  • weather_briefing/localization.py
  • weather_briefing/models.py
  • weather_briefing/notification_decision/core.py
  • weather_briefing/notification_decision/policies.py
  • weather_briefing/persistence/content.py
  • weather_briefing/persistence/context.py
  • weather_briefing/persistence/diagnostics.py
  • weather_briefing/persistence/health.py
  • weather_briefing/persistence/locking.py
  • weather_briefing/persistence/schema.py
  • weather_briefing/persistence/serialization.py
  • weather_briefing/persistence/service_status.py
  • weather_briefing/persistence/store.py
  • weather_briefing/persistence/warnings.py
  • weather_briefing/runtime_diagnostics.py
  • weather_briefing/scheduling.py
  • weather_briefing/service.py
  • weather_briefing/service_status/__init__.py
  • weather_briefing/service_status/collection.py
  • weather_briefing/service_status/composition.py
  • weather_briefing/service_status/feed.py
  • weather_briefing/service_status/models.py
  • weather_briefing/service_status/monitor.py
  • weather_briefing/service_status/notification.py
  • weather_briefing/service_status/providers/_surface.py
  • weather_briefing/service_status/providers/anthropic.py
  • weather_briefing/service_status/providers/deepseek.py
  • weather_briefing/service_status/providers/kimi.py
  • weather_briefing/service_status/providers/openai.py
  • weather_briefing/service_status/statuspage.py
  • weather_briefing/sources.py
  • weather_briefing/time_utils.py
  • weather_briefing/weather/base.py
  • weather_briefing/weather/composition.py
  • weather_briefing/weather/documents.py
  • weather_briefing/weather/jma.py
  • weather_briefing/weather/nea.py
  • weather_briefing/weather/open_meteo.py
  • weather_briefing/weather/open_meteo_parsing.py
  • weather_briefing/weather/open_meteo_reference.py
  • weather_briefing/weather/qweather.py
  • weather_briefing/weather/qweather_parsing.py

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (f87b732) to head (0333c81).
⚠️ Report is 5 commits behind head on master.
✅ All tests successful. No failed tests found.

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.
📢 Have feedback on the report? Share it here.

…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.
@IceCodeNew
IceCodeNew merged commit 3bfa7ad into master Aug 3, 2026
15 checks passed
@IceCodeNew
IceCodeNew deleted the lint branch August 3, 2026 05:09
IceCodeNew added a commit that referenced this pull request Aug 4, 2026
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.
IceCodeNew added a commit that referenced this pull request Aug 4, 2026
…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 -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant