Skip to content

Do not evaluate annotations when inspecting validators and serializers#12355

Merged
Viicos merged 1 commit intomainfrom
signature-no-eval
Oct 8, 2025
Merged

Do not evaluate annotations when inspecting validators and serializers#12355
Viicos merged 1 commit intomainfrom
signature-no-eval

Conversation

@Viicos
Copy link
Copy Markdown
Member

@Viicos Viicos commented Oct 8, 2025

Change Summary

Fixes #12353.

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

@Viicos Viicos added relnotes-fix Used for bugfixes. backport-2.13 Needs backport to 2.13 labels Oct 8, 2025
@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying pydantic-docs with  Cloudflare Pages  Cloudflare Pages

Latest commit: 7021708
Status: ✅  Deploy successful!
Preview URL: https://7dff2d69.pydantic-docs.pages.dev
Branch Preview URL: https://signature-no-eval.pydantic-docs.pages.dev

View logs

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Oct 8, 2025

Coverage report

Click to see where and how coverage changed

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

This report was generated by python-coverage-comment-action

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented Oct 8, 2025

CodSpeed Performance Report

Merging #12355 will improve performances by 6.47%

Comparing signature-no-eval (7021708) with main (f839721)

Summary

⚡ 1 improvement
✅ 45 untouched

Benchmarks breakdown

Benchmark BASE HEAD Change
test_model_validators_serializers 817.1 µs 767.5 µs +6.47%

assert A(a='1').a == 1


def test_deferred_annotations_return_values() -> None:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Worth testing wrap forms too?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

The decorated function inspection doesn't special case modes, so I think this should be fine

@Viicos Viicos merged commit 024e292 into main Oct 8, 2025
66 checks passed
@Viicos Viicos deleted the signature-no-eval branch October 8, 2025 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-2.13 Needs backport to 2.13 relnotes-fix Used for bugfixes.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2.12.0: Method decorated with model_validator runs into error when annotated with containing class's name as return type

2 participants