Closed
Description
from typing import Mapping
def func(results: Mapping[str, str]) -> None:
pass
if __name__ == "__main__":
# Passing an int here (even though all values should be strings) is intentional
func({"1":"1", "2":2})
Running the above code through mypy gives me the following incorrect error message:
error: List item 1 has incompatible type "Tuple[str, int]"
Strangely enough, the next section of code (which is nearly the same as the above code) produces a better error message:
from typing import Mapping
def func(results: Mapping[str, str]) -> None:
pass
if __name__ == "__main__":
# Using an int here (even though all values should be strings) is intentional
my_dict = {"1":"1", "2":2}
func(my_dict)
Running this code through mypy gives the following (better) error message:
error: Argument 1 to "func" has incompatible type Dict[str, object]; expected Mapping[str, str]
My Specs:
Python 3.5.1
mypy-lang 0.4.2
Metadata
Metadata
Assignees
Labels
No labels