-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent duplicated rule exception when importing rules and filters (#87)
Fixes #85. ### Implementation - Skip adding imported rules and rule filters to rule registry. - Split `tests/rules/example.py` into `tests/rules/rules.py` and `tests/rules/rule_filters.py`. - Test `Duplicated` exception is not raised by adding an imported `skip_schemaX` rule filter. ### Note Both rules and rule filters can be imported now, but the existing tests cover only rule filters. --------- Co-authored-by: Matthieu Caneill <matthieucan@users.noreply.github.com>
- Loading branch information
1 parent
c8a7d27
commit 2c47aa9
Showing
9 changed files
with
53 additions
and
37 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
"""Example rule filters.""" | ||
|
||
from dbt_score import Model, rule_filter | ||
|
||
|
||
@rule_filter | ||
def skip_model1(model: Model) -> bool: | ||
"""An example filter.""" | ||
return model.name != "model1" | ||
|
||
|
||
@rule_filter | ||
def skip_schemaX(model: Model) -> bool: | ||
"""An example filter.""" | ||
return model.schema != "X" |
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
"""Example rules.""" | ||
|
||
from dbt_score import Model, RuleViolation, rule | ||
|
||
from tests.rules.rule_filters import skip_schemaX | ||
|
||
|
||
@rule(rule_filters={skip_schemaX()}) | ||
def rule_test_example(model: Model) -> RuleViolation | None: | ||
"""An example 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