Skip to content

deps!(python): drop Python 3.9 support#272

Open
XuehaiPan wants to merge 1 commit intomainfrom
drop-py39
Open

deps!(python): drop Python 3.9 support#272
XuehaiPan wants to merge 1 commit intomainfrom
drop-py39

Conversation

@XuehaiPan
Copy link
Member

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 #15213 if this solves the issue #15213

  • I have raised an issue to propose this change (required for new features and bug fixes)

Types of changes

What types of changes does your code introduce? Put an x in all the boxes that apply:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds core functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation (update in the documentation)

Checklist

Go over all the following points, and put an x in all the boxes that apply.
If you are unsure about any of these, don't hesitate to ask. We are here to help!

  • I have read the CONTRIBUTION guide. (required)
  • My change requires a change to the documentation.
  • I have updated the tests accordingly. (required for a bug fix or a new feature)
  • I have updated the documentation accordingly.
  • I have reformatted the code using make format. (required)
  • I have checked the code using make lint. (required)
  • I have ensured make test pass. (required)

@XuehaiPan XuehaiPan self-assigned this Mar 12, 2026
@XuehaiPan XuehaiPan added cxx Something related to the CXX source code python Something related to the Python source code dependencies Pull requests that update a dependency file labels Mar 12, 2026
@XuehaiPan XuehaiPan marked this pull request as ready for review March 12, 2026 09:34
@codecov
Copy link

codecov bot commented Mar 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.00%. Comparing base (9ac8d63) to head (66511a6).
✅ All tests successful. No failed tests found.

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     
Flag Coverage Δ
unittests 100.00% <100.00%> (ø)
unittests-cp310-Linux 100.00% <100.00%> (ø)
unittests-cp310-Windows 100.00% <100.00%> (ø)
unittests-cp310-macOS 100.00% <100.00%> (ø)
unittests-cp311-Linux 100.00% <100.00%> (ø)
unittests-cp311-Windows 100.00% <100.00%> (ø)
unittests-cp311-macOS 100.00% <100.00%> (ø)
unittests-cp312-Linux 100.00% <100.00%> (ø)
unittests-cp312-Windows 100.00% <100.00%> (ø)
unittests-cp312-macOS 100.00% <100.00%> (ø)
unittests-cp313-Linux 100.00% <100.00%> (ø)
unittests-cp313-Windows 100.00% <100.00%> (ø)
unittests-cp313-macOS 100.00% <100.00%> (ø)
unittests-cp313t-Linux 100.00% <100.00%> (ø)
unittests-cp313t-Windows 100.00% <100.00%> (ø)
unittests-cp313t-macOS 100.00% <100.00%> (ø)
unittests-cp314-Linux 100.00% <100.00%> (ø)
unittests-cp314-Windows 100.00% <100.00%> (ø)
unittests-cp314-macOS 100.00% <100.00%> (ø)
unittests-cp314t-Linux 100.00% <100.00%> (ø)
unittests-cp314t-Windows 100.00% <100.00%> (ø)
unittests-cp314t-macOS 100.00% <100.00%> (ø)
unittests-cp39-Linux ?
unittests-cp39-Windows ?
unittests-cp39-macOS ?
unittests-pp311-Linux 100.00% <100.00%> (ø)
unittests-pp311-Windows 100.00% <100.00%> (ø)
unittests-pp311-macOS 100.00% <100.00%> (ø)
unittests-pydebug 100.00% <100.00%> (ø)
unittests-pydebug-cp310d-Linux 100.00% <100.00%> (ø)
unittests-pydebug-cp310d-Windows 100.00% <100.00%> (ø)
unittests-pydebug-cp310d-macOS 100.00% <100.00%> (ø)
unittests-pydebug-cp311d-Linux 100.00% <100.00%> (ø)
unittests-pydebug-cp311d-Windows 100.00% <100.00%> (ø)
unittests-pydebug-cp311d-macOS 100.00% <100.00%> (ø)
unittests-pydebug-cp312d-Linux 100.00% <100.00%> (ø)
unittests-pydebug-cp312d-Windows 100.00% <100.00%> (ø)
unittests-pydebug-cp312d-macOS 100.00% <100.00%> (ø)
unittests-pydebug-cp313d-Linux 100.00% <100.00%> (ø)
unittests-pydebug-cp313d-Windows 100.00% <100.00%> (ø)
unittests-pydebug-cp313d-macOS 100.00% <100.00%> (ø)
unittests-pydebug-cp313td-Linux 100.00% <100.00%> (ø)
unittests-pydebug-cp313td-Windows 100.00% <100.00%> (ø)
unittests-pydebug-cp313td-macOS 100.00% <100.00%> (ø)
unittests-pydebug-cp314d-Linux 100.00% <100.00%> (ø)
unittests-pydebug-cp314d-Windows 100.00% <100.00%> (ø)
unittests-pydebug-cp314d-macOS 100.00% <100.00%> (ø)
unittests-pydebug-cp314td-Linux 100.00% <100.00%> (ø)
unittests-pydebug-cp314td-Windows 100.00% <100.00%> (ø)
unittests-pydebug-cp314td-macOS 100.00% <100.00%> (ø)
unittests-pydebug-cp39d-Linux ?
unittests-pydebug-cp39d-Windows ?
unittests-pydebug-cp39d-macOS ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@XuehaiPan XuehaiPan force-pushed the drop-py39 branch 2 times, most recently from c754ae3 to 49f6ec7 Compare March 12, 2026 10:47
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@XuehaiPan
Copy link
Member Author

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cxx Something related to the CXX source code dependencies Pull requests that update a dependency file python Something related to the Python source code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants