From fffb83e67193724a6e638325e807fa15cab7d941 Mon Sep 17 00:00:00 2001 From: Matthieu Caneill Date: Fri, 26 Apr 2024 17:18:15 +0200 Subject: [PATCH] Expose public objects in top-level dbt_score package (#13) This allows rule creators to use simpler imports: ```python from dbt_score import Model, RuleViolation, rule @rule def my_rule(model: Model) -> RuleViolation | None: ... ``` --- pyproject.toml | 2 +- src/dbt_score/__init__.py | 5 +++++ src/dbt_score/rules/generic.py | 5 +---- tests/conftest.py | 3 +-- tests/rules/example.py | 3 +-- tests/rules/nested/example.py | 5 ++--- tests/test_rule.py | 3 +-- 7 files changed, 12 insertions(+), 14 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index c910d2d..f78b704 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,13 +55,13 @@ dbt-score = {call = "dbt_score.cli:cli"} [tool.mypy] strict = true +warn_no_return = false [[tool.mypy.overrides]] module = "tests.*" disallow_untyped_defs = false disallow_incomplete_defs = false disallow_untyped_calls = false -warn_no_return = false ### Ruff ### diff --git a/src/dbt_score/__init__.py b/src/dbt_score/__init__.py index 9f987f3..134923a 100644 --- a/src/dbt_score/__init__.py +++ b/src/dbt_score/__init__.py @@ -1 +1,6 @@ """Init dbt_score package.""" + +from dbt_score.models import Model +from dbt_score.rule import Rule, RuleViolation, Severity, rule + +__all__ = ["Model", "Rule", "RuleViolation", "Severity", "rule"] diff --git a/src/dbt_score/rules/generic.py b/src/dbt_score/rules/generic.py index ab4c347..d73807a 100644 --- a/src/dbt_score/rules/generic.py +++ b/src/dbt_score/rules/generic.py @@ -1,9 +1,6 @@ """All generic rules.""" -from dbt_score.models import Model -from dbt_score.rule import RuleViolation, rule - -# mypy: disable-error-code="return" +from dbt_score import Model, RuleViolation, rule @rule diff --git a/tests/conftest.py b/tests/conftest.py index d596db5..4b49fdd 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -4,8 +4,7 @@ from pathlib import Path from typing import Any, Type -from dbt_score.models import Model -from dbt_score.rule import Rule, RuleViolation, Severity, rule +from dbt_score import Model, Rule, RuleViolation, Severity, rule from pytest import fixture # Manifest diff --git a/tests/rules/example.py b/tests/rules/example.py index e9a9068..cadfea2 100644 --- a/tests/rules/example.py +++ b/tests/rules/example.py @@ -1,7 +1,6 @@ """Example rules.""" -from dbt_score.models import Model -from dbt_score.rule import RuleViolation, rule +from dbt_score import Model, RuleViolation, rule @rule() diff --git a/tests/rules/nested/example.py b/tests/rules/nested/example.py index 4eccd8d..c0d9077 100644 --- a/tests/rules/nested/example.py +++ b/tests/rules/nested/example.py @@ -1,9 +1,8 @@ """Example rules.""" -from dbt_score.models import Model -from dbt_score.rule import RuleViolation, rule +from dbt_score import Model, RuleViolation, rule -@rule() +@rule def rule_test_nested_example(model: Model) -> RuleViolation | None: """An example rule.""" diff --git a/tests/test_rule.py b/tests/test_rule.py index 9819e75..1ed3077 100644 --- a/tests/test_rule.py +++ b/tests/test_rule.py @@ -1,8 +1,7 @@ """Test rule.""" import pytest -from dbt_score.models import Model -from dbt_score.rule import Rule, RuleViolation, Severity, rule +from dbt_score import Model, Rule, RuleViolation, Severity, rule def test_rule_decorator_and_class(