Skip to content

Preserve exact integer arithmetic for multipleOf - #229

Open
mayankdhingra02 wants to merge 1 commit into
horejsek:masterfrom
mayankdhingra02:fix-integer-multiple-of
Open

mayankdhingra02 wants to merge 1 commit into
horejsek:masterfrom
mayankdhingra02:fix-integer-multiple-of

Conversation

@mayankdhingra02

Copy link
Copy Markdown

multipleOf currently accepts odd 64-bit integers such as 2**63 - 1 as multiples of 2 because true division rounds the quotient. It also raises OverflowError for valid large integer multiples such as 3 * 10**400.

Use an exact integer remainder when both operands are integers. Float and Decimal operands retain the existing handling. Regression tests exercise compiled and generated validators for drafts 04/06/07, both error collection modes, negative values, large divisors, zero and noninteger controls; 108 cases fail before the fix.

Validation:

  • Full CI tox recipe on every supported Python version (3.10–3.14): 4,699 passed each, 12 benchmark deselections, 435 xfailed and 950 non-strict xpassed. The untouched baseline has 4,539 passed with identical markers.
  • Wheel and source distribution build pass; git diff --check passes.
  • Whole-project Pylint retains the same nine baseline diagnostics (9.90/10). Strict documentation builds retain the same 14 unresolved-reference warnings as the untouched baseline. Neither check gains a diagnostic from this change.

Use integer remainders when both operands are integers. Floating-point
quotients can round nonmultiples into integers or overflow on valid
large multiples. Keep the existing float and Decimal paths unchanged.

Test compiled and generated validators across supported schema drafts,
including both error collection modes and unchanged noninteger operands.

Signed-off-by: Mayank Dhingra <mayankdhingra02@gmail.com>

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