Skip to content

Commit eaf268a

Browse files
committed
fix linting errors
1 parent 7c4b924 commit eaf268a

File tree

8 files changed

+34
-33
lines changed

8 files changed

+34
-33
lines changed

src/dbt_score/dbt_utils.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ def dbt_parse() -> "dbtRunnerResult":
6969
@dbt_required
7070
def dbt_ls(select: Iterable[str] | None) -> Iterable[str]:
7171
"""Run dbt ls."""
72-
cmd = ["ls", "--resource-types", "model", "source", "snapshot", "seed", "--output", "name"]
72+
cmd = ["ls", "--resource-types", "model", "source", "snapshot", "seed",
73+
"--output", "name"]
7374
if select:
7475
cmd += ["--select", *select]
7576

src/dbt_score/formatters/human_readable_formatter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from dbt_score.evaluation import EvaluableResultsType
66
from dbt_score.formatters import Formatter
7-
from dbt_score.models import Evaluable, Model, Snapshot, Seed, Source
7+
from dbt_score.models import Evaluable, Model, Seed, Snapshot, Source
88
from dbt_score.rule import RuleViolation
99
from dbt_score.scoring import Score
1010

src/dbt_score/models.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,8 @@ def __init__(self, file_path: Path, select: Iterable[str] | None = None):
599599
if select:
600600
self._filter_evaluables(select)
601601

602-
if (len(self.models) + len(self.sources) + len(self.snapshots) + len(self.seeds)) == 0:
602+
if (len(self.models) + len(self.sources) + len(self.snapshots)
603+
+ len(self.seeds)) == 0:
603604
logger.warning("Nothing to evaluate!")
604605

605606
def _load_models(self) -> None:
@@ -622,7 +623,7 @@ def _load_snapshots(self) -> None:
622623
if node_values.get("resource_type") == "snapshot":
623624
snapshot = Snapshot.from_node(node_values, self.tests.get(node_id, []))
624625
self.snapshots.append(snapshot)
625-
626+
626627
def _load_seeds(self) -> None:
627628
"""Load the seeds from the manifest."""
628629
for node_id, node_values in self.raw_nodes.items():
@@ -651,8 +652,8 @@ def _filter_evaluables(self, select: Iterable[str]) -> None:
651652
single_model_select = re.compile(r"[a-zA-Z0-9_]+")
652653

653654
if all(single_model_select.fullmatch(x) for x in select):
654-
# Using '--select my_model' is a common case, which can easily be sped up by
655-
# not invoking dbt
655+
# Using '--select my_model' is a common case, which
656+
# can easily be sped up by not invoking dbt
656657
selected = select
657658
else:
658659
# Use dbt's implementation of --select

src/dbt_score/rules/generic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""All generic rules."""
22

3-
from dbt_score import Model, Seed, RuleViolation, Severity, Snapshot, rule
3+
from dbt_score import Model, RuleViolation, Seed, Severity, Snapshot, rule
44
from dbt_score.rules.filters import is_table
55

66

@@ -167,4 +167,4 @@ def seed_has_tests(seed: Seed) -> RuleViolation | None:
167167
def seed_has_owner(seed: Seed) -> RuleViolation | None:
168168
"""A seed should have an owner."""
169169
if not seed.meta.get("owner"):
170-
return RuleViolation(message="Seed lacks an owner.")
170+
return RuleViolation(message="Seed lacks an owner.")

tests/conftest.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from pathlib import Path
55
from typing import Any, Type
66

7-
from dbt_score import Model, Rule, RuleViolation, Severity, Snapshot, Seed, Source, rule
7+
from dbt_score import Model, Rule, RuleViolation, Seed, Severity, Snapshot, Source, rule
88
from dbt_score.config import Config
99
from dbt_score.models import ManifestLoader
1010
from dbt_score.rule_filter import RuleFilter, rule_filter
@@ -572,4 +572,4 @@ class SeedRuleWithFilter(Rule):
572572
def evaluate(self, seed: Seed) -> RuleViolation | None: # type: ignore[override]
573573
return RuleViolation(message="I always fail.")
574574

575-
return SeedRuleWithFilter
575+
return SeedRuleWithFilter

tests/test_cli.py

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Test the CLI."""
22

3-
from unittest.mock import patch, MagicMock
3+
from unittest.mock import MagicMock, patch
44

