Skip to content

Raise the minimum Python to 3.11 in the package metadata - #202271

Closed
atalman wants to merge 2 commits into
pytorch:mainfrom
atalman:pyproject_min_py311_main
Closed

atalman wants to merge 2 commits into
pytorch:mainfrom
atalman:pyproject_min_py311_main

Conversation

@atalman

@atalman atalman commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

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 (#198233, #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 (#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

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.

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.
@pytorch-bot pytorch-bot Bot added the topic: not user facing topic category label Oct 27, 2026
@pytorch-bot

pytorch-bot Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

PR Status: in progress

A 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 @pytorchbot review to re-run the automated review. To bypass automated review, please add the “no automated review” label.

🟡 AUTOMATED REVIEW - Changes requested:

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.

Findings (4):

[major] pyproject.toml:381
`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.

[major] pyproject.toml:381
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.

[minor] pyproject.toml:381
`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)`.

[minor] pyproject.toml:531
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.

Reviewed commit: fd141c0

Review run

🔗 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 Pending

As of commit fd141c0 with merge base afabe7b (image):
💚 Looks good so far! There are no failures yet. 💚

🟡 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.

@huydhn huydhn left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The change LGTM as we have completely removed 3.10 from CI/CD. Let's also ask @malfet and @albanD for a stamp here before landing so they know that this is coming

@pytorchgreenlight pytorchgreenlight Bot added the GL/human GreenLight marked as needing human review label Oct 27, 2026
@atalman atalman added the ciflow/binaries Trigger all binary build and upload jobs on the PR label Oct 27, 2026
atalman added a commit that referenced this pull request Oct 27, 2026
…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]>

@albanD albanD left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

SGTM

@pytorchbot pytorchbot added the in progress PR is being worked on by the author, until the automated review accepts it label Oct 27, 2026
github-actions[bot]

This comment was marked as outdated.

@atalman

atalman commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator Author

@pytorchbot merge -f "lets merge will followup with cmake change"

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorch-auto-revert

Copy link
Copy Markdown

@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 Can you please read this revert comment, follow the links and read the errors, to then give a brief diagnostics on the cause of the error? If you judge the error to be legitimate reason for a revert, please provide brief guidance on how the author could fix it.

@claude

claude Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Claude finished @pytorch-auto-revert[bot]'s task in 59s —— View job


Revert diagnosis

The revert is justified. Raising requires-python to >=3.11 silently moved Ruff's target version to py311, and that turned on about 85 new pyupgrade findings across the repo.

Details

Root cause

[tool.ruff] in pyproject.toml doesn't set target-version. When it is unset, Ruff infers the target from project.requires-python. So >=3.10 → >=3.11 changed the lint target for every file, not just the package metadata. The failing job is lintrunner-noclang-all / lint. It ends with Lint failed! after reporting new py311-only RUFF findings across the codebase (counted from the log):

  • UP035: Import from typing instead: Self / Never / NotRequired / Required / assert_type / assert_never (all typing_extensions imports that are stdlib in 3.11). Example: .ci/lumen_cli/cli/lib/common/cli_helper.py:19.
  • UP036: Version block is outdated for minimum Python version, 34 occurrences, from sys.version_info >= (3, 11) branches.
  • UP041: Replace aliased errors with TimeoutError, from asyncio.TimeoutError.
  • UP017: Use datetime.UTC alias.
  • Use * for unpacking: Unpack[...] → * in subscripts.
  • Follow-on RUFF format patches.

The PR couldn't catch this because it was force-merged (merge -f) while 54 jobs were still pending, Lint among them.

How to fix (pick one)

  1. Smallest change, best for the reland and the release/2.15 cherry-pick. Keep the metadata change and pin Ruff's target explicitly so lint behaviour doesn't change:
    [tool.ruff]
    target-version = "py310"  # TODO: bump to py311 and apply UP fixes
    Then do the actual py311 lint migration in a separate PR.
  2. Full migration. Reland with the requires-python change, run lintrunner -a --all-files and commit the autofixes. Many touched files mean a large diff that is harder to cherry-pick. Hand-review the UP036 changes, because they delete else: code paths (some overlap with [dynamo] Remove Python 3.10 support code #199417's dynamo cleanup).

Whichever option you take, let Lint finish before merging. Use -i instead of -f so the pending signal still lands. When relanding, it's also worth doing the follow-up the automated review raised: update the cmake/Dependencies.cmake VERSION_LESS 3.10 guard and mypy-strict.ini python_version.

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@pytorchbot successfully started a revert job. Check the current status here.
Questions? Feedback? Please reach out to the PyTorch DevX Team

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

@atalman your PR has been successfully reverted.

pytorchmergebot added a commit that referenced this pull request Oct 27, 2026
…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)))
@pytorchmergebot pytorchmergebot added Reverted ci-no-td Do not run TD on this PR labels Oct 27, 2026
@pytorchgreenlight pytorchgreenlight Bot added the GL/superseded GreenLight review is superseded by changes label Oct 27, 2026
github-actions[bot]

This comment was marked as outdated.

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.

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Automated review of fd141c0: changes requested before human review.

The PR raises requires-python to &gt;=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

requires-python = ">=3.11"

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).


# Ruff takes its target version from requires-python, which is now >=3.11. That

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.

Comment thread pyproject.toml
description = "Tensors and Dynamic neural networks in Python with strong GPU acceleration"
readme = "README.md"
requires-python = ">=3.10"
requires-python = ">=3.11"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔴 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.

Comment thread pyproject.toml
description = "Tensors and Dynamic neural networks in Python with strong GPU acceleration"
readme = "README.md"
requires-python = ">=3.10"
requires-python = ">=3.11"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔴 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.

@atalman

atalman commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator Author

@pytorchmergebot merge -f "I belive lint is clear now, we can merge"

pytorchmergebot pushed a commit that referenced this pull request Oct 27, 2026
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
@pytorchmergebot

Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged immediately since you used the force (-f) flag, bypassing any CI checks (ETA: 1-5 minutes). Please use -f as last resort and instead consider -i/--ignore-current to continue the merge ignoring current failures. This will allow currently pending tests to finish and report signal before the merge.

Learn more about merging in the wiki.

Questions? Feedback? Please reach out to the PyTorch DevX Team

Advanced Debugging
Check the merge workflow status
here

@pytorchmergebot

Copy link
Copy Markdown
Collaborator

This PR (#202271) was merged in 24fd092 but it is still open, likely due to a Github bug, so mergebot is closing it manually. If you think this is a mistake, please feel free to reopen and contact Dev Infra.

sub4biz pushed a commit to sub4biz/pytorch that referenced this pull request Oct 27, 2026
)

## 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
atalman added a commit that referenced this pull request Oct 28, 2026
… 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]>
pytorchmergebot pushed a commit that referenced this pull request Nov 3, 2026
)

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
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 5, 2026
)

## 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
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 5, 2026
…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)))
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 5, 2026
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
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 5, 2026
)

## 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
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 5, 2026
…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
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 9, 2026
)

## 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
dominikjastrzebskix pushed a commit to dominikjastrzebskix/pytorch that referenced this pull request Nov 9, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci-no-td Do not run TD on this PR ciflow/binaries Trigger all binary build and upload jobs on the PR GL/human GreenLight marked as needing human review GL/superseded GreenLight review is superseded by changes in progress PR is being worked on by the author, until the automated review accepts it Merged Reverted topic: not user facing topic category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants