-
Notifications
You must be signed in to change notification settings - Fork 288
-
I'm running into a type checking error where I'm unsure whether what I'm looking at is an issue in mypy or an issue in my understanding of python type annotations.
d1: dict[str, str] = {}
d2: dict[str, str | None] = {}
d3 = d1 | d2
reveal_type(d3) # builtins.dict[builtins.str, Union[builtins.str, None]], aka dict[str, str | None]
# This is fine
d4: dict[str, str | None] = d3 # aka d1 | d2
# This isn't?
d5: dict[str, str | None] = d1 | d2
I cannot figure out why I'm not allowed to do d5: dict[str, str | None] = d1 | d2 in this case.
Beta Was this translation helpful? Give feedback.
All reactions
Answered by
erictraut
Dec 3, 2024
I think this is an issue with mypy. The code looks fine to me, and pyright accepts it without any errors.
Replies: 1 comment
-
I think this is an issue with mypy. The code looks fine to me, and pyright accepts it without any errors.
Beta Was this translation helpful? Give feedback.
All reactions
0 replies
Answer selected by
harahu
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment