Skip to content

Commit 30ba383

Browse files
committed
Fix Typing
1 parent a61d7d1 commit 30ba383

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

src/dbt_score/rule.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
overload,
1515
)
1616

17-
from dbt_score.models import Evaluable, Exposure, Model, Seed, Snapshot, Source
17+
from dbt_score.models import Evaluable, Exposure, Macro, Model, Seed, Snapshot, Source
1818
from dbt_score.more_itertools import first_true
1919
from dbt_score.rule_filter import RuleFilter
2020

@@ -68,12 +68,14 @@ class RuleViolation:
6868
SnapshotRuleEvaluationType: TypeAlias = Callable[[Snapshot], RuleViolation | None]
6969
ExposureRuleEvaluationType: TypeAlias = Callable[[Exposure], RuleViolation | None]
7070
SeedRuleEvaluationType: TypeAlias = Callable[[Seed], RuleViolation | None]
71+
MacroRuleEvaluationType: TypeAlias = Callable[[Macro], RuleViolation | None]
7172
RuleEvaluationType: TypeAlias = (
7273
ModelRuleEvaluationType
7374
| SourceRuleEvaluationType
7475
| SnapshotRuleEvaluationType
7576
| ExposureRuleEvaluationType
7677
| SeedRuleEvaluationType
78+
| MacroRuleEvaluationType
7779
)
7880

7981

@@ -223,6 +225,11 @@ def rule(__func: SeedRuleEvaluationType) -> Type[Rule]:
223225
...
224226

225227

228+
@overload
229+
def rule(__func: MacroRuleEvaluationType) -> Type[Rule]:
230+
...
231+
232+
226233
@overload
227234
def rule(
228235
*,

src/dbt_score/rule_filter.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,22 @@
44
import typing
55
from typing import Any, Callable, Type, TypeAlias, cast, overload
66

7-
from dbt_score.models import Evaluable, Exposure, Model, Seed, Snapshot, Source
7+
from dbt_score.models import Evaluable, Exposure, Macro, Model, Seed, Snapshot, Source
88
from dbt_score.more_itertools import first_true
99

1010
ModelFilterEvaluationType: TypeAlias = Callable[[Model], bool]
1111
SourceFilterEvaluationType: TypeAlias = Callable[[Source], bool]
1212
SnapshotFilterEvaluationType: TypeAlias = Callable[[Snapshot], bool]
1313
ExposureFilterEvaluationType: TypeAlias = Callable[[Exposure], bool]
1414
SeedRuleEvaluationType: TypeAlias = Callable[[Seed], bool]
15+
MacroFilterEvaluationType: TypeAlias = Callable[[Macro], bool]
1516
FilterEvaluationType: TypeAlias = (
1617
ModelFilterEvaluationType
1718
| SourceFilterEvaluationType
1819
| SnapshotFilterEvaluationType
1920
| ExposureFilterEvaluationType
2021
| SeedRuleEvaluationType
22+
| MacroFilterEvaluationType
2123
)
2224

2325

@@ -101,6 +103,11 @@ def rule_filter(__func: SeedRuleEvaluationType) -> Type[RuleFilter]:
101103
...
102104

103105

106+
@overload
107+
def rule_filter(__func: MacroFilterEvaluationType) -> Type[RuleFilter]:
108+
...
109+
110+
104111
@overload
105112
def rule_filter(
106113
*,

tests/rules_library/test_macro_rules.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ def test_macro_arguments_have_description():
6161
)
6262
violation = rule.evaluate(macro_no_docs)
6363
assert violation is not None
64+
assert violation.message is not None
6465
assert "arg1" in violation.message
6566

6667

@@ -94,4 +95,5 @@ def test_macro_name_follows_naming_convention():
9495
)
9596
violation = rule.evaluate(macro_camel)
9697
assert violation is not None
98+
assert violation.message is not None
9799
assert "snake_case" in violation.message

0 commit comments

Comments
 (0)