chore: make the tree lint-clean under ruff 0.16 - #357
Merged
Conversation
ruff 0.16.0 raised its default rule set from 59 to 413 rules, which turns CI red on `main`: uv.lock still pinned ruff 0.15.20 while pyproject asked for >=0.15.22, so `uv sync` re-resolved to 0.16.0 on every run. Refresh uv.lock (ruff 0.15.20 -> 0.16.0, pytest-cov 7.0.0 -> 7.1.0) so the linter version is pinned again, and clear the 336 resulting diagnostics: - 331 by `ruff check --fix [--unsafe-fixes]` — PEP 585/604 annotations, import sorting, `exit` -> `sys.exit`, `zip(x, x[1:])` -> `pairwise`, PEP 695 type parameters, and similar mechanical rewrites; - the rest by hand: drop the imports and the `T` TypeVar the rewrites orphaned, collapse the nested `if`s ruff could not fix on its own, and replace the `match: Span = match` self-assignment in the replicizer with a distinct loop variable, matching the block above it. RUF012 is silenced for token_patterns.py: the attributes it flags are Enum members holding spaCy token patterns, so the shared-mutable-state concern does not apply, and its `ClassVar` remedy would tell type checkers they are not members at all. Also fix [tool.black]'s `include`, which replaced Black's default file filter with a bare directory pattern — running Black rewrote the JSON, JSONL and CSV corpus fixtures under tests/ as though they were Python. `ruff check`, `ty check ttc` and the 69 tests all pass.
Contributor
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.
mainis currently red:uv.lockpinned ruff 0.15.20 whilepyproject.tomlasked for>=0.15.22, souv syncre-resolved to 0.16.0 on every CI run — and ruff 0.16.0 raised its default rule set from 59 to 413 rules. That surfaced 336 diagnostics.uv.lockrefreshed (ruff 0.15.20 → 0.16.0, pytest-cov 7.0.0 → 7.1.0) so the linter version is pinned again.ruff check --fix --unsafe-fixes: PEP 585/604 annotations, import sorting,exit→sys.exit,zip(x, x[1:])→itertools.pairwise, PEP 695 type parameters.TTypeVar, the four nestedifs ruff had no fix for, and thematch: Span = matchself-assignment in the replicizer (replaced with a distinct loop variable, mirroring theAUTHOR_INSERTIONblock above it).Two judgement calls worth a look:
token_patterns.py. The flagged attributes areEnummembers holding spaCy token patterns. Enum members are singletons, so the shared-mutable-state concern does not apply, and the rule's suggestedClassVarannotation would tell type checkers they are not members at all. Ruff has no Enum exemption for this rule.[tool.black]'sincludewas broken.includereplaces Black's default file filter, so the bare(tests|ttc)directory pattern also matched the JSON/JSONL/CSV corpus fixtures undertests/— running Black rewrote them as if they were Python. Now'/(tests|ttc)/.*\.pyi?$'.ruff check,ty check ttcand all 69 tests pass locally (with--all-groups, i.e. the large models installed).https://claude.ai/code/session_01CqqB29TdAZ183MjNnpkTFD