Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3k
[match-case] Fix narrowing of class pattern with union-argument.#19473
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 ourterms of service andprivacy 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?
[match-case] Fix narrowing of class pattern with union-argument.#19473
Conversation
current_type = try_expanding_sum_type_to_union(current_type, enum_name) | ||
current_type = get_proper_type(current_type) | ||
if isinstance(current_type, UnionType) and (default == 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.
Thedefault == current_type
was necessary, otherwise quite a few tests break.
Addingor (default is None)
and passingdefault=None
in the recursive call also seems to break stuff. Not entirely sure what's going on there.
According tomypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
isinstance
call. #19468testMatchNarrowDownUnionUsingClassPattern
I added factorization over
UnionType
inside theconditional_types
function.Then
try_expanding_sum_type_to_union
needed to move to the start of the function so that we expandcurrent_type
before attempting factorizating the union type.I also reformatted the docstring for better legibility.