From 772259b06bbe7dd4eb134691d3ba8faac3a3fb9b Mon Sep 17 00:00:00 2001 From: marsninja Date: Sun, 24 Nov 2024 16:57:47 -0500 Subject: [PATCH] feat: new flags for silenting errors and such --- jac/jaclang/compiler/passes/ir_pass.py | 6 ++++-- jac/jaclang/compiler/passes/utils/mypy_ast_build.py | 7 ++++++- jac/jaclang/settings.py | 3 +++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/jac/jaclang/compiler/passes/ir_pass.py b/jac/jaclang/compiler/passes/ir_pass.py index ee32ea64ad..5a615ba758 100644 --- a/jac/jaclang/compiler/passes/ir_pass.py +++ b/jac/jaclang/compiler/passes/ir_pass.py @@ -140,11 +140,13 @@ def traverse(self, node: ast.AstNode) -> ast.AstNode: def error(self, msg: str, node_override: Optional[ast.AstNode] = None) -> None: """Pass Error.""" - self.log_error(msg, node_override=node_override) + if not settings.silent_errors: + self.log_error(msg, node_override=node_override) def warning(self, msg: str, node_override: Optional[ast.AstNode] = None) -> None: """Pass Error.""" - self.log_warning(msg, node_override=node_override) + if not (settings.silent_warnings or settings.silent_errors): + self.log_warning(msg, node_override=node_override) def ice(self, msg: str = "Something went horribly wrong!") -> RuntimeError: """Pass Error.""" diff --git a/jac/jaclang/compiler/passes/utils/mypy_ast_build.py b/jac/jaclang/compiler/passes/utils/mypy_ast_build.py index 53fd75dad5..b2bcac8954 100644 --- a/jac/jaclang/compiler/passes/utils/mypy_ast_build.py +++ b/jac/jaclang/compiler/passes/utils/mypy_ast_build.py @@ -6,11 +6,13 @@ import os from typing import Callable, TYPE_CHECKING, TextIO + from jaclang.compiler.absyntree import AstNode from jaclang.compiler.passes import Pass from jaclang.compiler.passes.main.fuse_typeinfo_pass import ( FuseTypeInfoPass, ) +from jaclang.settings import settings import mypy.build as myb import mypy.checkexpr as mycke @@ -741,7 +743,10 @@ def report( end_line=end_line, end_column=end_column, ) - if (line, column, end_line, end_column) in mypy_to_jac_node_map: + if ( + settings.silent_type_errors + and (line, column, end_line, end_column) in mypy_to_jac_node_map + ): self.cur_pass.warning( msg=message, node_override=mypy_to_jac_node_map[ diff --git a/jac/jaclang/settings.py b/jac/jaclang/settings.py index 3e3c14a04a..b331216678 100644 --- a/jac/jaclang/settings.py +++ b/jac/jaclang/settings.py @@ -16,10 +16,13 @@ class Settings: pass_timer: bool = False collect_py_dep_debug: bool = False print_py_raised_ast: bool = False + silent_type_errors: bool = False # Compiler configuration disable_mtllm: bool = False ignore_test_annex: bool = False + silent_warnings: bool = False + silent_errors: bool = False # Formatter configuration max_line_length: int = 88