8000 Fix: do not check for `__get_validators__` on classes where `__get_pydantic_core_schema__` is also defined by tlambert03 · Pull Request #11444 · pydantic/pydantic · GitHub
[go: up one dir, main page]

Skip to content

Fix: do not check for __get_validators__ on classes where __get_pydantic_core_schema__ is also defined #11444

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 17, 2025

Conversation

tlambert03
Copy link
Contributor
@tlambert03 tlambert03 commented Feb 14, 2025

Related issue number

fixes #11443 by not checking for the existence of __get_validators__ on classes where __get_pydantic_core_schema__ is also defined. See also #10863, which introduced the change

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

Selected Reviewer: @sydney-runkle

@github-actions github-actions bot added the relnotes-fix Used for bugfixes. label Feb 14, 2025
@tlambert03 tlambert03 changed the title fix: Fix conditional check for validators in schema generation fix: do not check for __get_validators__ on classes where __get_pydantic_core_schema__ is also defined Feb 14, 2025
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

Copy link
codspeed-hq bot commented Feb 14, 2025

CodSpeed Performance Report

Merging #11444 will not alter performance

Comparing tlambert03:fix-gen-schema (e5f0a81) with main (2f3e1ac)

Summary

✅ 46 untouched benchmarks

@tlambert03
Copy link
Contributor Author

please review ... thanks!

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.

Wonderful, thanks @tlambert03!

We always appreciate your contributions. The clean unit test is great!

@sydney-runkle
Copy link
Contributor

Exciting to see that this was caught by folks testing alpha releases. This really helps on our end.

@sydney-runkle sydney-runkle merged commit c2102b7 into pydantic:main Feb 17, 2025
53 checks passed
@sydney-runkle sydney-runkle changed the title fix: do not check for __get_validators__ on classes where __get_pydantic_core_schema__ is also defined Fix: do not check for __get_validators__ on classes where __get_pydantic_core_schema__ is also defined Feb 17, 2025
@tlambert03
Copy link
Contributor Author

thanks @sydney-runkle :)

@tlambert03 tlambert03 deleted the fix-gen-schema branch February 17, 2025 15:57
@Viicos
Copy link
Member
Viicos commented Feb 17, 2025

@tlambert03 @sydney-runkle I was in the process of answering in the linked issue. This might have to be reverted/changed.

@tlambert03
Copy link
Contributor Author

no worries. just let us know what you learn, feel free to revert or change as needed

@Viicos
Copy link
Member
Viicos commented Feb 17, 2025

Side note: this only works because a deprecated __get_pydantic_core_schema__() method is defined on BaseModel. This fix will no longer work when this method will be removed from BaseModel in v3, but the support for __get_validators__() will also be removed at this point.

@tlambert03
Copy link
Contributor Author

ah, gotcha. Thanks for the clarification

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Broken validation of fields in `pydantic==2.11.0a{1,2}
3 participants
0