Guest User

Untitled

a guest
Jul 14th, 2020
18
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from typing import Union, List, Dict
  2.  
  3. def g(x: Union[
  4. Dict[str, float],
  5. Dict[str, Union[str, int]],
  6. ]):
  7. pass
  8.  
  9. g({"a": 1}) #fails
  10. g({"a": "b"}) #fails
  11. g({"a": 1.0}) #passes
  12.  
  13. def h(x: Dict[str, Union[float, str, int]]):
  14. pass
  15.  
  16. h({"a": 1}) #passes
  17. h({"a": "b"}) #passes
  18. h({"a": 1.0}) #passes
RAW Paste Data Copied