diff --git a/src/dbt_score/dbt_utils.py b/src/dbt_score/dbt_utils.py index a916afd..525b3e4 100644 --- a/src/dbt_score/dbt_utils.py +++ b/src/dbt_score/dbt_utils.py @@ -1,10 +1,9 @@ """dbt utilities.""" import contextlib -import logging import os from pathlib import Path -from typing import Iterator +from typing import Iterable, Iterator, cast from dbt.cli.main import dbtRunner, dbtRunnerResult @@ -41,7 +40,7 @@ def dbt_parse() -> dbtRunnerResult: return result -def dbt_ls(select: list[str] | None) -> list[str]: +def dbt_ls(select: Iterable[str] | None) -> Iterable[str]: """Run dbt ls.""" cmd = ["ls", "--resource-type", "model", "--output", "name"] if select: @@ -53,7 +52,8 @@ def dbt_ls(select: list[str] | None) -> list[str]: if not result.success: raise DbtLsException("dbt ls failed") from result.exception - return result.result + selected = cast(Iterable[str], result.result) # mypy hint + return selected def get_default_manifest_path() -> Path: diff --git a/src/dbt_score/lint.py b/src/dbt_score/lint.py index 43fecbc..45c6ee5 100644 --- a/src/dbt_score/lint.py +++ b/src/dbt_score/lint.py @@ -1,7 +1,7 @@ """Lint dbt models metadata.""" from pathlib import Path -from typing import Literal +from typing import Iterable, Literal from dbt_score.config import Config from dbt_score.evaluation import Evaluation @@ -16,7 +16,7 @@ def lint_dbt_project( manifest_path: Path, config: Config, format: Literal["plain", "manifest"], - select: list[str] | None = None, + select: Iterable[str] | None = None, ) -> None: """Lint dbt manifest.""" if not manifest_path.exists(): diff --git a/src/dbt_score/models.py b/src/dbt_score/models.py index 760b048..3efb3fc 100644 --- a/src/dbt_score/models.py +++ b/src/dbt_score/models.py @@ -5,7 +5,7 @@ from collections import defaultdict from dataclasses import dataclass, field from pathlib import Path -from typing import Any +from typing import Any, Iterable from dbt_score.dbt_utils import dbt_ls @@ -260,7 +260,7 @@ def _reindex_tests(self) -> None: ): self.tests[attached_node].append(node_values) - def select_models(self, select: list[str]) -> None: + def select_models(self, select: Iterable[str]) -> None: """Filter models like dbt's --select.""" single_model_select = re.compile(r"[a-zA-Z0-9_]+")