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

Do not duplicate metadata on model rebuild#11902

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Viicos merged 2 commits intov2.11-fixesfrom11870-2.11-fix
May 22, 2025
Merged

Conversation

Viicos
Copy link
Member

@ViicosViicos commentedMay 22, 2025
edited
Loading

Change Summary

This is a stripped down version of#11898, as a backport to 2.11. In 2.11, a change in the model rebuild logic surfaced an issue withFieldInfo being wrongly mutated and copied properly, resulting in a regression.

#11898 is a proper refactor, but can't be fully backported as it would be too risky as a patch release.

Fixes (for 2.11)#11870.

Third-party tests output.

Related issue number

Checklist

  • The pull request title is a good summary of the changes - it will be used in the changelog
  • Unit tests for the changes exist
  • Tests pass on CI
  • Documentation reflects the changes where applicable
  • My PR is ready to review,please add a comment including the phrase "please review" to assign reviewers

@github-actionsgithub-actionsbot added the relnotes-fixUsed for bugfixes. labelMay 22, 2025
@ViicosViicos added the third-party-testsAdd this label on a PR to trigger 3rd party tests labelMay 22, 2025
@ViicosViicos closed thisMay 22, 2025
@ViicosViicos reopened thisMay 22, 2025
@ViicosViicos removed the third-party-testsAdd this label on a PR to trigger 3rd party tests labelMay 22, 2025
@codspeed-hqCodSpeed HQ
Copy link

codspeed-hqbot commentedMay 22, 2025
edited
Loading

CodSpeed Performance Report

Merging#11902 willnot alter performance

Comparing11870-2.11-fix (cb10455) withmain (1f967d7)

Summary

✅ 46 untouched benchmarks

@github-actionsGitHub Actions
Copy link
Contributor

github-actionsbot commentedMay 22, 2025
edited
Loading

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  pydantic
  fields.py
Project Total 

This report was generated bypython-coverage-comment-action

@cloudflare-workers-and-pagesCloudflare Workers and Pages
Copy link

cloudflare-workers-and-pagesbot commentedMay 22, 2025
edited
Loading

Deploying pydantic-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit:cb10455
Status: ✅  Deploy successful!
Preview URL:https://43275662.pydantic-docs.pages.dev
Branch Preview URL:https://11870-2-11-fix.pydantic-docs.pages.dev

View logs

Comment on lines +591 to +598
def _copy(self) -> Self:
copied = copy(self)
for attr_name in ('metadata', '_attributes_set', '_qualifiers'):
# Apply "deep-copy" behavior on collections attributes:
value = getattr(copied, attr_name).copy()
setattr(copied, attr_name, value)

return copied
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

We can't define a custom__copy__(), because I couldn't find a way to delegate tocopy.copy() and then apply the special case formetadata,_attributes_set and_qualifiers.

The following could still be done:

def__copy__(self)->Self:cls=type(self)copied=cls()forattr_nameincls.__slots__:value=getattr(self,attr_name)ifattr_namein ('metadata','_attributes_set','_qualifiers'):# Apply "deep-copy" behavior on collections attributes:value=value.copy()setattr(copied,attr_name,value)returncopied

But this blows up on libraries (FastAPI/SQLModel) subclassingFieldInfo (not the first time this is causing issues..) as we don't know which extra attributes are defined on these classes.

@ViicosViicos merged commit1b63218 intov2.11-fixesMay 22, 2025
51 checks passed
@ViicosViicos deleted the 11870-2.11-fix branchMay 22, 2025 20:50
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
relnotes-fixUsed for bugfixes.
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

1 participant
@Viicos

[8]ページ先頭

©2009-2025 Movatter.jp