Skip to content

Commit 32f41c2

Browse files
authored
Improve docs for format_skeleton (#1106)
Makes it explicit that even when using fuzzy=True, the function can still raise if there are no suitable formats that match the skeleton.
1 parent 2ebc47e commit 32f41c2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

babel/dates.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,6 +826,10 @@ def format_skeleton(
826826
Traceback (most recent call last):
827827
...
828828
KeyError: yMMd
829+
>>> 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
830+
Traceback (most recent call last):
831+
...
832+
KeyError: None
829833
830834
After the skeleton is resolved to a pattern `format_datetime` is called so
831835
all timezone processing etc is the same as for that.
@@ -835,7 +839,8 @@ def format_skeleton(
835839
time in UTC is used
836840
:param tzinfo: the time-zone to apply to the time for display
837841
:param fuzzy: If the skeleton is not found, allow choosing a skeleton that's
838-
close enough to it.
842+
close enough to it. If there is no close match, a `KeyError`
843+
is thrown.
839844
:param locale: a `Locale` object or a locale identifier
840845
"""
841846
locale = Locale.parse(locale)

0 commit comments

Comments
 (0)