跳到主要内容

ClassProfile

类数据类源码

ClassProfile(
properties: list[property | cached_property] = [],
methods: list[function | classmethod | staticmethod] = [],
operators: dict[str, function] = dict(...),
abstract_attrs: AbstractAttrs | None = None
)

从类中提取的临时摘要。

此摘要只用来临时聚合类的各种成员、属性。其存放的信息、将在随后的 docstring 转换中,得以持久化。

字段​

字段类型必选
说明
propertieslist[property | cached_property]类的所有属性。
methodslist[function | classmethod | staticmethod]类的所有实例、类、静态方法。
operatorsdict[str, function]类的所有运算符重载。
abstract_attrsAbstractAttrs | None可选的抽象成员。如果所解析的类并非抽象类,则该值为None。

方法​

from_class​

v_1: Self = ClassProfile.from_class(base_cls: type[Any])

从某个类中提取摘要。

输入​

参数类型必选
说明
base_clstype[Any]用来解析摘要的类。

输出​

参数类型
说明
v_1Self解析后的类摘要。