Skip to content

Fix Decimal comparisons in enum and const - #249

Open
mayankdhingra02 wants to merge 1 commit into
horejsek:masterfrom
mayankdhingra02:codex/json-instance-equality
Open

mayankdhingra02 wants to merge 1 commit into
horejsek:masterfrom
mayankdhingra02:codex/json-instance-equality

Conversation

@mayankdhingra02

Copy link
Copy Markdown
Contributor

Numeric enum and const comparisons omit Decimal from their type guards, although the validator supports it as a number. An enum containing 1 rejects Decimal("1"); a numeric schema literal loaded with parse_float=Decimal can instead compare equal to a boolean.

Recognize Decimal values in both the schema-literal and generated runtime guards. Regression cases cover scalar and nested values, boolean rejection, compiled and generated validators, the explicit draft 04, 06, 07 and 2019-09 dispatches and both exception modes.

Validation on macOS arm64:

  • Full CI test command on CPython 3.10–3.14: 6,538 passed per version, plus 12 deselections, 335 expected failures and 805 non-strict XPASS results. The 3.13 baseline passes 5,698 tests with those same fixture statuses.
  • The 840-case focused matrix has 448 failures and 392 controls before the change; all pass afterward.
  • Pylint retains the same 10 baseline diagnostics and 9.90/10 score (exit 12).
  • Clean installed wheel and rebuilt source distribution on Python 3.10 each pass 280 real JSON/Decimal consumer scenarios and two ordinary-schema controls. Generated validators run from actual Python files. Twine passes with missing-description-content-type warnings.

The existing Python numeric comparisons are preserved; for example, Decimal("0.1") still differs from the binary float 0.1. This does not claim broader draft 2019-09 conformance. Targeted generated-client timing measured roughly 2–6% overhead in simple literal-only numeric cases from the additional accepted type. Other operating systems were not run locally.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant