Skip to content

Commit

Permalink
Fix mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
matthieucan committed Jan 6, 2025
1 parent ee2c465 commit a165455
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/dbt_score/dbt_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# Conditionally import dbt objects.
try:
DBT_INSTALLED = True
from dbt.cli.main import dbtRunner, dbtRunnerResult # type: ignore
from dbt.cli.main import dbtRunner, dbtRunnerResult
except ImportError:
DBT_INSTALLED = False

Expand Down
12 changes: 6 additions & 6 deletions src/dbt_score/rules/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@ def has_uniqueness_test(model: Model) -> RuleViolation | None:
pk_columns = None
# At column level?
for column in model.columns:
for constraint in column.constraints:
if constraint.type == "primary_key":
for column_constraint in column.constraints:
if column_constraint.type == "primary_key":
pk_columns = [column.name]
break
else:
continue
break
# Or at table level?
if pk_columns is None:
for constraint in model.constraints:
if constraint["type"] == "primary_key":
pk_columns = constraint["columns"]
for model_constraint in model.constraints:
if model_constraint["type"] == "primary_key":
pk_columns = model_constraint["columns"]
break

if pk_columns is None: # No PK, no need for uniqueness test
Expand All @@ -90,7 +90,7 @@ def has_uniqueness_test(model: Model) -> RuleViolation | None:

for data_test in model.tests:
if data_test.type == "unique_combination_of_columns":
if set(data_test.kwargs.get("combination_of_columns")) == set(pk_columns):
if set(data_test.kwargs.get("combination_of_columns")) == set(pk_columns): # type: ignore
return None

return RuleViolation("There is no uniqueness test defined and matching the PK.")

0 comments on commit a165455

Please sign in to comment.