Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Small error in the docs #9407

Closed
1 task done
paulmartin91 opened this issue May 7, 2024 · 1 comment
Closed
1 task done

Small error in the docs #9407

paulmartin91 opened this issue May 7, 2024 · 1 comment
Labels
bug V2 Bug related to Pydantic V2 pending Awaiting a response / confirmation

Comments

@paulmartin91
Copy link
Contributor

Initial Checks

  • I confirm that I'm using Pydantic V2

Description

docs.concepts.dataclasses.md there is an example dataclass with the @model_validator(mode='before') decorator that does not use the @classmethod decorator. The @model_validator decorator docs state: "The first argument should be cls (and we also recommend you use @classmethod below @model_validator for proper type checking)".

Example Code

@dataclass
class User:
    birth: Birth

    @model_validator(mode='before')
    def pre_root(cls, values: Dict[str, Any]) -> Dict[str, Any]:
        print(f'First: {values}')
        """
        First: ArgsKwargs((), {'birth': {'year': 1995, 'month': 3, 'day': 2}})
        """
        return values

Python, Pydantic & OS Version

https://docs.pydantic.dev/latest/concepts/dataclasses/#initialization-hooks
@paulmartin91 paulmartin91 added bug V2 Bug related to Pydantic V2 pending Awaiting a response / confirmation labels May 7, 2024
@sydney-runkle
Copy link
Member

Marking as resolved! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug V2 Bug related to Pydantic V2 pending Awaiting a response / confirmation
Projects
None yet
Development

No branches or pull requests

2 participants