Skip to content

Commit

Permalink
style(lint): auto prettifier
Browse files Browse the repository at this point in the history
  • Loading branch information
diorge committed Jul 30, 2024
1 parent 255acce commit 9841366
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 21 deletions.
25 changes: 11 additions & 14 deletions docs/create_rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,10 @@ from dbt_score import rule, Severity
@rule(severity=Severity.HIGH)
```

If a custom rule should be applied to only a subset of the models in the project,
a special value of type `SkipRule` can be returned.
Models that were skipped will be ignored in the final score.
More complex uses of skipping rules can use Model Filters (see below).

If a custom rule should be applied to only a subset of the models in the
project, a special value of type `SkipRule` can be returned. Models that were
skipped will be ignored in the final score. More complex uses of skipping rules
can use Model Filters (see below).

```python
from dbt_score import rule, Model, RuleViolation, SkipRule
Expand Down Expand Up @@ -111,14 +110,13 @@ def sql_has_reasonable_number_of_lines(model: Model, max_lines: int = 200) -> Ru

### Filtering models

Custom and standard rules can be configured to have model filters.
Filters allows setting models of the project to be ignored by a given rule.
Custom and standard rules can be configured to have model filters. Filters
allows setting models of the project to be ignored by a given rule.

Filters are created using the same discovery mechanism and interface as custom rules,
except they do not accept parameters.
Similar to Python's built-in `filter` function,
when the filter evaluation returns `True` the model should be evaluated,
otherwise it should be skipped.
Filters are created using the same discovery mechanism and interface as custom
rules, except they do not accept parameters. Similar to Python's built-in
`filter` function, when the filter evaluation returns `True` the model should be
evaluated, otherwise it should be skipped.

```python
from dbt_score import ModelFilter, model_filter
Expand All @@ -134,8 +132,7 @@ class SkipSchemaY(ModelFilter):
return model.schema.lower() != 'y'
```

Similar to setting a rule severity,
standard rules can have filters set in the
Similar to setting a rule severity, standard rules can have filters set in the
[configuration file](configuration.md/#tooldbt-scorerulesrule_namespacerule_name),
while custom rules accept the configuration file or a decorator parameter.

Expand Down
6 changes: 3 additions & 3 deletions src/dbt_score/rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@ def from_dict(rule_config: dict[str, Any]) -> "RuleConfig":
else []
)

return RuleConfig(severity=severity,
config=config,
model_filter_names=filter_names)
return RuleConfig(
severity=severity, config=config, model_filter_names=filter_names
)


@dataclass
Expand Down
7 changes: 3 additions & 4 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ def test_load_valid_toml_file(valid_config_path):
assert config.badge_config.first.icon == "1️⃣"
assert config.fail_project_under == 7.5
assert config.fail_any_model_under == 6.9
assert (
config.rules_config["tests.rules.example.rule_test_example"].model_filter_names
== ["tests.rules.example.skip_model1"]
)
assert config.rules_config[
"tests.rules.example.rule_test_example"
].model_filter_names == ["tests.rules.example.skip_model1"]


def test_load_invalid_toml_file(caplog, invalid_config_path):
Expand Down

0 comments on commit 9841366

Please sign in to comment.