You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the minimal example below, I get an unexpected "Overloaded function signatures overlap with incompatible return types" error from mypy. The example is taken from a general "wait for an event or a message" function that I use in my codebase. It allows requesting one or multiple event or message types.
To Reproduce
class Message:
pass
class Event:
pass
_WaitableTypes = Union[type[Message], type[Event]]
_MessageT1 = TypeVar("_MessageT1", bound=Message)
_MessageT2 = TypeVar("_MessageT2", bound=Message)
# Single message
@overload
def wait_for(
msg_type: type[_MessageT1],
) -> _MessageT1:
...
# Two messages (arbitrary iterable of messages is also supported, but not relevant in this example)
@overload
def wait_for(
msg_type: tuple[type[_MessageT1], type[_MessageT2]],
) -> Union[_MessageT1, _MessageT2]:
...
# List of events
@overload
def wait_for(
msg_type: Iterable[type[Event]],
) -> Event:
...
def wait_for(
msg_type: Union[_WaitableTypes, Iterable[_WaitableTypes]],
) -> Union[Message, Event]:
return ... # type: ignore
Expected Behavior
mypy does not complain
Actual Behavior
mypy reports "error: Overloaded function signatures 2 and 3 overlap with incompatible return types [misc]"
Your Environment
Mypy version used: 1.0.1
Mypy command-line flags: none
Mypy configuration options from mypy.ini (and other config files): none
Python version used: 3.9
The text was updated successfully, but these errors were encountered:
Bug Report
In the minimal example below, I get an unexpected "Overloaded function signatures overlap with incompatible return types" error from mypy. The example is taken from a general "wait for an event or a message" function that I use in my codebase. It allows requesting one or multiple event or message types.
To Reproduce
Expected Behavior
mypy does not complain
Actual Behavior
mypy reports "error: Overloaded function signatures 2 and 3 overlap with incompatible return types [misc]"
Your Environment
mypy.ini
(and other config files): noneThe text was updated successfully, but these errors were encountered: