fix Support types like pydantic.types.PositiveInt #1451 able to check call site #1902
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
part of #1451
Added call-time constraint checking for BaseModel fields: after building the dataclass metadata we now collect each field’s gt/ge/lt/le bounds, map positional slots plus aliases back to field names, infer the argument literals, and report BadArgumentType when a literal violates its declared range, so cases like Model(x=0) or Model(x=15) are caught at the callsite.
Hooked the new checker into AnswersSolver::construct_class, so every BaseModel instantiation is validated immediately after
__init__analysis; since we now reuse the class metadata, this avoids re-fetching it and ensures the diagnostics fire for both positional and keyword arguments.Exposed iter_fields from the dataclass helper so the Pydantic logic can share the same ordering rules, keeping kw-only handling consistent with the existing initializer synthesis.
fix https://github.com/facebook/pyrefly/pull/1458/changes#r2487290587
Test Plan
Updated the regression test so the
Field(gt=0, lt=10)example now expects errors for the invalid calls, reflecting the fix for issue.