Open
Description
This is a really neat extension which gives a nice output.
One thing which would be very nice to have is for any ClassVar
on a model to be grouped separately or otherwise indicated in the list of attributes.
Currently it also shows pydantic-field
for such a field when you set show_labels: true
but this is misleading as a value set as ClassVar
is not validated as part of the model!
A model example to recreate this:
class MyModelWithClassVar(BaseModel):
"""This is an example model with a `ClassVar`"""
model_config = ConfigDict(extra="allow", use_enum_values=True)
TOP_SECRET: ClassVar[str] = "BASE"
"""This is a ClassVar"""
a: int
"""This is a model field"""
b: str
"""This is also a model field"""
@field_validator("a")
@classmethod
def check_a_is_big(cls, v: int, info: ValidationInfo) -> int:
if v < 10:
raise ValueError("a is too small!")
return v