Skip to content

Conversation

@Mantisus
Copy link
Collaborator

@Mantisus Mantisus commented Oct 8, 2025

Description

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

Issues

@Mantisus Mantisus requested review from janbuchar and vdusek and removed request for vdusek October 8, 2025 15:12
@Mantisus Mantisus self-assigned this Oct 8, 2025
Copy link
Collaborator

@vdusek vdusek left a comment

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
Copy link
Collaborator Author

Mantisus commented Oct 9, 2025

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
Copy link
Collaborator

@vdusek vdusek left a comment

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 merged commit 35c1108 into apify:master Oct 10, 2025
19 of 20 checks passed
@vdusek vdusek added the t-tooling Issues with this label are in the ownership of the tooling team. label Oct 10, 2025
@vdusek vdusek added this to the 125th sprint - Tooling team milestone Oct 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Updating to Pydantic >3.11.9 causes TypeError on import

2 participants