]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
babel.numbers: Fix some mypy-discovered issues
authorAarni Koskela <akx@iki.fi>
Wed, 1 Mar 2023 07:18:44 +0000 (09:18 +0200)
committerAarni Koskela <akx@iki.fi>
Wed, 1 Mar 2023 07:31:17 +0000 (09:31 +0200)
babel/numbers.py

index de0f419d43d766556a13a3576c0e69b29f003e3a..37b2bef4dbf0d9606e89817600ab08e70da334fc 100644 (file)
@@ -60,10 +60,8 @@ def list_currencies(locale: Locale | str | None = None) -> set[str]:
     """
     # Get locale-scoped currencies.
     if locale:
-        currencies = Locale.parse(locale).currencies.keys()
-    else:
-        currencies = get_global('all_currencies')
-    return set(currencies)
+        return set(Locale.parse(locale).currencies)
+    return set(get_global('all_currencies'))
 
 
 def validate_currency(currency: str, locale: Locale | str | None = None) -> None:
@@ -103,7 +101,7 @@ def normalize_currency(currency: str, locale: Locale | str | None = None) -> str
     if isinstance(currency, str):
         currency = currency.upper()
     if not is_currency(currency, locale):
-        return
+        return None
     return currency
 
 
@@ -706,7 +704,7 @@ def _format_currency_long_name(
 
     # Step 5.
     if not format:
-        format = locale.decimal_formats[format]
+        format = locale.decimal_formats[None]
 
     pattern = parse_pattern(format)
 
@@ -810,7 +808,7 @@ def format_percent(
     """
     locale = Locale.parse(locale)
     if not format:
-        format = locale.percent_formats[format]
+        format = locale.percent_formats[None]
     pattern = parse_pattern(format)
     return pattern.apply(
         number, locale, decimal_quantization=decimal_quantization, group_separator=group_separator)
@@ -849,7 +847,7 @@ def format_scientific(
     """
     locale = Locale.parse(locale)
     if not format:
-        format = locale.scientific_formats[format]
+        format = locale.scientific_formats[None]
     pattern = parse_pattern(format)
     return pattern.apply(
         number, locale, decimal_quantization=decimal_quantization)