Skip to content

Commit 0f78ea8

Browse files
committed
Apply minor simplifications
1 parent cd766b7 commit 0f78ea8

6 files changed

Lines changed: 5 additions & 9 deletions

File tree

babel/messages/extract.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,6 @@ def extract(
426426
:returns: iterable of tuples of the form ``(lineno, message, comments, context)``
427427
:rtype: Iterable[tuple[int, str|tuple[str], list[str], str|None]
428428
"""
429-
func = None
430429
if callable(method):
431430
func = method
432431
elif ':' in method or '.' in method:

babel/messages/frontend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ def _configure_command(self, cmdname, argv):
961961
usage=self.usage % (cmdname, ''),
962962
description=self.commands[cmdname],
963963
)
964-
as_args = getattr(cmdclass, "as_args", ())
964+
as_args: str | None = getattr(cmdclass, "as_args", None)
965965
for long, short, help in cmdclass.user_options:
966966
name = long.strip("=")
967967
default = getattr(cmdinst, name.replace("-", "_"))

babel/plural.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ def within_range_list(num: float | decimal.Decimal, range_list: Iterable[Iterabl
296296
>>> within_range_list(10.5, [(1, 4), (20, 30)])
297297
False
298298
"""
299-
return any(num >= min_ and num <= max_ for min_, max_ in range_list)
299+
return any(min_ <= num <= max_ for min_, max_ in range_list)
300300

301301

302302
def cldr_modulo(a: float, b: float) -> float:

babel/units.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def _find_unit_pattern(unit_id: str, locale: Locale | str | None = None) -> str
6666
:return: A key to the `unit_patterns` mapping, or None.
6767
"""
6868
locale = Locale.parse(locale or LC_NUMERIC)
69-
unit_patterns = locale._data["unit_patterns"]
69+
unit_patterns: dict[str, str] = locale._data["unit_patterns"]
7070
if unit_id in unit_patterns:
7171
return unit_id
7272
for unit_pattern in sorted(unit_patterns, key=len):

scripts/dump_global.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@
1212
# history and logs, available at http://babel.edgewall.org/log/.
1313

1414
import os
15+
import pickle
1516
import sys
1617
from pprint import pprint
1718

18-
import cPickle as pickle
19-
2019
import babel
2120

2221
dirname = os.path.join(os.path.dirname(babel.__file__))

scripts/import_cldr.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,12 +389,10 @@ def _process_local_datas(sup, srcdir, destdir, force=False, dump_json=False):
389389
if elem is not None:
390390
language = elem.attrib['type']
391391

392-
territory = None
392+
territory = '001' # world
393393
elem = tree.find('.//identity/territory')
394394
if elem is not None:
395395
territory = elem.attrib['type']
396-
else:
397-
territory = '001' # world
398396
regions = territory_containment.get(territory, [])
399397

400398
log.info(

0 commit comments

Comments
 (0)