I have noticed that mypy and pyright have this (undocumented?) feature where you can annotate `self` in a method with a protocol: from dataclasses import dataclass from typing import Protocol class HasX(Protocol): x: int class Base: def double_x(self: HasX) -> int: return 2 * self.x @dataclass class ChildCorrect(Base): x: int ChildCorrect(3).double_x() # OK @dataclass class ChildIncorrect(Base): y: int ChildIncorrect(3).double_x() # err: not compatible with HasX Note that `HasX` isn't anywhere in the base classes of `Base`. My first question is whether this feature is documented somewhere. And my second question is whether this could also take into account methods defined in the actual class. So, for example, if I change the above example to class HasX(Protocol): x: int class Base: def z(self) -> int: return 4 def double_x_plus_z(self: HasX) -> int: return 2 * self.x + self.z() # type-check error then the type checker complains about `self.z()` because `HasX` doesn't have this method. However, it seems to me that any possible type for `self` will have this method, because `Base` defines it right there. So, shouldn't this type-check? Cheers, Thomas