Skip to content

Commit

Permalink
Fix crash when parsing date
Browse files Browse the repository at this point in the history
I was getting a `ValueError: Invalid isoformat string:
'2023-09-23T13:07:50'` crash.
  • Loading branch information
snan committed Sep 23, 2023
1 parent f6e4549 commit 2964986
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion toot/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

from dataclasses import dataclass, is_dataclass
from datetime import date, datetime
from dateutil import parser
from typing import Dict, List, Optional, Type, TypeVar, Union
from typing import get_type_hints

Expand Down Expand Up @@ -394,7 +395,7 @@ def _convert(field_type, value):
return datetime.strptime(value, "%Y-%m-%dT%H:%M:%S.%f%z")

if field_type == date:
return date.fromisoformat(value)
return parser.parse(value)

if get_origin(field_type) == list:
(inner_type,) = get_args(field_type)
Expand Down

0 comments on commit 2964986

Please sign in to comment.