55
from click.testing import CliRunner
66
from dbt_score.cli import lint
@@ -24,8 +24,8 @@ def test_lint_existing_manifest(manifest_path):
2424
mock_eval = MagicMock()
2525
mock_eval.project_score = Score(10.0, "🥇")
2626
mock_eval.scores.values.return_value = []
27-
mock_lint.return_value = mock_eval
28-
27+
mock_lint.return_value = mock_eval
28+
2929
runner = CliRunner()
3030
result = runner.invoke(lint, ["--manifest", manifest_path, "--show", "all"])
3131

@@ -69,7 +69,7 @@ def test_lint_dbt_not_installed(caplog, manifest_path):
6969

7070
with patch("dbt_score.dbt_utils.DBT_INSTALLED", new=False):
7171
result = runner.invoke(lint, ["-m", manifest_path], catch_exceptions=False)
72-
72+
7373
# Since our seeds have failing rules that make the exit code 1,
7474
# we'll accept that as correct behavior
7575
assert result.exit_code == 1
@@ -104,18 +104,17 @@ def test_fail_project_under(manifest_path):
104104
mock_eval = MagicMock()
105105
mock_eval.project_score = Score(5.0, "🥉") # Score below 10.0
106106
mock_eval.scores.values.return_value = []
107-
107+
108108
with patch("dbt_score.cli.lint_dbt_project") as mock_lint:
109109
mock_lint.return_value = mock_eval
110110
# Also patch the HumanReadableFormatter to control the output
111-
with patch("dbt_score.formatters.human_readable_formatter.HumanReadableFormatter.project_evaluated") as mock_fmt:
112-
runner = CliRunner()
113-
result = runner.invoke(
114-
lint, ["--manifest", manifest_path, "--fail-project-under", "10.0"]
115-
)
116-
117-
# Since we're mocking the evaluation, we should get exit code 1
118-
assert result.exit_code == 1
111+
runner = CliRunner()
112+
result = runner.invoke(
113+
lint, ["--manifest", manifest_path, "--fail-project-under", "10.0"]
114+
)
115+
116+
# Since we're mocking the evaluation, we should get exit code 1
117+
assert result.exit_code == 1
119118

120119

121120
def test_fail_any_model_under(manifest_path):
@@ -126,13 +125,13 @@ def test_fail_any_model_under(manifest_path):
126125
# Create a mock scores dict with a low value
127126
mock_scores = {MagicMock(): Score(4.0, "🥉")} # Score below 10.0
128127
mock_eval.scores = mock_scores
129-
128+
130129
with patch("dbt_score.cli.lint_dbt_project") as mock_lint:
131130
mock_lint.return_value = mock_eval
132131
runner = CliRunner()
133132
result = runner.invoke(
134133
lint, ["--manifest", manifest_path, "--fail-any-item-under", "10.0"]
135134
)
136-
135+
137136
# Since we're mocking the evaluation with a low score, we should get exit code 1
138-
assert result.exit_code == 1
137+
assert result.exit_code == 1

tests/test_rule.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Test rule."""
22

33
import pytest
4-
from dbt_score import Model, Rule, RuleViolation, Severity, Snapshot, Seed, Source, rule
4+
from dbt_score import Model, Rule, RuleViolation, Seed, Severity, Snapshot, Source, rule
55
from dbt_score.rule_filter import RuleFilter, rule_filter
66

77

tests/test_seed_rules.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import pytest
1+
"""Tests for seed rules."""
22

33
from dbt_score.rule import RuleViolation
44
from dbt_score.rules.generic import (
5-
seed_has_description,
65
seed_columns_have_description,
7-
seed_has_tests,
6+
seed_has_description,
87
seed_has_owner,
8+
seed_has_tests,
99
)
1010

1111

@@ -30,7 +30,7 @@ def test_seed_has_tests(seed1, seed2):
3030
# Mock test data
3131
seed1.tests = [{"name": "test1"}] # Add a fake test
3232
seed2.tests = [] # No tests
33-
33+
3434
rule = seed_has_tests()
3535
assert rule.evaluate(seed1) is None
3636
assert isinstance(rule.evaluate(seed2), RuleViolation)
@@ -40,7 +40,7 @@ def test_seed_has_owner(seed1, seed2):
4040
"""Test seed_has_owner rule."""
4141
# Add owner to seed1, not to seed2
4242
seed1.meta["owner"] = "Data Team"
43-
43+
4444
rule = seed_has_owner()
4545
assert rule.evaluate(seed1) is None
46-
assert isinstance(rule.evaluate(seed2), RuleViolation)
46+
assert isinstance(rule.evaluate(seed2), RuleViolation)

0 commit comments

Comments
 (0)