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
I expect this code to type check, as the empty dictionary {} type checks against both sides of the Union — that is, if I remove the Union from the above code and leave only either side, mypy reports no issue.
Actual Behavior
Mypy reports an incompatible type:
test.py:14: error: Argument 1 to "foo" has incompatible type "Dict[<nothing>, <nothing>]"; expected "Union[Mapping[bytes, str], Mapping[str, str]]" [arg-type]
If I break down the call to foo into
arg= {}
foo(arg)
mypy now complains that arg must be type annotated.
Your Environment
Mypy version used: 1.0.0
Mypy command-line flags: none
Mypy configuration options from mypy.ini: none
Python version used: 3.10.9
The text was updated successfully, but these errors were encountered:
Bug Report
When calling a function that calls for an argument of type
Union[Mapping[x,z], Mapping[y,z]]
, the empty dictionary{}
does not type-check.I encountered this problem when trying to call
subprocess.run
with an empty environment, that is,To Reproduce
The smallest I've been able to reduce this issue to is the following code:
Expected Behavior
I expect this code to type check, as the empty dictionary
{}
type checks against both sides of theUnion
— that is, if I remove theUnion
from the above code and leave only either side, mypy reports no issue.Actual Behavior
Mypy reports an incompatible type:
If I break down the call to
foo
intomypy now complains that
arg
must be type annotated.Your Environment
mypy.ini
: noneThe text was updated successfully, but these errors were encountered: