fix(ci): pin ruff — an unpinned linter broke CI with no code change - #36
Merged
Conversation
CI has been red since 2026-07-21 on every branch, including ones that touch no Python at all. Nothing in the repo changed: ruff is installed as ruff>=0.1.0, so CI resolves whatever is newest, and 0.16.0 reports 1903 errors here — mostly UP006/UP045 typing modernisation that 0.14.x did not raise under the same target-version = "py39". Verified by running 0.16.0 against main: 1903 errors. 0.14.11 on the same tree: clean. The tree is fine; the linter moved. black is already pinned exactly, with the comment "Pin version for consistent formatting". A linter needs that guarantee for the same reason and did not have it. This applies the repo's own convention to ruff. Deliberately NOT fixing the 1903 findings. Adopting 0.16.0's rules is a real change worth making on purpose, in a PR that can be reviewed as such — not absorbed silently to turn CI green.
VickyXAI
added a commit
that referenced
this pull request
Jul 28, 2026
….9 (#39) * chore: adopt ruff 0.16 — 1631 typing fixes, verified against Python 3.9 #36 pinned ruff at 0.14.11 because 0.16 reported 1903 findings and turning CI green by absorbing them silently would have been the wrong move. This is that change, made on purpose. The trap was real. 1529 of the fixes are classified UNSAFE, and this package declares requires-python = ">=3.9" — PEP 604 (`X | None`) is a runtime error there. Applying them blind would have broken the published 3.9 support while every test passed on 3.13. What made them safe was the rule ruff was already pointing at: FA100, 341 occurrences of "this file could use `from __future__ import annotations`". With that import every annotation is a string, so PEP 585/604 syntax never executes. Added to the 16 files that lacked it, THEN the fixes applied. Verified rather than assumed: - grepped for union syntax outside annotations — cast(), TypeAlias, isinstance(). None. Every union is in an annotation, where laziness applies. - compiled the whole package under a real Python 3.9.21. Exit 0. - 436 tests pass. types.py is pydantic, which resolves string annotations, so that one was checked by import as well as by suite. The 227 remaining findings are behaviour, not typing, and are ignored with a written reason each rather than silently: 157 blind excepts where some are deliberate best-effort paths, 54 try/except/pass, and 4 naive datetimes in cache/tx_log/wallet. That last one is worth doing — a transaction log without a timezone is genuinely ambiguous — but it changes recorded values and needs its own migration thought. Two one-offs got a targeted fix instead of a blanket ignore: the example file is now executable, and `x != x` carries a noqa saying it is the NaN test, which it is. * fix: keep types.py on typing constructs — pydantic evaluates annotations at runtime CI on Python 3.9 caught what my local check did not: TypeError: Unable to evaluate type annotation 'str | None' `from __future__ import annotations` makes annotations strings, which is what made the PEP 604 rewrite safe everywhere else. pydantic then EVALUATES those strings to build each model, and on 3.9 evaluating "str | None" is a TypeError regardless of how it got there. My verification was wrong in a specific way worth naming: I ran compileall under a real 3.9 and it passed, because parsing is not the constraint — evaluation is. Nothing that only parses the file can catch this. types.py goes back to typing.Optional/List with no future import, and carries a per-file ruff ignore saying why. The other 15 files are unaffected: they have no runtime annotation reader. Now verified by running, not compiling: a real 3.9.21 venv with the package installed passes 339 tests, and 3.13 passes 436. --------- Co-authored-by: 1bcMax <viewitter@gmail.com>
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.
The symptom
CI has been failing since 2026-07-21 on every branch — including branches that touch no Python at all. I hit it on a docs-only PR (#35) whose entire diff is a README, a workflow file and two new non-Python files.
The cause
"ruff>=0.1.0",CI runs
pip install -e ".[dev]", so it resolves whatever ruff is newest at that moment. ruff 0.16.0 reports 1903 errors on this tree — mostlyUP006/UP045typing modernisation that 0.14.x did not raise under the sametarget-version = "py39".Verified, not assumed
Run against
main, no PR changes involved:All checks passed!The tree is fine. The linter moved.
The fix
This is the repo's own convention, already applied one line above:
A linter needs that guarantee for exactly the same reason and did not have it.
What this deliberately does NOT do
It does not fix the 1903 findings. Adopting 0.16.0's ruleset is a real change — it rewrites type annotations across the package — and deserves a PR that can be reviewed as such, not one absorbed silently to get CI green.
Bumping the pin is now an explicit, reviewable act, which is the point.