Skip to content

[BE] Apply pep604 to torch/_dynamo#175555

Closed
Lucaskabela wants to merge 2 commits intomainfrom
lucaskabela/pep_604_for_dynamo
Closed

[BE] Apply pep604 to torch/_dynamo#175555
Lucaskabela wants to merge 2 commits intomainfrom
lucaskabela/pep_604_for_dynamo

Conversation

@Lucaskabela
Copy link
Copy Markdown
Contributor

@Lucaskabela Lucaskabela commented Feb 23, 2026

Since python>=3.10 is defined in the pyproject.toml, we can enable pep604 (in python >=3.10)

Why?

  1. Fewer imports making code simpler
  2. Standardization - prior to this change, we could have Optional or the | None intermixed in the codebase
  3. Future proof for direction of python type system

cc @voznesenskym @penguinwu @EikanWang @jgong5 @Guobing-Chen @XiaobingSuper @zhuhaozhe @blzheng @wenzhe-nrv @jiayisunx @kadeng @chauhang @amjames @jataylo @xmfan @aditvenk

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Feb 23, 2026

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/175555

Note: Links to docs will display an error until the docs builds have been completed.

❌ 2 New Failures

As of commit 80d7f51 with merge base 85cf583 (image):

NEW FAILURES - The following jobs have failed:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@Lucaskabela
Copy link
Copy Markdown
Contributor Author

@pytorchmergebot merge

@pytorch-bot pytorch-bot Bot added the ciflow/trunk Trigger trunk jobs on your pull request label Feb 24, 2026
@pytorchmergebot
Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

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 pushed a commit that referenced this pull request Feb 25, 2026
Since python>=3.10 is defined in the pyproject.toml, we can enable [pep604](https://peps.python.org/pep-0604/) (in python >=3.10)

Why?

* Fewer imports making code simpler
* Standardization - prior to this change, we could have Optional or the | None intermixed in the codebase
* Future proof for direction of python type system

We apply this to `torch/_functorch` in this PR

See #175555 for another application
Pull Request resolved: #175659
Approved by: https://github.com/aorenste
@Lucaskabela
Copy link
Copy Markdown
Contributor Author

@pytorchbot merge

@pytorchmergebot
Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

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

Merge failed

Reason: Command git -C /home/runner/work/pytorch/pytorch rebase origin/main returned non-zero exit code 1

Rebasing (1/1)
Auto-merging torch/_dynamo/debug_utils.py
Auto-merging torch/_dynamo/decorators.py
Auto-merging torch/_dynamo/exc.py
Auto-merging torch/_dynamo/functional_export.py
CONFLICT (content): Merge conflict in torch/_dynamo/functional_export.py
Auto-merging torch/_dynamo/guards.py
Auto-merging torch/_dynamo/variables/builder.py
Auto-merging torch/_dynamo/variables/script_object.py
Auto-merging torch/_dynamo/variables/tensor.py
Auto-merging torch/_dynamo/variables/torch.py
error: could not apply 95e5dd52950... [BE] Apply pep604 to `torch/_dynamo` (#175555)
hint: Resolve all conflicts manually, mark them as resolved with
hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
hint: You can instead skip this commit: run "git rebase --skip".
hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
hint: Disable this message with "git config set advice.mergeConflict false"
Could not apply 95e5dd52950... # [BE] Apply pep604 to `torch/_dynamo` (#175555)
Details for Dev Infra team Raised by workflow job

@Lucaskabela Lucaskabela force-pushed the lucaskabela/pep_604_for_dynamo branch from 508a03a to 80d7f51 Compare February 25, 2026 20:46
@Lucaskabela
Copy link
Copy Markdown
Contributor Author

@pytorchmergebot merge

@pytorchmergebot
Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

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

@Lucaskabela
Copy link
Copy Markdown
Contributor Author

@pytorchmergebot merge

@pytorchmergebot
Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged once all checks pass (ETA 0-4 Hours).

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

Merge failed

Reason: 1 jobs have failed, first few of them are: trunk / linux-jammy-rocm-py3.10 / test (default, 6, 6, linux.rocm.gpu.gfx950.1)

Details for Dev Infra team Raised by workflow job

@Lucaskabela
Copy link
Copy Markdown
Contributor Author

@pytorchmergebot merge -I

@pytorch-bot
Copy link
Copy Markdown

pytorch-bot Bot commented Feb 28, 2026

❌ 🤖 pytorchbot command failed:

@pytorchbot: error: unrecognized arguments: -I

usage: @pytorchbot [-h] {merge,revert,rebase,label,drci,cherry-pick} ...

Try @pytorchbot --help for more info.

@Lucaskabela
Copy link
Copy Markdown
Contributor Author

@pytorchmergebot merge -i

@pytorchmergebot
Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged while ignoring the following 1 checks: trunk / linux-jammy-rocm-py3.10 / test (default, 6, 6, linux.rocm.gpu.gfx950.1)

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

Merge failed

Reason: 1 jobs have failed, first few of them are: trunk / linux-jammy-rocm-py3.10 / test (distributed, 1, 3, linux.rocm.gpu.gfx950.4)

Details for Dev Infra team Raised by workflow job

@Lucaskabela
Copy link
Copy Markdown
Contributor Author

@pytorchmergebot merge -i

@pytorchmergebot
Copy link
Copy Markdown
Collaborator

Merge started

Your change will be merged while ignoring the following 2 checks: trunk / linux-jammy-rocm-py3.10 / test (default, 6, 6, linux.rocm.gpu.gfx950.1), trunk / linux-jammy-rocm-py3.10 / test (distributed, 1, 3, linux.rocm.gpu.gfx950.4)

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

meta-codesync Bot pushed a commit to pytorch/benchmark that referenced this pull request Mar 2, 2026
Summary:
Since python>=3.10 is defined in the pyproject.toml, we can enable [pep604](https://peps.python.org/pep-0604/) (in python >=3.10)

Why?

1) Fewer imports making code simpler
2) Standardization - prior to this change, we could have `Optional` or the  `| None` intermixed in the codebase
3) Future proof for direction of python type system

