feat: calculator;

This commit is contained in:
Dan Chen
2024-03-19 09:07:57 +08:00
parent f773627aa4
commit 4e2a4ef63c
3 changed files with 4 additions and 4 deletions

View File

@ -4,12 +4,12 @@ from blackbox.blackbox import Blackbox
class Calculator(Blackbox):
"""This class just for example, it show how to implement Blackbox interface."""
"""This class just for example, it show how to implement Blackbox interface."""
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:
if not self.valid(data):
raise ValueError("Invalid data")