-
Notifications
You must be signed in to change notification settings - Fork 460
Closed
Milestone
Description
Overview Description
The type annotations for the locale parameter (e.g. in babel.numbers.format_currency()) suggest that the value can be None, but this causes a TypeError in Locale.parse().
Steps to Reproduce
babel.numbers.format_currency(0, "USD", locale=None)Actual Results
Traceback (most recent call last):
File "<python-input-1>", line 1, in <module>
babel.numbers.format_currency(0, "USD", locale=None)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
File ".venv/lib/python3.13/site-packages/babel/numbers.py", line 777, in format_currency
locale = Locale.parse(locale)
File ".venv/lib/python3.13/site-packages/babel/core.py", line 332, in parse
raise TypeError(f"Unexpected value for identifier: {identifier!r}")
TypeError: Unexpected value for identifier: NoneExpected Results
I would expect a value of None to use the default value, or None should be removed from the type annotations entirely.
Reproducibility
Additional Information
Metadata
Metadata
Assignees
Labels
No labels