Skip to content

fix Pydantic Field(ge/gt/le/lt=N) with int literal flagged as bad-argument-type on Decimal fields #3403#3411

Open
asukaminato0721 wants to merge 1 commit into
facebook:mainfrom
asukaminato0721:3403
Open

fix Pydantic Field(ge/gt/le/lt=N) with int literal flagged as bad-argument-type on Decimal fields #3403#3411
asukaminato0721 wants to merge 1 commit into
facebook:mainfrom
asukaminato0721:3403

Conversation

@asukaminato0721
Copy link
Copy Markdown
Contributor

@asukaminato0721 asukaminato0721 commented May 15, 2026

Summary

Fixes #3403

Pydantic range constraint metadata unwraps Annotated[...], handles Decimal | None, and accepts int/float-compatible constraint values for Decimal instead of relying only on strict subtype checks.

Test Plan

add test

@github-actions
Copy link
Copy Markdown

According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅

@asukaminato0721 asukaminato0721 marked this pull request as ready for review May 15, 2026 14:45
Copilot AI review requested due to automatic review settings May 15, 2026 14:45
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@rchen152
Copy link
Copy Markdown
Contributor

This strikes me as likely not the right approach. It solves the problem for Decimal but not other types that may be runtime-coercible to one another, and it adds a new way of handling pydantic's runtime type coercion rather than reusing existing logic. But @migeed-z is the expert here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pydantic Field(ge/gt/le/lt=N) with int literal flagged as bad-argument-type on Decimal fields

4 participants