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:
- from typing import overload, Optional
- @overload
- def inc_maybe(x: None) -> None: ...
- @overload
- def inc_maybe(x: int) -> int: ...
- def inc_maybe(x: Optional[int]) -> Optional[int]:
- if x is None:
- return None
- else:
- return x + 1
- inc_maybe(None) # OK
- inc_maybe(5) # OK
- # Error: No overload variant of "inc_maybe" matches argument type "float" [call-overload]
- inc_maybe(1.2)