]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Enforce trailing commas (enable Ruff COM rule and autofix) (#1045)
authorAarni Koskela <akx@iki.fi>
Mon, 27 Nov 2023 13:18:54 +0000 (15:18 +0200)
committerGitHub <noreply@github.com>
Mon, 27 Nov 2023 13:18:54 +0000 (15:18 +0200)
31 files changed:
babel/core.py
babel/dates.py
babel/lists.py
babel/localtime/_helpers.py
babel/messages/catalog.py
babel/messages/checkers.py
babel/messages/extract.py
babel/messages/frontend.py
babel/messages/jslexer.py
babel/messages/mofile.py
babel/messages/plurals.py
babel/messages/pofile.py
babel/messages/setuptools_frontend.py
babel/numbers.py
babel/plural.py
babel/support.py
babel/units.py
babel/util.py
docs/conf.py
pyproject.toml
scripts/import_cldr.py
setup.py
tests/messages/test_extract.py
tests/messages/test_frontend.py
tests/messages/test_js_extract.py
tests/messages/test_jslexer.py
tests/messages/test_pofile.py
tests/test_dates.py
tests/test_localedata.py
tests/test_numbers.py
tests/test_plural.py

index ef0d16a1d6326b2a563f14934ca5eae926564c30..782c8f26a44598ccc328282ec15d8530dc6250bd 100644 (file)
@@ -111,7 +111,7 @@ LOCALE_ALIASES = {
     'ja': 'ja_JP', 'km': 'km_KH', 'ko': 'ko_KR', 'lt': 'lt_LT', 'lv': 'lv_LV',
     'mk': 'mk_MK', 'nl': 'nl_NL', 'nn': 'nn_NO', 'no': 'nb_NO', 'pl': 'pl_PL',
     'pt': 'pt_PT', 'ro': 'ro_RO', 'ru': 'ru_RU', 'sk': 'sk_SK', 'sl': 'sl_SI',
-    'sv': 'sv_SE', 'th': 'th_TH', 'tr': 'tr_TR', 'uk': 'uk_UA'
+    'sv': 'sv_SE', 'th': 'th_TH', 'tr': 'tr_TR', 'uk': 'uk_UA',
 }
 
 
@@ -1149,7 +1149,7 @@ def negotiate_locale(preferred: Iterable[str], available: Iterable[str], sep: st
 
 def parse_locale(
     identifier: str,
-    sep: str = '_'
+    sep: str = '_',
 ) -> tuple[str, str | None, str | None, str | None] | tuple[str, str | None, str | None, str | None, str | None]:
     """Parse a locale identifier into a tuple of the form ``(language,
     territory, script, variant, modifier)``.
index ddc8e71054a2439d1164e8ffd8c69263c72d86d3..40d950983585209cb3d81673d55d682abb4267bd 100644 (file)
@@ -521,7 +521,7 @@ def get_timezone_location(
         return city_name
     return region_format % (fallback_format % {
         '0': city_name,
-        '1': territory_name
+        '1': territory_name,
     })
 
 
@@ -852,7 +852,7 @@ TIMEDELTA_UNITS: tuple[tuple[str, int], ...] = (
     ('day', 3600 * 24),
     ('hour', 3600),
     ('minute', 60),
-    ('second', 1)
+    ('second', 1),
 )
 
 
@@ -1324,7 +1324,7 @@ class DateTimeFormat:
         self,
         value: datetime.date | datetime.time,
         locale: Locale | str,
-        reference_date: datetime.date | None = None
+        reference_date: datetime.date | None = None,
     ) -> None:
         assert isinstance(value, (datetime.date, datetime.datetime, datetime.time))
         if isinstance(value, (datetime.datetime, datetime.time)) and value.tzinfo is None:
@@ -1663,7 +1663,7 @@ PATTERN_CHARS: dict[str, list[int] | None] = {
     'm': [1, 2],                                                        # minute
     's': [1, 2], 'S': None, 'A': None,                                  # second
     'z': [1, 2, 3, 4], 'Z': [1, 2, 3, 4, 5], 'O': [1, 4], 'v': [1, 4],  # zone
-    'V': [1, 2, 3, 4], 'x': [1, 2, 3, 4, 5], 'X': [1, 2, 3, 4, 5]       # zone
+    'V': [1, 2, 3, 4], 'x': [1, 2, 3, 4, 5], 'X': [1, 2, 3, 4, 5],      # zone
 }
 
 #: The pattern characters declared in the Date Field Symbol Table
index 5c435dd63200aa0aa181372c785256bff878a88f..a8471fd1ebfca53e9077e94c6721610b45f09dcd 100644 (file)
@@ -79,7 +79,7 @@ def format_list(lst: Sequence[str],
     if style not in locale.list_patterns:
         raise ValueError(
             f'Locale {locale} does not support list formatting style {style!r} '
-            f'(supported are {sorted(locale.list_patterns)})'
+            f'(supported are {sorted(locale.list_patterns)})',
         )
     patterns = locale.list_patterns[style]
 
index 159f9a5697c16847aaa99228cb6876093408fe91..f27b31522a49b6884707220e5a9592157b6f2828 100644 (file)
@@ -30,7 +30,7 @@ def _get_tzinfo_or_raise(tzenv: str):
     if tzinfo is None:
         raise LookupError(
             f"Can not find timezone {tzenv}. \n"
-            "Timezone names are generally in the form `Continent/City`."
+            "Timezone names are generally in the form `Continent/City`.",
         )
     return tzinfo
 
index 8faf046d3c49128b34de13c974a8740090c38981..41adfaeee2c6b5dfa58a0d66a89dfb855c79eb19 100644 (file)
@@ -861,7 +861,7 @@ class Catalog:
                 if not isinstance(message.string, (list, tuple)):
                     fuzzy = True
                     message.string = tuple(
-                        [message.string] + ([''] * (len(message.id) - 1))
+                        [message.string] + ([''] * (len(message.id) - 1)),
                     )
                 elif len(message.string) != self.num_plurals:
                     fuzzy = True
index f4070e56d2f3a0d987cf57c1aafa065d728d881e..e5448e06b8c3ce2eebaf951ed69e065c3d98d790 100644 (file)
@@ -19,7 +19,7 @@ from babel.messages.catalog import PYTHON_FORMAT, Catalog, Message, TranslationE
 _string_format_compatibilities = [
     {'i', 'd', 'u'},
     {'x', 'X'},
-    {'f', 'F', 'g', 'G'}
+    {'f', 'F', 'g', 'G'},
 ]
 
 
@@ -150,7 +150,7 @@ def _validate_format(format: str, alternative: str) -> None:
             elif not _compatible(typechar, type_map[name]):
                 raise TranslationError(
                     f'incompatible format for placeholder {name!r}: '
-                    f'{typechar!r} and {type_map[name]!r} are not compatible'
+                    f'{typechar!r} and {type_map[name]!r} are not compatible',
                 )
 
 
index a5b6eab07918360240af2b3c8f1371db71e91db0..b13f1a9a60cd07a64918e6610ae9f1f4a43cd571 100644 (file)
@@ -86,7 +86,7 @@ DEFAULT_KEYWORDS: dict[str, _Keyword] = {
     'dngettext': (2, 3),
     'N_': None,
     'pgettext': ((1, 'c'), 2),
-    'npgettext': ((1, 'c'), 2, 3)
+    'npgettext': ((1, 'c'), 2, 3),
 }
 
 DEFAULT_MAPPING: list[tuple[str, str]] = [('**.py', 'python')]
@@ -281,7 +281,7 @@ def check_and_call_extract_file(
             keywords=keywords,
             comment_tags=comment_tags,
             options=options,
-            strip_comment_tags=strip_comment_tags
+            strip_comment_tags=strip_comment_tags,
         ):
             yield (filename, *message_tuple)
 
@@ -352,7 +352,7 @@ def _match_messages_against_spec(lineno: int, messages: list[str|None], comments
         filename = (getattr(fileobj, "name", None) or "(unknown)")
         sys.stderr.write(
             f"{filename}:{lineno}: warning: Empty msgid.  It is reserved by GNU gettext: gettext(\"\") "
-            f"returns the header entry with meta information, not the empty string.\n"
+            f"returns the header entry with meta information, not the empty string.\n",
         )
         return
 
@@ -437,7 +437,7 @@ def extract(
             builtin = {
                 'ignore': extract_nothing,
                 'python': extract_python,
-                'javascript': extract_javascript
+                'javascript': extract_javascript,
             }
             func = builtin.get(method)
 
@@ -690,7 +690,7 @@ def extract_javascript(
         jsx=options.get("jsx", True),
         template_string=options.get("template_string", True),
         dotted=dotted,
-        lineno=lineno
+        lineno=lineno,
     ):
         if (  # Turn keyword`foo` expressions into keyword("foo") calls:
             funcname and  # have a keyword...
index 4d61f01633a076082d57845d1cf77fac8fd12b1a..5cdade9f0cea085d5866907076f0cedc2bfa24d3 100644 (file)
@@ -166,7 +166,7 @@ class CompileCatalog(CommandMixin):
         ('use-fuzzy', 'f',
          'also include fuzzy translations'),
         ('statistics', None,
-         'print statistics about translations')
+         'print statistics about translations'),
     ]
     boolean_options = ['use-fuzzy', 'statistics']
 
@@ -246,7 +246,7 @@ class CompileCatalog(CommandMixin):
                     percentage = translated * 100 // len(catalog)
                 self.log.info(
                     '%d of %d messages (%d%%) translated in %s',
-                    translated, len(catalog), percentage, po_file
+                    translated, len(catalog), percentage, po_file,
                 )
 
             if catalog.fuzzy and not self.use_fuzzy:
@@ -257,7 +257,7 @@ class CompileCatalog(CommandMixin):
             for message, errors in catalog_errors:
                 for error in errors:
                     self.log.error(
-                        'error: %s:%d: %s', po_file, message.lineno, error
+                        'error: %s:%d: %s', po_file, message.lineno, error,
                     )
 
             self.log.info('compiling catalog %s to %s', po_file, mo_file)
@@ -342,7 +342,7 @@ class ExtractMessages(CommandMixin):
     ]
     boolean_options = [
         'no-default-keywords', 'no-location', 'omit-header', 'no-wrap',
-        'sort-output', 'sort-by-file', 'strip-comments'
+        'sort-output', 'sort-by-file', 'strip-comments',
     ]
     as_args = 'input-paths'
     multiple_value_options = (
@@ -357,7 +357,7 @@ class ExtractMessages(CommandMixin):
         'strip-comments': ('--strip-comment-tags',),
     }
     option_choices = {
-        'add-location': ('full', 'file', 'never',),
+        'add-location': ('full', 'file', 'never'),
     }
 
     def initialize_options(self):
@@ -391,7 +391,7 @@ class ExtractMessages(CommandMixin):
                 self.input_paths = self.input_dirs
             else:
                 raise OptionError(
-                    'input-dirs and input-paths are mutually exclusive'
+                    'input-dirs and input-paths are mutually exclusive',
                 )
 
         keywords = {} if self.no_default_keywords else DEFAULT_KEYWORDS.copy()
@@ -402,14 +402,14 @@ class ExtractMessages(CommandMixin):
 
         if not self.keywords:
             raise OptionError(
-                'you must specify new keywords if you disable the default ones'
+                'you must specify new keywords if you disable the default ones',
             )
 
         if not self.output_file:
             raise OptionError('no output file specified')
         if self.no_wrap and self.width:
             raise OptionError(
-                "'--no-wrap' and '--width' are mutually exclusive"
+                "'--no-wrap' and '--width' are mutually exclusive",
             )
         if not self.no_wrap and not self.width:
             self.width = 76
@@ -418,7 +418,7 @@ class ExtractMessages(CommandMixin):
 
         if self.sort_output and self.sort_by_file:
             raise OptionError(
-                "'--sort-output' and '--sort-by-file' are mutually exclusive"
+                "'--sort-output' and '--sort-by-file' are mutually exclusive",
             )
 
         if self.input_paths:
@@ -497,7 +497,7 @@ class ExtractMessages(CommandMixin):
                     extracted = check_and_call_extract_file(
                         path, method_map, options_map,
                         callback, self.keywords, self.add_comments,
-                        self.strip_comments, current_dir
+                        self.strip_comments, current_dir,
                     )
                 else:
                     extracted = extract_from_dir(
@@ -612,7 +612,7 @@ class InitCatalog(CommandMixin):
 
     def run(self):
         self.log.info(
-            'creating catalog %s based on %s', self.output_file, self.input_file
+            'creating catalog %s based on %s', self.output_file, self.input_file,
         )
 
         with open(self.input_file, 'rb') as infile:
@@ -701,7 +701,7 @@ class UpdateCatalog(CommandMixin):
             if not self.locale:
                 raise OptionError(
                     'you must specify the locale for '
-                    'the init-missing option to work'
+                    'the init-missing option to work',
                 )
 
             try:
@@ -755,7 +755,7 @@ class UpdateCatalog(CommandMixin):
                     check_status[filename] = False
                     continue
                 self.log.info(
-                    'creating catalog %s based on %s', filename, self.input_file
+                    'creating catalog %s based on %s', filename, self.input_file,
                 )
 
                 with open(self.input_file, 'rb') as infile:
@@ -841,7 +841,7 @@ class CommandLineInterface:
         'compile': 'compile message catalogs to MO files',
         'extract': 'extract messages from source files and generate a POT file',
         'init': 'create new message catalogs from a POT file',
-        'update': 'update existing message catalogs from a POT file'
+        'update': 'update existing message catalogs from a POT file',
     }
 
     command_classes = {
@@ -935,7 +935,7 @@ class CommandLineInterface:
 
         parser = optparse.OptionParser(
             usage=self.usage % (cmdname, ''),
-            description=self.commands[cmdname]
+            description=self.commands[cmdname],
         )
         as_args = getattr(cmdclass, "as_args", ())
         for long, short, help in cmdclass.user_options:
index cf287e4504a56c2cc52d646c6844fc5c06446276..6456bd03861db6edad0595e36c7f3cb4b82d5aac 100644 (file)
@@ -18,7 +18,7 @@ operators: list[str] = sorted([
     '+', '-', '*', '%', '!=', '==', '<', '>', '<=', '>=', '=',
     '+=', '-=', '*=', '%=', '<<', '>>', '>>>', '<<=', '>>=',
     '>>>=', '&', '&=', '|', '|=', '&&', '||', '^', '^=', '(', ')',
-    '[', ']', '{', '}', '!', '--', '++', '~', ',', ';', '.', ':'
+    '[', ']', '{', '}', '!', '--', '++', '~', ',', ';', '.', ':',
 ], key=len, reverse=True)
 
 escapes: dict[str, str] = {'b': '\b', 'f': '\f', 'n': '\n', 'r': '\r', 't': '\t'}
@@ -58,7 +58,7 @@ _rules: list[tuple[str | None, re.Pattern[str]]] = [
     ('string', re.compile(r'''(
         '(?:[^'\\]*(?:\\.[^'\\]*)*)'  |
         "(?:[^"\\]*(?:\\.[^"\\]*)*)"
-    )''', re.VERBOSE | re.DOTALL))
+    )''', re.VERBOSE | re.DOTALL)),
 ]
 
 
index 4ec58cac70138c0816c25a2a6b27650c0bb8cff2..ca02e6837a483fb6557e7cf14f830e00e3064b19 100644 (file)
@@ -208,5 +208,5 @@ def write_mo(fileobj: SupportsWrite[bytes], catalog: Catalog, use_fuzzy: bool =
                               len(messages),              # number of entries
                               7 * 4,                      # start of key index
                               7 * 4 + len(messages) * 8,  # start of value index
-                              0, 0                        # size and offset of hash table
+                              0, 0,                       # size and offset of hash table
                               ) + array.array.tobytes(array.array("i", offsets)) + ids + strs)
index 5341b8356b9202641535d4fe87cabaa33d3aba1a..fa3f03ed8af15631ee12fb161a053fbac3e39148 100644 (file)
@@ -65,7 +65,7 @@ PLURALS: dict[str, tuple[int, str]] = {
         6,
         '(n==1 ? 0 : n%10==1 && n%100!=11 && n%100!=71 && n%100!=91 ? 1 : n%10==2 && n%100!=12 && n%100!=72 && '
         'n%100!=92 ? 2 : (n%10==3 || n%10==4 || n%10==9) && n%100!=13 && n%100!=14 && n%100!=19 && n%100!=73 && '
-        'n%100!=74 && n%100!=79 && n%100!=93 && n%100!=94 && n%100!=99 ? 3 : n%1000000==0 ? 4 : 5)'
+        'n%100!=74 && n%100!=79 && n%100!=93 && n%100!=94 && n%100!=99 ? 3 : n%1000000==0 ? 4 : 5)',
     ),
     # Bosnian
     'bs': (3, '(n%10==1 && n%100!=11 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)'),
index 3c8a523e08cee7c77e65bef91b4457709c1cca04..b64a5085e81104498a7894c7624e90f596b420e4 100644 (file)
@@ -617,7 +617,7 @@ def write_po(
             )
             if len(message.previous_id) > 1:
                 _write_comment('msgid_plural %s' % _normalize(
-                    message.previous_id[1]
+                    message.previous_id[1],
                 ), prefix='|')
 
         _write_message(message)
@@ -626,7 +626,7 @@ def write_po(
     if not ignore_obsolete:
         for message in _sort_messages(
             catalog.obsolete.values(),
-            sort_by=sort_by
+            sort_by=sort_by,
         ):
             for comment in message.user_comments:
                 _write_comment(comment)
index 2f23fc1823ad1f30a455773afe48bdd14a667aa9..67b9f24e1fd97068341f568ac181ec9064ef24d6 100644 (file)
@@ -28,7 +28,7 @@ def check_message_extractors(dist, name, value):
     assert name == "message_extractors"
     if not isinstance(value, dict):
         raise SetupError(
-            'the value of the "message_extractors" parameter must be a dictionary'
+            'the value of the "message_extractors" parameter must be a dictionary',
         )
 
 
index e0df40ccefbb8b1be8ccb1ea01b9bab7ee3b0281..c6fcb9504ae65e00721efc81fef22f4123de0fbf 100644 (file)
@@ -721,7 +721,7 @@ def format_compact_currency(
     *,
     format_type: Literal["short"] = "short",
     locale: Locale | str | None = LC_NUMERIC,
-    fraction_digits: int = 0
+    fraction_digits: int = 0,
 ) -> str:
     """Format a number as a currency value in compact form.
 
@@ -1216,7 +1216,7 @@ class NumberPattern:
                 self._quantize_value(value, locale, frac_prec, group_separator),
                 get_exponential_symbol(locale),
                 exp_sign,  # type: ignore  # exp_sign is always defined here
-                self._format_int(str(exp), self.exp_prec[0], self.exp_prec[1], locale)  # type: ignore  # exp is always defined here
+                self._format_int(str(exp), self.exp_prec[0], self.exp_prec[1], locale),  # type: ignore  # exp is always defined here
             ])
 
         # Is it a significant digits pattern?
index 9d368481c73be2336bb2367802fe0ad63475b9ec..01df16c6d543c6d69e0f363cdf22f436187904c4 100644 (file)
@@ -342,7 +342,7 @@ _RULES: list[tuple[str | None, re.Pattern[str]]] = [
     ('word', re.compile(fr'\b(and|or|is|(?:with)?in|not|mod|[{"".join(_VARS)}])\b')),
     ('value', re.compile(r'\d+')),
     ('symbol', re.compile(r'%|,|!=|=')),
-    ('ellipsis', re.compile(r'\.{2,3}|\u2026', re.UNICODE))  # U+2026: ELLIPSIS
+    ('ellipsis', re.compile(r'\.{2,3}|\u2026', re.UNICODE)),  # U+2026: ELLIPSIS
 ]
 
 
index 43b406349c16272e88eb5cf84ac2eee8275e61d6..8d03934a39ad5f01ca238d8f41bbb610a842b3b5 100644 (file)
@@ -344,7 +344,7 @@ class LazyProxy:
             self._func,
             enable_cache=self._is_cache_enabled,
             *self._args,  # noqa: B026
-            **self._kwargs
+            **self._kwargs,
         )
 
     def __deepcopy__(self, memo: Any) -> LazyProxy:
@@ -353,7 +353,7 @@ class LazyProxy:
             deepcopy(self._func, memo),
             enable_cache=deepcopy(self._is_cache_enabled, memo),
             *deepcopy(self._args, memo),  # noqa: B026
