b025782module-10(ex{2..4}): adapt so flake8 wont complain
3 files changed, +7, -4
@@ -3,23 +3,28 @@ from collections.abc import Callable
3 3
4 4 def mage_counter() -> Callable:
5 5 count = 0
6+
6 7 def counter() -> int:
7 8 nonlocal count
8 9 count += 1
910 return count
11+
1012 return counter
1113
1214
1315 def spell_accumulator(initial_power: int) -> Callable:
1416 total = initial_power
17+
1518 def accumulate(amount: int) -> int:
1619 nonlocal total
1720 total += amount
1821 return total
22+
1923 return accumulate
2024
2125
2226 def enchantment_factory(enchantment_type: str) -> Callable:
27+
2328 def enchant(item_name: str) -> str:
2429 return f"{enchantment_type} {item_name}"
2530 return enchant
@@ -27,8 +32,10 @@ def enchantment_factory(enchantment_type: str) -> Callable:
2732
2833 def memory_vault() -> dict[str, Callable]:
2934 vault: dict = {}
35+
3036 def store(key: str, value: object) -> None:
3137 vault[key] = value
38+
3239 def recall(key: str) -> object:
3340 return vault.get(key, "Memory not found")
3441 return {"store": store, "recall": recall}
@@ -14,8 +14,6 @@ def spell_reducer(spells: list[int], operation: str) -> int:
1414 }
1515 if operation not in ops:
1616 raise ValueError(f"Unknown operation: {operation}")
17 - if operation in ("max", "min"):
18 - return reduce(ops[operation], spells)
1917 return reduce(ops[operation], spells)
2018
2119
@@ -83,7 +81,6 @@ if __name__ == "__main__":
8381 print(f"fib(15): {memoized_fibonacci(15)}")
8482 print(f"Cache info: {memoized_fibonacci.cache_info()}")
8583
86 -
8784 print("\nTesting spell dispatcher...")
8885 dispatch = spell_dispatcher()
8986 print(dispatch(42))