We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
Bug Report
Enum should be assignable to union of its literals (expansion). Mypy usually understands that, but not when union is behind an alias.
To Reproduce
playground
from enum import Enum from typing import Literal class E(Enum): A = 'a' B = 'b' C = 'c' A = Literal[E.A] B = Literal[E.B, E.C] def f(x: A | B) -> None: ... def f2(x: A | Literal[E.B, E.C]) -> None: ... def f3(x: Literal[E.A] | B) -> None: ... def main(x: E) -> None: f(x) # E: Argument 1 to "f" has incompatible type "E"; expected "Literal[E.A] | Literal[E.B, E.C]" [arg-type] f2(x) f3(x) # E: Argument 1 to "f" has incompatible type "E"; expected "Literal[E.A] | Literal[E.B, E.C]" [arg-type]
Expected Behavior
Success, 0 errors.
Actual Behavior
main.py:17: error: Argument 1 to "f" has incompatible type "E"; expected "Literal[E.A] | Literal[E.B, E.C]" [arg-type] main.py:19: error: Argument 1 to "f3" has incompatible type "E"; expected "Literal[E.A] | Literal[E.B, E.C]" [arg-type] Found 2 errors in 1 file (checked 1 source file)
Your Environment
mypy.ini
I have a patch for this - just a small impl omission. Discovered while looking at #18895.
The text was updated successfully, but these errors were encountered:
narrow_declared_type
c3ed5e0
sterliakov
Successfully merging a pull request may close this issue.
Bug Report
Enum should be assignable to union of its literals (expansion). Mypy usually understands that, but not when union is behind an alias.
To Reproduce
playground
Expected Behavior
Success, 0 errors.
Actual Behavior
Your Environment
mypy.ini
(and other config files): n/aI have a patch for this - just a small impl omission. Discovered while looking at #18895.
The text was updated successfully, but these errors were encountered: