From 32f41c22d589d7f187448be477affe1cfbcbc59d Mon Sep 17 00:00:00 2001 From: Tomas R Date: Thu, 25 Jul 2024 11:34:35 +0200 Subject: [PATCH] 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. --- babel/dates.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/babel/dates.py b/babel/dates.py index df129604..3373e063 100644 --- a/babel/dates.py +++ b/babel/dates.py @@ -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. @@ -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) -- 2.47.2