fix: Add support for Pydantic v2.12 by Mantisus · Pull Request #1471 · apify/crawlee-python
Description
- Add support pydantic v2.12. This uses a workaround to ensure compatibility with
Annotated[..., Field(default_factory=...)]and with type hints.
Issues
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure about this workaround - shouldn't we wait for a fix on the Pydantic side instead?
shouldn't we wait for a fix on the Pydantic side instead?
I'm not sure that Pydantic will fix this. Since the default value was factually ignored before 2.12, we set it for the type checker.
An example of a discussion in the Pydantic repository - pydantic/pydantic#6713 (comment)
vdusek
changed the title
fix: Add support pydantic v2.12
fix: Add support for Pydantic v2.12
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation. The best solution would be if the Pydantic Mypy plugin were able to handle this issue (default_factory vs. standard default field values) - https://docs.pydantic.dev/2.12/integrations/mypy/#enabling-the-plugin. But since it's not the case, this is probably the 2nd best solution, so LGTM.
label
Oct 10, 2025This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters