:param basedate: a datetime object representing the current time
against which to measure relative dates. If you do not supply this
argument, the plugin uses ``datetime.utcnow()``.
and is likely referring to both ParserBase.date_from() and DateParse.date_from() that assume a default of datetime.utcnow() when their own basedate parameter is None, other functions called within DateParserPlugin, like whoosh.util.times.timespan.disambiguated() require a non-None value.
As such, submitting a date range query like [oct 1970 to dec 8 19z70] (intentional typo), throws:
File "...\whoosh\util\times.py", line 334, in disambiguated
end.year = max(start.year, basedate.year)
^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'year'
Proposed fix
I may have missed something, but as both date_from() are only called within dateparse.py from what I can tell, it might make sense to remove
if basedate is None:
basedate = datetime.utcnow()
and =None parameter defaults and simply set within DateParserPlugin.__init__ as follows?
self.basedate = basedate or datetime.utcnow()
Collecting these issues for now, will fix in a fork eventually.
Although
DateParserPlugin.__init__
states:and is likely referring to both
ParserBase.date_from()
andDateParse.date_from()
that assume a default ofdatetime.utcnow()
when their ownbasedate
parameter isNone
, other functions called withinDateParserPlugin
, likewhoosh.util.times.timespan.disambiguated()
require a non-None
value.As such, submitting a date range query like
[oct 1970 to dec 8 19z70]
(intentional typo), throws:Proposed fix
I may have missed something, but as both
date_from()
are only called withindateparse.py
from what I can tell, it might make sense to removeand
=None
parameter defaults and simply set withinDateParserPlugin.__init__
as follows?Collecting these issues for now, will fix in a fork eventually.