Support `from_attributes` in `TypeAdapter.validate_python()` with Pydantic `dataclass`
Author: Arseniy-PopovCreated Jul 1, 2024Updated Sep 17, 2026
Labelsfeature request
Initial Checks
- I have searched Google & GitHub for similar requests and couldn't find anything
- I have read and followed the docs and still think this feature is missing
Description
The note says that
When using
TypeAdapterwith a Pydanticdataclass, the use of thefrom_attributesargument is not supported.
but creating dataclasses from arbitrary types, e.g. SQLAlchemy models, would be useful.
Affected Components
- Compatibility between releases
- Data validation/parsing
- Data serialization -
.model_dump()and.model_dump_json() - JSON Schema
- Dataclasses
- Model Config
- Field Types - adding or changing a particular data type
- Function validation decorator
- Generic Models
- Other Model behaviour -
model_construct(), pickling, private attributes, ORM mode - Plugins and integration with other tools - mypy, FastAPI, python-devtools, Hypothesis, VS Code, PyCharm, etc.
Source: pydantic/pydantic