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'm converting a bunch of pydantic dataclasses to base models, and ran into this unhelpful error message that occurs when attempting to instantiate a class that both extends BaseModel and uses the pydantic @dataclass decorator:
pydantic_core._pydantic_core.ValidationError: 1 validation error for Foo
Input should be a valid dictionary or instance of Foo [type=model_type, input_value=ArgsKwargs((), {'a': 1}), input_type=ArgsKwargs]
For further information visit https://errors.pydantic.dev/2.7/v/model_type
the error message should instead say something like this, to explain that the the problem was not some sort of invalid input, but rather that the class itself incorrectly uses both BaseModel and @dataclass:
`Foo` cannot extend `BaseModel` and use the `@dataclass` decorator.
DetachHead
changed the title
"Input should be a valid dictionary or instance" error when using both pydantic dataclass and BaseModel
misleading error message "Input should be a valid dictionary or instance" when using both pydantic dataclass and BaseModelMay 3, 2024
Initial Checks
Description
i'm converting a bunch of pydantic dataclasses to base models, and ran into this unhelpful error message that occurs when attempting to instantiate a class that both extends
BaseModel
and uses the pydantic@dataclass
decorator:the error message should instead say something like this, to explain that the the problem was not some sort of invalid input, but rather that the class itself incorrectly uses both
BaseModel
and@dataclass
:Example Code
Python, Pydantic & OS Version
The text was updated successfully, but these errors were encountered: