From 6c04e2fee424917ae5a38ac42e01d1db79bb084c Mon Sep 17 00:00:00 2001 From: LordBaryhobal Date: Wed, 24 Jun 2026 14:10:30 +0200 Subject: [PATCH 1/3] feat(cli): add compile option to ignore errors --- midas/cli/commands/compile.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/midas/cli/commands/compile.py b/midas/cli/commands/compile.py index 5a623ec..497a0f9 100644 --- a/midas/cli/commands/compile.py +++ b/midas/cli/commands/compile.py @@ -19,9 +19,11 @@ from midas.utils import TypedAST @click.command(help="Compile source") @click.argument("file", type=click.File("r")) @click.option("-t", "--types", type=click.File("r"), multiple=True) +@click.option("--ignore-errors", is_flag=True) def compile( file: TextIO, types: tuple[TextIO], + ignore_errors: bool, ): source: str = file.read() source_path: Path = Path(file.name).resolve() @@ -35,7 +37,9 @@ def compile( printer = DiagnosticPrinter() printer.print_all(diagnostics) - if any(map(lambda d: d.type == DiagnosticType.ERROR, diagnostics)): + if not ignore_errors and any( + map(lambda d: d.type == DiagnosticType.ERROR, diagnostics) + ): sys.exit(1) generator = Generator(workdir=source_path.parent, types=checker.types) From 66f39acec00036d9690146ffd25b85d78b005a13 Mon Sep 17 00:00:00 2001 From: LordBaryhobal Date: Wed, 24 Jun 2026 14:11:15 +0200 Subject: [PATCH 2/3] fix(cli): show all diagnostics in types command combine type checker diagnostics with judgements info diagnostics --- midas/cli/commands/types.py | 1 + 1 file changed, 1 insertion(+) diff --git a/midas/cli/commands/types.py b/midas/cli/commands/types.py index d17a0a8..57aa897 100644 --- a/midas/cli/commands/types.py +++ b/midas/cli/commands/types.py @@ -41,6 +41,7 @@ def types( message=f"Type: {type}", ) ) + diagnostics.extend(checker.diagnostics) printer = DiagnosticPrinter() printer.print_all(diagnostics) From 32ed62a6f17356e3dc5f902753ce1b6ef241e720 Mon Sep 17 00:00:00 2001 From: LordBaryhobal Date: Wed, 24 Jun 2026 14:11:39 +0200 Subject: [PATCH 3/3] fix(cli): show summary of diagnostic counts --- midas/cli/utils.py | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/midas/cli/utils.py b/midas/cli/utils.py index 6cc7d38..38ceaee 100644 --- a/midas/cli/utils.py +++ b/midas/cli/utils.py @@ -1,3 +1,4 @@ +from collections import defaultdict from pathlib import Path from typing import Optional @@ -7,6 +8,13 @@ from midas.cli.ansi import Ansi class DiagnosticPrinter: + COLORS: dict[DiagnosticType, int] = { + DiagnosticType.ERROR: Ansi.RED, + DiagnosticType.WARNING: Ansi.YELLOW, + DiagnosticType.INFO: Ansi.CYAN, + DiagnosticType.DEBUG: Ansi.MAGENTA, + } + def __init__(self) -> None: self.files: dict[Optional[str], list[str]] = {} @@ -22,10 +30,25 @@ class DiagnosticPrinter: return self.files[filename] def print_all(self, diagnostics: list[Diagnostic], indent: int = 4): + by_type: dict[DiagnosticType, int] = defaultdict(int) for diagnostic in diagnostics: filename: Optional[str] = diagnostic.file_path lines = self.get_lines(filename) self.print(lines, diagnostic, indent=indent) + by_type[diagnostic.type] += 1 + + if len(diagnostics) == 0: + return + + counts: list[str] = [] + for type in DiagnosticType: + if type not in by_type: + continue + count: int = by_type[type] + color: int = self.COLORS.get(type, Ansi.WHITE) + counts.append(f"{Ansi.FG(color)}{type.value}s{Ansi.RESET}: {count}") + + print(" ".join(counts)) def print(self, lines: list[str], diagnostic: Diagnostic, indent: int = 4): """Pretty-print a diagnostic, showing some context if possible @@ -55,12 +78,7 @@ class DiagnosticPrinter: before: str = line[:start_offset] after: str = line[end_offset:] - color: int = { - DiagnosticType.ERROR: Ansi.RED, - DiagnosticType.WARNING: Ansi.YELLOW, - DiagnosticType.INFO: Ansi.CYAN, - DiagnosticType.DEBUG: Ansi.MAGENTA, - }.get(diagnostic.type, Ansi.WHITE) + color: int = self.COLORS.get(diagnostic.type, Ansi.WHITE) subject: str = Ansi.FG(color) + line[start_offset:end_offset] + Ansi.RESET cursor: str = (