You can put the type in quotations to refer to it self (i.e. refer to the class via a string).
class MyClass:
def my_func(self: 'MyClass') -> str:
return 'Hello world!'
However, it's not necessary to use type annotation in this case as the self
parameter is passed implicitly and is therefore known.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…