feat: runtime

This commit is contained in:
Dan Chen
2024-03-21 15:13:32 +08:00
parent e914aeee32
commit 49659dcc13
6 changed files with 339 additions and 4 deletions

View File

@ -18,14 +18,14 @@ class Blackbox(ABC):
Output same as above.
"""
@abstractmethod
async def processing(self, data: any) -> any:
async def processing(self, *args, **kwargs) -> any:
pass
"""
valid method should return True if the data is valid and False if the data is invalid
"""
@abstractmethod
def valid(self, data: any) -> bool:
def valid(self, *args, **kwargs) -> bool:
pass
"""

View File

@ -10,7 +10,7 @@ class Calculator(Blackbox):
def valid(self, data: any) -> bool:
return isinstance(data, dict) and "op" in data and "left" in data and "right" in data
def processing(self, data: dict) -> any:
def processing(self, data: dict) -> int | float:
if not self.valid(data):
raise ValueError("Invalid data")
a = data["left"]