-
Notifications
You must be signed in to change notification settings - Fork 182
fix Support types like pydantic.types.PositiveInt #1451 #1458
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
base: main
Are you sure you want to change the base?
Conversation
|
Thank you for this! this would be a great change to support. I will take a more detailed look soon. Also, would that solution also check the "gt"/"lt" etc. field constraints? if we're adding actual range constraints to the solver then we could also leverage this for the "gt" and "lt" testcases? right now, they do not check ranges. They just check against the annotation. |
| class Model(BaseModel): | ||
| value: int = Field(1, gt=0) | ||
| "#, |
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.
I would have expected this testcase in the same file:
from pydantic import BaseModel, Field
class Model(BaseModel):
x: int = Field(gt=0, lt=10)
Model(x=5)
Model(x=0)
Model(x=15)
to now have a different result. Would that diff not support that?
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.
Right now, the new logic only kicks in when we analyze class-body defaults.
If we want to catch those call-site violations too, we’d need a larger follow-up that threads the range constraints through the call analysis (so the solver can reject Model(x=0)
fix #1451
Leveraged new RangeConstraints plumbing so type aliases and annotations keep the Gt/Ge/Lt/Le metadata
Propagated those constraints into Pydantic field metadata and enforced them for class-body defaults, including support for the previously missing le keyword
Added le handling to Pydantic binding constants plus range merging helpers