]> git.ipfire.org Git - thirdparty/babel.git/commitdiff
Improve docs for `format_skeleton` (#1106)
authorTomas R <tomas.roun8@gmail.com>
Thu, 25 Jul 2024 09:34:35 +0000 (11:34 +0200)
committerGitHub <noreply@github.com>
Thu, 25 Jul 2024 09:34:35 +0000 (12:34 +0300)
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

index df129604a25d7d383df202359316d02e4fad0d0a..3373e06397036f37a2943dae48cd7130e0f9b3c6 100644 (file)
@@ -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)