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

Explicit validator in parent class breaks type validation in child class for nested types #1015

Closed
AlbertMukhammadiev opened this issue Nov 20, 2019 · 3 comments
Labels
bug V1 Bug related to Pydantic V1.X

Comments

@AlbertMukhammadiev
Copy link

Question

Please complete:

  • OS: Ubuntu 18.04
  • Python version import sys; print(sys.version): 3.6.8 [GCC 7.4.0]
  • Pydantic version import pydantic; print(pydantic.VERSION): 1.2a1

Hello, I'm trying to create an instance of class Bar.

import pydantic
from typing import List


class Foo(pydantic.BaseModel):
    foo: List[List[int]]

    @pydantic.validator('foo')
    def check_something(cls, value):
        return value


class Bar(Foo):
    pass


foo_ = [[0, 1]]
Foo(foo=foo_)
Bar(foo=foo_)

Output:

pydantic.error_wrappers.ValidationError: 1 validation error for Bar
foo -> 0
  value is not a valid integer (type=type_error.integer)

There will be no error, If you remove validator.

@AlbertMukhammadiev AlbertMukhammadiev added the bug V1 Bug related to Pydantic V1.X label Nov 20, 2019
@samuelcolvin
Copy link
Member

Confirmed, thanks for reporting. Has been this way since v1.

I'll try and fix forthwith.

@samuelcolvin
Copy link
Member

should be fixed via #1016, please let me know if that solves your problem. If so I'll release it as v1.1.1

@AlbertMukhammadiev
Copy link
Author

Great! Thank you for the quick response!

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

No branches or pull requests

2 participants