Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Apr 13, 2026
commit 9611435dcf9cdbbadc2c0c8a11a1e246a6f1d04e
7 changes: 4 additions & 3 deletions other/grocery_store_cart.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

def add_item(self, item: str, quantity: int = 1) -> None:
if item not in self.price_catalog:
raise KeyError(f"{item!r} is not in the catalog")

Check failure on line 28 in other/grocery_store_cart.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (EM102)

other/grocery_store_cart.py:28:28: EM102 Exception must not use an f-string literal, assign to variable first help: Assign to variable; remove f-string literal
if quantity <= 0:
raise ValueError("quantity must be positive")
self.quantities[item] = self.quantities.get(item, 0) + quantity
Expand All @@ -35,15 +35,16 @@
raise ValueError("quantity must be positive")
current = self.quantities.get(item, 0)
if current == 0:
raise KeyError(f"{item!r} is not present in the cart")

Check failure on line 38 in other/grocery_store_cart.py

View workflow job for this annotation

GitHub Actions / ruff

ruff (EM102)

other/grocery_store_cart.py:38:28: EM102 Exception must not use an f-string literal, assign to variable first help: Assign to variable; remove f-string literal
remaining = current - quantity
if remaining > 0:
if (remaining := current - quantity) > 0:
self.quantities[item] = remaining
else:
self.quantities.pop(item, None)

def total_price(self) -> float:
return sum(self.price_catalog[item] * qty for item, qty in self.quantities.items())
return sum(
self.price_catalog[item] * qty for item, qty in self.quantities.items()
Comment thread
nickzerjeski marked this conversation as resolved.
)


if __name__ == "__main__":
Expand Down
Loading