How can I set the same type as class in method's parameter following PEP484? [duplicate]
Inside of the class, the class is not defined yet, causing a NameError
(and PyCharm to complain).
To get around this, use forward declarations:
class Foo: def foo_method(self, other_foo: "Foo"): return "Hello World!"
Basically, if a type annotations is a string, it is eval
ed after the whole module is loaded, so it can evaluate to the Foo
class.