-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
bug V1Bug related to Pydantic V1.XBug related to Pydantic V1.X
Description
Initial Checks
- 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
when instanciating a dataclass where a property is a list or dict of another dataclass, it causes this error:
extra fields not permitted (type=value_error.extra)
Example Code
from pydantic import Extra
from pydantic.dataclasses import dataclass
class ExtraPropertiesForbidden:
extra = Extra.forbid
@dataclass(config=ExtraPropertiesForbidden)
class Bar:
...
@dataclass(config=ExtraPropertiesForbidden)
class Foo:
a: list[Bar]
a = Foo(a=[Bar()]) # error: extra fields not permitted (type=value_error.extra)Python, Pydantic & OS Version
this issue seems to have been introduced after the 1.9.1 release. this occurred after installing the latest commit from master:
pip uninstall pydantic
pip install git+https://github.com/samuelcolvin/pydantic.git@a69136d2096e327ed48954a298c775dceb1551d1
pydantic version: 1.9.0
pydantic compiled: False
install path: C:\Users\chungus\AppData\Local\pypoetry\Cache\virtualenvs\project-e01-Hfn1-py3.10\Lib\site-packages\pydantic
python version: 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)]
platform: Windows-10-10.0.19042-SP0
optional deps. installed: ['typing-extensions']
Affected Components
- Compatibility between releases
- Data validation/parsing
- Data serialization -
.dict()and.json() - JSON Schema
- Dataclasses
- Model Config
- Field Types - adding or changing a particular data type
- Function validation decorator
- Generic Models
- Other Model behaviour -
construct(), pickling, private attributes, ORM mode - Settings Management
- Plugins and integration with other tools - mypy, FastAPI, python-devtools, Hypothesis, VS Code, PyCharm, etc.
DetachHead and KotlinIsland
Metadata
Metadata
Assignees
Labels
bug V1Bug related to Pydantic V1.XBug related to Pydantic V1.X