mirror of
https://github.com/coding-horror/basic-computer-games.git
synced 2025-12-05 20:40:25 -08:00
Fixes the type check failures for python implementations, boxing.py and Stock_Market.py
This commit is contained in:
@@ -3,7 +3,7 @@ import json
|
||||
import random
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
from typing import Dict, Literal, NamedTuple, Tuple
|
||||
from typing import Dict, Literal, NamedTuple, Tuple, cast
|
||||
|
||||
|
||||
class PunchProfile(NamedTuple):
|
||||
@@ -70,7 +70,7 @@ def read_punch_profiles(filepath: Path) -> Dict[Literal[1, 2, 3, 4], PunchProfil
|
||||
with open(filepath) as f:
|
||||
punch_profile_dict = json.load(f)
|
||||
return {
|
||||
int(key): PunchProfile(**value)
|
||||
cast(Literal[1, 2, 3, 4], int(key)): PunchProfile(**value)
|
||||
for key, value in punch_profile_dict.items()
|
||||
}
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ class Stock_Market:
|
||||
return self.cash_assets + self.stock_assets
|
||||
|
||||
def _generate_day_change(self) -> None:
|
||||
self.changes = []
|
||||
self.changes: List[float] = []
|
||||
self.changes.extend(
|
||||
round(random.uniform(-5, 5), 2) for _ in range(len(self.data))
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user