-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Labels
bug V1Bug related to Pydantic V1.XBug related to Pydantic V1.X
Milestone
Description
Checks
- I added a descriptive title to this issue
- I have searched (google, github) for similar issues and couldn't find anything
- I have read and followed the docs and still think this is a bug
Bug
Output of python -c "import pydantic.utils; print(pydantic.utils.version_info())":
pydantic version: 1.9.0
pydantic compiled: True
install path: /home/veikman/.local/lib/python3.9/site-packages/pydantic
python version: 3.9.7 (default, Sep 10 2021, 14:59:43) [GCC 11.2.0]
platform: Linux-5.11.0-38-generic-x86_64-with-glibc2.34
optional deps. installed: ['typing-extensions']
Minimal reproducing script:
from __future__ import annotations
from typing import List
from pydantic.dataclasses import dataclass
@dataclass
class Node:
children: List[Node]
Node.__pydantic_model__.update_forward_refs()
Node(children=[Node(children=[])]) # Case 1.
Node(children=[dict(children=[])]) # Case 2.Case 1 in the sample script works as expected with Pydantic v1.8.2. In Pydantic 1.9.0, that upgrade being the only change to the environment, it produces this validation error:
children -> 0
value is not a valid dict (type=type_error.dict)
Case 2 works with both versions of Pydantic, indicating that the validation error message as such is correct.
I conclude that Pydantic v1.9.0 breaks support for Pydantic dataclasses as field data types on themselves (recursive nesting), for the case of input in the form of dataclass instances (case 1), which was a useful feature for unit testing. I have found no announcement in the change log that this is intentional.
peterschutt and samuelcolvin
Metadata
Metadata
Assignees
Labels
bug V1Bug related to Pydantic V1.XBug related to Pydantic V1.X