Skip to content

Mypy does not allow using the root validator with arguments other than pre or _func #1192

@j0z89t-c927815636lo0

Description

@j0z89t-c927815636lo0

Bug

Output of python -c "import pydantic.utils; print(pydantic.utils.version_info())":

             pydantic version: 1.4
            pydantic compiled: True
                 install path: /home/[username]/Desktop/[project]/env/lib/python3.6/site-packages/pydantic
               python version: 3.6.9 (default, Nov  7 2019, 10:44:02)  [GCC 8.3.0]
                     platform: Linux-5.3.0-26-generic-x86_64-with-Ubuntu-18.04-bionic
     optional deps. installed: ['typing-extensions']

Code:

    @root_validator(pre=False, skip_on_failure=True)
    def test_validator(cls, values):
        return values

Output:

test.py:5: error: No overload variant of "root_validator" matches argument types "bool", "bool"
test.py:5: note: Possible overload variants:
test.py:5: note:     def root_validator(_func: Callable[..., Any]) -> classmethod
test.py:5: note:     def root_validator(*, pre: bool = ...) -> Callable[[Callable[..., Any]], classmethod]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug V1Bug related to Pydantic V1.X

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions