Skip to content

Apply explicit decimal scales to every accepted input - #207

Merged
csingley merged 1 commit into
csingley:masterfrom
ryanduguid:fix/decimal-explicit-scale
Oct 4, 2026
Merged

csingley merged 1 commit into
csingley:masterfrom
ryanduguid:fix/decimal-explicit-scale

Conversation

@ryanduguid

@ryanduguid ryanduguid commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Explicit decimal scales now apply to every input accepted by the existing converter. Under the default decimal context, Decimal(2).convert(100) produces 100.00 and converts back to text successfully; previously it produced 100, which failed the export scale check. Scale zero now uses a whole-number quantum, so Decimal(0).convert("12.7") produces 13 rather than 12.7.

With an explicit scale, quantisation runs once after the existing coercion paths. Tests cover descriptor assignment and aggregate XML export, accepted input types, rounding and traps, native float conversion, comma parsing, and Decimal subclasses.

Evidence

  • The added regression checks failed before the production change. All 18 decimal tests now pass.
  • Linux Python 3.13.15: all 4,026 tests pass, with 95% coverage.
  • Windows Python 3.10.21 and 3.14.7: each passes 4,025 tests and retains the existing tests/test_utils.py:117 failure because HOME is absent. Both unchanged baselines had the same failure.
  • Ruff lint, Ruff formatting and mypy pass on all three environments. Aikido reports no issues in the two changed files.

Compatibility

Explicitly scaled integer, float and other constructor inputs now follow the caller's decimal rounding, precision and traps, as string and Decimal inputs already do. A low-precision context can therefore raise where these inputs previously skipped quantisation. Conversion without a scale retains full precision and existing Decimal identity. Negative-scale quantum construction retains its existing behaviour.

Unverified

Python 3.11 and 3.12 and upstream CI have not run locally. The three existing Linux warnings remain. The Windows HOME failure is outside this change.

@csingley
csingley merged commit b5c35c7 into csingley:master Oct 4, 2026
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.

2 participants