Repository navigation
Normalize locale thousands separators consistently with input - #205
Merged
SethMMorton merged 1 commit intoOct 16, 2026
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #205 +/- ##
==========================================
+ Coverage 97.80% 97.96% +0.16%
==========================================
Files 10 10
Lines 637 638 +1
==========================================
+ Hits 623 625 +2
+ Misses 14 13 -1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Combining
ns.LOCALENUMwithns.COMPATIBILITYNORMALIZEmisorders numbers containing non-breaking-space thousands separators. For example, underfr_FR.UTF-8on Windows:Input is normalized to NFKD before locale numeric processing, which turns U+202F (and U+00A0) into an ordinary space. The thousands-separator regex still looks for the original character, so the key for 1000 becomes
('', 1, ' ', 0).Normalize the configured thousands separator using the same existing normalization factory before constructing the regex. This produces
('', 1000)and the expected numeric order, preserving the original output strings. It adds no per-input normalization work. With compatibility normalization selected, ordinary spaces and these non-breaking spaces are intentionally equivalent; both can therefore be recognized as grouping separators in these locales.The documented flags support combining options, including locale numeric handling and NFKD normalization. Tests cover both separator characters, integer/float parsing, and default/compatibility normalization. The locale symbol getters are patched for portable tests; the example above was also reproduced with the actual installed French locale before and after the fix.
Validation on Windows / Python 3.12:
tox -e py312: 363 passed, 94% overall coverage, plus README/examples and module doctests (15 items) and the how-it-works doctest.tox -e docs, repository-wide Ruff format check, distribution builds and Twine checks: passed.type: ignore; the same failure was reproduced on the unmodified source.AI assistance: developed with OpenAI Codex and checked through independent Claude Opus and Codex AI reviews. This is not a claim of human review.