Require Python 3.10 and use the annotations it provides - #94
Merged
Conversation
Python 3.9 reached end of life in October 2025, and it was the only reason the package carried a typing_extensions dependency and a try/except import fallback in cuvis/doc.py. CI has been running 3.11 alone for a while, so nothing in the workflow changes. With the floor raised, the annotations are restated in the forms 3.10 provides: Union and Optional become A | B and A | None, and Tuple, FrozenSet, Sequence, Callable and Awaitable come from builtins and collections.abc. Applied with ruff's pyupgrade rules rather than by hand. ImageData.__getitem__ keeps Union on purpose, because its member list holds a forward reference and | cannot join a type to a string at runtime. The migration also surfaced a latent bug. register_ready_callback was annotated Callable[None, Awaitable[None]], which is not a valid Callable form; typing.Callable never checked, collections.abc.Callable does. It is now Callable[[], Awaitable[None]], matching the no-argument call the implementation makes.
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.
What
requires-pythonfrom>=3.9to>=3.10, drops thetyping_extensionsdependency and the 3.9 classifier, and moves ruff totarget-version = "py310".try/except ImportErrorfallback incuvis/doc.py;ParamSpecandTypeAliasare intypingfrom 3.10.Union[A, B]andOptional[A]toA | BandA | None, andTuple,FrozenSet,Sequence,Callable,Awaitabletobuiltinsandcollections.abc.register_ready_callback, whosecallbackparameter was annotatedCallable[None, Awaitable[None]].Why
typing_extensionsdependency and the import fallback. CI already runs 3.11 alone, so no workflow changes.Callable[None, ...]was never a validCallableform.typing.Callabledid not validate it;collections.abc.Callabledoes and raisesTypeErrorat import, so the migration surfaced it. The implementation callscallback()with no arguments, soCallable[[], Awaitable[None]]is what it always meant.Pitfalls
ruff check --select UP006,UP007,UP035,UP045 --fix, not by hand.ImageData.__getitem__deliberately keepsUnion. Its member list contains a forward reference, and|cannot join a type to a string at runtime. Ruff declines to rewrite it for the same reason.Verification
ruff check,ruff format --checkandscripts/check_changelog.pyclean.