Skip to content

Conversation

Viicos
Copy link
Member

@Viicos Viicos commented Nov 21, 2024

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-actions github-actions bot added the relnotes-fix Used for bugfixes. label Nov 21, 2024
Copy link

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
Member Author

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 mentioned test_uses_the_correct_globals_to_resolve_model_forward_refs test was also failing on 2.9

@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
from pydantic import BaseModel, field_serializer # or model_serializer, computed_field
from pydantic import BaseModel, field_serializer # or model_serializer
Copy link
Member Author

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 to 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.

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

Copy link
Member Author

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 to get_function_return_type as well?

Copy link

codspeed-hq bot commented Nov 21, 2024

CodSpeed Performance Report

Merging #10929 will not alter performance

Comparing func-rt (821184f) with main (3cb6852)

Summary

✅ 46 untouched benchmarks

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 by python-coverage-comment-action

@Viicos
Copy link
Member Author

Viicos commented Nov 21, 2024

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

Not passing any globals will let get_function_return_type -> get_function_type_hints fetch them using func.__module__

Copy link
Contributor

@sydney-runkle sydney-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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

relnotes-fix Used for bugfixes.

2 participants