-            **deepcopy(self._kwargs, memo)
+            **deepcopy(self._kwargs, memo),
         )
 
 
index 7b0e144deb87887773b68fe905525690d692351a..465d2263df2487ad889108054bde12c52746c174 100644 (file)
@@ -271,7 +271,7 @@ def format_compound_unit(
         formatted_numerator = numerator_value
     elif numerator_unit:  # Numerator has unit
         formatted_numerator = format_unit(
-            numerator_value, numerator_unit, length=length, format=format, locale=locale
+            numerator_value, numerator_unit, length=length, format=format, locale=locale,
         )
     else:  # Unitless numerator
         formatted_numerator = format_decimal(numerator_value, format=format, locale=locale)
index 17b08d1ec06219738dfc76130281ea08c6e68c55..093197f9fe9bfee6fbee9fb25a1336d6e374eb38 100644 (file)
@@ -202,7 +202,7 @@ def pathmatch(pattern: str, filename: str) -> bool:
 class TextWrapper(textwrap.TextWrapper):
     wordsep_re = re.compile(
         r'(\s+|'                                  # any whitespace
-        r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))'    # em-dash
+        r'(?<=[\w\!\"\'\&\.\,\?])-{2,}(?=\w))',   # em-dash
     )
 
 
index df7382766858b9256b056417a4dd2a318197ab7c..5e4ade202906c43a6a3c6bdfc0c2ab896553cde3 100644 (file)
@@ -138,7 +138,7 @@ html_sidebars = {
     'index':    ['sidebar-about.html', 'localtoc.html', 'sidebar-links.html',
                  'searchbox.html'],
     '**':       ['sidebar-logo.html', 'localtoc.html', 'relations.html',
-                 'searchbox.html']
+                 'searchbox.html'],
 }
 
 # Additional templates that should be rendered to pages, maps page names to
