Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from typing import Union, List, Dict
- def f(x: Union[List[Union[Dict[str, Union[int, List[int]]], Dict[str, Union[Dict[str, Union[int, List[int]]], List[int]]]]], Union[Dict[str, Union[int, List[int]]], Dict[str, Union[Dict[str, Union[int, List[int]]], List[int]]]]]):
- pass
- f({"foo": 23})
- """
- C:\Users\Kevin\Desktop>mypy test.py
- test.py:8: error: Argument 1 to "f" has incompatible type "Dict[str, int]"; expected "Union[List[Union[Dict[str, Union[int, List[int]]], Dict[str, Union[Dict[str, Union[int, List[int]]], List[int]]]]], Dict[str, Union[int, List[int]]], Dict[str, Union[Dict[str, Union[int, List[int]]], List[int]]]]"
- test.py:8: note: "Dict" is invariant -- see http://mypy.readthedocs.io/en/latest/common_issues.html#variance
- test.py:8: note: Consider using "Mapping" instead, which is covariant in the value type
- Found 1 error in 1 file (checked 1 source file)
- """
Add Comment
Please, Sign In to add comment