litestar
litestar copied to clipboard
Bug: `__dto__` key for `pydantic.Field` is deprecated and will be removed in v3
Description
Right now dto_field() sets __dto__ attribute on pydantic.Field: https://github.com/litestar-org/litestar/blob/645e41e787b9cb0697bdb32e2997e9149cc49705/tests/unit/test_contrib/test_pydantic/test_pydantic_dto_factory.py#L20-L22
However, this behavior is deprecated:
tests/unit/test_contrib/test_pydantic/test_pydantic_dto_factory.py::test_field_definition_generation
tests/unit/test_contrib/test_pydantic/test_pydantic_dto_factory.py::test_field_definition_generation
/home/runner/work/litestar/litestar/.venv/lib/python3.11/site-packages/pydantic/fields.py:792: PydanticDeprecatedSince20: Using extra keyword arguments on `Field` is deprecated and will be removed. Use `json_schema_extra` instead. (Extra keys: '__dto__'). Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.3/migration/
warn(
Looks like we need to rework how dto_field is set on pydantic.Field
URL to code causing the issue
No response
MCVE
No response
Steps to reproduce
No response
Screenshots
No response
Logs
No response
Litestar Version
main
Platform
- [X] Linux
- [X] Mac
- [X] Windows
- [ ] Other (Please specify in the description above)
Funding
- If you would like to see an issue prioritized, make a pledge towards it!
- We receive the pledge once the issue is completed & verified
@peterschutt, any ideas?
@peterschutt, any ideas?
Maybe via Annotated?
This issue has been closed in #3289. The change will be included in the upcoming patch release.
A fix for this issue has been released in v2.8.0