X-link: pytorch/pytorch#175555
Approved by: https://github.com/aorenste, https://github.com/zou3519

Reviewed By: jeanschmidt

Differential Revision: D94811748

fbshipit-source-id: ca8ca84d7872b78f3d27e60d7fb8402eeb5c6c54
EmanueleCoradin pushed a commit to EmanueleCoradin/pytorch that referenced this pull request Mar 30, 2026
Since python>=3.10 is defined in the pyproject.toml, we can enable [pep604](https://peps.python.org/pep-0604/) (in python >=3.10)

Why?

* Fewer imports making code simpler
* Standardization - prior to this change, we could have Optional or the | None intermixed in the codebase
* Future proof for direction of python type system

We apply this to `torch/_functorch` in this PR

See pytorch#175555 for another application
Pull Request resolved: pytorch#175659
Approved by: https://github.com/aorenste
EmanueleCoradin pushed a commit to EmanueleCoradin/pytorch that referenced this pull request Mar 30, 2026
Since python>=3.10 is defined in the pyproject.toml, we can enable [pep604](https://peps.python.org/pep-0604/) (in python >=3.10)

Why?

1) Fewer imports making code simpler
2) Standardization - prior to this change, we could have `Optional` or the  `| None` intermixed in the codebase
3) Future proof for direction of python type system

Pull Request resolved: pytorch#175555
Approved by: https://github.com/aorenste, https://github.com/zou3519
EmanueleCoradin pushed a commit to EmanueleCoradin/pytorch that referenced this pull request Mar 30, 2026
EmanueleCoradin pushed a commit to EmanueleCoradin/pytorch that referenced this pull request Mar 30, 2026
This reverts commit 2958025.

Reverted pytorch#175765 on behalf of https://github.com/jeanschmidt due to Need to revert in order to revert pytorch#175555 - see D94699609 ([comment](pytorch#175765 (comment)))
EmanueleCoradin pushed a commit to EmanueleCoradin/pytorch that referenced this pull request Mar 30, 2026
pytorch#174751)"

This reverts commit 1b9046a.

Reverted pytorch#174751 on behalf of https://github.com/jeanschmidt due to Need to revert in order to revert pytorch#175555 - see D94699526 ([comment](pytorch#174933 (comment)))
EmanueleCoradin pushed a commit to EmanueleCoradin/pytorch that referenced this pull request Mar 30, 2026
)"

This reverts commit ba59c42.

Reverted pytorch#174933 on behalf of https://github.com/jeanschmidt due to Need to revert in order to revert pytorch#175555 - see D94699526 ([comment](pytorch#174933 (comment)))
EmanueleCoradin pushed a commit to EmanueleCoradin/pytorch that referenced this pull request Mar 30, 2026
…h/_* (pytorch#175870)"

This reverts commit 4802e2a.

Reverted pytorch#175870 on behalf of https://github.com/jeanschmidt due to Need to revert in order to revert pytorch#175555 - see D94699362 ([comment](pytorch#175870 (comment)))
EmanueleCoradin pushed a commit to EmanueleCoradin/pytorch that referenced this pull request Mar 30, 2026
This reverts commit 45c625b.

Reverted pytorch#175510 on behalf of https://github.com/jeanschmidt due to Need to revert in order to revert pytorch#175555 - see D94598146 ([comment](pytorch#175510 (comment)))
EmanueleCoradin pushed a commit to EmanueleCoradin/pytorch that referenced this pull request Mar 30, 2026
EmanueleCoradin pushed a commit to EmanueleCoradin/pytorch that referenced this pull request Mar 30, 2026
Since python>=3.10 is defined in the pyproject.toml, we can enable [pep604](https://peps.python.org/pep-0604/) (in python >=3.10)

Why?

1) Fewer imports making code simpler
2) Standardization - prior to this change, we could have `Optional` or the  `| None` intermixed in the codebase
3) Future proof for direction of python type system

Pull Request resolved: pytorch#175555
Approved by: https://github.com/aorenste, https://github.com/zou3519
@github-actions github-actions Bot deleted the lucaskabela/pep_604_for_dynamo branch April 1, 2026 02:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants