summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAarni Koskela <akx@iki.fi>2023-01-18 20:04:18 +0200
committerAarni Koskela <akx@iki.fi>2023-01-18 21:16:39 +0200
commit9512281c7e45e9c829b47c50d332e9654809cb64 (patch)
tree0d81333e2474bdf410f1f6df85a4e174d53c4aa8
parent47072d2c96390f5e5daae9e96d5dc30ae2d704ec (diff)
downloadbabel-9512281c7e45e9c829b47c50d332e9654809cb64.tar.gz
Apply ruff E category fixes
-rw-r--r--docs/conf.py3
-rw-r--r--pyproject.toml4
-rw-r--r--tests/test_core.py2
-rw-r--r--tests/test_localedata.py4
-rw-r--r--tests/test_numbers.py18
-rw-r--r--tests/test_util.py3
6 files changed, 20 insertions, 14 deletions
diff --git a/docs/conf.py b/docs/conf.py
index c0e2389..ed4794e 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 0a92130..df9eba7 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 605bf5c..a200718 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 7bfe9c6..006a6b0 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 0939562..3ae9143 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 d78aee7..ba62d9b 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():