Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #272 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 14 14
Lines 1416 1382 -34
Branches 175 170 -5
=========================================
- Hits 1416 1382 -34 Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
c754ae3 to
49f6ec7
Compare
There was a problem hiding this comment.
Pull request overview
This PR drops Python 3.9 support across the project, updating packaging metadata, CI matrices, runtime guards, and simplifying code paths/tests that previously branched on 3.9 behavior.
Changes:
- Raise minimum supported Python to 3.10 (packaging, tooling, CI, and C-extension compile-time checks).
- Replace 3.9 compatibility conditionals with 3.10+ features (e.g.,
zip(..., strict=...), PEP 604 unions, dataclass slots/kw-only args). - Update tests and docs to align with the new minimum version and stricter iteration invariants.
Reviewed changes
Copilot reviewed 30 out of 30 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| pyproject.toml | Bumps requires-python to 3.10; updates tooling targets (mypy/pylint/ruff) and classifiers. |
| .github/workflows/tests.yml | Removes Python 3.9 from the test matrix. |
| .github/workflows/tests-with-pydebug.yml | Removes Python 3.9 from Py_DEBUG test matrix and related excludes. |
| .github/workflows/build.yml | Updates build/test Python ranges and removes 3.9 entries/excludes. |
| include/optree/pymacros.h | Raises compile-time minimum Python version check to 3.10. |
| README.md | Updates stated minimum Python version to 3.10+. |
| CONTRIBUTING.md | Updates cibuildwheel example from cp39 to cp310. |
| CHANGELOG.md | Documents dropping Python 3.9 support. |
| optree/utils.py | Uses 3.10+ zip(..., strict=True) in safe_zip; adjusts Callable import source. |
| optree/typing.py | Moves to 3.10+ typing constructs (ParamSpec, TypeAlias, ` |
| optree/registry.py | Removes 3.9 conditionals; uses slots=True dataclasses; simplifies errors. |
| optree/accessors.py | Removes 3.9 conditionals; uses slots=True dataclasses; adds type ignores for __slots__. |
| optree/pytree.py | Uses typing.ParamSpec (3.10+) instead of typing_extensions. |
| optree/ops.py | Uses zip(..., strict=True) in transpose/path logic and adjusts Callable import source. |
| optree/dataclasses.py | Removes 3.9-only branches and always passes 3.10+ dataclass kwargs; uses strict zip in unflatten. |
| optree/functools.py | Moves Callable typing import under TYPE_CHECKING. |
| optree/integrations/torch.py | Moves TypeAlias to typing and shifts Callable import under TYPE_CHECKING. |
| optree/integrations/numpy.py | Same as torch integration changes for typing imports. |
| optree/integrations/jax.py | Same as torch integration changes for typing imports. |
| docs/source/conf.py | Updates Union-type detection comment and adds # noqa: UP007. |
| tests/test_typing.py | Removes 3.9/3.10 branching; adds explicit ` |
| tests/test_treespec.py | Uses zip(..., strict=True) in many places; uses explicit strict=False in transform test. |
| tests/test_registry.py | Removes 3.9/PyPy-conditional branches; uses zip(..., strict=True) in unflatten. |
| tests/test_ops.py | Removes 3.9 Windows debug skip; uses zip(..., strict=True) in multiple assertions. |
| tests/test_dataclasses.py | Removes 3.9 branches; directly tests 3.10+ dataclass parameters. |
| tests/test_accessors.py | Uses zip(..., strict=True) in accessor comparisons. |
| tests/helpers.py | Uses zip(..., strict=True) in parametrization and accessor equality helper. |
| tests/integrations/test_torch.py | Uses zip(..., strict=True) when comparing reconstructed leaves. |
| tests/integrations/test_numpy.py | Uses zip(..., strict=True) when comparing reconstructed leaves. |
| tests/integrations/test_jax.py | Uses zip(..., strict=True) when comparing reconstructed leaves. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code |
Description
Describe your changes in detail.
Python 3.9 is EOL on 31 Oct 2025.
Xref:
Motivation and Context
Why is this change required? What problem does it solve?
If it fixes an open issue, please link to the issue here.
You can use the syntax
close #15213if this solves the issue #15213Types of changes
What types of changes does your code introduce? Put an
xin all the boxes that apply:Checklist
Go over all the following points, and put an
xin all the boxes that apply.If you are unsure about any of these, don't hesitate to ask. We are here to help!
make format. (required)make lint. (required)make testpass. (required)