You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Incorrect deduplication of Enum values in Union[Literal[1], Literal[SomeEnum.one]] #103592
These assertions fail on 3.8 since Union deduplicates both Literals into the same thing. The reason you need Literal 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.
This is not tested right now, in fact, Literal with enum is never tested at all.
Moreover, we don't have a single Union[Literal, Literal, ...] test as well.
Thanks a lot @adriangb for raising this.
PR with the fix is ready :)
Activity
JelleZijlstra commentedon Apr 17, 2023
3.8 is in security fix-only mode, so it's too late to fix this.
adriangb commentedon Apr 17, 2023
Makes sense. I'll just close the issue then.
adriangb commentedon Apr 17, 2023
Do you think we can change https://github.com/python/typing_extensions/blob/501a00e4701185ec93220155a0caa3da71d327e8/src/typing_extensions.py#L264-L268 to use the
typing-extensionsimplementation for 3.8 as well?JelleZijlstra commentedon Apr 17, 2023
Yes, that makes sense to do.
sobolevn commentedon Apr 23, 2023
test_typing.pypolice is here 🚨This is not tested right now, in fact,
Literalwithenumis never tested at all.Moreover, we don't have a single
Union[Literal, Literal, ...]test as well.Thanks a lot @adriangb for raising this.
PR with the fix is ready :)
pythongh-103592: Add tests of `Literal` with `Enum` and `Union` of `L…
gh-103592: Add tests of `Literal` with `Enum` and `Union` of `Literal…
pythongh-103592: Add tests of `Literal` with `Enum` and `Union` of `L…
[3.11] gh-103592: Add tests of `Literal` with `Enum` and `Union` of `…