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

Comments

@bochecha
Copy link

@bochecha 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 label Nov 8, 2019
@samuelcolvin

This comment has been minimized.

Copy link
Owner

@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
Projects
None yet
2 participants
You can’t perform that action at this time.