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

mypy complains about pre=True root validators #984

Closed
bochecha opened this issue Nov 8, 2019 · 1 comment · Fixed by #985
Closed

mypy complains about pre=True root validators #984

bochecha opened this issue Nov 8, 2019 · 1 comment · Fixed by #985
Labels
bug V1 Bug related to Pydantic V1.X

Comments

@bochecha
Copy link

bochecha commented Nov 8, 2019

Bug

Please complete:

  • OS: Ubuntu 19.04
  • Python version import sys; print(sys.version): 3.7.3
  • Pydantic version import pydantic; print(pydantic.VERSION): 1.0

With the code found in the root validators documentation:

from pydantic import BaseModel, root_validator


class UserModel(BaseModel):
    username: str
    password1: str
    password2: str

    @root_validator(pre=True)
    def check_card_number_omitted(cls, values):  # type: ignore
        assert 'card_number' not in values, 'card_number should not be included'
        return values

Mypy has the following to say:

9: error: "classmethod" not callable

The following change pleases mypy, but of course that changes the semantics:

-    @root_validator(pre=True)
+    @root_validator
@bochecha bochecha added the bug V1 Bug related to Pydantic V1.X label Nov 8, 2019
@samuelcolvin
Copy link
Member

Thanks for reporting. Fixed by #985

alexdrydew pushed a commit to alexdrydew/pydantic that referenced this issue Dec 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug V1 Bug related to Pydantic V1.X
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants