3.6. Typing Overload

  • If we have multiple methods with the same name, but different arguments

  • Example: @single_dispatch_method from functools

>>> from typing import overload
>>>
>>>
>>> class User:
...     def login(self, credentials: dict[str, str]):
...         print('ok')
...
...     @overload
...     def login(self, credentials: tuple[str, str]):
...         print('ok')