-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Overview Extends rules so that they can be used to against dbt [sources](https://docs.getdbt.com/docs/build/sources) in addition to models. # Usage A rule defines what resource-type it acts against in the type signature of the function it wraps or in a class-based `evaluate` method: ```python from dbt_score import Model, Source rule, Rule, RuleViolation # decorator-based # for a Model @rule def model_has_description(model: Model) -> RuleViolation | None: """A model should have a description.""" if not model.description: return RuleViolation(message="Model lacks a description.") # for a Source @rule def has_description(source: Source) -> RuleViolation | None: """A source should have a loader defined.""" if not source.loader: return RuleViolation(message="Source lacks a loader.") # class-based class ExampleSource(Rule): """Example class-based rule.""" description = "A source should have a loader defined." def evaluate(self, source: Source) -> RuleViolation | None: """Evaluate source.""" if not source.loader: return RuleViolation(message="Source lacks a loader.") ``` The `Evaluation` handler is then responsible for applying source-rules to Source objects and model-rules to Model objects. --- closes #76 --------- Co-authored-by: Jochem van Dooren <[email protected]> Co-authored-by: Jochem van Dooren <[email protected]> Co-authored-by: Matthieu Caneill <[email protected]>
- Loading branch information
1 parent
b0bb6f3
commit 8aa8aad
Showing
44 changed files
with
1,452 additions
and
491 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ build-backend = "pdm.backend" | |
name = "dbt-score" | ||
dynamic = ["version"] | ||
|
||
description = "Linter for dbt model metadata." | ||
description = "Linter for dbt metadata." | ||
authors = [ | ||
{name = "Picnic Analyst Development Platform", email = "[email protected]"} | ||
] | ||
|
@@ -101,6 +101,7 @@ max-args = 9 | |
[tool.ruff.lint.per-file-ignores] | ||
"tests/**/*.py" = [ | ||
"PLR2004", # Magic value comparisons | ||
"PLR0913", # Too many args in func def | ||
] | ||
|
||
### Coverage ### | ||
|
@@ -114,3 +115,7 @@ source = [ | |
[tool.coverage.report] | ||
show_missing = true | ||
fail_under = 80 | ||
exclude_also = [ | ||
"@overload" | ||
] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
"""Init dbt_score package.""" | ||
|
||
from dbt_score.model_filter import ModelFilter, model_filter | ||
from dbt_score.models import Model | ||
from dbt_score.models import Model, Source | ||
from dbt_score.rule import Rule, RuleViolation, Severity, rule | ||
from dbt_score.rule_filter import RuleFilter, rule_filter | ||
|
||
__all__ = [ | ||
"Model", | ||
"ModelFilter", | ||
"Source", | ||
"RuleFilter", | ||
"Rule", | ||
"RuleViolation", | ||
"Severity", | ||
"model_filter", | ||
"rule_filter", | ||
"rule", | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.