Closed
Description
A function that expects a heterogeneous dictionary and gets a dictionary with a subset of the expected types seems to cause problems.
from typing import Any, Mapping, Union
def f(arg: Mapping[ str , Any]) -> None: pass
def g(arg: Mapping[Union[str, int], Any]) -> None: pass
f({'b': 'c'})
g({'b': 'c'})
d = {'b': 'c'}
f(d)
g(d) # <--- Line 8
Mypy's output is
mypy-test.py:8: error: Argument 1 to "g" has incompatible type "Dict[str, str]"; expected "Mapping[Union[str, int], Any]"
I'm using Python 3.7.1 and Mypy 0.641. Possibly related to #5849?
Metadata
Metadata
Assignees
Labels
No labels