Skip to content

Commit

Permalink
Fix linter errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Iain-S committed Sep 23, 2024
1 parent eaf3fd8 commit fb09fc9
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions usage_function/utils/usage.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ def combine_items(item_to_update: models.Usage, other_item: models.Usage) -> Non
item_to_update.unit_price = (item_to_update.unit_price or 0) + (
other_item.unit_price or 0
)

item_to_update.cost += other_item.cost
item_to_update.cost = (item_to_update.cost or 0) + (other_item.cost or 0)


def combine_itemz(items: list[models.Usage]) -> list[models.Usage]:
Expand All @@ -118,7 +117,7 @@ def combine_itemz(items: list[models.Usage]) -> list[models.Usage]:
"quantity",
}

ret_list = []
ret_list: list[models.Usage] = []
for item in items:
curr_item_fields_dict = item.model_dump(exclude=combinable_fields)

Expand All @@ -129,11 +128,10 @@ def combine_itemz(items: list[models.Usage]) -> list[models.Usage]:
if existing_fields_dict == curr_item_fields_dict:
# item can be combined.
match_found = True
combine_items(ret_list[idx], item)
break

if match_found:
combine_items(ret_list[idx], item)
else:
if not match_found:
# insert item into ret_list
ret_list.append(copy.deepcopy(item))
return ret_list
Expand Down

0 comments on commit fb09fc9

Please sign in to comment.