Skip to content

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

Merged
anth-volk merged 7 commits into
mainfrom
ruff-safe-autofixes
Oct 15, 2026
Merged

anth-volk merged 7 commits into
mainfrom
ruff-safe-autofixes

Conversation

@anth-volk

@anth-volk anth-volk commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #764

Same-Repository Draft PR Check

  • This PR is a draft.
  • This PR is from a branch in PolicyEngine/policyengine-sim-api, not a personal fork.

Summary

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

  • uv run ruff check . now runs in the lint job on the whole repository, with ruff pinned to 0.15.22.
  • New rule families: ruff.toml adds FLY, FURB, I, PIE, PYI, RET, RSE, UP and W. Every finding is fixed (about 270, mostly import sorting and pyupgrade).
  • Fixed by hand:
    • policyengine-fastapi re-exports JWTDecoder through __all__ and drops two unused imports (the 9 F401s noted in Phase 0).
    • Two executor tests build their JSON receipts with json.dumps instead of % formatting.
    • smoke_app uses min() instead of sorted()[0], so ruff 0.16 (FURB192) is clean too.
    • An unused async with ... as resource was removed.
  • scripts/** is linted as Python 3.11. There's no root pyproject.toml, so it was treated as 3.9. 3.11 is the shared rules tool's minimum, and import sorting now matches policyengine-api byte for byte.
  • Registry: sim.quality.ruff-lint moves from advisory to enforced.
  • After rebasing onto main: Count households once: sum the weight column unweighted #767 added a test with unsorted imports. The commit "Sort the imports in the budget output test from Count households once: sum the weight column unweighted #767" fixes it.

Testing

All seven projects' test suites pass:

Project Passed
fastapi 14
contract 145
observability 30
stage12 12
entry 224
gateway 214
executor 733 (23 skipped)
  • ruff check . passes with 0.15.22 and 0.16.8, and the format check is unchanged.
  • Both guards pass. Rules tool unittest: 75 pass. uv.lock files are unchanged.

🤖 Generated with Claude Code

@anth-volk
anth-volk added this pull request to stack #755 October 12, 2026 20:43
@anth-volk anth-volk mentioned this pull request Oct 13, 2026
2 tasks done
@anth-volk
anth-volk force-pushed the ruff-safe-autofixes branch from 191837d to b2b04e9 Compare October 13, 2026 16:56
@anth-volk
anth-volk force-pushed the ruff-safe-autofixes branch 3 times, most recently from 019fe7e to 7fa12ee Compare October 14, 2026 14:47
@anth-volk
anth-volk force-pushed the ruff-safe-autofixes branch from 7fa12ee to c4eb50a Compare October 14, 2026 17:29
@anth-volk
anth-volk force-pushed the ruff-safe-autofixes branch 3 times, most recently from c3fbc7e to 5d74e00 Compare October 14, 2026 20:04
@anth-volk
anth-volk force-pushed the ruff-safe-autofixes branch 2 times, most recently from 00d5abd to e940d49 Compare October 14, 2026 21:43
Base automatically changed from ci-scripts-deploy to main October 14, 2026 21:52
@anth-volk
anth-volk force-pushed the ruff-safe-autofixes branch 2 times, most recently from 6f81c14 to 31adebf Compare October 14, 2026 22:04
anth-volk and others added 7 commits October 15, 2026 17:38
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:
- policyengine-fastapi re-exports JWTDecoder through __all__ and drops two
  unused imports (the 9 F401s noted in Phase 0).
- Two tests build their JSON receipts with json.dumps, not % formatting.
- smoke_app uses min() rather than sorted()[0] (ruff 0.16 FURB192).
scripts/** is linted as Python 3.11, the shared rules tool's minimum, so
import sorting matches policyengine-api byte for byte.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The lint job now runs ruff check . on the whole repository, and
sim.quality.ruff-lint moves from advisory to enforced with the codes
selected in ruff.toml.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#767 landed on main after this stack branched, and its new test imports
are unsorted under the I rule this PR enables.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#743 and #744 landed on main after this stack branched. A dataset-digest
test from #743 and the tomllib import #744 added to the deployment assets
test are unsorted under the I rule this PR enables.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#787 landed on main after this stack branched. It renamed the macro result
fixture module to fixtures.macro_output and added fixtures.fake_object_store,
and those imports in the output builder, Stage 12 artifact and Stage 12
runtime tests are unsorted under the I rule this PR enables.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
#791 landed on main after this stack branched. I, which this PR enables,
flags the import block of its new Stage 12 failure-cause tests; ruff's
safe fix sorts it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@anth-volk
anth-volk force-pushed the ruff-safe-autofixes branch from 31adebf to 87d86ec Compare October 15, 2026 14:06
@anth-volk
anth-volk marked this pull request as ready for review October 15, 2026 15:08
@anth-volk
anth-volk requested a review from a team as a code owner October 15, 2026 15:08
@anth-volk
anth-volk merged commit 9cd0ca3 into main Oct 15, 2026
14 checks passed
@anth-volk
anth-volk deleted the ruff-safe-autofixes branch October 15, 2026 15:08
anth-volk added a commit that referenced this pull request Oct 15, 2026
Brings in #765 (ruff check in CI with the first group of rule
families), #809 (policyengine 6.4.1) and #791 (redacted Stage 12
failure cause).

Conflicts:
- auth.py: kept this branch's Callable and Literal imports and sorted
  the stdlib import block the way main's newly enabled I rule expects.
- docs/generated/rules.md: regenerated with python -m scripts.rules
  render from the auto-merged registry, which holds main's enforced
  sim.quality.ruff-lint and this branch's
  sim.deploy.permission-enforcement-wired (34 of 48 rules blocking).

ruff check . passes under main's ruff.toml with ruff 0.15.22, so this
branch's own code needed no further changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
anth-volk added a commit that referenced this pull request Oct 15, 2026
Resolved import-only conflicts in v2_app and two Stage 12 test modules,
then applied the newly enforced ruff rules (import sorting, pyupgrade)
to the files this branch adds.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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