index dbd137cff7743de8a9cea7e6c4c3485823d23ccd..c90b6e45e2757b76cb2be6aefa3e91b05db5ca00 100644 (file)
@@ -3,6 +3,7 @@ target-version = "py37"
 select = [
     "B",
     "C",
+    "COM",
     "E",
     "F",
     "I",
index 96b6c9438d92d6e074118a6165c396a918d97ef1..15d53398050fcd1ab11675ee353e958160ba42f9 100755 (executable)
@@ -23,7 +23,7 @@ from xml.etree import ElementTree
 # Make sure we're using Babel source, and not some previously installed version
 CHECKOUT_ROOT = os.path.abspath(os.path.join(
     os.path.dirname(__file__),
-    '..'
+    '..',
 ))
 BABEL_PACKAGE_ROOT = os.path.join(CHECKOUT_ROOT, "babel")
 sys.path.insert(0, CHECKOUT_ROOT)
@@ -55,7 +55,7 @@ NAME_MAP = {
     'eraAbbr': 'abbreviated',
     'eraNames': 'wide',
     'eraNarrow': 'narrow',
-    'timeFormats': 'time_formats'
+    'timeFormats': 'time_formats',
 }
 
 log = logging.getLogger("import_cldr")
@@ -164,11 +164,11 @@ def main():
     parser = OptionParser(usage='%prog path/to/cldr')
     parser.add_option(
         '-f', '--force', dest='force', action='store_true', default=False,
-        help='force import even if destination file seems up to date'
+        help='force import even if destination file seems up to date',
     )
     parser.add_option(
         '-j', '--json', dest='dump_json', action='store_true', default=False,
-        help='also export debugging JSON dumps of locale data'
+        help='also export debugging JSON dumps of locale data',
     )
     parser.add_option(
         '-q', '--quiet', dest='quiet', action='store_true', default=bool(os.environ.get('BABEL_CLDR_QUIET')),
@@ -187,7 +187,7 @@ def main():
         srcdir=args[0],
         destdir=BABEL_PACKAGE_ROOT,
         force=bool(options.force),
-        dump_json=bool(options.dump_json)
+        dump_json=bool(options.dump_json),
     )
 
 
@@ -399,7 +399,7 @@ def _process_local_datas(sup, srcdir, destdir, force=False, dump_json=False):
 
         locale_id = '_'.join(filter(None, [
             language,
-            territory != '001' and territory or None
+            territory != '001' and territory or None,
         ]))
 
         data['locale_id'] = locale_id
@@ -448,7 +448,7 @@ def _process_local_datas(sup, srcdir, destdir, force=False, dump_json=False):
         if unsupported_number_systems_string:
             log.warning(
                 f"{locale_id}: unsupported number systems were ignored: "
-                f"{unsupported_number_systems_string}"
+                f"{unsupported_number_systems_string}",
             )
 
         write_datafile(data_filename, data, dump_json=dump_json)
@@ -616,7 +616,7 @@ def parse_calendar_months(data, calendar):
                 elif elem.tag == 'alias':
                     ctxts[width_type] = Alias(
                         _translate_alias(['months', ctxt_type, width_type],
-                                         elem.attrib['path'])
+                                         elem.attrib['path']),
                     )
 
 
