I'm trying to write out type annotation for proper autocomplete in PyCharm. See this refined code example:
class TestClass:
a = 1
@staticmethod
def make_new_with_a(a: int) -> TestClass:
t = TestClass()
t.a = a
return t
print(TestClass.make_new_with_a(7).a)
Code works and prints 7
to output. But PyCharm underlines -> TestClass
with red and shows Unresolved reference 'TestClass'
on mouse over hint. Autocompletion for fields of method return type (...make_new_with_a(7).
+ <ctrl+space>
) doesn't work.
Similar questions: