From 35ceda99aa4b4374e7c7b8a784bf766aaf8ddec0 Mon Sep 17 00:00:00 2001 From: LordBaryhobal Date: Tue, 2 Jun 2026 11:45:49 +0200 Subject: [PATCH] chore: tidy --- midas/checker/checker.py | 11 +++++++---- midas/resolver/builtin.py | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/midas/checker/checker.py b/midas/checker/checker.py index c873863..c210b7c 100644 --- a/midas/checker/checker.py +++ b/midas/checker/checker.py @@ -9,7 +9,7 @@ from midas.ast.location import Location from midas.checker.diagnostic import Diagnostic, DiagnosticType from midas.checker.environment import Environment from midas.checker.operators import COMPARATOR_METHODS, OPERATOR_METHODS -from midas.checker.types import BaseType, Function, SimpleType, Type, UnitType, UnknownType +from midas.checker.types import Function, Type, UnitType, UnknownType from midas.lexer.midas import MidasLexer from midas.lexer.token import Token from midas.parser.midas import MidasParser @@ -91,7 +91,7 @@ class Checker( Args: block (list[p.Stmt]): the statements to evaluate env (Environment): the environment in which to evaluate - + Returns: bool: whether a return statement is present in the block """ @@ -223,7 +223,7 @@ class Checker( for arg in pos_args + args + kw_args: env.define(arg.name, arg.type) - + returns_hint: Optional[Type] = None if stmt.returns is not None: returns_hint = stmt.returns.accept(self) @@ -417,7 +417,10 @@ class Checker( true_type: Type = expr.if_true.accept(self) false_type: Type = expr.if_false.accept(self) if true_type != false_type: - self.error(expr.location, f"Type mismatch in ternary if branches: true={true_type} != false={false_type}") + self.error( + expr.location, + f"Type mismatch in ternary if branches: true={true_type} != false={false_type}", + ) return UnknownType() return true_type diff --git a/midas/resolver/builtin.py b/midas/resolver/builtin.py index 6a00b14..04bc6e3 100644 --- a/midas/resolver/builtin.py +++ b/midas/resolver/builtin.py @@ -16,6 +16,7 @@ def op(ctx: MidasResolver, t1: Type, operator: str, t2: Type, t3: Type): result=t3, ) + def basic_op(ctx: MidasResolver, type: Type, op: str): ctx.define_operation( left=type, @@ -68,4 +69,4 @@ def define_builtins(ctx: MidasResolver): op(ctx, float, "__gt__", int, bool) # float > int = bool op(ctx, float, "__le__", int, bool) # float <= int = bool op(ctx, float, "__ge__", int, bool) # float >= int = bool - op(ctx, float, "__eq__", int, bool) # float == int = bool \ No newline at end of file + op(ctx, float, "__eq__", int, bool) # float == int = bool