Skip to content

Run ruff check in CI with the first group of rule families - #3898

Draft
anth-volk wants to merge 2 commits into
ci-scripts-deployfrom
ruff-safe-autofixes
Draft

anth-volk wants to merge 2 commits into
ci-scripts-deployfrom
ruff-safe-autofixes

Conversation

@anth-volk

Copy link
Copy Markdown
Collaborator

Fixes #3897

Summary

Phase 1 step 1.8, group 1 of about 8: safe auto-fixes. Stacked on #3896.

  • ruff check . now runs in CI (lint job in pr.yml and push.yml), using the ruff version pinned in uv.lock.
  • New rule families: select gains FLY, FURB, I, PIE, PYI, RET, RSE, UP and W. Every finding is fixed, with no ratchet. About 620 were ruff's safe fixes (mostly import sorting and pyupgrade); the rest are below.
  • Fixed by hand:
    • Nine v2 model enums move from (str, Enum) to StrEnum (UP042). None is formatted with str() or format(). SQLAlchemy and Pydantic store and serialise them by value, and their repr is unchanged.
    • RET504 and PIE810 fixes reviewed. compare_economic_outputs now returns None explicitly. Two __enter__ methods return Self.
    • Import sorting wrapped two long imports and moved their # type: ignore onto the wrong line. They're back on the import line, and mypy passes.
  • Alembic revisions: they're now exempt from all lint rules (previously F401 only). They must stay exactly as Alembic generates them (api.migration.alembic-autogenerated-only), and the revision tests check that. The hand-written env.py files are still linted.
  • Registry: api.quality.ruff-lint moves from advisory to enforced.

Testing

  • pytest tests/unit tests/contract: 2,358 passed.
  • mypy: no issues (97 files).
  • ruff check . passes with 0.15.12 (pinned) and 0.16.8. ruff format --check . passes.
  • All quality guards pass. Rules tool unittest: 75 pass.

🤖 Generated with Claude Code

anth-volk and others added 2 commits October 13, 2026 00:42
Select FLY, FURB, I, PIE, PYI, RET, RSE, UP and W, and fix every finding:
ruff's safe fixes (import sorting, pyupgrade), then by hand:
- Nine v2 enums move from (str, Enum) to StrEnum; none is formatted with
  str() or format(), and storage and serialisation use the value.
- RET504/PIE810 fixes reviewed; compare_economic_outputs returns None
  explicitly; __enter__ methods return Self.
- Two type: ignore comments moved back onto their import lines after
  import sorting wrapped them.
Alembic revisions are exempt from all lint rules (previously only F401):
they must stay exactly as Alembic generates them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The lint jobs now run ruff check ., and api.quality.ruff-lint moves from
advisory to enforced with the codes selected in pyproject.toml.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@anth-volk
anth-volk added this pull request to stack #3888 October 12, 2026 20:43
@codecov

codecov Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.63602% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.56%. Comparing base (0ff411d) to head (f1871e7).

Files with missing lines Patch % Lines
policyengine_api/services/economy_comparison.py 20.00% 4 Missing and 4 partials ⚠️
policyengine_api/fastapi_routes/dependencies.py 25.00% 2 Missing and 1 partial ⚠️
policyengine_api/services/report_output_service.py 75.00% 1 Missing ⚠️
...engine_api/services/v2/metadata/transformations.py 66.66% 1 Missing ⚠️
policyengine_api/utils/singleton.py 0.00% 1 Missing ⚠️
Additional details and impacted files
@@                Coverage Diff                 @@
##           ci-scripts-deploy    #3898   +/-   ##
==================================================
  Coverage              87.56%   87.56%           
==================================================
  Files                    198      198           
  Lines                  12211    12208    -3     
  Branches                2159     2159           
==================================================
- Hits                   10692    10690    -2     
+ Misses                   922      921    -1     
  Partials                 597      597           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch was successfully deployed

1 active deployment
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.

Run ruff check in CI with the first group of rule families

1 participant