Skip to content

feature: Support parsing of Pydantic BaseModel classes #280

Closed as not planned
@TongTong313

Description

@TongTong313

Currently, mkdocstrings is unable to correctly parse pydantic's BaseModel. All class variables are recognized as required.

Example:

class BaseTool(BaseModel, ABC):
"""基础工具类,所有的类都要继承这个类

Args:
    tool (Any): 工具,形式不限
    tool_name (str, optional): 工具名称,默认输入为None,会自动获取工具名称
    tool_description (str, optional): 工具描述,默认输入为None,会自动获取工具描述
    tool_schema (Dict[str, Any], optional): 工具schema,默认输入为None,会自动获取工具schema
"""
tool: Any = Field(..., description="工具")
tool_name: Optional[str] = Field(default=None, description="工具名称")
tool_description: Optional[str] = Field(default=None, description="工具描述")
tool_schema: Optional[Dict[str, Any]] = Field(default=None,
                                              description="工具schema")
Image

Clearly, the three class variables tool_name, tool_description, and tool_schema are not required, as they have a default value of None. However, the parsing result incorrectly identifies them as required variables.

Metadata

Metadata

Assignees

Labels

featureNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions