Repository navigation
Conversation
PyTorch 2.15 no longer builds 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 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.
PR Status: in progressA maintainer requested changes. Please address their feedback before the PR returns to maintainer review. To become ready for review, the change must pass automated review and every maintainer comment must be addressed, either with a code change or a reply explaining why no change is needed. A fresh automated review checks that the feedback has been addressed. All CI must finish and Dr. CI must classify every failure as unrelated to your PR. Fix the failures it attributes to your PR (see status below in this comment). Workflows waiting for a maintainer to approve their run do not block this. To minimize iteration time, feel free to run the pr-review skill from the repo locally. If you address comments without pushing, comment 🟡 AUTOMATED REVIEW - Changes requested:
Findings (4): Reviewed commit: 🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/202271
Note: Links to docs will display an error until the docs builds have been completed. ⏳ No Failures, 153 PendingAs of commit fd141c0 with merge base afabe7b ( 🟡 GREEN LIGHT - PR was reverted - re-landing requires human review:
Green Light will not review this PR again, on this or any later commit; re-landing it needs a human approval. This comment was automatically generated by Dr. CI and updates every 15 minutes. |
…ta (#202273) Same change as #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. Co-authored-by: Andrey Talman <[email protected]>
|
@pytorchbot merge -f "lets merge will followup with cmake change" |
Merge startedYour change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
|
@pytorchbot revert -m "Reverted automatically by pytorch's autorevert, to avoid this behaviour add the tag autorevert: disable" -c autorevert This PR is attributed to have caused regression in:
Autorevert dashboard as of 2026-10-27 21:15:07 UTC Note: This revert was accelerated by the AI advisor: AI advisor: related (confidence=0.95) Please investigate and fix the issues. |
|
Claude finished @pytorch-auto-revert[bot]'s task in 59s —— View job Revert diagnosisThe revert is justified. Raising DetailsRoot cause
The PR couldn't catch this because it was force-merged ( How to fix (pick one)
Whichever option you take, let Lint finish before merging. Use |
|
@pytorchbot successfully started a revert job. Check the current status here. |
|
@atalman your PR has been successfully reverted. |
…2271)" This reverts commit 4a6a0da. Reverted #202271 on behalf of https://github.com/pytorch-auto-revert due to Reverted automatically by pytorch's autorevert, to avoid this behaviour add the tag autorevert: disable ([comment](#202271 (comment)))
Ruff takes its target version from requires-python. With 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, which fails the Lint job. Most of the fixes are mechanical but 134 need --unsafe-fixes, and they would touch torch/_dynamo files that the Python 3.10 cleanup PRs are already editing. Pin target-version to py310 so lint is unchanged; remove it with that cleanup.
There was a problem hiding this comment.
Automated review of fd141c0: changes requested before human review.
The PR raises requires-python to >=3.11, drops the 3.10 classifier, updates the README prerequisite, and pins Ruff's target-version to py310, but the CMake configure guard still accepts Python 3.10 and a maintainer's request for a second sign-off is still open. Recommendation: Request Changes.
🔴 2 blocking findings are attached to the code below.
⚪ 2 non-blocking findings
Line 381 in fd141c0
tools/dynamo/verify_dynamo.py:11 still says the minimum is 3.10. It sets MIN_PYTHON_VERSION = (3, 10), so this user-facing check tells 3.10 users they meet the minimum, which now contradicts the package metadata. Change it to (3, 11).
Line 531 in fd141c0
The new comment points to an unnamed cleanup: it refers to 'the "Remove Python 3.10 support code" cleanups' but gives no PR or issue number, so nothing ties the target-version = "py310" pin to the work that should remove it. Cite # 199417, or a tracking issue, as the PR description already does. The comment also says the rules "rewrite" ~160 files, but ruff check only reports findings unless run with --fix. Say it reports findings in ~160 files, and list UP041 along with UP035/UP036/UP044/UP017.
Please address the findings and push; a new commit normally gets a fresh automated review.
This review is AI-generated and advisory. Each new automated review replaces the previous one.
| description = "Tensors and Dynamic neural networks in Python with strong GPU acceleration" | ||
| readme = "README.md" | ||
| requires-python = ">=3.10" | ||
| requires-python = ">=3.11" |
There was a problem hiding this comment.
🔴 cmake/Dependencies.cmake:877-879 still allows 3.10: it reads if(${Python_VERSION} VERSION_LESS 3.10) and prints "Python < 3.10 is no longer supported by PyTorch." The requires-python change only stops pip install .. python setup.py develop, pip install --ignore-requires-python, and running CMake directly skip it and rely only on this guard, so a 3.10 source build gets past configure and then fails late or produces an unsupported build instead of stopping early with a clear error. The author's force-merge comment ("will followup with cmake change") admits this gap, but the follow-up isn't linked. Move both the condition and the message to 3.11 in this PR, or link the follow-up so the release/2.15 cherry-pick carries the change with it.
| description = "Tensors and Dynamic neural networks in Python with strong GPU acceleration" | ||
| readme = "README.md" | ||
| requires-python = ">=3.10" | ||
| requires-python = ">=3.11" |
There was a problem hiding this comment.
🔴 huydhn's request is still open. In their approval, huydhn asked for a stamp from both @ malfet and @ albanD before landing. albanD approved ("SGTM"), but the conversation has nothing from malfet, and the PR was force-merged (@ pytorchbot merge -f) without it.
|
@pytorchmergebot merge -f "I belive lint is clear now, we can merge" |
Follow-up to #202271, from its [review comment](#202271 (comment)). ## Summary Raise the Python floor that CMake enforces from 3.10 to 3.11, so CMake agrees with `pyproject.toml` and the README after #202271. `cmake/Dependencies.cmake`: ```cmake if(${Python_VERSION} VERSION_LESS 3.11) message(FATAL_ERROR "Found Python libraries version ${Python_VERSION}. Python < 3.11 is no longer supported by PyTorch.") endif() ``` ## Why #202271 sets `requires-python = ">=3.11"` and the README prerequisite to "Python 3.11 or later". `pip install .` on 3.10 is then stopped by `requires-python`, but builds that skip that check (`python setup.py develop`, `pip install --ignore-requires-python`, calling CMake directly) rely on this guard. With the floor still at 3.10 those builds get past configure and fail much later, or produce an unsupported build, instead of stopping with a clear message. No CI job builds PyTorch from source on Python 3.10: the only remaining `3.10` string in `.github/workflows` is a description comment, and the binary matrix starts at 3.11. It is the only 3.10 floor I found in `cmake/`, `CMakeLists.txt`, `setup.py`, `tools/` or `torch/__init__.py`. ## Testing Ran the same `if`/`message` block with `cmake -P` (CMake 4.4.4) and `Python_VERSION` set to three values: `3.10.12` stops with the new message and exit 1; `3.11.0` and `3.15.1` are accepted. I did not run a full PyTorch configure. Independent of #202271 (a different file), so the two can land in either order. `release/2.15` has the same guard; this PR does not change that branch. Pull Request resolved: #202290 Approved by: https://github.com/huydhn
Merge startedYour change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use Learn more about merging in the wiki. Questions? Feedback? Please reach out to the PyTorch DevX Team |
) ## 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 the `Programming Language :: Python :: 3.10` classifier. - `README.md`: the source-build prerequisite says "Python 3.11 or later". - `[tool.ruff] target-version = "py310"`: pinned so lint does not change (see below). ## Why The binary build matrix no longer includes Python 3.10: `FULL_PYTHON_VERSIONS` in `.github/scripts/generate_binary_build_matrix.py` starts at `3.11`, and the 2.15.0 wheels on the test channel are `cp311` to `cp315` (plus `cp314t` and `cp315t`), with no `cp310`. `pyproject.toml` was not updated, so the 2.15.0 wheels carry: ``` Requires-Python: >=3.10 Classifier: Programming Language :: Python :: 3.10 ``` That tells PyPI and `pip show` that 3.10 is supported, and makes `uv` and 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 PRs that dropped 3.10 from the builds (pytorch#198233, pytorch#199398) only changed build and CI config and did not touch `pyproject.toml`. ## Lint Ruff derives its target version from `requires-python`, so raising it to 3.11 enabled the pyupgrade rules for 3.11 and failed the Lint job: 257 findings in 162 files (UP036 obsolete `sys.version_info` checks 104, UP035 `typing_extensions` imports 101, UP044 `Unpack` 30, UP017 `datetime.UTC` 20, UP041 2). I reproduced the same counts locally with `ruff==0.14.4` and the repo config. 134 of the fixes need `--unsafe-fixes`, and they touch `torch/_dynamo` files that the Python 3.10 cleanup PRs (pytorch#199417) are editing, so they do not belong in a metadata change. This PR pins `target-version = "py310"` in `[tool.ruff]`, which restores the previous lint behavior: on the 162 files `ruff check` passes, and `ruff format --check` reports the same single file (`torch/utils/checkpoint.py`) as on the base commit. The pin should be removed together with the Python 3.10 code cleanup. ## Not changed - `[tool.ruff]` settings and the `# TODO: Remove Python-3.10 specific suppressions` comment. - The Python 3.10 code paths in dynamo; pytorch#199417 handles those. ## Testing `pyproject.toml` parses (`tomllib`), and `project.requires-python` is `>=3.11` with the classifiers `3 :: Only`, `3.11` to `3.15`. With the pin, `ruff check` (ruff 0.14.4, repo config) passes on all 162 files the Lint job had flagged. I did not build a wheel or an sdist from this change. Cherry-pick to `release/2.15` is a separate PR. Pull Request resolved: pytorch#202271 Approved by: https://github.com/huydhn, https://github.com/albanD
… 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
) ## 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 the `Programming Language :: Python :: 3.10` classifier. - `README.md`: the source-build prerequisite says "Python 3.11 or later". ## Why The binary build matrix no longer includes Python 3.10: `FULL_PYTHON_VERSIONS` in `.github/scripts/generate_binary_build_matrix.py` starts at `3.11`, and the 2.15.0 wheels on the test channel are `cp311` to `cp315` (plus `cp314t` and `cp315t`), with no `cp310`. `pyproject.toml` was not updated, so the 2.15.0 wheels carry: ``` Requires-Python: >=3.10 Classifier: Programming Language :: Python :: 3.10 ``` That tells PyPI and `pip show` that 3.10 is supported, and makes `uv` and 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 PRs that dropped 3.10 from the builds (pytorch#198233, pytorch#199398) only changed build and CI config and did not touch `pyproject.toml`. ## Not changed - `[tool.ruff]` settings and the `# TODO: Remove Python-3.10 specific suppressions` comment. - The Python 3.10 code paths in dynamo; pytorch#199417 handles those. ## Testing `pyproject.toml` parses (`tomllib`), and `project.requires-python` is `>=3.11` with the classifiers `3 :: Only`, `3.11` to `3.15`. I did not build a wheel or an sdist from this change. Cherry-pick to `release/2.15` is a separate PR. Pull Request resolved: pytorch#202271 Approved by: https://github.com/huydhn, https://github.com/albanD
…orch#202271)" This reverts commit 4a6a0da. Reverted pytorch#202271 on behalf of https://github.com/pytorch-auto-revert due to Reverted automatically by pytorch's autorevert, to avoid this behaviour add the tag autorevert: disable ([comment](pytorch#202271 (comment)))
Follow-up to pytorch#202271, from its [review comment](pytorch#202271 (comment)). ## Summary Raise the Python floor that CMake enforces from 3.10 to 3.11, so CMake agrees with `pyproject.toml` and the README after pytorch#202271. `cmake/Dependencies.cmake`: ```cmake if(${Python_VERSION} VERSION_LESS 3.11) message(FATAL_ERROR "Found Python libraries version ${Python_VERSION}. Python < 3.11 is no longer supported by PyTorch.") endif() ``` ## Why pytorch#202271 sets `requires-python = ">=3.11"` and the README prerequisite to "Python 3.11 or later". `pip install .` on 3.10 is then stopped by `requires-python`, but builds that skip that check (`python setup.py develop`, `pip install --ignore-requires-python`, calling CMake directly) rely on this guard. With the floor still at 3.10 those builds get past configure and fail much later, or produce an unsupported build, instead of stopping with a clear message. No CI job builds PyTorch from source on Python 3.10: the only remaining `3.10` string in `.github/workflows` is a description comment, and the binary matrix starts at 3.11. It is the only 3.10 floor I found in `cmake/`, `CMakeLists.txt`, `setup.py`, `tools/` or `torch/__init__.py`. ## Testing Ran the same `if`/`message` block with `cmake -P` (CMake 4.4.4) and `Python_VERSION` set to three values: `3.10.12` stops with the new message and exit 1; `3.11.0` and `3.15.1` are accepted. I did not run a full PyTorch configure. Independent of pytorch#202271 (a different file), so the two can land in either order. `release/2.15` has the same guard; this PR does not change that branch. Pull Request resolved: pytorch#202290 Approved by: https://github.com/huydhn
) ## 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 the `Programming Language :: Python :: 3.10` classifier. - `README.md`: the source-build prerequisite says "Python 3.11 or later". - `[tool.ruff] target-version = "py310"`: pinned so lint does not change (see below). ## Why The binary build matrix no longer includes Python 3.10: `FULL_PYTHON_VERSIONS` in `.github/scripts/generate_binary_build_matrix.py` starts at `3.11`, and the 2.15.0 wheels on the test channel are `cp311` to `cp315` (plus `cp314t` and `cp315t`), with no `cp310`. `pyproject.toml` was not updated, so the 2.15.0 wheels carry: ``` Requires-Python: >=3.10 Classifier: Programming Language :: Python :: 3.10 ``` That tells PyPI and `pip show` that 3.10 is supported, and makes `uv` and 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 PRs that dropped 3.10 from the builds (pytorch#198233, pytorch#199398) only changed build and CI config and did not touch `pyproject.toml`. ## Lint Ruff derives its target version from `requires-python`, so raising it to 3.11 enabled the pyupgrade rules for 3.11 and failed the Lint job: 257 findings in 162 files (UP036 obsolete `sys.version_info` checks 104, UP035 `typing_extensions` imports 101, UP044 `Unpack` 30, UP017 `datetime.UTC` 20, UP041 2). I reproduced the same counts locally with `ruff==0.14.4` and the repo config. 134 of the fixes need `--unsafe-fixes`, and they touch `torch/_dynamo` files that the Python 3.10 cleanup PRs (pytorch#199417) are editing, so they do not belong in a metadata change. This PR pins `target-version = "py310"` in `[tool.ruff]`, which restores the previous lint behavior: on the 162 files `ruff check` passes, and `ruff format --check` reports the same single file (`torch/utils/checkpoint.py`) as on the base commit. The pin should be removed together with the Python 3.10 code cleanup. ## Not changed - `[tool.ruff]` settings and the `# TODO: Remove Python-3.10 specific suppressions` comment. - The Python 3.10 code paths in dynamo; pytorch#199417 handles those. ## Testing `pyproject.toml` parses (`tomllib`), and `project.requires-python` is `>=3.11` with the classifiers `3 :: Only`, `3.11` to `3.15`. With the pin, `ruff check` (ruff 0.14.4, repo config) passes on all 162 files the Lint job had flagged. I did not build a wheel or an sdist from this change. Cherry-pick to `release/2.15` is a separate PR. Pull Request resolved: pytorch#202271 Approved by: https://github.com/huydhn, https://github.com/albanD
…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
) ## 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 the `Programming Language :: Python :: 3.10` classifier. - `README.md`: the source-build prerequisite says "Python 3.11 or later". - `[tool.ruff] target-version = "py310"`: pinned so lint does not change (see below). ## Why The binary build matrix no longer includes Python 3.10: `FULL_PYTHON_VERSIONS` in `.github/scripts/generate_binary_build_matrix.py` starts at `3.11`, and the 2.15.0 wheels on the test channel are `cp311` to `cp315` (plus `cp314t` and `cp315t`), with no `cp310`. `pyproject.toml` was not updated, so the 2.15.0 wheels carry: ``` Requires-Python: >=3.10 Classifier: Programming Language :: Python :: 3.10 ``` That tells PyPI and `pip show` that 3.10 is supported, and makes `uv` and 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 PRs that dropped 3.10 from the builds (pytorch#198233, pytorch#199398) only changed build and CI config and did not touch `pyproject.toml`. ## Lint Ruff derives its target version from `requires-python`, so raising it to 3.11 enabled the pyupgrade rules for 3.11 and failed the Lint job: 257 findings in 162 files (UP036 obsolete `sys.version_info` checks 104, UP035 `typing_extensions` imports 101, UP044 `Unpack` 30, UP017 `datetime.UTC` 20, UP041 2). I reproduced the same counts locally with `ruff==0.14.4` and the repo config. 134 of the fixes need `--unsafe-fixes`, and they touch `torch/_dynamo` files that the Python 3.10 cleanup PRs (pytorch#199417) are editing, so they do not belong in a metadata change. This PR pins `target-version = "py310"` in `[tool.ruff]`, which restores the previous lint behavior: on the 162 files `ruff check` passes, and `ruff format --check` reports the same single file (`torch/utils/checkpoint.py`) as on the base commit. The pin should be removed together with the Python 3.10 code cleanup. ## Not changed - `[tool.ruff]` settings and the `# TODO: Remove Python-3.10 specific suppressions` comment. - The Python 3.10 code paths in dynamo; pytorch#199417 handles those. ## Testing `pyproject.toml` parses (`tomllib`), and `project.requires-python` is `>=3.11` with the classifiers `3 :: Only`, `3.11` to `3.15`. With the pin, `ruff check` (ruff 0.14.4, repo config) passes on all 162 files the Lint job had flagged. I did not build a wheel or an sdist from this change. Cherry-pick to `release/2.15` is a separate PR. Pull Request resolved: pytorch#202271 Approved by: https://github.com/huydhn, https://github.com/albanD
…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
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".[tool.ruff] target-version = "py310": pinned so lint does not change (see below).Why
The binary build matrix no longer includes Python 3.10:
FULL_PYTHON_VERSIONSin.github/scripts/generate_binary_build_matrix.pystarts at3.11, and the 2.15.0 wheels on the test channel arecp311tocp315(pluscp314tandcp315t), with nocp310.pyproject.tomlwas not updated, so the 2.15.0 wheels carry:That tells PyPI and
pip showthat 3.10 is supported, 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 PRs that dropped 3.10 from the builds (#198233, #199398) only changed build and CI config and did not touchpyproject.toml.Lint
Ruff derives its target version from
requires-python, so raising it to 3.11 enabled the pyupgrade rules for 3.11 and failed the Lint job: 257 findings in 162 files (UP036 obsoletesys.version_infochecks 104, UP035typing_extensionsimports 101, UP044Unpack30, UP017datetime.UTC20, UP041 2). I reproduced the same counts locally withruff==0.14.4and the repo config. 134 of the fixes need--unsafe-fixes, and they touchtorch/_dynamofiles that the Python 3.10 cleanup PRs (#199417) are editing, so they do not belong in a metadata change. This PR pinstarget-version = "py310"in[tool.ruff], which restores the previous lint behavior: on the 162 filesruff checkpasses, andruff format --checkreports the same single file (torch/utils/checkpoint.py) as on the base commit. The pin should be removed together with the Python 3.10 code cleanup.Not changed
[tool.ruff]settings and the# TODO: Remove Python-3.10 specific suppressionscomment.Testing
pyproject.tomlparses (tomllib), andproject.requires-pythonis>=3.11with the classifiers3 :: Only,3.11to3.15. With the pin,ruff check(ruff 0.14.4, repo config) passes on all 162 files the Lint job had flagged. I did not build a wheel or an sdist from this change. Cherry-pick torelease/2.15is a separate PR.