-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
hotfix for 20445 #20450
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
base: master
Are you sure you want to change the base?
hotfix for 20445 #20450
Conversation
| proposed_type = make_simplified_union(proposed_items) | ||
|
|
||
| if isinstance(proper_type, AnyType): | ||
| return proposed_type, current_type |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way, would it be technically more correct to return AnyType(TypeOfAny.from_another_any, source_any=proper_type) for the else branch, rather than proper_type itself?
| return default, UninhabitedType() | ||
| elif not is_overlapping_types(current_type, proposed_type, ignore_promotions=True): | ||
| return default, remainder | ||
| if not is_overlapping_types(current_type, proposed_type, ignore_promotions=True): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Converted the elif to if because the if not any(type_range.is_upper_bound for type_range in proposed_type_ranges): is not guaranteed to return anymore.
| ) | ||
| ): | ||
| # Expression is always of one of the types in proposed_type_ranges | ||
| return default, UninhabitedType() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This return was problematic in the structural case when current_type=Any | Proto, restricting Proto away should leave us with Any and not Never.
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
Fixes #20445
Fixes a regression in
conditional_typewhen given a union ofAny | Protocol