Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable flake8-pyi's Y037 #9686

Merged
merged 4 commits into from
Feb 7, 2023
Merged

Enable flake8-pyi's Y037 #9686

merged 4 commits into from
Feb 7, 2023

Conversation

AlexWaygood
Copy link
Member

@AlexWaygood AlexWaygood commented Feb 7, 2023

Always use PEP 604 syntax instead of Union and Optional.

Closes #4819

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2023

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

beautiful

@JelleZijlstra JelleZijlstra merged commit 0ef9c3f into main Feb 7, 2023
@JelleZijlstra JelleZijlstra deleted the 604 branch February 7, 2023 03:01
@Avasam
Copy link
Collaborator

Avasam commented Feb 7, 2023

I was looking forward to this one. There's still a mention to using Optional and Union as a workaround in CONTRIBUTING.md though: https://github.com/python/typeshed/blob/main/CONTRIBUTING.md?plain=1#L438

use X | Y instead of Union[X, Y] and X | None, instead of
Optional[X], except when it is not possible due to mypy bugs (type aliases and base classes);

@intgr
Copy link
Contributor

intgr commented Feb 7, 2023

types-requests version 2.28.11.11 somehow causes issues with lots of djangotestframework-stubs CI tests. (https://github.com/typeddjango/djangorestframework-stubs/actions/runs/4114959794/jobs/7103023727)

According to changelog this PR was the only change in that version.

Errors like this appear in every tests:

requests-stubs/sessions.pyi:80: error: Type application has too many types (1 expected) (diff)
requests-stubs/sessions.pyi:81: error: Type application has too many types (1 expected) (diff)
requests-stubs/sessions.pyi:99: error: Type application has too many types (1 expected) (diff)
requests-stubs/sessions.pyi:106: error: Type application has too many types (1 expected) (diff)
urllib3-stubs/fields.pyi:6: error: Type application has too many types (1 expected) (diff)

@AlexWaygood
Copy link
Member Author

@intgr do your tests run with mypy 1.0? If not, you may need to upgrade to mypy 1.0.

@AlexWaygood
Copy link
Member Author

That error message comes from python/mypy#11098, but that bug should have been fixed in mypy 1.0.

@intgr
Copy link
Contributor

intgr commented Feb 7, 2023

Created issue #9690. Sorry, should have done that in the first place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PEP 604 (Unions with pipe character) tracker
4 participants