-
-
Notifications
You must be signed in to change notification settings - Fork 31k
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
Incorrect deduplication of Enum values in Union[Literal[1], Literal[SomeEnum.one]]
#103592
Comments
3.8 is in security fix-only mode, so it's too late to fix this. |
Makes sense. I'll just close the issue then. |
Do you think we can change https://github.com/python/typing_extensions/blob/501a00e4701185ec93220155a0caa3da71d327e8/src/typing_extensions.py#L264-L268 to use the |
Yes, that makes sense to do. |
This is not tested right now, in fact, Thanks a lot @adriangb for raising this. |
…iteral`s (pythonGH-103706) (cherry picked from commit 5041c2b) Co-authored-by: Nikita Sobolev <[email protected]>
This was fixed on 3.9 (by #23294 or followups). Here's a test / example:
These assertions fail on 3.8 since
Union
deduplicates bothLiteral
s into the same thing. The reason you needLiteral
here is because enum values are values not types so they can only appear in a Union if they're also within a Literal.As per #23294 (comment) maybe the answer here is to not do anything. And in fact I looked into back porting and it was too big of a change to be called a back port. But I didn't see this specific issue w/ Enum and Union reported, so I at least wanted to report it and confirm that it is a bug.
Linked PRs
Literal
withEnum
andUnion
ofLiteral
s #103706Literal
withEnum
andUnion
ofLiteral
s (GH-103706) #103720The text was updated successfully, but these errors were encountered: