enforce operators include possible right hand types in their input parameter
Description
class Left:
def __add__(self, other: int) -> int:
# here "other" is `Right`
return other + 1 # Type error here
class Right:
def __radd__(self, other: Left) -> str:
return "i'm string :)"
Left() + Right()
i dont get it, Left() + Right() is a str in basedpyright and at runtime so what's the issue?
i dont get it,
Left() + Right()is astrin basedpyright and at runtime so what's the issue?
this code raises a TypeError because it passes a Right to a function that only accepts an int
oopsies, that was an oversight. i've updated the op
any reason why the error should be on the usage instead? having to account for every possible type in the definition would be annoying
any reason why the error should be on the usage instead?
that would make sense, but it would be very disruptive. everything is written with this assumption