diff options
author | Aarni Koskela <akx@iki.fi> | 2023-03-01 09:18:44 +0200 |
---|---|---|
committer | Aarni Koskela <akx@iki.fi> | 2023-03-01 09:31:17 +0200 |
commit | 544381da61482a7c413ba608d1958e573c0914da (patch) | |
tree | 47de5a576455c1ec5a1e0c2cfa36c948ed30bd4f | |
parent | da8117c7d02a9eaf432a57748752e596b5871adf (diff) | |
download | babel-544381da61482a7c413ba608d1958e573c0914da.tar.gz |
babel.numbers: Fix some mypy-discovered issues
-rw-r--r-- | babel/numbers.py | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/babel/numbers.py b/babel/numbers.py index de0f419..37b2bef 100644 --- a/babel/numbers.py +++ b/babel/numbers.py @@ -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) |