Skip to content

[BE] Apply pep604 and turn on flake8 rule so no regressions#2415

Merged
Lucaskabela merged 1 commit intopytorch:mainfrom
Lucaskabela:lucaskabela/enable_pep_604
Feb 24, 2026
Merged

[BE] Apply pep604 and turn on flake8 rule so no regressions#2415
Lucaskabela merged 1 commit intopytorch:mainfrom
Lucaskabela:lucaskabela/enable_pep_604

Conversation

@Lucaskabela
Copy link
Contributor

@Lucaskabela Lucaskabela commented Feb 21, 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

Test

Ran

 python -m flake8 --pep604-activation=always .

Explicitly

@meta-cla meta-cla bot added the CLA Signed This label is managed by the Meta Open Source bot. label Feb 21, 2026
@Lucaskabela Lucaskabela marked this pull request as ready for review February 21, 2026 00:50
Copy link
Contributor

@tianyu-l tianyu-l left a comment

Choose a reason for hiding this comment

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

Thanks, this looks quite useful! Would prefer landing this after #2386

@Lucaskabela
Copy link
Contributor Author

Review #2411 first then will rebase and fix merge conflicts

@Lucaskabela Lucaskabela force-pushed the lucaskabela/enable_pep_604 branch from 356fa0d to 7e620a6 Compare February 23, 2026 21:10
@Lucaskabela Lucaskabela force-pushed the lucaskabela/enable_pep_604 branch from 7e620a6 to 06cc224 Compare February 24, 2026 16:19
@Lucaskabela Lucaskabela merged commit 4032725 into pytorch:main Feb 24, 2026
22 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ciflow/8gpu CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants