Comparing main...decimal-constraints-683 · msgspec/msgspec · GitHub
Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: msgspec/msgspec
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: msgspec/msgspec
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: decimal-constraints-683
Choose a head ref
Checking mergeability… Don’t worry, you can still create the pull request.
  • 9 commits
  • 4 files changed
  • 2 contributors

Commits on Apr 20, 2026

  1. Support numeric constraints for decimal.Decimal

    Extends gt, ge, lt, le, and multiple_of Meta constraints to work with
    decimal.Decimal types, enabling exact arithmetic comparisons and
    sub-integer precision constraints without floating point issues.
    
    Constraint bounds passed as int or float are coerced to Decimal via
    their string representation to preserve precision. multiple_of uses
    Python's % operator for exact arithmetic.
    
    Closes #683
    aleksandr.tseluyko authored and Siyet committed Apr 20, 2026
    Configuration menu
    Copy the full SHA
    023b9e1 View commit details
    Browse the repository at this point in the history

Commits on Apr 21, 2026

  1. Reject Decimal bounds on int and float constrained types

    Coercing a Decimal bound to int or float silently drops precision, which
    defeats the point of specifying the bound as a Decimal in the first
    place. Only allow Decimal bounds when the annotated type is also
    Decimal, and raise a TypeError otherwise at TypeNode construction time.
    Siyet committed Apr 21, 2026
    Configuration menu
    Copy the full SHA
    3d489dd View commit details
    Browse the repository at this point in the history

Commits on Jun 15, 2026

  1. Merge remote-tracking branch 'origin/main' into decimal-constraints-683

    # Conflicts:
    #	src/msgspec/__init__.pyi
    #	tests/unit/test_constraints.py
    Siyet committed Jun 15, 2026
    Configuration menu
    Copy the full SHA
    b449815 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    72b7932 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    f59ed16 View commit details
    Browse the repository at this point in the history

Commits on Jul 2, 2026

  1. Store decimal constraints in a single details slot holding a 5-tuple

    Frees up 4 bits in the types bitmask (main now uses bits 38-39 for
    frozendict, leaving too few free bits for per-constraint decimal bits).
    Also compare the multiple_of remainder against zero explicitly instead
    of relying on __bool__.
    Siyet committed Jul 2, 2026
    Configuration menu
    Copy the full SHA
    38f7e7c View commit details
    Browse the repository at this point in the history
  2. Merge main (frozendict bit reallocation)

    MS_TYPE_FROZENDICT took bits 38-39, MS_CONSTR_DECIMAL moved to bit 40.
    Siyet committed Jul 2, 2026
    Configuration menu
    Copy the full SHA
    def7a7b View commit details
    Browse the repository at this point in the history

Commits on Sep 4, 2026

  1. Merge remote-tracking branch 'origin/main' into decimal-constraints-683

    # Conflicts:
    #	src/msgspec/__init__.pyi
    Siyet committed Sep 4, 2026
    Configuration menu
    Copy the full SHA
    16b0dc4 View commit details
    Browse the repository at this point in the history
  2. Reject non-finite Decimal bounds and document Decimal in the Meta doc…

    …string
    
    The float branch already rejected inf and nan bounds; the Decimal branch
    converted to double for the positivity check only and let Decimal('NaN')
    and Decimal('Infinity') through. Also check PyObject_IsInstance for error.
    Siyet committed Sep 4, 2026
    Configuration menu
    Copy the full SHA
    c86893e View commit details
    Browse the repository at this point in the history
Loading