4

我正在尝试为 PyCharm 中的正确自动完成写出类型注释。请参阅此精炼代码示例:

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)

代码工作并打印7输出。但是 PyCharm-> TestClass用红色下划线并Unresolved reference 'TestClass'在鼠标悬停时显示提示。...make_new_with_a(7).方法返回类型 ( + )的字段的自动完成<ctrl+space>功能不起作用。

类似的问题:

4

0 回答 0