from typing import Self, ClassVar
class Foo:
instance: ClassVar[Self]
@classmethod
def get_instance(cls) -> Self:
return cls.instance # error: Incompatible return value type (got "Foo", expected "Self") [return-value]
@classmethod
def get_instance2(cls) -> Self:
return cls.get_instance() # no error
playground
playground