Check calls to overloaded functions [call-overload]

When you call an overloaded function, mypy checks that at least one ofthe signatures of the overload items match the argument types in thecall.

Example:

  1. from typing import overload, Optional
  2.  
  3. @overload
  4. def inc_maybe(x: None) -> None: ...
  5.  
  6. @overload
  7. def inc_maybe(x: int) -> int: ...
  8.  
  9. def inc_maybe(x: Optional[int]) -> Optional[int]:
  10. if x is None:
  11. return None
  12. else:
  13. return x + 1
  14.  
  15. inc_maybe(None) # OK
  16. inc_maybe(5) # OK
  17.  
  18. # Error: No overload variant of "inc_maybe" matches argument type "float" [call-overload]
  19. inc_maybe(1.2)