Skip to content
Snippets Groups Projects
Commit be5df93f authored by Bilel El Yaagoubi's avatar Bilel El Yaagoubi
Browse files

lint !

parent 65777830
No related branches found
No related tags found
No related merge requests found
Pipeline #46217 passed
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
This Calculator holds the logic for the calculator. This Calculator holds the logic for the calculator.
""" """
from calculator.operators import Operator, STANDARD_OPERATORS from calculator.operators import Operator, STANDARD_OPERATORS
from calculator.expression import Token, Term, Expression, TermExpression, OperatorExpression from calculator.expression import Term, Expression, TermExpression, OperatorExpression
class Calculator: class Calculator:
...@@ -17,8 +17,10 @@ class Calculator: ...@@ -17,8 +17,10 @@ class Calculator:
if operators is None: if operators is None:
operators = STANDARD_OPERATORS operators = STANDARD_OPERATORS
self.operators = operators self.operators = operators
def tokenize(self, line: str): def tokenize(self, line: str):
"""
ok
"""
tokens = [] tokens = []
for token in line.split(): for token in line.split():
if token in self.operators: if token in self.operators:
......
""" """
Expression module defines the structure of an expression. Expression module defines the structure of an expression.
""" """
from calculator.operators import Operator
from typing import Union from typing import Union
from calculator.operators import Operator
Term: type = int Term: type = int
Token: type = Union[Operator, Term] Token: type = Union[Operator, Term]
......
...@@ -17,4 +17,6 @@ class Operator: ...@@ -17,4 +17,6 @@ class Operator:
return self.evaluate_function(left, right) return self.evaluate_function(left, right)
STANDARD_OPERATORS = { '+': Operator('+', 1, lambda a, b: a + b),'-': Operator('-', 1, lambda a, b: a - b),'*': Operator('×', 2, lambda a, b: a * b),'/': Operator('/', 2, lambda a, b: a / b)} STANDARD_OPERATORS = { '+': Operator('+', 1, lambda a, b: a + b),
'-': Operator('-', 1, lambda a, b: a - b),'*': Operator('×', 2, lambda a, b: a * b),
'/': Operator('/', 2, lambda a, b: a / b)}
from calculator.calculator import Calculator """
caca
"""
from fastapi import FastAPI from fastapi import FastAPI
from fastapi.requests import Request from fastapi.requests import Request
from fastapi.templating import Jinja2Templates from fastapi.templating import Jinja2Templates
from calculator.calculator import Calculator
app = FastAPI() app = FastAPI()
templates = Jinja2Templates(directory="calculator/templates") templates = Jinja2Templates(directory="calculator/templates")
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment