fix: Add support for Pydantic v2.12 by Mantisus · Pull Request #1471 · apify/crawlee-python

@Mantisus

Description

  • Add support pydantic v2.12. This uses a workaround to ensure compatibility with Annotated[..., Field(default_factory=...)] and with type hints.

Issues

@Mantisus

vdusek

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?

@Mantisus

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 vdusek changed the title fix: Add support pydantic v2.12 fix: Add support for Pydantic v2.12

Oct 10, 2025

vdusek

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.

@vdusek vdusek added the t-tooling

Issues with this label are in the ownership of the tooling team.

label

Oct 10, 2025