Skip to content

Commit

Permalink
Improve docs for format_skeleton (#1106)
Browse files Browse the repository at this point in the history
Makes it explicit that even when using fuzzy=True, the function can still raise if there are no suitable formats that match the skeleton.
  • Loading branch information
tomasr8 authored Jul 25, 2024
1 parent 2ebc47e commit 32f41c2
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion babel/dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -826,6 +826,10 @@ def format_skeleton(
Traceback (most recent call last):
...
KeyError: yMMd
>>> format_skeleton('GH', t, fuzzy=True, locale='fi_FI') # GH is not in the Finnish locale and there is no close match, an error is thrown
Traceback (most recent call last):
...
KeyError: None
After the skeleton is resolved to a pattern `format_datetime` is called so
all timezone processing etc is the same as for that.
Expand All @@ -835,7 +839,8 @@ def format_skeleton(
time in UTC is used
:param tzinfo: the time-zone to apply to the time for display
:param fuzzy: If the skeleton is not found, allow choosing a skeleton that's
close enough to it.
close enough to it. If there is no close match, a `KeyError`
is thrown.
:param locale: a `Locale` object or a locale identifier
"""
locale = Locale.parse(locale)
Expand Down

0 comments on commit 32f41c2

Please sign in to comment.