Closed
Description
Assume a function like:
def get_item(key: str, default: Optional[Item] = None) -> Optional[Item]:
# implementation goes here
...
Now let's assume we want to enhance typing through an @overload
by changing it to:
@overload
def get_item(key: str) -> Item:
...
def get_item(key: str, default: Optional[Item] = None) -> Optional[Item]:
# implementation goes here
...
mypy will complain with:
error: Single overload definition, multiple required
This check makes sense for a .pyi
file where you would expect multiple @overload
s on equal footing, but in this case the original declaration might as well serve as an "overload".
A workaround is obviously to add:
@overload
def get_item(key: str, default: Optional[Item]) -> Optional[Item]:
...
which adds needless verbosity.
Metadata
Metadata
Assignees
Labels
No labels