Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tr4nt0r committed Dec 19, 2024
1 parent 16e3baf commit 0653146
Showing 1 changed file with 22 additions and 31 deletions.
53 changes: 22 additions & 31 deletions homeassistant/components/bring/todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,29 +98,26 @@ def __init__(
@property
def todo_items(self) -> list[TodoItem]:
"""Return the todo items."""
try:
return [
*(
TodoItem(
uid=item["uuid"],
summary=item["itemId"],
description=item["specification"] or "",
status=TodoItemStatus.NEEDS_ACTION,
)
for item in self.bring_list["purchase"]
),
*(
TodoItem(
uid=item["uuid"],
summary=item["itemId"],
description=item["specification"] or "",
status=TodoItemStatus.COMPLETED,
)
for item in self.bring_list["recently"]
),
]
except StopIteration:
return []
return [
*(
TodoItem(
uid=item["uuid"],
summary=item["itemId"],
description=item["specification"] or "",
status=TodoItemStatus.NEEDS_ACTION,
)
for item in self.bring_list["purchase"]
),
*(
TodoItem(
uid=item["uuid"],
summary=item["itemId"],
description=item["specification"] or "",
status=TodoItemStatus.COMPLETED,
)
for item in self.bring_list["recently"]
),
]

@property
def bring_list(self) -> BringData:
Expand Down Expand Up @@ -163,14 +160,8 @@ async def async_update_todo_item(self, item: TodoItem) -> None:
instead and no update for this item is performed and on the next cloud pull
update, it will get cleared and replaced seamlessly.
"""
try:
bring_list = self.bring_list
except StopIteration as e:
raise HomeAssistantError(
translation_domain=DOMAIN,
translation_key="todo_rename_item_failed",
translation_placeholders={"name": item.summary or ""},
) from e

bring_list = self.bring_list

bring_purchase_item = next(
(i for i in bring_list["purchase"] if i["uuid"] == item.uid),
Expand Down

0 comments on commit 0653146

Please sign in to comment.