chore: Modernize Python tooling (ruff, uv, mypy)#8040
Open
phacops wants to merge 1 commit into
Open
Conversation
Bring the lint/type toolchain up to modern standards and clear the debt the upgrades surface. Ruff: expand the lint set from E/F/W/I to add B (bugbear), UP (pyupgrade), C4 (comprehensions), SIM (simplify) and RET (return), enforce E402, and set isort known-first-party. Apply the resulting ~5,100 fixes (typing modernization, comprehension/return cleanups). PEP 695 native-generic rules (UP040/046/047) are deliberately left ignored - mass-migrating generics under custom metaclasses is a separate, risky change. mypy: upgrade 1.1.1 -> 2.1.0 (mypyc-compiled). The jump surfaced 110 pre-existing errors that 1.1.1 missed; all are fixed (41 redundant casts plus arg-type/attr-defined/type-arg across ~25 files). Resolve the duplicate-conftest collision and align the pre-commit mypy hook's excludes with the config so 'mypy .' and pre-commit check the same files. type: ignore: reduce from 159 to 62 by fixing the underlying types; every remaining suppression is now error-code-specific (zero bare, zero unused). Config: move pytest config from setup.cfg (deleted) into pyproject.toml, add Makefile lint/lint-check/typecheck targets, and remove the obsolete no-op tests/utils/conftest.py. Several latent bugs were caught in the process: missing test assertions, a profile-events call missing an argument, and DeletionSettings constructed with positional args in the wrong fields. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Agent transcript: https://claudescope.sentry.dev/share/DD3ny1HpZNB23VAt3zOpAjqDbo3ncHFJvSHXcXKnr-Y
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Modernizes the Python lint/type toolchain and clears the debt the upgrades surface. Functionally a no-op for production code, but it expands static-analysis coverage and upgrades mypy across a major version. Reviewable as: tooling/config diffs (small) + a large mechanical sweep (autofixes) + targeted type fixes.
Ruff: expanded rule set
Adds
B,UP,C4,SIM,RETto the existingE/F/W/I, enforcesE402(was blanket-ignored, which hid misplaced imports), and sets isortknown-first-party. The ~5,100 resulting fixes are mostly mechanical typing modernization (Optional[X]→X | None,List→list). PEP 695 native-generic rules (UP040/046/047) are deliberately left ignored — mass-migrating generics under custom metaclasses is a separate, riskier change.mypy: 1.1.1 → 2.1.0
A three-year version jump (mypyc-compiled). It surfaced 110 pre-existing errors that 1.1.1 silently missed — all fixed (41 redundant casts plus
arg-type/attr-defined/type-argacross ~25 files). Also resolves the duplicate-conftestcollision somypy .runs clean, and aligns the pre-commit mypy hook's excludes with the config (pre-commit passes filenames explicitly, which bypassed mypy's ownexclude).type: ignore: 159 → 62
The reduction comes from fixing the underlying types, not suppressing. Every remaining ignore is now error-code-specific (
# type: ignore[arg-type]) — zero bare, zero unused.Config & housekeeping
pytest config moves from
setup.cfg(deleted) intopyproject.toml;Makefilegainslint/lint-check/typechecktargets; the obsolete no-optests/utils/conftest.py(overriding a fixture that no longer exists) is removed.The stricter analysis also caught a few latent bugs, now fixed: test assertions that never asserted (bare comparisons), a
profile_eventscall missing itsclusterless_modeargument, andDeletionSettingsconstructed with positional args landing in the wrong fields.Agent transcript: https://claudescope.sentry.dev/share/1JX1N9F7KUr3uBfmc57-ubJQKrY3XFoIPufiNWeh91w