We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
For the following minimal code example i get the typing complaint "Method should have "self" as first argument":
from typing import Literal import pydantic class BaseModelClass(pydantic.BaseModel): """ Doctolib search criteria """ attribute: Literal["a", "b"] @pydantic.validator("attribute", pre=True) def lower_case_str(cls, v: str) -> str: return v.lower() x = BaseModelClass(attribute="a") print(x) y = BaseModelClass(attribute="A") print(y)
When i add @classmethod the complaint goes away:
@classmethod @pydantic.validator("attribute", pre=True) def lower_case_str(cls, v: str) -> str:
... but the validation won't get through:
pydantic.error_wrappers.ValidationError: 1 validation error for BaseModelClass attribute unexpected value; permitted: 'a', 'b' (type=value_error.const; given=A; permitted=('a', 'b'))
When i reverse the order everything works fine:
@pydantic.validator("attribute", pre=True) @classmethod def lower_case_str(cls, v: str) -> str:
however i get the warning "This decorator will not receive a callable it may expect; the built-in decorator returns a special object"
How to solve this?
The text was updated successfully, but these errors were encountered:
Is this fixed by #4102?
Sorry, something went wrong.
This is now fixed in v1 and v2
dmontagu
No branches or pull requests
For the following minimal code example i get the typing complaint "Method should have "self" as first argument":
When i add @classmethod the complaint goes away:
... but the validation won't get through:
When i reverse the order everything works fine:
however i get the warning "This decorator will not receive a callable it may expect; the built-in decorator returns a special object"
How to solve this?
The text was updated successfully, but these errors were encountered: