-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Fix annotation application logic #9623
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
Conversation
Deploying pydantic-docs with
|
| Latest commit: |
37e7348
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://6d944a00.pydantic-docs.pages.dev |
| Branch Preview URL: | https://annotation-application-fix.pydantic-docs.pages.dev |
CodSpeed Performance ReportMerging #9623 will not alter performanceComparing Summary
|
|
Please review |
| COMPARISON_VALIDATORS = { | ||
| 'gt': _validators.greater_than_validator, | ||
| 'ge': _validators.greater_than_or_equal_validator, | ||
| 'lt': _validators.less_than_validator, | ||
| 'le': _validators.less_than_or_equal_validator, | ||
| 'multiple_of': _validators.multiple_of_validator, | ||
| 'min_length': _validators.min_length_validator, | ||
| 'max_length': _validators.max_length_validator, | ||
| } | ||
|
|
||
| CONSTRAINT_STR_FROM_ANNOTATED_TYPE = { | ||
| at.Gt: 'gt', | ||
| at.Ge: 'ge', | ||
| at.Lt: 'lt', | ||
| at.Le: 'le', | ||
| at.MultipleOf: 'multiple_of', | ||
| at.MinLen: 'min_length', | ||
| at.MaxLen: 'max_length', | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels excessive - any better ideas?
| if chain_schema_steps: | ||
| chain_schema_steps = [schema] + chain_schema_steps | ||
| return cs.chain_schema(chain_schema_steps) | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One interesting question here is what happens when you have mixes of constraints that are applied as validator functions vs chain schema additions. This implementation isn't breaking any tests (in fact, fixing bugs), but I could see an argument for considering a pattern for this more carefully.
Fix #9381
I've been wanting to refactor the logic from #9303 for a while, and this seemed like a good time to do that.
Still working on this, want to generally improve the annotation application.
Selected Reviewer: @adriangb