Skip to content

Support default values specified in Pydantic Models #793

Open
@jinnovation

Description

@jinnovation

Problem Description

My codebase leverages Pydantic heavily. In particular, we use Pydantic Models heavily as a "superpowered" form of dataclasses. In particular, we use the Field() function heavily to validate, specify defaults, and otherwise impose restrictions on the values passed into a given field.

Unfortunately, for Pydantic Model fields, it seems that the default value -- whether specified in Field() or "normally" -- ends up not rendering properly in pdoc.

For example, the following results in the default value of 1 not showing up properly:

from pydantic import BaseModel

class Foo(BaseModel):
    """Test class."""
    bar: int = Field(default=1)
Image

Nor does the following:

from pydantic import BaseModel

class Foo(BaseModel):
    """Test class."""
    bar: int = 1

Proposal

As "esoteric" as Pydantic can be at times, it would be nice to have native support for Pydantic models. Full-blown support for all of Pydantic is a heavy request, so I'd be happy with just supporting rendering default values properly (for the time being 😇).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions