overload

Domain: Validation Typing

🎯 Motivation

overload lets you declare multiple type signatures for the same function so type checkers understand different call patterns. It improves autocomplete and type accuracy for functions with varying argument types.

πŸ“‹ Concrete Example

You write @overload def parse(x: str) -> int: ... and @overload def parse(x: bytes) -> str: ..., then implement one real function. mypy knows the return type depends on the input type.

πŸ”— Analogy

overload is like a restaurant menu listing the same β€œlunch special” with different sides depending on the day. The kitchen (implementation) is the same, but the menu (type) shows different options.