Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feature: greater distinction for model ClassVar #18

Open
awgymer opened this issue Jan 3, 2025 · 1 comment
Open

feature: greater distinction for model ClassVar #18

awgymer opened this issue Jan 3, 2025 · 1 comment
Assignees
Labels
feature New feature or request fund Issue priority can be boosted

Comments

@awgymer
Copy link

awgymer commented Jan 3, 2025

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

And this gives:
image


This issue was labeled with the fund label. The following section is automatically added by Polar.

Boost priority in our backlog through Polar's "issue funding". Issues linked to monthly sponsorships of $50 or more (author, upvoters) are already prioritized, see how we manage our backlog.

Fund with Polar
@awgymer awgymer added the feature New feature or request label Jan 3, 2025
@pawamoy
Copy link
Member

pawamoy commented Jan 3, 2025

Hi @awgymer, thanks for the request, and for the kind words ❤️

Noted, added to the backlog!

@pawamoy pawamoy added the fund Issue priority can be boosted label Jan 3, 2025
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
feature New feature or request fund Issue priority can be boosted
Projects
None yet
Development

No branches or pull requests

2 participants