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

Support ==-based narrowing of Optional #18163

Merged
merged 1 commit into from
Nov 19, 2024

Conversation

tyralla
Copy link
Collaborator

@tyralla tyralla commented Nov 18, 2024

Closes #18135

This change implements the third approach mentioned in #18135, which is stricter than similar narrowings, as clarified by the new/modified code comments. Personally, I prefer this more stringent way but could also switch this PR to approach two if there is consent that convenience is more important than type safety here.

Closes python#18135

This change implements the third approach mentioned in python#18135, which is stricter than similar narrowings, as clarified by the new/modified code comments. Personally, I prefer this more stringent way but could also switch this PR to approach two if there is a consent that convenience is more important than type safety here.
@tyralla tyralla added the topic-type-narrowing Conditional type narrowing / binder label Nov 18, 2024
Copy link
Contributor

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

Copy link
Collaborator

@hauntsaninja hauntsaninja left a comment

Choose a reason for hiding this comment

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

Nice!

@hauntsaninja hauntsaninja merged commit e2a47e2 into python:master Nov 19, 2024
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic-type-narrowing Conditional type narrowing / binder
Projects
None yet
Development

Successfully merging this pull request may close these issues.

==-based narrowing of Optional
2 participants