@@ -634,7 +634,7 @@ def parse_calendar_days(data, calendar):
                 elif elem.tag == 'alias':
                     ctxts[width_type] = Alias(
                         _translate_alias(['days', ctxt_type, width_type],
-                                         elem.attrib['path'])
+                                         elem.attrib['path']),
                     )
 
 
@@ -667,7 +667,7 @@ def parse_calendar_eras(data, calendar):
             elif elem.tag == 'alias':
                 eras[width_type] = Alias(
                     _translate_alias(['eras', width_type],
-                                     elem.attrib['path'])
+                                     elem.attrib['path']),
                 )
 
 
@@ -695,13 +695,13 @@ def parse_calendar_date_formats(data, calendar):
                     continue
                 try:
                     date_formats[type] = dates.parse_pattern(
-                        str(elem.findtext('dateFormat/pattern'))
+                        str(elem.findtext('dateFormat/pattern')),
                     )
                 except ValueError as e:
                     log.error(e)
             elif elem.tag == 'alias':
                 date_formats = Alias(_translate_alias(
-                    ['date_formats'], elem.attrib['path'])
+                    ['date_formats'], elem.attrib['path']),
                 )
 
 
@@ -715,13 +715,13 @@ def parse_calendar_time_formats(data, calendar):
                     continue
                 try:
                     time_formats[type] = dates.parse_pattern(
-                        str(elem.findtext('timeFormat/pattern'))
+                        str(elem.findtext('timeFormat/pattern')),
                     )
                 except ValueError as e:
                     log.error(e)
             elif elem.tag == 'alias':
                 time_formats = Alias(_translate_alias(
-                    ['time_formats'], elem.attrib['path'])
+                    ['time_formats'], elem.attrib['path']),
                 )
 
 
@@ -740,7 +740,7 @@ def parse_calendar_datetime_skeletons(data, calendar):
                     log.error(e)
             elif elem.tag == 'alias':
                 datetime_formats = Alias(_translate_alias(
-                    ['datetime_formats'], elem.attrib['path'])
+                    ['datetime_formats'], elem.attrib['path']),
                 )
             elif elem.tag == 'availableFormats':
                 for datetime_skeleton in elem.findall('dateFormatItem'):
@@ -933,7 +933,7 @@ def parse_currency_formats(data, tree):
                     if child.tag == 'alias':
                         currency_formats[type] = Alias(
                             _translate_alias(['currency_formats', elem.attrib['type']],
-                                             child.attrib['path'])
+                                             child.attrib['path']),
                         )
                     elif child.tag == 'pattern':
                         pattern_type = child.attrib.get('type')
index 5233af1c8a9359aeed9387107492624435699b2d..4da20aabff68af5f3244d80f19968eef7a45e527 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -102,5 +102,5 @@ setup(
     ignore = babel.messages.extract:extract_nothing
     python = babel.messages.extract:extract_python
     javascript = babel.messages.extract:extract_javascript
-    """
+    """,
 )
index 63f4d1052222f13384eb429cff7988f3a47fd526..086702ed7d088139bc5d627860097668edfea078 100644 (file)
@@ -119,7 +119,7 @@ class Meta:
         assert messages == [
             (3, '_', 'Page arg 1', []),
             (3, '_', 'Page arg 2', []),
-            (8, '_', 'log entry', [])
+            (8, '_', 'log entry', []),
         ]
 
     def test_multiline(self):
index a5f4363050c10feb31cd61d1e6ab05ca8a0aa0e1..53be756111dff319b1bef8430415fdb12689ca42 100644 (file)
@@ -277,7 +277,7 @@ msgstr[1] ""
             'project': [
                 ('**/ignored/**.*', 'ignore', None),
                 ('**.py', 'python', None),
-            ]
+            ],
         }
         self.cmd.copyright_holder = 'FooBar, Inc.'
         self.cmd.msgid_bugs_address = 'bugs.address@email.tld'
@@ -332,7 +332,7 @@ msgstr[1] ""
             'project': [
                 ('**/ignored/**.*', 'ignore', None),
                 ('**.py', 'python', None),
-            ]
+            ],
         }
         self.cmd.output_file = 'project/i18n/temp.pot'
         self.cmd.add_location = 'file'
@@ -1168,7 +1168,7 @@ msgstr[2] ""
         self.cli.run(sys.argv + ['init',
                                  '-l', 'fi',
                                  '-o', po_file,
-                                 '-i', tmpl_file
+                                 '-i', tmpl_file,
                                  ])
         with open(po_file) as infp:
             catalog = read_po(infp)
@@ -1202,7 +1202,7 @@ msgstr[2] ""
         self.cli.run(sys.argv + ['init',
                                  '-l', 'fi',
                                  '-o', po_file,
-                                 '-i', tmpl_file
+                                 '-i', tmpl_file,
                                  ])
         with open(po_file) as infp:
             catalog = read_po(infp)
@@ -1256,7 +1256,7 @@ msgstr[2] ""
         self.cli.run(sys.argv + ['init',
                                  '-l', 'fi_FI',
                                  '-o', po_file,
-                                 '-i', tmpl_file
+                                 '-i', tmpl_file,
                                  ])
 
         # Update the catalog file
@@ -1314,7 +1314,7 @@ msgstr[2] ""
         self.cli.run(sys.argv + ['init',
                                  '-l', 'fi_FI',
                                  '-o', po_file,
-                                 '-i', tmpl_file
+                                 '-i', tmpl_file,
                                  ])
 
         # Update the catalog file
