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
It could be seen as a duplicate, not sure about it, but this one looks slightly different and more general as the one linked above, it's not only about None in unions but more about unions of unions where mypy has difficulties to narrow the correct TypedDict
Likely a bug in the narrowing code that doesn't take into account type alias types (or just a missing get_proper_type() there). If I inline Event in the second alias, then everything works as expected.
The code in refine_parent_types() bailed out when it encountered
something other than a TypedDict in the union, including a nested union
of TypedDicts. This caused the narrowing to fail.
Fix it by making it iterate over the flattened union items.
Fixespython#9308.
bluetech
added a commit
to bluetech/mypy
that referenced
this issue
Sep 27, 2021
The code in refine_parent_types() bailed out when it encountered
something other than a TypedDict in the union, including a nested union
of TypedDicts. This caused the narrowing to fail.
Fix it by making it iterate over the flattened union items.
Fixespython#9308.
The code in refine_parent_types() bailed out when it encountered
something other than a TypedDict in the union, including a nested union
of TypedDicts. This caused the narrowing to fail.
Fix it by making it iterate over the flattened union items.
Fixes#9308.
Report Type: Bug
Example: https://mypy-play.net/?mypy=latest&python=3.8&gist=529e99849ebe65749d8568b743f21050
I saw #8925.
It could be seen as a duplicate, not sure about it, but this one looks slightly different and more general as the one linked above, it's not only about
None
in unions but more about unions of unions where mypy has difficulties to narrow the correct TypedDictWhat is the behavior/output you expect?
I would expect the union of union to be narrowed
What are the versions of mypy and Python you are using?
v0.782
Do you see the same issue after installing mypy from Git master?
yes
What are the mypy flags you are using? (For example --strict-optional)
The text was updated successfully, but these errors were encountered: