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

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

mypy complains about pre=True root validators #984

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


Copy link

@bochecha bochecha commented Nov 8, 2019


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

    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
Copy link

@samuelcolvin samuelcolvin commented Nov 8, 2019

Thanks for reporting. Fixed by #985

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

Successfully merging a pull request may close this issue.

2 participants