fix(ex4): add wraps to every functions;

mypy compliance
This commit is contained in:
2026-03-29 13:33:56 +02:00
parent 1dfeee81e3
commit 1cf669e6f8
6 changed files with 60 additions and 268 deletions
+8 -3
View File
@@ -1,4 +1,7 @@
def artifact_sorter(artifacts: list[dict]) -> list[dict]:
from typing import Any
def artifact_sorter(artifacts: list[dict[Any, Any]]) -> list[dict[Any, Any]]:
try:
return sorted(artifacts, key=lambda artifact: artifact["power"])
except KeyError as err:
@@ -6,7 +9,9 @@ def artifact_sorter(artifacts: list[dict]) -> list[dict]:
return artifacts
def power_filter(mages: list[dict], min_power: int) -> list[dict]:
def power_filter(
mages: list[dict[Any, Any]], min_power: int
) -> list[dict[Any, Any]]:
try:
return list(filter(lambda x: x["power"] >= min_power, mages))
except KeyError as err:
@@ -18,7 +23,7 @@ def spell_transformer(spells: list[str]) -> list[str]:
return list(map(lambda x: "* " + x + " *", spells))
def mage_stats(mages: list[dict]) -> dict:
def mage_stats(mages: list[dict[Any, Any]]) -> dict[str, int | float]:
try:
max_power = max(mages, key=lambda mage: mage["power"])
min_power = min(mages, key=lambda mage: mage["power"])