Spaces:
Running
Running
Download code-review-env/sample_codebase/cart.py from Athmabhiram1/nodeaudit-openenv: direct link, hf CLI and curl.
- Browser
- Download file 550 Bytes
-
https://huggingface.co/spaces/Athmabhiram1/nodeaudit-openenv/resolve/main/code-review-env/sample_codebase/cart.py
- Command line
-
hf download hf://spaces/Athmabhiram1/nodeaudit-openenv/code-review-env/sample_codebase/cart.py
-
curl -L -o cart.py https://huggingface.co/spaces/Athmabhiram1/nodeaudit-openenv/resolve/main/code-review-env/sample_codebase/cart.py
550 Bytes
| """Cart calculations.""" | |
| import config | |
| def calculate_subtotal(items: list[dict[str, float]]) -> float: | |
| subtotal = 0.0 | |
| for item in items: | |
| subtotal += float(item.get("price", 0.0)) * float(item.get("qty", 0.0)) | |
| return subtotal | |
| def calculate_total(items: list[dict[str, float]]) -> float: | |
| subtotal = calculate_subtotal(items) | |
| # BUG: config.DISCOUNT_RATE is intended to be 0.20, but set to 20 in config. | |
| discounted = subtotal - (subtotal * config.DISCOUNT_RATE) | |
| return discounted + (discounted * config.TAX_RATE) | |