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
There should be no type error, Literals in Unions should be flattened.
I would love if unions of literals are flattened in general. Literal["a"] | Literal["b"] | (Literal["c"] | Literal["d"]) == Literal["a", "b", "c", "d"]
But I guess this is yet another issue.
It would be nice if mypy becomes smarter about unions of literals but if you want a quick workaround here you can replace TimeRange | CreatedRange by Literal[TimeRange, CreatedRange] (Literal is allowed to contain other literals).
It would be nice if mypy becomes smarter about unions of literals but if you want a quick workaround here you can replace TimeRange | CreatedRange by Literal[TimeRange, CreatedRange] (Literal is allowed to contain other literals).
Good to know, that Literal is allowed to contain other Literals. Thank you.
Bug Report
If Literals are given as Unions they aren't accepted as TypedDict Keys
To Reproduce
MyPy Play
Expected Behavior
There should be no type error, Literals in Unions should be flattened.
I would love if unions of literals are flattened in general.
Literal["a"] | Literal["b"] | (Literal["c"] | Literal["d"]) == Literal["a", "b", "c", "d"]
But I guess this is yet another issue.
Actual Behavior
Can't access typed dict without type error
Your Environment
(see mypy play)
Related #16813
The text was updated successfully, but these errors were encountered: