Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Comments

⬆️ Update mypy to 1.14.1#12970

Merged
tiangolo merged 10 commits intofastapi:masterfrom
tamird:mypy-bump-pydantic
Sep 20, 2025
Merged

⬆️ Update mypy to 1.14.1#12970
tiangolo merged 10 commits intofastapi:masterfrom
tamird:mypy-bump-pydantic

Conversation

@tamird
Copy link
Contributor

@tamirdtamird commentedNov 22, 2024
edited
Loading

Depends on#12971.

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@tamirdtamird changed the titleUpdate and fix mypyUpgrade and fix mypyNov 22, 2024
@tamirdtamird changed the titleUpgrade and fix mypy♻️ Update and fix mypyNov 22, 2024
@tamirdtamird changed the title♻️ Update and fix mypy♻️ Update mypy to 1.13.0Nov 22, 2024
@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@svlandegsvlandeg added dependenciesPull requests that update a dependency file upgrade labelsNov 25, 2024
@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@tamird
Copy link
ContributorAuthor

@alejsdev could you please take a look? This is relatively trivial.

@github-actions

This comment was marked as outdated.

@tamird
Copy link
ContributorAuthor

@Kludex thanks for the approval. Are you able to land this please?

@Kludex
Copy link
Member

No. I don't merge PRs.

@svlandegsvlandeg changed the title♻️ Update mypy to 1.13.0⬆️ Update mypy to 1.13.0Jan 20, 2025
@tamird
Copy link
ContributorAuthor

@tiangolo could you please have a look? you merged#12971 quickly but perhaps forgot about this one.

@tamirdtamird changed the title⬆️ Update mypy to 1.13.0⬆️ Update mypy to 1.15.0Feb 5, 2025
@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@YuriiMotovYuriiMotov changed the title⬆️ Update mypy to 1.15.0, ruff to 0.9.4⬆️ Update mypy to 1.14.1 (last version compatible with Python 3.8), installpydantic.mypy pluginJun 30, 2025
Copy link
Member

@YuriiMotovYuriiMotov left a comment

Choose a reason for hiding this comment

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

LGTM

Maybe we should extract the part related to plugin installation into a separate PR, but doesn't seem critical to me

@tamird
Copy link
ContributorAuthor

Thank you@YuriiMotov. Are you planning to merge this?

@svlandegsvlandeg changed the title⬆️ Update mypy to 1.14.1 (last version compatible with Python 3.8), installpydantic.mypy plugin⬆️ Update mypy to 1.14.1 and installpydantic.mypy pluginSep 16, 2025
@svlandegsvlandeg assignedsvlandeg and unassignedtiangoloSep 16, 2025
@github-actions
Copy link
Contributor

📝 Docs preview for commit21c8f18 at:https://c3a1493f.fastapitiangolo.pages.dev

@svlandegsvlandeg changed the title⬆️ Update mypy to 1.14.1 and installpydantic.mypy plugin⬆️ Update mypy to 1.14.1Sep 16, 2025
Copy link
Member

@svlandegsvlandeg left a comment

Choose a reason for hiding this comment

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

Ok, so in an attempt to get this merged, I've moved the pydantic.mypy plugin changes to a separate PR#14081. This makes it easier to review which changes are causing what, as several reviewers had questions about what exactly is needed and what relates to what.

For this PR, the goal is simply to update tomypy 1.14.1. When doing so, we're getting 2 similar errors:

fastapi\encoders.py:244: error: Argument 1 to "asdict" has incompatible type "DataclassInstance | type[DataclassInstance]"; expected "DataclassInstance"  [arg-type]

What happens here is that first, we're callingdataclasses.is_dataclass(obj).

Due tothe typing of this method in theirdataclasses.pyi,mypy will go and typeobj asDataclassInstance | type[DataclassInstance]. This then doesn't align with the signature of the followingdataclasses.asdict(obj) statement, which expects aDataclassInstance.

So, these are the possible fixes for this:

  • add an ignore statement
  • add atype() call before callingis_dataclass, as@tamird suggests. This isn't actually necessary, because the implementation ofdataclasses.is_dataclass will calltype() when necessary. However, by doing this, we trickmypy into assuming thatobj is NOT atype[DataclassInstance] and then it won't error on the followingasdict call
  • inbetween the originalis_dataclass check and theasdict call, add the following:assert not isinstance(obj, type). This again will tellmypy not to assume theobj is a type. To me, this is the most direct/clear solution, but I think it's a matter of taste.

Will run this by Tiangolo to get his opinion.

@svlandegsvlandeg removed their assignmentSep 16, 2025
@tiangolo
Copy link
Member

Thanks a lot for the investigation and clarification with all the context@svlandeg! Yep, it makes more sense to me to useassert there instead of usingtype() inside of it.

svlandeg reacted with thumbs up emoji

Copy link
Member

@tiangolotiangolo left a comment

Choose a reason for hiding this comment

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

Nice, thanks! 🚀

And thanks@svlandeg for the analysis, discussion and work on this! 🙌

svlandeg reacted with rocket emoji
@tiangolotiangolo merged commita95e91e intofastapi:masterSep 20, 2025
29 checks passed
@tamirdtamird deleted the mypy-bump-pydantic branchSeptember 20, 2025 12:15
@tiangolotiangolo added internal and removed upgrade labelsSep 20, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@svlandegsvlandegsvlandeg left review comments

@tiangolotiangolotiangolo approved these changes

@KludexKludexKludex approved these changes

@YuriiMotovYuriiMotovYuriiMotov approved these changes

Assignees

No one assigned

Labels

dependenciesPull requests that update a dependency fileinternal

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

5 participants

@tamird@Kludex@tiangolo@svlandeg@YuriiMotov

[8]ページ先頭

©2009-2026 Movatter.jp