我有一个 python 模块文件,它有一堆类定义及其方法 sample.py
def abc():
...
class Sampler(object):
def foo(self):
...
class Sampler2(object):
def bar(self):
...
现在我想将此文件导入另一个 python 文件并在定义如下函数时使用类型注释:比如 samplers.py
import sample
class Xyz(object):
def foobar(self, sampleparam:sample.Sampler)-> int :
...
以上是抛出 AttributeError: module 'sample' has no attribute 'Sampler'。上面的实现不正确吗?