]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Apply minor simplifications
authorAarni Koskela <akx@iki.fi>
Mon, 13 Jan 2025 11:54:56 +0000 (13:54 +0200)
committerAarni Koskela <akx@iki.fi>
Tue, 14 Jan 2025 07:52:31 +0000 (09:52 +0200)
babel/messages/extract.py
babel/messages/frontend.py
babel/plural.py
babel/units.py
scripts/dump_global.py
scripts/import_cldr.py

index 921e5c2ce88998de39e7067d2caa90daf7c90b05..1c86e4ac8512a3824a9a3f60626093a2fd6d6c2f 100644 (file)
@@ -426,7 +426,6 @@ def extract(
     :returns: iterable of tuples of the form ``(lineno, message, comments, context)``
     :rtype: Iterable[tuple[int, str|tuple[str], list[str], str|None]
     """
-    func = None
     if callable(method):
         func = method
     elif ':' in method or '.' in method:
index 442703ff9a8e92b19ba378b5a78a711094fe10f6..5a696125e014d2a17116b23d22c8e3493522f084 100644 (file)
@@ -961,7 +961,7 @@ class CommandLineInterface:
             usage=self.usage % (cmdname, ''),
             description=self.commands[cmdname],
         )
-        as_args = getattr(cmdclass, "as_args", ())
+        as_args: str | None = getattr(cmdclass, "as_args", None)
         for long, short, help in cmdclass.user_options:
             name = long.strip("=")
             default = getattr(cmdinst, name.replace("-", "_"))
index 5c828d60165b4d7dfde338353f5b2fdbca01ac62..528d4175ea8d7a8c5bf1f528f4c157330ecdcfcb 100644 (file)
@@ -296,7 +296,7 @@ def within_range_list(num: float | decimal.Decimal, range_list: Iterable[Iterabl
     >>> within_range_list(10.5, [(1, 4), (20, 30)])
     False
     """
-    return any(num >= min_ and num <= max_ for min_, max_ in range_list)
+    return any(min_ <= num <= max_ for min_, max_ in range_list)
 
 
 def cldr_modulo(a: float, b: float) -> float:
index 1ff71eb699fa8cc6a3a3678f9a0d09b37f7f6f69..d7d5e84f534b9e4ba34bdf6da5623718304656bb 100644 (file)
@@ -66,7 +66,7 @@ def _find_unit_pattern(unit_id: str, locale: Locale | str | None = None) -> str
     :return: A key to the `unit_patterns` mapping, or None.
     """
     locale = Locale.parse(locale or LC_NUMERIC)
-    unit_patterns = locale._data["unit_patterns"]
+    unit_patterns: dict[str, str] = locale._data["unit_patterns"]
     if unit_id in unit_patterns:
         return unit_id
     for unit_pattern in sorted(unit_patterns, key=len):
index 8b8294014d79754e0fcc6ac620e39b8f8e87b061..e03fc0278c8dcf5f2afd3c53c66f374870119646 100755 (executable)
 # history and logs, available at http://babel.edgewall.org/log/.
 
 import os
+import pickle
 import sys
 from pprint import pprint
 
-import cPickle as pickle
-
 import babel
 
 dirname = os.path.join(os.path.dirname(babel.__file__))
index e8cc03106cf224638820e71b5c4c38a68d98c510..2ab8d0bf81662d322f9e9bcdb9dc80ee5988e4b8 100755 (executable)
@@ -389,12 +389,10 @@ def _process_local_datas(sup, srcdir, destdir, force=False, dump_json=False):
         if elem is not None:
             language = elem.attrib['type']
 
-        territory = None
+        territory = '001'  # world
         elem = tree.find('.//identity/territory')
         if elem is not None:
             territory = elem.attrib['type']
-        else:
-            territory = '001'  # world
         regions = territory_containment.get(territory, [])
 
         log.info(