`RSSFeed` model ImportError when locale not set
sneakers-the-rat opened this issue · comments
locale.getdefaultlocale()
(which is deprecated) and locale.getlocale()
can return None
if language cannot be determined: https://docs.python.org/3/library/locale.html#locale.getdefaultlocale
Since the default in the model calls the function directly (rather than using default_factory
), the model can't be imported at all:
fastapi_rss/fastapi_rss/models/feed.py
Line 23 in 558151c
due to a predictable AttributeError
: NoneType
object has no attribute lower
thrown here:
fastapi_rss/fastapi_rss/utils.py
Line 14 in 558151c
to fix:
- use
default_factory
so the model can be imported and patched if needed - make language optional, and check for
None
type inget_locale_code
This has been deployed on PyPI