Pyright and mypy warn about all four expressions below (a-d):
from typing import Self
class Size[T]:
def __init__(self, value: T) -> None:
self.value = value
def end(self) -> None:
a = Size(1).__sub__(self)
b = Size(1) - self
c = self.__sub__(Size(1))
d = self - Size(1)
def __sub__(self, other: Self) -> 'Size':
return self
zuban only warns about expressions c and d.
Originally posted by @correctmost in #304