Skip to content

Commit

Permalink
babel.numbers: Fix some mypy-discovered issues
Browse files Browse the repository at this point in the history
  • Loading branch information
akx committed Mar 1, 2023
1 parent da8117c commit 544381d
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions babel/numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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


Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 544381d

Please sign in to comment.