@@ -1441,7 +1441,7 @@ def test_parse_keywords_with_t():
             None: (1,),
             2: (2,),
             3: ((2, 'c'), 3),
-        }
+        },
     }
 
 
@@ -1504,7 +1504,7 @@ def test_extract_keyword_args_384(split, arg_name):
     # (Both of those invocation styles should be equivalent, so there is no parametrization from here on out)
 
     cmdinst = configure_cli_command(
-        f"extract -F babel-django.cfg --add-comments Translators: -o django232.pot {kwarg_text} ."
+        f"extract -F babel-django.cfg --add-comments Translators: -o django232.pot {kwarg_text} .",
     )
     assert isinstance(cmdinst, ExtractMessages)
     assert set(cmdinst.keywords.keys()) == {'_', 'dgettext', 'dngettext',
index 82f5379eae644e4ac708967997df12394a2fd3d0..fc643851e27d70314c45fe9a922aa6b0f38e1c8c 100644 (file)
@@ -39,7 +39,7 @@ msg10 = dngettext(domain, 'Page', 'Pages', 3)
     assert messages == [
         (5, ('bunny', 'bunnies'), [], None),
         (8, 'Rabbit', [], None),
-        (10, ('Page', 'Pages'), [], None)
+        (10, ('Page', 'Pages'), [], None),
     ]
 
 
@@ -130,7 +130,7 @@ def test_jsx_extraction(jsx_enabled):
 def test_dotted_keyword_extract():
     buf = BytesIO(b"msg1 = com.corporate.i18n.formatMessage('Insert coin to continue')")
     messages = list(
-        extract.extract('javascript', buf, {"com.corporate.i18n.formatMessage": None}, [], {})
+        extract.extract('javascript', buf, {"com.corporate.i18n.formatMessage": None}, [], {}),
     )
 
     assert messages == [(1, 'Insert coin to continue', [], None)]
@@ -139,7 +139,7 @@ def test_dotted_keyword_extract():
 def test_template_string_standard_usage():
     buf = BytesIO(b"msg1 = gettext(`Very template, wow`)")
     messages = list(
-        extract.extract('javascript', buf, {"gettext": None}, [], {})
+        extract.extract('javascript', buf, {"gettext": None}, [], {}),
     )
 
     assert messages == [(1, 'Very template, wow', [], None)]
@@ -148,7 +148,7 @@ def test_template_string_standard_usage():
 def test_template_string_tag_usage():
     buf = BytesIO(b"function() { if(foo) msg1 = i18n`Tag template, wow`; }")
     messages = list(
-        extract.extract('javascript', buf, {"i18n": None}, [], {})
+        extract.extract('javascript', buf, {"i18n": None}, [], {}),
     )
 
     assert messages == [(1, 'Tag template, wow', [], None)]
@@ -157,7 +157,7 @@ def test_template_string_tag_usage():
 def test_inside_template_string():
     buf = BytesIO(b"const msg = `${gettext('Hello')} ${user.name}`")
     messages = list(
-        extract.extract('javascript', buf, {"gettext": None}, [], {'parse_template_string': True})
+        extract.extract('javascript', buf, {"gettext": None}, [], {'parse_template_string': True}),
     )
 
     assert messages == [(1, 'Hello', [], None)]
@@ -178,7 +178,7 @@ gettext('Are you doing ok?')
 }`
 """)
     messages = list(
-        extract.extract('javascript', buf, {"gettext": None}, [], {'parse_template_string': True})
+        extract.extract('javascript', buf, {"gettext": None}, [], {'parse_template_string': True}),
     )
 
     assert messages == [(1, 'Username', [], None), (3, 'Hello', [], None), (5, 'Are you having a nice day?', [], None), (8, 'Howdy', [], None), (10, 'Are you doing ok?', [], None)]
@@ -187,7 +187,7 @@ gettext('Are you doing ok?')
 def test_inside_nested_template_string():
     buf = BytesIO(b"const msg = `${gettext('Greetings!')} ${ evening ? `${user.name}: ${gettext('This is a lovely evening.')}` : `${gettext('The day is really nice!')} ${user.name}`}`")
     messages = list(
-        extract.extract('javascript', buf, {"gettext": None}, [], {'parse_template_string': True})
+        extract.extract('javascript', buf, {"gettext": None}, [], {'parse_template_string': True}),
     )
 
     assert messages == [(1, 'Greetings!', [], None), (1, 'This is a lovely evening.', [], None), (1, 'The day is really nice!', [], None)]
index 3889f0b3a344a0b5aed8a584d45ccd29dd99f344..00afc78ae4329fe0264a44162ff634254316fbc2 100644 (file)
@@ -17,7 +17,7 @@ def test_dotted_name():
         ('name', 'foo.bar', 1),
         ('operator', '(', 1),
         ('name', 'quux', 1),
-        ('operator', ')', 1)
+        ('operator', ')', 1),
     ]
 
 
@@ -30,7 +30,7 @@ def test_dotted_name_end():
 def test_template_string():
     assert list(jslexer.tokenize("gettext `foo\"bar\"p`", template_string=True)) == [
         ('name', 'gettext', 1),
-        ('template_string', '`foo"bar"p`', 1)
+        ('template_string', '`foo"bar"p`', 1),
     ]
 
 
