ClassProfile
类数据类源码
ClassProfile(
properties: list[property | cached_property] = [],
methods: list[function | classmethod | staticmethod] = [],
operators: dict[str, function] = dict(...),
abstract_attrs: AbstractAttrs | None = None
)
从类中提取的临时摘要。
此摘要只用来临时聚合类的各种成员、属性。其存放的信息、将在随后的 docstring 转换中,得以持久化。
字段
| 字段 | 类型 | 必选 | |
|---|---|---|---|
properties | list[property | cached_property] | 类的所有属性。 | |
methods | list[function | classmethod | staticmethod] | 类的所有实例、类、静态方法。 | |
operators | dict[str, function] | 类的所有运算符重载。 | |
abstract_attrs | AbstractAttrs | None | 可选的抽象成员。如果所解析的类并非抽象类,则该值为None。 |
方法
from_class
v_1: Self = ClassProfile.from_class(base_cls: type[Any])
从某个类中提取摘要。
输入
| 参数 | 类型 | 必选 | |
|---|---|---|---|
base_cls | type[Any] | 用来解析摘要的类。 |
输出
| 参数 | 类型 | |
|---|---|---|
v_1 | Self | 解析后的类摘要。 |