- changed status to wontfix
parse_datetime cannot handle missing time part and throws a unhelpful error
Issue #25
wontfix
>>> from flask_restful.inputs import datetime_from_iso8601
>>> datetime_from_iso8601('2012-01-01')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/maxnoe/.cache/pypoetry/virtualenvs/backend-upwAqJaD-py3.8/lib/python3.8/site-packages/flask_restful/inputs.py", line 282, in datetime_from_iso8601
return aniso8601.parse_datetime(datetime_str)
File "/home/maxnoe/.cache/pypoetry/virtualenvs/backend-upwAqJaD-py3.8/lib/python3.8/site-packages/aniso8601/time.py", line 124, in parse_datetime
isodatestr, isotimestr = isodatetimestr.split(delimiter, 1)
ValueError: not enough values to unpack (expected 2, got 1)
Comments (1)
-
repo owner - Log in to comment
flask-restful, is not my project.
You appear to be looking for the date parsing function.
I have submitted a pull-request to make it more clear the method you are using is only for datetimes, not dates.
Pull requests are welcome, but making that error message more detailed is more complicated than you think, and requires guessing what the user intended. At the very least it would require parsing erroneous input as both a date and a time to see if either parse is successful, and asking the user if perhaps they meant something else.