我们有内置dir()函数来获取在基类中定义的类或实例可用的所有属性。
注释也一样吗?我想要get_annotations()一个功能,其工作原理如下:
def get_annotations(cls: type): ... # ?
class Base1:
foo: float
class Base2:
bar: int
class A(Base1, Base2):
baz: str
assert get_annotations(A) == {'foo': float, 'bar': int, 'baz': str}
陪伴而非守候
相关分类