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
in
Bug Report
(A clear and concise description of what the bug is.)
To Reproduce
from typing import Dict, Union, NewType A = NewType("A", str) B = NewType("B", str) dict_a: Dict[A, str] = {} def f(a: Union[A, B]): if a in dict_a: dict_a[a]
Expected Behavior
Mypy recognizes that a inside the if statement is type A, because dict_a's keys are of type A and a is one of the keys.
a
A
dict_a
Actual Behavior
error: Invalid index type "Union[A, B]" for "Dict[A, str]"; expected type "A"
Your Environment
mypy.ini
The text was updated successfully, but these errors were encountered:
Duplicate of #10977
Sorry, something went wrong.
No branches or pull requests
Bug Report
(A clear and concise description of what the bug is.)
To Reproduce
Expected Behavior
Mypy recognizes that
a
inside the if statement is typeA
, becausedict_a
's keys are of typeA
anda
is one of the keys.Actual Behavior
error: Invalid index type "Union[A, B]" for "Dict[A, str]"; expected type "A"
Your Environment
mypy.ini
(and other config files): noneThe text was updated successfully, but these errors were encountered: