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
False positive "unsafe[] overlapping" for _floordiv__/__rfloordiv__ with Real argument, but nearly identical signatures for other operators are fine #10755
Where the single argument to __floordiv__/__rfloordiv__ includes numbers.Real, it results in (what I think is) a false Signatures … are unsafely overlapping error.
To Reproduce
# test_case.pyfromnumbersimportRealfromoperatorimportfloordiv, mul, truedivfromtypingimportNamedTuple, Union_OperandT=Union[float, Real]
# _OperandT = Real # <- results in the same error# _OperandT = float # <- this worksclassSpam(NamedTuple):
value: _OperandTdef__floordiv__(self, other: _OperandT) ->"Spam":
returnSpam(floordiv(self.value, other))
def__rfloordiv__(self, other: _OperandT) ->"Spam": # <- this presents an error …returnSpam(floordiv(other, self.value))
def__mul__(self, other: _OperandT) ->"Spam":
returnSpam(mul(self.value, other))
def__rmul__(self, other: _OperandT) ->"Spam": # <- … but this is just fine …returnSpam(mul(other, self.value))
def__truediv__(self, other: _OperandT) ->"Spam":
returnSpam(truediv(self.value, other))
def__rtruediv__(self, other: _OperandT) ->"Spam": # <- … and so is thisreturnSpam(truediv(other, self.value))
Actual Behavior
$ mypy --version
mypy 0.902
$ mypy test_case.py
test_case.py:16: error: Signatures of "__rfloordiv__" of "Spam" and "__floordiv__" of "Union[float, Real]" are unsafely overlapping
Found 1 error in 1 file (checked 1 source file)
Expected Behavior
I would expect symmetry with other binary operator signatures. I'm also pretty sure there isn't any actual overlap here, but I could be wrong.