Skip to content

Commit

Permalink
Fix issues in items factory
Browse files Browse the repository at this point in the history
  • Loading branch information
allenporter committed Nov 18, 2023
1 parent 9f79505 commit 38bfa71
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions homeassistant/components/todo/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,11 @@ def _api_items_factory(obj: Iterable[tuple[str, Any]]) -> dict[str, str]:
"""Convert CalendarEvent dataclass items to dictionary of attributes."""
result: dict[str, str] = {}
for name, value in obj:
if isinstance(value, datetime.date):
if value is None:
continue
if isinstance(value, (datetime.date, datetime.datetime)):
result[name] = value.isoformat()
elif value is not None:
else:
result[name] = str(value)
return result

Expand Down

0 comments on commit 38bfa71

Please sign in to comment.