当我在Pycharm中使用带边界的TypeVar时,没有与TypeVar的上限相关的提示。示例:
from typing import TypeVar
class TestClass:
def test_class_method(self):
print("test")
T = TypeVar('T', bound=TestClass)
def test_method(test_class: T):
test_class.test_class_method()
test_method(TestClass())
在这里,我希望当我在test_class
上按ctrl+space时,test_class method
会在自动完成中列出。但什么都没有。当我突出显示test_class
时,有一个正确的工具提示:推断类型:TypeVar('T',TestClass)。我这边有错误吗,还是自动完成的问题?在
目前没有回答
相关问题 更多 >
编程相关推荐