@@ -121,5 +121,5 @@ def test_jsx():
         ('operator', '}', 7),
         ('jsx_tag', '/>', 7),
         ('jsx_tag', '</comp2', 8),
-        ('operator', '>', 8)
+        ('operator', '>', 8),
     ]
index acd8c6e348b3d75f39befe84591ca6c340863bd2..043f9c8bd15af6d7561e5a5fde5dfadac23a0531 100644 (file)
@@ -580,10 +580,10 @@ msgstr ""'''
     def test_wrap_locations_with_hyphens(self):
         catalog = Catalog()
         catalog.add('foo', locations=[
-            ('doupy/templates/base/navmenu.inc.html.py', 60)
+            ('doupy/templates/base/navmenu.inc.html.py', 60),
         ])
         catalog.add('foo', locations=[
-            ('doupy/templates/job-offers/helpers.html', 22)
+            ('doupy/templates/job-offers/helpers.html', 22),
         ])
         buf = BytesIO()
         pofile.write_po(buf, catalog, omit_header=True)
index f4f57739720e916ac2214afb4fea8194384bb339..d3f2ad9e70d5b6de52f36b7ac38c88fa31034945 100644 (file)
@@ -569,7 +569,7 @@ def test_format_datetime(timezone_getter):
     full = dates.format_datetime(
         dt, 'full',
         tzinfo=timezone_getter('Europe/Paris'),
-        locale='fr_FR'
+        locale='fr_FR',
     )
     assert full == (
         'dimanche 1 avril 2007, 17:30:00 heure '
@@ -578,7 +578,7 @@ def test_format_datetime(timezone_getter):
     custom = dates.format_datetime(
         dt, "yyyy.MM.dd G 'at' HH:mm:ss zzz",
         tzinfo=timezone_getter('US/Eastern'),
-        locale='en'
+        locale='en',
     )
     assert custom == '2007.04.01 AD at 11:30:00 EDT'
 
index 1cc3a63b34322a5a32d96dcf3acd511477d0517d..d4eb4e5970d2cdc1a39233183be9fc3bef32e093 100644 (file)
@@ -46,11 +46,11 @@ class MergeResolveTestCase(unittest.TestCase):
         alias = localedata.Alias('x')
         d1 = {
             'x': {'a': 1, 'b': 2, 'c': 3},
-            'y': alias
+            'y': alias,
         }
         d2 = {
             'x': {'a': 1, 'b': 12, 'd': 14},
-            'y': {'b': 22, 'e': 25}
+            'y': {'b': 22, 'e': 25},
         }
         localedata.merge(d1, d2)
         assert d1 == {'x': {'a': 1, 'b': 12, 'c': 3, 'd': 14}, 'y': (alias, {'b': 22, 'e': 25})}
index 3674453f635fb39eb820be508bf0ce114e17bd89..0367804123212bb0c6da78f0542cc00b4c23c454 100644 (file)
@@ -303,7 +303,7 @@ def test_get_territory_currencies():
                                                 'currency': 'USD',
                                                 'from': date(1792, 1, 1),
                                                 'to': None,
-                                                'tender': True
+                                                'tender': True,
                                             }]
 
     assert numbers.get_territory_currencies('LS', date(2013, 1, 1)) == ['ZAR', 'LSL']
index 6fbf3af7e28a61b4a82869ad97f61ae99ee4e71e..2fa56cf4e0a84cf969fab10796bb3ea380fad717 100644 (file)
@@ -142,13 +142,43 @@ def test_locales_with_no_plural_rules_have_default():
 
 
 WELL_FORMED_TOKEN_TESTS = (
-    ('', []),
-    ('n = 1', [('value', '1'), ('symbol', '='), ('word', 'n'), ]),
-    ('n = 1 @integer 1', [('value', '1'), ('symbol', '='), ('word', 'n'), ]),
-    ('n is 1', [('value', '1'), ('word', 'is'), ('word', 'n'), ]),
-    ('n % 100 = 3..10', [('value', '10'), ('ellipsis', '..'), ('value', '3'),
-                         ('symbol', '='), ('value', '100'), ('symbol', '%'),
-                         ('word', 'n'), ]),
+    ("", []),
+    (
+        "n = 1",
+        [
+            ("value", "1"),
+            ("symbol", "="),
+            ("word", "n"),
+        ],
+    ),
+    (
+        "n = 1 @integer 1",
+        [
+            ("value", "1"),
+            ("symbol", "="),
+            ("word", "n"),
+        ],
+    ),
+    (
+        "n is 1",
+        [
+            ("value", "1"),
+            ("word", "is"),
+            ("word", "n"),
+        ],
+    ),
+    (
+        "n % 100 = 3..10",
+        [
+            ("value", "10"),
+            ("ellipsis", ".."),
+            ("value", "3"),
+            ("symbol", "="),
+            ("value", "100"),
+            ("symbol", "%"),
+            ("word", "n"),
+        ],
+    ),
 )
 
 
@@ -236,7 +266,7 @@ class PluralRuleParserTestCase(unittest.TestCase):
                              ('relation', ('in',
                                            ('mod', (self.n,
                                                     plural.value_node(100))),
-                                           (make_range_list((1, 19)))))))
+                                           (make_range_list((1, 19))))))),
                     ))