Skip to content

Commit

Permalink
Fix warnings as errors during tests (#5800)
Browse files Browse the repository at this point in the history
Added RunResultWarningMessage event to support this change.
  • Loading branch information
stu-k authored Sep 9, 2022
1 parent e3f8275 commit 79da002
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .changes/unreleased/Fixes-20220909-095627.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
kind: Fixes
body: Fix warnings as errors during tests
time: 2022-09-09T09:56:27.90654-05:00
custom:
Author: stu-k
Issue: "5424"
PR: "5800"
9 changes: 9 additions & 0 deletions core/dbt/events/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -1640,6 +1640,15 @@ def message(self) -> str:
return ui.yellow(f"{info} in {self.resource_type} {self.node_name} ({self.path})")


@dataclass
class RunResultWarningMessage(WarnLevel):
msg: str
code: str = "Z049"

def message(self) -> str:
return f" {self.msg}"


@dataclass
class RunResultFailure(ErrorLevel):
resource_type: str
Expand Down
6 changes: 5 additions & 1 deletion core/dbt/task/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from dbt.events.types import (
EmptyLine,
RunResultWarning,
RunResultWarningMessage,
RunResultFailure,
StatsLine,
RunResultError,
Expand Down Expand Up @@ -99,7 +100,10 @@ def print_run_result_error(result, newline: bool = True, is_warning: bool = Fals
)

if result.message:
fire_event(RunResultError(msg=result.message))
if is_warning:
fire_event(RunResultWarningMessage(msg=result.message))
else:
fire_event(RunResultError(msg=result.message))
else:
fire_event(RunResultErrorNoMessage(status=result.status))

Expand Down

0 comments on commit 79da002

Please sign in to comment.