Repository navigation
[release/2.15] Raise the minimum Python to 3.11 in the package metadata - #202273
Conversation
Same change as pytorch#202271 on main. PyTorch 2.15 builds no cp310 wheels (FULL_PYTHON_VERSIONS starts at 3.11), but pyproject.toml still declares requires-python >=3.10 and the 3.10 classifier, so the 2.15 wheels advertise a Python they are not built for. Set requires-python to >=3.11, drop the 3.10 classifier and update the README prerequisite.
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/202273
Note: Links to docs will display an error until the docs builds have been completed. ⏳ No Failures, 22 PendingAs of commit 0c5eff6 with merge base 2cce586 ( 🟡 GREEN LIGHT - PR requires human review:
reason: This comment was automatically generated by Dr. CI and updates every 15 minutes. |
There was a problem hiding this comment.
Automated review of 0c5eff6: nothing blocking; ready for human review.
This PR raises requires-python in pyproject.toml to >=3.11, drops the Python 3.10 classifier, and changes the README's source-build prerequisite to Python 3.11, which matches the 2.15 row of RELEASE.md. The review found no issues. Recommendation: Approve.
This review is AI-generated and advisory. Each new automated review replaces the previous one.
… removed (#202303) Follow-up to #202273. Ruff takes its target version from requires-python; at >=3.11 it enables UP035, UP036, UP044, UP017 and UP041 and flags 257 places in 162 files that still carry Python 3.10 compatibility code, so the Lint job fails on release/2.15. Pin target-version to py310 so lint is unchanged. Same change as the pin added to #202271 on main. Co-authored-by: Andrey Talman <[email protected]>
) Go through the following checklist - [x] Passes lint (checked `ruff` and the PYFMT adapter directly, not through `lintrunner`) - [ ] Added/updated tests - [ ] Updated documentation (if applicable) - [ ] Included benchmark results (for PRs impacting perf) --- ## Linked issue or supporting maintainer Follow-up to #202271 / #202273, which raised `requires-python` to `>=3.11` and (via #202303 on `release/2.15`) pinned ruff to 3.10 until this cleanup. ## BC-breaking? No. Lint configuration and Python 3.11-only syntax/imports only. Behaviour is unchanged: the rewritten `sys.version_info >= (3, 11)` branches were already the live ones. ## Summary (human written only) Removes `target-version = "py310"` from `[tool.ruff]` so ruff takes its target from `requires-python` (3.11) again, and applies the findings that turns on. ## Agent details (if applicable) Drafted with Claude Code; diff reviewed by hand. The commit message follows. Without the pin, `ruff check .` (ruff 0.14.4, the version lintrunner pins) goes from 941 to 1115 findings: 174 new, in 143 files, from five rules. | Rule | Count | What | Fix | |---|---|---|---| | UP035 | 103 | `typing_extensions` imports that are in `typing` / `collections.abc` on 3.11 | safe | | UP044 | 30 | `Unpack[...]` | unsafe | | UP017 | 20 | `timezone.utc` -> `UTC` | safe | | UP036 | 19 | obsolete `sys.version_info` checks | unsafe | | UP041 | 2 | aliased errors | safe | Changes: - Delete the pin. - `ruff check --fix --unsafe-fixes` for those five rules. I read the UP036 rewrites (e.g. `torch/_inductor/await_utils.py`, the `bisect_left` paths in `torch/fx/proxy.py` and `symbolic_shapes.py`); each keeps the 3.11 branch. - Clean up what the fixes leave behind (27 unused imports and similar, all safe fixes), then `usort` + `ruff format` on the 94 files where moving imports changed their order. One `import tomllib` in `test/spincli/test_spin.py` was left out of order and is moved by hand. - Python 3.11 across the lint tooling, instead of carving out the adapters. lintrunner runs 15 adapters with `uv run --python 3.10`, where the autofix's `import tomllib` and `typing.Self` would not exist. Rather than pin them to a 3.10 ruff target, the second commit moves those 15 `--python 3.10` entries in `.lintrunner.toml` and their `requires-python` script headers to 3.11, drops the `tomli ; python_version < '3.11'` dependency markers, and applies the same fixes to `tools/linter/adapters/**`. `mypy-strict.ini` moves from `python_version = 3.10` to 3.11 too. Not changed: `pyrefly.toml` (`python-version = "3.12"`), and the `B905` entry in `[tool.ruff.lint] ignore`, whose comment says "TODO: Remove Python-3.10 specific suppressions". I did not check what removing it would change; it is a separate cleanup. This touches 161 files (+294/-427) across `torch/`, `torchgen/`, `test/`, `.github/scripts` and `tools`, so it will conflict with in-flight PRs; the sooner it lands the fewer rebases. ## Testing With `ruff==0.14.4` and the repo config, on the tree at this PR's base: - Before the change (pin in place): 941 findings. - With the pin removed and no fixes: 1115 findings (174 new). - This PR: 939 findings, none beyond the 941 baseline. - `pyfmt_linter.py` (usort + ruff format) on the changed `.py` files introduces nothing new; it flags only `torch/utils/checkpoint.py`, which it also flags without this change. - Smoke-tested under `uv run --python 3.11 --script`: `pyfmt_linter`, `pyproject_linter` and `cmake_minimum_required_linter` (clean on `pyproject.toml`), and `license_files_linter` starts. The other moved adapters were not run individually. - All 139 changed `.py`/`.pyi` files parse on CPython 3.11. Not run: `lintrunner` end to end, `mypy --config-file mypy-strict.ini` on 3.11 (used by `test/test_type_hints.py`), and the test suites. CI is the verification for those. Authored with an AI assistant; the diff was reviewed by hand. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Pull Request resolved: #203051 Approved by: https://github.com/williamwen42, https://github.com/justinchuby, https://github.com/d4l3k
…rch#203051) Go through the following checklist - [x] Passes lint (checked `ruff` and the PYFMT adapter directly, not through `lintrunner`) - [ ] Added/updated tests - [ ] Updated documentation (if applicable) - [ ] Included benchmark results (for PRs impacting perf) --- ## Linked issue or supporting maintainer Follow-up to pytorch#202271 / pytorch#202273, which raised `requires-python` to `>=3.11` and (via pytorch#202303 on `release/2.15`) pinned ruff to 3.10 until this cleanup. ## BC-breaking? No. Lint configuration and Python 3.11-only syntax/imports only. Behaviour is unchanged: the rewritten `sys.version_info >= (3, 11)` branches were already the live ones. ## Summary (human written only) Removes `target-version = "py310"` from `[tool.ruff]` so ruff takes its target from `requires-python` (3.11) again, and applies the findings that turns on. ## Agent details (if applicable) Drafted with Claude Code; diff reviewed by hand. The commit message follows. Without the pin, `ruff check .` (ruff 0.14.4, the version lintrunner pins) goes from 941 to 1115 findings: 174 new, in 143 files, from five rules. | Rule | Count | What | Fix | |---|---|---|---| | UP035 | 103 | `typing_extensions` imports that are in `typing` / `collections.abc` on 3.11 | safe | | UP044 | 30 | `Unpack[...]` | unsafe | | UP017 | 20 | `timezone.utc` -> `UTC` | safe | | UP036 | 19 | obsolete `sys.version_info` checks | unsafe | | UP041 | 2 | aliased errors | safe | Changes: - Delete the pin. - `ruff check --fix --unsafe-fixes` for those five rules. I read the UP036 rewrites (e.g. `torch/_inductor/await_utils.py`, the `bisect_left` paths in `torch/fx/proxy.py` and `symbolic_shapes.py`); each keeps the 3.11 branch. - Clean up what the fixes leave behind (27 unused imports and similar, all safe fixes), then `usort` + `ruff format` on the 94 files where moving imports changed their order. One `import tomllib` in `test/spincli/test_spin.py` was left out of order and is moved by hand. - Python 3.11 across the lint tooling, instead of carving out the adapters. lintrunner runs 15 adapters with `uv run --python 3.10`, where the autofix's `import tomllib` and `typing.Self` would not exist. Rather than pin them to a 3.10 ruff target, the second commit moves those 15 `--python 3.10` entries in `.lintrunner.toml` and their `requires-python` script headers to 3.11, drops the `tomli ; python_version < '3.11'` dependency markers, and applies the same fixes to `tools/linter/adapters/**`. `mypy-strict.ini` moves from `python_version = 3.10` to 3.11 too. Not changed: `pyrefly.toml` (`python-version = "3.12"`), and the `B905` entry in `[tool.ruff.lint] ignore`, whose comment says "TODO: Remove Python-3.10 specific suppressions". I did not check what removing it would change; it is a separate cleanup. This touches 161 files (+294/-427) across `torch/`, `torchgen/`, `test/`, `.github/scripts` and `tools`, so it will conflict with in-flight PRs; the sooner it lands the fewer rebases. ## Testing With `ruff==0.14.4` and the repo config, on the tree at this PR's base: - Before the change (pin in place): 941 findings. - With the pin removed and no fixes: 1115 findings (174 new). - This PR: 939 findings, none beyond the 941 baseline. - `pyfmt_linter.py` (usort + ruff format) on the changed `.py` files introduces nothing new; it flags only `torch/utils/checkpoint.py`, which it also flags without this change. - Smoke-tested under `uv run --python 3.11 --script`: `pyfmt_linter`, `pyproject_linter` and `cmake_minimum_required_linter` (clean on `pyproject.toml`), and `license_files_linter` starts. The other moved adapters were not run individually. - All 139 changed `.py`/`.pyi` files parse on CPython 3.11. Not run: `lintrunner` end to end, `mypy --config-file mypy-strict.ini` on 3.11 (used by `test/test_type_hints.py`), and the test suites. CI is the verification for those. Authored with an AI assistant; the diff was reviewed by hand. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Pull Request resolved: pytorch#203051 Approved by: https://github.com/williamwen42, https://github.com/justinchuby, https://github.com/d4l3k
…rch#203051) Go through the following checklist - [x] Passes lint (checked `ruff` and the PYFMT adapter directly, not through `lintrunner`) - [ ] Added/updated tests - [ ] Updated documentation (if applicable) - [ ] Included benchmark results (for PRs impacting perf) --- ## Linked issue or supporting maintainer Follow-up to pytorch#202271 / pytorch#202273, which raised `requires-python` to `>=3.11` and (via pytorch#202303 on `release/2.15`) pinned ruff to 3.10 until this cleanup. ## BC-breaking? No. Lint configuration and Python 3.11-only syntax/imports only. Behaviour is unchanged: the rewritten `sys.version_info >= (3, 11)` branches were already the live ones. ## Summary (human written only) Removes `target-version = "py310"` from `[tool.ruff]` so ruff takes its target from `requires-python` (3.11) again, and applies the findings that turns on. ## Agent details (if applicable) Drafted with Claude Code; diff reviewed by hand. The commit message follows. Without the pin, `ruff check .` (ruff 0.14.4, the version lintrunner pins) goes from 941 to 1115 findings: 174 new, in 143 files, from five rules. | Rule | Count | What | Fix | |---|---|---|---| | UP035 | 103 | `typing_extensions` imports that are in `typing` / `collections.abc` on 3.11 | safe | | UP044 | 30 | `Unpack[...]` | unsafe | | UP017 | 20 | `timezone.utc` -> `UTC` | safe | | UP036 | 19 | obsolete `sys.version_info` checks | unsafe | | UP041 | 2 | aliased errors | safe | Changes: - Delete the pin. - `ruff check --fix --unsafe-fixes` for those five rules. I read the UP036 rewrites (e.g. `torch/_inductor/await_utils.py`, the `bisect_left` paths in `torch/fx/proxy.py` and `symbolic_shapes.py`); each keeps the 3.11 branch. - Clean up what the fixes leave behind (27 unused imports and similar, all safe fixes), then `usort` + `ruff format` on the 94 files where moving imports changed their order. One `import tomllib` in `test/spincli/test_spin.py` was left out of order and is moved by hand. - Python 3.11 across the lint tooling, instead of carving out the adapters. lintrunner runs 15 adapters with `uv run --python 3.10`, where the autofix's `import tomllib` and `typing.Self` would not exist. Rather than pin them to a 3.10 ruff target, the second commit moves those 15 `--python 3.10` entries in `.lintrunner.toml` and their `requires-python` script headers to 3.11, drops the `tomli ; python_version < '3.11'` dependency markers, and applies the same fixes to `tools/linter/adapters/**`. `mypy-strict.ini` moves from `python_version = 3.10` to 3.11 too. Not changed: `pyrefly.toml` (`python-version = "3.12"`), and the `B905` entry in `[tool.ruff.lint] ignore`, whose comment says "TODO: Remove Python-3.10 specific suppressions". I did not check what removing it would change; it is a separate cleanup. This touches 161 files (+294/-427) across `torch/`, `torchgen/`, `test/`, `.github/scripts` and `tools`, so it will conflict with in-flight PRs; the sooner it lands the fewer rebases. ## Testing With `ruff==0.14.4` and the repo config, on the tree at this PR's base: - Before the change (pin in place): 941 findings. - With the pin removed and no fixes: 1115 findings (174 new). - This PR: 939 findings, none beyond the 941 baseline. - `pyfmt_linter.py` (usort + ruff format) on the changed `.py` files introduces nothing new; it flags only `torch/utils/checkpoint.py`, which it also flags without this change. - Smoke-tested under `uv run --python 3.11 --script`: `pyfmt_linter`, `pyproject_linter` and `cmake_minimum_required_linter` (clean on `pyproject.toml`), and `license_files_linter` starts. The other moved adapters were not run individually. - All 139 changed `.py`/`.pyi` files parse on CPython 3.11. Not run: `lintrunner` end to end, `mypy --config-file mypy-strict.ini` on 3.11 (used by `test/test_type_hints.py`), and the test suites. CI is the verification for those. Authored with an AI assistant; the diff was reviewed by hand. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Pull Request resolved: pytorch#203051 Approved by: https://github.com/williamwen42, https://github.com/justinchuby, https://github.com/d4l3k
Release-branch copy of #202271 (main). Same two-file change; it applies cleanly to
release/2.15.Summary
Raise the minimum Python in the package metadata from 3.10 to 3.11, to match what 2.15 builds.
pyproject.toml:requires-python = ">=3.11", and remove theProgramming Language :: Python :: 3.10classifier.README.md: the source-build prerequisite says "Python 3.11 or later".Why
FULL_PYTHON_VERSIONSonrelease/2.15starts at3.11, and the 2.15.0 wheels on the test channel arecp311tocp315(pluscp314tandcp315t), with nocp310. The 2.15 releng notes say the same: "PyTorch 2.15 raises the minimum supported Python version for binaries to 3.11". But the 2.15.0 wheels carry:That advertises 3.10 on PyPI and
pip show, and makesuvand Poetry try to resolve 2.15 for Python 3.10 and fail on a missing wheel instead of reporting that 3.11 is required. The RC wheels already on the test channel have the old metadata; GA wheels built from this branch after this lands will not.Testing
pyproject.tomlparses (tomllib), andproject.requires-pythonis>=3.11with the classifiers3 :: Only,3.11to3.15. I did not build a wheel or an sdist from this change.