]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Apply ruff I category fixes
authorAarni Koskela <akx@iki.fi>
Wed, 18 Jan 2023 18:07:31 +0000 (20:07 +0200)
committerAarni Koskela <akx@iki.fi>
Wed, 18 Jan 2023 19:20:51 +0000 (21:20 +0200)
37 files changed:
babel/dates.py
babel/localtime/__init__.py
babel/localtime/_unix.py
babel/localtime/_win32.py
babel/messages/catalog.py
babel/messages/checkers.py
babel/messages/extract.py
babel/messages/frontend.py
babel/messages/jslexer.py
babel/messages/plurals.py
babel/messages/pofile.py
babel/numbers.py
babel/support.py
babel/util.py
docs/conf.py
pyproject.toml
scripts/download_import_cldr.py
scripts/dump_data.py
scripts/dump_global.py
scripts/generate_authors.py
scripts/import_cldr.py
setup.py
tests/conftest.py
tests/messages/test_catalog.py
tests/messages/test_frontend.py
tests/messages/test_js_extract.py
tests/messages/test_mofile.py
tests/messages/test_pofile.py
tests/test_core.py
tests/test_dates.py
tests/test_day_periods.py
tests/test_localedata.py
tests/test_numbers.py
tests/test_plural.py
tests/test_smoke.py
tests/test_support.py
tests/test_util.py

index ee8bcfdef363ea599b946308a520fcee9653edb8..7bfea7111d81f37c2a5d25deca5f733b84d6b191 100644 (file)
@@ -27,9 +27,9 @@ except ModuleNotFoundError:
     pytz = None
     import zoneinfo
 
+import datetime
 from bisect import bisect_right
 from collections.abc import Iterable
-import datetime
 
 from babel import localtime
 from babel.core import Locale, default_locale, get_global
index 9d227c7b176faed66f5c09e841f29b18ecc14d4a..1d65fb2070755926bf9efb1560da0f9ddc2d50f6 100644 (file)
@@ -9,9 +9,9 @@
     :license: BSD, see LICENSE for more details.
 """
 
+import datetime
 import sys
 import time
-import datetime
 from threading import RLock
 
 if sys.platform == 'win32':
index 89b461a01b6e0f758d6e8ced8c4b52a8fd32e54e..eb81beb618b3d4a8894468b48a4f423652f3422c 100644 (file)
@@ -1,14 +1,14 @@
+import datetime
 import os
 import re
 
-import datetime
-
 from babel.localtime._helpers import (
+    _get_tzinfo,
     _get_tzinfo_from_file,
     _get_tzinfo_or_raise,
-    _get_tzinfo,
 )
 
+
 def _tz_from_env(tzenv: str) -> datetime.tzinfo:
     if tzenv[0] == ':':
         tzenv = tzenv[1:]
index 42f819a21afa37817767d223b439e042ea060099..1a52567bc44cf0f5688cccffa869673b72b8cde7 100644 (file)
@@ -6,9 +6,10 @@ except ImportError:
     winreg = None
 
 import datetime
+from typing import Any, Dict, cast
+
 from babel.core import get_global
 from babel.localtime._helpers import _get_tzinfo_or_raise
-from typing import Any, Dict, cast
 
 # When building the cldr data on windows this module gets imported.
 # Because at that point there is no global.dat yet this call will
index 7b27f64270e679c8f5af68d087b1b6b5d0228844..dbca10f4567601bd5815fbe0c9c49ee8ff18c2a3 100644 (file)
@@ -9,21 +9,20 @@
 """
 from __future__ import annotations
 
+import datetime
 import re
-
 from collections import OrderedDict
 from collections.abc import Iterable, Iterator
-import datetime
+from copy import copy
 from difflib import get_close_matches
 from email import message_from_string
-from copy import copy
 from typing import TYPE_CHECKING
 
 from babel import __version__ as VERSION
 from babel.core import Locale, UnknownLocaleError
 from babel.dates import format_datetime
 from babel.messages.plurals import get_plural
-from babel.util import distinct, LOCALTZ, FixedOffsetTimezone, _cmp
+from babel.util import LOCALTZ, FixedOffsetTimezone, _cmp, distinct
 
 if TYPE_CHECKING:
     from typing_extensions import TypeAlias
index 5e36b87f3e69a4e9605e9dc8c184a069f321fbab..38a26e844f15a9f090211c470fd01e103712aa6d 100644 (file)
@@ -13,8 +13,7 @@ from __future__ import annotations
 
 from collections.abc import Callable
 
