Skip to content

Commit a56a42f

Browse files
committed
Fixes the type check failures for python implementations, boxing.py and Stock_Market.py
1 parent 6a4936c commit a56a42f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

15_Boxing/python/boxing.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import random
44
from dataclasses import dataclass
55
from pathlib import Path
6-
from typing import Dict, Literal, NamedTuple, Tuple
6+
from typing import Dict, Literal, NamedTuple, Tuple, cast
77

88

99
class PunchProfile(NamedTuple):
@@ -70,7 +70,7 @@ def read_punch_profiles(filepath: Path) -> Dict[Literal[1, 2, 3, 4], PunchProfil
7070
with open(filepath) as f:
7171
punch_profile_dict = json.load(f)
7272
return {
73-
int(key): PunchProfile(**value)
73+
cast(Literal[1, 2, 3, 4], int(key)): PunchProfile(**value)
7474
for key, value in punch_profile_dict.items()
7575
}
7676

83_Stock_Market/python/Stock_Market.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def total_assets(self) -> float:
3434
return self.cash_assets + self.stock_assets
3535

3636
def _generate_day_change(self) -> None:
37-
self.changes = []
37+
self.changes: List[float] = []
3838
self.changes.extend(
3939
round(random.uniform(-5, 5), 2) for _ in range(len(self.data))
4040
)

0 commit comments

Comments
 (0)