From: Aarni Koskela Date: Wed, 18 Jan 2023 18:04:18 +0000 (+0200) Subject: Apply ruff E category fixes X-Git-Tag: v2.12.0~19^2~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9512281c7e45e9c829b47c50d332e9654809cb64;p=thirdparty%2Fbabel.git Apply ruff E category fixes --- diff --git a/docs/conf.py b/docs/conf.py index c0e23894..ed4794ea 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -10,7 +10,8 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import sys, os +import sys +import os # 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 diff --git a/pyproject.toml b/pyproject.toml index 0a92130a..df9eba7e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,12 +3,16 @@ target-version = "py37" select = [ "B", "C", + "E", ] ignore = [ "C901", # Complexity "E501", # Line length + "E731", # Do not assign a lambda expression (we use them on purpose) "E741", # Ambiguous variable name ] extend-exclude = [ "tests/messages/data", ] +[tool.ruff.per-file-ignores] +"scripts/import_cldr.py" = ["E402"] diff --git a/tests/test_core.py b/tests/test_core.py index 605bf5c0..a2007189 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -322,7 +322,7 @@ def test_issue_601_no_language_name_but_has_variant(): # Instead, it's better to return None altogether, as we can't reliably format # part of a language name. - assert Locale.parse('fi_FI').get_display_name('kw_GB') == None + assert Locale.parse('fi_FI').get_display_name('kw_GB') is None def test_issue_814(): diff --git a/tests/test_localedata.py b/tests/test_localedata.py index 7bfe9c6b..006a6b04 100644 --- a/tests/test_localedata.py +++ b/tests/test_localedata.py @@ -95,13 +95,13 @@ def test_locale_argument_acceptance(): normalized_locale = localedata.normalize_locale(None) assert normalized_locale is None locale_exist = localedata.exists(None) - assert locale_exist == False + assert locale_exist is False # # Testing list input. normalized_locale = localedata.normalize_locale(['en_us', None]) assert normalized_locale is None locale_exist = localedata.exists(['en_us', None]) - assert locale_exist == False + assert locale_exist is False def test_locale_identifiers_cache(monkeypatch): diff --git a/tests/test_numbers.py b/tests/test_numbers.py index 0939562b..3ae91439 100644 --- a/tests/test_numbers.py +++ b/tests/test_numbers.py @@ -224,15 +224,15 @@ def test_validate_currency(): def test_is_currency(): - assert is_currency('EUR') == True - assert is_currency('eUr') == False - assert is_currency('FUU') == False - assert is_currency('') == False - assert is_currency(None) == False - assert is_currency(' EUR ') == False - assert is_currency(' ') == False - assert is_currency([]) == False - assert is_currency(set()) == False + assert is_currency('EUR') is True + assert is_currency('eUr') is False + assert is_currency('FUU') is False + assert is_currency('') is False + assert is_currency(None) is False + assert is_currency(' EUR ') is False + assert is_currency(' ') is False + assert is_currency([]) is False + assert is_currency(set()) is False def test_normalize_currency(): diff --git a/tests/test_util.py b/tests/test_util.py index d78aee7b..ba62d9bb 100644 --- a/tests/test_util.py +++ b/tests/test_util.py @@ -56,7 +56,8 @@ class FixedOffsetTimezoneTestCase(unittest.TestCase): assert util.FixedOffsetTimezone(330).zone == 'Etc/GMT+330' -parse_encoding = lambda s: util.parse_encoding(BytesIO(s.encode('utf-8'))) +def parse_encoding(s): + return util.parse_encoding(BytesIO(s.encode('utf-8'))) def test_parse_encoding_defined():