Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(lint): get around a Pydantic 2.10.x type bug #566

Merged
merged 2 commits into from
Nov 25, 2024

Conversation

tigarmo
Copy link
Contributor

@tigarmo tigarmo commented Nov 25, 2024

Both mypy and pyright complain that the "field.default_factory()" call has too few arguments, even though its type is typing.Callable[[], Any]. It should be fixed soon, and in the meantime we can ignore the spurious error.

Ref: pydantic/pydantic#10945

  • Have you followed the guidelines for contributing?
  • Have you signed the CLA?
  • Have you successfully run tox?

Both mypy and pyright complain that the "field.default_factory()" call has too
few arguments, even though its type is typing.Callable[[], Any]. It should be
fixed soon, and in the meantime we can ignore the spurious error.

Ref: pydantic/pydantic#10945
Copy link
Contributor

@dariuszd21 dariuszd21 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@tigarmo tigarmo requested a review from a team November 25, 2024 19:10
Copy link
Contributor

@bepri bepri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we include some sort of "# TODO:" comment or something to remind us to come back and remove this ignore directive? I can see this accidentally staying for a long time after the bug is fixed otherwise.

@tigarmo tigarmo requested a review from bepri November 25, 2024 19:23
Copy link
Contributor

@bepri bepri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@tigarmo tigarmo merged commit bb813c4 into main Nov 25, 2024
9 checks passed
@tigarmo tigarmo deleted the work/fix-pydantic-lint branch November 25, 2024 19:35
@Viicos
Copy link

Viicos commented Dec 3, 2024

Note that pydantic/pydantic#10945 won't get fixed as you could expect. Instead, I would suggest following the approach I suggested in this comment. In 2.10.3 (to be released soon), I'll add an extra attribute on the FieldInfo class to check if the default_factory takes an extra argument.

@tigarmo
Copy link
Contributor Author

tigarmo commented Dec 3, 2024

@Viicos thanks for the heads-up!

linostar pushed a commit to linostar/craft-application that referenced this pull request Dec 4, 2024
Both mypy and pyright complain that the "field.default_factory()" call has too
few arguments, even though its type is typing.Callable[[], Any]. It should be
fixed soon, and in the meantime we can ignore the spurious error.

Ref: pydantic/pydantic#10945
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants