Skip to content

Commit

Permalink
Migrate from custom _error_tag to dbt-common defined error_tag (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
QMalcolm authored Apr 12, 2024
1 parent cb56f4f commit c53d67d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
6 changes: 6 additions & 0 deletions .changes/unreleased/Under the Hood-20240412-134502.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
kind: Under the Hood
body: Migrate to using `error_tag` provided by `dbt-common`
time: 2024-04-12T13:45:02.879023-07:00
custom:
Author: QMalcolm
Issue: "9914"
11 changes: 3 additions & 8 deletions core/dbt/events/types.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import json

from dbt.constants import MAXIMUM_SEED_SIZE_NAME, PIN_PACKAGE_URL
from dbt_common.ui import warning_tag, line_wrap_message, green, yellow, red
from dbt_common.ui import error_tag, warning_tag, line_wrap_message, green, yellow, red
from dbt_common.events.base_types import EventLevel
from dbt_common.events.format import (
format_fancy_output_line,
Expand All @@ -11,11 +11,6 @@
from dbt.events.base_types import WarnLevel, InfoLevel, DebugLevel, ErrorLevel, DynamicLevel


# TODO Move this to dbt_common.ui
def _error_tag(msg: str) -> str:
return f'[{red("ERROR")}]: {msg}'


# Event codes have prefixes which follow this table
#
# | Code | Description |
Expand Down Expand Up @@ -430,7 +425,7 @@ def message(self) -> str:
)

if self.level == EventLevel.ERROR.value:
description = _error_tag(description)
description = error_tag(description)
elif self.level == EventLevel.WARN.value:
description = warning_tag(description)

Expand All @@ -448,7 +443,7 @@ def message(self) -> str:
description += " Run again with `--debug` to see them all."

if self.level == EventLevel.ERROR.value:
description = _error_tag(description)
description = error_tag(description)
elif self.level == EventLevel.WARN.value:
description = warning_tag(description)

Expand Down
2 changes: 1 addition & 1 deletion core/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"minimal-snowplow-tracker>=0.0.2,<0.1",
"dbt-semantic-interfaces>=0.5.1,<0.6",
# Minor versions for these are expected to be backwards-compatible
"dbt-common<2.0",
"dbt-common>=1.0.1,<2.0",
"dbt-adapters>=0.1.0a2,<2.0",
# ----
# Expect compatibility with all new versions of these packages, so lower bounds only.
Expand Down

0 comments on commit c53d67d

Please sign in to comment.