-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
addressed in next versionIssue is fixed and will appear in next published versionIssue is fixed and will appear in next published versionbugSomething isn't workingSomething isn't working
Description
from typing import Self, overload
class A:
@overload
def __divmod__(self, x: Self, /) -> tuple[Self, Self]: ...
@overload
def __divmod__(self, x: int, /) -> tuple[int, int]: ...
def __divmod__(self, x: Self | int, /) -> tuple[Self, Self] | tuple[int, int]:
return (self, self) if isinstance(x, A) else (x, x)
reveal_type(divmod(A(), 1))reports two errors:
No overloads for "divmod" match the provided arguments (reportCallIssue)
Argument of type "Literal[1]" cannot be assigned to parameter "y" of type "SupportsRDivMod[_T_contra@divmod, _T_co@divmod]" in function "divmod"
"Literal[1]" is incompatible with protocol "SupportsRDivMod[A, _T_co@divmod]"
"__rdivmod__" is an incompatible type
Type "(value: int, /) -> tuple[int, int]" is not assignable to type "(other: _T_contra@SupportsRDivMod, /) -> _T_co@SupportsRDivMod"
Parameter 1: type "_T_contra@SupportsRDivMod" is incompatible with type "int"
"A" is not assignable to "int" (reportArgumentType)
mypy behaves correctly, and reports:
revealed type is "tuple[builtins.int, builtins.int]"
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
addressed in next versionIssue is fixed and will appear in next published versionIssue is fixed and will appear in next published versionbugSomething isn't workingSomething isn't working