Repository navigation
Respect unit-name boundaries when selecting unit patterns - #1453
Open
liugedragon wants to merge 1 commit into
Open
liugedragon wants to merge 1 commit into
liugedragon wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
format_compound_unit(5, "meter", denominator_unit="hour", locale="en")currently returns5 kilometers per hour. The suffix lookup matchesmeter-per-hourinsidespeed-kilometer-per-hour, so a label can silently use a different unit without converting its value.Require a unit-name boundary before a shortened suffix. Exact qualified IDs and deprecated-ID normalization keep their existing paths. An unavailable predefined combination now falls back to the existing per-unit formatter:
Also retain an unresolved denominator's original name. With a numeric denominator of
1, an unknown unit previously becameNone, then an empty suffix, and could format as an unrelated unit. It now raisesUnknownUnitErrorwith the supplied name, consistently with other numeric denominator values. Preformatted string denominators continue to ignore their unit.Validation on Windows / Python 3.13.4 with CLDR 49:
cb0c7a7has 57 failed, 75 passed; patched suite has 132 passed.python -m pytest --doctest-modules babel tests -q: 8,483 passed, 7 skipped, 2 xfailed.git diff --check: passed.This does not tighten every possible shorthand into strict identifier validation or change unit data, plural selection, or number formatting.