-
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
Describe the bug
If creating overloads for __divmod__() that should be applied with divmod, the wrong types are returned when using divmod
Code or Screenshots
File divmod.pyi :
from typing import overload
class LHS:
@overload
def __divmod__(self, other: RHS) -> tuple[RHS, RHS]: ... # type: ignore[overload-overlap]
@overload
def __divmod__(self, other: object) -> tuple[LHS, LHS]: ...
class RHS:
@overload
def __divmod__(self, other: LHS) -> tuple[LHS, LHS]: ... # type: ignore[overload-overlap]
@overload
def __divmod__(self, other: object) -> tuple[RHS, RHS]: ...File divmodtst.py :
from divmod import LHS, RHS
lhs = LHS()
rhs = RHS()
reveal_type(divmod(lhs, rhs))
reveal_type(lhs.__divmod__(rhs))pyright divmodtst.py has this:
divmodtst.py:1:6 - warning: Import "divmod" could not be resolved from source (reportMissingModuleSource)
divmodtst.py:6:13 - information: Type of "divmod(lhs, rhs)" is "tuple[RHS, RHS] | tuple[LHS, LHS]"
c:\Code\Misc\pytypes\divmodtst.py:7:13 - information: Type of "lhs.__divmod__(rhs)" is "tuple[RHS, RHS]"
mypy divmodtst.py has this:
divmodtst.py:6: note: Revealed type is "tuple[divmod.RHS, divmod.RHS]"
divmodtst.py:7: note: Revealed type is "tuple[divmod.RHS, divmod.RHS]"
Note that the results for pyright for calling divmod vs. __divmod__() are different. I think they should be the same.
VS Code extension or command-line
pyright command linen version 1.1.404, python 3.11
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