Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new flags for silenting errors and such #1462

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions jac/jaclang/compiler/passes/ir_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down
7 changes: 6 additions & 1 deletion jac/jaclang/compiler/passes/utils/mypy_ast_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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[
Expand Down
3 changes: 3 additions & 0 deletions jac/jaclang/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading