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

Fix various issues with dataclasses anduse_attribute_docstrings#11246

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 4 commits intomainfromdataclasses-fixes
Jan 14, 2025

Conversation

Viicos
Copy link
Member

@ViicosViicos commentedJan 9, 2025
edited
Loading

Change Summary

Fixes#11243.

Edit post 2.11 release:fixes#11133.

Best reviewed commit per commit.

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

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

cloudflare-workers-and-pagesbot commentedJan 9, 2025
edited
Loading

Deploying pydantic-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit:dbc6825
Status: ✅  Deploy successful!
Preview URL:https://425a87be.pydantic-docs.pages.dev
Branch Preview URL:https://dataclasses-fixes.pydantic-docs.pages.dev

View logs

@github-actionsgithub-actionsbot added the relnotes-fixUsed for bugfixes. labelJan 9, 2025
@codspeed-hqCodSpeed HQ
Copy link

codspeed-hqbot commentedJan 9, 2025
edited
Loading

CodSpeed Performance Report

Merging#11246 willimprove performances by 10.84%

Comparingdataclasses-fixes (dbc6825) withmain (8ef33a0)

Summary

⚡ 1 improvements
✅ 44 untouched benchmarks

Benchmarks breakdown

Benchmarkmaindataclasses-fixesChange
test_construct_dataclass_schema2.1 ms1.9 ms+10.84%

@github-actionsGitHub Actions
Copy link
Contributor

github-actionsbot commentedJan 9, 2025
edited
Loading

Coverage report

This PR does not seem to contain any modification to coverable code.

Copy link
Contributor

@sydney-runklesydney-runkle left a comment

Choose a reason for hiding this comment

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

Nice work overall, left a few comments / questions. Thanks!

Comment on lines +67 to +71
def _update_fields_from_docstrings(cls: type[Any], fields: dict[str, FieldInfo], use_inspect: bool = False) -> None:
fields_docs = extract_docstrings_from_cls(cls, use_inspect=use_inspect)
for ann_name, field_info in fields.items():
if field_info.description is None and ann_name in fields_docs:
field_info.description = fields_docs[ann_name]
Copy link
Contributor

Choose a reason for hiding this comment

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

Re letting callers decide if this is necessary - I assume this is for general cleanliness and to avoid the overhead of a function call if not necessary?

Viicos reacted with thumbs up emoji
…in the process of being builtDo not rely on `__pydantic_validator__`, an attribute which is setonly when the class is fully built. Because we check for this conditionduring schema building, we end up considering the class as a stdlibdataclass.As a consequence, the deepcopy logic of `FieldInfo` instances wastweaked, as in some tests, the deep copy would fail. Instead, makea shallow copy of every `FieldInfo` instance, this is enough(the same thing is done in `collect_model_fields` for Pydanticmodels, we make a shallow copy of the parent fields).
Let callers be responsible for checking if using docstrings isnecessary.
Copy link
Contributor

@sydney-runklesydney-runkle left a comment

Choose a reason for hiding this comment

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

Otherwise, lgtm!

@ViicosViicosenabled auto-merge (squash)January 14, 2025 09:39
@ViicosViicos merged commitdb061c2 intomainJan 14, 2025
58 checks passed
@ViicosViicos deleted the dataclasses-fixes branchJanuary 14, 2025 09:42
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@sydney-runklesydney-runklesydney-runkle approved these changes

Assignees
No one assigned
Labels
relnotes-fixUsed for bugfixes.
Projects
None yet
Milestone
No milestone
2 participants
@Viicos@sydney-runkle

[8]ページ先頭

©2009-2025 Movatter.jp