Skip to content

Commit dc2f6e1

Browse files
committed
add mypyyyyyyy
1 parent 918e935 commit dc2f6e1

7 files changed

Lines changed: 10 additions & 5 deletions

File tree

src/supermarket_receipt/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@ The starting position for this exercise contains the code for setting up the Tel
1313
- make a venv
1414
- install requirements, e.g. `python -m pip install -r requirements.txt`
1515
- use pytest to run the tests
16+
17+
## Mypy
18+
19+
You can validate the types with the following command: `mypy src/supermarket_receipt/`. Only a missing stub for appovaltests should be raised by default.
20+

src/supermarket_receipt/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ pytest==7.3.2
22
approvaltests==10.0.0
33
pytest-approvaltests==0.2.4
44
coverage
5+
mypy

src/supermarket_receipt/src/catalog.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33

44
class SupermarketCatalog:
5-
def __init__(self):
5+
def __init__(self) -> None:
66
self.products: dict[str, Product] = {}
77
self.prices: dict[str, float] = {}
88

src/supermarket_receipt/src/receipt.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ def __init__(self) -> None:
1515
self._discounts: list[Discount] = []
1616

1717
def total_price(self) -> float:
18-
total = 0
18+
total = 0.0
1919
for item in self.items:
2020
total += item.total_price
2121
for discount in self.discounts:

src/supermarket_receipt/src/teller.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
class Teller:
88

9-
def __init__(self, catalog):
9+
def __init__(self, catalog: SupermarketCatalog) -> None:
1010
self.catalog: SupermarketCatalog = catalog
1111
self.offers: dict[Product, Offer] = {}
1212

src/supermarket_receipt/tests/receipt_printer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from src.model_objects import ProductUnit
1+
from src.model_objects import ProductUnit, Discount
22
from src.receipt import Receipt, ReceiptItem
33

44

src/supermarket_receipt/tests/test_supermarket.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import approvaltests
2-
import pytest
32

43
from src.model_objects import SpecialOfferType, Product
54
from tests.receipt_printer import ReceiptPrinter

0 commit comments

Comments
 (0)