You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have searched GitHub for a duplicate issue and I'm sure this is something new
I have searched Google & StackOverflow for a solution and couldn't find anything
I have read and followed the docs and still think this is a bug
I am confident that the issue is with pydantic (not my code, or another library in the ecosystem like FastAPI or mypy)
Description
post_init and validator are not triggered in the following code. However, uncommenting any of the lines: py_dataclass(D_C_Base) or b: str = "string" solves the issue.
Versions 1.9.x could trigger both post_init and validators without these lines.
Example Code
fromdataclassesimportdataclassfrompydantic.dataclassesimportdataclassaspy_dataclassfrompydanticimportvalidator@dataclassclassD_C_Base:
a: float=1.0# py_dataclass(D_C_Base)@py_dataclassclassD_C_Child(D_C_Base):
# b: str = "string"def__post_init__(self):
print('POST_INIT')
@validator('a')defvalidate_a(cls, value):
print(f'Validating "a" is {value}')
d_c_class=D_C_Child()
togrishka
changed the title
__post_init__ and validators are not triggered in class inherited from stdlib dataclass
__post_init__ and validators are not triggered in class inherited from stdlib dataclass in 1.10.1
Sep 4, 2022
Initial Checks
Description
post_init and validator are not triggered in the following code. However, uncommenting any of the lines:
py_dataclass(D_C_Base)
orb: str = "string"
solves the issue.Versions 1.9.x could trigger both post_init and validators without these lines.
Example Code
Python, Pydantic & OS Version
Affected Components
.dict()
and.json()
construct()
, pickling, private attributes, ORM modeThe text was updated successfully, but these errors were encountered: