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

Use the globals of the function when evaluating the return type of serializers and computed_fields#10929

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 1 commit intomainfromfunc-rt
Nov 21, 2024

Conversation

Viicos
Copy link
Member

Fixes#10919

Change Summary

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. labelNov 21, 2024
@cloudflare-workers-and-pagesCloudflare Workers and Pages

Deploying pydantic-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit:821184f
Status: ✅  Deploy successful!
Preview URL:https://2cc7b3e8.pydantic-docs.pages.dev
Branch Preview URL:https://func-rt.pydantic-docs.pages.dev

View logs

Comment on lines -1305 to -1308
@pytest.mark.xfail(
reason='In `GenerateSchema`, only the current class module is taken into account. '
'This is similar to `test_uses_the_correct_globals_to_resolve_model_forward_refs`.'
)
Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Turns out this used to work. However, the mentionedtest_uses_the_correct_globals_to_resolve_model_forward_refs test was also failing on 2.9

sydney-runkle reacted with heart emoji
@create_module
def module_1():
from pydantic import BaseModel, field_serializer # or model_serializer
from pydantic import BaseModel, field_serializer # or model_serializer, computed_field
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
frompydanticimportBaseModel,field_serializer# or model_serializer, computed_field
frompydanticimportBaseModel,field_serializer# or model_serializer

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

The goal was to mentioned that this also applied tocomputed_field

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, but it's not included in the example?

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

It is commented out, just to mention that the same logic applies to the three decorators. We could add a test for each alternatively.

Copy link
Contributor

Choose a reason for hiding this comment

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

oh my goodness 😢 sorry I missed that 🫨. Thanks! Let's merge :)

@sydney-runkle
Copy link
Contributor

Looking good, I'm guessing there are changes toget_function_return_type as well?

@codspeed-hqCodSpeed HQ
Copy link

CodSpeed Performance Report

Merging#10929 willnot alter performance

Comparingfunc-rt (821184f) withmain (3cb6852)

Summary

✅ 46 untouched benchmarks

@github-actionsGitHub Actions
Copy link
Contributor

Coverage report

Click to see where and how coverage changed

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

This report was generated bypython-coverage-comment-action

@Viicos
Copy link
MemberAuthor

Looking good, I'm guessing there are changes toget_function_return_type as well?

Not passing any globals will letget_function_return_type ->get_function_type_hints fetch them usingfunc.__module__

sydney-runkle reacted with thumbs up emoji

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, good find. Thanks for the speedy fix.

@sydney-runklesydney-runkle merged commit22a9af2 intomainNov 21, 2024
55 checks passed
@sydney-runklesydney-runkle deleted the func-rt branchNovember 21, 2024 17:35
sydney-runkle pushed a commit that referenced this pull requestNov 22, 2024
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
Development

Successfully merging this pull request may close these issues.

2.10: Issue with forward annotations and serializers/computed_field (raises:<model> is not fully defined)
2 participants
@Viicos@sydney-runkle

[8]ページ先頭

©2009-2025 Movatter.jp