From a56a42f52b611bdb6d9a5c6cd7bfc0b1e7b67e75 Mon Sep 17 00:00:00 2001 From: Aldrin Misquitta Date: Tue, 24 Sep 2024 15:02:21 +0400 Subject: [PATCH] Fixes the type check failures for python implementations, boxing.py and Stock_Market.py --- 15_Boxing/python/boxing.py | 4 ++-- 83_Stock_Market/python/Stock_Market.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/15_Boxing/python/boxing.py b/15_Boxing/python/boxing.py index 9d8c87d58..907f645c7 100755 --- a/15_Boxing/python/boxing.py +++ b/15_Boxing/python/boxing.py @@ -3,7 +3,7 @@ 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() } diff --git a/83_Stock_Market/python/Stock_Market.py b/83_Stock_Market/python/Stock_Market.py index 38d8442a1..6ad3f8d1a 100644 --- a/83_Stock_Market/python/Stock_Market.py +++ b/83_Stock_Market/python/Stock_Market.py @@ -34,7 +34,7 @@ def total_assets(self) -> float: 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)) )