]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Apply ruff E category fixes
authorAarni Koskela <akx@iki.fi>
Wed, 18 Jan 2023 18:04:18 +0000 (20:04 +0200)
committerAarni Koskela <akx@iki.fi>
Wed, 18 Jan 2023 19:16:39 +0000 (21:16 +0200)
docs/conf.py
pyproject.toml
tests/test_core.py
tests/test_localedata.py
tests/test_numbers.py
tests/test_util.py

index c0e23894b72a686b94add0e234b7f65002702945..ed4794ea91ded77562875b7e118f1392ca5ae10e 100644 (file)
@@ -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
index 0a92130a66d01fb6146f9626044bc784e531c262..df9eba7e638e106d9872c25b18a6c08ecc799d5b 100644 (file)
@@ -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"]
index 605bf5c02f147495a1054c2f5d3bce3d2b7fc72b..a2007189782cb45f9ff4c66c3673dd3b18433e32 100644 (file)
@@ -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():
index 7bfe9c6bac69d5b55eeb2ffec6b0ae532858166f..006a6b0479ecb38367b9c91f492764f6a5341ee7 100644 (file)
@@ -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):
index 0939562bf548697f38b74869a7dabff1a45cff66..3ae9143962248aab5b7aeb0f2fe2e156138633d9 100644 (file)
@@ -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():
index d78aee7bcaccf03e6190b8b00b487e44f94c4840..ba62d9bb8efdfbefeca89a8af492126a90fff07e 100644 (file)
@@ -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():