Guest User

Untitled

a guest
Jul 14th, 2020
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. from typing import Union, List, Dict
  2. 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]]]]]):
  3. pass
  4.  
  5. f({"foo": 23})
  6.  
  7. """
  8. C:\Users\Kevin\Desktop>mypy test.py
  9. 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]]]]"
  10. test.py:8: note: "Dict" is invariant -- see http://mypy.readthedocs.io/en/latest/common_issues.html#variance
  11. test.py:8: note: Consider using "Mapping" instead, which is covariant in the value type
  12. Found 1 error in 1 file (checked 1 source file)
  13. """
Add Comment
Please, Sign In to add comment