'TranslationError',
]
+
def get_close_matches(word, possibilities, n=3, cutoff=0.6):
"""A modified version of ``difflib.get_close_matches``.
if not 0.0 <= cutoff <= 1.0: # pragma: no cover
raise ValueError(f"cutoff must be in [0.0, 1.0]: {cutoff!r}")
result = []
- s = SequenceMatcher(autojunk=False) # only line changed from difflib.py
+ s = SequenceMatcher(autojunk=False) # only line changed from difflib.py
s.set_seq2(word)
for x in possibilities:
s.set_seq1(x)
options, strip_comment_tags))
-def _match_messages_against_spec(lineno: int, messages: list[str|None], comments: list[str],
- fileobj: _FileObj, spec: tuple[int|tuple[int, str], ...]):
+def _match_messages_against_spec(
+ lineno: int,
+ messages: list[str | None],
+ comments: list[str],
+ fileobj: _FileObj,
+ spec: tuple[int | tuple[int, str], ...],
+):
translatable = []
context = None
# last_index is 1 based like the keyword spec
last_index = len(messages)
for index in spec:
- if isinstance(index, tuple): # (n, 'c')
+ if isinstance(index, tuple): # (n, 'c')
context = messages[index[0] - 1]
continue
if last_index < index:
elif tok == NAME and value in keywords:
funcname = value
- if (current_fstring_start is not None
- and tok not in {FSTRING_START, FSTRING_MIDDLE}
- ):
+ if current_fstring_start is not None and tok not in {FSTRING_START, FSTRING_MIDDLE}:
# In Python 3.12, tokens other than FSTRING_* mean the
# f-string is dynamic, so we don't wan't to extract it.
# And if it's FSTRING_END, we've already handled it above.
with pytest.raises(numbers.UnsupportedNumberingSystemError):
numbers.format_decimal(12345.5, locale='en_US', numbering_system="unknown")
+
@pytest.mark.parametrize('input_value, expected_value', [
('10000', '10,000'),
('1', '1'),
with pytest.raises(numbers.UnsupportedNumberingSystemError):
numbers.parse_number('1.099,98', locale='en', numbering_system="unsupported")
+
@pytest.mark.parametrize('string', [
'1 099',
'1\xa0099',