Rule
Rule definitions.
Rule
The rule base class.
Source code in src/dbt_score/rule.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
|
__hash__()
__init__(rule_config=None)
__init_subclass__(**kwargs)
Initializes the subclass.
Source code in src/dbt_score/rule.py
evaluate(evaluable)
process_config(rule_config)
Process the rule config.
Source code in src/dbt_score/rule.py
set_filters(rule_filters)
classmethod
set_severity(severity)
classmethod
should_evaluate(evaluable)
classmethod
Checks whether the rule should be applied against the evaluable.
The evaluable must satisfy the following criteria
- all filters in the rule allow evaluation
- the rule and evaluable have matching resource_types
Source code in src/dbt_score/rule.py
RuleConfig
dataclass
Configuration for a rule.
Source code in src/dbt_score/rule.py
from_dict(rule_config)
staticmethod
Create a RuleConfig from a dictionary.
Source code in src/dbt_score/rule.py
RuleViolation
dataclass
Severity
rule(__func=None, *, description=None, severity=Severity.MEDIUM, rule_filters=None)
Rule decorator.
The rule decorator creates a rule class (subclass of Rule) and returns it.
Using arguments or not are both supported:
- @rule
- @rule(description="...")
Parameters:
Name | Type | Description | Default |
---|---|---|---|
__func
|
RuleEvaluationType | None
|
The rule evaluation function being decorated. |
None
|
description
|
str | None
|
The description of the rule. |
None
|
severity
|
Severity
|
The severity of the rule. |
MEDIUM
|
rule_filters
|
set[RuleFilter] | None
|
Set of RuleFilter that filters the items that the rule applies to. |
None
|