8300788module-05(ex0): change imports to be in compliance with the requirements
1 file changed, +12, -12
module-05/ex0/data_processor.py
+12, -12
+12, -12
@@ -1,18 +1,18 @@
1 -from abc import ABC, abstractmethod
2 -from typing import Any
1+import abc
2+import typing
3 3
4 4
5 -class DataProcessor(ABC):
5+class DataProcessor(abc.ABC):
6 6 def __init__(self) -> None:
7 7 self._storage: list[str] = []
8 8 self._rank: int = 0
9 9
10 - @abstractmethod
11 - def validate(self, data: Any) -> bool:
10+ @abc.abstractmethod
11+ def validate(self, data: typing.Any) -> bool:
12 12 pass
13 13
14 - @abstractmethod
15 - def ingest(self, data: Any) -> None:
14+ @abc.abstractmethod
15+ def ingest(self, data: typing.Any) -> None:
16 16 pass
17 17
18 18 def output(self) -> tuple[int, str]:
@@ -27,7 +27,7 @@ class DataProcessor(ABC):
27 27
28 28
29 29 class NumericProcessor(DataProcessor):
30 - def validate(self, data: Any) -> bool:
30+ def validate(self, data: typing.Any) -> bool:
31 31 if isinstance(data, (int, float)):
32 32 return True
33 33
@@ -55,7 +55,7 @@ class NumericProcessor(DataProcessor):
55 55
56 56
57 57 class TextProcessor(DataProcessor):
58 - def validate(self, data: Any) -> bool:
58+ def validate(self, data: typing.Any) -> bool:
59 59 if isinstance(data, str):
60 60 return True
61 61
@@ -79,8 +79,8 @@ class TextProcessor(DataProcessor):
79 79
80 80
81 81 class LogProcessor(DataProcessor):
82 - def validate(self, data: Any) -> bool:
83 - def valid_dict(d: Any) -> bool:
82+ def validate(self, data: typing.Any) -> bool:
83+ def valid_dict(d: typing.Any) -> bool:
84 84 if not isinstance(d, dict):
85 85 return False
86 86
@@ -161,7 +161,7 @@ def main() -> None:
161161 rank, value = numeric.output()
162162 print(f" Numeric value {rank}: {value}")
163163
164 - mix_data = [1, 2.5, 3.1, 4.6]
164+ mix_data = [1, 2.5, 3.1, 4]
165165 print(f" Processing mix data: {mix_data}")
166166
167167 numeric.ingest(mix_data)