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

Deprecate accessingmodel_fields andmodel_computed_fields on instances#11169

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
sydney-runkle merged 3 commits intomainfrom10930
Dec 30, 2024

Conversation

Viicos
Copy link
Member

@ViicosViicos commentedDec 21, 2024
edited
Loading

Change Summary

Fixes#10930.
Requires#11168, which defines the new deprecation class.

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

sydney-runkle reacted with thumbs up emoji
…tancesAlso reorder `BaseModel` members in API documentation.
@github-actionsgithub-actionsbot added the relnotes-fixUsed for bugfixes. labelDec 21, 2024
@cloudflare-workers-and-pagesCloudflare Workers and Pages
Copy link

cloudflare-workers-and-pagesbot commentedDec 21, 2024
edited
Loading

Deploying pydantic-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit:b871688
Status: ✅  Deploy successful!
Preview URL:https://7a2dc613.pydantic-docs.pages.dev
Branch Preview URL:https://10930.pydantic-docs.pages.dev

View logs

@codspeed-hqCodSpeed HQ
Copy link

codspeed-hqbot commentedDec 21, 2024
edited
Loading

CodSpeed Performance Report

Merging#11169 willnot alter performance

Comparing10930 (b871688) withmain (d823d8c)

Summary

✅ 46 untouched benchmarks

Copy link
Contributor

@hyperlint-aihyperlint-aibot left a comment

Choose a reason for hiding this comment

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

The style guide flagged several spelling errors that seemed like false positives. We skipped posting inline suggestions for the following words:

  • [Mm]odel_fields

@github-actionsGitHub Actions
Copy link
Contributor

github-actionsbot commentedDec 21, 2024
edited
Loading

Coverage report

Click to see where and how coverage changed

FileStatementsMissingCoverageCoverage
(new stmts)
Lines missing
  pydantic
  main.py
  pydantic/_internal
  _utils.py
Project Total 

This report was generated bypython-coverage-comment-action

@@ -814,26 +814,3 @@ def my_field_serializer(self, value: Any, info: FieldSerializationInfo) -> Any:
return f'{info.field_name} = {value}'

assert MyModel().model_dump() == {'my_field': 'my_field = foo', 'other_field': 'other_field = 42'}


def test_fields_on_instance_and_cls() -> None:
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Tested intest_deprecated.py

@ViicosViicos added relnotes-changeUsed for changes to existing functionality which don't have a better categorization. and removed relnotes-fixUsed for bugfixes. labelsDec 23, 2024
@@ -34,5 +34,6 @@ class Knight(BaseModel):

assert_type(Knight.model_fields, dict[str, FieldInfo])
assert_type(Knight.model_computed_fields, dict[str, ComputedFieldInfo])
assert_type(k.model_fields, dict[str, FieldInfo])
assert_type(k.model_computed_fields, dict[str, ComputedFieldInfo])
# Mypy does not report the deprecated access (https://github.com/python/mypy/issues/18323):
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

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.

This looks good to me overall. Surprised that we had so many tests accessing these attributes on instances :(.

I've requested a few wording changes + maybe a chance to the already deprecated__fields__ as well.

I'd like to get input from@samuelcolvin on this PR before we merge, we can chat about this in our next sync 👍

@pydantic-hookypydantic-hookybot added awaiting author revisionawaiting changes from the PR author labelsDec 27, 2024
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.

Thought about this a bit more. I definitely think this makes sense to deprecate.

We haven't lost any functionality here, so I'm alright with going ahead and merging. I don't think@samuelcolvin would object to a simple deprecation here.

@Viicos
Copy link
MemberAuthor

Yes to be clear, this was already deprecated by#10493, but this goes one step further by actually raising the deprecation warning and type checking error

sydney-runkle reacted with thumbs up emoji

@sydney-runklesydney-runkle merged commitcfd4c9f intomainDec 30, 2024
59 checks passed
@sydney-runklesydney-runkle deleted the 10930 branchDecember 30, 2024 16:12
bruno-f-cruz added a commit to AllenNeuralDynamics/Aind.Behavior.Services that referenced this pull requestMay 5, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@hyperlint-aihyperlint-ai[bot]hyperlint-ai[bot] left review comments

@sydney-runklesydney-runklesydney-runkle approved these changes

Assignees

@ViicosViicos

Labels
awaiting author revisionawaiting changes from the PR authorrelnotes-changeUsed for changes to existing functionality which don't have a better categorization.
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

For v2.11: use custom decorator formodel_fields andmodel_computed_fields
2 participants
@Viicos@sydney-runkle

[8]ページ先頭

©2009-2025 Movatter.jp