-from babel.messages.catalog import Catalog, Message, TranslationError, PYTHON_FORMAT
-
+from babel.messages.catalog import PYTHON_FORMAT, Catalog, Message, TranslationError
 
 #: list of format chars that are compatible to each other
 _string_format_compatibilities = [
index a4265101abed13e5ae7dad3c03e8ac95e775cc0e..0934937c82d2264cad064d65d846b492eaeb1bbf 100644 (file)
 from __future__ import annotations
 
 import ast
-from collections.abc import Callable, Collection, Generator, Iterable, Mapping, MutableSequence
 import io
 import os
 import sys
+from collections.abc import (
+    Callable,
+    Collection,
+    Generator,
+    Iterable,
+    Mapping,
+    MutableSequence,
+)
 from os.path import relpath
-from tokenize import generate_tokens, COMMENT, NAME, OP, STRING
-from typing import Any, TYPE_CHECKING
+from textwrap import dedent
+from tokenize import COMMENT, NAME, OP, STRING, generate_tokens
+from typing import TYPE_CHECKING, Any
 
 from babel.util import parse_encoding, parse_future_flags, pathmatch
-from textwrap import dedent
 
 if TYPE_CHECKING:
     from typing import IO, Protocol
-    from typing_extensions import Final, TypeAlias, TypedDict
+
     from _typeshed import SupportsItems, SupportsRead, SupportsReadline
+    from typing_extensions import Final, TypeAlias, TypedDict
 
     class _PyOptions(TypedDict, total=False):
         encoding: str
index a9a3e4d6a28be2e243146e503f07988ee2d00447..98a1ca89a65950845cbe82f58889a995ef5ee325 100644 (file)
@@ -8,6 +8,7 @@
     :license: BSD, see LICENSE for more details.
 """
 
+import datetime
 import fnmatch
 import logging
 import optparse
@@ -18,15 +19,19 @@ import sys
 import tempfile
 from collections import OrderedDict
 from configparser import RawConfigParser
-import datetime
 from io import StringIO
 from typing import Iterable
 
-from babel import __version__ as VERSION
 from babel import Locale, localedata
+from babel import __version__ as VERSION
 from babel.core import UnknownLocaleError
-from babel.messages.catalog import Catalog, DEFAULT_HEADER
-from babel.messages.extract import DEFAULT_KEYWORDS, DEFAULT_MAPPING, check_and_call_extract_file, extract_from_dir
+from babel.messages.catalog import DEFAULT_HEADER, Catalog
+from babel.messages.extract import (
+    DEFAULT_KEYWORDS,
+    DEFAULT_MAPPING,
+    check_and_call_extract_file,
+    extract_from_dir,
+)
 from babel.messages.mofile import write_mo
 from babel.messages.pofile import read_po, write_po
 from babel.util import LOCALTZ
@@ -39,14 +44,16 @@ try:
     distutils_log = log  # "distutils.log → (no replacement yet)"
 
     try:
-        from setuptools.errors import OptionError, SetupError, BaseError
+        from setuptools.errors import BaseError, OptionError, SetupError
     except ImportError:  # Error aliases only added in setuptools 59 (2021-11).
         OptionError = SetupError = BaseError = Exception
 
 except ImportError:
     from distutils import log as distutils_log
     from distutils.cmd import Command as _Command
-    from distutils.errors import DistutilsOptionError as OptionError, DistutilsSetupError as SetupError, DistutilsError as BaseError
+    from distutils.errors import DistutilsError as BaseError
+    from distutils.errors import DistutilsOptionError as OptionError
+    from distutils.errors import DistutilsSetupError as SetupError
 
 
 
index 11ddf96593057b6280ce332acbdddab5f8e399a0..e6d20aec58be9054be1ffd908cbe44c0a49a575d 100644 (file)
@@ -11,8 +11,8 @@
 """
 from __future__ import annotations
 
-from collections.abc import Generator
 import re
+from collections.abc import Generator
 from typing import NamedTuple
 
 operators: list[str] = sorted([
index 0fdf53bb084906b1683cd0586fd5be63e9f0de11..eb8de47e1cc3f9aadce19add33e3d2e81d1800c4 100644 (file)
@@ -9,9 +9,9 @@
 """
 from __future__ import annotations
 
-from babel.core import default_locale, Locale
 from operator import itemgetter
 
+from babel.core import Locale, default_locale
 
 # XXX: remove this file, duplication with babel.plural
 
index b6d0d6ed81539b04dd93c3b1d2879247eafe3cc9..76d3123e7b70470c59d2be0fbfee0020d1fb3001 100644 (file)
@@ -14,14 +14,15 @@ import os
 import re
 from collections.abc import Iterable
 from typing import TYPE_CHECKING
-from babel.core import Locale
 
+from babel.core import Locale
 from babel.messages.catalog import Catalog, Message
-from babel.util import wraptext, _cmp
+from babel.util import _cmp, wraptext
 
 if TYPE_CHECKING:
-    from _typeshed import SupportsWrite
     from typing import IO, AnyStr
+
+    from _typeshed import SupportsWrite
     from typing_extensions import Literal
 
 
index f229072a86a0cde02021ea9ac6e08ff21bc67bbd..6ecd7dc1110eb180b4db0ef1b1ea5860e1814d52 100644 (file)
 #  - https://www.unicode.org/reports/tr35/ (Appendix G.6)
 from __future__ import annotations
 
+import datetime
 import decimal
 import re
-from typing import TYPE_CHECKING, Any, overload
 import warnings
-import datetime
+from typing import TYPE_CHECKING, Any, overload
 
 from babel.core import Locale, default_locale, get_global
 from babel.localedata import LocaleDataDict
index 216c8f1d6c4ae404d2cf0768702bcc56a70fa4e8..70925997ccd79e31e307af5cb6536ef6665c82c2 100644 (file)
@@ -20,12 +20,15 @@ from collections.abc import Iterator
 from typing import TYPE_CHECKING, Any, Callable
 
 from babel.core import Locale
-
-from babel.dates import (format_date, format_datetime, format_time,
-                         format_timedelta)
-from babel.numbers import (format_compact_currency, format_compact_decimal,
-                           format_currency, format_decimal, format_percent,
-                           format_scientific)
+from babel.dates import format_date, format_datetime, format_time, format_timedelta
+from babel.numbers import (
+    format_compact_currency,
+    format_compact_decimal,
+    format_currency,
+    format_decimal,
+    format_percent,
+    format_scientific,
+)
 
 if TYPE_CHECKING:
     from typing_extensions import Literal
index d25ec533db9d22e0420d1a5bb9deb072b837b50f..cf86f20f54893ecdae655a4fa24fea6a2a72810f 100644 (file)
@@ -11,15 +11,15 @@ from __future__ import annotations
 
 import codecs
 import collections
+import datetime
 import os
 import re
 import textwrap
-from babel import localtime, dates
-
 from collections.abc import Generator, Iterable
-import datetime
 from typing import IO, Any, TypeVar
 
+from babel import dates, localtime
+
 missing = object()
 
 _T = TypeVar("_T")
index ed4794ea91ded77562875b7e118f1392ca5ae10e..84bbd7ed2e43d93cbd8a5befd38d16bbe5a94d10 100644 (file)
@@ -10,8 +10,8 @@
 # All configuration values have a default; values that are commented out
 # serve to show the default.
 
-import sys
 import os
+import sys
 
 # If extensions (or modules to document with autodoc) are in another directory,
 # add these directories to sys.path here. If the directory is relative to the
index 7dd161ef3aaeeb380e64637062b485d1be4548cc..37f7fe34d8ed3ec0f59709d2cfcbb650323fdfaf 100644 (file)
@@ -5,6 +5,7 @@ select = [
     "C",
     "E",
     "F",
+    "I",
 ]
 ignore = [
     "C901",  # Complexity
index 57995b57140b96c5f2d93482e62e2e8b62b06b56..926e747609bb6dd03686fa5aa9c166fb91c1bfdb 100755 (executable)
@@ -1,15 +1,14 @@
 #!/usr/bin/env python3
 
 import contextlib
+import hashlib
 import os
-import sys
 import shutil
-import hashlib
-import zipfile
 import subprocess
+import sys
+import zipfile
 from urllib.request import urlretrieve
 
-
 URL = 'http://unicode.org/Public/cldr/41/cldr-common-41.0.zip'
 FILENAME = 'cldr-common-41.0.zip'
 # Via https://unicode.org/Public/cldr/41/hashes/SHASUM512
index e41905000f5f2f6f05a9c118a6953bec8f0686e8..041a410e125141a0734674008daaa6921cd3fa27 100755 (executable)
@@ -14,7 +14,7 @@
 from optparse import OptionParser
 from pprint import pprint
 
-from babel.localedata import load, LocaleDataDict
+from babel.localedata import LocaleDataDict, load
 
 
 def main():
index 6696415e6e468900c76e2993e003d1058913ce17..3fc95b6c9861671ebd188efdb84f7121dc841830 100755 (executable)
 # individuals. For the exact contribution history, see the revision
 # history and logs, available at http://babel.edgewall.org/log/.
 
-import cPickle as pickle
 import os
-from pprint import pprint
 import sys
+from pprint import pprint
+
+import cPickle as pickle
 
 import babel
 
index e2e3addcd22dc6ed6157dc235310060476eb2fcc..64c0af82edc3c9985c46bd8878e5b0fbf78ff920 100644 (file)
@@ -1,8 +1,7 @@
+import os
 from collections import Counter
 from subprocess import check_output
 
-import os
-
 root_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..'))
 
 
index 5de707c89cbca69cc042cc2deba4dce9e6b455ae..0dc47382f08b56860f9dc911a4b62f76bb34c8cf 100755 (executable)
 # history and logs, available at http://babel.edgewall.org/log/.
 
 import collections
-from optparse import OptionParser
+import logging
 import os
 import pickle
 import re
 import sys
-import logging
-
+from optparse import OptionParser
 from xml.etree import ElementTree
 
 # Make sure we're using Babel source, and not some previously installed version
index db63216e991c43360cc6e628c2af9e2f3ce6ff3a..df6ad8b9a86f785182972792ef0011cf618e3ff1 100755 (executable)
--- a/setup.py
+++ b/setup.py
@@ -1,7 +1,7 @@
 import subprocess
 import sys
 
-from setuptools import setup, Command
+from setuptools import Command, setup
 
 try:
     from babel import __version__
index 0506a833032e00b8b1a8adc1317e090c4f5de0c4..67e3ce921ed895532957176be102e5b8b17eedd5 100644 (file)
@@ -1,4 +1,5 @@
 import os
+
 import pytest
 
 try:
index e9b15a88aaf2a3adbf3ea8e14fa71164c687e617..eb1e308f2dc9f1f0ce6f13a7072d65ffe5ade0cd 100644 (file)
@@ -15,7 +15,7 @@ import datetime
 import unittest
 from io import StringIO
 
-from babel.dates import format_datetime, UTC
+from babel.dates import UTC, format_datetime
 from babel.messages import catalog, pofile
 from babel.util import FixedOffsetTimezone
 
index 8727cb82b45e9f2df0605de04619c43c73d75ff6..e540e7137e7018206c5900b1740f1a22efc7d646 100644 (file)
@@ -9,26 +9,32 @@
 # This software consists of voluntary contributions made by many
 # individuals. For the exact contribution history, see the revision
 # history and logs, available at http://babel.edgewall.org/log/.
-import shlex
-from datetime import datetime
-from freezegun import freeze_time
-from io import StringIO
-from setuptools import Distribution
 import logging
 import os
+import shlex
 import shutil
 import sys
 import time
 import unittest
+from datetime import datetime
+from io import StringIO
 
 import pytest
+from freezegun import freeze_time
+from setuptools import Distribution
 
 from babel import __version__ as VERSION
 from babel.dates import format_datetime
-from babel.messages import frontend, Catalog
-from babel.messages.frontend import CommandLineInterface, extract_messages, update_catalog, OptionError, BaseError
-from babel.util import LOCALTZ
+from babel.messages import Catalog, frontend
+from babel.messages.frontend import (
+    BaseError,
+    CommandLineInterface,
+    OptionError,
+    extract_messages,
+    update_catalog,
+)
 from babel.messages.pofile import read_po, write_po
+from babel.util import LOCALTZ
 
 TEST_PROJECT_DISTRIBUTION_DATA = {
     "name": "TestProject",
index 95985c0f7b90dd5b0b459fc165a949f790fa9a54..7d4392150228d793f9471031cd2fbcc2a1bfb744 100644 (file)
@@ -1,5 +1,7 @@
 from io import BytesIO
+
 import pytest
+
 from babel.messages import extract
 
 
index 6e026a846c361cb391b209db528f8dce0a9177c2..ff7c2ed0b00c9ad9d94d855da40ceb4f67bc2eba 100644 (file)
@@ -14,7 +14,7 @@ import os
 import unittest
 from io import BytesIO
 
-from babel.messages import mofile, Catalog
+from babel.messages import Catalog, mofile
 from babel.support import Translations
 
 
index a72368bcce3190a952e63329a8339166d2e3eb29..fb5799b169bc950dcf9f2522a17780cfa0de963e 100644 (file)
 # individuals. For the exact contribution history, see the revision
 # history and logs, available at http://babel.edgewall.org/log/.
 
-from datetime import datetime
 import unittest
+from datetime import datetime
 from io import BytesIO, StringIO
+
 import pytest
 
 from babel.core import Locale
-from babel.messages.catalog import Catalog, Message
 from babel.messages import pofile
+from babel.messages.catalog import Catalog, Message
 from babel.util import FixedOffsetTimezone
 
+
 class ReadPoTestCase(unittest.TestCase):
 
     def test_preserve_locale(self):
index a2007189782cb45f9ff4c66c3673dd3b18433e32..f4d253c1072f1b873dce6cb5f82eb7594f447270 100644 (file)
@@ -13,7 +13,7 @@
 import pytest
 
 from babel import core
-from babel.core import default_locale, Locale
+from babel.core import Locale, default_locale
 
 
 def test_locale_provides_access_to_cldr_locale_data():
index a4fb9c5bfd1c68709dbff59e03c3eceea3807d2b..b4abaf9341298035bf369e38d76637f3bc7b2a35 100644 (file)
@@ -16,7 +16,7 @@ from datetime import date, datetime, time, timedelta
 import freezegun
 import pytest
 
-from babel import dates, Locale
+from babel import Locale, dates
 from babel.dates import NO_INHERITANCE_MARKER, _localize
 from babel.util import FixedOffsetTimezone
 
index 414c0f6e5f15fefbb5ae677f0dea5b06b937047c..9b51e1dd993f5498b85c0d1cf16164b9c4327878 100644 (file)
@@ -1,8 +1,9 @@
 from datetime import time
 
-import babel.dates as dates
 import pytest
 
+import babel.dates as dates
+
 
 @pytest.mark.parametrize("locale, time, expected_period_id", [
     ("de", time(7, 42), "morning1"),  # (from, before)
index 006a6b0479ecb38367b9c91f492764f6a5341ee7..7672ddc1516bc464cc7bd098c0d8ed1bcd428c83 100644 (file)
 
 import os
 import pickle
+import random
 import sys
 import tempfile
 import unittest
-import random
 from operator import methodcaller
 
 import pytest
 
-from babel import localedata, Locale, UnknownLocaleError
+from babel import Locale, UnknownLocaleError, localedata
 
 
 class MergeResolveTestCase(unittest.TestCase):
index 3ae9143962248aab5b7aeb0f2fe2e156138633d9..ca33c1e2b479a597e2c8e26a6af9a7b428ebb046 100644 (file)
 
 import decimal
 import unittest
-import pytest
-
 from datetime import date
 
+import pytest
+
 from babel import localedata, numbers
 from babel.numbers import (
-    list_currencies, validate_currency, UnknownCurrencyError, is_currency, normalize_currency,
-    get_currency_precision, get_decimal_precision, get_currency_unit_pattern)
+    UnknownCurrencyError,
+    get_currency_precision,
+    get_currency_unit_pattern,
+    get_decimal_precision,
+    is_currency,
+    list_currencies,
+    normalize_currency,
+    validate_currency,
+)
 
 
 class FormatDecimalTestCase(unittest.TestCase):
index 16601cfec06a91f9803d6b8162b5f00e96322dad..e1e5ead60da67847ab48972df4e7c8e48624fa5c 100644 (file)
 # history and logs, available at http://babel.edgewall.org/log/.
 import decimal
 import unittest
+
 import pytest
 
-from babel import plural, localedata
+from babel import localedata, plural
 
 EPSILON = decimal.Decimal("0.0001")
 
index aed676a16191557053ad9a8880de67e3d5e969c0..c91684534089048704d19ed2a18dd1ebe4feba04 100644 (file)
@@ -4,11 +4,12 @@ looking at improving test coverage.  They just verify that basic
 operations don't fail due to odd corner cases on any locale that
 we ship.
 """
-import decimal
 import datetime
+import decimal
+
 import pytest
 
-from babel import Locale, units, dates, numbers
+from babel import Locale, dates, numbers, units
 
 NUMBERS = (
     decimal.Decimal("-33.76"),  # Negative Decimal
index 3ca0be3d63fa0a200f087543e1a24018bd9caf91..fe10402647c806f372ad684e5cfa3287b7ae2f35 100644 (file)
 import inspect
 import os
 import shutil
+import sys
 import tempfile
 import unittest
-import pytest
-import sys
 from datetime import date, datetime, timedelta
 from io import BytesIO
 
+import pytest
+
 from babel import support
 from babel.messages import Catalog
 from babel.messages.mofile import write_mo
 
-
 SKIP_LGETTEXT = sys.version_info >= (3, 8)
 
 @pytest.mark.usefixtures("os_environ")
index ba62d9bb8efdfbefeca89a8af492126a90fff07e..f58fc2443c7611abdd0c12720929b589d1871be5 100644 (file)
@@ -11,6 +11,7 @@
 # history and logs, available at http://babel.edgewall.org/log/.
 
 import __future__
+
 import unittest
 from io import BytesIO