Skip to content

Commit 471e617

Browse files
committed
refactor: breaking up the console interface
1 parent 2d87813 commit 471e617

2 files changed

Lines changed: 11 additions & 9 deletions

File tree

sqlmesh/core/console.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,15 @@
8383
RED_X_MARK = "\u274c"
8484

8585

86-
class Console(abc.ABC):
86+
class LinterConsole(abc.ABC):
87+
@abc.abstractmethod
88+
def show_linter_violations(
89+
self, violations: t.List[RuleViolation], model: Model, is_error: bool = False
90+
) -> None:
91+
"""Prints all linter violations depending on their severity"""
92+
93+
94+
class Console(LinterConsole, abc.ABC):
8795
"""Abstract base class for defining classes used for displaying information to the user and also interact
8896
with them when their input is needed."""
8997

@@ -400,12 +408,6 @@ def _limit_model_names(self, tree: Tree, verbosity: Verbosity = Verbosity.DEFAUL
400408
]
401409
return tree
402410

403-
@abc.abstractmethod
404-
def show_linter_violations(
405-
self, violations: t.List[RuleViolation], model: Model, is_error: bool = False
406-
) -> None:
407-
"""Prints all linter violations depending on their severity"""
408-
409411

410412
class NoopConsole(Console):
411413
def start_plan_evaluation(self, plan: EvaluatablePlan) -> None:

sqlmesh/core/linter/definition.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from sqlmesh.core.model import Model
88

99
from sqlmesh.utils.errors import raise_config_error
10-
from sqlmesh.core.console import get_console, Console
10+
from sqlmesh.core.console import LinterConsole, get_console, Console
1111
from sqlmesh.core.linter.rule import RuleSet
1212

1313

@@ -50,7 +50,7 @@ def from_rules(cls, all_rules: RuleSet, config: LinterConfig) -> Linter:
5050

5151
return Linter(config.enabled, all_rules, rules, warn_rules)
5252

53-
def lint_model(self, model: Model, console: Console = get_console()) -> bool:
53+
def lint_model(self, model: Model, console: LinterConsole = get_console()) -> bool:
5454
if not self.enabled:
5555
return False
5656

0 commit comments

Comments
 (0)