Repository navigation
Apply explicit decimal scales to every accepted input - #207
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Explicit decimal scales now apply to every input accepted by the existing converter. Under the default decimal context,
Decimal(2).convert(100)produces100.00and converts back to text successfully; previously it produced100, which failed the export scale check. Scale zero now uses a whole-number quantum, soDecimal(0).convert("12.7")produces13rather than12.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
tests/test_utils.py:117failure becauseHOMEis absent. Both unchanged baselines had the same failure.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
HOMEfailure is outside this change.