When using format_skeleton, a KeyError is raised despite using fuzzy=True.
Steps to Reproduce
from datetime import datetime
from babel.dates import format_skeleton
dt = datetime(2012, 1, 1, 14, 30, 59)
format_skeleton("G", dt, locale="cs_CZ", fuzzy=True)
From the docs:
fuzzy – If the skeleton is not found, allow choosing a skeleton that’s close enough to it.
The way I read it is that as long as I pass fuzzy=True (which is the default) a skeleton should always be found and I should not need to worry about KeyErrors in that case.
Even the example in the docs makes it seem a KeyError is only thrown with fuzzy=False:
format_skeleton('yMMd', t, fuzzy=False, locale='fi') # yMMd is not in the Finnish locale, an error is thrown
If this is the expected behaviour, I think the docs should state that explicitly. If not, I would suggest adding allow_different_fields=True to the underlying match_skeleton() call.
Overview Description
When using
format_skeleton
, aKeyError
is raised despite usingfuzzy=True
.Steps to Reproduce
From the docs:
The way I read it is that as long as I pass
fuzzy=True
(which is the default) a skeleton should always be found and I should not need to worry aboutKeyError
s in that case.Even the example in the docs makes it seem a
KeyError
is only thrown withfuzzy=False
:If this is the expected behaviour, I think the docs should state that explicitly. If not, I would suggest adding
allow_different_fields=True
to the underlyingmatch_skeleton()
call.Additional Information
Babel version:
2.15