Using a settings dictionary when parsing a date results in an error if the provided object is a subclass of the type specified in the dateparser settings schema, such as when using a pendulum.DateTime object . So running
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/lib/python3.8/site-packages/dateparser/conf.py", line 92, in wrapper
return f(*args, **kwargs)
File "/lib/python3.8/site-packages/dateparser/__init__.py", line 58, in parse
parser = DateDataParser(languages=languages, locales=locales,
File "/lib/python3.8/site-packages/dateparser/conf.py", line 92, in wrapper
return f(*args, **kwargs)
File "/lib/python3.8/site-packages/dateparser/date.py", line 387, in __init__
check_settings(settings)
File "/lib/python3.8/site-packages/dateparser/conf.py", line 244, in check_settings
raise SettingValidationError(
dateparser.conf.SettingValidationError: "RELATIVE_BASE" must be "datetime", not "DateTime".
Even though a pendulum.DateTime is a subclass of a datetime object. The check at this line https://github.com/scrapinghub/dateparser/blob/master/dateparser/conf.py#L243
should call isinstance instead of directly checking type equality to ensure subclassed objects are allowed in settings definitions. This is a regression from previous versions where pendulum.DateTime objects were allowed.
Using a settings dictionary when parsing a date results in an error if the provided object is a subclass of the type specified in the
dateparser
settings schema, such as when using a pendulum.DateTime object . So runningwill generate the error
Even though a pendulum.DateTime is a subclass of a datetime object. The check at this line https://github.com/scrapinghub/dateparser/blob/master/dateparser/conf.py#L243 should call
isinstance
instead of directly checking type equality to ensure subclassed objects are allowed in settings definitions. This is a regression from previous versions where pendulum.DateTime objects were allowed.