Skip to main content

get_field_docstrings

FunctionSource

v_1: dict[str, str | None] = get_field_docstrings(model_cls: type[Any], include_dyn_assign: bool = False)

Capture the docstrings of each assignment item in a class by its source code.

Arguments

Requires

NameTypeRequired
Description
model_clstype[Any]The class to be analyzed.
include_dyn_assignbool

By default, this method will only detect the docstrings of such items:

name: type = value

If this flag is enabled, will also detect docstrings of such items:

name = value

Returns

NameType
Description
v_1dict[str, str | None]The docstrings of the fields. If the value of a key is None, it means that this field does not have the docstring.