diff --git a/.isort.cfg b/.isort.cfg new file mode 100644 index 00000000000..f0695fa70f5 --- /dev/null +++ b/.isort.cfg @@ -0,0 +1,4 @@ +[settings] +profile=black +extend_skip_glob=.github/*,third-party-stubs/*,scripts/* +known_first_party=dbt,dbt_adapters,dbt_common,dbt_extractor,dbt_semantic_interface diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 160c9cfd0f7..2ac0c53a38c 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,6 +19,10 @@ repos: exclude_types: - "markdown" - id: check-case-conflict +- repo: https://github.com/pycqa/isort + rev: 5.12.0 + hooks: + - id: isort - repo: https://github.com/psf/black rev: 22.3.0 hooks: diff --git a/core/dbt/artifacts/resources/__init__.py b/core/dbt/artifacts/resources/__init__.py index d937828e6d5..5d456dd6ef9 100644 --- a/core/dbt/artifacts/resources/__init__.py +++ b/core/dbt/artifacts/resources/__init__.py @@ -1,32 +1,29 @@ -from dbt.artifacts.resources.base import BaseResource, GraphResource, FileHash, Docs +from dbt.artifacts.resources.base import BaseResource, Docs, FileHash, GraphResource +from dbt.artifacts.resources.v1.analysis import Analysis # alias to latest resource definitions from dbt.artifacts.resources.v1.components import ( - DependsOn, - NodeVersion, - RefArgs, - HasRelationMetadata, - ParsedResourceMandatory, - ParsedResource, ColumnInfo, CompiledResource, - InjectedCTE, Contract, DeferRelation, + DependsOn, FreshnessThreshold, + HasRelationMetadata, + InjectedCTE, + NodeVersion, + ParsedResource, + ParsedResourceMandatory, Quoting, + RefArgs, Time, ) -from dbt.artifacts.resources.v1.analysis import Analysis -from dbt.artifacts.resources.v1.hook import HookNode -from dbt.artifacts.resources.v1.model import Model, ModelConfig -from dbt.artifacts.resources.v1.sql_operation import SqlOperation -from dbt.artifacts.resources.v1.seed import Seed, SeedConfig -from dbt.artifacts.resources.v1.singular_test import SingularTest -from dbt.artifacts.resources.v1.generic_test import GenericTest, TestMetadata -from dbt.artifacts.resources.v1.snapshot import Snapshot, SnapshotConfig - - +from dbt.artifacts.resources.v1.config import ( + Hook, + NodeAndTestConfig, + NodeConfig, + TestConfig, +) from dbt.artifacts.resources.v1.documentation import Documentation from dbt.artifacts.resources.v1.exposure import ( Exposure, @@ -34,8 +31,10 @@ ExposureType, MaturityType, ) -from dbt.artifacts.resources.v1.macro import Macro, MacroDependsOn, MacroArgument +from dbt.artifacts.resources.v1.generic_test import GenericTest, TestMetadata from dbt.artifacts.resources.v1.group import Group +from dbt.artifacts.resources.v1.hook import HookNode +from dbt.artifacts.resources.v1.macro import Macro, MacroArgument, MacroDependsOn from dbt.artifacts.resources.v1.metric import ( ConstantPropertyInput, ConversionTypeParams, @@ -46,6 +45,7 @@ MetricTimeWindow, MetricTypeParams, ) +from dbt.artifacts.resources.v1.model import Model, ModelConfig from dbt.artifacts.resources.v1.owner import Owner from dbt.artifacts.resources.v1.saved_query import ( Export, @@ -55,6 +55,7 @@ SavedQueryConfig, SavedQueryMandatory, ) +from dbt.artifacts.resources.v1.seed import Seed, SeedConfig from dbt.artifacts.resources.v1.semantic_layer_components import ( FileSlice, SourceFileMetadata, @@ -74,28 +75,22 @@ SemanticModel, SemanticModelConfig, ) - -from dbt.artifacts.resources.v1.config import ( - NodeAndTestConfig, - NodeConfig, - TestConfig, - Hook, -) - +from dbt.artifacts.resources.v1.singular_test import SingularTest +from dbt.artifacts.resources.v1.snapshot import Snapshot, SnapshotConfig from dbt.artifacts.resources.v1.source_definition import ( - SourceConfig, ExternalPartition, ExternalTable, - SourceDefinition, ParsedSourceMandatory, + SourceConfig, + SourceDefinition, ) - +from dbt.artifacts.resources.v1.sql_operation import SqlOperation from dbt.artifacts.resources.v1.unit_test_definition import ( UnitTestConfig, UnitTestDefinition, + UnitTestFormat, UnitTestInputFixture, + UnitTestNodeVersions, UnitTestOutputFixture, UnitTestOverrides, - UnitTestNodeVersions, - UnitTestFormat, ) diff --git a/core/dbt/artifacts/resources/base.py b/core/dbt/artifacts/resources/base.py index dd66aa97d72..0911a997c19 100644 --- a/core/dbt/artifacts/resources/base.py +++ b/core/dbt/artifacts/resources/base.py @@ -1,9 +1,9 @@ +import hashlib from dataclasses import dataclass -from dbt_common.dataclass_schema import dbtClassMixin from typing import List, Optional -import hashlib from dbt.artifacts.resources.types import NodeType +from dbt_common.dataclass_schema import dbtClassMixin @dataclass diff --git a/core/dbt/artifacts/resources/v1/analysis.py b/core/dbt/artifacts/resources/v1/analysis.py index 60f90e61576..325db979c61 100644 --- a/core/dbt/artifacts/resources/v1/analysis.py +++ b/core/dbt/artifacts/resources/v1/analysis.py @@ -1,7 +1,8 @@ -from dbt.artifacts.resources.v1.components import CompiledResource -from typing import Literal from dataclasses import dataclass +from typing import Literal + from dbt.artifacts.resources.types import NodeType +from dbt.artifacts.resources.v1.components import CompiledResource @dataclass diff --git a/core/dbt/artifacts/resources/v1/components.py b/core/dbt/artifacts/resources/v1/components.py index aca72c5d0f2..119e5fee1bb 100644 --- a/core/dbt/artifacts/resources/v1/components.py +++ b/core/dbt/artifacts/resources/v1/components.py @@ -1,16 +1,15 @@ import time from dataclasses import dataclass, field -from dbt.artifacts.resources.base import GraphResource, FileHash, Docs -from dbt.artifacts.resources.types import NodeType +from datetime import timedelta +from typing import Any, Dict, List, Optional, Union + +from dbt.artifacts.resources.base import Docs, FileHash, GraphResource +from dbt.artifacts.resources.types import NodeType, TimePeriod from dbt.artifacts.resources.v1.config import NodeConfig -from dbt_common.dataclass_schema import dbtClassMixin, ExtensibleDbtClassMixin from dbt_common.contracts.config.properties import AdditionalPropertiesMixin from dbt_common.contracts.constraints import ColumnLevelConstraint -from typing import Dict, List, Optional, Union, Any -from datetime import timedelta -from dbt.artifacts.resources.types import TimePeriod from dbt_common.contracts.util import Mergeable - +from dbt_common.dataclass_schema import ExtensibleDbtClassMixin, dbtClassMixin NodeVersion = Union[str, float] diff --git a/core/dbt/artifacts/resources/v1/config.py b/core/dbt/artifacts/resources/v1/config.py index 28b9879584c..fc9be8f7c70 100644 --- a/core/dbt/artifacts/resources/v1/config.py +++ b/core/dbt/artifacts/resources/v1/config.py @@ -1,21 +1,18 @@ import re +from dataclasses import dataclass, field +from typing import Any, Dict, List, Optional, Union -from dbt_common.dataclass_schema import dbtClassMixin, ValidationError -from typing import Optional, List, Any, Dict, Union +from mashumaro.jsonschema.annotations import Pattern from typing_extensions import Annotated -from dataclasses import dataclass, field -from dbt_common.contracts.config.base import ( - BaseConfig, - CompareBehavior, - MergeBehavior, -) -from dbt_common.contracts.config.metadata import Metadata, ShowBehavior -from dbt_common.contracts.config.materialization import OnConfigurationChangeOption + +from dbt import hooks from dbt.artifacts.resources.base import Docs from dbt.artifacts.resources.types import ModelHookType from dbt.artifacts.utils.validation import validate_color -from dbt import hooks -from mashumaro.jsonschema.annotations import Pattern +from dbt_common.contracts.config.base import BaseConfig, CompareBehavior, MergeBehavior +from dbt_common.contracts.config.materialization import OnConfigurationChangeOption +from dbt_common.contracts.config.metadata import Metadata, ShowBehavior +from dbt_common.dataclass_schema import ValidationError, dbtClassMixin def list_str() -> List[str]: diff --git a/core/dbt/artifacts/resources/v1/exposure.py b/core/dbt/artifacts/resources/v1/exposure.py index 1460c110d43..00f3c8b89e1 100644 --- a/core/dbt/artifacts/resources/v1/exposure.py +++ b/core/dbt/artifacts/resources/v1/exposure.py @@ -1,12 +1,13 @@ +import time from dataclasses import dataclass, field +from typing import Any, Dict, List, Literal, Optional + from dbt.artifacts.resources.base import GraphResource from dbt.artifacts.resources.types import NodeType from dbt.artifacts.resources.v1.components import DependsOn, RefArgs from dbt.artifacts.resources.v1.owner import Owner from dbt_common.contracts.config.base import BaseConfig from dbt_common.dataclass_schema import StrEnum -import time -from typing import Any, Dict, List, Literal, Optional class ExposureType(StrEnum): diff --git a/core/dbt/artifacts/resources/v1/generic_test.py b/core/dbt/artifacts/resources/v1/generic_test.py index b24be584b3a..504dbb07940 100644 --- a/core/dbt/artifacts/resources/v1/generic_test.py +++ b/core/dbt/artifacts/resources/v1/generic_test.py @@ -1,9 +1,10 @@ from dataclasses import dataclass, field -from typing import Optional, Any, Dict, Literal -from dbt_common.dataclass_schema import dbtClassMixin +from typing import Any, Dict, Literal, Optional + from dbt.artifacts.resources.types import NodeType -from dbt.artifacts.resources.v1.config import TestConfig from dbt.artifacts.resources.v1.components import CompiledResource +from dbt.artifacts.resources.v1.config import TestConfig +from dbt_common.dataclass_schema import dbtClassMixin @dataclass diff --git a/core/dbt/artifacts/resources/v1/hook.py b/core/dbt/artifacts/resources/v1/hook.py index dcfb4684c68..93fe314518e 100644 --- a/core/dbt/artifacts/resources/v1/hook.py +++ b/core/dbt/artifacts/resources/v1/hook.py @@ -1,7 +1,8 @@ from dataclasses import dataclass -from typing import Optional, Literal -from dbt.artifacts.resources.v1.components import CompiledResource +from typing import Literal, Optional + from dbt.artifacts.resources.types import NodeType +from dbt.artifacts.resources.v1.components import CompiledResource @dataclass diff --git a/core/dbt/artifacts/resources/v1/macro.py b/core/dbt/artifacts/resources/v1/macro.py index be02d529ee1..c5154a9a6d4 100644 --- a/core/dbt/artifacts/resources/v1/macro.py +++ b/core/dbt/artifacts/resources/v1/macro.py @@ -1,11 +1,11 @@ -from dataclasses import dataclass, field import time -from typing import Literal, List, Dict, Optional, Any +from dataclasses import dataclass, field +from typing import Any, Dict, List, Literal, Optional -from dbt_common.dataclass_schema import dbtClassMixin from dbt.artifacts.resources.base import BaseResource, Docs -from dbt.artifacts.resources.types import NodeType, ModelLanguage +from dbt.artifacts.resources.types import ModelLanguage, NodeType from dbt.artifacts.resources.v1.components import MacroDependsOn +from dbt_common.dataclass_schema import dbtClassMixin @dataclass diff --git a/core/dbt/artifacts/resources/v1/metric.py b/core/dbt/artifacts/resources/v1/metric.py index 84b484b5484..4f4dcfb98c9 100644 --- a/core/dbt/artifacts/resources/v1/metric.py +++ b/core/dbt/artifacts/resources/v1/metric.py @@ -1,6 +1,14 @@ import time - from dataclasses import dataclass, field +from typing import Any, Dict, List, Literal, Optional + +from dbt_semantic_interfaces.references import MeasureReference, MetricReference +from dbt_semantic_interfaces.type_enums import ( + ConversionCalculationType, + MetricType, + TimeGranularity, +) + from dbt.artifacts.resources.base import GraphResource from dbt.artifacts.resources.types import NodeType from dbt.artifacts.resources.v1.components import DependsOn, RefArgs @@ -10,14 +18,6 @@ ) from dbt_common.contracts.config.base import BaseConfig, CompareBehavior, MergeBehavior from dbt_common.dataclass_schema import dbtClassMixin -from dbt_semantic_interfaces.references import MeasureReference, MetricReference -from dbt_semantic_interfaces.type_enums import ( - ConversionCalculationType, - MetricType, - TimeGranularity, -) -from typing import Any, Dict, List, Literal, Optional - """ The following classes are dataclasses which are used to construct the Metric diff --git a/core/dbt/artifacts/resources/v1/model.py b/core/dbt/artifacts/resources/v1/model.py index afb5edaad54..f575f360aa3 100644 --- a/core/dbt/artifacts/resources/v1/model.py +++ b/core/dbt/artifacts/resources/v1/model.py @@ -1,11 +1,16 @@ from dataclasses import dataclass, field -from typing import Literal, Optional, List from datetime import datetime +from typing import List, Literal, Optional + +from dbt.artifacts.resources.types import AccessType, NodeType +from dbt.artifacts.resources.v1.components import ( + CompiledResource, + DeferRelation, + NodeVersion, +) +from dbt.artifacts.resources.v1.config import NodeConfig from dbt_common.contracts.config.base import MergeBehavior from dbt_common.contracts.constraints import ModelLevelConstraint -from dbt.artifacts.resources.v1.config import NodeConfig -from dbt.artifacts.resources.types import AccessType, NodeType -from dbt.artifacts.resources.v1.components import DeferRelation, NodeVersion, CompiledResource @dataclass diff --git a/core/dbt/artifacts/resources/v1/saved_query.py b/core/dbt/artifacts/resources/v1/saved_query.py index 5f0575d26a7..379ae940e10 100644 --- a/core/dbt/artifacts/resources/v1/saved_query.py +++ b/core/dbt/artifacts/resources/v1/saved_query.py @@ -1,7 +1,13 @@ from __future__ import annotations -import time +import time from dataclasses import dataclass, field +from typing import Any, Dict, List, Optional + +from dbt_semantic_interfaces.type_enums.export_destination_type import ( + ExportDestinationType, +) + from dbt.artifacts.resources.base import GraphResource from dbt.artifacts.resources.v1.components import DependsOn, RefArgs from dbt.artifacts.resources.v1.semantic_layer_components import ( @@ -10,8 +16,6 @@ ) from dbt_common.contracts.config.base import BaseConfig, CompareBehavior, MergeBehavior from dbt_common.dataclass_schema import dbtClassMixin -from dbt_semantic_interfaces.type_enums.export_destination_type import ExportDestinationType -from typing import Any, Dict, List, Optional @dataclass diff --git a/core/dbt/artifacts/resources/v1/seed.py b/core/dbt/artifacts/resources/v1/seed.py index 47a16352cf2..09d9233710f 100644 --- a/core/dbt/artifacts/resources/v1/seed.py +++ b/core/dbt/artifacts/resources/v1/seed.py @@ -1,9 +1,14 @@ from dataclasses import dataclass, field -from typing import Optional, Literal -from dbt_common.dataclass_schema import ValidationError +from typing import Literal, Optional + from dbt.artifacts.resources.types import NodeType -from dbt.artifacts.resources.v1.components import MacroDependsOn, DeferRelation, ParsedResource +from dbt.artifacts.resources.v1.components import ( + DeferRelation, + MacroDependsOn, + ParsedResource, +) from dbt.artifacts.resources.v1.config import NodeConfig +from dbt_common.dataclass_schema import ValidationError @dataclass diff --git a/core/dbt/artifacts/resources/v1/semantic_layer_components.py b/core/dbt/artifacts/resources/v1/semantic_layer_components.py index 540317d0889..2288ea3e6ca 100644 --- a/core/dbt/artifacts/resources/v1/semantic_layer_components.py +++ b/core/dbt/artifacts/resources/v1/semantic_layer_components.py @@ -1,9 +1,13 @@ from dataclasses import dataclass -from dbt_common.dataclass_schema import dbtClassMixin -from dbt_semantic_interfaces.call_parameter_sets import FilterCallParameterSets -from dbt_semantic_interfaces.parsing.where_filter.where_filter_parser import WhereFilterParser from typing import List, Sequence, Tuple +from dbt_semantic_interfaces.call_parameter_sets import FilterCallParameterSets +from dbt_semantic_interfaces.parsing.where_filter.where_filter_parser import ( + WhereFilterParser, +) + +from dbt_common.dataclass_schema import dbtClassMixin + @dataclass class WhereFilter(dbtClassMixin): diff --git a/core/dbt/artifacts/resources/v1/semantic_model.py b/core/dbt/artifacts/resources/v1/semantic_model.py index 8a02aa5fa61..6abe48bb3da 100644 --- a/core/dbt/artifacts/resources/v1/semantic_model.py +++ b/core/dbt/artifacts/resources/v1/semantic_model.py @@ -1,10 +1,7 @@ import time - from dataclasses import dataclass, field -from dbt.artifacts.resources.base import GraphResource -from dbt.artifacts.resources.v1.components import DependsOn, RefArgs -from dbt_common.contracts.config.base import BaseConfig, CompareBehavior, MergeBehavior -from dbt_common.dataclass_schema import dbtClassMixin +from typing import Any, Dict, List, Optional, Sequence + from dbt_semantic_interfaces.references import ( DimensionReference, EntityReference, @@ -19,9 +16,12 @@ EntityType, TimeGranularity, ) -from dbt.artifacts.resources import SourceFileMetadata -from typing import Any, Dict, List, Optional, Sequence +from dbt.artifacts.resources import SourceFileMetadata +from dbt.artifacts.resources.base import GraphResource +from dbt.artifacts.resources.v1.components import DependsOn, RefArgs +from dbt_common.contracts.config.base import BaseConfig, CompareBehavior, MergeBehavior +from dbt_common.dataclass_schema import dbtClassMixin """ The classes in this file are dataclasses which are used to construct the Semantic diff --git a/core/dbt/artifacts/resources/v1/singular_test.py b/core/dbt/artifacts/resources/v1/singular_test.py index 76b47183c51..3b025d79e11 100644 --- a/core/dbt/artifacts/resources/v1/singular_test.py +++ b/core/dbt/artifacts/resources/v1/singular_test.py @@ -1,5 +1,6 @@ from dataclasses import dataclass, field from typing import Literal + from dbt.artifacts.resources.types import NodeType from dbt.artifacts.resources.v1.components import CompiledResource from dbt.artifacts.resources.v1.config import TestConfig diff --git a/core/dbt/artifacts/resources/v1/snapshot.py b/core/dbt/artifacts/resources/v1/snapshot.py index 3eceb9bb1d2..c20911ad3af 100644 --- a/core/dbt/artifacts/resources/v1/snapshot.py +++ b/core/dbt/artifacts/resources/v1/snapshot.py @@ -1,9 +1,10 @@ -from typing import Union, List, Optional, Literal from dataclasses import dataclass -from dbt_common.dataclass_schema import ValidationError +from typing import List, Literal, Optional, Union + from dbt.artifacts.resources.types import NodeType from dbt.artifacts.resources.v1.components import CompiledResource, DeferRelation from dbt.artifacts.resources.v1.config import NodeConfig +from dbt_common.dataclass_schema import ValidationError @dataclass diff --git a/core/dbt/artifacts/resources/v1/source_definition.py b/core/dbt/artifacts/resources/v1/source_definition.py index e5a9ab1d98e..ac0fcfca1b2 100644 --- a/core/dbt/artifacts/resources/v1/source_definition.py +++ b/core/dbt/artifacts/resources/v1/source_definition.py @@ -1,6 +1,7 @@ import time - from dataclasses import dataclass, field +from typing import Any, Dict, List, Literal, Optional, Union + from dbt.artifacts.resources.base import GraphResource from dbt.artifacts.resources.types import NodeType from dbt.artifacts.resources.v1.components import ( @@ -13,7 +14,6 @@ from dbt_common.contracts.config.properties import AdditionalPropertiesAllowed from dbt_common.contracts.util import Mergeable from dbt_common.exceptions import CompilationError -from typing import Any, Dict, List, Literal, Optional, Union @dataclass diff --git a/core/dbt/artifacts/resources/v1/sql_operation.py b/core/dbt/artifacts/resources/v1/sql_operation.py index fd8e79b21a1..f669471f1dd 100644 --- a/core/dbt/artifacts/resources/v1/sql_operation.py +++ b/core/dbt/artifacts/resources/v1/sql_operation.py @@ -1,5 +1,6 @@ from dataclasses import dataclass from typing import Literal + from dbt.artifacts.resources.types import NodeType from dbt.artifacts.resources.v1.components import CompiledResource diff --git a/core/dbt/artifacts/resources/v1/unit_test_definition.py b/core/dbt/artifacts/resources/v1/unit_test_definition.py index fc265fa36b9..5c18538a733 100644 --- a/core/dbt/artifacts/resources/v1/unit_test_definition.py +++ b/core/dbt/artifacts/resources/v1/unit_test_definition.py @@ -1,18 +1,13 @@ -from dataclasses import dataclass, field import time -from typing import Optional, Sequence, Dict, Any, List, Union - -from dbt_common.contracts.config.base import ( - BaseConfig, - CompareBehavior, - MergeBehavior, -) -from dbt_common.contracts.config.metadata import ShowBehavior -from dbt_common.dataclass_schema import dbtClassMixin, StrEnum +from dataclasses import dataclass, field +from typing import Any, Dict, List, Optional, Sequence, Union -from dbt.artifacts.resources.v1.config import metas, list_str +from dbt.artifacts.resources import DependsOn, NodeVersion from dbt.artifacts.resources.base import GraphResource -from dbt.artifacts.resources import NodeVersion, DependsOn +from dbt.artifacts.resources.v1.config import list_str, metas +from dbt_common.contracts.config.base import BaseConfig, CompareBehavior, MergeBehavior +from dbt_common.contracts.config.metadata import ShowBehavior +from dbt_common.dataclass_schema import StrEnum, dbtClassMixin @dataclass diff --git a/core/dbt/artifacts/schemas/base.py b/core/dbt/artifacts/schemas/base.py index d7c206a218e..2ee9f09eb5e 100644 --- a/core/dbt/artifacts/schemas/base.py +++ b/core/dbt/artifacts/schemas/base.py @@ -1,19 +1,18 @@ import dataclasses -from datetime import datetime import functools +from datetime import datetime +from typing import Any, ClassVar, Dict, Optional, Type, TypeVar + from mashumaro.jsonschema import build_json_schema from mashumaro.jsonschema.dialects import DRAFT_2020_12 -from typing import ClassVar, Type, TypeVar, Dict, Any, Optional -from dbt_common.clients.system import write_json, read_json -from dbt_common.exceptions import DbtInternalError, DbtRuntimeError +from dbt.artifacts.exceptions import IncompatibleSchemaError +from dbt.version import __version__ +from dbt_common.clients.system import read_json, write_json +from dbt_common.dataclass_schema import dbtClassMixin from dbt_common.events.functions import get_metadata_vars +from dbt_common.exceptions import DbtInternalError, DbtRuntimeError from dbt_common.invocation import get_invocation_id -from dbt_common.dataclass_schema import dbtClassMixin - -from dbt.version import __version__ -from dbt.artifacts.exceptions import IncompatibleSchemaError - BASE_SCHEMAS_URL = "https://schemas.getdbt.com/" SCHEMA_PATH = "dbt/{name}/v{version}.json" diff --git a/core/dbt/artifacts/schemas/catalog/v1/catalog.py b/core/dbt/artifacts/schemas/catalog/v1/catalog.py index bd6571152be..d1c692e7573 100644 --- a/core/dbt/artifacts/schemas/catalog/v1/catalog.py +++ b/core/dbt/artifacts/schemas/catalog/v1/catalog.py @@ -1,10 +1,14 @@ -from typing import Dict, Union, Optional, NamedTuple, Any, List from dataclasses import dataclass, field from datetime import datetime +from typing import Any, Dict, List, NamedTuple, Optional, Union +from dbt.artifacts.schemas.base import ( + ArtifactMixin, + BaseArtifactMetadata, + schema_version, +) from dbt_common.dataclass_schema import dbtClassMixin from dbt_common.utils.formatting import lowercase -from dbt.artifacts.schemas.base import ArtifactMixin, BaseArtifactMetadata, schema_version Primitive = Union[bool, str, float, None] PrimitiveDict = Dict[str, Primitive] diff --git a/core/dbt/artifacts/schemas/freshness/v3/freshness.py b/core/dbt/artifacts/schemas/freshness/v3/freshness.py index a9b956d2863..fe489994268 100644 --- a/core/dbt/artifacts/schemas/freshness/v3/freshness.py +++ b/core/dbt/artifacts/schemas/freshness/v3/freshness.py @@ -1,19 +1,23 @@ from dataclasses import dataclass, field -from typing import Dict, Any, Sequence, List, Union, Optional from datetime import datetime +from typing import Any, Dict, List, Optional, Sequence, Union from dbt.artifacts.resources import FreshnessThreshold -from dbt.artifacts.schemas.results import ExecutionResult, FreshnessStatus, NodeResult, TimingInfo from dbt.artifacts.schemas.base import ( ArtifactMixin, + BaseArtifactMetadata, VersionedSchema, schema_version, - BaseArtifactMetadata, ) -from dbt_common.dataclass_schema import dbtClassMixin, StrEnum -from dbt_common.exceptions import DbtInternalError - +from dbt.artifacts.schemas.results import ( + ExecutionResult, + FreshnessStatus, + NodeResult, + TimingInfo, +) from dbt.contracts.graph.nodes import SourceDefinition +from dbt_common.dataclass_schema import StrEnum, dbtClassMixin +from dbt_common.exceptions import DbtInternalError @dataclass diff --git a/core/dbt/artifacts/schemas/manifest/v12/manifest.py b/core/dbt/artifacts/schemas/manifest/v12/manifest.py index 2ac3f3d761c..4a4314ceab9 100644 --- a/core/dbt/artifacts/schemas/manifest/v12/manifest.py +++ b/core/dbt/artifacts/schemas/manifest/v12/manifest.py @@ -1,34 +1,33 @@ from dataclasses import dataclass, field -from typing import Mapping, Iterable, Tuple, Optional, Dict, List, Any, Union +from typing import Any, Dict, Iterable, List, Mapping, Optional, Tuple, Union from uuid import UUID -from dbt.artifacts.schemas.base import ( - BaseArtifactMetadata, - ArtifactMixin, - schema_version, - get_artifact_schema_version, -) -from dbt.artifacts.schemas.upgrades import upgrade_manifest_json from dbt.artifacts.resources import ( + Analysis, Documentation, Exposure, + GenericTest, Group, + HookNode, Macro, Metric, + Model, SavedQuery, - SemanticModel, - SourceDefinition, - UnitTestDefinition, Seed, - Analysis, + SemanticModel, SingularTest, - HookNode, - Model, - SqlOperation, - GenericTest, Snapshot, + SourceDefinition, + SqlOperation, + UnitTestDefinition, ) - +from dbt.artifacts.schemas.base import ( + ArtifactMixin, + BaseArtifactMetadata, + get_artifact_schema_version, + schema_version, +) +from dbt.artifacts.schemas.upgrades import upgrade_manifest_json NodeEdgeMap = Dict[str, List[str]] UniqueID = str diff --git a/core/dbt/artifacts/schemas/results.py b/core/dbt/artifacts/schemas/results.py index 5b36d7fe6fb..f3f830ca927 100644 --- a/core/dbt/artifacts/schemas/results.py +++ b/core/dbt/artifacts/schemas/results.py @@ -1,12 +1,12 @@ -from dbt.contracts.graph.nodes import ResultNode -from dbt_common.events.helpers import datetime_to_json_string -from dbt_common.utils import cast_to_str, cast_to_int -from dbt_common.dataclass_schema import dbtClassMixin, StrEnum - from dataclasses import dataclass from datetime import datetime from typing import Any, Callable, Dict, List, Optional, Sequence, Union +from dbt.contracts.graph.nodes import ResultNode +from dbt_common.dataclass_schema import StrEnum, dbtClassMixin +from dbt_common.events.helpers import datetime_to_json_string +from dbt_common.utils import cast_to_int, cast_to_str + @dataclass class TimingInfo(dbtClassMixin): diff --git a/core/dbt/artifacts/schemas/run/v5/run.py b/core/dbt/artifacts/schemas/run/v5/run.py index d3e6bfa4ece..d4adf100388 100644 --- a/core/dbt/artifacts/schemas/run/v5/run.py +++ b/core/dbt/artifacts/schemas/run/v5/run.py @@ -1,28 +1,26 @@ -import threading -from typing import Any, Optional, Iterable, Tuple, Sequence, Dict, TYPE_CHECKING import copy +import threading from dataclasses import dataclass, field from datetime import datetime +from typing import TYPE_CHECKING, Any, Dict, Iterable, Optional, Sequence, Tuple - -from dbt_common.constants import SECRET_ENV_PREFIX from dbt.artifacts.resources import CompiledResource from dbt.artifacts.schemas.base import ( - BaseArtifactMetadata, ArtifactMixin, - schema_version, + BaseArtifactMetadata, get_artifact_schema_version, + schema_version, ) from dbt.artifacts.schemas.results import ( BaseResult, + ExecutionResult, NodeResult, - RunStatus, ResultNode, - ExecutionResult, + RunStatus, ) -from dbt_common.clients.system import write_json from dbt.exceptions import scrub_secrets - +from dbt_common.clients.system import write_json +from dbt_common.constants import SECRET_ENV_PREFIX if TYPE_CHECKING: import agate diff --git a/core/dbt/cli/context.py b/core/dbt/cli/context.py index b8f541b9ad8..f0be810e1e4 100644 --- a/core/dbt/cli/context.py +++ b/core/dbt/cli/context.py @@ -1,6 +1,7 @@ -import click from typing import Optional +import click + from dbt.cli.main import cli as dbt diff --git a/core/dbt/cli/exceptions.py b/core/dbt/cli/exceptions.py index d88f91c01ac..54479c30900 100644 --- a/core/dbt/cli/exceptions.py +++ b/core/dbt/cli/exceptions.py @@ -1,6 +1,7 @@ -from typing import Optional, IO +from typing import IO, Optional from click.exceptions import ClickException + from dbt.utils import ExitCodes diff --git a/core/dbt/cli/flags.py b/core/dbt/cli/flags.py index 9d49d339543..d3cfd707cbb 100644 --- a/core/dbt/cli/flags.py +++ b/core/dbt/cli/flags.py @@ -6,20 +6,22 @@ from pprint import pformat as pf from typing import Any, Callable, Dict, List, Optional, Set, Union -from click import Context, get_current_context, Parameter -from click.core import Command as ClickCommand, Group, ParameterSource +from click import Context, Parameter, get_current_context +from click.core import Command as ClickCommand +from click.core import Group, ParameterSource + from dbt.cli.exceptions import DbtUsageException from dbt.cli.resolvers import default_log_path, default_project_dir from dbt.cli.types import Command as CliCommand from dbt.config.project import read_project_flags from dbt.contracts.project import ProjectFlags +from dbt.deprecations import renamed_env_var +from dbt.events import ALL_EVENT_NAMES from dbt_common import ui +from dbt_common.clients import jinja from dbt_common.events import functions from dbt_common.exceptions import DbtInternalError -from dbt_common.clients import jinja -from dbt.deprecations import renamed_env_var from dbt_common.helper_types import WarnErrorOptions -from dbt.events import ALL_EVENT_NAMES if os.name != "nt": # https://bugs.python.org/issue41567 diff --git a/core/dbt/cli/main.py b/core/dbt/cli/main.py index 35a01700acd..387fbc09359 100644 --- a/core/dbt/cli/main.py +++ b/core/dbt/cli/main.py @@ -4,21 +4,16 @@ from typing import Callable, List, Optional, Union import click -from click.exceptions import ( - Exit as ClickExit, - BadOptionUsage, - NoSuchOption, - UsageError, -) +from click.exceptions import BadOptionUsage +from click.exceptions import Exit as ClickExit +from click.exceptions import NoSuchOption, UsageError -from dbt.cli import requires, params as p -from dbt.cli.exceptions import ( - DbtInternalException, - DbtUsageException, -) -from dbt.contracts.graph.manifest import Manifest from dbt.artifacts.schemas.catalog import CatalogArtifact from dbt.artifacts.schemas.run import RunExecutionResult +from dbt.cli import params as p +from dbt.cli import requires +from dbt.cli.exceptions import DbtInternalException, DbtUsageException +from dbt.contracts.graph.manifest import Manifest from dbt_common.events.base_types import EventMsg diff --git a/core/dbt/cli/option_types.py b/core/dbt/cli/option_types.py index 544b09bee2a..6c94116eb67 100644 --- a/core/dbt/cli/option_types.py +++ b/core/dbt/cli/option_types.py @@ -1,8 +1,8 @@ -from click import ParamType, Choice +from click import Choice, ParamType -from dbt.config.utils import parse_cli_yaml_string, exclusive_primary_alt_value_setting +from dbt.config.utils import exclusive_primary_alt_value_setting, parse_cli_yaml_string from dbt.events import ALL_EVENT_NAMES -from dbt.exceptions import ValidationError, OptionNotYamlDictError +from dbt.exceptions import OptionNotYamlDictError, ValidationError from dbt_common.exceptions import DbtValidationError from dbt_common.helper_types import WarnErrorOptions diff --git a/core/dbt/cli/options.py b/core/dbt/cli/options.py index bf0749ae002..c73a4bcd374 100644 --- a/core/dbt/cli/options.py +++ b/core/dbt/cli/options.py @@ -1,8 +1,10 @@ -import click import inspect import typing as t + +import click from click import Context from click.parser import OptionParser, ParsingState + from dbt.cli.option_types import ChoiceTuple diff --git a/core/dbt/cli/params.py b/core/dbt/cli/params.py index b2716728ce6..701bc95a19d 100644 --- a/core/dbt/cli/params.py +++ b/core/dbt/cli/params.py @@ -1,9 +1,10 @@ from pathlib import Path import click + +from dbt.cli.option_types import YAML, ChoiceTuple, Package, WarnErrorOptionsType from dbt.cli.options import MultiOption -from dbt.cli.option_types import YAML, ChoiceTuple, WarnErrorOptionsType, Package -from dbt.cli.resolvers import default_project_dir, default_profiles_dir +from dbt.cli.resolvers import default_profiles_dir, default_project_dir from dbt.version import get_version_information add_package = click.option( diff --git a/core/dbt/cli/requires.py b/core/dbt/cli/requires.py index f92436b6a5e..0104515d601 100644 --- a/core/dbt/cli/requires.py +++ b/core/dbt/cli/requires.py @@ -1,52 +1,47 @@ +import importlib.util import os +import time +import traceback +from functools import update_wrapper +from typing import Optional -from dbt_common.context import get_invocation_context, set_invocation_context -from dbt_common.record import Recorder, RecorderMode, get_record_mode_from_env -from dbt_common.clients.system import get_env -from dbt_common.invocation import reset_invocation_id +from click import Context import dbt.tracking -from dbt.version import installed as installed_version -from dbt.adapters.factory import adapter_management, register_adapter, get_adapter -from dbt.context.providers import generate_runtime_macro_context -from dbt.flags import set_flags, get_flag_dict -from dbt.cli.exceptions import ( - ExceptionExit, - ResultExit, -) +from dbt.adapters.factory import adapter_management, get_adapter, register_adapter +from dbt.cli.exceptions import ExceptionExit, ResultExit from dbt.cli.flags import Flags from dbt.config import RuntimeConfig -from dbt.config.runtime import load_project, load_profile, UnsetProfile +from dbt.config.runtime import UnsetProfile, load_profile, load_project +from dbt.context.providers import generate_runtime_macro_context from dbt.context.query_header import generate_query_header_context - -from dbt_common.events.base_types import EventLevel -from dbt_common.events.functions import ( - fire_event, - LOG_VERSION, -) from dbt.events.logging import setup_event_logger from dbt.events.types import ( - MainReportVersion, + CommandCompleted, + MainEncounteredError, MainReportArgs, + MainReportVersion, + MainStackTrace, MainTrackingUserState, + ResourceReport, ) -from dbt_common.events.helpers import get_json_string_utcnow -from dbt.events.types import CommandCompleted, MainEncounteredError, MainStackTrace, ResourceReport -from dbt_common.exceptions import DbtBaseException as DbtException from dbt.exceptions import DbtProjectError, FailFastError +from dbt.flags import get_flag_dict, set_flags +from dbt.mp_context import get_mp_context from dbt.parser.manifest import parse_manifest +from dbt.plugins import set_up_plugin_manager from dbt.profiler import profiler from dbt.tracking import active_user, initialize_from_flags, track_run +from dbt.version import installed as installed_version +from dbt_common.clients.system import get_env +from dbt_common.context import get_invocation_context, set_invocation_context +from dbt_common.events.base_types import EventLevel +from dbt_common.events.functions import LOG_VERSION, fire_event +from dbt_common.events.helpers import get_json_string_utcnow +from dbt_common.exceptions import DbtBaseException as DbtException +from dbt_common.invocation import reset_invocation_id +from dbt_common.record import Recorder, RecorderMode, get_record_mode_from_env from dbt_common.utils import cast_dict_to_dict_of_strings -from dbt.plugins import set_up_plugin_manager -from dbt.mp_context import get_mp_context - -from click import Context -from functools import update_wrapper -import importlib.util -import time -import traceback -from typing import Optional def preflight(func): diff --git a/core/dbt/cli/resolvers.py b/core/dbt/cli/resolvers.py index 48ba92c365a..6d495501c39 100644 --- a/core/dbt/cli/resolvers.py +++ b/core/dbt/cli/resolvers.py @@ -1,4 +1,5 @@ from pathlib import Path + from dbt.config.project import PartialProject from dbt.exceptions import DbtProjectError diff --git a/core/dbt/clients/git.py b/core/dbt/clients/git.py index 4da1c323327..33beb93a6ba 100644 --- a/core/dbt/clients/git.py +++ b/core/dbt/clients/git.py @@ -1,25 +1,26 @@ -import re import os.path +import re + +from packaging import version -from dbt_common.clients.system import run_cmd, rmdir -from dbt_common.events.functions import fire_event from dbt.events.types import ( - GitSparseCheckoutSubdirectory, + GitNothingToDo, + GitProgressCheckedOutAt, GitProgressCheckoutRevision, - GitProgressUpdatingExistingDependency, GitProgressPullingNewDependency, - GitNothingToDo, GitProgressUpdatedCheckoutRange, - GitProgressCheckedOutAt, + GitProgressUpdatingExistingDependency, + GitSparseCheckoutSubdirectory, ) from dbt.exceptions import ( CommandResultError, + DbtRuntimeError, GitCheckoutError, GitCloningError, UnknownGitCloningProblemError, - DbtRuntimeError, ) -from packaging import version +from dbt_common.clients.system import rmdir, run_cmd +from dbt_common.events.functions import fire_event def _is_commit(revision: str) -> bool: diff --git a/core/dbt/clients/jinja.py b/core/dbt/clients/jinja.py index 514bbcc342f..4aa6f013916 100644 --- a/core/dbt/clients/jinja.py +++ b/core/dbt/clients/jinja.py @@ -1,7 +1,7 @@ import re import threading from contextlib import contextmanager -from typing import List, Union, Optional, Dict, Any, NoReturn, Tuple +from typing import Any, Dict, List, NoReturn, Optional, Tuple, Union import jinja2 import jinja2.ext @@ -10,22 +10,20 @@ import jinja2.parser import jinja2.sandbox -from dbt_common.clients.jinja import ( - render_template, - get_template, - CallableMacroGenerator, - MacroProtocol, -) -from dbt_common.utils import deep_map_render from dbt.contracts.graph.nodes import GenericTestNode - from dbt.exceptions import ( DbtInternalError, MaterializtionMacroNotUsedError, NoSupportedLanguagesFoundError, ) from dbt.node_types import ModelLanguage - +from dbt_common.clients.jinja import ( + CallableMacroGenerator, + MacroProtocol, + get_template, + render_template, +) +from dbt_common.utils import deep_map_render SUPPORTED_LANG_ARG = jinja2.nodes.Name("supported_languages", "param") diff --git a/core/dbt/clients/jinja_static.py b/core/dbt/clients/jinja_static.py index aa9c72d7d79..8e0c34df2e6 100644 --- a/core/dbt/clients/jinja_static.py +++ b/core/dbt/clients/jinja_static.py @@ -1,11 +1,11 @@ from typing import Any, Dict, Optional import jinja2 -from dbt_common.clients.jinja import get_environment -from dbt_common.tests import test_caching_enabled + from dbt.exceptions import MacroNamespaceNotStringError +from dbt_common.clients.jinja import get_environment from dbt_common.exceptions.macros import MacroNameNotStringError - +from dbt_common.tests import test_caching_enabled _TESTING_MACRO_CACHE: Optional[Dict[str, Any]] = {} diff --git a/core/dbt/clients/registry.py b/core/dbt/clients/registry.py index 3a160c7f791..ed634e9f811 100644 --- a/core/dbt/clients/registry.py +++ b/core/dbt/clients/registry.py @@ -1,22 +1,24 @@ import functools +import os from typing import Any, Dict, List + import requests -from dbt_common.events.functions import fire_event + +from dbt import deprecations from dbt.events.types import ( - RegistryProgressGETRequest, - RegistryProgressGETResponse, RegistryIndexProgressGETRequest, RegistryIndexProgressGETResponse, - RegistryResponseUnexpectedType, - RegistryResponseMissingTopKeys, - RegistryResponseMissingNestedKeys, + RegistryProgressGETRequest, + RegistryProgressGETResponse, RegistryResponseExtraNestedKeys, + RegistryResponseMissingNestedKeys, + RegistryResponseMissingTopKeys, + RegistryResponseUnexpectedType, ) from dbt.utils import memoized -from dbt_common.utils.connection import connection_exception_retry -from dbt import deprecations from dbt_common import semver -import os +from dbt_common.events.functions import fire_event +from dbt_common.utils.connection import connection_exception_retry if os.getenv("DBT_PACKAGE_HUB_URL"): DEFAULT_REGISTRY_BASE_URL = os.getenv("DBT_PACKAGE_HUB_URL") diff --git a/core/dbt/clients/yaml_helper.py b/core/dbt/clients/yaml_helper.py index 95f65e397ae..a0a51099331 100644 --- a/core/dbt/clients/yaml_helper.py +++ b/core/dbt/clients/yaml_helper.py @@ -1,13 +1,17 @@ -import dbt_common.exceptions.base -import dbt_common.exceptions from typing import Any, Dict, Optional + import yaml +import dbt_common.exceptions +import dbt_common.exceptions.base + # the C version is faster, but it doesn't always exist try: - from yaml import CLoader as Loader, CSafeLoader as SafeLoader, CDumper as Dumper + from yaml import CDumper as Dumper + from yaml import CLoader as Loader + from yaml import CSafeLoader as SafeLoader except ImportError: - from yaml import Loader, SafeLoader, Dumper # type: ignore # noqa: F401 + from yaml import Dumper, Loader, SafeLoader # type: ignore # noqa: F401 YAML_ERROR_MESSAGE = """ diff --git a/core/dbt/compilation.py b/core/dbt/compilation.py index 09695fc59d7..d03407b2a4c 100644 --- a/core/dbt/compilation.py +++ b/core/dbt/compilation.py @@ -1,46 +1,45 @@ import json - -import networkx as nx # type: ignore import os import pickle - from collections import defaultdict -from typing import List, Dict, Any, Tuple, Optional +from typing import Any, Dict, List, Optional, Tuple -from dbt_common.invocation import get_invocation_id -from dbt.flags import get_flags +import networkx as nx # type: ignore +import sqlparse + +import dbt.tracking from dbt.adapters.factory import get_adapter from dbt.clients import jinja from dbt.context.providers import ( generate_runtime_model_context, generate_runtime_unit_test_context, ) -from dbt_common.clients.system import make_directory from dbt.contracts.graph.manifest import Manifest, UniqueID from dbt.contracts.graph.nodes import ( - ManifestNode, - ManifestSQLNode, GenericTestNode, GraphMemberNode, InjectedCTE, + ManifestNode, + ManifestSQLNode, SeedNode, - UnitTestNode, UnitTestDefinition, + UnitTestNode, ) +from dbt.events.types import FoundStats, WritingInjectedSQLForNode from dbt.exceptions import ( - GraphDependencyNotFoundError, DbtInternalError, DbtRuntimeError, + GraphDependencyNotFoundError, ) +from dbt.flags import get_flags from dbt.graph import Graph -from dbt_common.events.functions import fire_event -from dbt_common.events.types import Note +from dbt.node_types import ModelLanguage, NodeType +from dbt_common.clients.system import make_directory from dbt_common.events.contextvars import get_node_info -from dbt.events.types import WritingInjectedSQLForNode, FoundStats -from dbt.node_types import NodeType, ModelLanguage from dbt_common.events.format import pluralize -import dbt.tracking -import sqlparse +from dbt_common.events.functions import fire_event +from dbt_common.events.types import Note +from dbt_common.invocation import get_invocation_id graph_file_name = "graph.gpickle" diff --git a/core/dbt/config/__init__.py b/core/dbt/config/__init__.py index 767901c84eb..1f3875422c9 100644 --- a/core/dbt/config/__init__.py +++ b/core/dbt/config/__init__.py @@ -1,4 +1,4 @@ # all these are just exports, they need "noqa" so flake8 will not complain. from .profile import Profile # noqa -from .project import Project, IsFQNResource, PartialProject # noqa +from .project import IsFQNResource, PartialProject, Project # noqa from .runtime import RuntimeConfig # noqa diff --git a/core/dbt/config/profile.py b/core/dbt/config/profile.py index 2b7ad51b562..ada7f30711c 100644 --- a/core/dbt/config/profile.py +++ b/core/dbt/config/profile.py @@ -1,14 +1,10 @@ +import os from dataclasses import dataclass from typing import Any, Dict, Optional, Tuple -import os - -from dbt_common.dataclass_schema import ValidationError -from dbt.flags import get_flags -from dbt_common.clients.system import load_file_contents +from dbt.adapters.contracts.connection import Credentials, HasCredentials from dbt.clients.yaml_helper import load_yaml_text from dbt.contracts.project import ProfileConfig -from dbt.adapters.contracts.connection import Credentials, HasCredentials from dbt.events.types import MissingProfileTarget from dbt.exceptions import ( CompilationError, @@ -17,8 +13,11 @@ DbtRuntimeError, ProfileConfigError, ) -from dbt_common.exceptions import DbtValidationError +from dbt.flags import get_flags +from dbt_common.clients.system import load_file_contents +from dbt_common.dataclass_schema import ValidationError from dbt_common.events.functions import fire_event +from dbt_common.exceptions import DbtValidationError from .renderer import ProfileRenderer diff --git a/core/dbt/config/project.py b/core/dbt/config/project.py index 52b20e5179d..7f396477fd6 100644 --- a/core/dbt/config/project.py +++ b/core/dbt/config/project.py @@ -1,61 +1,50 @@ +import os from copy import deepcopy from dataclasses import dataclass, field from itertools import chain -from typing import ( - List, - Dict, - Any, - Optional, - TypeVar, - Union, - Mapping, -) -from typing_extensions import Protocol, runtime_checkable +from typing import Any, Dict, List, Mapping, Optional, TypeVar, Union -import os +from typing_extensions import Protocol, runtime_checkable -from dbt.flags import get_flags from dbt import deprecations +from dbt.adapters.contracts.connection import QueryComment +from dbt.clients.yaml_helper import load_yaml_text +from dbt.config.selectors import SelectorDict +from dbt.config.utils import exclusive_primary_alt_value_setting from dbt.constants import ( + DBT_PROJECT_FILE_NAME, DEPENDENCIES_FILE_NAME, - PACKAGES_FILE_NAME, PACKAGE_LOCK_HASH_KEY, - DBT_PROJECT_FILE_NAME, + PACKAGES_FILE_NAME, ) -from dbt_common.clients.system import path_exists, load_file_contents -from dbt.clients.yaml_helper import load_yaml_text -from dbt.adapters.contracts.connection import QueryComment +from dbt.contracts.project import PackageConfig +from dbt.contracts.project import Project as ProjectContract +from dbt.contracts.project import ProjectFlags, ProjectPackageMetadata, SemverString from dbt.exceptions import ( - DbtProjectError, DbtExclusivePropertyUseError, + DbtProjectError, + DbtRuntimeError, ProjectContractBrokenError, ProjectContractError, - DbtRuntimeError, ) -from dbt_common.exceptions import SemverError +from dbt.flags import get_flags from dbt.graph import SelectionSpec -from dbt_common.helper_types import NoValue -from dbt_common.semver import VersionSpecifier, versions_compatible -from dbt.version import get_installed_version -from dbt.utils import MultiDict, md5, coerce_dict_str from dbt.node_types import NodeType -from dbt.config.selectors import SelectorDict -from dbt.config.utils import exclusive_primary_alt_value_setting -from dbt.contracts.project import ( - Project as ProjectContract, - SemverString, - ProjectFlags, -) -from dbt.contracts.project import PackageConfig, ProjectPackageMetadata +from dbt.utils import MultiDict, coerce_dict_str, md5 +from dbt.version import get_installed_version +from dbt_common.clients.system import load_file_contents, path_exists from dbt_common.dataclass_schema import ValidationError +from dbt_common.exceptions import SemverError +from dbt_common.helper_types import NoValue +from dbt_common.semver import VersionSpecifier, versions_compatible + from .renderer import DbtProjectYamlRenderer, PackageRenderer from .selectors import ( + SelectorConfig, selector_config_from_data, selector_data_from_root, - SelectorConfig, ) - INVALID_VERSION_ERROR = """\ This version of dbt is not supported with the '{package}' package. Installed version of dbt: {installed} diff --git a/core/dbt/config/renderer.py b/core/dbt/config/renderer.py index 75e7f690251..4f605979e62 100644 --- a/core/dbt/config/renderer.py +++ b/core/dbt/config/renderer.py @@ -1,21 +1,20 @@ -from typing import Dict, Any, Tuple, Optional, Union, Callable import re from datetime import date +from typing import Any, Callable, Dict, Optional, Tuple, Union +from dbt.adapters.contracts.connection import HasCredentials from dbt.clients.jinja import get_rendered -from dbt_common.clients.jinja import catch_jinja -from dbt_common.constants import SECRET_ENV_PREFIX from dbt.constants import DEPENDENCIES_FILE_NAME, SECRET_PLACEHOLDER -from dbt.context.target import TargetContext -from dbt.context.secret import SecretContext from dbt.context.base import BaseContext -from dbt.adapters.contracts.connection import HasCredentials +from dbt.context.secret import SecretContext +from dbt.context.target import TargetContext from dbt.exceptions import DbtProjectError +from dbt_common.clients.jinja import catch_jinja +from dbt_common.constants import SECRET_ENV_PREFIX from dbt_common.context import get_invocation_context from dbt_common.exceptions import CompilationError, RecursionError from dbt_common.utils import deep_map_render - Keypath = Tuple[Union[str, int], ...] diff --git a/core/dbt/config/runtime.py b/core/dbt/config/runtime.py index e32005aa91f..f64fd22775b 100644 --- a/core/dbt/config/runtime.py +++ b/core/dbt/config/runtime.py @@ -16,24 +16,29 @@ ) from dbt import tracking -from dbt.adapters.factory import get_include_paths, get_relation_class_by_name -from dbt.adapters.contracts.connection import AdapterRequiredConfig, Credentials, HasCredentials +from dbt.adapters.contracts.connection import ( + AdapterRequiredConfig, + Credentials, + HasCredentials, +) from dbt.adapters.contracts.relation import ComponentName -from dbt.flags import get_flags +from dbt.adapters.factory import get_include_paths, get_relation_class_by_name from dbt.config.project import load_raw_project from dbt.contracts.graph.manifest import ManifestMetadata from dbt.contracts.project import Configuration -from dbt_common.dataclass_schema import ValidationError -from dbt_common.events.functions import warn_or_error from dbt.events.types import UnusedResourceConfigPath from dbt.exceptions import ( ConfigContractBrokenError, DbtProjectError, - NonUniquePackageNameError, DbtRuntimeError, + NonUniquePackageNameError, UninstalledPackagesFoundError, ) +from dbt.flags import get_flags +from dbt_common.dataclass_schema import ValidationError +from dbt_common.events.functions import warn_or_error from dbt_common.helper_types import DictDefaultEmptyStr, FQNPath, PathSet + from .profile import Profile from .project import Project from .renderer import DbtProjectYamlRenderer, ProfileRenderer diff --git a/core/dbt/config/selectors.py b/core/dbt/config/selectors.py index 4602abbf84e..82ab388a456 100644 --- a/core/dbt/config/selectors.py +++ b/core/dbt/config/selectors.py @@ -1,21 +1,21 @@ -from pathlib import Path from copy import deepcopy -from typing import Dict, Any, Union -from dbt.clients.yaml_helper import yaml, Loader, Dumper, load_yaml_text # noqa: F401 -from dbt_common.dataclass_schema import ValidationError - -from .renderer import BaseRenderer +from pathlib import Path +from typing import Any, Dict, Union +from dbt.clients.yaml_helper import Dumper, Loader, load_yaml_text, yaml # noqa: F401 +from dbt.contracts.selection import SelectorFile +from dbt.exceptions import DbtSelectorsError +from dbt.graph import SelectionSpec, parse_from_selectors_definition +from dbt.graph.selector_spec import SelectionCriteria from dbt_common.clients.system import ( load_file_contents, path_exists, resolve_path_from_base, ) -from dbt.contracts.selection import SelectorFile -from dbt.exceptions import DbtSelectorsError +from dbt_common.dataclass_schema import ValidationError from dbt_common.exceptions import DbtRuntimeError -from dbt.graph import parse_from_selectors_definition, SelectionSpec -from dbt.graph.selector_spec import SelectionCriteria + +from .renderer import BaseRenderer MALFORMED_SELECTOR_ERROR = """\ The selectors.yml file in this project is malformed. Please double check diff --git a/core/dbt/config/utils.py b/core/dbt/config/utils.py index f94e5dce0ad..6f7f1266309 100644 --- a/core/dbt/config/utils.py +++ b/core/dbt/config/utils.py @@ -1,10 +1,9 @@ from typing import Any, Dict, Optional - from dbt.clients import yaml_helper -from dbt_common.events.functions import fire_event from dbt.events.types import InvalidOptionYAML from dbt.exceptions import DbtExclusivePropertyUseError, OptionNotYamlDictError +from dbt_common.events.functions import fire_event from dbt_common.exceptions import DbtValidationError diff --git a/core/dbt/context/base.py b/core/dbt/context/base.py index 3bc9db78740..b989afd2078 100644 --- a/core/dbt/context/base.py +++ b/core/dbt/context/base.py @@ -1,39 +1,44 @@ from __future__ import annotations +import datetime +import itertools import json import os -from typing import Any, Callable, Dict, NoReturn, Optional, Mapping, Iterable, Set, List +import re import threading +from typing import Any, Callable, Dict, Iterable, List, Mapping, NoReturn, Optional, Set + +# These modules are added to the context. Consider alternative +# approaches which will extend well to potentially many modules +import pytz -from dbt.flags import get_flags import dbt.flags as flags_module -from dbt import tracking -from dbt import utils +from dbt import tracking, utils from dbt.clients.jinja import get_rendered -from dbt.clients.yaml_helper import yaml, safe_load, SafeLoader, Loader, Dumper # noqa: F401 -from dbt_common.constants import SECRET_ENV_PREFIX +from dbt.clients.yaml_helper import ( # noqa: F401 + Dumper, + Loader, + SafeLoader, + safe_load, + yaml, +) from dbt.constants import DEFAULT_ENV_PLACEHOLDER, SECRET_PLACEHOLDER from dbt.contracts.graph.nodes import Resource +from dbt.events.types import JinjaLogDebug, JinjaLogInfo from dbt.exceptions import ( - SecretEnvVarLocationError, EnvVarMissingError, RequiredVarNotFoundError, + SecretEnvVarLocationError, SetStrictWrongTypeError, ZipStrictWrongTypeError, ) +from dbt.flags import get_flags +from dbt.version import __version__ as dbt_version +from dbt_common.constants import SECRET_ENV_PREFIX from dbt_common.context import get_invocation_context -from dbt_common.exceptions.macros import MacroReturn -from dbt_common.events.functions import fire_event, get_invocation_id -from dbt.events.types import JinjaLogInfo, JinjaLogDebug from dbt_common.events.contextvars import get_node_info -from dbt.version import __version__ as dbt_version - -# These modules are added to the context. Consider alternative -# approaches which will extend well to potentially many modules -import pytz -import datetime -import re -import itertools +from dbt_common.events.functions import fire_event, get_invocation_id +from dbt_common.exceptions.macros import MacroReturn # See the `contexts` module README for more information on how contexts work @@ -329,6 +334,7 @@ def env_var(self, var: str, default: Optional[str] = None) -> str: def debug(): """Enter a debugger at this line in the compiled jinja code.""" import sys + import ipdb # type: ignore frame = sys._getframe(3) diff --git a/core/dbt/context/configured.py b/core/dbt/context/configured.py index 10a34d8394c..240d9afb843 100644 --- a/core/dbt/context/configured.py +++ b/core/dbt/context/configured.py @@ -1,16 +1,14 @@ from typing import Any, Dict, Optional -from dbt_common.context import get_invocation_context - -from dbt_common.constants import SECRET_ENV_PREFIX -from dbt.constants import DEFAULT_ENV_PLACEHOLDER from dbt.adapters.contracts.connection import AdapterRequiredConfig -from dbt.node_types import NodeType -from dbt.utils import MultiDict - -from dbt.context.base import contextproperty, contextmember, Var +from dbt.constants import DEFAULT_ENV_PLACEHOLDER +from dbt.context.base import Var, contextmember, contextproperty from dbt.context.target import TargetContext from dbt.exceptions import EnvVarMissingError, SecretEnvVarLocationError +from dbt.node_types import NodeType +from dbt.utils import MultiDict +from dbt_common.constants import SECRET_ENV_PREFIX +from dbt_common.context import get_invocation_context class ConfiguredContext(TargetContext): diff --git a/core/dbt/context/context_config.py b/core/dbt/context/context_config.py index e825a194b6c..b0664f33aba 100644 --- a/core/dbt/context/context_config.py +++ b/core/dbt/context/context_config.py @@ -1,15 +1,15 @@ from abc import abstractmethod from copy import deepcopy from dataclasses import dataclass -from typing import List, Iterator, Dict, Any, TypeVar, Generic, Optional +from typing import Any, Dict, Generic, Iterator, List, Optional, TypeVar from dbt.adapters.factory import get_config_class_by_name -from dbt.config import RuntimeConfig, Project, IsFQNResource +from dbt.config import IsFQNResource, Project, RuntimeConfig from dbt.contracts.graph.model_config import get_config_for -from dbt_common.contracts.config.base import BaseConfig, _listify -from dbt_common.exceptions import DbtInternalError from dbt.node_types import NodeType from dbt.utils import fqn_search +from dbt_common.contracts.config.base import BaseConfig, _listify +from dbt_common.exceptions import DbtInternalError @dataclass diff --git a/core/dbt/context/docs.py b/core/dbt/context/docs.py index 94f64709fc7..923e8d402b9 100644 --- a/core/dbt/context/docs.py +++ b/core/dbt/context/docs.py @@ -1,15 +1,11 @@ from typing import Any, Dict, Union -from dbt.exceptions import ( - DocTargetNotFoundError, - DocArgsError, -) from dbt.config.runtime import RuntimeConfig -from dbt.contracts.graph.manifest import Manifest -from dbt.contracts.graph.nodes import Macro, ResultNode - from dbt.context.base import contextmember from dbt.context.configured import SchemaYamlContext +from dbt.contracts.graph.manifest import Manifest +from dbt.contracts.graph.nodes import Macro, ResultNode +from dbt.exceptions import DocArgsError, DocTargetNotFoundError class DocsRuntimeContext(SchemaYamlContext): diff --git a/core/dbt/context/exceptions_jinja.py b/core/dbt/context/exceptions_jinja.py index a0d7c5af339..5c5867d1fca 100644 --- a/core/dbt/context/exceptions_jinja.py +++ b/core/dbt/context/exceptions_jinja.py @@ -1,37 +1,36 @@ import functools from typing import NoReturn -from dbt_common.events.functions import warn_or_error -from dbt.events.types import JinjaLogWarning - -from dbt_common.exceptions import ( - DbtRuntimeError, - NotImplementedError, - DbtDatabaseError, - DataclassNotDictError, -) from dbt.adapters.exceptions import ( - MissingConfigError, ColumnTypeMissingError, + MissingConfigError, MissingMaterializationError, RelationWrongTypeError, ) +from dbt.adapters.exceptions.cache import CacheInconsistencyError +from dbt.events.types import JinjaLogWarning from dbt.exceptions import ( - MissingRelationError, AmbiguousAliasError, AmbiguousCatalogMatchError, CompilationError, - DependencyNotFoundError, + ContractError, DependencyError, + DependencyNotFoundError, DuplicatePatchPathError, DuplicateResourceNameError, - PropertyYMLError, - ContractError, FailFastError, - scrub_secrets, + MissingRelationError, + PropertyYMLError, env_secrets, + scrub_secrets, +) +from dbt_common.events.functions import warn_or_error +from dbt_common.exceptions import ( + DataclassNotDictError, + DbtDatabaseError, + DbtRuntimeError, + NotImplementedError, ) -from dbt.adapters.exceptions.cache import CacheInconsistencyError def warn(msg, node=None): diff --git a/core/dbt/context/macro_resolver.py b/core/dbt/context/macro_resolver.py index d897c754049..ad497b3e885 100644 --- a/core/dbt/context/macro_resolver.py +++ b/core/dbt/context/macro_resolver.py @@ -1,8 +1,9 @@ from typing import Dict, MutableMapping, Optional + +from dbt.clients.jinja import MacroGenerator from dbt.contracts.graph.nodes import Macro from dbt.exceptions import DuplicateMacroNameError, PackageNotFoundForMacroError from dbt.include.global_project import PROJECT_NAME as GLOBAL_PROJECT_NAME -from dbt.clients.jinja import MacroGenerator MacroNamespace = Dict[str, Macro] diff --git a/core/dbt/context/macros.py b/core/dbt/context/macros.py index c2442b1f4a8..954cc72c9a4 100644 --- a/core/dbt/context/macros.py +++ b/core/dbt/context/macros.py @@ -1,10 +1,9 @@ -from typing import Any, Dict, Iterable, Union, Optional, List, Iterator, Mapping, Set +from typing import Any, Dict, Iterable, Iterator, List, Mapping, Optional, Set, Union from dbt.clients.jinja import MacroGenerator, MacroStack from dbt.contracts.graph.nodes import Macro -from dbt.include.global_project import PROJECT_NAME as GLOBAL_PROJECT_NAME from dbt.exceptions import DuplicateMacroNameError, PackageNotFoundForMacroError - +from dbt.include.global_project import PROJECT_NAME as GLOBAL_PROJECT_NAME FlatNamespace = Dict[str, MacroGenerator] NamespaceMember = Union[FlatNamespace, MacroGenerator] diff --git a/core/dbt/context/manifest.py b/core/dbt/context/manifest.py index 0d95fd3b95f..264f59a61e2 100644 --- a/core/dbt/context/manifest.py +++ b/core/dbt/context/manifest.py @@ -1,12 +1,11 @@ from typing import List -from dbt.clients.jinja import MacroStack from dbt.adapters.contracts.connection import AdapterRequiredConfig -from dbt.contracts.graph.manifest import Manifest +from dbt.clients.jinja import MacroStack from dbt.context.macro_resolver import TestMacroNamespace -from .base import contextproperty - +from dbt.contracts.graph.manifest import Manifest +from .base import contextproperty from .configured import ConfiguredContext from .macros import MacroNamespace, MacroNamespaceBuilder diff --git a/core/dbt/context/providers.py b/core/dbt/context/providers.py index acc5a56281d..a27eb395293 100644 --- a/core/dbt/context/providers.py +++ b/core/dbt/context/providers.py @@ -1,87 +1,94 @@ import abc -from copy import deepcopy import os +from copy import deepcopy from typing import ( - Callable, + TYPE_CHECKING, Any, + Callable, Dict, - Optional, - Union, - List, - TypeVar, - Type, Iterable, + List, Mapping, + Optional, Tuple, - TYPE_CHECKING, + Type, + TypeVar, + Union, ) from typing_extensions import Protocol +from dbt import selected_resources from dbt.adapters.base.column import Column +from dbt.adapters.contracts.connection import AdapterResponse +from dbt.adapters.exceptions import MissingConfigError +from dbt.adapters.factory import ( + get_adapter, + get_adapter_package_names, + get_adapter_type_names, +) from dbt.artifacts.resources import NodeVersion, RefArgs -from dbt_common.clients.jinja import MacroProtocol -from dbt_common.context import get_invocation_context -from dbt.adapters.factory import get_adapter, get_adapter_package_names, get_adapter_type_names -from dbt.clients.jinja import get_rendered, MacroGenerator, MacroStack, UnitTestMacroGenerator -from dbt.config import RuntimeConfig, Project -from dbt_common.constants import SECRET_ENV_PREFIX +from dbt.clients.jinja import ( + MacroGenerator, + MacroStack, + UnitTestMacroGenerator, + get_rendered, +) +from dbt.config import IsFQNResource, Project, RuntimeConfig from dbt.constants import DEFAULT_ENV_PLACEHOLDER -from dbt.context.base import contextmember, contextproperty, Var +from dbt.context.base import Var, contextmember, contextproperty from dbt.context.configured import FQNLookup from dbt.context.context_config import ContextConfig from dbt.context.exceptions_jinja import wrapped_exports from dbt.context.macro_resolver import MacroResolver, TestMacroNamespace -from dbt.context.macros import MacroNamespaceBuilder, MacroNamespace +from dbt.context.macros import MacroNamespace, MacroNamespaceBuilder from dbt.context.manifest import ManifestContext -from dbt.adapters.contracts.connection import AdapterResponse -from dbt.contracts.graph.manifest import Manifest, Disabled +from dbt.contracts.graph.manifest import Disabled, Manifest +from dbt.contracts.graph.metrics import MetricReference, ResolvedMetricReference from dbt.contracts.graph.nodes import ( - Macro, + AccessType, Exposure, - SeedNode, - SourceDefinition, - Resource, + Macro, ManifestNode, - AccessType, + Resource, + SeedNode, SemanticModel, + SourceDefinition, UnitTestNode, ) -from dbt.contracts.graph.metrics import MetricReference, ResolvedMetricReference -from dbt_common.events.functions import get_metadata_vars -from dbt_common.exceptions import ( - DbtInternalError, - DbtRuntimeError, - DbtValidationError, - MacrosSourcesUnWriteableError, -) -from dbt.adapters.exceptions import MissingConfigError from dbt.exceptions import ( CompilationError, ConflictingConfigKeysError, - SecretEnvVarLocationError, + DbtReferenceError, EnvVarMissingError, InlineModelConfigError, - NumberSourceArgsError, - PersistDocsValueTypeError, LoadAgateTableNotSeedError, LoadAgateTableValueError, MacroDispatchArgError, MacroResultAlreadyLoadedError, MetricArgsError, + NumberSourceArgsError, OperationsCannotRefEphemeralNodesError, ParsingError, - RefBadContextError, + PersistDocsValueTypeError, RefArgsError, + RefBadContextError, + SecretEnvVarLocationError, TargetNotFoundError, - DbtReferenceError, ) -from dbt.config import IsFQNResource -from dbt.node_types import NodeType, ModelLanguage - +from dbt.node_types import ModelLanguage, NodeType from dbt.utils import MultiDict, args_to_dict -from dbt_common.utils import merge, AttrDict, cast_to_str -from dbt import selected_resources +from dbt_common.clients.jinja import MacroProtocol +from dbt_common.constants import SECRET_ENV_PREFIX +from dbt_common.context import get_invocation_context +from dbt_common.events.functions import get_metadata_vars +from dbt_common.exceptions import ( + DbtInternalError, + DbtRuntimeError, + DbtValidationError, + MacrosSourcesUnWriteableError, +) +from dbt_common.utils import AttrDict, cast_to_str, merge if TYPE_CHECKING: import agate diff --git a/core/dbt/context/secret.py b/core/dbt/context/secret.py index be6a5428531..3f2641323fe 100644 --- a/core/dbt/context/secret.py +++ b/core/dbt/context/secret.py @@ -1,13 +1,12 @@ from typing import Any, Dict, Optional +from dbt.constants import DEFAULT_ENV_PLACEHOLDER, SECRET_PLACEHOLDER +from dbt.exceptions import EnvVarMissingError +from dbt_common.constants import SECRET_ENV_PREFIX from dbt_common.context import get_invocation_context from .base import BaseContext, contextmember -from dbt_common.constants import SECRET_ENV_PREFIX -from dbt.constants import DEFAULT_ENV_PLACEHOLDER, SECRET_PLACEHOLDER -from dbt.exceptions import EnvVarMissingError - class SecretContext(BaseContext): """This context is used in profiles.yml + packages.yml. It can render secret diff --git a/core/dbt/contracts/files.py b/core/dbt/contracts/files.py index 714782161cc..512dc1533d0 100644 --- a/core/dbt/contracts/files.py +++ b/core/dbt/contracts/files.py @@ -1,12 +1,12 @@ import os from dataclasses import dataclass, field +from typing import Any, Dict, List, Optional, Union from mashumaro.types import SerializableType -from typing import List, Optional, Union, Dict, Any -from dbt.constants import MAXIMUM_SEED_SIZE -from dbt_common.dataclass_schema import dbtClassMixin, StrEnum from dbt.artifacts.resources.base import FileHash +from dbt.constants import MAXIMUM_SEED_SIZE +from dbt_common.dataclass_schema import StrEnum, dbtClassMixin from .util import SourceKey diff --git a/core/dbt/contracts/graph/manifest.py b/core/dbt/contracts/graph/manifest.py index 75930fba3de..08000eb5ad9 100644 --- a/core/dbt/contracts/graph/manifest.py +++ b/core/dbt/contracts/graph/manifest.py @@ -2,29 +2,48 @@ from collections import defaultdict from dataclasses import dataclass, field, replace from itertools import chain -from mashumaro.mixins.msgpack import DataClassMessagePackMixin from multiprocessing.synchronize import Lock from typing import ( + Any, + Callable, + ClassVar, DefaultDict, Dict, + Generic, List, - Optional, - Union, Mapping, MutableMapping, - Any, + Optional, Set, Tuple, TypeVar, - Callable, - Generic, - ClassVar, + Union, ) + +from mashumaro.mixins.msgpack import DataClassMessagePackMixin from typing_extensions import Protocol -from dbt import deprecations -from dbt import tracking +import dbt_common.exceptions +import dbt_common.utils +from dbt import deprecations, tracking +from dbt.adapters.exceptions import ( + DuplicateMacroInPackageError, + DuplicateMaterializationNameError, +) + +# to preserve import paths +from dbt.artifacts.resources import BaseResource, DeferRelation, NodeVersion +from dbt.artifacts.resources.v1.config import NodeConfig +from dbt.artifacts.schemas.manifest import ManifestMetadata, UniqueID, WritableManifest +from dbt.contracts.files import ( + AnySourceFile, + FileHash, + FixtureSourceFile, + SchemaSourceFile, + SourceFile, +) from dbt.contracts.graph.nodes import ( + RESOURCE_CLASS_TO_NODE_CLASS, BaseNode, Documentation, Exposure, @@ -37,50 +56,33 @@ ModelNode, ResultNode, SavedQuery, - SemanticModel, SeedNode, + SemanticModel, SourceDefinition, - UnpatchedSourceDefinition, UnitTestDefinition, UnitTestFileFixture, - RESOURCE_CLASS_TO_NODE_CLASS, + UnpatchedSourceDefinition, ) from dbt.contracts.graph.unparsed import SourcePatch, UnparsedVersion -from dbt.flags import get_flags - -# to preserve import paths -from dbt.artifacts.resources import ( - NodeVersion, - DeferRelation, - BaseResource, -) -from dbt.artifacts.resources.v1.config import NodeConfig -from dbt.artifacts.schemas.manifest import WritableManifest, ManifestMetadata, UniqueID -from dbt.contracts.files import ( - SourceFile, - SchemaSourceFile, - FileHash, - AnySourceFile, - FixtureSourceFile, -) from dbt.contracts.util import SourceKey -from dbt_common.dataclass_schema import dbtClassMixin - +from dbt.events.types import UnpinnedRefNewVersionAvailable from dbt.exceptions import ( + AmbiguousResourceNameRefError, CompilationError, DuplicateResourceNameError, - AmbiguousResourceNameRefError, ) -from dbt.adapters.exceptions import DuplicateMacroInPackageError, DuplicateMaterializationNameError -from dbt_common.helper_types import PathSet -from dbt_common.events.functions import fire_event -from dbt_common.events.contextvars import get_node_info -from dbt.events.types import UnpinnedRefNewVersionAvailable -from dbt.node_types import NodeType, AccessType, REFABLE_NODE_TYPES, VERSIONED_NODE_TYPES +from dbt.flags import get_flags from dbt.mp_context import get_mp_context -import dbt_common.utils -import dbt_common.exceptions - +from dbt.node_types import ( + REFABLE_NODE_TYPES, + VERSIONED_NODE_TYPES, + AccessType, + NodeType, +) +from dbt_common.dataclass_schema import dbtClassMixin +from dbt_common.events.contextvars import get_node_info +from dbt_common.events.functions import fire_event +from dbt_common.helper_types import PathSet PackageName = str DocName = str diff --git a/core/dbt/contracts/graph/metrics.py b/core/dbt/contracts/graph/metrics.py index e9bb7694000..6b1a737aec8 100644 --- a/core/dbt/contracts/graph/metrics.py +++ b/core/dbt/contracts/graph/metrics.py @@ -1,8 +1,8 @@ -from dbt.contracts.graph.manifest import Manifest, Metric -from dbt_semantic_interfaces.type_enums import MetricType - from typing import Any, Dict, Iterator, List +from dbt_semantic_interfaces.type_enums import MetricType + +from dbt.contracts.graph.manifest import Manifest, Metric DERIVED_METRICS = [MetricType.DERIVED, MetricType.RATIO] BASE_METRICS = [MetricType.SIMPLE, MetricType.CUMULATIVE, MetricType.CONVERSION] diff --git a/core/dbt/contracts/graph/model_config.py b/core/dbt/contracts/graph/model_config.py index b45c313327c..14317f769b5 100644 --- a/core/dbt/contracts/graph/model_config.py +++ b/core/dbt/contracts/graph/model_config.py @@ -1,22 +1,22 @@ -from dataclasses import field, dataclass -from typing import Any, List, Optional, Dict, Type +from dataclasses import dataclass, field +from typing import Any, Dict, List, Optional, Type from dbt.artifacts.resources import ( ExposureConfig, MetricConfig, - SavedQueryConfig, - SemanticModelConfig, + ModelConfig, NodeConfig, + SavedQueryConfig, SeedConfig, - TestConfig, + SemanticModelConfig, SnapshotConfig, SourceConfig, - ModelConfig, + TestConfig, UnitTestConfig, ) +from dbt.node_types import NodeType from dbt_common.contracts.config.base import BaseConfig from dbt_common.contracts.config.metadata import Metadata -from dbt.node_types import NodeType def metas(*metas: Metadata) -> Dict[str, Any]: diff --git a/core/dbt/contracts/graph/node_args.py b/core/dbt/contracts/graph/node_args.py index cd19252275c..60b2a2aa1f8 100644 --- a/core/dbt/contracts/graph/node_args.py +++ b/core/dbt/contracts/graph/node_args.py @@ -1,9 +1,9 @@ from dataclasses import dataclass, field from datetime import datetime -from typing import Optional, List +from typing import List, Optional from dbt.artifacts.resources import NodeVersion -from dbt.node_types import NodeType, AccessType +from dbt.node_types import AccessType, NodeType @dataclass diff --git a/core/dbt/contracts/graph/nodes.py b/core/dbt/contracts/graph/nodes.py index 2a7752500e2..8edb307f242 100644 --- a/core/dbt/contracts/graph/nodes.py +++ b/core/dbt/contracts/graph/nodes.py @@ -1,95 +1,91 @@ +import hashlib import os -from datetime import datetime from dataclasses import dataclass, field -import hashlib - -from mashumaro.types import SerializableType +from datetime import datetime from typing import ( - Optional, - Union, - List, - Dict, Any, + Dict, + Iterator, + List, + Literal, + Optional, Sequence, Tuple, Type, - Iterator, - Literal, + Union, get_args, ) -from dbt import deprecations -from dbt_common.contracts.constraints import ConstraintType +from mashumaro.types import SerializableType -from dbt_common.clients.system import write_file +from dbt import deprecations +from dbt.artifacts.resources import Analysis as AnalysisResource +from dbt.artifacts.resources import ( + BaseResource, + ColumnInfo, + CompiledResource, + DependsOn, + Docs, +) +from dbt.artifacts.resources import Documentation as DocumentationResource +from dbt.artifacts.resources import Exposure as ExposureResource +from dbt.artifacts.resources import FileHash +from dbt.artifacts.resources import GenericTest as GenericTestResource +from dbt.artifacts.resources import GraphResource +from dbt.artifacts.resources import Group as GroupResource +from dbt.artifacts.resources import HasRelationMetadata as HasRelationMetadataResource +from dbt.artifacts.resources import HookNode as HookNodeResource +from dbt.artifacts.resources import InjectedCTE +from dbt.artifacts.resources import Macro as MacroResource +from dbt.artifacts.resources import MacroArgument +from dbt.artifacts.resources import Metric as MetricResource +from dbt.artifacts.resources import MetricInputMeasure +from dbt.artifacts.resources import Model as ModelResource +from dbt.artifacts.resources import ( + ModelConfig, + NodeConfig, + NodeVersion, + ParsedResource, + ParsedResourceMandatory, +) +from dbt.artifacts.resources import Quoting as QuotingResource +from dbt.artifacts.resources import SavedQuery as SavedQueryResource +from dbt.artifacts.resources import Seed as SeedResource +from dbt.artifacts.resources import SemanticModel as SemanticModelResource +from dbt.artifacts.resources import SingularTest as SingularTestResource +from dbt.artifacts.resources import Snapshot as SnapshotResource +from dbt.artifacts.resources import SourceDefinition as SourceDefinitionResource +from dbt.artifacts.resources import SqlOperation as SqlOperationResource +from dbt.artifacts.resources import UnitTestDefinition as UnitTestDefinitionResource +from dbt.contracts.graph.model_config import EmptySnapshotConfig, UnitTestNodeConfig +from dbt.contracts.graph.node_args import ModelNodeArgs from dbt.contracts.graph.unparsed import ( HasYamlMetadata, TestDef, + UnitTestOverrides, + UnparsedColumn, UnparsedSourceDefinition, UnparsedSourceTableDefinition, - UnparsedColumn, - UnitTestOverrides, ) -from dbt.contracts.graph.model_config import ( - UnitTestNodeConfig, - EmptySnapshotConfig, -) -from dbt.contracts.graph.node_args import ModelNodeArgs -from dbt_common.events.functions import warn_or_error -from dbt.exceptions import ParsingError, ContractBreakingChangeError, ValidationError from dbt.events.types import ( - SeedIncreased, - SeedExceedsLimitSamePath, SeedExceedsLimitAndPathChanged, SeedExceedsLimitChecksumChanged, + SeedExceedsLimitSamePath, + SeedIncreased, UnversionedBreakingChange, ) -from dbt_common.events.contextvars import set_log_contextvars +from dbt.exceptions import ContractBreakingChangeError, ParsingError, ValidationError from dbt.flags import get_flags from dbt.node_types import ( - NodeType, - AccessType, REFABLE_NODE_TYPES, VERSIONED_NODE_TYPES, + AccessType, + NodeType, ) - - -from dbt.artifacts.resources import ( - BaseResource, - DependsOn, - Docs, - Exposure as ExposureResource, - MacroArgument, - Documentation as DocumentationResource, - Macro as MacroResource, - Metric as MetricResource, - NodeVersion, - Group as GroupResource, - GraphResource, - SavedQuery as SavedQueryResource, - SemanticModel as SemanticModelResource, - ParsedResourceMandatory, - ParsedResource, - CompiledResource, - HasRelationMetadata as HasRelationMetadataResource, - FileHash, - NodeConfig, - ColumnInfo, - InjectedCTE, - Analysis as AnalysisResource, - HookNode as HookNodeResource, - Model as ModelResource, - ModelConfig, - SqlOperation as SqlOperationResource, - Seed as SeedResource, - SingularTest as SingularTestResource, - GenericTest as GenericTestResource, - Snapshot as SnapshotResource, - Quoting as QuotingResource, - SourceDefinition as SourceDefinitionResource, - MetricInputMeasure, - UnitTestDefinition as UnitTestDefinitionResource, -) +from dbt_common.clients.system import write_file +from dbt_common.contracts.constraints import ConstraintType +from dbt_common.events.contextvars import set_log_contextvars +from dbt_common.events.functions import warn_or_error # ===================================================================== # This contains the classes for all of the nodes and node-like objects @@ -606,8 +602,8 @@ def same_contract(self, old, adapter_type=None) -> bool: contract_enforced_disabled = True # TODO: this avoid the circular imports but isn't ideal - from dbt.adapters.factory import get_adapter_constraint_support from dbt.adapters.base import ConstraintSupport + from dbt.adapters.factory import get_adapter_constraint_support constraint_support = get_adapter_constraint_support(adapter_type) column_constraints_exist = False diff --git a/core/dbt/contracts/graph/semantic_manifest.py b/core/dbt/contracts/graph/semantic_manifest.py index e52f03a795e..cf268571425 100644 --- a/core/dbt/contracts/graph/semantic_manifest.py +++ b/core/dbt/contracts/graph/semantic_manifest.py @@ -3,7 +3,9 @@ PydanticProjectConfiguration, ) from dbt_semantic_interfaces.implementations.saved_query import PydanticSavedQuery -from dbt_semantic_interfaces.implementations.semantic_manifest import PydanticSemanticManifest +from dbt_semantic_interfaces.implementations.semantic_manifest import ( + PydanticSemanticManifest, +) from dbt_semantic_interfaces.implementations.semantic_model import PydanticSemanticModel from dbt_semantic_interfaces.implementations.time_spine_table_configuration import ( PydanticTimeSpineTableConfiguration, @@ -13,11 +15,11 @@ SemanticManifestValidator, ) +from dbt.events.types import SemanticValidationFailure +from dbt.exceptions import ParsingError from dbt_common.clients.system import write_file from dbt_common.events.base_types import EventLevel from dbt_common.events.functions import fire_event -from dbt.events.types import SemanticValidationFailure -from dbt.exceptions import ParsingError class SemanticManifest: diff --git a/core/dbt/contracts/graph/unparsed.py b/core/dbt/contracts/graph/unparsed.py index ef2012221b5..0cddc3139b0 100644 --- a/core/dbt/contracts/graph/unparsed.py +++ b/core/dbt/contracts/graph/unparsed.py @@ -1,42 +1,44 @@ import datetime import re +from dataclasses import dataclass, field +from pathlib import Path +from typing import Any, Dict, List, Literal, Optional, Sequence, Union +from dbt_semantic_interfaces.type_enums import ConversionCalculationType + +# trigger the PathEncoder +import dbt_common.helper_types # noqa:F401 from dbt import deprecations -from dbt.artifacts.resources import ConstantPropertyInput, Quoting -from dbt_common.contracts.config.properties import AdditionalPropertiesMixin -from dbt_common.contracts.util import Mergeable -from dbt_common.exceptions import DbtInternalError -from dbt_common.dataclass_schema import ( - dbtClassMixin, - StrEnum, - ExtensibleDbtClassMixin, - ValidationError, -) -from dbt.node_types import NodeType from dbt.artifacts.resources import ( + ConstantPropertyInput, Defaults, DimensionValidityParams, + Docs, ExposureType, ExternalTable, FreshnessThreshold, + MacroArgument, MaturityType, MeasureAggregationParameters, + NodeVersion, + Owner, + Quoting, UnitTestInputFixture, - UnitTestOutputFixture, UnitTestNodeVersions, + UnitTestOutputFixture, UnitTestOverrides, ) - -# trigger the PathEncoder -import dbt_common.helper_types # noqa:F401 from dbt.exceptions import ParsingError - -from dbt_semantic_interfaces.type_enums import ConversionCalculationType -from dbt.artifacts.resources import Docs, MacroArgument, NodeVersion, Owner - -from dataclasses import dataclass, field -from pathlib import Path -from typing import Optional, List, Union, Dict, Any, Sequence, Literal +from dbt.node_types import NodeType +from dbt_common.contracts.config.properties import AdditionalPropertiesMixin +from dbt_common.contracts.util import Mergeable +from dbt_common.dataclass_schema import ( + ExtensibleDbtClassMixin, + StrEnum, + ValidationError, + dbtClassMixin, +) +from dbt_common.exceptions import DbtInternalError @dataclass diff --git a/core/dbt/contracts/project.py b/core/dbt/contracts/project.py index c2090eb4d10..4b98143f4b4 100644 --- a/core/dbt/contracts/project.py +++ b/core/dbt/contracts/project.py @@ -1,20 +1,21 @@ +from dataclasses import dataclass, field +from typing import Any, ClassVar, Dict, List, Optional, Union + +from mashumaro.jsonschema.annotations import Pattern +from mashumaro.types import SerializableType +from typing_extensions import Annotated + from dbt import deprecations -from dbt.contracts.util import list_str, Identifier from dbt.adapters.contracts.connection import QueryComment -from dbt_common.helper_types import NoValue +from dbt.contracts.util import Identifier, list_str from dbt_common.contracts.util import Mergeable from dbt_common.dataclass_schema import ( - dbtClassMixin, - ValidationError, ExtensibleDbtClassMixin, + ValidationError, + dbtClassMixin, dbtMashConfig, ) -from dataclasses import dataclass, field -from typing import Optional, List, Dict, Union, Any, ClassVar -from typing_extensions import Annotated -from mashumaro.types import SerializableType -from mashumaro.jsonschema.annotations import Pattern - +from dbt_common.helper_types import NoValue DEFAULT_SEND_ANONYMOUS_USAGE_STATS = True diff --git a/core/dbt/contracts/results.py b/core/dbt/contracts/results.py index c0775b10aa6..79a190087c4 100644 --- a/core/dbt/contracts/results.py +++ b/core/dbt/contracts/results.py @@ -9,50 +9,45 @@ VersionedSchema, schema_version, ) - +from dbt.artifacts.schemas.catalog import ( + CatalogArtifact, + CatalogKey, + CatalogMetadata, + CatalogResults, + CatalogTable, + ColumnMetadata, + StatsItem, + TableMetadata, +) +from dbt.artifacts.schemas.freshness import ( + FreshnessErrorEnum, + FreshnessExecutionResultArtifact, + FreshnessMetadata, + FreshnessNodeOutput, + FreshnessNodeResult, + FreshnessResult, + PartialSourceFreshnessResult, + SourceFreshnessOutput, + SourceFreshnessResult, + SourceFreshnessRuntimeError, + process_freshness_result, +) from dbt.artifacts.schemas.results import ( + BaseResult, + ExecutionResult, + FreshnessStatus, + NodeResult, NodeStatus, + RunningStatus, RunStatus, TestStatus, - FreshnessStatus, - RunningStatus, TimingInfo, collect_timing_info, - BaseResult, - NodeResult, - ExecutionResult, ) - from dbt.artifacts.schemas.run import ( - RunResult, - RunResultsMetadata, RunExecutionResult, + RunResult, RunResultsArtifact, + RunResultsMetadata, process_run_result, ) - -from dbt.artifacts.schemas.freshness import ( - FreshnessErrorEnum, - FreshnessMetadata, - FreshnessResult, - FreshnessExecutionResultArtifact, - FreshnessNodeResult, - FreshnessNodeOutput, - process_freshness_result, - SourceFreshnessResult, - SourceFreshnessRuntimeError, - SourceFreshnessOutput, - PartialSourceFreshnessResult, -) - -from dbt.artifacts.schemas.catalog import ( - CatalogResults, - CatalogKey, - StatsItem, - ColumnMetadata, - TableMetadata, - CatalogTable, - CatalogMetadata, - CatalogResults, - CatalogArtifact, -) diff --git a/core/dbt/contracts/selection.py b/core/dbt/contracts/selection.py index 611338559d3..0a4d39bede7 100644 --- a/core/dbt/contracts/selection.py +++ b/core/dbt/contracts/selection.py @@ -1,7 +1,7 @@ from dataclasses import dataclass -from dbt_common.dataclass_schema import dbtClassMixin +from typing import Any, Dict, List, Union -from typing import List, Dict, Any, Union +from dbt_common.dataclass_schema import dbtClassMixin @dataclass diff --git a/core/dbt/contracts/sql.py b/core/dbt/contracts/sql.py index ec1033ef831..168ceb3e937 100644 --- a/core/dbt/contracts/sql.py +++ b/core/dbt/contracts/sql.py @@ -1,16 +1,14 @@ import uuid from dataclasses import dataclass, field from datetime import datetime -from typing import Optional, List, Any, Dict, Sequence +from typing import Any, Dict, List, Optional, Sequence -from dbt_common.dataclass_schema import dbtClassMixin - -from dbt.contracts.graph.nodes import ResultNode -from dbt.artifacts.schemas.results import TimingInfo, ExecutionResult -from dbt.artifacts.schemas.run import RunResult, RunResultsArtifact, RunExecutionResult from dbt.artifacts.schemas.base import VersionedSchema, schema_version +from dbt.artifacts.schemas.results import ExecutionResult, TimingInfo +from dbt.artifacts.schemas.run import RunExecutionResult, RunResult, RunResultsArtifact +from dbt.contracts.graph.nodes import ResultNode from dbt.logger import LogMessage - +from dbt_common.dataclass_schema import dbtClassMixin TaskTags = Optional[Dict[str, Any]] TaskID = uuid.UUID diff --git a/core/dbt/contracts/state.py b/core/dbt/contracts/state.py index 01a2eba958b..d65fe4d9b4f 100644 --- a/core/dbt/contracts/state.py +++ b/core/dbt/contracts/state.py @@ -1,13 +1,13 @@ from pathlib import Path from typing import Optional -from dbt.contracts.graph.manifest import Manifest from dbt.artifacts.exceptions import IncompatibleSchemaError -from dbt.artifacts.schemas.manifest import WritableManifest from dbt.artifacts.schemas.freshness import FreshnessExecutionResultArtifact +from dbt.artifacts.schemas.manifest import WritableManifest from dbt.artifacts.schemas.run import RunResultsArtifact -from dbt_common.events.functions import fire_event +from dbt.contracts.graph.manifest import Manifest from dbt.events.types import WarnStateTargetEqual +from dbt_common.events.functions import fire_event def load_result_state(results_path) -> Optional[RunResultsArtifact]: diff --git a/core/dbt/contracts/util.py b/core/dbt/contracts/util.py index 539744f0dc5..05157fa006f 100644 --- a/core/dbt/contracts/util.py +++ b/core/dbt/contracts/util.py @@ -1,10 +1,8 @@ -from typing import List, Any, Tuple - -from dbt_common.dataclass_schema import ValidatedStringMixin, ValidationError +from typing import Any, List, Tuple # Leave imports of `Mergeable` to preserve import paths from dbt_common.contracts.util import Mergeable # noqa:F401 - +from dbt_common.dataclass_schema import ValidatedStringMixin, ValidationError SourceKey = Tuple[str, str] diff --git a/core/dbt/deprecations.py b/core/dbt/deprecations.py index 86c820b6553..53f95ee1e65 100644 --- a/core/dbt/deprecations.py +++ b/core/dbt/deprecations.py @@ -1,10 +1,9 @@ import abc -from typing import Optional, Set, List, Dict, ClassVar +from typing import ClassVar, Dict, List, Optional, Set import dbt.tracking - from dbt.events import types as core_types -from dbt_common.events.functions import warn_or_error, fire_event +from dbt_common.events.functions import fire_event, warn_or_error class DBTDeprecation: diff --git a/core/dbt/deps/base.py b/core/dbt/deps/base.py index db48526b0e0..0d6dfaf20ed 100644 --- a/core/dbt/deps/base.py +++ b/core/dbt/deps/base.py @@ -1,15 +1,15 @@ import abc -import os import functools +import os import tempfile from contextlib import contextmanager from pathlib import Path -from typing import List, Optional, Generic, TypeVar, Dict +from typing import Dict, Generic, List, Optional, TypeVar -from dbt_common.clients import system from dbt.contracts.project import ProjectPackageMetadata -from dbt_common.events.functions import fire_event from dbt.events.types import DepsSetDownloadDirectory +from dbt_common.clients import system +from dbt_common.events.functions import fire_event from dbt_common.utils.connection import connection_exception_retry DOWNLOADS_PATH = None diff --git a/core/dbt/deps/git.py b/core/dbt/deps/git.py index 0d5e74a0156..c7f76423887 100644 --- a/core/dbt/deps/git.py +++ b/core/dbt/deps/git.py @@ -1,20 +1,22 @@ import os -from typing import List, Optional, Dict +from typing import Dict, List, Optional from dbt.clients import git -from dbt_common.clients import system from dbt.config.project import PartialProject, Project from dbt.config.renderer import PackageRenderer -from dbt.contracts.project import ( - ProjectPackageMetadata, - GitPackage, -) +from dbt.contracts.project import GitPackage, ProjectPackageMetadata from dbt.deps.base import PinnedPackage, UnpinnedPackage, get_downloads_path -from dbt_common.exceptions import ExecutableError +from dbt.events.types import DepsScrubbedPackageName, DepsUnpinned, EnsureGitInstalled from dbt.exceptions import MultipleVersionGitDepsError -from dbt_common.events.functions import fire_event, warn_or_error, scrub_secrets, env_secrets -from dbt.events.types import EnsureGitInstalled, DepsUnpinned, DepsScrubbedPackageName from dbt.utils import md5 +from dbt_common.clients import system +from dbt_common.events.functions import ( + env_secrets, + fire_event, + scrub_secrets, + warn_or_error, +) +from dbt_common.exceptions import ExecutableError def md5sum(s: str): diff --git a/core/dbt/deps/local.py b/core/dbt/deps/local.py index 9dd76b80161..869ac0c3055 100644 --- a/core/dbt/deps/local.py +++ b/core/dbt/deps/local.py @@ -1,16 +1,13 @@ import shutil from typing import Dict -from dbt_common.clients import system -from dbt.deps.base import PinnedPackage, UnpinnedPackage -from dbt.contracts.project import ( - ProjectPackageMetadata, - LocalPackage, -) -from dbt_common.events.functions import fire_event -from dbt.events.types import DepsCreatingLocalSymlink, DepsSymlinkNotAvailable from dbt.config.project import PartialProject, Project from dbt.config.renderer import PackageRenderer +from dbt.contracts.project import LocalPackage, ProjectPackageMetadata +from dbt.deps.base import PinnedPackage, UnpinnedPackage +from dbt.events.types import DepsCreatingLocalSymlink, DepsSymlinkNotAvailable +from dbt_common.clients import system +from dbt_common.events.functions import fire_event class LocalPackageMixin: diff --git a/core/dbt/deps/registry.py b/core/dbt/deps/registry.py index 408d42bab87..8943523e3f5 100644 --- a/core/dbt/deps/registry.py +++ b/core/dbt/deps/registry.py @@ -1,19 +1,16 @@ -from typing import List, Dict +from typing import Dict, List -from dbt_common import semver -from dbt.flags import get_flags -from dbt.version import get_installed_version from dbt.clients import registry -from dbt.contracts.project import ( - RegistryPackageMetadata, - RegistryPackage, -) +from dbt.contracts.project import RegistryPackage, RegistryPackageMetadata from dbt.deps.base import PinnedPackage, UnpinnedPackage from dbt.exceptions import ( DependencyError, PackageNotFoundError, PackageVersionNotFoundError, ) +from dbt.flags import get_flags +from dbt.version import get_installed_version +from dbt_common import semver from dbt_common.exceptions import VersionsNotCompatibleError diff --git a/core/dbt/deps/resolver.py b/core/dbt/deps/resolver.py index 5f890109b0e..0ac27835511 100644 --- a/core/dbt/deps/resolver.py +++ b/core/dbt/deps/resolver.py @@ -1,27 +1,25 @@ from dataclasses import dataclass, field -from typing import Dict, List, NoReturn, Type, Iterator, Set, Any - -from dbt.exceptions import ( - DuplicateDependencyToRootError, - DuplicateProjectDependencyError, - MismatchedDependencyTypeError, - DbtInternalError, -) +from typing import Any, Dict, Iterator, List, NoReturn, Set, Type from dbt.config import Project from dbt.config.renderer import PackageRenderer -from dbt.deps.base import BasePackage, PinnedPackage, UnpinnedPackage -from dbt.deps.local import LocalUnpinnedPackage -from dbt.deps.tarball import TarballUnpinnedPackage -from dbt.deps.git import GitUnpinnedPackage -from dbt.deps.registry import RegistryUnpinnedPackage - from dbt.contracts.project import ( - PackageSpec, - LocalPackage, - TarballPackage, GitPackage, + LocalPackage, + PackageSpec, RegistryPackage, + TarballPackage, +) +from dbt.deps.base import BasePackage, PinnedPackage, UnpinnedPackage +from dbt.deps.git import GitUnpinnedPackage +from dbt.deps.local import LocalUnpinnedPackage +from dbt.deps.registry import RegistryUnpinnedPackage +from dbt.deps.tarball import TarballUnpinnedPackage +from dbt.exceptions import ( + DbtInternalError, + DuplicateDependencyToRootError, + DuplicateProjectDependencyError, + MismatchedDependencyTypeError, ) diff --git a/core/dbt/deps/tarball.py b/core/dbt/deps/tarball.py index 77963469e06..d7874978e2b 100644 --- a/core/dbt/deps/tarball.py +++ b/core/dbt/deps/tarball.py @@ -3,13 +3,13 @@ from pathlib import Path from typing import Dict -from dbt_common.clients import system from dbt.config.project import PartialProject from dbt.contracts.project import TarballPackage from dbt.deps.base import PinnedPackage, UnpinnedPackage, get_downloads_path -from dbt.exceptions import DependencyError, scrub_secrets, env_secrets -from dbt_common.events.functions import warn_or_error from dbt.events.types import DepsScrubbedPackageName +from dbt.exceptions import DependencyError, env_secrets, scrub_secrets +from dbt_common.clients import system +from dbt_common.events.functions import warn_or_error from dbt_common.utils.connection import connection_exception_retry diff --git a/core/dbt/docs/source/_ext/dbt_click.py b/core/dbt/docs/source/_ext/dbt_click.py index 7343cc6a110..f51de96b7f5 100644 --- a/core/dbt/docs/source/_ext/dbt_click.py +++ b/core/dbt/docs/source/_ext/dbt_click.py @@ -1,11 +1,12 @@ +import traceback +import typing as t + import click import click.types as click_t -import dbt.cli.option_types as dbt_t from docutils import nodes from docutils.parsers.rst import Directive -import traceback -import typing as t +import dbt.cli.option_types as dbt_t PARAM_TYPE_MAP = { click_t.BoolParamType: lambda _: "boolean", diff --git a/core/dbt/docs/source/conf.py b/core/dbt/docs/source/conf.py index d9962bbfc8b..db6364a4266 100644 --- a/core/dbt/docs/source/conf.py +++ b/core/dbt/docs/source/conf.py @@ -1,5 +1,5 @@ -import sys import os +import sys import typing as t # Configuration file for the Sphinx documentation builder. diff --git a/core/dbt/events/__init__.py b/core/dbt/events/__init__.py index 8570ea527f7..123f242cae5 100644 --- a/core/dbt/events/__init__.py +++ b/core/dbt/events/__init__.py @@ -1,8 +1,8 @@ -from typing import Dict, Any, Set +from typing import Any, Dict, Set import dbt.adapters.events.types as adapter_dbt_event_types -import dbt_common.events.types as dbt_event_types import dbt.events.types as core_dbt_event_types +import dbt_common.events.types as dbt_event_types ALL_EVENT_TYPES: Dict[str, Any] = { **dbt_event_types.__dict__, diff --git a/core/dbt/events/base_types.py b/core/dbt/events/base_types.py index 39b45e9502e..a3ae0610849 100644 --- a/core/dbt/events/base_types.py +++ b/core/dbt/events/base_types.py @@ -1,14 +1,12 @@ # Aliasing common Level classes in order to make custom, but not overly-verbose versions that have PROTO_TYPES_MODULE set to the core-specific generated types_pb2 module -from dbt_common.events.base_types import ( - BaseEvent, - DynamicLevel as CommonDyanicLevel, - TestLevel as CommonTestLevel, - DebugLevel as CommonDebugLevel, - InfoLevel as CommonInfoLevel, - WarnLevel as CommonWarnLevel, - ErrorLevel as CommonErrorLevel, -) from dbt.events import core_types_pb2 +from dbt_common.events.base_types import BaseEvent +from dbt_common.events.base_types import DebugLevel as CommonDebugLevel +from dbt_common.events.base_types import DynamicLevel as CommonDyanicLevel +from dbt_common.events.base_types import ErrorLevel as CommonErrorLevel +from dbt_common.events.base_types import InfoLevel as CommonInfoLevel +from dbt_common.events.base_types import TestLevel as CommonTestLevel +from dbt_common.events.base_types import WarnLevel as CommonWarnLevel class CoreBaseEvent(BaseEvent): diff --git a/core/dbt/events/logging.py b/core/dbt/events/logging.py index 8b46908d7ef..68f2b2a0943 100644 --- a/core/dbt/events/logging.py +++ b/core/dbt/events/logging.py @@ -1,21 +1,21 @@ import os from functools import partial -from typing import List, Callable +from typing import Callable, List -from dbt_common.events.base_types import EventMsg, EventLevel +from dbt_common.events.base_types import EventLevel, EventMsg from dbt_common.events.event_manager_client import ( + add_logger_to_manager, cleanup_event_logger, get_event_manager, - add_logger_to_manager, ) from dbt_common.events.functions import ( - make_log_dir_if_missing, env_scrubber, - get_stdout_config, get_capture_stream, + get_stdout_config, + make_log_dir_if_missing, ) -from dbt_common.invocation import get_invocation_id from dbt_common.events.logger import LineFormat, LoggerConfig +from dbt_common.invocation import get_invocation_id # These are the logging events issued by the "clean" command, # where we can't count on having a log directory. We've removed diff --git a/core/dbt/events/types.py b/core/dbt/events/types.py index 8ca9c9279f2..15da4645133 100644 --- a/core/dbt/events/types.py +++ b/core/dbt/events/types.py @@ -1,15 +1,20 @@ import json from dbt.constants import MAXIMUM_SEED_SIZE_NAME, PIN_PACKAGE_URL -from dbt_common.ui import error_tag, warning_tag, line_wrap_message, green, yellow, red +from dbt.events.base_types import ( + DebugLevel, + DynamicLevel, + ErrorLevel, + InfoLevel, + WarnLevel, +) from dbt_common.events.base_types import EventLevel from dbt_common.events.format import ( format_fancy_output_line, - timestamp_to_datetime_string, pluralize, + timestamp_to_datetime_string, ) -from dbt.events.base_types import WarnLevel, InfoLevel, DebugLevel, ErrorLevel, DynamicLevel - +from dbt_common.ui import error_tag, green, line_wrap_message, red, warning_tag, yellow # Event codes have prefixes which follow this table # diff --git a/core/dbt/exceptions.py b/core/dbt/exceptions.py index ea44f0c055c..aec2b5e3826 100644 --- a/core/dbt/exceptions.py +++ b/core/dbt/exceptions.py @@ -1,24 +1,21 @@ +import io import json import re -import io -from typing import Any, Dict, List, Mapping, Optional, Union, TYPE_CHECKING +from typing import TYPE_CHECKING, Any, Dict, List, Mapping, Optional, Union +from dbt.node_types import REFABLE_NODE_TYPES, AccessType, NodeType +from dbt_common.constants import SECRET_ENV_PREFIX +from dbt_common.dataclass_schema import ValidationError from dbt_common.exceptions import ( - DbtRuntimeError, + CommandResultError, CompilationError, - DbtInternalError, DbtConfigError, + DbtInternalError, + DbtRuntimeError, + DbtValidationError, env_secrets, scrub_secrets, - DbtValidationError, - CommandResultError, ) -from dbt.node_types import NodeType, AccessType, REFABLE_NODE_TYPES - -from dbt_common.dataclass_schema import ValidationError - -from dbt_common.constants import SECRET_ENV_PREFIX - if TYPE_CHECKING: import agate diff --git a/core/dbt/flags.py b/core/dbt/flags.py index 7deb8966013..367e1007aa5 100644 --- a/core/dbt/flags.py +++ b/core/dbt/flags.py @@ -1,8 +1,8 @@ # Do not import the os package because we expose this package in jinja -from os import getenv as os_getenv from argparse import Namespace -from typing import Optional +from os import getenv as os_getenv from pathlib import Path +from typing import Optional # for setting up logger for legacy logger @@ -37,8 +37,8 @@ def get_flags(): def set_from_args(args: Namespace, project_flags): global GLOBAL_FLAGS - from dbt.cli.main import cli from dbt.cli.flags import Flags, convert_config + from dbt.cli.main import cli # we set attributes of args after initialize the flags, but project_flags # is being read in the Flags constructor, so we need to read it here and pass in diff --git a/core/dbt/graph/__init__.py b/core/dbt/graph/__init__.py index 67d979cc0fb..f89b1edfc69 100644 --- a/core/dbt/graph/__init__.py +++ b/core/dbt/graph/__init__.py @@ -1,17 +1,11 @@ +from .cli import parse_difference, parse_from_selectors_definition # noqa: F401 +from .graph import Graph, UniqueId # noqa: F401 +from .queue import GraphQueue # noqa: F401 +from .selector import NodeSelector, ResourceTypeSelector # noqa: F401 from .selector_spec import ( # noqa: F401 - SelectionUnion, - SelectionSpec, - SelectionIntersection, - SelectionDifference, SelectionCriteria, + SelectionDifference, + SelectionIntersection, + SelectionSpec, + SelectionUnion, ) -from .selector import ( # noqa: F401 - ResourceTypeSelector, - NodeSelector, -) -from .cli import ( # noqa: F401 - parse_difference, - parse_from_selectors_definition, -) -from .queue import GraphQueue # noqa: F401 -from .graph import Graph, UniqueId # noqa: F401 diff --git a/core/dbt/graph/cli.py b/core/dbt/graph/cli.py index 4d8ccef52a8..412ad54caae 100644 --- a/core/dbt/graph/cli.py +++ b/core/dbt/graph/cli.py @@ -1,22 +1,21 @@ # special support for CLI argument parsing. # TODO: Remove as part of https://github.com/dbt-labs/dbt-core/issues/6701 -from dbt.flags import get_flags -from copy import deepcopy import itertools -from dbt.clients.yaml_helper import yaml, Loader, Dumper # noqa: F401 - -from typing import Dict, List, Optional, Tuple, Any, Union +from copy import deepcopy +from typing import Any, Dict, List, Optional, Tuple, Union +from dbt.clients.yaml_helper import Dumper, Loader, yaml # noqa: F401 from dbt.contracts.selection import SelectorDefinition, SelectorFile +from dbt.flags import get_flags from dbt_common.exceptions import DbtInternalError, DbtValidationError from .selector_spec import ( - SelectionUnion, - SelectionSpec, - SelectionIntersection, - SelectionDifference, - SelectionCriteria, IndirectSelection, + SelectionCriteria, + SelectionDifference, + SelectionIntersection, + SelectionSpec, + SelectionUnion, ) INTERSECTION_DELIMITER = "," diff --git a/core/dbt/graph/graph.py b/core/dbt/graph/graph.py index 122e2f4d29a..87ba64414fb 100644 --- a/core/dbt/graph/graph.py +++ b/core/dbt/graph/graph.py @@ -1,7 +1,8 @@ -from typing import Set, Iterable, Iterator, Optional, NewType +from functools import partial from itertools import product +from typing import Iterable, Iterator, NewType, Optional, Set + import networkx as nx # type: ignore -from functools import partial from dbt_common.exceptions import DbtInternalError diff --git a/core/dbt/graph/queue.py b/core/dbt/graph/queue.py index 64b8c8438ab..cda16cd3126 100644 --- a/core/dbt/graph/queue.py +++ b/core/dbt/graph/queue.py @@ -1,19 +1,20 @@ -import networkx as nx # type: ignore import threading - from queue import PriorityQueue -from typing import Dict, Set, List, Generator, Optional +from typing import Dict, Generator, List, Optional, Set -from .graph import UniqueId +import networkx as nx # type: ignore + +from dbt.contracts.graph.manifest import Manifest from dbt.contracts.graph.nodes import ( - SourceDefinition, Exposure, - Metric, GraphMemberNode, + Metric, + SourceDefinition, ) -from dbt.contracts.graph.manifest import Manifest from dbt.node_types import NodeType +from .graph import UniqueId + class GraphQueue: """A fancy queue that is backed by the dependency graph. diff --git a/core/dbt/graph/selector.py b/core/dbt/graph/selector.py index 40ef6a1c9cc..6df9f352729 100644 --- a/core/dbt/graph/selector.py +++ b/core/dbt/graph/selector.py @@ -1,22 +1,18 @@ -from typing import Set, List, Optional, Tuple +from typing import List, Optional, Set, Tuple -from .graph import Graph, UniqueId -from .queue import GraphQueue -from .selector_methods import MethodManager -from .selector_spec import SelectionCriteria, SelectionSpec, IndirectSelection - -from dbt_common.events.functions import fire_event, warn_or_error -from dbt.events.types import SelectorReportInvalidSelector, NoNodesForSelectionCriteria -from dbt.node_types import NodeType -from dbt.exceptions import ( - DbtInternalError, - InvalidSelectorError, -) -from dbt.contracts.graph.nodes import GraphMemberNode +from dbt import selected_resources from dbt.contracts.graph.manifest import Manifest +from dbt.contracts.graph.nodes import GraphMemberNode from dbt.contracts.state import PreviousState +from dbt.events.types import NoNodesForSelectionCriteria, SelectorReportInvalidSelector +from dbt.exceptions import DbtInternalError, InvalidSelectorError +from dbt.node_types import NodeType +from dbt_common.events.functions import fire_event, warn_or_error -from dbt import selected_resources +from .graph import Graph, UniqueId +from .queue import GraphQueue +from .selector_methods import MethodManager +from .selector_spec import IndirectSelection, SelectionCriteria, SelectionSpec def get_package_names(nodes): diff --git a/core/dbt/graph/selector_methods.py b/core/dbt/graph/selector_methods.py index d5d16c5c5ca..11db223bb74 100644 --- a/core/dbt/graph/selector_methods.py +++ b/core/dbt/graph/selector_methods.py @@ -2,35 +2,41 @@ from fnmatch import fnmatch from itertools import chain from pathlib import Path -from typing import Set, List, Dict, Iterator, Tuple, Any, Union, Type, Optional, Callable - -from dbt_common.dataclass_schema import StrEnum - -from .graph import UniqueId +from typing import ( + Any, + Callable, + Dict, + Iterator, + List, + Optional, + Set, + Tuple, + Type, + Union, +) from dbt.contracts.graph.manifest import Manifest from dbt.contracts.graph.nodes import ( - SingularTestNode, Exposure, - Metric, GenericTestNode, - SourceDefinition, - ResultNode, ManifestNode, + Metric, ModelNode, - UnitTestDefinition, + ResultNode, SavedQuery, SemanticModel, + SingularTestNode, + SourceDefinition, + UnitTestDefinition, ) from dbt.contracts.graph.unparsed import UnparsedVersion from dbt.contracts.state import PreviousState -from dbt_common.exceptions import ( - DbtInternalError, - DbtRuntimeError, -) from dbt.node_types import NodeType +from dbt_common.dataclass_schema import StrEnum from dbt_common.events.contextvars import get_project_root +from dbt_common.exceptions import DbtInternalError, DbtRuntimeError +from .graph import UniqueId SELECTOR_GLOB = "*" SELECTOR_DELIMITER = ":" diff --git a/core/dbt/graph/selector_spec.py b/core/dbt/graph/selector_spec.py index 08448deb182..e801aef7396 100644 --- a/core/dbt/graph/selector_spec.py +++ b/core/dbt/graph/selector_spec.py @@ -2,16 +2,15 @@ import re from abc import ABCMeta, abstractmethod from dataclasses import dataclass -from dbt_common.dataclass_schema import StrEnum, dbtClassMixin - +from typing import Any, Dict, Iterable, Iterator, List, Optional, Set, Tuple, Union -from typing import Set, Iterator, List, Optional, Dict, Union, Any, Iterable, Tuple -from .graph import UniqueId -from .selector_methods import MethodName -from dbt_common.exceptions import DbtRuntimeError from dbt.exceptions import InvalidSelectorError from dbt.flags import get_flags +from dbt_common.dataclass_schema import StrEnum, dbtClassMixin +from dbt_common.exceptions import DbtRuntimeError +from .graph import UniqueId +from .selector_methods import MethodName RAW_SELECTOR_PATTERN = re.compile( r"\A" diff --git a/core/dbt/hooks.py b/core/dbt/hooks.py index c49d04d07b1..131b28a2449 100644 --- a/core/dbt/hooks.py +++ b/core/dbt/hooks.py @@ -1,7 +1,7 @@ -from dbt_common.dataclass_schema import StrEnum import json +from typing import Any, Dict, Union -from typing import Union, Dict, Any +from dbt_common.dataclass_schema import StrEnum class ModelHookType(StrEnum): diff --git a/core/dbt/internal_deprecations.py b/core/dbt/internal_deprecations.py index f85c65bf42b..22d389586f2 100644 --- a/core/dbt/internal_deprecations.py +++ b/core/dbt/internal_deprecations.py @@ -1,8 +1,8 @@ import functools from typing import Optional -from dbt_common.events.functions import warn_or_error from dbt.events.types import InternalDeprecation +from dbt_common.events.functions import warn_or_error def deprecated(suggested_action: str, version: str, reason: Optional[str]): diff --git a/core/dbt/logger.py b/core/dbt/logger.py index 33332417f2b..a3aef80f002 100644 --- a/core/dbt/logger.py +++ b/core/dbt/logger.py @@ -1,6 +1,3 @@ -import dbt.flags -import dbt_common.ui - import json import logging import sys @@ -8,10 +5,12 @@ import warnings from dataclasses import dataclass from datetime import datetime -from typing import Optional, List, ContextManager, Callable, Dict, Any, Set +from typing import Any, Callable, ContextManager, Dict, List, Optional, Set import logbook +import dbt.flags +import dbt_common.ui from dbt_common.context import get_invocation_context from dbt_common.dataclass_schema import dbtClassMixin diff --git a/core/dbt/mp_context.py b/core/dbt/mp_context.py index 19cefd99511..0a39fd4da96 100644 --- a/core/dbt/mp_context.py +++ b/core/dbt/mp_context.py @@ -1,7 +1,6 @@ from multiprocessing import get_context from multiprocessing.context import SpawnContext - _MP_CONTEXT = get_context("spawn") diff --git a/core/dbt/node_types.py b/core/dbt/node_types.py index 229c97352f3..52503f46ba2 100644 --- a/core/dbt/node_types.py +++ b/core/dbt/node_types.py @@ -1,7 +1,12 @@ from typing import List # preserving import path during dbt/artifacts refactor -from dbt.artifacts.resources.types import NodeType, AccessType, RunHookType, ModelLanguage # noqa +from dbt.artifacts.resources.types import ( # noqa + AccessType, + ModelLanguage, + NodeType, + RunHookType, +) EXECUTABLE_NODE_TYPES: List["NodeType"] = [ NodeType.Model, diff --git a/core/dbt/parser/__init__.py b/core/dbt/parser/__init__.py index ee0490ecb61..04f345fe107 100644 --- a/core/dbt/parser/__init__.py +++ b/core/dbt/parser/__init__.py @@ -1,24 +1,23 @@ -from .analysis import AnalysisParser # noqa -from .base import Parser, ConfiguredParser # noqa -from .singular_test import SingularTestParser # noqa -from .generic_test import GenericTestParser # noqa -from .docs import DocumentationParser # noqa -from .hooks import HookParser # noqa -from .macros import MacroParser # noqa -from .models import ModelParser # noqa -from .schemas import SchemaParser # noqa -from .seeds import SeedParser # noqa -from .snapshots import SnapshotParser # noqa - from . import ( # noqa analysis, base, - generic_test, - singular_test, docs, + generic_test, hooks, macros, models, schemas, + singular_test, snapshots, ) +from .analysis import AnalysisParser # noqa +from .base import ConfiguredParser, Parser # noqa +from .docs import DocumentationParser # noqa +from .generic_test import GenericTestParser # noqa +from .hooks import HookParser # noqa +from .macros import MacroParser # noqa +from .models import ModelParser # noqa +from .schemas import SchemaParser # noqa +from .seeds import SeedParser # noqa +from .singular_test import SingularTestParser # noqa +from .snapshots import SnapshotParser # noqa diff --git a/core/dbt/parser/base.py b/core/dbt/parser/base.py index e345a74183c..aabc29f5760 100644 --- a/core/dbt/parser/base.py +++ b/core/dbt/parser/base.py @@ -1,33 +1,30 @@ import abc import itertools import os -from typing import List, Dict, Any, Generic, Optional, TypeVar +from typing import Any, Dict, Generic, List, Optional, TypeVar -from dbt_common.dataclass_schema import ValidationError - -from dbt import utils -from dbt.clients.jinja import MacroGenerator -from dbt.context.providers import ( - generate_parser_model_context, - generate_generate_name_macro_context, -) +from dbt import hooks, utils from dbt.adapters.factory import get_adapter # noqa: F401 from dbt.artifacts.resources import Contract -from dbt.clients.jinja import get_rendered +from dbt.clients.jinja import MacroGenerator, get_rendered from dbt.config import Project, RuntimeConfig from dbt.context.context_config import ContextConfig +from dbt.context.providers import ( + generate_generate_name_macro_context, + generate_parser_model_context, +) from dbt.contracts.graph.manifest import Manifest from dbt.contracts.graph.nodes import BaseNode, ManifestNode from dbt.contracts.graph.unparsed import Docs, UnparsedNode from dbt.exceptions import ( - DbtInternalError, ConfigUpdateError, + DbtInternalError, DictParseError, InvalidAccessTypeError, ) -from dbt import hooks -from dbt.node_types import NodeType, ModelLanguage, AccessType +from dbt.node_types import AccessType, ModelLanguage, NodeType from dbt.parser.search import FileBlock +from dbt_common.dataclass_schema import ValidationError # internally, the parser may store a less-restrictive type that will be # transformed into the final type. But it will have to be derived from diff --git a/core/dbt/parser/common.py b/core/dbt/parser/common.py index a4f990147d2..5e5807a0335 100644 --- a/core/dbt/parser/common.py +++ b/core/dbt/parser/common.py @@ -1,21 +1,23 @@ +from dataclasses import dataclass +from typing import Any, Dict, Generic, List, Optional, TypeVar, Union + from dbt.artifacts.resources import ColumnInfo, NodeVersion -from dbt_common.contracts.constraints import ColumnLevelConstraint, ConstraintType +from dbt.contracts.graph.nodes import UnpatchedSourceDefinition from dbt.contracts.graph.unparsed import ( + HasColumnDocs, HasColumnProps, - UnparsedColumn, - UnparsedNodeUpdate, - UnparsedMacroUpdate, + HasColumnTests, UnparsedAnalysisUpdate, + UnparsedColumn, UnparsedExposure, + UnparsedMacroUpdate, UnparsedModelUpdate, + UnparsedNodeUpdate, ) -from dbt.contracts.graph.unparsed import HasColumnTests, HasColumnDocs -from dbt.contracts.graph.nodes import UnpatchedSourceDefinition +from dbt.exceptions import ParsingError from dbt.parser.search import FileBlock -from typing import List, Dict, Any, TypeVar, Generic, Union, Optional -from dataclasses import dataclass +from dbt_common.contracts.constraints import ColumnLevelConstraint, ConstraintType from dbt_common.exceptions import DbtInternalError -from dbt.exceptions import ParsingError def trimmed(inp: str) -> str: diff --git a/core/dbt/parser/docs.py b/core/dbt/parser/docs.py index edc7f83acfc..1bd7af5b55c 100644 --- a/core/dbt/parser/docs.py +++ b/core/dbt/parser/docs.py @@ -1,14 +1,12 @@ -from typing import Iterable, Optional - import re +from typing import Iterable, Optional from dbt.clients.jinja import get_rendered from dbt.contracts.files import SourceFile from dbt.contracts.graph.nodes import Documentation from dbt.node_types import NodeType from dbt.parser.base import Parser -from dbt.parser.search import BlockContents, FileBlock, BlockSearcher - +from dbt.parser.search import BlockContents, BlockSearcher, FileBlock SHOULD_PARSE_RE = re.compile(r"{[{%]") diff --git a/core/dbt/parser/fixtures.py b/core/dbt/parser/fixtures.py index b3002725674..b1469d0477d 100644 --- a/core/dbt/parser/fixtures.py +++ b/core/dbt/parser/fixtures.py @@ -1,6 +1,6 @@ -from typing import Optional, Dict, List, Any -from io import StringIO import csv +from io import StringIO +from typing import Any, Dict, List, Optional from dbt.contracts.files import FixtureSourceFile from dbt.contracts.graph.nodes import UnitTestFileFixture diff --git a/core/dbt/parser/generic_test.py b/core/dbt/parser/generic_test.py index 61dcc790163..3c10976fe30 100644 --- a/core/dbt/parser/generic_test.py +++ b/core/dbt/parser/generic_test.py @@ -2,14 +2,14 @@ import jinja2 -from dbt.exceptions import ParsingError -from dbt_common.clients import jinja +from dbt.contracts.files import SourceFile from dbt.contracts.graph.nodes import GenericTestNode, Macro from dbt.contracts.graph.unparsed import UnparsedMacro -from dbt.contracts.files import SourceFile +from dbt.exceptions import ParsingError from dbt.node_types import NodeType from dbt.parser.base import BaseParser from dbt.parser.search import FileBlock +from dbt_common.clients import jinja from dbt_common.utils import MACRO_PREFIX diff --git a/core/dbt/parser/generic_test_builders.py b/core/dbt/parser/generic_test_builders.py index bc9d75fc3c5..8a4864be82e 100644 --- a/core/dbt/parser/generic_test_builders.py +++ b/core/dbt/parser/generic_test_builders.py @@ -1,21 +1,11 @@ import re from copy import deepcopy -from typing import ( - Generic, - Dict, - Any, - Tuple, - Optional, - List, -) +from typing import Any, Dict, Generic, List, Optional, Tuple from dbt.artifacts.resources import NodeVersion -from dbt.clients.jinja import get_rendered, GENERIC_TEST_KWARGS_NAME +from dbt.clients.jinja import GENERIC_TEST_KWARGS_NAME, get_rendered from dbt.contracts.graph.nodes import UnpatchedSourceDefinition -from dbt.contracts.graph.unparsed import ( - UnparsedNodeUpdate, - UnparsedModelUpdate, -) +from dbt.contracts.graph.unparsed import UnparsedModelUpdate, UnparsedNodeUpdate from dbt.exceptions import ( CustomMacroPopulatingConfigValueError, SameKeyNestedError, @@ -24,13 +14,13 @@ TestArgIncludesModelError, TestArgsNotDictError, TestDefinitionDictLengthError, - TestTypeError, TestNameNotStringError, + TestTypeError, UnexpectedTestNamePatternError, ) -from dbt_common.exceptions.macros import UndefinedMacroError from dbt.parser.common import Testable from dbt.utils import md5 +from dbt_common.exceptions.macros import UndefinedMacroError def synthesize_generic_test_names( diff --git a/core/dbt/parser/hooks.py b/core/dbt/parser/hooks.py index c09df3f8fc7..f8efd6a5a75 100644 --- a/core/dbt/parser/hooks.py +++ b/core/dbt/parser/hooks.py @@ -1,14 +1,14 @@ from dataclasses import dataclass -from typing import Iterable, Iterator, Union, List, Tuple +from typing import Iterable, Iterator, List, Tuple, Union from dbt.context.context_config import ContextConfig from dbt.contracts.files import FilePath from dbt.contracts.graph.nodes import HookNode -from dbt_common.exceptions import DbtInternalError from dbt.node_types import NodeType, RunHookType from dbt.parser.base import SimpleParser from dbt.parser.search import FileBlock from dbt.utils import get_pseudo_hook_path +from dbt_common.exceptions import DbtInternalError @dataclass diff --git a/core/dbt/parser/macros.py b/core/dbt/parser/macros.py index 23a9bf53060..f7eaef62b69 100644 --- a/core/dbt/parser/macros.py +++ b/core/dbt/parser/macros.py @@ -2,15 +2,15 @@ import jinja2 -from dbt_common.clients import jinja from dbt.clients.jinja import get_supported_languages -from dbt.contracts.graph.unparsed import UnparsedMacro -from dbt.contracts.graph.nodes import Macro from dbt.contracts.files import FilePath, SourceFile +from dbt.contracts.graph.nodes import Macro +from dbt.contracts.graph.unparsed import UnparsedMacro from dbt.exceptions import ParsingError from dbt.node_types import NodeType from dbt.parser.base import BaseParser from dbt.parser.search import FileBlock, filesystem_search +from dbt_common.clients import jinja from dbt_common.utils import MACRO_PREFIX diff --git a/core/dbt/parser/manifest.py b/core/dbt/parser/manifest.py index 7dbb55c4a2a..adb1072107d 100644 --- a/core/dbt/parser/manifest.py +++ b/core/dbt/parser/manifest.py @@ -1,146 +1,124 @@ -from copy import deepcopy -from dataclasses import dataclass -from dataclasses import field import datetime +import json import os +import pprint +import time import traceback -from typing import ( - Dict, - Optional, - Mapping, - Callable, - Any, - List, - Type, - Union, - Tuple, - Set, -) +from copy import deepcopy +from dataclasses import dataclass, field from itertools import chain -import time +from typing import Any, Callable, Dict, List, Mapping, Optional, Set, Tuple, Type, Union -from dbt.context.query_header import generate_query_header_context -from dbt.contracts.graph.semantic_manifest import SemanticManifest -from dbt_common.events.base_types import EventLevel -from dbt_common.exceptions.base import DbtValidationError -import dbt_common.utils -import json -import pprint -from dbt.mp_context import get_mp_context import msgpack +from dbt_semantic_interfaces.enum_extension import assert_values_exhausted +from dbt_semantic_interfaces.type_enums import MetricType import dbt.deprecations import dbt.exceptions import dbt.tracking import dbt.utils -from dbt.flags import get_flags - +import dbt_common.utils +from dbt import plugins from dbt.adapters.factory import ( get_adapter, - get_relation_class_by_name, get_adapter_package_names, + get_relation_class_by_name, register_adapter, ) +from dbt.artifacts.resources import FileHash, NodeRelation, NodeVersion +from dbt.artifacts.schemas.base import Writable +from dbt.clients.jinja import MacroStack, get_rendered +from dbt.clients.jinja_static import statically_extract_macro_calls +from dbt.config import Project, RuntimeConfig from dbt.constants import ( MANIFEST_FILE_NAME, PARTIAL_PARSE_FILE_NAME, SEMANTIC_MANIFEST_FILE_NAME, ) -from dbt_common.constants import SECRET_ENV_PREFIX -from dbt_common.helper_types import PathSet -from dbt_common.events.functions import fire_event, get_invocation_id, warn_or_error -from dbt_common.events.types import ( - Note, -) -from dbt.events.types import ( - PartialParsingErrorProcessingFile, - PartialParsingError, - ParsePerfInfoPath, - PartialParsingSkipParsing, - UnableToPartialParse, - PartialParsingNotEnabled, - ParsedFileLoadFailed, - InvalidDisabledTargetInTestNode, - NodeNotFoundOrDisabled, - StateCheckVarsHash, - DeprecatedModel, - DeprecatedReference, - UpcomingReferenceDeprecation, - SpacesInResourceNameDeprecation, -) -from dbt.logger import DbtProcessState -from dbt.node_types import NodeType, AccessType -from dbt.clients.jinja import get_rendered, MacroStack -from dbt.clients.jinja_static import statically_extract_macro_calls -from dbt_common.clients.system import ( - make_directory, - path_exists, - read_json, - write_file, -) -from dbt.config import Project, RuntimeConfig +from dbt.context.configured import generate_macro_context from dbt.context.docs import generate_runtime_docs_context from dbt.context.macro_resolver import MacroResolver, TestMacroNamespace -from dbt.context.configured import generate_macro_context from dbt.context.providers import ParseProvider, generate_runtime_macro_context +from dbt.context.query_header import generate_query_header_context from dbt.contracts.files import ParseFileType, SchemaSourceFile -from dbt.parser.read_files import ( - ReadFilesFromFileSystem, - load_source_file, - FileDiff, - ReadFilesFromDiff, - ReadFiles, -) -from dbt.parser.partial import PartialParsing, special_override_macros from dbt.contracts.graph.manifest import ( - Manifest, Disabled, MacroManifest, + Manifest, ManifestStateCheck, ParsingInfo, ) from dbt.contracts.graph.nodes import ( - SourceDefinition, - Macro, Exposure, + Macro, + ManifestNode, Metric, + ModelNode, + ResultNode, SavedQuery, SeedNode, SemanticModel, - ManifestNode, - ResultNode, - ModelNode, + SourceDefinition, +) +from dbt.contracts.graph.semantic_manifest import SemanticManifest +from dbt.events.types import ( + DeprecatedModel, + DeprecatedReference, + InvalidDisabledTargetInTestNode, + NodeNotFoundOrDisabled, + ParsedFileLoadFailed, + ParsePerfInfoPath, + PartialParsingError, + PartialParsingErrorProcessingFile, + PartialParsingNotEnabled, + PartialParsingSkipParsing, + SpacesInResourceNameDeprecation, + StateCheckVarsHash, + UnableToPartialParse, + UpcomingReferenceDeprecation, ) -from dbt.artifacts.resources import NodeRelation, NodeVersion, FileHash -from dbt.artifacts.schemas.base import Writable from dbt.exceptions import ( - TargetNotFoundError, AmbiguousAliasError, InvalidAccessTypeError, + TargetNotFoundError, scrub_secrets, ) -from dbt.parser.base import Parser +from dbt.flags import get_flags +from dbt.logger import DbtProcessState +from dbt.mp_context import get_mp_context +from dbt.node_types import AccessType, NodeType from dbt.parser.analysis import AnalysisParser -from dbt.parser.generic_test import GenericTestParser -from dbt.parser.singular_test import SingularTestParser +from dbt.parser.base import Parser from dbt.parser.docs import DocumentationParser from dbt.parser.fixtures import FixtureParser +from dbt.parser.generic_test import GenericTestParser from dbt.parser.hooks import HookParser from dbt.parser.macros import MacroParser from dbt.parser.models import ModelParser +from dbt.parser.partial import PartialParsing, special_override_macros +from dbt.parser.read_files import ( + FileDiff, + ReadFiles, + ReadFilesFromDiff, + ReadFilesFromFileSystem, + load_source_file, +) from dbt.parser.schemas import SchemaParser from dbt.parser.search import FileBlock from dbt.parser.seeds import SeedParser +from dbt.parser.singular_test import SingularTestParser from dbt.parser.snapshots import SnapshotParser from dbt.parser.sources import SourcePatcher from dbt.parser.unit_tests import process_models_for_unit_test from dbt.version import __version__ - +from dbt_common.clients.system import make_directory, path_exists, read_json, write_file +from dbt_common.constants import SECRET_ENV_PREFIX from dbt_common.dataclass_schema import StrEnum, dbtClassMixin -from dbt import plugins - -from dbt_semantic_interfaces.enum_extension import assert_values_exhausted -from dbt_semantic_interfaces.type_enums import MetricType +from dbt_common.events.base_types import EventLevel +from dbt_common.events.functions import fire_event, get_invocation_id, warn_or_error +from dbt_common.events.types import Note +from dbt_common.exceptions.base import DbtValidationError +from dbt_common.helper_types import PathSet PARSING_STATE = DbtProcessState("parsing") PERF_INFO_FILE_NAME = "perf_info.json" diff --git a/core/dbt/parser/models.py b/core/dbt/parser/models.py index 20ad0ada34d..dc3ff334bf4 100644 --- a/core/dbt/parser/models.py +++ b/core/dbt/parser/models.py @@ -1,30 +1,30 @@ +# New for Python models :p +import ast +import random from copy import deepcopy -from dbt.artifacts.resources import RefArgs -from dbt.context.context_config import ContextConfig -from dbt.contracts.graph.nodes import ModelNode -from dbt.flags import get_flags -from dbt.node_types import NodeType, ModelLanguage -from dbt.parser.base import SimpleSQLParser -from dbt.parser.search import FileBlock -from dbt.clients.jinja import get_rendered -import dbt.tracking as tracking -from dbt import utils -from dbt_extractor import ExtractionError, py_extract_from_source # type: ignore from functools import reduce from itertools import chain -import random from typing import Any, Dict, Iterator, List, Optional, Tuple, Union -# New for Python models :p -import ast -from dbt_common.dataclass_schema import ValidationError +import dbt.tracking as tracking +from dbt import utils +from dbt.artifacts.resources import RefArgs +from dbt.clients.jinja import get_rendered +from dbt.context.context_config import ContextConfig +from dbt.contracts.graph.nodes import ModelNode from dbt.exceptions import ( ModelConfigError, ParsingError, PythonLiteralEvalError, PythonParsingError, ) +from dbt.flags import get_flags +from dbt.node_types import ModelLanguage, NodeType +from dbt.parser.base import SimpleSQLParser +from dbt.parser.search import FileBlock +from dbt_common.dataclass_schema import ValidationError from dbt_common.exceptions.macros import UndefinedMacroError +from dbt_extractor import ExtractionError, py_extract_from_source # type: ignore dbt_function_key_words = set(["ref", "source", "config", "get"]) dbt_function_full_names = set(["dbt.ref", "dbt.source", "dbt.config", "dbt.config.get"]) diff --git a/core/dbt/parser/partial.py b/core/dbt/parser/partial.py index f9c558be6ba..c5060745299 100644 --- a/core/dbt/parser/partial.py +++ b/core/dbt/parser/partial.py @@ -1,24 +1,20 @@ import os from copy import deepcopy -from typing import MutableMapping, Dict, List, Callable +from typing import Callable, Dict, List, MutableMapping -from dbt.contracts.graph.manifest import Manifest +from dbt.constants import DEFAULT_ENV_PLACEHOLDER from dbt.contracts.files import ( AnySourceFile, ParseFileType, - parse_file_type_to_parser, SchemaSourceFile, + parse_file_type_to_parser, ) +from dbt.contracts.graph.manifest import Manifest +from dbt.events.types import PartialParsingEnabled, PartialParsingFile +from dbt.node_types import NodeType from dbt_common.context import get_invocation_context -from dbt_common.events.functions import fire_event from dbt_common.events.base_types import EventLevel -from dbt.events.types import ( - PartialParsingEnabled, - PartialParsingFile, -) -from dbt.constants import DEFAULT_ENV_PLACEHOLDER -from dbt.node_types import NodeType - +from dbt_common.events.functions import fire_event mssat_files = ( ParseFileType.Model, diff --git a/core/dbt/parser/read_files.py b/core/dbt/parser/read_files.py index 314a2a0fdd1..e5e25841f06 100644 --- a/core/dbt/parser/read_files.py +++ b/core/dbt/parser/read_files.py @@ -1,26 +1,27 @@ import os -import pathspec # type: ignore import pathlib from dataclasses import dataclass, field -from dbt_common.clients.system import load_file_contents +from typing import Dict, List, Mapping, MutableMapping, Optional, Protocol + +import pathspec # type: ignore + +from dbt.config import Project from dbt.contracts.files import ( + AnySourceFile, + FileHash, FilePath, + FixtureSourceFile, ParseFileType, - SourceFile, - FileHash, - AnySourceFile, SchemaSourceFile, - FixtureSourceFile, + SourceFile, ) -from dbt.config import Project -from dbt_common.dataclass_schema import dbtClassMixin -from dbt.parser.schemas import yaml_from_file, schema_file_keys +from dbt.events.types import InputFileDiffError from dbt.exceptions import ParsingError +from dbt.parser.schemas import schema_file_keys, yaml_from_file from dbt.parser.search import filesystem_search -from typing import Optional, Dict, List, Mapping, MutableMapping -from dbt.events.types import InputFileDiffError +from dbt_common.clients.system import load_file_contents +from dbt_common.dataclass_schema import dbtClassMixin from dbt_common.events.functions import fire_event -from typing import Protocol @dataclass diff --git a/core/dbt/parser/schema_generic_tests.py b/core/dbt/parser/schema_generic_tests.py index be1f4a6e939..14e2dbc862a 100644 --- a/core/dbt/parser/schema_generic_tests.py +++ b/core/dbt/parser/schema_generic_tests.py @@ -1,38 +1,43 @@ -import pathlib import itertools import os +import pathlib +from typing import Any, Dict, List, Optional, Union -from typing import List, Dict, Optional, Union, Any +from dbt.adapters.factory import get_adapter, get_adapter_package_names from dbt.artifacts.resources import NodeVersion, RefArgs -from dbt.parser.base import SimpleParser -from dbt.parser.generic_test_builders import TestBuilder -from dbt.parser.search import FileBlock +from dbt.clients.jinja import add_rendered_test_kwargs, get_rendered +from dbt.context.configured import SchemaYamlVars, generate_schema_yml_context +from dbt.context.context_config import ContextConfig +from dbt.context.macro_resolver import MacroResolver from dbt.context.providers import generate_test_context +from dbt.contracts.files import FileHash +from dbt.contracts.graph.nodes import ( + GenericTestNode, + GraphMemberNode, + ManifestNode, + UnpatchedSourceDefinition, +) +from dbt.contracts.graph.unparsed import UnparsedColumn, UnparsedNodeUpdate +from dbt.exceptions import ( + CompilationError, + ParsingError, + SchemaConfigError, + TestConfigError, +) +from dbt.node_types import NodeType +from dbt.parser.base import SimpleParser from dbt.parser.common import ( - TestBlock, + GenericTestBlock, Testable, + TestBlock, TestDef, - GenericTestBlock, VersionedTestBlock, trimmed, ) -from dbt.contracts.graph.unparsed import UnparsedNodeUpdate, UnparsedColumn -from dbt.contracts.graph.nodes import ( - GenericTestNode, - UnpatchedSourceDefinition, - ManifestNode, - GraphMemberNode, -) -from dbt.context.context_config import ContextConfig -from dbt.context.configured import generate_schema_yml_context, SchemaYamlVars +from dbt.parser.generic_test_builders import TestBuilder +from dbt.parser.search import FileBlock +from dbt.utils import get_pseudo_test_path, md5 from dbt_common.dataclass_schema import ValidationError -from dbt.exceptions import SchemaConfigError, CompilationError, ParsingError, TestConfigError -from dbt.contracts.files import FileHash -from dbt.utils import md5, get_pseudo_test_path -from dbt.clients.jinja import get_rendered, add_rendered_test_kwargs -from dbt.adapters.factory import get_adapter, get_adapter_package_names -from dbt.node_types import NodeType -from dbt.context.macro_resolver import MacroResolver # This parser handles the tests that are defined in "schema" (yaml) files, on models, diff --git a/core/dbt/parser/schema_renderer.py b/core/dbt/parser/schema_renderer.py index 005f54f390e..3a0e1907593 100644 --- a/core/dbt/parser/schema_renderer.py +++ b/core/dbt/parser/schema_renderer.py @@ -1,4 +1,4 @@ -from typing import Dict, Any +from typing import Any, Dict from dbt.config.renderer import BaseRenderer, Keypath diff --git a/core/dbt/parser/schema_yaml_readers.py b/core/dbt/parser/schema_yaml_readers.py index b7c047d01dd..646de376763 100644 --- a/core/dbt/parser/schema_yaml_readers.py +++ b/core/dbt/parser/schema_yaml_readers.py @@ -1,31 +1,14 @@ -from dbt.parser.schemas import YamlReader, SchemaParser, ParseResult -from dbt.parser.common import YamlBlock -from dbt.node_types import NodeType -from dbt.contracts.graph.unparsed import ( - UnparsedDimension, - UnparsedDimensionTypeParams, - UnparsedEntity, - UnparsedExport, - UnparsedExposure, - UnparsedGroup, - UnparsedMeasure, - UnparsedMetric, - UnparsedMetricInput, - UnparsedMetricInputMeasure, - UnparsedMetricTypeParams, - UnparsedNonAdditiveDimension, - UnparsedQueryParams, - UnparsedSavedQuery, - UnparsedSemanticModel, - UnparsedConversionTypeParams, -) -from dbt.contracts.graph.nodes import ( - Exposure, - Group, - Metric, - SemanticModel, - SavedQuery, +from typing import Any, Dict, List, Optional, Union + +from dbt_semantic_interfaces.type_enums import ( + AggregationType, + ConversionCalculationType, + DimensionType, + EntityType, + MetricType, + TimeGranularity, ) + from dbt.artifacts.resources import ( ConversionTypeParams, Dimension, @@ -46,26 +29,41 @@ WhereFilter, WhereFilterIntersection, ) -from dbt_common.exceptions import DbtInternalError -from dbt.exceptions import YamlParseDictError, JSONValidationError -from dbt.context.providers import generate_parse_exposure, generate_parse_semantic_models - +from dbt.clients.jinja import get_rendered from dbt.context.context_config import ( BaseContextConfigGenerator, ContextConfigGenerator, UnrenderedConfigGenerator, ) -from dbt.clients.jinja import get_rendered -from dbt_common.dataclass_schema import ValidationError -from dbt_semantic_interfaces.type_enums import ( - AggregationType, - ConversionCalculationType, - DimensionType, - EntityType, - MetricType, - TimeGranularity, +from dbt.context.providers import ( + generate_parse_exposure, + generate_parse_semantic_models, ) -from typing import Any, Dict, List, Optional, Union +from dbt.contracts.graph.nodes import Exposure, Group, Metric, SavedQuery, SemanticModel +from dbt.contracts.graph.unparsed import ( + UnparsedConversionTypeParams, + UnparsedDimension, + UnparsedDimensionTypeParams, + UnparsedEntity, + UnparsedExport, + UnparsedExposure, + UnparsedGroup, + UnparsedMeasure, + UnparsedMetric, + UnparsedMetricInput, + UnparsedMetricInputMeasure, + UnparsedMetricTypeParams, + UnparsedNonAdditiveDimension, + UnparsedQueryParams, + UnparsedSavedQuery, + UnparsedSemanticModel, +) +from dbt.exceptions import JSONValidationError, YamlParseDictError +from dbt.node_types import NodeType +from dbt.parser.common import YamlBlock +from dbt.parser.schemas import ParseResult, SchemaParser, YamlReader +from dbt_common.dataclass_schema import ValidationError +from dbt_common.exceptions import DbtInternalError def parse_where_filter( diff --git a/core/dbt/parser/schemas.py b/core/dbt/parser/schemas.py index 68fafba85f5..c8f222e15c3 100644 --- a/core/dbt/parser/schemas.py +++ b/core/dbt/parser/schemas.py @@ -1,25 +1,19 @@ import datetime import time - from abc import ABCMeta, abstractmethod -from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, Type, TypeVar from dataclasses import dataclass, field +from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, Type, TypeVar from dbt import deprecations -from dbt_common.contracts.constraints import ConstraintType, ModelLevelConstraint -from dbt_common.dataclass_schema import ValidationError, dbtClassMixin - from dbt.clients.yaml_helper import load_yaml_text -from dbt.parser.schema_renderer import SchemaYamlRenderer -from dbt.parser.schema_generic_tests import SchemaGenericTestParser +from dbt.context.configured import SchemaYamlVars, generate_schema_yml_context from dbt.context.context_config import ContextConfig -from dbt.context.configured import generate_schema_yml_context, SchemaYamlVars from dbt.contracts.files import SchemaSourceFile from dbt.contracts.graph.nodes import ( - ParsedNodePatch, + ModelNode, ParsedMacroPatch, + ParsedNodePatch, UnpatchedSourceDefinition, - ModelNode, ) from dbt.contracts.graph.unparsed import ( HasColumnDocs, @@ -27,46 +21,49 @@ SourcePatch, UnparsedAnalysisUpdate, UnparsedMacroUpdate, - UnparsedNodeUpdate, UnparsedModelUpdate, + UnparsedNodeUpdate, UnparsedSourceDefinition, ) +from dbt.events.types import ( + MacroNotFoundForPatch, + NoNodeForYamlKey, + UnsupportedConstraintMaterialization, + ValidationWarning, + WrongResourceSchemaFile, +) from dbt.exceptions import ( + DbtInternalError, DuplicateMacroPatchNameError, DuplicatePatchPathError, DuplicateSourcePatchNameError, + InvalidAccessTypeError, JSONValidationError, - DbtInternalError, ParsingError, YamlLoadError, YamlParseDictError, YamlParseListError, - InvalidAccessTypeError, -) -from dbt_common.exceptions import DbtValidationError -from dbt_common.events.functions import warn_or_error -from dbt.events.types import ( - MacroNotFoundForPatch, - NoNodeForYamlKey, - ValidationWarning, - UnsupportedConstraintMaterialization, - WrongResourceSchemaFile, ) -from dbt.node_types import NodeType, AccessType +from dbt.node_types import AccessType, NodeType from dbt.parser.base import SimpleParser -from dbt.parser.search import FileBlock from dbt.parser.common import ( - YamlBlock, + ParserRef, TargetBlock, TestBlock, VersionedTestBlock, - ParserRef, + YamlBlock, trimmed, ) +from dbt.parser.schema_generic_tests import SchemaGenericTestParser +from dbt.parser.schema_renderer import SchemaYamlRenderer +from dbt.parser.search import FileBlock from dbt.utils import coerce_dict_str +from dbt_common.contracts.constraints import ConstraintType, ModelLevelConstraint +from dbt_common.dataclass_schema import ValidationError, dbtClassMixin +from dbt_common.events.functions import warn_or_error +from dbt_common.exceptions import DbtValidationError from dbt_common.utils import deep_merge - schema_file_keys = ( "models", "seeds", diff --git a/core/dbt/parser/search.py b/core/dbt/parser/search.py index 36289833240..444fb4439eb 100644 --- a/core/dbt/parser/search.py +++ b/core/dbt/parser/search.py @@ -1,13 +1,24 @@ import os from dataclasses import dataclass -from typing import List, Callable, Iterable, Set, Union, Iterator, TypeVar, Generic, Optional +from typing import ( + Callable, + Generic, + Iterable, + Iterator, + List, + Optional, + Set, + TypeVar, + Union, +) + from pathspec import PathSpec # type: ignore -from dbt_common.clients.jinja import extract_toplevel_blocks, BlockTag -from dbt_common.clients.system import find_matching from dbt.config import Project -from dbt.contracts.files import FilePath, AnySourceFile -from dbt.exceptions import ParsingError, DbtInternalError +from dbt.contracts.files import AnySourceFile, FilePath +from dbt.exceptions import DbtInternalError, ParsingError +from dbt_common.clients.jinja import BlockTag, extract_toplevel_blocks +from dbt_common.clients.system import find_matching # What's the point of wrapping a SourceFile with this class? diff --git a/core/dbt/parser/snapshots.py b/core/dbt/parser/snapshots.py index 27749a5e78b..259c4289817 100644 --- a/core/dbt/parser/snapshots.py +++ b/core/dbt/parser/snapshots.py @@ -1,14 +1,13 @@ import os from typing import List -from dbt_common.dataclass_schema import ValidationError - from dbt.contracts.graph.nodes import IntermediateSnapshotNode, SnapshotNode from dbt.exceptions import SnapshopConfigError from dbt.node_types import NodeType from dbt.parser.base import SQLParser from dbt.parser.search import BlockContents, BlockSearcher, FileBlock from dbt.utils import split_path +from dbt_common.dataclass_schema import ValidationError class SnapshotParser(SQLParser[IntermediateSnapshotNode, SnapshotNode]): diff --git a/core/dbt/parser/sources.py b/core/dbt/parser/sources.py index f94262aac03..5666a44da11 100644 --- a/core/dbt/parser/sources.py +++ b/core/dbt/parser/sources.py @@ -1,15 +1,11 @@ -from dataclasses import replace import itertools +from dataclasses import replace from pathlib import Path -from typing import Iterable, Dict, Optional, Set, Any, List +from typing import Any, Dict, Iterable, List, Optional, Set from dbt.adapters.capability import Capability from dbt.adapters.factory import get_adapter -from dbt.artifacts.resources import ( - FreshnessThreshold, - SourceConfig, - Time, -) +from dbt.artifacts.resources import FreshnessThreshold, SourceConfig, Time from dbt.config import RuntimeConfig from dbt.context.context_config import ( BaseContextConfigGenerator, @@ -18,25 +14,23 @@ ) from dbt.contracts.graph.manifest import Manifest, SourceKey from dbt.contracts.graph.nodes import ( - UnpatchedSourceDefinition, - SourceDefinition, GenericTestNode, + SourceDefinition, + UnpatchedSourceDefinition, ) from dbt.contracts.graph.unparsed import ( - UnparsedSourceDefinition, SourcePatch, SourceTablePatch, - UnparsedSourceTableDefinition, UnparsedColumn, + UnparsedSourceDefinition, + UnparsedSourceTableDefinition, ) -from dbt_common.events.functions import warn_or_error, fire_event -from dbt.events.types import UnusedTables, FreshnessConfigProblem - -from dbt_common.exceptions import DbtInternalError +from dbt.events.types import FreshnessConfigProblem, UnusedTables from dbt.node_types import NodeType - from dbt.parser.common import ParserRef from dbt.parser.schema_generic_tests import SchemaGenericTestParser +from dbt_common.events.functions import fire_event, warn_or_error +from dbt_common.exceptions import DbtInternalError # An UnparsedSourceDefinition is taken directly from the yaml diff --git a/core/dbt/parser/sql.py b/core/dbt/parser/sql.py index 5294f3657aa..ffd16ccc015 100644 --- a/core/dbt/parser/sql.py +++ b/core/dbt/parser/sql.py @@ -3,13 +3,13 @@ from typing import Iterable from dbt.contracts.graph.manifest import SourceFile -from dbt.contracts.graph.nodes import SqlNode, Macro +from dbt.contracts.graph.nodes import Macro, SqlNode from dbt.contracts.graph.unparsed import UnparsedMacro -from dbt_common.exceptions import DbtInternalError from dbt.node_types import NodeType from dbt.parser.base import SimpleSQLParser from dbt.parser.macros import MacroParser from dbt.parser.search import FileBlock +from dbt_common.exceptions import DbtInternalError @dataclass diff --git a/core/dbt/parser/unit_tests.py b/core/dbt/parser/unit_tests.py index 8e2dd58a00e..e80b6041b64 100644 --- a/core/dbt/parser/unit_tests.py +++ b/core/dbt/parser/unit_tests.py @@ -1,42 +1,41 @@ -from csv import DictReader -from copy import deepcopy -from pathlib import Path -from typing import List, Set, Dict, Any, Optional +import csv import os +from copy import deepcopy +from csv import DictReader from io import StringIO -import csv - -from dbt_extractor import py_extract_from_source, ExtractionError # type: ignore +from pathlib import Path +from typing import Any, Dict, List, Optional, Set from dbt import utils +from dbt.artifacts.resources import ModelConfig, UnitTestConfig, UnitTestFormat from dbt.config import RuntimeConfig from dbt.context.context_config import ContextConfig from dbt.context.providers import generate_parse_exposure, get_rendered from dbt.contracts.files import FileHash, SchemaSourceFile from dbt.contracts.graph.manifest import Manifest from dbt.contracts.graph.model_config import UnitTestNodeConfig -from dbt.artifacts.resources import ModelConfig, UnitTestConfig, UnitTestFormat from dbt.contracts.graph.nodes import ( + DependsOn, ModelNode, - UnitTestNode, UnitTestDefinition, - DependsOn, + UnitTestNode, UnitTestSourceDefinition, ) from dbt.contracts.graph.unparsed import UnparsedUnitTest -from dbt.exceptions import ParsingError, InvalidUnitTestGivenInput +from dbt.exceptions import InvalidUnitTestGivenInput, ParsingError from dbt.graph import UniqueId from dbt.node_types import NodeType from dbt.parser.schemas import ( + JSONValidationError, + ParseResult, SchemaParser, - YamlBlock, ValidationError, - JSONValidationError, + YamlBlock, YamlParseDictError, YamlReader, - ParseResult, ) from dbt.utils import get_pseudo_test_path +from dbt_extractor import ExtractionError, py_extract_from_source # type: ignore class UnitTestManifestLoader: diff --git a/core/dbt/plugins/__init__.py b/core/dbt/plugins/__init__.py index e6ed7198d80..37744d655e4 100644 --- a/core/dbt/plugins/__init__.py +++ b/core/dbt/plugins/__init__.py @@ -1,10 +1,7 @@ from typing import Optional -from .manager import PluginManager - # these are just exports, they need "noqa" so flake8 will not complain. -from .manager import dbtPlugin, dbt_hook # noqa - +from .manager import PluginManager, dbt_hook, dbtPlugin # noqa PLUGIN_MANAGER: Optional[PluginManager] = None diff --git a/core/dbt/plugins/contracts.py b/core/dbt/plugins/contracts.py index b0342c72a34..f6f5b4d6543 100644 --- a/core/dbt/plugins/contracts.py +++ b/core/dbt/plugins/contracts.py @@ -1,9 +1,9 @@ from typing import Dict # just exports, they need "noqa" so flake8 will not complain. -from dbt.artifacts.schemas.base import ArtifactMixin as PluginArtifact, schema_version # noqa +from dbt.artifacts.schemas.base import ArtifactMixin as PluginArtifact # noqa from dbt.artifacts.schemas.base import BaseArtifactMetadata # noqa -from dbt_common.dataclass_schema import dbtClassMixin, ExtensibleDbtClassMixin # noqa - +from dbt.artifacts.schemas.base import schema_version # noqa +from dbt_common.dataclass_schema import ExtensibleDbtClassMixin, dbtClassMixin # noqa PluginArtifacts = Dict[str, PluginArtifact] diff --git a/core/dbt/plugins/manager.py b/core/dbt/plugins/manager.py index 118d191f3af..5ef8b8fb735 100644 --- a/core/dbt/plugins/manager.py +++ b/core/dbt/plugins/manager.py @@ -2,14 +2,14 @@ import importlib import pkgutil from types import ModuleType -from typing import Dict, List, Callable, Mapping +from typing import Callable, Dict, List, Mapping +import dbt.tracking from dbt.contracts.graph.manifest import Manifest -from dbt_common.tests import test_caching_enabled -from dbt_common.exceptions import DbtRuntimeError from dbt.plugins.contracts import PluginArtifacts from dbt.plugins.manifest import PluginNodes -import dbt.tracking +from dbt_common.exceptions import DbtRuntimeError +from dbt_common.tests import test_caching_enabled def dbt_hook(func): diff --git a/core/dbt/plugins/manifest.py b/core/dbt/plugins/manifest.py index 9b1080e3afa..2c39599dba2 100644 --- a/core/dbt/plugins/manifest.py +++ b/core/dbt/plugins/manifest.py @@ -1,13 +1,13 @@ from dataclasses import dataclass, field from typing import Dict -from dbt.contracts.graph.node_args import ModelNodeArgs +from dbt.artifacts.resources import NodeVersion # noqa # all these are just exports, they need "noqa" so flake8 will not complain. from dbt.contracts.graph.manifest import Manifest # noqa -from dbt.node_types import AccessType, NodeType # noqa -from dbt.artifacts.resources import NodeVersion # noqa +from dbt.contracts.graph.node_args import ModelNodeArgs from dbt.graph.graph import UniqueId # noqa +from dbt.node_types import AccessType, NodeType # noqa @dataclass diff --git a/core/dbt/selected_resources.py b/core/dbt/selected_resources.py index 871cf059beb..74104fa6ef8 100644 --- a/core/dbt/selected_resources.py +++ b/core/dbt/selected_resources.py @@ -1,4 +1,4 @@ -from typing import Set, Any +from typing import Any, Set SELECTED_RESOURCES = [] diff --git a/core/dbt/task/base.py b/core/dbt/task/base.py index d4c206b023c..2a1944a63b9 100644 --- a/core/dbt/task/base.py +++ b/core/dbt/task/base.py @@ -8,46 +8,49 @@ from pathlib import Path from typing import Any, Dict, List, Optional, Set -from dbt.compilation import Compiler -import dbt_common.exceptions.base import dbt.exceptions +import dbt_common.exceptions.base from dbt import tracking +from dbt.artifacts.resources.types import NodeType +from dbt.artifacts.schemas.results import ( + NodeStatus, + RunningStatus, + RunStatus, + TimingInfo, + collect_timing_info, +) +from dbt.artifacts.schemas.run import RunResult from dbt.cli.flags import Flags +from dbt.compilation import Compiler from dbt.config import RuntimeConfig from dbt.config.profile import read_profile from dbt.constants import DBT_PROJECT_FILE_NAME from dbt.contracts.graph.manifest import Manifest -from dbt.artifacts.resources.types import NodeType -from dbt.artifacts.schemas.results import TimingInfo, collect_timing_info -from dbt.artifacts.schemas.results import NodeStatus, RunningStatus, RunStatus -from dbt.artifacts.schemas.run import RunResult -from dbt_common.events.contextvars import get_node_info -from dbt_common.events.functions import fire_event from dbt.events.types import ( - SkippingDetails, - NodeCompiling, - NodeExecuting, CatchableExceptionOnRun, - InternalErrorOnRun, GenericExceptionOnRun, - NodeConnectionReleaseError, + InternalErrorOnRun, + LogDbtProfileError, + LogDbtProjectError, LogDebugStackTrace, LogSkipBecauseError, -) -from dbt_common.exceptions import ( - DbtRuntimeError, - DbtInternalError, - CompilationError, - NotImplementedError, -) -from dbt.events.types import ( - LogDbtProjectError, - LogDbtProfileError, + NodeCompiling, + NodeConnectionReleaseError, + NodeExecuting, + SkippingDetails, ) from dbt.flags import get_flags from dbt.graph import Graph from dbt.logger import log_manager from dbt.task.printer import print_run_result_error +from dbt_common.events.contextvars import get_node_info +from dbt_common.events.functions import fire_event +from dbt_common.exceptions import ( + CompilationError, + DbtInternalError, + DbtRuntimeError, + NotImplementedError, +) def read_profiles(profiles_dir=None): diff --git a/core/dbt/task/build.py b/core/dbt/task/build.py index 57f11c71bd5..e3880f69a63 100644 --- a/core/dbt/task/build.py +++ b/core/dbt/task/build.py @@ -1,23 +1,24 @@ import threading from typing import Dict, List, Set -from .run import RunTask, ModelRunner as run_model_runner -from .snapshot import SnapshotRunner as snapshot_model_runner -from .seed import SeedRunner as seed_runner -from .test import TestRunner as test_runner - from dbt.artifacts.schemas.results import NodeStatus, RunStatus from dbt.artifacts.schemas.run import RunResult from dbt.cli.flags import Flags from dbt.config.runtime import RuntimeConfig from dbt.contracts.graph.manifest import Manifest -from dbt.graph import ResourceTypeSelector, GraphQueue, Graph +from dbt.events.types import LogNodeNoOpResult +from dbt.exceptions import DbtInternalError +from dbt.graph import Graph, GraphQueue, ResourceTypeSelector from dbt.node_types import NodeType -from dbt.task.test import TestSelector from dbt.task.base import BaseRunner, resource_types_from_args +from dbt.task.test import TestSelector from dbt_common.events.functions import fire_event -from dbt.events.types import LogNodeNoOpResult -from dbt.exceptions import DbtInternalError + +from .run import ModelRunner as run_model_runner +from .run import RunTask +from .seed import SeedRunner as seed_runner +from .snapshot import SnapshotRunner as snapshot_model_runner +from .test import TestRunner as test_runner class SavedQueryRunner(BaseRunner): diff --git a/core/dbt/task/clean.py b/core/dbt/task/clean.py index c4e98f5db2b..d7bfb92fc9a 100644 --- a/core/dbt/task/clean.py +++ b/core/dbt/task/clean.py @@ -2,19 +2,12 @@ from shutil import rmtree from dbt import deprecations -from dbt_common.events.functions import fire_event -from dbt.events.types import ( - CheckCleanPath, - ConfirmCleanPath, - FinishedCleanPaths, -) -from dbt_common.exceptions import DbtRuntimeError from dbt.cli.flags import Flags from dbt.config.project import Project -from dbt.task.base import ( - BaseTask, - move_to_nearest_project_dir, -) +from dbt.events.types import CheckCleanPath, ConfirmCleanPath, FinishedCleanPaths +from dbt.task.base import BaseTask, move_to_nearest_project_dir +from dbt_common.events.functions import fire_event +from dbt_common.exceptions import DbtRuntimeError class CleanTask(BaseTask): diff --git a/core/dbt/task/clone.py b/core/dbt/task/clone.py index 8bf5cf6112f..8edfdd02068 100644 --- a/core/dbt/task/clone.py +++ b/core/dbt/task/clone.py @@ -1,18 +1,18 @@ import threading -from typing import AbstractSet, Any, List, Iterable, Set, Optional +from typing import AbstractSet, Any, Iterable, List, Optional, Set from dbt.adapters.base import BaseRelation +from dbt.artifacts.schemas.run import RunResult, RunStatus from dbt.clients.jinja import MacroGenerator from dbt.context.providers import generate_runtime_model_context from dbt.contracts.graph.manifest import Manifest -from dbt.artifacts.schemas.run import RunStatus, RunResult -from dbt_common.dataclass_schema import dbtClassMixin -from dbt_common.exceptions import DbtInternalError, CompilationError from dbt.graph import ResourceTypeSelector from dbt.node_types import REFABLE_NODE_TYPES from dbt.task.base import BaseRunner, resource_types_from_args from dbt.task.run import _validate_materialization_relations_dict from dbt.task.runnable import GraphRunnableTask +from dbt_common.dataclass_schema import dbtClassMixin +from dbt_common.exceptions import CompilationError, DbtInternalError class CloneRunner(BaseRunner): diff --git a/core/dbt/task/compile.py b/core/dbt/task/compile.py index 4541dfd1567..5470c67c68d 100644 --- a/core/dbt/task/compile.py +++ b/core/dbt/task/compile.py @@ -1,22 +1,19 @@ import threading -from dbt.artifacts.schemas.run import RunStatus, RunResult -from dbt_common.events.base_types import EventLevel -from dbt_common.events.functions import fire_event -from dbt_common.events.types import Note -from dbt.events.types import ParseInlineNodeError, CompiledNode -from dbt_common.exceptions import ( - CompilationError, - DbtInternalError, - DbtBaseException as DbtException, -) - +from dbt.artifacts.schemas.run import RunResult, RunStatus +from dbt.events.types import CompiledNode, ParseInlineNodeError from dbt.graph import ResourceTypeSelector -from dbt.node_types import NodeType, EXECUTABLE_NODE_TYPES +from dbt.node_types import EXECUTABLE_NODE_TYPES, NodeType from dbt.parser.manifest import process_node from dbt.parser.sql import SqlBlockParser from dbt.task.base import BaseRunner from dbt.task.runnable import GraphRunnableTask +from dbt_common.events.base_types import EventLevel +from dbt_common.events.functions import fire_event +from dbt_common.events.types import Note +from dbt_common.exceptions import CompilationError +from dbt_common.exceptions import DbtBaseException as DbtException +from dbt_common.exceptions import DbtInternalError class CompileRunner(BaseRunner): diff --git a/core/dbt/task/debug.py b/core/dbt/task/debug.py index b388e4336ba..53eca1e53bc 100644 --- a/core/dbt/task/debug.py +++ b/core/dbt/task/debug.py @@ -3,34 +3,28 @@ import os import platform import sys - from collections import namedtuple from enum import Flag from pathlib import Path -from typing import Optional, Dict, Any, List, Tuple +from typing import Any, Dict, List, Optional, Tuple -from dbt_common.events.functions import fire_event -from dbt.events.types import ( - OpenCommand, - DebugCmdOut, - DebugCmdResult, -) -import dbt_common.clients.system import dbt.exceptions +import dbt_common.clients.system import dbt_common.exceptions from dbt.adapters.factory import get_adapter, register_adapter -from dbt.cli.flags import Flags -from dbt.config import PartialProject, Project, Profile -from dbt.config.renderer import DbtProjectYamlRenderer, ProfileRenderer from dbt.artifacts.schemas.results import RunStatus +from dbt.cli.flags import Flags from dbt.clients.yaml_helper import load_yaml_text +from dbt.config import PartialProject, Profile, Project +from dbt.config.renderer import DbtProjectYamlRenderer, ProfileRenderer +from dbt.events.types import DebugCmdOut, DebugCmdResult, OpenCommand from dbt.links import ProfileConfigDocs -from dbt_common.ui import green, red -from dbt_common.events.format import pluralize from dbt.mp_context import get_mp_context -from dbt.version import get_installed_version - from dbt.task.base import BaseTask, get_nearest_project_dir +from dbt.version import get_installed_version +from dbt_common.events.format import pluralize +from dbt_common.events.functions import fire_event +from dbt_common.ui import green, red ONLY_PROFILE_MESSAGE = """ A `dbt_project.yml` file was not found in this directory. diff --git a/core/dbt/task/deps.py b/core/dbt/task/deps.py index 0f8e45f073f..3e92154cf17 100644 --- a/core/dbt/task/deps.py +++ b/core/dbt/task/deps.py @@ -1,25 +1,21 @@ +import json from hashlib import sha1 -from typing import Any, Dict, Optional, List -import yaml from pathlib import Path -import dbt.utils +from typing import Any, Dict, List, Optional + +import yaml + import dbt.deprecations import dbt.exceptions -import json - +import dbt.utils +from dbt.config import Project +from dbt.config.project import load_yml_dict, package_config_from_data from dbt.config.renderer import PackageRenderer -from dbt.config.project import package_config_from_data, load_yml_dict from dbt.constants import PACKAGE_LOCK_FILE_NAME, PACKAGE_LOCK_HASH_KEY +from dbt.contracts.project import PackageSpec from dbt.deps.base import downloads_directory -from dbt.deps.resolver import resolve_lock_packages, resolve_packages from dbt.deps.registry import RegistryPinnedPackage -from dbt.contracts.project import PackageSpec - - -from dbt_common.events.functions import fire_event -from dbt_common.events.types import ( - Formatting, -) +from dbt.deps.resolver import resolve_lock_packages, resolve_packages from dbt.events.types import ( DepsAddPackage, DepsFoundDuplicatePackage, @@ -32,11 +28,10 @@ DepsUpdateAvailable, DepsUpToDate, ) -from dbt_common.clients import system - from dbt.task.base import BaseTask, move_to_nearest_project_dir - -from dbt.config import Project +from dbt_common.clients import system +from dbt_common.events.functions import fire_event +from dbt_common.events.types import Formatting class dbtPackageDumper(yaml.Dumper): diff --git a/core/dbt/task/docs/generate.py b/core/dbt/task/docs/generate.py index 800f997268d..7f238cf4e44 100644 --- a/core/dbt/task/docs/generate.py +++ b/core/dbt/task/docs/generate.py @@ -2,52 +2,48 @@ import shutil from dataclasses import replace from datetime import datetime -from typing import Dict, List, Any, Optional, Tuple, Set, Iterable -import agate from itertools import chain +from typing import Any, Dict, Iterable, List, Optional, Set, Tuple -import dbt_common.utils.formatting -from dbt_common.dataclass_schema import ValidationError -from dbt_common.clients.system import load_file_contents - -from dbt.task.docs import DOCS_INDEX_FILE_PATH -from dbt.task.compile import CompileTask +import agate +import dbt.compilation +import dbt.exceptions +import dbt.utils +import dbt_common.utils.formatting +from dbt.adapters.events.types import ( + BuildingCatalog, + CannotGenerateDocs, + CatalogWritten, + WriteCatalogFailure, +) from dbt.adapters.factory import get_adapter - -from dbt.graph.graph import UniqueId -from dbt.contracts.graph.nodes import ResultNode -from dbt.contracts.graph.manifest import Manifest -from dbt.artifacts.schemas.results import NodeStatus from dbt.artifacts.schemas.catalog import ( - TableMetadata, - CatalogTable, + CatalogArtifact, + CatalogKey, CatalogResults, + CatalogTable, + ColumnMetadata, PrimitiveDict, - CatalogKey, - StatsItem, StatsDict, - ColumnMetadata, - CatalogArtifact, + StatsItem, + TableMetadata, ) -from dbt_common.exceptions import DbtInternalError +from dbt.artifacts.schemas.results import NodeStatus +from dbt.constants import MANIFEST_FILE_NAME +from dbt.contracts.graph.manifest import Manifest +from dbt.contracts.graph.nodes import ResultNode from dbt.exceptions import AmbiguousCatalogMatchError from dbt.graph import ResourceTypeSelector +from dbt.graph.graph import UniqueId from dbt.node_types import EXECUTABLE_NODE_TYPES, NodeType -from dbt_common.events.functions import fire_event -from dbt.adapters.events.types import ( - WriteCatalogFailure, - CatalogWritten, - CannotGenerateDocs, - BuildingCatalog, -) from dbt.parser.manifest import write_manifest -import dbt.utils -import dbt.compilation -import dbt.exceptions -from dbt.constants import ( - MANIFEST_FILE_NAME, -) +from dbt.task.compile import CompileTask +from dbt.task.docs import DOCS_INDEX_FILE_PATH +from dbt_common.clients.system import load_file_contents +from dbt_common.dataclass_schema import ValidationError +from dbt_common.events.functions import fire_event +from dbt_common.exceptions import DbtInternalError CATALOG_FILENAME = "catalog.json" diff --git a/core/dbt/task/docs/serve.py b/core/dbt/task/docs/serve.py index c3e6fda61fa..b6aca15190c 100644 --- a/core/dbt/task/docs/serve.py +++ b/core/dbt/task/docs/serve.py @@ -6,8 +6,8 @@ import click -from dbt.task.docs import DOCS_INDEX_FILE_PATH from dbt.task.base import ConfiguredTask +from dbt.task.docs import DOCS_INDEX_FILE_PATH class ServeTask(ConfiguredTask): diff --git a/core/dbt/task/freshness.py b/core/dbt/task/freshness.py index aab7e44fbc1..e20671dc532 100644 --- a/core/dbt/task/freshness.py +++ b/core/dbt/task/freshness.py @@ -1,39 +1,32 @@ import os import threading import time -from typing import Optional, List, AbstractSet, Dict - -from .base import BaseRunner -from .printer import ( - print_run_result_error, -) -from .run import RunTask +from typing import AbstractSet, Dict, List, Optional +from dbt import deprecations +from dbt.adapters.base.impl import FreshnessResponse +from dbt.adapters.base.relation import BaseRelation +from dbt.adapters.capability import Capability +from dbt.adapters.contracts.connection import AdapterResponse from dbt.artifacts.schemas.freshness import ( FreshnessResult, + FreshnessStatus, PartialSourceFreshnessResult, SourceFreshnessResult, - FreshnessStatus, -) -from dbt_common.exceptions import DbtRuntimeError, DbtInternalError -from dbt_common.events.functions import fire_event -from dbt_common.events.types import Note -from dbt import deprecations -from dbt.events.types import ( - FreshnessCheckComplete, - LogStartLine, - LogFreshnessResult, ) +from dbt.contracts.graph.nodes import HookNode, SourceDefinition from dbt.contracts.results import RunStatus +from dbt.events.types import FreshnessCheckComplete, LogFreshnessResult, LogStartLine +from dbt.graph import ResourceTypeSelector from dbt.node_types import NodeType, RunHookType - -from dbt.adapters.capability import Capability -from dbt.adapters.contracts.connection import AdapterResponse -from dbt.adapters.base.relation import BaseRelation -from dbt.adapters.base.impl import FreshnessResponse -from dbt.contracts.graph.nodes import SourceDefinition, HookNode from dbt_common.events.base_types import EventLevel -from dbt.graph import ResourceTypeSelector +from dbt_common.events.functions import fire_event +from dbt_common.events.types import Note +from dbt_common.exceptions import DbtInternalError, DbtRuntimeError + +from .base import BaseRunner +from .printer import print_run_result_error +from .run import RunTask RESULT_FILE_NAME = "sources.json" diff --git a/core/dbt/task/init.py b/core/dbt/task/init.py index aa7e942c206..61d8f30e039 100644 --- a/core/dbt/task/init.py +++ b/core/dbt/task/init.py @@ -1,38 +1,35 @@ import copy import os -from pathlib import Path import re import shutil +from pathlib import Path from typing import Optional -import yaml import click +import yaml import dbt.config import dbt_common.clients.system +from dbt.adapters.factory import get_include_paths, load_plugin from dbt.config.profile import read_profile -from dbt_common.exceptions import DbtRuntimeError -from dbt.flags import get_flags -from dbt.version import _get_adapter_plugin_names -from dbt.adapters.factory import load_plugin, get_include_paths - from dbt.contracts.util import Identifier as ProjectName - -from dbt_common.events.functions import fire_event from dbt.events.types import ( - StarterProjectPath, ConfigFolderDirectory, + InvalidProfileTemplateYAML, NoSampleProfileFound, + ProfileWrittenWithProjectTemplateYAML, ProfileWrittenWithSample, ProfileWrittenWithTargetTemplateYAML, - ProfileWrittenWithProjectTemplateYAML, - SettingUpProfile, - InvalidProfileTemplateYAML, - ProjectNameAlreadyExists, ProjectCreated, + ProjectNameAlreadyExists, + SettingUpProfile, + StarterProjectPath, ) - +from dbt.flags import get_flags from dbt.task.base import BaseTask, move_to_nearest_project_dir +from dbt.version import _get_adapter_plugin_names +from dbt_common.events.functions import fire_event +from dbt_common.exceptions import DbtRuntimeError DOCS_URL = "https://docs.getdbt.com/docs/configure-your-profile" SLACK_URL = "https://community.getdbt.com/" @@ -55,7 +52,9 @@ class InitTask(BaseTask): def copy_starter_repo(self, project_name: str) -> None: # Lazy import to avoid ModuleNotFoundError - from dbt.include.starter_project import PACKAGE_PATH as starter_project_directory + from dbt.include.starter_project import ( + PACKAGE_PATH as starter_project_directory, + ) fire_event(StarterProjectPath(dir=starter_project_directory)) shutil.copytree( diff --git a/core/dbt/task/list.py b/core/dbt/task/list.py index e345bc78d94..11d1ed1049e 100644 --- a/core/dbt/task/list.py +++ b/core/dbt/task/list.py @@ -1,29 +1,26 @@ import json +from dbt.cli.flags import Flags +from dbt.config.runtime import RuntimeConfig +from dbt.contracts.graph.manifest import Manifest from dbt.contracts.graph.nodes import ( Exposure, - SourceDefinition, Metric, SavedQuery, SemanticModel, + SourceDefinition, UnitTestDefinition, ) -from dbt.cli.flags import Flags -from dbt.config.runtime import RuntimeConfig -from dbt.contracts.graph.manifest import Manifest +from dbt.events.types import ListCmdOut, NoNodesSelected from dbt.flags import get_flags from dbt.graph import ResourceTypeSelector +from dbt.node_types import NodeType from dbt.task.base import resource_types_from_args from dbt.task.runnable import GraphRunnableTask from dbt.task.test import TestSelector -from dbt.node_types import NodeType -from dbt_common.events.functions import ( - fire_event, - warn_or_error, -) -from dbt.events.types import NoNodesSelected, ListCmdOut -from dbt_common.exceptions import DbtRuntimeError, DbtInternalError from dbt_common.events.contextvars import task_contextvars +from dbt_common.events.functions import fire_event, warn_or_error +from dbt_common.exceptions import DbtInternalError, DbtRuntimeError class ListTask(GraphRunnableTask): diff --git a/core/dbt/task/printer.py b/core/dbt/task/printer.py index 1e4d37878ab..54c40b7fd03 100644 --- a/core/dbt/task/printer.py +++ b/core/dbt/task/printer.py @@ -1,27 +1,23 @@ from typing import Dict -from dbt.logger import ( - DbtStatusMessage, - TextOnly, -) -from dbt_common.events.functions import fire_event -from dbt_common.events.types import Formatting + +from dbt.artifacts.schemas.results import NodeStatus from dbt.events.types import ( - RunResultWarning, - RunResultWarningMessage, - RunResultFailure, - StatsLine, + CheckNodeTestFailure, + EndOfRunSummary, RunResultError, RunResultErrorNoMessage, + RunResultFailure, + RunResultWarning, + RunResultWarningMessage, SQLCompiledPath, - CheckNodeTestFailure, - EndOfRunSummary, + StatsLine, ) - +from dbt.logger import DbtStatusMessage, TextOnly +from dbt.node_types import NodeType from dbt.tracking import InvocationProcessor from dbt_common.events.format import pluralize - -from dbt.artifacts.schemas.results import NodeStatus -from dbt.node_types import NodeType +from dbt_common.events.functions import fire_event +from dbt_common.events.types import Formatting def get_counts(flat_nodes) -> str: diff --git a/core/dbt/task/retry.py b/core/dbt/task/retry.py index 57724f455e0..fd943b1151f 100644 --- a/core/dbt/task/retry.py +++ b/core/dbt/task/retry.py @@ -1,15 +1,16 @@ from pathlib import Path + from click import get_current_context from click.core import ParameterSource +from dbt.artifacts.schemas.results import NodeStatus from dbt.cli.flags import Flags -from dbt.flags import set_flags, get_flags from dbt.cli.types import Command as CliCommand from dbt.config import RuntimeConfig -from dbt.artifacts.schemas.results import NodeStatus from dbt.contracts.state import load_result_state -from dbt_common.exceptions import DbtRuntimeError +from dbt.flags import get_flags, set_flags from dbt.graph import GraphQueue +from dbt.parser.manifest import parse_manifest from dbt.task.base import ConfiguredTask from dbt.task.build import BuildTask from dbt.task.clone import CloneTask @@ -20,7 +21,7 @@ from dbt.task.seed import SeedTask from dbt.task.snapshot import SnapshotTask from dbt.task.test import TestTask -from dbt.parser.manifest import parse_manifest +from dbt_common.exceptions import DbtRuntimeError RETRYABLE_STATUSES = {NodeStatus.Error, NodeStatus.Fail, NodeStatus.Skipped, NodeStatus.RuntimeErr} IGNORE_PARENT_FLAGS = { diff --git a/core/dbt/task/run.py b/core/dbt/task/run.py index 89b392c63da..808f9596c67 100644 --- a/core/dbt/task/run.py +++ b/core/dbt/task/run.py @@ -1,61 +1,51 @@ import functools import threading import time -from typing import List, Dict, Any, Iterable, Set, Tuple, Optional, AbstractSet - -from dbt_common.dataclass_schema import dbtClassMixin - -from .compile import CompileRunner, CompileTask - -from .printer import ( - print_run_end_messages, - get_counts, -) from datetime import datetime -from dbt import tracking -from dbt import utils +from typing import AbstractSet, Any, Dict, Iterable, List, Optional, Set, Tuple + +from dbt import tracking, utils from dbt.adapters.base import BaseRelation +from dbt.adapters.events.types import ( + DatabaseErrorRunningHook, + FinishedRunningStats, + HooksRunning, +) +from dbt.adapters.exceptions import MissingMaterializationError +from dbt.artifacts.resources import Hook +from dbt.artifacts.schemas.results import ( + BaseResult, + NodeStatus, + RunningStatus, + RunStatus, +) +from dbt.artifacts.schemas.run import RunResult from dbt.cli.flags import Flags from dbt.clients.jinja import MacroGenerator from dbt.config.runtime import RuntimeConfig from dbt.context.providers import generate_runtime_model_context -from dbt.contracts.graph.nodes import HookNode, ResultNode from dbt.contracts.graph.manifest import Manifest -from dbt.artifacts.schemas.results import NodeStatus, RunStatus, RunningStatus, BaseResult -from dbt.artifacts.schemas.run import RunResult -from dbt.artifacts.resources import Hook -from dbt.exceptions import ( - CompilationError, - DbtInternalError, - DbtRuntimeError, -) -from dbt_common.exceptions import DbtValidationError -from dbt.adapters.exceptions import MissingMaterializationError -from dbt.adapters.events.types import ( - DatabaseErrorRunningHook, - HooksRunning, - FinishedRunningStats, -) -from dbt_common.events.contextvars import log_contextvars -from dbt_common.events.functions import fire_event, get_invocation_id -from dbt_common.events.types import Formatting -from dbt_common.events.base_types import EventLevel +from dbt.contracts.graph.nodes import HookNode, ResultNode from dbt.events.types import ( - LogModelResult, - LogStartLine, LogHookEndLine, LogHookStartLine, + LogModelResult, + LogStartLine, ) -from dbt.logger import ( - TextOnly, - HookMetadata, - UniqueID, - TimestampNamed, - DbtModelState, -) +from dbt.exceptions import CompilationError, DbtInternalError, DbtRuntimeError from dbt.graph import ResourceTypeSelector from dbt.hooks import get_hook_dict +from dbt.logger import DbtModelState, HookMetadata, TextOnly, TimestampNamed, UniqueID from dbt.node_types import NodeType, RunHookType +from dbt_common.dataclass_schema import dbtClassMixin +from dbt_common.events.base_types import EventLevel +from dbt_common.events.contextvars import log_contextvars +from dbt_common.events.functions import fire_event, get_invocation_id +from dbt_common.events.types import Formatting +from dbt_common.exceptions import DbtValidationError + +from .compile import CompileRunner, CompileTask +from .printer import get_counts, print_run_end_messages class Timer: diff --git a/core/dbt/task/run_operation.py b/core/dbt/task/run_operation.py index 1c6c5002e27..6f7cd7b64c0 100644 --- a/core/dbt/task/run_operation.py +++ b/core/dbt/task/run_operation.py @@ -6,19 +6,19 @@ import dbt_common.exceptions from dbt.adapters.factory import get_adapter +from dbt.artifacts.schemas.results import RunStatus, TimingInfo +from dbt.artifacts.schemas.run import RunResult, RunResultsArtifact from dbt.contracts.files import FileHash from dbt.contracts.graph.nodes import HookNode -from dbt.artifacts.schemas.results import RunStatus, TimingInfo -from dbt.artifacts.schemas.run import RunResultsArtifact, RunResult -from dbt_common.events.functions import fire_event from dbt.events.types import ( LogDebugStackTrace, RunningOperationCaughtError, RunningOperationUncaughtError, ) -from dbt_common.exceptions import DbtInternalError from dbt.node_types import NodeType from dbt.task.base import ConfiguredTask +from dbt_common.events.functions import fire_event +from dbt_common.exceptions import DbtInternalError RESULT_FILE_NAME = "run_results.json" diff --git a/core/dbt/task/runnable.py b/core/dbt/task/runnable.py index 82d4561ad93..99c2285d5c1 100644 --- a/core/dbt/task/runnable.py +++ b/core/dbt/task/runnable.py @@ -5,60 +5,64 @@ from datetime import datetime from multiprocessing.dummy import Pool as ThreadPool from pathlib import Path -from typing import AbstractSet, Optional, Dict, List, Set, Tuple, Iterable - -from dbt_common.context import get_invocation_context, _INVOCATION_CONTEXT_VAR -import dbt_common.utils.formatting +from typing import AbstractSet, Dict, Iterable, List, Optional, Set, Tuple import dbt.exceptions import dbt.tracking import dbt.utils +import dbt_common.utils.formatting from dbt.adapters.base import BaseRelation from dbt.adapters.factory import get_adapter +from dbt.artifacts.schemas.results import ( + BaseResult, + NodeStatus, + RunningStatus, + RunStatus, +) +from dbt.artifacts.schemas.run import RunExecutionResult, RunResult from dbt.cli.flags import Flags from dbt.config.runtime import RuntimeConfig from dbt.contracts.graph.manifest import Manifest from dbt.contracts.graph.nodes import ResultNode -from dbt.artifacts.schemas.results import NodeStatus, RunningStatus, RunStatus, BaseResult -from dbt.artifacts.schemas.run import RunExecutionResult, RunResult from dbt.contracts.state import PreviousState -from dbt_common.events.contextvars import log_contextvars, task_contextvars -from dbt_common.events.functions import fire_event, warn_or_error -from dbt_common.events.types import Formatting from dbt.events.types import ( - LogCancelLine, - DefaultSelector, - NodeStart, - NodeFinished, - QueryCancelationUnsupported, ConcurrencyLine, + DefaultSelector, EndRunResult, - NothingToDo, GenericExceptionOnRun, + LogCancelLine, + NodeFinished, + NodeStart, + NothingToDo, + QueryCancelationUnsupported, ) -from dbt.exceptions import ( - DbtInternalError, - DbtRuntimeError, - FailFastError, -) -from dbt_common.exceptions import NotImplementedError +from dbt.exceptions import DbtInternalError, DbtRuntimeError, FailFastError from dbt.flags import get_flags -from dbt.graph import GraphQueue, NodeSelector, SelectionSpec, parse_difference, UniqueId +from dbt.graph import ( + GraphQueue, + NodeSelector, + SelectionSpec, + UniqueId, + parse_difference, +) from dbt.logger import ( - DbtProcessState, - TextOnly, - UniqueID, - TimestampNamed, DbtModelState, + DbtProcessState, ModelMetadata, NodeCount, + TextOnly, + TimestampNamed, + UniqueID, ) from dbt.parser.manifest import write_manifest -from dbt.task.base import ConfiguredTask, BaseRunner -from .printer import ( - print_run_result_error, - print_run_end_messages, -) +from dbt.task.base import BaseRunner, ConfiguredTask +from dbt_common.context import _INVOCATION_CONTEXT_VAR, get_invocation_context +from dbt_common.events.contextvars import log_contextvars, task_contextvars +from dbt_common.events.functions import fire_event, warn_or_error +from dbt_common.events.types import Formatting +from dbt_common.exceptions import NotImplementedError + +from .printer import print_run_end_messages, print_run_result_error RESULT_FILE_NAME = "run_results.json" RUNNING_STATE = DbtProcessState("running") diff --git a/core/dbt/task/seed.py b/core/dbt/task/seed.py index ce8ba0f35b9..a5960cb931c 100644 --- a/core/dbt/task/seed.py +++ b/core/dbt/task/seed.py @@ -1,23 +1,17 @@ import random -from .run import ModelRunner, RunTask -from .printer import ( - print_run_end_messages, -) - -from dbt.artifacts.schemas.results import RunStatus, NodeStatus -from dbt_common.exceptions import DbtInternalError +from dbt.artifacts.schemas.results import NodeStatus, RunStatus +from dbt.events.types import LogSeedResult, LogStartLine, SeedHeader from dbt.graph import ResourceTypeSelector from dbt.logger import TextOnly +from dbt.node_types import NodeType +from dbt_common.events.base_types import EventLevel from dbt_common.events.functions import fire_event from dbt_common.events.types import Formatting -from dbt_common.events.base_types import EventLevel -from dbt.events.types import ( - SeedHeader, - LogSeedResult, - LogStartLine, -) -from dbt.node_types import NodeType +from dbt_common.exceptions import DbtInternalError + +from .printer import print_run_end_messages +from .run import ModelRunner, RunTask class SeedRunner(ModelRunner): diff --git a/core/dbt/task/show.py b/core/dbt/task/show.py index 608ba6fdebd..a7a367c279b 100644 --- a/core/dbt/task/show.py +++ b/core/dbt/task/show.py @@ -2,16 +2,16 @@ import threading import time +from dbt.artifacts.schemas.run import RunResult, RunStatus from dbt.context.providers import generate_runtime_model_context from dbt.contracts.graph.nodes import SeedNode -from dbt.artifacts.schemas.run import RunResult, RunStatus +from dbt.events.types import ShowNode +from dbt.task.compile import CompileRunner, CompileTask +from dbt.task.seed import SeedRunner from dbt_common.events.base_types import EventLevel from dbt_common.events.functions import fire_event from dbt_common.events.types import Note -from dbt.events.types import ShowNode from dbt_common.exceptions import DbtRuntimeError -from dbt.task.compile import CompileTask, CompileRunner -from dbt.task.seed import SeedRunner class ShowRunner(CompileRunner): diff --git a/core/dbt/task/snapshot.py b/core/dbt/task/snapshot.py index 728ea49851c..5604d9cc546 100644 --- a/core/dbt/task/snapshot.py +++ b/core/dbt/task/snapshot.py @@ -1,14 +1,14 @@ -from .run import ModelRunner, RunTask - -from dbt_common.exceptions import DbtInternalError -from dbt_common.events.functions import fire_event -from dbt_common.events.base_types import EventLevel +from dbt.artifacts.schemas.results import NodeStatus from dbt.events.types import LogSnapshotResult from dbt.graph import ResourceTypeSelector from dbt.node_types import NodeType -from dbt.artifacts.schemas.results import NodeStatus +from dbt_common.events.base_types import EventLevel +from dbt_common.events.functions import fire_event +from dbt_common.exceptions import DbtInternalError from dbt_common.utils import cast_dict_to_dict_of_strings +from .run import ModelRunner, RunTask + class SnapshotRunner(ModelRunner): def describe_node(self): diff --git a/core/dbt/task/sql.py b/core/dbt/task/sql.py index 6a9522133d0..a88d790bb96 100644 --- a/core/dbt/task/sql.py +++ b/core/dbt/task/sql.py @@ -1,20 +1,19 @@ +import traceback from abc import abstractmethod from datetime import datetime from typing import Generic, TypeVar -import traceback -import dbt_common.exceptions.base import dbt.exceptions +import dbt_common.exceptions.base from dbt.contracts.sql import ( RemoteCompileResult, RemoteCompileResultMixin, RemoteRunResult, ResultTable, ) -from dbt_common.events.functions import fire_event from dbt.events.types import SQLRunnerException from dbt.task.compile import CompileRunner - +from dbt_common.events.functions import fire_event SQLResult = TypeVar("SQLResult", bound=RemoteCompileResultMixin) diff --git a/core/dbt/task/test.py b/core/dbt/task/test.py index 8a82c7f1243..3be5f5c5504 100644 --- a/core/dbt/task/test.py +++ b/core/dbt/task/test.py @@ -1,46 +1,41 @@ -import daff import io import json import re -from dataclasses import dataclass -from dbt.utils import _coerce_decimal, strtobool -from dbt_common.events.format import pluralize -from dbt_common.dataclass_schema import dbtClassMixin import threading -from typing import Dict, Any, Optional, Union, List, TYPE_CHECKING, Tuple +from dataclasses import dataclass +from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union -from .compile import CompileRunner -from .run import RunTask +import daff +from dbt.adapters.exceptions import MissingMaterializationError +from dbt.artifacts.schemas.catalog import PrimitiveDict +from dbt.artifacts.schemas.results import TestStatus +from dbt.artifacts.schemas.run import RunResult +from dbt.clients.jinja import MacroGenerator +from dbt.context.providers import generate_runtime_model_context +from dbt.contracts.graph.manifest import Manifest from dbt.contracts.graph.nodes import ( + GenericTestNode, + SingularTestNode, TestNode, UnitTestDefinition, UnitTestNode, - GenericTestNode, - SingularTestNode, -) -from dbt.contracts.graph.manifest import Manifest -from dbt.artifacts.schemas.results import TestStatus -from dbt.artifacts.schemas.run import RunResult -from dbt.artifacts.schemas.catalog import PrimitiveDict -from dbt.context.providers import generate_runtime_model_context -from dbt.clients.jinja import MacroGenerator -from dbt_common.events.functions import fire_event -from dbt.events.types import ( - LogTestResult, - LogStartLine, -) -from dbt.exceptions import DbtInternalError, BooleanError -from dbt_common.exceptions import DbtBaseException, DbtRuntimeError -from dbt.adapters.exceptions import MissingMaterializationError -from dbt.graph import ( - ResourceTypeSelector, ) +from dbt.events.types import LogStartLine, LogTestResult +from dbt.exceptions import BooleanError, DbtInternalError +from dbt.flags import get_flags +from dbt.graph import ResourceTypeSelector from dbt.node_types import NodeType from dbt.parser.unit_tests import UnitTestManifestLoader -from dbt.flags import get_flags +from dbt.utils import _coerce_decimal, strtobool +from dbt_common.dataclass_schema import dbtClassMixin +from dbt_common.events.format import pluralize +from dbt_common.events.functions import fire_event +from dbt_common.exceptions import DbtBaseException, DbtRuntimeError from dbt_common.ui import green, red +from .compile import CompileRunner +from .run import RunTask if TYPE_CHECKING: import agate diff --git a/core/dbt/tests/fixtures/project.py b/core/dbt/tests/fixtures/project.py index 252f11116c1..501305ff0b0 100644 --- a/core/dbt/tests/fixtures/project.py +++ b/core/dbt/tests/fixtures/project.py @@ -1,32 +1,36 @@ import os +import random +import warnings +from argparse import Namespace +from datetime import datetime from pathlib import Path from typing import Mapping import pytest # type: ignore -import random -from argparse import Namespace -from datetime import datetime -import warnings import yaml -from dbt.mp_context import get_mp_context -from dbt.parser.manifest import ManifestLoader -from dbt_common.context import set_invocation_context -from dbt_common.exceptions import CompilationError, DbtDatabaseError -from dbt.context.providers import generate_runtime_macro_context import dbt.flags as flags -from dbt_common.tests import enable_test_caching +from dbt.adapters.factory import ( + get_adapter, + get_adapter_by_type, + register_adapter, + reset_adapters, +) from dbt.config.runtime import RuntimeConfig -from dbt.adapters.factory import get_adapter, register_adapter, reset_adapters, get_adapter_by_type -from dbt_common.events.event_manager_client import cleanup_event_logger +from dbt.context.providers import generate_runtime_macro_context from dbt.events.logging import setup_event_logger +from dbt.mp_context import get_mp_context +from dbt.parser.manifest import ManifestLoader from dbt.tests.util import ( - write_file, - run_sql_with_adapter, TestProcessingException, get_connection, + run_sql_with_adapter, + write_file, ) - +from dbt_common.context import set_invocation_context +from dbt_common.events.event_manager_client import cleanup_event_logger +from dbt_common.exceptions import CompilationError, DbtDatabaseError +from dbt_common.tests import enable_test_caching # These are the fixtures that are used in dbt core functional tests # diff --git a/core/dbt/tests/util.py b/core/dbt/tests/util.py index 437f25aa2e2..9376c0e9a2a 100644 --- a/core/dbt/tests/util.py +++ b/core/dbt/tests/util.py @@ -1,28 +1,29 @@ -from contextvars import ContextVar, copy_context -from io import StringIO +import json import os import shutil -import yaml -import json import warnings +from contextlib import contextmanager +from contextvars import ContextVar, copy_context from datetime import datetime +from io import StringIO from typing import Any, Dict, List, Optional -from contextlib import contextmanager -from dbt.adapters.factory import Adapter +import yaml + +from dbt.adapters.base.relation import BaseRelation +from dbt.adapters.factory import Adapter from dbt.cli.main import dbtRunner -from dbt.logger import log_manager from dbt.contracts.graph.manifest import Manifest +from dbt.logger import log_manager from dbt_common.context import _INVOCATION_CONTEXT_VAR, InvocationContext +from dbt_common.events.base_types import EventLevel from dbt_common.events.functions import ( - fire_event, capture_stdout_logs, - stop_capture_stdout_logs, + fire_event, reset_metadata_vars, + stop_capture_stdout_logs, ) -from dbt_common.events.base_types import EventLevel from dbt_common.events.types import Note -from dbt.adapters.base.relation import BaseRelation # ============================================================================= # Test utilities diff --git a/core/dbt/tracking.py b/core/dbt/tracking.py index ff7b9e7ebb9..689b12f1d61 100644 --- a/core/dbt/tracking.py +++ b/core/dbt/tracking.py @@ -15,8 +15,8 @@ from snowplow_tracker import logger as sp_logger from dbt import version as dbt_version +from dbt.adapters.exceptions import FailedToConnectError from dbt.clients.yaml_helper import safe_load, yaml # noqa:F401 -from dbt_common.events.functions import fire_event, get_invocation_id from dbt.events.types import ( DisableTracking, FlushEvents, @@ -26,7 +26,7 @@ SendingEvent, TrackingInitializeFailure, ) -from dbt.adapters.exceptions import FailedToConnectError +from dbt_common.events.functions import fire_event, get_invocation_id from dbt_common.exceptions import NotImplementedError sp_logger.setLevel(100) diff --git a/core/dbt/utils.py b/core/dbt/utils.py index 8f7509a5dec..065d9649479 100644 --- a/core/dbt/utils.py +++ b/core/dbt/utils.py @@ -3,34 +3,33 @@ import decimal import functools import itertools -import jinja2 import json import os -from pathlib import PosixPath, WindowsPath - -from dbt_common.utils import md5 -from dbt_common.exceptions import ( - RecursionError, -) -from dbt.exceptions import DuplicateAliasError -from dbt_common.helper_types import WarnErrorOptions -from dbt import flags from enum import Enum +from pathlib import PosixPath, WindowsPath from typing import ( - Tuple, - Type, + AbstractSet, Any, - Optional, Dict, - List, + Iterable, Iterator, + List, Mapping, - Iterable, - AbstractSet, - Set, + Optional, Sequence, + Set, + Tuple, + Type, ) +import jinja2 + +from dbt import flags +from dbt.exceptions import DuplicateAliasError +from dbt_common.exceptions import RecursionError +from dbt_common.helper_types import WarnErrorOptions +from dbt_common.utils import md5 + DECIMALS: Tuple[Type[Any], ...] try: import cdecimal # typing: ignore diff --git a/core/dbt/version.py b/core/dbt/version.py index 5d515185ae6..6ddbeafe2bf 100644 --- a/core/dbt/version.py +++ b/core/dbt/version.py @@ -3,12 +3,11 @@ import importlib.util import json import os -import requests - from typing import Iterator, List, Optional, Tuple -import dbt_common.semver as semver +import requests +import dbt_common.semver as semver from dbt_common.ui import green, red, yellow PYPI_VERSION_URL = "https://pypi.org/pypi/dbt-core/json" diff --git a/dev-requirements.txt b/dev-requirements.txt index c90f50ea531..be10d2c2384 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -11,6 +11,7 @@ flaky freezegun>=1.4.0,<1.5 hypothesis ipdb +isort>=5.12,<6 mypy==1.4.1 pip-tools pre-commit diff --git a/tests/fixtures/jaffle_shop.py b/tests/fixtures/jaffle_shop.py index 5ac17c81e1d..9b366ed2d5a 100644 --- a/tests/fixtures/jaffle_shop.py +++ b/tests/fixtures/jaffle_shop.py @@ -1,5 +1,7 @@ -import pytest import os + +import pytest + from dbt.tests.util import read_file # models/customers.sql diff --git a/tests/functional/access/test_access.py b/tests/functional/access/test_access.py index 8fa4f791d0f..5ef10c0e100 100644 --- a/tests/functional/access/test_access.py +++ b/tests/functional/access/test_access.py @@ -1,10 +1,10 @@ import pytest +from dbt.exceptions import DbtReferenceError, InvalidAccessTypeError +from dbt.node_types import AccessType from dbt.tests.fixtures.project import write_project_files +from dbt.tests.util import get_manifest, rm_file, run_dbt, write_file from tests.fixtures.dbt_integration_project import dbt_integration_project # noqa: F401 -from dbt.tests.util import run_dbt, get_manifest, write_file, rm_file -from dbt.node_types import AccessType -from dbt.exceptions import InvalidAccessTypeError, DbtReferenceError my_model_sql = "select 1 as fun" diff --git a/tests/functional/adapter/aliases/test_aliases.py b/tests/functional/adapter/aliases/test_aliases.py index d5f5b37152e..3e35518f06c 100644 --- a/tests/functional/adapter/aliases/test_aliases.py +++ b/tests/functional/adapter/aliases/test_aliases.py @@ -1,22 +1,23 @@ import pytest + from dbt.tests.util import run_dbt from tests.functional.adapter.aliases.fixtures import ( MACROS__CAST_SQL, MACROS__EXPECT_VALUE_SQL, - MODELS__SCHEMA_YML, - MODELS__FOO_ALIAS_SQL, MODELS__ALIAS_IN_PROJECT_SQL, MODELS__ALIAS_IN_PROJECT_WITH_OVERRIDE_SQL, + MODELS__FOO_ALIAS_SQL, MODELS__REF_FOO_ALIAS_SQL, + MODELS__SCHEMA_YML, MODELS_DUPE__MODEL_A_SQL, MODELS_DUPE__MODEL_B_SQL, - MODELS_DUPE_CUSTOM_SCHEMA__SCHEMA_YML, + MODELS_DUPE_CUSTOM_DATABASE__MODEL_A_SQL, + MODELS_DUPE_CUSTOM_DATABASE__MODEL_B_SQL, + MODELS_DUPE_CUSTOM_DATABASE__SCHEMA_YML, MODELS_DUPE_CUSTOM_SCHEMA__MODEL_A_SQL, MODELS_DUPE_CUSTOM_SCHEMA__MODEL_B_SQL, MODELS_DUPE_CUSTOM_SCHEMA__MODEL_C_SQL, - MODELS_DUPE_CUSTOM_DATABASE__SCHEMA_YML, - MODELS_DUPE_CUSTOM_DATABASE__MODEL_A_SQL, - MODELS_DUPE_CUSTOM_DATABASE__MODEL_B_SQL, + MODELS_DUPE_CUSTOM_SCHEMA__SCHEMA_YML, ) diff --git a/tests/functional/adapter/basic/test_adapter_methods.py b/tests/functional/adapter/basic/test_adapter_methods.py index aced1b21682..51d987f07de 100644 --- a/tests/functional/adapter/basic/test_adapter_methods.py +++ b/tests/functional/adapter/basic/test_adapter_methods.py @@ -1,8 +1,7 @@ import pytest -from dbt.tests.util import run_dbt, check_relations_equal from dbt.tests.fixtures.project import write_project_files - +from dbt.tests.util import check_relations_equal, run_dbt tests__get_columns_in_relation_sql = """ {% set columns = adapter.get_columns_in_relation(ref('model')) %} diff --git a/tests/functional/adapter/basic/test_base.py b/tests/functional/adapter/basic/test_base.py index 64edd03872e..98edd9926cc 100644 --- a/tests/functional/adapter/basic/test_base.py +++ b/tests/functional/adapter/basic/test_base.py @@ -1,17 +1,18 @@ import pytest + from dbt.tests.util import ( - run_dbt, - check_result_nodes_by_name, - relation_from_name, check_relation_types, check_relations_equal, + check_result_nodes_by_name, + relation_from_name, + run_dbt, ) from tests.functional.adapter.basic.files import ( - seeds_base_csv, - base_view_sql, - base_table_sql, base_materialized_var_sql, + base_table_sql, + base_view_sql, schema_base_yml, + seeds_base_csv, ) diff --git a/tests/functional/adapter/basic/test_docs_generate.py b/tests/functional/adapter/basic/test_docs_generate.py index 9b849160564..c6c070bf2a3 100644 --- a/tests/functional/adapter/basic/test_docs_generate.py +++ b/tests/functional/adapter/basic/test_docs_generate.py @@ -1,14 +1,15 @@ -import pytest import os from datetime import datetime -import dbt -from dbt.tests.util import run_dbt, rm_file, get_artifact, check_datetime_between +import pytest + +import dbt from dbt.tests.fixtures.project import write_project_files +from dbt.tests.util import check_datetime_between, get_artifact, rm_file, run_dbt from tests.functional.adapter.basic.expected_catalog import ( base_expected_catalog, - no_stats, expected_references_catalog, + no_stats, ) models__schema_yml = """ diff --git a/tests/functional/adapter/basic/test_empty.py b/tests/functional/adapter/basic/test_empty.py index 8bfe928686f..49941ae6f67 100644 --- a/tests/functional/adapter/basic/test_empty.py +++ b/tests/functional/adapter/basic/test_empty.py @@ -1,6 +1,7 @@ -from dbt.tests.util import run_dbt import os +from dbt.tests.util import run_dbt + class BaseEmpty: def test_empty(self, project): diff --git a/tests/functional/adapter/basic/test_ephemeral.py b/tests/functional/adapter/basic/test_ephemeral.py index 65a9e5af727..9b330b896cd 100644 --- a/tests/functional/adapter/basic/test_ephemeral.py +++ b/tests/functional/adapter/basic/test_ephemeral.py @@ -1,18 +1,20 @@ -import pytest import os + +import pytest + from dbt.tests.util import ( - run_dbt, - get_manifest, check_relations_equal, check_result_nodes_by_name, + get_manifest, relation_from_name, + run_dbt, ) from tests.functional.adapter.basic.files import ( - seeds_base_csv, base_ephemeral_sql, - ephemeral_view_sql, ephemeral_table_sql, + ephemeral_view_sql, schema_base_yml, + seeds_base_csv, ) diff --git a/tests/functional/adapter/basic/test_generic_tests.py b/tests/functional/adapter/basic/test_generic_tests.py index 0c71a197bb0..12c564609ab 100644 --- a/tests/functional/adapter/basic/test_generic_tests.py +++ b/tests/functional/adapter/basic/test_generic_tests.py @@ -1,13 +1,14 @@ import pytest + from dbt.tests.util import run_dbt from tests.functional.adapter.basic.files import ( - seeds_base_csv, - generic_test_seed_yml, - base_view_sql, base_table_sql, - schema_base_yml, - generic_test_view_yml, + base_view_sql, + generic_test_seed_yml, generic_test_table_yml, + generic_test_view_yml, + schema_base_yml, + seeds_base_csv, ) diff --git a/tests/functional/adapter/basic/test_incremental.py b/tests/functional/adapter/basic/test_incremental.py index 4d94ff17d2d..11eadddbb3f 100644 --- a/tests/functional/adapter/basic/test_incremental.py +++ b/tests/functional/adapter/basic/test_incremental.py @@ -1,12 +1,13 @@ import pytest -from dbt.tests.util import run_dbt, check_relations_equal, relation_from_name + from dbt.artifacts.schemas.results import RunStatus +from dbt.tests.util import check_relations_equal, relation_from_name, run_dbt from tests.functional.adapter.basic.files import ( - seeds_base_csv, - seeds_added_csv, - schema_base_yml, - incremental_sql, incremental_not_schema_change_sql, + incremental_sql, + schema_base_yml, + seeds_added_csv, + seeds_base_csv, ) diff --git a/tests/functional/adapter/basic/test_singular_tests.py b/tests/functional/adapter/basic/test_singular_tests.py index 3f9071cc56e..5f72adc0588 100644 --- a/tests/functional/adapter/basic/test_singular_tests.py +++ b/tests/functional/adapter/basic/test_singular_tests.py @@ -1,9 +1,7 @@ import pytest -from tests.functional.adapter.basic.files import ( - test_passing_sql, - test_failing_sql, -) + from dbt.tests.util import check_result_nodes_by_name, run_dbt +from tests.functional.adapter.basic.files import test_failing_sql, test_passing_sql class BaseSingularTests: diff --git a/tests/functional/adapter/basic/test_singular_tests_ephemeral.py b/tests/functional/adapter/basic/test_singular_tests_ephemeral.py index 6e2315d5fbd..43f693ab69c 100644 --- a/tests/functional/adapter/basic/test_singular_tests_ephemeral.py +++ b/tests/functional/adapter/basic/test_singular_tests_ephemeral.py @@ -1,12 +1,12 @@ import pytest -from dbt.tests.util import run_dbt, check_result_nodes_by_name +from dbt.tests.util import check_result_nodes_by_name, run_dbt from tests.functional.adapter.basic.files import ( - seeds_base_csv, ephemeral_with_cte_sql, - test_ephemeral_passing_sql, - test_ephemeral_failing_sql, schema_base_yml, + seeds_base_csv, + test_ephemeral_failing_sql, + test_ephemeral_passing_sql, ) diff --git a/tests/functional/adapter/basic/test_snapshot_check_cols.py b/tests/functional/adapter/basic/test_snapshot_check_cols.py index 29eb35c3bea..18c2e9f5fd5 100644 --- a/tests/functional/adapter/basic/test_snapshot_check_cols.py +++ b/tests/functional/adapter/basic/test_snapshot_check_cols.py @@ -1,11 +1,12 @@ import pytest -from dbt.tests.util import run_dbt, update_rows, relation_from_name + +from dbt.tests.util import relation_from_name, run_dbt, update_rows from tests.functional.adapter.basic.files import ( - seeds_base_csv, - seeds_added_csv, cc_all_snapshot_sql, cc_date_snapshot_sql, cc_name_snapshot_sql, + seeds_added_csv, + seeds_base_csv, ) diff --git a/tests/functional/adapter/basic/test_snapshot_timestamp.py b/tests/functional/adapter/basic/test_snapshot_timestamp.py index 7c227084336..7211ce28663 100644 --- a/tests/functional/adapter/basic/test_snapshot_timestamp.py +++ b/tests/functional/adapter/basic/test_snapshot_timestamp.py @@ -1,9 +1,10 @@ import pytest -from dbt.tests.util import run_dbt, relation_from_name, update_rows + +from dbt.tests.util import relation_from_name, run_dbt, update_rows from tests.functional.adapter.basic.files import ( + seeds_added_csv, seeds_base_csv, seeds_newcolumns_csv, - seeds_added_csv, ts_snapshot_sql, ) diff --git a/tests/functional/adapter/basic/test_table_materialization.py b/tests/functional/adapter/basic/test_table_materialization.py index 279152d6985..ec07e4f2c0b 100644 --- a/tests/functional/adapter/basic/test_table_materialization.py +++ b/tests/functional/adapter/basic/test_table_materialization.py @@ -1,7 +1,6 @@ import pytest -from dbt.tests.util import run_dbt, check_relations_equal - +from dbt.tests.util import check_relations_equal, run_dbt seeds__seed_csv = """id,first_name,last_name,email,gender,ip_address 1,Jack,Hunter,jhunter0@pbs.org,Male,59.80.20.168 diff --git a/tests/functional/adapter/catalog/relation_types.py b/tests/functional/adapter/catalog/relation_types.py index bbb3bed0a72..a73972b534d 100644 --- a/tests/functional/adapter/catalog/relation_types.py +++ b/tests/functional/adapter/catalog/relation_types.py @@ -1,7 +1,7 @@ -from dbt.artifacts.schemas.catalog import CatalogArtifact -from dbt.tests.util import run_dbt import pytest +from dbt.artifacts.schemas.catalog import CatalogArtifact +from dbt.tests.util import run_dbt from tests.functional.adapter.catalog import files diff --git a/tests/functional/adapter/column_types/test_column_types.py b/tests/functional/adapter/column_types/test_column_types.py index fd783a08ddc..7e028b33c5b 100644 --- a/tests/functional/adapter/column_types/test_column_types.py +++ b/tests/functional/adapter/column_types/test_column_types.py @@ -1,4 +1,5 @@ import pytest + from dbt.tests.util import run_dbt from tests.functional.adapter.column_types.fixtures import ( macro_test_is_type_sql, diff --git a/tests/functional/adapter/concurrency/test_concurrency.py b/tests/functional/adapter/concurrency/test_concurrency.py index 898deafa587..65932f95ea7 100644 --- a/tests/functional/adapter/concurrency/test_concurrency.py +++ b/tests/functional/adapter/concurrency/test_concurrency.py @@ -1,4 +1,5 @@ import pytest + from dbt.tests.util import ( check_relations_equal, check_table_does_not_exist, @@ -8,7 +9,6 @@ write_file, ) - models__invalid_sql = """ {{ config( diff --git a/tests/functional/adapter/constraints/test_constraints.py b/tests/functional/adapter/constraints/test_constraints.py index 894c451cda4..7fea5a7420f 100644 --- a/tests/functional/adapter/constraints/test_constraints.py +++ b/tests/functional/adapter/constraints/test_constraints.py @@ -1,43 +1,43 @@ -import pytest import re +import pytest + from dbt.tests.util import ( - run_dbt, get_manifest, - run_dbt_and_capture, - write_file, read_file, relation_from_name, + run_dbt, + run_dbt_and_capture, + write_file, ) - from tests.functional.adapter.constraints.fixtures import ( - my_model_sql, + constrained_model_schema_yml, + create_table_macro_sql, + foreign_key_model_sql, + incremental_foreign_key_model_raw_numbers_sql, + incremental_foreign_key_model_stg_numbers_sql, + incremental_foreign_key_schema_yml, + model_contract_header_schema_yml, + model_data_type_schema_yml, + model_fk_constraint_schema_yml, + model_quoted_column_schema_yml, + model_schema_yml, my_incremental_model_sql, - my_model_wrong_order_sql, - my_model_wrong_name_sql, + my_model_contract_sql_header_sql, my_model_data_type_sql, - model_data_type_schema_yml, - my_model_view_wrong_order_sql, - my_model_view_wrong_name_sql, - my_model_incremental_wrong_order_sql, + my_model_incremental_contract_sql_header_sql, + my_model_incremental_with_nulls_sql, my_model_incremental_wrong_name_sql, + my_model_incremental_wrong_order_depends_on_fk_sql, + my_model_incremental_wrong_order_sql, + my_model_sql, + my_model_view_wrong_name_sql, + my_model_view_wrong_order_sql, my_model_with_nulls_sql, - my_model_incremental_with_nulls_sql, my_model_with_quoted_column_name_sql, - model_schema_yml, - model_fk_constraint_schema_yml, - constrained_model_schema_yml, - model_quoted_column_schema_yml, - foreign_key_model_sql, + my_model_wrong_name_sql, my_model_wrong_order_depends_on_fk_sql, - my_model_incremental_wrong_order_depends_on_fk_sql, - my_model_contract_sql_header_sql, - my_model_incremental_contract_sql_header_sql, - model_contract_header_schema_yml, - create_table_macro_sql, - incremental_foreign_key_schema_yml, - incremental_foreign_key_model_raw_numbers_sql, - incremental_foreign_key_model_stg_numbers_sql, + my_model_wrong_order_sql, ) diff --git a/tests/functional/adapter/dbt_clone/test_dbt_clone.py b/tests/functional/adapter/dbt_clone/test_dbt_clone.py index d8ed00df986..9e5cb40a926 100644 --- a/tests/functional/adapter/dbt_clone/test_dbt_clone.py +++ b/tests/functional/adapter/dbt_clone/test_dbt_clone.py @@ -6,20 +6,20 @@ import pytest from dbt.exceptions import DbtRuntimeError +from dbt.tests.util import run_dbt, run_dbt_and_capture from tests.functional.adapter.dbt_clone.fixtures import ( - seed_csv, - table_model_sql, - view_model_sql, + custom_can_clone_tables_false_macros_sql, ephemeral_model_sql, exposures_yml, - schema_yml, - snapshot_sql, get_schema_name_sql, - macros_sql, infinite_macros_sql, - custom_can_clone_tables_false_macros_sql, + macros_sql, + schema_yml, + seed_csv, + snapshot_sql, + table_model_sql, + view_model_sql, ) -from dbt.tests.util import run_dbt, run_dbt_and_capture class BaseClone: diff --git a/tests/functional/adapter/dbt_debug/test_dbt_debug.py b/tests/functional/adapter/dbt_debug/test_dbt_debug.py index 3ad39e9c2ab..206c7598258 100644 --- a/tests/functional/adapter/dbt_debug/test_dbt_debug.py +++ b/tests/functional/adapter/dbt_debug/test_dbt_debug.py @@ -1,6 +1,7 @@ -import pytest import os import re + +import pytest import yaml from dbt.cli.exceptions import DbtUsageException diff --git a/tests/functional/adapter/dbt_show/test_dbt_show.py b/tests/functional/adapter/dbt_show/test_dbt_show.py index 4c5c1c18bac..08a494e031a 100644 --- a/tests/functional/adapter/dbt_show/test_dbt_show.py +++ b/tests/functional/adapter/dbt_show/test_dbt_show.py @@ -1,11 +1,11 @@ import pytest -from dbt.tests.util import run_dbt +from dbt.tests.util import run_dbt from tests.functional.adapter.dbt_show.fixtures import ( - models__sql_header, models__ephemeral_model, - models__second_ephemeral_model, models__sample_model, + models__second_ephemeral_model, + models__sql_header, seeds__sample_seed, ) diff --git a/tests/functional/adapter/ephemeral/test_ephemeral.py b/tests/functional/adapter/ephemeral/test_ephemeral.py index 22491f3b45d..665a12399a2 100644 --- a/tests/functional/adapter/ephemeral/test_ephemeral.py +++ b/tests/functional/adapter/ephemeral/test_ephemeral.py @@ -1,8 +1,9 @@ -import pytest -import re import os -from dbt.tests.util import run_dbt, check_relations_equal +import re + +import pytest +from dbt.tests.util import check_relations_equal, run_dbt models__dependent_sql = """ diff --git a/tests/functional/adapter/hooks/test_model_hooks.py b/tests/functional/adapter/hooks/test_model_hooks.py index 90ba298054a..1a4c01cb506 100644 --- a/tests/functional/adapter/hooks/test_model_hooks.py +++ b/tests/functional/adapter/hooks/test_model_hooks.py @@ -1,15 +1,10 @@ -import pytest - from pathlib import Path -from dbt_common.exceptions import CompilationError -from dbt.exceptions import ParsingError - -from dbt.tests.util import ( - run_dbt, - write_file, -) +import pytest +from dbt.exceptions import ParsingError +from dbt.tests.util import run_dbt, write_file +from dbt_common.exceptions import CompilationError from tests.functional.adapter.hooks.fixtures import ( models__hooked, models__hooks, diff --git a/tests/functional/adapter/hooks/test_run_hooks.py b/tests/functional/adapter/hooks/test_run_hooks.py index 6671e8cee19..f8bec5c6aeb 100644 --- a/tests/functional/adapter/hooks/test_run_hooks.py +++ b/tests/functional/adapter/hooks/test_run_hooks.py @@ -1,20 +1,16 @@ import os -import pytest - from pathlib import Path +import pytest + +from dbt.tests.util import check_table_does_not_exist, run_dbt from tests.functional.adapter.hooks.fixtures import ( - macros__hook, macros__before_and_after, - models__hooks, - seeds__example_seed_csv, + macros__hook, macros_missing_column, + models__hooks, models__missing_column, -) - -from dbt.tests.util import ( - check_table_does_not_exist, - run_dbt, + seeds__example_seed_csv, ) diff --git a/tests/functional/adapter/incremental/test_incremental_merge_exclude_columns.py b/tests/functional/adapter/incremental/test_incremental_merge_exclude_columns.py index db958f1eda4..7597865154c 100644 --- a/tests/functional/adapter/incremental/test_incremental_merge_exclude_columns.py +++ b/tests/functional/adapter/incremental/test_incremental_merge_exclude_columns.py @@ -1,7 +1,8 @@ -import pytest -from dbt.tests.util import run_dbt, check_relations_equal from collections import namedtuple +import pytest + +from dbt.tests.util import check_relations_equal, run_dbt models__merge_exclude_columns_sql = """ {{ config( diff --git a/tests/functional/adapter/incremental/test_incremental_on_schema_change.py b/tests/functional/adapter/incremental/test_incremental_on_schema_change.py index f5d415de3cd..8182e35dd38 100644 --- a/tests/functional/adapter/incremental/test_incremental_on_schema_change.py +++ b/tests/functional/adapter/incremental/test_incremental_on_schema_change.py @@ -1,23 +1,19 @@ import pytest -from dbt.tests.util import ( - check_relations_equal, - run_dbt, -) - +from dbt.tests.util import check_relations_equal, run_dbt from tests.functional.adapter.incremental.fixtures import ( - _MODELS__INCREMENTAL_SYNC_REMOVE_ONLY, + _MODELS__A, + _MODELS__INCREMENTAL_APPEND_NEW_COLUMNS, + _MODELS__INCREMENTAL_APPEND_NEW_COLUMNS_REMOVE_ONE, + _MODELS__INCREMENTAL_APPEND_NEW_COLUMNS_REMOVE_ONE_TARGET, + _MODELS__INCREMENTAL_APPEND_NEW_COLUMNS_TARGET, + _MODELS__INCREMENTAL_FAIL, _MODELS__INCREMENTAL_IGNORE, - _MODELS__INCREMENTAL_SYNC_REMOVE_ONLY_TARGET, _MODELS__INCREMENTAL_IGNORE_TARGET, - _MODELS__INCREMENTAL_FAIL, _MODELS__INCREMENTAL_SYNC_ALL_COLUMNS, - _MODELS__INCREMENTAL_APPEND_NEW_COLUMNS_REMOVE_ONE, - _MODELS__A, - _MODELS__INCREMENTAL_APPEND_NEW_COLUMNS_TARGET, - _MODELS__INCREMENTAL_APPEND_NEW_COLUMNS, _MODELS__INCREMENTAL_SYNC_ALL_COLUMNS_TARGET, - _MODELS__INCREMENTAL_APPEND_NEW_COLUMNS_REMOVE_ONE_TARGET, + _MODELS__INCREMENTAL_SYNC_REMOVE_ONLY, + _MODELS__INCREMENTAL_SYNC_REMOVE_ONLY_TARGET, ) diff --git a/tests/functional/adapter/incremental/test_incremental_predicates.py b/tests/functional/adapter/incremental/test_incremental_predicates.py index 2060e9eb6d4..f6eaf67fb17 100644 --- a/tests/functional/adapter/incremental/test_incremental_predicates.py +++ b/tests/functional/adapter/incremental/test_incremental_predicates.py @@ -1,7 +1,8 @@ -import pytest -from dbt.tests.util import run_dbt, check_relations_equal from collections import namedtuple +import pytest + +from dbt.tests.util import check_relations_equal, run_dbt models__delete_insert_incremental_predicates_sql = """ {{ config( diff --git a/tests/functional/adapter/incremental/test_incremental_unique_id.py b/tests/functional/adapter/incremental/test_incremental_unique_id.py index e08e332ad3e..194d35db56f 100644 --- a/tests/functional/adapter/incremental/test_incremental_unique_id.py +++ b/tests/functional/adapter/incremental/test_incremental_unique_id.py @@ -1,9 +1,11 @@ -import pytest -from dbt.tests.util import run_dbt, check_relations_equal -from dbt.artifacts.schemas.results import RunStatus from collections import namedtuple from pathlib import Path +import pytest + +from dbt.artifacts.schemas.results import RunStatus +from dbt.tests.util import check_relations_equal, run_dbt + models__trinary_unique_key_list_sql = """ -- a multi-argument unique key list should see overwriting on rows in the model -- where all unique key fields apply diff --git a/tests/functional/adapter/materialized_view/basic.py b/tests/functional/adapter/materialized_view/basic.py index 518522a4631..1d82977ae64 100644 --- a/tests/functional/adapter/materialized_view/basic.py +++ b/tests/functional/adapter/materialized_view/basic.py @@ -11,7 +11,6 @@ run_dbt_and_capture, set_model_file, ) - from tests.functional.adapter.materialized_view.files import ( MY_MATERIALIZED_VIEW, MY_SEED, diff --git a/tests/functional/adapter/materialized_view/changes.py b/tests/functional/adapter/materialized_view/changes.py index 243b1e34995..7005a5e0b26 100644 --- a/tests/functional/adapter/materialized_view/changes.py +++ b/tests/functional/adapter/materialized_view/changes.py @@ -3,7 +3,6 @@ import pytest from dbt.adapters.base.relation import BaseRelation -from dbt_common.contracts.config.materialization import OnConfigurationChangeOption from dbt.adapters.contracts.relation import RelationType from dbt.tests.util import ( assert_message_in_logs, @@ -12,7 +11,7 @@ run_dbt_and_capture, set_model_file, ) - +from dbt_common.contracts.config.materialization import OnConfigurationChangeOption from tests.functional.adapter.materialized_view.files import ( MY_MATERIALIZED_VIEW, MY_SEED, diff --git a/tests/functional/adapter/persist_docs/test_persist_docs.py b/tests/functional/adapter/persist_docs/test_persist_docs.py index aa311eba9f2..3f4521e69e5 100644 --- a/tests/functional/adapter/persist_docs/test_persist_docs.py +++ b/tests/functional/adapter/persist_docs/test_persist_docs.py @@ -1,9 +1,9 @@ import json import os + import pytest from dbt.tests.util import run_dbt - from tests.functional.adapter.persist_docs.fixtures import ( _DOCS__MY_FUN_DOCS, _MODELS__MISSING_COLUMN, @@ -11,8 +11,8 @@ _MODELS__NO_DOCS_MODEL, _MODELS__TABLE, _MODELS__VIEW, - _PROPERTIES__QUOTE_MODEL, _PROPERITES__SCHEMA_MISSING_COL, + _PROPERTIES__QUOTE_MODEL, _PROPERTIES__SCHEMA_YML, _SEEDS__SEED, ) diff --git a/tests/functional/adapter/python_model/test_python_model.py b/tests/functional/adapter/python_model/test_python_model.py index 259895abde9..bba537bb2fb 100644 --- a/tests/functional/adapter/python_model/test_python_model.py +++ b/tests/functional/adapter/python_model/test_python_model.py @@ -1,6 +1,8 @@ -import pytest import os + +import pytest import yaml + from dbt.tests.util import run_dbt basic_sql = """ diff --git a/tests/functional/adapter/python_model/test_spark.py b/tests/functional/adapter/python_model/test_spark.py index 7e105a957d3..2c5148e84fd 100644 --- a/tests/functional/adapter/python_model/test_spark.py +++ b/tests/functional/adapter/python_model/test_spark.py @@ -1,4 +1,5 @@ import pytest + from dbt.tests.util import run_dbt PANDAS_MODEL = """ diff --git a/tests/functional/adapter/query_comment/test_query_comment.py b/tests/functional/adapter/query_comment/test_query_comment.py index 5651e54b39b..32dba5a1695 100644 --- a/tests/functional/adapter/query_comment/test_query_comment.py +++ b/tests/functional/adapter/query_comment/test_query_comment.py @@ -1,8 +1,13 @@ -import pytest import json + +import pytest + from dbt.exceptions import DbtRuntimeError from dbt.tests.util import run_dbt_and_capture -from tests.functional.adapter.query_comment.fixtures import MACROS__MACRO_SQL, MODELS__X_SQL +from tests.functional.adapter.query_comment.fixtures import ( + MACROS__MACRO_SQL, + MODELS__X_SQL, +) class BaseDefaultQueryComments: diff --git a/tests/functional/adapter/relations/test_changing_relation_type.py b/tests/functional/adapter/relations/test_changing_relation_type.py index 2eeb5aea64d..a9b719f7d92 100644 --- a/tests/functional/adapter/relations/test_changing_relation_type.py +++ b/tests/functional/adapter/relations/test_changing_relation_type.py @@ -1,9 +1,9 @@ from typing import List, Optional + import pytest from dbt.tests.util import run_dbt - _DEFAULT_CHANGE_RELATION_TYPE_MODEL = """ {{ config(materialized=var('materialized')) }} diff --git a/tests/functional/adapter/relations/test_dropping_schema_named.py b/tests/functional/adapter/relations/test_dropping_schema_named.py index 2999d43fec6..d626ba46992 100644 --- a/tests/functional/adapter/relations/test_dropping_schema_named.py +++ b/tests/functional/adapter/relations/test_dropping_schema_named.py @@ -1,6 +1,6 @@ import pytest -from dbt.tests.util import run_dbt, get_connection +from dbt.tests.util import get_connection, run_dbt class BaseDropSchemaNamed: diff --git a/tests/functional/adapter/simple_copy/test_copy_uppercase.py b/tests/functional/adapter/simple_copy/test_copy_uppercase.py index 277f592fb0e..931f485924f 100644 --- a/tests/functional/adapter/simple_copy/test_copy_uppercase.py +++ b/tests/functional/adapter/simple_copy/test_copy_uppercase.py @@ -1,18 +1,18 @@ import pytest -from dbt.tests.util import run_dbt, check_relations_equal +from dbt.tests.util import check_relations_equal, run_dbt from tests.functional.adapter.simple_copy.fixtures import ( - _PROPERTIES__SCHEMA_YML, - _SEEDS__SEED_INITIAL, _MODELS__ADVANCED_INCREMENTAL, _MODELS__COMPOUND_SORT, _MODELS__DISABLED, _MODELS__EMPTY, - _MODELS_GET_AND_REF_UPPERCASE, _MODELS__INCREMENTAL, _MODELS__INTERLEAVED_SORT, _MODELS__MATERIALIZED, _MODELS__VIEW_MODEL, + _MODELS_GET_AND_REF_UPPERCASE, + _PROPERTIES__SCHEMA_YML, + _SEEDS__SEED_INITIAL, ) diff --git a/tests/functional/adapter/simple_copy/test_simple_copy.py b/tests/functional/adapter/simple_copy/test_simple_copy.py index 77494b6b679..c86e7f4b01a 100644 --- a/tests/functional/adapter/simple_copy/test_simple_copy.py +++ b/tests/functional/adapter/simple_copy/test_simple_copy.py @@ -1,16 +1,12 @@ # mix in biguery # mix in snowflake -import pytest - from pathlib import Path -from dbt.tests.util import run_dbt, rm_file, write_file, check_relations_equal +import pytest +from dbt.tests.util import check_relations_equal, rm_file, run_dbt, write_file from tests.functional.adapter.simple_copy.fixtures import ( - _PROPERTIES__SCHEMA_YML, - _SEEDS__SEED_INITIAL, - _SEEDS__SEED_UPDATE, _MODELS__ADVANCED_INCREMENTAL, _MODELS__COMPOUND_SORT, _MODELS__DISABLED, @@ -20,6 +16,9 @@ _MODELS__INTERLEAVED_SORT, _MODELS__MATERIALIZED, _MODELS__VIEW_MODEL, + _PROPERTIES__SCHEMA_YML, + _SEEDS__SEED_INITIAL, + _SEEDS__SEED_UPDATE, ) diff --git a/tests/functional/adapter/simple_seed/test_seed.py b/tests/functional/adapter/simple_seed/test_seed.py index d01f5fe3159..536ed7ad017 100644 --- a/tests/functional/adapter/simple_seed/test_seed.py +++ b/tests/functional/adapter/simple_seed/test_seed.py @@ -1,36 +1,34 @@ import csv -import pytest - from codecs import BOM_UTF8 from pathlib import Path +import pytest + from dbt.tests.util import ( + check_relations_equal, + check_table_does_exist, + check_table_does_not_exist, copy_file, mkdir, + read_file, rm_dir, run_dbt, - read_file, - check_relations_equal, - check_table_does_exist, - check_table_does_not_exist, ) - from tests.functional.adapter.simple_seed.fixtures import ( models__downstream_from_seed_actual, - models__from_basic_seed, models__downstream_from_seed_pipe_separated, + models__from_basic_seed, ) - from tests.functional.adapter.simple_seed.seeds import ( seed__actual_csv, - seeds__expected_sql, - seeds__enabled_in_config_csv, - seeds__disabled_in_config_csv, - seeds__tricky_csv, - seeds__wont_parse_csv, seed__unicode_csv, seed__with_dots_csv, + seeds__disabled_in_config_csv, + seeds__enabled_in_config_csv, + seeds__expected_sql, seeds__pipe_separated_csv, + seeds__tricky_csv, + seeds__wont_parse_csv, ) diff --git a/tests/functional/adapter/simple_seed/test_seed_type_override.py b/tests/functional/adapter/simple_seed/test_seed_type_override.py index 438e0bf5047..d4142f860bb 100644 --- a/tests/functional/adapter/simple_seed/test_seed_type_override.py +++ b/tests/functional/adapter/simple_seed/test_seed_type_override.py @@ -1,15 +1,13 @@ import pytest from dbt.tests.util import run_dbt - from tests.functional.adapter.simple_seed.fixtures import ( macros__schema_test, properties__schema_yml, ) - from tests.functional.adapter.simple_seed.seeds import ( - seeds__enabled_in_config_csv, seeds__disabled_in_config_csv, + seeds__enabled_in_config_csv, seeds__tricky_csv, ) diff --git a/tests/functional/adapter/simple_snapshot/common.py b/tests/functional/adapter/simple_snapshot/common.py index 726cc292e02..8eafeb90cb4 100644 --- a/tests/functional/adapter/simple_snapshot/common.py +++ b/tests/functional/adapter/simple_snapshot/common.py @@ -1,7 +1,7 @@ from typing import Dict, List -from dbt.tests.util import relation_from_name from dbt.tests.fixtures.project import TestProjInfo +from dbt.tests.util import relation_from_name def get_records( diff --git a/tests/functional/adapter/simple_snapshot/test_snapshot.py b/tests/functional/adapter/simple_snapshot/test_snapshot.py index e230c395ce1..05f08bb3928 100644 --- a/tests/functional/adapter/simple_snapshot/test_snapshot.py +++ b/tests/functional/adapter/simple_snapshot/test_snapshot.py @@ -1,10 +1,9 @@ +from typing import Dict, Iterable, List + import pytest -from typing import Dict, List, Iterable from dbt.tests.util import run_dbt - -from tests.functional.adapter.simple_snapshot import common -from tests.functional.adapter.simple_snapshot import seeds, snapshots +from tests.functional.adapter.simple_snapshot import common, seeds, snapshots MODEL_FACT_SQL = """ {{ config(materialized="table") }} diff --git a/tests/functional/adapter/store_test_failures_tests/basic.py b/tests/functional/adapter/store_test_failures_tests/basic.py index 3f5b8a29a53..88196d1f308 100644 --- a/tests/functional/adapter/store_test_failures_tests/basic.py +++ b/tests/functional/adapter/store_test_failures_tests/basic.py @@ -4,11 +4,9 @@ import pytest from dbt.artifacts.schemas.results import TestStatus -from dbt.tests.util import run_dbt, check_relation_types - +from dbt.tests.util import check_relation_types, run_dbt from tests.functional.adapter.store_test_failures_tests import _files - TestResult = namedtuple("TestResult", ["name", "status", "type"]) diff --git a/tests/functional/adapter/store_test_failures_tests/test_store_test_failures.py b/tests/functional/adapter/store_test_failures_tests/test_store_test_failures.py index edf85105a67..40546cea9e9 100644 --- a/tests/functional/adapter/store_test_failures_tests/test_store_test_failures.py +++ b/tests/functional/adapter/store_test_failures_tests/test_store_test_failures.py @@ -1,20 +1,16 @@ import pytest -from dbt.tests.util import ( - check_relations_equal, - run_dbt, -) - +from dbt.tests.util import check_relations_equal, run_dbt from tests.functional.adapter.store_test_failures_tests.fixtures import ( - seeds__people, + models__file_model_but_with_a_no_good_very_long_name, + models__fine_model, + models__problematic_model, + properties__schema_yml, seeds__expected_accepted_values, seeds__expected_failing_test, seeds__expected_not_null_problematic_model_id, seeds__expected_unique_problematic_model_id, - properties__schema_yml, - models__problematic_model, - models__fine_model, - models__file_model_but_with_a_no_good_very_long_name, + seeds__people, tests__failing_test, tests__passing_test, ) diff --git a/tests/functional/adapter/utils/base_array_utils.py b/tests/functional/adapter/utils/base_array_utils.py index 4c75a8650cb..3abc2ffce64 100644 --- a/tests/functional/adapter/utils/base_array_utils.py +++ b/tests/functional/adapter/utils/base_array_utils.py @@ -1,5 +1,5 @@ +from dbt.tests.util import check_relations_equal, get_relation_columns, run_dbt from tests.functional.adapter.utils.base_utils import BaseUtils -from dbt.tests.util import run_dbt, check_relations_equal, get_relation_columns class BaseArrayUtils(BaseUtils): diff --git a/tests/functional/adapter/utils/base_utils.py b/tests/functional/adapter/utils/base_utils.py index 622b4ab4224..75672e70090 100644 --- a/tests/functional/adapter/utils/base_utils.py +++ b/tests/functional/adapter/utils/base_utils.py @@ -1,4 +1,5 @@ import pytest + from dbt.tests.util import run_dbt macros__equals_sql = """ diff --git a/tests/functional/adapter/utils/data_types/base_data_type_macro.py b/tests/functional/adapter/utils/data_types/base_data_type_macro.py index 07eb07d8911..b5fe690ff56 100644 --- a/tests/functional/adapter/utils/data_types/base_data_type_macro.py +++ b/tests/functional/adapter/utils/data_types/base_data_type_macro.py @@ -1,4 +1,4 @@ -from dbt.tests.util import run_dbt, check_relations_equal, get_relation_columns +from dbt.tests.util import check_relations_equal, get_relation_columns, run_dbt class BaseDataTypeMacro: diff --git a/tests/functional/adapter/utils/data_types/test_type_bigint.py b/tests/functional/adapter/utils/data_types/test_type_bigint.py index 7b6d31882ba..946f8b888c8 100644 --- a/tests/functional/adapter/utils/data_types/test_type_bigint.py +++ b/tests/functional/adapter/utils/data_types/test_type_bigint.py @@ -1,5 +1,8 @@ import pytest -from tests.functional.adapter.utils.data_types.base_data_type_macro import BaseDataTypeMacro + +from tests.functional.adapter.utils.data_types.base_data_type_macro import ( + BaseDataTypeMacro, +) models__expected_sql = """ select 9223372036854775800 as bigint_col diff --git a/tests/functional/adapter/utils/data_types/test_type_boolean.py b/tests/functional/adapter/utils/data_types/test_type_boolean.py index 14ef64b1a15..db2fcd5459a 100644 --- a/tests/functional/adapter/utils/data_types/test_type_boolean.py +++ b/tests/functional/adapter/utils/data_types/test_type_boolean.py @@ -1,5 +1,8 @@ import pytest -from tests.functional.adapter.utils.data_types.base_data_type_macro import BaseDataTypeMacro + +from tests.functional.adapter.utils.data_types.base_data_type_macro import ( + BaseDataTypeMacro, +) seeds__expected_csv = """boolean_col True diff --git a/tests/functional/adapter/utils/data_types/test_type_float.py b/tests/functional/adapter/utils/data_types/test_type_float.py index 8f3077dbd1b..e3c75b6e7b8 100644 --- a/tests/functional/adapter/utils/data_types/test_type_float.py +++ b/tests/functional/adapter/utils/data_types/test_type_float.py @@ -1,5 +1,8 @@ import pytest -from tests.functional.adapter.utils.data_types.base_data_type_macro import BaseDataTypeMacro + +from tests.functional.adapter.utils.data_types.base_data_type_macro import ( + BaseDataTypeMacro, +) seeds__expected_csv = """float_col 1.2345 diff --git a/tests/functional/adapter/utils/data_types/test_type_int.py b/tests/functional/adapter/utils/data_types/test_type_int.py index cc93e6f0f4c..9836730da95 100644 --- a/tests/functional/adapter/utils/data_types/test_type_int.py +++ b/tests/functional/adapter/utils/data_types/test_type_int.py @@ -1,5 +1,8 @@ import pytest -from tests.functional.adapter.utils.data_types.base_data_type_macro import BaseDataTypeMacro + +from tests.functional.adapter.utils.data_types.base_data_type_macro import ( + BaseDataTypeMacro, +) seeds__expected_csv = """int_col 12345678 diff --git a/tests/functional/adapter/utils/data_types/test_type_numeric.py b/tests/functional/adapter/utils/data_types/test_type_numeric.py index 0ba4d88b1fe..fd8fef883fc 100644 --- a/tests/functional/adapter/utils/data_types/test_type_numeric.py +++ b/tests/functional/adapter/utils/data_types/test_type_numeric.py @@ -1,5 +1,8 @@ import pytest -from tests.functional.adapter.utils.data_types.base_data_type_macro import BaseDataTypeMacro + +from tests.functional.adapter.utils.data_types.base_data_type_macro import ( + BaseDataTypeMacro, +) seeds__expected_csv = """numeric_col 1.2345 diff --git a/tests/functional/adapter/utils/data_types/test_type_string.py b/tests/functional/adapter/utils/data_types/test_type_string.py index 14486e8e871..1b39a038a1f 100644 --- a/tests/functional/adapter/utils/data_types/test_type_string.py +++ b/tests/functional/adapter/utils/data_types/test_type_string.py @@ -1,5 +1,8 @@ import pytest -from tests.functional.adapter.utils.data_types.base_data_type_macro import BaseDataTypeMacro + +from tests.functional.adapter.utils.data_types.base_data_type_macro import ( + BaseDataTypeMacro, +) seeds__expected_csv = """string_col "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum." diff --git a/tests/functional/adapter/utils/data_types/test_type_timestamp.py b/tests/functional/adapter/utils/data_types/test_type_timestamp.py index 030e664914e..d8ebef3fbd7 100644 --- a/tests/functional/adapter/utils/data_types/test_type_timestamp.py +++ b/tests/functional/adapter/utils/data_types/test_type_timestamp.py @@ -1,5 +1,8 @@ import pytest -from tests.functional.adapter.utils.data_types.base_data_type_macro import BaseDataTypeMacro + +from tests.functional.adapter.utils.data_types.base_data_type_macro import ( + BaseDataTypeMacro, +) seeds__expected_csv = """timestamp_col 2021-01-01 01:01:01 diff --git a/tests/functional/adapter/utils/test_any_value.py b/tests/functional/adapter/utils/test_any_value.py index 4360c537e73..9db412683e6 100644 --- a/tests/functional/adapter/utils/test_any_value.py +++ b/tests/functional/adapter/utils/test_any_value.py @@ -1,10 +1,11 @@ import pytest + from tests.functional.adapter.utils.base_utils import BaseUtils from tests.functional.adapter.utils.fixture_any_value import ( - seeds__data_any_value_csv, - seeds__data_any_value_expected_csv, models__test_any_value_sql, models__test_any_value_yml, + seeds__data_any_value_csv, + seeds__data_any_value_expected_csv, ) diff --git a/tests/functional/adapter/utils/test_array_append.py b/tests/functional/adapter/utils/test_array_append.py index 52d9bd590f2..c7f518b99e0 100644 --- a/tests/functional/adapter/utils/test_array_append.py +++ b/tests/functional/adapter/utils/test_array_append.py @@ -1,4 +1,5 @@ import pytest + from tests.functional.adapter.utils.base_array_utils import BaseArrayUtils from tests.functional.adapter.utils.fixture_array_append import ( models__array_append_actual_sql, diff --git a/tests/functional/adapter/utils/test_array_concat.py b/tests/functional/adapter/utils/test_array_concat.py index 61a0652c220..535223e36f1 100644 --- a/tests/functional/adapter/utils/test_array_concat.py +++ b/tests/functional/adapter/utils/test_array_concat.py @@ -1,4 +1,5 @@ import pytest + from tests.functional.adapter.utils.base_array_utils import BaseArrayUtils from tests.functional.adapter.utils.fixture_array_concat import ( models__array_concat_actual_sql, diff --git a/tests/functional/adapter/utils/test_array_construct.py b/tests/functional/adapter/utils/test_array_construct.py index 6543b733449..8184d0f1a30 100644 --- a/tests/functional/adapter/utils/test_array_construct.py +++ b/tests/functional/adapter/utils/test_array_construct.py @@ -1,4 +1,5 @@ import pytest + from tests.functional.adapter.utils.base_array_utils import BaseArrayUtils from tests.functional.adapter.utils.fixture_array_construct import ( models__array_construct_actual_sql, diff --git a/tests/functional/adapter/utils/test_bool_or.py b/tests/functional/adapter/utils/test_bool_or.py index e360ca56a56..70d87dbc9b1 100644 --- a/tests/functional/adapter/utils/test_bool_or.py +++ b/tests/functional/adapter/utils/test_bool_or.py @@ -1,10 +1,11 @@ import pytest + from tests.functional.adapter.utils.base_utils import BaseUtils from tests.functional.adapter.utils.fixture_bool_or import ( - seeds__data_bool_or_csv, - seeds__data_bool_or_expected_csv, models__test_bool_or_sql, models__test_bool_or_yml, + seeds__data_bool_or_csv, + seeds__data_bool_or_expected_csv, ) diff --git a/tests/functional/adapter/utils/test_cast_bool_to_text.py b/tests/functional/adapter/utils/test_cast_bool_to_text.py index 728caf1ce89..c9a9b8a89b6 100644 --- a/tests/functional/adapter/utils/test_cast_bool_to_text.py +++ b/tests/functional/adapter/utils/test_cast_bool_to_text.py @@ -1,4 +1,5 @@ import pytest + from tests.functional.adapter.utils.base_utils import BaseUtils from tests.functional.adapter.utils.fixture_cast_bool_to_text import ( models__test_cast_bool_to_text_sql, diff --git a/tests/functional/adapter/utils/test_concat.py b/tests/functional/adapter/utils/test_concat.py index 766ef1790e2..7d9a09adc5d 100644 --- a/tests/functional/adapter/utils/test_concat.py +++ b/tests/functional/adapter/utils/test_concat.py @@ -1,9 +1,10 @@ import pytest + from tests.functional.adapter.utils.base_utils import BaseUtils from tests.functional.adapter.utils.fixture_concat import ( - seeds__data_concat_csv, models__test_concat_sql, models__test_concat_yml, + seeds__data_concat_csv, ) diff --git a/tests/functional/adapter/utils/test_current_timestamp.py b/tests/functional/adapter/utils/test_current_timestamp.py index 2a071c4ba2a..de97c71024c 100644 --- a/tests/functional/adapter/utils/test_current_timestamp.py +++ b/tests/functional/adapter/utils/test_current_timestamp.py @@ -1,12 +1,8 @@ -import pytest - -from datetime import datetime -from datetime import timezone -from datetime import timedelta +from datetime import datetime, timedelta, timezone -from dbt.tests.util import run_dbt -from dbt.tests.util import relation_from_name +import pytest +from dbt.tests.util import relation_from_name, run_dbt models__current_ts_sql = """ select {{ dbt.current_timestamp() }} as current_ts_column diff --git a/tests/functional/adapter/utils/test_date_spine.py b/tests/functional/adapter/utils/test_date_spine.py index 0b4b3b95279..0c6545cdba0 100644 --- a/tests/functional/adapter/utils/test_date_spine.py +++ b/tests/functional/adapter/utils/test_date_spine.py @@ -1,4 +1,5 @@ import pytest + from tests.functional.adapter.utils.base_utils import BaseUtils from tests.functional.adapter.utils.fixture_date_spine import ( models__test_date_spine_sql, diff --git a/tests/functional/adapter/utils/test_date_trunc.py b/tests/functional/adapter/utils/test_date_trunc.py index 977a2845efb..7c781c1fbd3 100644 --- a/tests/functional/adapter/utils/test_date_trunc.py +++ b/tests/functional/adapter/utils/test_date_trunc.py @@ -1,9 +1,10 @@ import pytest + from tests.functional.adapter.utils.base_utils import BaseUtils from tests.functional.adapter.utils.fixture_date_trunc import ( - seeds__data_date_trunc_csv, models__test_date_trunc_sql, models__test_date_trunc_yml, + seeds__data_date_trunc_csv, ) diff --git a/tests/functional/adapter/utils/test_dateadd.py b/tests/functional/adapter/utils/test_dateadd.py index 01171bff3fd..dcb8e78e38c 100644 --- a/tests/functional/adapter/utils/test_dateadd.py +++ b/tests/functional/adapter/utils/test_dateadd.py @@ -1,9 +1,10 @@ import pytest + from tests.functional.adapter.utils.base_utils import BaseUtils from tests.functional.adapter.utils.fixture_dateadd import ( - seeds__data_dateadd_csv, models__test_dateadd_sql, models__test_dateadd_yml, + seeds__data_dateadd_csv, ) diff --git a/tests/functional/adapter/utils/test_datediff.py b/tests/functional/adapter/utils/test_datediff.py index 291e5788997..df21dd5a361 100644 --- a/tests/functional/adapter/utils/test_datediff.py +++ b/tests/functional/adapter/utils/test_datediff.py @@ -1,9 +1,10 @@ import pytest + from tests.functional.adapter.utils.base_utils import BaseUtils from tests.functional.adapter.utils.fixture_datediff import ( - seeds__data_datediff_csv, models__test_datediff_sql, models__test_datediff_yml, + seeds__data_datediff_csv, ) diff --git a/tests/functional/adapter/utils/test_equals.py b/tests/functional/adapter/utils/test_equals.py index 4fdf5e1eae8..46a8c9ec462 100644 --- a/tests/functional/adapter/utils/test_equals.py +++ b/tests/functional/adapter/utils/test_equals.py @@ -1,11 +1,12 @@ import pytest + +from dbt.tests.util import relation_from_name, run_dbt from tests.functional.adapter.utils.base_utils import macros__equals_sql from tests.functional.adapter.utils.fixture_equals import ( - SEEDS__DATA_EQUALS_CSV, MODELS__EQUAL_VALUES_SQL, MODELS__NOT_EQUAL_VALUES_SQL, + SEEDS__DATA_EQUALS_CSV, ) -from dbt.tests.util import run_dbt, relation_from_name class BaseEquals: diff --git a/tests/functional/adapter/utils/test_escape_single_quotes.py b/tests/functional/adapter/utils/test_escape_single_quotes.py index 5847b4cca59..a9f2715130d 100644 --- a/tests/functional/adapter/utils/test_escape_single_quotes.py +++ b/tests/functional/adapter/utils/test_escape_single_quotes.py @@ -1,8 +1,9 @@ import pytest + from tests.functional.adapter.utils.base_utils import BaseUtils from tests.functional.adapter.utils.fixture_escape_single_quotes import ( - models__test_escape_single_quotes_quote_sql, models__test_escape_single_quotes_backslash_sql, + models__test_escape_single_quotes_quote_sql, models__test_escape_single_quotes_yml, ) diff --git a/tests/functional/adapter/utils/test_except.py b/tests/functional/adapter/utils/test_except.py index b34b7f5569c..bb73a3aa181 100644 --- a/tests/functional/adapter/utils/test_except.py +++ b/tests/functional/adapter/utils/test_except.py @@ -1,18 +1,19 @@ import pytest -from dbt.tests.util import run_dbt, check_relations_equal + +from dbt.tests.util import check_relations_equal, run_dbt from tests.functional.adapter.utils.base_utils import BaseUtils from tests.functional.adapter.utils.fixture_except import ( - seeds__data_except_a_csv, - seeds__data_except_b_csv, - seeds__data_except_a_minus_b_csv, - seeds__data_except_b_minus_a_csv, models__data_except_empty_sql, - models__test_except_a_minus_b_sql, - models__test_except_b_minus_a_sql, models__test_except_a_minus_a_sql, + models__test_except_a_minus_b_sql, models__test_except_a_minus_empty_sql, + models__test_except_b_minus_a_sql, models__test_except_empty_minus_a_sql, models__test_except_empty_minus_empty_sql, + seeds__data_except_a_csv, + seeds__data_except_a_minus_b_csv, + seeds__data_except_b_csv, + seeds__data_except_b_minus_a_csv, ) diff --git a/tests/functional/adapter/utils/test_generate_series.py b/tests/functional/adapter/utils/test_generate_series.py index 402adb4964a..19252b40c81 100644 --- a/tests/functional/adapter/utils/test_generate_series.py +++ b/tests/functional/adapter/utils/test_generate_series.py @@ -1,4 +1,5 @@ import pytest + from tests.functional.adapter.utils.base_utils import BaseUtils from tests.functional.adapter.utils.fixture_generate_series import ( models__test_generate_series_sql, diff --git a/tests/functional/adapter/utils/test_get_intervals_between.py b/tests/functional/adapter/utils/test_get_intervals_between.py index b21087ed795..f73b9ba4885 100644 --- a/tests/functional/adapter/utils/test_get_intervals_between.py +++ b/tests/functional/adapter/utils/test_get_intervals_between.py @@ -1,4 +1,5 @@ import pytest + from tests.functional.adapter.utils.base_utils import BaseUtils from tests.functional.adapter.utils.fixture_get_intervals_between import ( models__test_get_intervals_between_sql, diff --git a/tests/functional/adapter/utils/test_get_powers_of_two.py b/tests/functional/adapter/utils/test_get_powers_of_two.py index 26842140a12..dd1922a2f4c 100644 --- a/tests/functional/adapter/utils/test_get_powers_of_two.py +++ b/tests/functional/adapter/utils/test_get_powers_of_two.py @@ -1,4 +1,5 @@ import pytest + from tests.functional.adapter.utils.base_utils import BaseUtils from tests.functional.adapter.utils.fixture_get_powers_of_two import ( models__test_get_powers_of_two_sql, diff --git a/tests/functional/adapter/utils/test_hash.py b/tests/functional/adapter/utils/test_hash.py index dc5a5c0e075..4237ec14d8a 100644 --- a/tests/functional/adapter/utils/test_hash.py +++ b/tests/functional/adapter/utils/test_hash.py @@ -1,9 +1,10 @@ import pytest + from tests.functional.adapter.utils.base_utils import BaseUtils from tests.functional.adapter.utils.fixture_hash import ( - seeds__data_hash_csv, models__test_hash_sql, models__test_hash_yml, + seeds__data_hash_csv, ) diff --git a/tests/functional/adapter/utils/test_intersect.py b/tests/functional/adapter/utils/test_intersect.py index 2d6221b654d..a7911afeb93 100644 --- a/tests/functional/adapter/utils/test_intersect.py +++ b/tests/functional/adapter/utils/test_intersect.py @@ -1,17 +1,18 @@ import pytest -from dbt.tests.util import run_dbt, check_relations_equal + +from dbt.tests.util import check_relations_equal, run_dbt from tests.functional.adapter.utils.base_utils import BaseUtils from tests.functional.adapter.utils.fixture_intersect import ( - seeds__data_intersect_a_csv, - seeds__data_intersect_b_csv, - seeds__data_intersect_a_overlap_b_csv, models__data_intersect_empty_sql, - models__test_intersect_a_overlap_b_sql, - models__test_intersect_b_overlap_a_sql, models__test_intersect_a_overlap_a_sql, + models__test_intersect_a_overlap_b_sql, models__test_intersect_a_overlap_empty_sql, + models__test_intersect_b_overlap_a_sql, models__test_intersect_empty_overlap_a_sql, models__test_intersect_empty_overlap_empty_sql, + seeds__data_intersect_a_csv, + seeds__data_intersect_a_overlap_b_csv, + seeds__data_intersect_b_csv, ) diff --git a/tests/functional/adapter/utils/test_last_day.py b/tests/functional/adapter/utils/test_last_day.py index 030b9b95802..4b05d869738 100644 --- a/tests/functional/adapter/utils/test_last_day.py +++ b/tests/functional/adapter/utils/test_last_day.py @@ -1,9 +1,10 @@ import pytest + from tests.functional.adapter.utils.base_utils import BaseUtils from tests.functional.adapter.utils.fixture_last_day import ( - seeds__data_last_day_csv, models__test_last_day_sql, models__test_last_day_yml, + seeds__data_last_day_csv, ) diff --git a/tests/functional/adapter/utils/test_length.py b/tests/functional/adapter/utils/test_length.py index 24f93c1edbe..ede2b0821a9 100644 --- a/tests/functional/adapter/utils/test_length.py +++ b/tests/functional/adapter/utils/test_length.py @@ -1,9 +1,10 @@ import pytest + from tests.functional.adapter.utils.base_utils import BaseUtils from tests.functional.adapter.utils.fixture_length import ( - seeds__data_length_csv, models__test_length_sql, models__test_length_yml, + seeds__data_length_csv, ) diff --git a/tests/functional/adapter/utils/test_listagg.py b/tests/functional/adapter/utils/test_listagg.py index e1e8076ac36..e838a369ebb 100644 --- a/tests/functional/adapter/utils/test_listagg.py +++ b/tests/functional/adapter/utils/test_listagg.py @@ -1,10 +1,11 @@ import pytest + from tests.functional.adapter.utils.base_utils import BaseUtils from tests.functional.adapter.utils.fixture_listagg import ( - seeds__data_listagg_csv, - seeds__data_listagg_output_csv, models__test_listagg_sql, models__test_listagg_yml, + seeds__data_listagg_csv, + seeds__data_listagg_output_csv, ) diff --git a/tests/functional/adapter/utils/test_null_compare.py b/tests/functional/adapter/utils/test_null_compare.py index f1c1a83cbcc..161b6bb0110 100644 --- a/tests/functional/adapter/utils/test_null_compare.py +++ b/tests/functional/adapter/utils/test_null_compare.py @@ -1,5 +1,6 @@ import pytest +from dbt.tests.util import run_dbt from tests.functional.adapter.utils.base_utils import BaseUtils from tests.functional.adapter.utils.fixture_null_compare import ( MODELS__TEST_MIXED_NULL_COMPARE_SQL, @@ -7,7 +8,6 @@ MODELS__TEST_NULL_COMPARE_SQL, MODELS__TEST_NULL_COMPARE_YML, ) -from dbt.tests.util import run_dbt class BaseMixedNullCompare(BaseUtils): diff --git a/tests/functional/adapter/utils/test_position.py b/tests/functional/adapter/utils/test_position.py index 314048d82d5..4558ed17be5 100644 --- a/tests/functional/adapter/utils/test_position.py +++ b/tests/functional/adapter/utils/test_position.py @@ -1,9 +1,10 @@ import pytest + from tests.functional.adapter.utils.base_utils import BaseUtils from tests.functional.adapter.utils.fixture_position import ( - seeds__data_position_csv, models__test_position_sql, models__test_position_yml, + seeds__data_position_csv, ) diff --git a/tests/functional/adapter/utils/test_replace.py b/tests/functional/adapter/utils/test_replace.py index b94f9ada4de..7e7d558064c 100644 --- a/tests/functional/adapter/utils/test_replace.py +++ b/tests/functional/adapter/utils/test_replace.py @@ -1,9 +1,10 @@ import pytest + from tests.functional.adapter.utils.base_utils import BaseUtils from tests.functional.adapter.utils.fixture_replace import ( - seeds__data_replace_csv, models__test_replace_sql, models__test_replace_yml, + seeds__data_replace_csv, ) diff --git a/tests/functional/adapter/utils/test_right.py b/tests/functional/adapter/utils/test_right.py index aef52a94615..05fbad4ddf5 100644 --- a/tests/functional/adapter/utils/test_right.py +++ b/tests/functional/adapter/utils/test_right.py @@ -1,9 +1,10 @@ import pytest + from tests.functional.adapter.utils.base_utils import BaseUtils from tests.functional.adapter.utils.fixture_right import ( - seeds__data_right_csv, models__test_right_sql, models__test_right_yml, + seeds__data_right_csv, ) diff --git a/tests/functional/adapter/utils/test_safe_cast.py b/tests/functional/adapter/utils/test_safe_cast.py index 07d82867f2c..1052cec209d 100644 --- a/tests/functional/adapter/utils/test_safe_cast.py +++ b/tests/functional/adapter/utils/test_safe_cast.py @@ -1,9 +1,10 @@ import pytest + from tests.functional.adapter.utils.base_utils import BaseUtils from tests.functional.adapter.utils.fixture_safe_cast import ( - seeds__data_safe_cast_csv, models__test_safe_cast_sql, models__test_safe_cast_yml, + seeds__data_safe_cast_csv, ) diff --git a/tests/functional/adapter/utils/test_split_part.py b/tests/functional/adapter/utils/test_split_part.py index e8e076c43a5..0fee3db618f 100644 --- a/tests/functional/adapter/utils/test_split_part.py +++ b/tests/functional/adapter/utils/test_split_part.py @@ -1,9 +1,10 @@ import pytest + from tests.functional.adapter.utils.base_utils import BaseUtils from tests.functional.adapter.utils.fixture_split_part import ( - seeds__data_split_part_csv, models__test_split_part_sql, models__test_split_part_yml, + seeds__data_split_part_csv, ) diff --git a/tests/functional/adapter/utils/test_string_literal.py b/tests/functional/adapter/utils/test_string_literal.py index ab0d9ea83a8..f83a8f43438 100644 --- a/tests/functional/adapter/utils/test_string_literal.py +++ b/tests/functional/adapter/utils/test_string_literal.py @@ -1,4 +1,5 @@ import pytest + from tests.functional.adapter.utils.base_utils import BaseUtils from tests.functional.adapter.utils.fixture_string_literal import ( models__test_string_literal_sql, diff --git a/tests/functional/adapter/utils/test_timestamps.py b/tests/functional/adapter/utils/test_timestamps.py index 3fb3b2cd13d..adc5477373e 100644 --- a/tests/functional/adapter/utils/test_timestamps.py +++ b/tests/functional/adapter/utils/test_timestamps.py @@ -1,5 +1,7 @@ -import pytest import re + +import pytest + from dbt.tests.util import check_relation_has_expected_schema, run_dbt _MODEL_CURRENT_TIMESTAMP = """ diff --git a/tests/functional/adapter/utils/test_validate_sql.py b/tests/functional/adapter/utils/test_validate_sql.py index 5e03da33979..4c125d57721 100644 --- a/tests/functional/adapter/utils/test_validate_sql.py +++ b/tests/functional/adapter/utils/test_validate_sql.py @@ -3,8 +3,8 @@ import pytest from dbt.adapters.base.impl import BaseAdapter -from dbt.exceptions import DbtRuntimeError from dbt.adapters.exceptions import InvalidConnectionError +from dbt.exceptions import DbtRuntimeError class BaseValidateSqlMethod: diff --git a/tests/functional/analysis/test_analyses.py b/tests/functional/analysis/test_analyses.py index 61f66bc1dbc..e061039117f 100644 --- a/tests/functional/analysis/test_analyses.py +++ b/tests/functional/analysis/test_analyses.py @@ -1,8 +1,8 @@ import os -import pytest -from dbt.tests.util import run_dbt, get_manifest +import pytest +from dbt.tests.util import get_manifest, run_dbt my_model_sql = """ select 1 as id diff --git a/tests/functional/artifacts/expected_manifest.py b/tests/functional/artifacts/expected_manifest.py index 4d2a58592c6..eb010780334 100644 --- a/tests/functional/artifacts/expected_manifest.py +++ b/tests/functional/artifacts/expected_manifest.py @@ -1,7 +1,8 @@ import hashlib -import dbt import os from unittest.mock import ANY + +import dbt from dbt.tests.util import AnyStringWith # This produces an "expected manifest", with a number of the fields diff --git a/tests/functional/artifacts/expected_run_results.py b/tests/functional/artifacts/expected_run_results.py index 889dcf6353d..3a3148eba4d 100644 --- a/tests/functional/artifacts/expected_run_results.py +++ b/tests/functional/artifacts/expected_run_results.py @@ -1,4 +1,5 @@ from unittest.mock import ANY + from dbt.tests.util import AnyFloat diff --git a/tests/functional/artifacts/test_artifact_fields.py b/tests/functional/artifacts/test_artifact_fields.py index fc8e60330cd..74b121b7622 100644 --- a/tests/functional/artifacts/test_artifact_fields.py +++ b/tests/functional/artifacts/test_artifact_fields.py @@ -1,5 +1,6 @@ import pytest -from dbt.tests.util import run_dbt, get_manifest, get_artifact + +from dbt.tests.util import get_artifact, get_manifest, run_dbt # This is a place to put specific tests for contents of artifacts that we # don't want to bother putting in the big artifact output test, which is diff --git a/tests/functional/artifacts/test_artifacts.py b/tests/functional/artifacts/test_artifacts.py index 7aadb308513..4126266b129 100644 --- a/tests/functional/artifacts/test_artifacts.py +++ b/tests/functional/artifacts/test_artifacts.py @@ -1,25 +1,30 @@ -import pytest import os from datetime import datetime -import dbt + import jsonschema +import pytest -from dbt.tests.util import run_dbt, get_artifact, check_datetime_between, run_dbt_and_capture +import dbt +from dbt.artifacts.schemas.results import RunStatus +from dbt.artifacts.schemas.run import RunResultsArtifact +from dbt.contracts.graph.manifest import WritableManifest +from dbt.tests.util import ( + check_datetime_between, + get_artifact, + run_dbt, + run_dbt_and_capture, +) from tests.functional.artifacts.expected_manifest import ( - expected_seeded_manifest, expected_references_manifest, + expected_seeded_manifest, expected_versions_manifest, ) from tests.functional.artifacts.expected_run_results import ( - expected_run_results, expected_references_run_results, + expected_run_results, expected_versions_run_results, ) -from dbt.contracts.graph.manifest import WritableManifest -from dbt.artifacts.schemas.results import RunStatus -from dbt.artifacts.schemas.run import RunResultsArtifact - models__schema_yml = """ version: 2 diff --git a/tests/functional/artifacts/test_docs_generate_defer.py b/tests/functional/artifacts/test_docs_generate_defer.py index dc5eef6e030..cbeff63558d 100644 --- a/tests/functional/artifacts/test_docs_generate_defer.py +++ b/tests/functional/artifacts/test_docs_generate_defer.py @@ -1,6 +1,8 @@ import os import shutil + import pytest + from dbt.tests.util import run_dbt model_sql = """ diff --git a/tests/functional/artifacts/test_override.py b/tests/functional/artifacts/test_override.py index 1d4f32030bd..11f4ec200e1 100644 --- a/tests/functional/artifacts/test_override.py +++ b/tests/functional/artifacts/test_override.py @@ -1,6 +1,7 @@ import pytest -from dbt.tests.util import run_dbt + from dbt.exceptions import CompilationError +from dbt.tests.util import run_dbt model_sql = """ select 1 as id diff --git a/tests/functional/artifacts/test_previous_version_state.py b/tests/functional/artifacts/test_previous_version_state.py index a8511de5a2b..449c0004566 100644 --- a/tests/functional/artifacts/test_previous_version_state.py +++ b/tests/functional/artifacts/test_previous_version_state.py @@ -4,11 +4,11 @@ import pytest +from dbt.artifacts.exceptions import IncompatibleSchemaError from dbt.artifacts.schemas.base import get_artifact_schema_version -from dbt.contracts.graph.manifest import WritableManifest from dbt.artifacts.schemas.run import RunResultsArtifact -from dbt.artifacts.exceptions import IncompatibleSchemaError -from dbt.tests.util import run_dbt, get_manifest +from dbt.contracts.graph.manifest import WritableManifest +from dbt.tests.util import get_manifest, run_dbt # This project must have one of each kind of node type, plus disabled versions, for # test coverage to be complete. diff --git a/tests/functional/artifacts/test_run_results.py b/tests/functional/artifacts/test_run_results.py index 7f136afdb60..ba2fff9db1f 100644 --- a/tests/functional/artifacts/test_run_results.py +++ b/tests/functional/artifacts/test_run_results.py @@ -1,7 +1,9 @@ +import json from multiprocessing import Process from pathlib import Path -import json + import pytest + from dbt.tests.util import run_dbt good_model_sql = """ diff --git a/tests/functional/assertions/test_runner.py b/tests/functional/assertions/test_runner.py index 160a0f3c5c9..01ebc87339e 100644 --- a/tests/functional/assertions/test_runner.py +++ b/tests/functional/assertions/test_runner.py @@ -3,8 +3,8 @@ from dbt.cli.main import dbtRunner, dbtRunnerResult from dbt.contracts.graph.manifest import Manifest -from dbt_common.events.base_types import EventMsg from dbt.tests.util import get_run_results +from dbt_common.events.base_types import EventMsg def assert_run_results_have_compiled_node_attributes( diff --git a/tests/functional/basic/test_basic.py b/tests/functional/basic/test_basic.py index 836df78f83f..115f5ab206d 100644 --- a/tests/functional/basic/test_basic.py +++ b/tests/functional/basic/test_basic.py @@ -1,6 +1,6 @@ import pytest -from dbt.tests.util import run_dbt, get_manifest +from dbt.tests.util import get_manifest, run_dbt my_model_sql = """ select 1 as fun diff --git a/tests/functional/basic/test_invalid_reference.py b/tests/functional/basic/test_invalid_reference.py index 1c54d1b906a..9452573c11a 100644 --- a/tests/functional/basic/test_invalid_reference.py +++ b/tests/functional/basic/test_invalid_reference.py @@ -1,7 +1,7 @@ import pytest -from dbt.tests.util import run_dbt -from dbt.exceptions import CompilationError +from dbt.exceptions import CompilationError +from dbt.tests.util import run_dbt descendant_sql = """ -- should be ref('model') diff --git a/tests/functional/basic/test_jaffle_shop.py b/tests/functional/basic/test_jaffle_shop.py index c4ac406d462..c74cbf28298 100644 --- a/tests/functional/basic/test_jaffle_shop.py +++ b/tests/functional/basic/test_jaffle_shop.py @@ -1,6 +1,4 @@ -from dbt.tests.util import run_dbt, get_manifest, run_dbt_and_capture, write_file - - +from dbt.tests.util import get_manifest, run_dbt, run_dbt_and_capture, write_file from tests.fixtures.jaffle_shop import JaffleShopProject diff --git a/tests/functional/basic/test_mixed_case_db.py b/tests/functional/basic/test_mixed_case_db.py index 13519cc4bb4..8c9cf44fdd5 100644 --- a/tests/functional/basic/test_mixed_case_db.py +++ b/tests/functional/basic/test_mixed_case_db.py @@ -1,6 +1,6 @@ import pytest -from dbt.tests.util import run_dbt, get_manifest +from dbt.tests.util import get_manifest, run_dbt model_sql = """ select 1 as id diff --git a/tests/functional/basic/test_project.py b/tests/functional/basic/test_project.py index 6602c5e300f..2bdb101c913 100644 --- a/tests/functional/basic/test_project.py +++ b/tests/functional/basic/test_project.py @@ -1,10 +1,11 @@ import os +from pathlib import Path + import pytest import yaml -from pathlib import Path -from dbt.tests.util import run_dbt, update_config_file, write_config_file -from dbt.exceptions import ProjectContractError +from dbt.exceptions import ProjectContractError +from dbt.tests.util import run_dbt, update_config_file, write_config_file simple_model_sql = """ select true as my_column diff --git a/tests/functional/basic/test_simple_reference.py b/tests/functional/basic/test_simple_reference.py index 680a81383c5..22ba540bee6 100644 --- a/tests/functional/basic/test_simple_reference.py +++ b/tests/functional/basic/test_simple_reference.py @@ -1,6 +1,6 @@ import pytest -from dbt.tests.util import run_dbt, copy_file, read_file, check_relations_equal +from dbt.tests.util import check_relations_equal, copy_file, read_file, run_dbt ephemeral_copy_sql = """ {{ diff --git a/tests/functional/basic/test_varchar_widening.py b/tests/functional/basic/test_varchar_widening.py index 3e74629adea..76b62b0ef85 100644 --- a/tests/functional/basic/test_varchar_widening.py +++ b/tests/functional/basic/test_varchar_widening.py @@ -1,7 +1,8 @@ -import pytest import os -from dbt.tests.util import run_dbt, check_relations_equal +import pytest + +from dbt.tests.util import check_relations_equal, run_dbt incremental_sql = """ {{ diff --git a/tests/functional/build_command/test_build.py b/tests/functional/build_command/test_build.py index 01d516213b6..f0464f75dd8 100644 --- a/tests/functional/build_command/test_build.py +++ b/tests/functional/build_command/test_build.py @@ -2,28 +2,28 @@ from dbt.tests.util import run_dbt from tests.functional.build_command.fixtures import ( - seeds__country_csv, - snapshots__snap_0, - snapshots__snap_1, - snapshots__snap_99, - models__test_yml, models__model_0_sql, models__model_1_sql, models__model_2_sql, models__model_3_sql, models__model_99_sql, - models_failing__model_1_sql, + models__test_yml, models_circular_relationship__test_yml, + models_failing__model_1_sql, models_failing_tests__tests_yml, + models_interdependent__model_a_sql, + models_interdependent__model_b_null_sql, + models_interdependent__model_b_sql, + models_interdependent__model_c_sql, + models_interdependent__test_yml, models_simple_blocking__model_a_sql, models_simple_blocking__model_b_sql, models_simple_blocking__test_yml, models_triple_blocking__test_yml, - models_interdependent__test_yml, - models_interdependent__model_a_sql, - models_interdependent__model_b_sql, - models_interdependent__model_b_null_sql, - models_interdependent__model_c_sql, + seeds__country_csv, + snapshots__snap_0, + snapshots__snap_1, + snapshots__snap_99, unit_tests__yml, ) diff --git a/tests/functional/cli/test_cli_exit_codes.py b/tests/functional/cli/test_cli_exit_codes.py index 71c1097ba6a..2853a5d5c3c 100644 --- a/tests/functional/cli/test_cli_exit_codes.py +++ b/tests/functional/cli/test_cli_exit_codes.py @@ -3,7 +3,6 @@ from dbt.cli.exceptions import ResultExit from dbt.cli.main import cli - good_sql = """ select 1 as fun """ diff --git a/tests/functional/cli/test_env_var_deprecations.py b/tests/functional/cli/test_env_var_deprecations.py index 6880cc6890d..42a5afab88e 100644 --- a/tests/functional/cli/test_env_var_deprecations.py +++ b/tests/functional/cli/test_env_var_deprecations.py @@ -1,8 +1,8 @@ -import pytest import os -from dbt.tests.util import read_file, run_dbt +import pytest +from dbt.tests.util import read_file, run_dbt model_one_sql = """ select 1 as fun diff --git a/tests/functional/cli/test_error_handling.py b/tests/functional/cli/test_error_handling.py index 83c8a6fc47c..1eab78a0418 100644 --- a/tests/functional/cli/test_error_handling.py +++ b/tests/functional/cli/test_error_handling.py @@ -2,7 +2,6 @@ from dbt.tests.util import run_dbt - model_one_sql = """ someting bad """ diff --git a/tests/functional/cli/test_multioption.py b/tests/functional/cli/test_multioption.py index e9013fdb658..59b233c5a98 100644 --- a/tests/functional/cli/test_multioption.py +++ b/tests/functional/cli/test_multioption.py @@ -1,6 +1,6 @@ import pytest -from dbt.tests.util import run_dbt +from dbt.tests.util import run_dbt model_one_sql = """ select 1 as fun diff --git a/tests/functional/cli/test_resolvers.py b/tests/functional/cli/test_resolvers.py index 2ce8e17ceba..e25b6651aa5 100644 --- a/tests/functional/cli/test_resolvers.py +++ b/tests/functional/cli/test_resolvers.py @@ -1,6 +1,8 @@ +from pathlib import Path + import pytest + from dbt.cli.resolvers import default_log_path -from pathlib import Path class TestDefaultLogPathNoProject: diff --git a/tests/functional/colors/test_colors.py b/tests/functional/colors/test_colors.py index f42591c2b6a..3f731108d18 100644 --- a/tests/functional/colors/test_colors.py +++ b/tests/functional/colors/test_colors.py @@ -1,7 +1,8 @@ -import pytest import re -from dbt.tests.util import run_dbt_and_capture +import pytest + +from dbt.tests.util import run_dbt_and_capture models__do_nothing_then_fail_sql = """ select 1, diff --git a/tests/functional/compile/test_compile.py b/tests/functional/compile/test_compile.py index f7861ca24e2..e7732b09a8c 100644 --- a/tests/functional/compile/test_compile.py +++ b/tests/functional/compile/test_compile.py @@ -1,21 +1,23 @@ import json import pathlib -import pytest import re -from dbt_common.exceptions import DbtRuntimeError, DbtBaseException as DbtException -from dbt.tests.util import run_dbt, run_dbt_and_capture, read_file +import pytest + +from dbt.tests.util import read_file, run_dbt, run_dbt_and_capture +from dbt_common.exceptions import DbtBaseException as DbtException +from dbt_common.exceptions import DbtRuntimeError +from tests.functional.assertions.test_runner import dbtTestRunner from tests.functional.compile.fixtures import ( - first_model_sql, - second_model_sql, first_ephemeral_model_sql, + first_model_sql, + model_multiline_jinja, + schema_yml, second_ephemeral_model_sql, + second_model_sql, third_ephemeral_model_sql, with_recursive_model_sql, - schema_yml, - model_multiline_jinja, ) -from tests.functional.assertions.test_runner import dbtTestRunner def norm_whitespace(string): diff --git a/tests/functional/configs/test_configs.py b/tests/functional/configs/test_configs.py index 7ac6259ac13..8d520f1ff80 100644 --- a/tests/functional/configs/test_configs.py +++ b/tests/functional/configs/test_configs.py @@ -1,9 +1,15 @@ -from dbt_common.dataclass_schema import ValidationError -import pytest import os +import pytest + from dbt.exceptions import ParsingError -from dbt.tests.util import run_dbt, update_config_file, write_file, check_relations_equal +from dbt.tests.util import ( + check_relations_equal, + run_dbt, + update_config_file, + write_file, +) +from dbt_common.dataclass_schema import ValidationError from tests.functional.configs.fixtures import BaseConfigProject, simple_snapshot diff --git a/tests/functional/configs/test_configs_in_schema_files.py b/tests/functional/configs/test_configs_in_schema_files.py index c32eb89a3e0..2c4e2ca8119 100644 --- a/tests/functional/configs/test_configs_in_schema_files.py +++ b/tests/functional/configs/test_configs_in_schema_files.py @@ -1,8 +1,7 @@ import pytest -from dbt.tests.util import run_dbt, get_manifest, check_relations_equal, write_file - from dbt.exceptions import CompilationError, ParsingError +from dbt.tests.util import check_relations_equal, get_manifest, run_dbt, write_file models_alt__schema_yml = """ version: 2 diff --git a/tests/functional/configs/test_contract_configs.py b/tests/functional/configs/test_contract_configs.py index 10a3e778904..abd4b0caadc 100644 --- a/tests/functional/configs/test_contract_configs.py +++ b/tests/functional/configs/test_contract_configs.py @@ -1,7 +1,15 @@ -import pytest import os + +import pytest + from dbt.exceptions import ParsingError, ValidationError -from dbt.tests.util import run_dbt, get_manifest, get_artifact, run_dbt_and_capture, write_file +from dbt.tests.util import ( + get_artifact, + get_manifest, + run_dbt, + run_dbt_and_capture, + write_file, +) my_model_sql = """ {{ diff --git a/tests/functional/configs/test_custom_node_colors_configs.py b/tests/functional/configs/test_custom_node_colors_configs.py index f1ac98a76a9..1ca28d67795 100644 --- a/tests/functional/configs/test_custom_node_colors_configs.py +++ b/tests/functional/configs/test_custom_node_colors_configs.py @@ -1,7 +1,6 @@ import pytest -from dbt.tests.util import run_dbt, get_manifest - +from dbt.tests.util import get_manifest, run_dbt from dbt_common.dataclass_schema import ValidationError CUSTOM_NODE_COLOR_MODEL_LEVEL = "red" diff --git a/tests/functional/configs/test_disabled_configs.py b/tests/functional/configs/test_disabled_configs.py index 8fc738977c6..d2ee83e801a 100644 --- a/tests/functional/configs/test_disabled_configs.py +++ b/tests/functional/configs/test_disabled_configs.py @@ -1,7 +1,6 @@ import pytest from dbt.tests.util import run_dbt - from tests.functional.configs.fixtures import BaseConfigProject diff --git a/tests/functional/configs/test_disabled_model.py b/tests/functional/configs/test_disabled_model.py index df9886e8067..23cf8fde1e0 100644 --- a/tests/functional/configs/test_disabled_model.py +++ b/tests/functional/configs/test_disabled_model.py @@ -1,22 +1,21 @@ import pytest -from dbt_common.dataclass_schema import ValidationError -from dbt.tests.util import run_dbt, get_manifest from dbt.exceptions import CompilationError, ParsingError - +from dbt.tests.util import get_manifest, run_dbt +from dbt_common.dataclass_schema import ValidationError from tests.functional.configs.fixtures import ( - schema_all_disabled_yml, - schema_partial_enabled_yml, - schema_partial_disabled_yml, - schema_explicit_enabled_yml, - schema_invalid_enabled_yml, my_model, my_model_2, - my_model_2_enabled, my_model_2_disabled, + my_model_2_enabled, my_model_3, my_model_3_disabled, my_model_3_enabled, + schema_all_disabled_yml, + schema_explicit_enabled_yml, + schema_invalid_enabled_yml, + schema_partial_disabled_yml, + schema_partial_enabled_yml, ) diff --git a/tests/functional/configs/test_dupe_paths.py b/tests/functional/configs/test_dupe_paths.py index 95b76f5858f..7a12385a526 100644 --- a/tests/functional/configs/test_dupe_paths.py +++ b/tests/functional/configs/test_dupe_paths.py @@ -2,7 +2,6 @@ from dbt.tests.util import run_dbt - my_model_sql = """ select 1 as fun """ diff --git a/tests/functional/configs/test_get_default.py b/tests/functional/configs/test_get_default.py index 597e88c6d65..245ce4c3242 100644 --- a/tests/functional/configs/test_get_default.py +++ b/tests/functional/configs/test_get_default.py @@ -2,7 +2,6 @@ from dbt.tests.util import run_dbt - models_get__any_model_sql = """ -- models/any_model.sql select {{ config.get('made_up_nonexistent_key', 'default_value') }} as col_value diff --git a/tests/functional/configs/test_grant_configs.py b/tests/functional/configs/test_grant_configs.py index 64d3f48d4ca..8b1a4e40126 100644 --- a/tests/functional/configs/test_grant_configs.py +++ b/tests/functional/configs/test_grant_configs.py @@ -1,6 +1,6 @@ import pytest -from dbt.tests.util import run_dbt, get_manifest, write_file, write_config_file +from dbt.tests.util import get_manifest, run_dbt, write_config_file, write_file dbt_project_yml = """ models: diff --git a/tests/functional/configs/test_indiv_tests.py b/tests/functional/configs/test_indiv_tests.py index d02be0ba2ca..707d7f66320 100644 --- a/tests/functional/configs/test_indiv_tests.py +++ b/tests/functional/configs/test_indiv_tests.py @@ -1,7 +1,6 @@ import pytest from dbt.tests.util import run_dbt - from tests.functional.configs.fixtures import BaseConfigProject diff --git a/tests/functional/configs/test_unused_configs.py b/tests/functional/configs/test_unused_configs.py index e3dfaf8ad58..62b0fc6b3f0 100644 --- a/tests/functional/configs/test_unused_configs.py +++ b/tests/functional/configs/test_unused_configs.py @@ -1,7 +1,7 @@ import pytest -from dbt.tests.util import run_dbt from dbt.exceptions import CompilationError +from dbt.tests.util import run_dbt seeds__seed_csv = """id,value 4,2 diff --git a/tests/functional/configs/test_versioned_model_constraint.py b/tests/functional/configs/test_versioned_model_constraint.py index eb135df5d61..3776585b573 100644 --- a/tests/functional/configs/test_versioned_model_constraint.py +++ b/tests/functional/configs/test_versioned_model_constraint.py @@ -1,7 +1,7 @@ import pytest -from dbt.tests.util import run_dbt, rm_file, write_file, get_manifest -from dbt.exceptions import ParsingError +from dbt.exceptions import ParsingError +from dbt.tests.util import get_manifest, rm_file, run_dbt, write_file schema_yml = """ models: diff --git a/tests/functional/configs/test_warn_error_options.py b/tests/functional/configs/test_warn_error_options.py index 2363fc469fd..4b6552b0143 100644 --- a/tests/functional/configs/test_warn_error_options.py +++ b/tests/functional/configs/test_warn_error_options.py @@ -1,3 +1,5 @@ +from typing import Dict, Union + import pytest from dbt.cli.main import dbtRunner, dbtRunnerResult @@ -5,7 +7,6 @@ from dbt.tests.util import update_config_file from dbt_common.events.base_types import EventLevel from tests.functional.utils import EventCatcher -from typing import Dict, Union ModelsDictSpec = Dict[str, Union[str, "ModelsDictSpec"]] diff --git a/tests/functional/context_methods/test_builtin_functions.py b/tests/functional/context_methods/test_builtin_functions.py index 3acaf25170c..727df1b63bc 100644 --- a/tests/functional/context_methods/test_builtin_functions.py +++ b/tests/functional/context_methods/test_builtin_functions.py @@ -1,9 +1,10 @@ -import pytest import json import os -from dbt.tests.util import run_dbt, run_dbt_and_capture, write_file +import pytest + from dbt.exceptions import CompilationError +from dbt.tests.util import run_dbt, run_dbt_and_capture, write_file macros__validate_set_sql = """ {% macro validate_set() %} diff --git a/tests/functional/context_methods/test_cli_var_override.py b/tests/functional/context_methods/test_cli_var_override.py index 74e89604f01..b171c880451 100644 --- a/tests/functional/context_methods/test_cli_var_override.py +++ b/tests/functional/context_methods/test_cli_var_override.py @@ -2,7 +2,6 @@ from dbt.tests.util import run_dbt - models_override__schema_yml = """ version: 2 models: diff --git a/tests/functional/context_methods/test_cli_vars.py b/tests/functional/context_methods/test_cli_vars.py index 1d72e8c5021..8c563335ed0 100644 --- a/tests/functional/context_methods/test_cli_vars.py +++ b/tests/functional/context_methods/test_cli_vars.py @@ -1,18 +1,16 @@ import pytest import yaml -from tests.fixtures.dbt_integration_project import dbt_integration_project # noqa: F401 - +from dbt.exceptions import CompilationError, DbtRuntimeError +from dbt.tests.fixtures.project import write_project_files from dbt.tests.util import ( + get_artifact, + get_logging_events, run_dbt, run_dbt_and_capture, - get_logging_events, - get_artifact, write_config_file, ) -from dbt.tests.fixtures.project import write_project_files -from dbt.exceptions import DbtRuntimeError, CompilationError - +from tests.fixtures.dbt_integration_project import dbt_integration_project # noqa: F401 models_complex__schema_yml = """ version: 2 diff --git a/tests/functional/context_methods/test_custom_env_vars.py b/tests/functional/context_methods/test_custom_env_vars.py index e74a5dcee09..bf93d826fcd 100644 --- a/tests/functional/context_methods/test_custom_env_vars.py +++ b/tests/functional/context_methods/test_custom_env_vars.py @@ -1,7 +1,8 @@ -import pytest import json import os +import pytest + from dbt.tests.util import run_dbt_and_capture diff --git a/tests/functional/context_methods/test_env_vars.py b/tests/functional/context_methods/test_env_vars.py index ebe1c9e31a3..30c56551c09 100644 --- a/tests/functional/context_methods/test_env_vars.py +++ b/tests/functional/context_methods/test_env_vars.py @@ -1,10 +1,10 @@ -import pytest import os -from dbt_common.constants import SECRET_ENV_PREFIX -from dbt.constants import DEFAULT_ENV_PLACEHOLDER -from dbt.tests.util import run_dbt, get_manifest, run_dbt_and_capture +import pytest +from dbt.constants import DEFAULT_ENV_PLACEHOLDER +from dbt.tests.util import get_manifest, run_dbt, run_dbt_and_capture +from dbt_common.constants import SECRET_ENV_PREFIX context_sql = """ diff --git a/tests/functional/context_methods/test_secret_env_vars.py b/tests/functional/context_methods/test_secret_env_vars.py index f2447ffcf95..68ece050ff4 100644 --- a/tests/functional/context_methods/test_secret_env_vars.py +++ b/tests/functional/context_methods/test_secret_env_vars.py @@ -1,11 +1,11 @@ -import pytest import os +import pytest + +from dbt.exceptions import DbtInternalError, ParsingError +from dbt.tests.util import read_file, run_dbt, run_dbt_and_capture from dbt_common.constants import SECRET_ENV_PREFIX -from dbt.exceptions import ParsingError, DbtInternalError from tests.functional.context_methods.first_dependency import FirstDependencyProject -from dbt.tests.util import run_dbt, run_dbt_and_capture, read_file - secret_bad__context_sql = """ diff --git a/tests/functional/context_methods/test_var_dependency.py b/tests/functional/context_methods/test_var_dependency.py index 9755c8c9ab8..5822091b3b3 100644 --- a/tests/functional/context_methods/test_var_dependency.py +++ b/tests/functional/context_methods/test_var_dependency.py @@ -1,9 +1,9 @@ import pytest -from dbt.tests.util import run_dbt, check_relations_equal +from dbt.tests.util import check_relations_equal, run_dbt from tests.functional.context_methods.first_dependency import ( - FirstDependencyProject, FirstDependencyConfigProject, + FirstDependencyProject, ) dependency_seeds__root_model_expected_csv = """first_dep_global,from_root diff --git a/tests/functional/context_methods/test_var_in_generate_name.py b/tests/functional/context_methods/test_var_in_generate_name.py index 2bbba457e58..d4c4e81d29a 100644 --- a/tests/functional/context_methods/test_var_in_generate_name.py +++ b/tests/functional/context_methods/test_var_in_generate_name.py @@ -1,7 +1,7 @@ import pytest -from dbt.tests.util import run_dbt, update_config_file from dbt.exceptions import CompilationError +from dbt.tests.util import run_dbt, update_config_file model_sql = """ select 1 as id diff --git a/tests/functional/context_methods/test_yaml_functions.py b/tests/functional/context_methods/test_yaml_functions.py index d07fea670d9..e90da5f7254 100644 --- a/tests/functional/context_methods/test_yaml_functions.py +++ b/tests/functional/context_methods/test_yaml_functions.py @@ -2,7 +2,6 @@ from dbt.tests.util import run_dbt - tests__from_yaml_sql = """ {% set simplest = (fromyaml('a: 1') == {'a': 1}) %} {% set nested_data %} diff --git a/tests/functional/contracts/test_contract_enforcement.py b/tests/functional/contracts/test_contract_enforcement.py index 78eb2aea556..1d069f204d4 100644 --- a/tests/functional/contracts/test_contract_enforcement.py +++ b/tests/functional/contracts/test_contract_enforcement.py @@ -1,6 +1,6 @@ import pytest -from dbt.tests.util import run_dbt, write_file +from dbt.tests.util import run_dbt, write_file my_model_sql = """ select 'some string' as string_column diff --git a/tests/functional/contracts/test_contract_precision.py b/tests/functional/contracts/test_contract_precision.py index ee5ad4bb50c..a4df2c8ace9 100644 --- a/tests/functional/contracts/test_contract_precision.py +++ b/tests/functional/contracts/test_contract_precision.py @@ -1,6 +1,6 @@ import pytest -from dbt.tests.util import run_dbt_and_capture +from dbt.tests.util import run_dbt_and_capture my_numeric_model_sql = """ select diff --git a/tests/functional/contracts/test_nonstandard_data_type.py b/tests/functional/contracts/test_nonstandard_data_type.py index 4ee559ff4e5..1bcb5e8bb65 100644 --- a/tests/functional/contracts/test_nonstandard_data_type.py +++ b/tests/functional/contracts/test_nonstandard_data_type.py @@ -1,6 +1,6 @@ import pytest -from dbt.tests.util import run_dbt, run_dbt_and_capture +from dbt.tests.util import run_dbt, run_dbt_and_capture my_numeric_model_sql = """ select diff --git a/tests/functional/custom_aliases/test_custom_aliases.py b/tests/functional/custom_aliases/test_custom_aliases.py index 86b44c3b3f0..22ff536c175 100644 --- a/tests/functional/custom_aliases/test_custom_aliases.py +++ b/tests/functional/custom_aliases/test_custom_aliases.py @@ -1,12 +1,11 @@ import pytest from dbt.tests.util import run_dbt - from tests.functional.custom_aliases.fixtures import ( + macros_config_sql, + macros_sql, model1_sql, model2_sql, - macros_sql, - macros_config_sql, schema_yml, ) diff --git a/tests/functional/custom_singular_tests/test_custom_singular_tests.py b/tests/functional/custom_singular_tests/test_custom_singular_tests.py index aec0586b873..4dc638f3827 100644 --- a/tests/functional/custom_singular_tests/test_custom_singular_tests.py +++ b/tests/functional/custom_singular_tests/test_custom_singular_tests.py @@ -1,7 +1,7 @@ -import pytest - from pathlib import Path +import pytest + from dbt.tests.util import run_dbt # from `test/integration/009_data_test` diff --git a/tests/functional/dbt_runner/test_dbt_runner.py b/tests/functional/dbt_runner/test_dbt_runner.py index c332490e2d7..80b94b9c73a 100644 --- a/tests/functional/dbt_runner/test_dbt_runner.py +++ b/tests/functional/dbt_runner/test_dbt_runner.py @@ -2,10 +2,10 @@ import pytest +from dbt.adapters.factory import FACTORY, reset_adapters from dbt.cli.exceptions import DbtUsageException from dbt.cli.main import dbtRunner from dbt.exceptions import DbtProjectError -from dbt.adapters.factory import reset_adapters, FACTORY from dbt.tests.util import read_file, write_file from dbt.version import __version__ as dbt_version from dbt_common.events.contextvars import get_node_info diff --git a/tests/functional/defer_state/test_defer_state.py b/tests/functional/defer_state/test_defer_state.py index 1a40fbca73a..b823c8e1f78 100644 --- a/tests/functional/defer_state/test_defer_state.py +++ b/tests/functional/defer_state/test_defer_state.py @@ -6,21 +6,21 @@ from dbt.contracts.results import RunStatus from dbt.exceptions import DbtRuntimeError -from dbt.tests.util import run_dbt, write_file, rm_file +from dbt.tests.util import rm_file, run_dbt, write_file from tests.functional.defer_state.fixtures import ( - seed_csv, - table_model_sql, + changed_ephemeral_model_sql, changed_table_model_sql, - view_model_sql, changed_view_model_sql, ephemeral_model_sql, - changed_ephemeral_model_sql, - schema_yml, exposures_yml, - macros_sql, infinite_macros_sql, + macros_sql, + schema_yml, + seed_csv, snapshot_sql, + table_model_sql, view_model_now_table_sql, + view_model_sql, ) diff --git a/tests/functional/defer_state/test_group_updates.py b/tests/functional/defer_state/test_group_updates.py index 884909cf649..ab1cf1f2460 100644 --- a/tests/functional/defer_state/test_group_updates.py +++ b/tests/functional/defer_state/test_group_updates.py @@ -2,19 +2,17 @@ import pytest -from dbt.tests.util import run_dbt, write_file, copy_file from dbt.exceptions import ParsingError - - +from dbt.tests.util import copy_file, run_dbt, write_file from tests.functional.defer_state.fixtures import ( - seed_csv, + group_modified_fail_schema_yml, + group_modified_schema_yml, + group_schema_yml, model_1_sql, - modified_model_1_sql, model_2_sql, + modified_model_1_sql, modified_model_2_sql, - group_schema_yml, - group_modified_schema_yml, - group_modified_fail_schema_yml, + seed_csv, ) diff --git a/tests/functional/defer_state/test_modified_state.py b/tests/functional/defer_state/test_modified_state.py index 40f5e1e31d1..bfd5648ae61 100644 --- a/tests/functional/defer_state/test_modified_state.py +++ b/tests/functional/defer_state/test_modified_state.py @@ -5,42 +5,40 @@ import pytest +from dbt.exceptions import CompilationError, ContractBreakingChangeError from dbt.tests.util import ( + get_manifest, run_dbt, + run_dbt_and_capture, update_config_file, write_file, - get_manifest, - run_dbt_and_capture, ) - -from dbt.exceptions import CompilationError, ContractBreakingChangeError - from tests.functional.defer_state.fixtures import ( - seed_csv, - table_model_sql, - view_model_sql, + constraint_schema_yml, + contract_schema_yml, + disabled_contract_schema_yml, ephemeral_model_sql, - schema_yml, exposures_yml, - macros_sql, infinite_macros_sql, - no_contract_schema_yml, - contract_schema_yml, + macros_sql, + metricflow_time_spine_sql, + modified_column_constraint_schema_yml, modified_contract_schema_yml, - disabled_contract_schema_yml, - constraint_schema_yml, - versioned_no_contract_schema_yml, + modified_model_constraint_schema_yml, + modified_semantic_model_schema_yml, + no_contract_schema_yml, + schema_yml, + seed_csv, + semantic_model_schema_yml, + table_model_now_incremental_sql, + table_model_now_view_sql, + table_model_sql, versioned_contract_schema_yml, versioned_disabled_contract_schema_yml, versioned_modified_contract_schema_yml, - modified_column_constraint_schema_yml, - modified_model_constraint_schema_yml, - table_model_now_view_sql, - table_model_now_incremental_sql, + versioned_no_contract_schema_yml, view_model_now_table_sql, - metricflow_time_spine_sql, - semantic_model_schema_yml, - modified_semantic_model_schema_yml, + view_model_sql, ) diff --git a/tests/functional/defer_state/test_run_results_state.py b/tests/functional/defer_state/test_run_results_state.py index 69dc77a1dd3..e4b467d8e37 100644 --- a/tests/functional/defer_state/test_run_results_state.py +++ b/tests/functional/defer_state/test_run_results_state.py @@ -4,16 +4,15 @@ import pytest from dbt.tests.util import run_dbt, write_file - from tests.functional.defer_state.fixtures import ( - seed_csv, - table_model_sql, - view_model_sql, ephemeral_model_sql, - schema_yml, exposures_yml, - macros_sql, infinite_macros_sql, + macros_sql, + schema_yml, + seed_csv, + table_model_sql, + view_model_sql, ) diff --git a/tests/functional/dependencies/test_dependency_options.py b/tests/functional/dependencies/test_dependency_options.py index 7e451555ac3..067fd7bf1e5 100644 --- a/tests/functional/dependencies/test_dependency_options.py +++ b/tests/functional/dependencies/test_dependency_options.py @@ -1,5 +1,6 @@ import os import shutil + import pytest from dbt.tests.util import run_dbt diff --git a/tests/functional/dependencies/test_dependency_secrets.py b/tests/functional/dependencies/test_dependency_secrets.py index 12d3ecb489d..02dc4f0f8f1 100644 --- a/tests/functional/dependencies/test_dependency_secrets.py +++ b/tests/functional/dependencies/test_dependency_secrets.py @@ -1,4 +1,5 @@ import os + import pytest from dbt.tests.util import run_dbt_and_capture diff --git a/tests/functional/dependencies/test_local_dependency.py b/tests/functional/dependencies/test_local_dependency.py index 04391e0c872..28558bc725f 100644 --- a/tests/functional/dependencies/test_local_dependency.py +++ b/tests/functional/dependencies/test_local_dependency.py @@ -1,22 +1,22 @@ -import os -import pytest import json +import os import shutil -import yaml - -# todo: make self.unique_schema to fixture - from pathlib import Path from unittest import mock -import dbt_common.semver as semver -import dbt_common.exceptions +import pytest +import yaml + import dbt.config import dbt.exceptions - +import dbt_common.exceptions +import dbt_common.semver as semver from dbt.tests.util import check_relations_equal, run_dbt, run_dbt_and_capture from tests.functional.utils import up_one +# todo: make self.unique_schema to fixture + + models__dep_source = """ {# If our dependency source didn't exist, this would be an errror #} select * from {{ source('seed_source', 'seed') }} diff --git a/tests/functional/dependencies/test_simple_dependency.py b/tests/functional/dependencies/test_simple_dependency.py index 9483400fc24..e63a648e0be 100644 --- a/tests/functional/dependencies/test_simple_dependency.py +++ b/tests/functional/dependencies/test_simple_dependency.py @@ -1,16 +1,11 @@ import os -import pytest import tempfile - from pathlib import Path -from dbt.exceptions import DbtProjectError -from dbt.tests.util import ( - check_relations_equal, - run_dbt, - write_config_file, -) +import pytest +from dbt.exceptions import DbtProjectError +from dbt.tests.util import check_relations_equal, run_dbt, write_config_file models__disabled_one = """ {{config(enabled=False)}} diff --git a/tests/functional/dependencies/test_simple_dependency_with_configs.py b/tests/functional/dependencies/test_simple_dependency_with_configs.py index 86ab911a2b1..40642d4e81a 100644 --- a/tests/functional/dependencies/test_simple_dependency_with_configs.py +++ b/tests/functional/dependencies/test_simple_dependency_with_configs.py @@ -1,12 +1,8 @@ -import pytest - from pathlib import Path -from dbt.tests.util import ( - check_relations_equal, - run_dbt, -) +import pytest +from dbt.tests.util import check_relations_equal, run_dbt models__view_summary = """ {{ diff --git a/tests/functional/deprecations/model_deprecations.py b/tests/functional/deprecations/model_deprecations.py index 043b7e1e5e9..03e38b1220e 100644 --- a/tests/functional/deprecations/model_deprecations.py +++ b/tests/functional/deprecations/model_deprecations.py @@ -1,10 +1,9 @@ import pytest -from dbt.exceptions import EventCompilationError from dbt.cli.main import dbtRunner +from dbt.exceptions import EventCompilationError from dbt.tests.util import run_dbt - deprecated_model__yml = """ version: 2 diff --git a/tests/functional/deprecations/test_config_deprecations.py b/tests/functional/deprecations/test_config_deprecations.py index ba2d780c999..d4e965a8451 100644 --- a/tests/functional/deprecations/test_config_deprecations.py +++ b/tests/functional/deprecations/test_config_deprecations.py @@ -2,17 +2,16 @@ from dbt import deprecations from dbt.exceptions import CompilationError, ProjectContractError, YamlParseDictError -from dbt.tests.util import run_dbt, update_config_file from dbt.tests.fixtures.project import write_project_files - +from dbt.tests.util import run_dbt, update_config_file from tests.functional.deprecations.fixtures import ( - macros__custom_test_sql, - models_trivial__model_sql, - old_tests_yml, + data_tests_yaml, local_dependency__dbt_project_yml, local_dependency__schema_yml, local_dependency__seed_csv, - data_tests_yaml, + macros__custom_test_sql, + models_trivial__model_sql, + old_tests_yml, seed_csv, sources_old_tests_yaml, test_type_mixed_yaml, diff --git a/tests/functional/deprecations/test_deprecations.py b/tests/functional/deprecations/test_deprecations.py index d93cb5f9a10..8082be7b911 100644 --- a/tests/functional/deprecations/test_deprecations.py +++ b/tests/functional/deprecations/test_deprecations.py @@ -1,13 +1,13 @@ import pytest -import dbt_common +import yaml +import dbt_common from dbt import deprecations +from dbt.tests.util import run_dbt, write_file from tests.functional.deprecations.fixtures import ( - models_trivial__model_sql, bad_name_yaml, + models_trivial__model_sql, ) -from dbt.tests.util import run_dbt, write_file -import yaml class TestConfigPathDeprecation: diff --git a/tests/functional/docs/test_duplicate_docs_block.py b/tests/functional/docs/test_duplicate_docs_block.py index 89454e7bf55..95262bcb734 100644 --- a/tests/functional/docs/test_duplicate_docs_block.py +++ b/tests/functional/docs/test_duplicate_docs_block.py @@ -1,8 +1,7 @@ import pytest -from dbt.tests.util import run_dbt import dbt_common.exceptions - +from dbt.tests.util import run_dbt duplicate_doc_blocks_model_sql = "select 1 as id, 'joe' as first_name" diff --git a/tests/functional/docs/test_generate.py b/tests/functional/docs/test_generate.py index 7597fdb41f3..8e5873e602d 100644 --- a/tests/functional/docs/test_generate.py +++ b/tests/functional/docs/test_generate.py @@ -1,8 +1,9 @@ -import pytest from unittest import mock -from dbt.plugins.manifest import PluginNodes, ModelNodeArgs -from dbt.tests.util import run_dbt, get_manifest +import pytest + +from dbt.plugins.manifest import ModelNodeArgs, PluginNodes +from dbt.tests.util import get_manifest, run_dbt sample_seed = """sample_num,sample_bool 1,true diff --git a/tests/functional/docs/test_good_docs_blocks.py b/tests/functional/docs/test_good_docs_blocks.py index 782489854f5..768e6201275 100644 --- a/tests/functional/docs/test_good_docs_blocks.py +++ b/tests/functional/docs/test_good_docs_blocks.py @@ -1,11 +1,11 @@ import json import os from pathlib import Path + import pytest from dbt.tests.util import run_dbt, update_config_file, write_file - good_docs_blocks_model_sql = "select 1 as id, 'joe' as first_name" good_docs_blocks_docs_md = """{% docs my_model_doc %} diff --git a/tests/functional/docs/test_invalid_doc_ref.py b/tests/functional/docs/test_invalid_doc_ref.py index 6750f987fce..cfcd65da6e0 100644 --- a/tests/functional/docs/test_invalid_doc_ref.py +++ b/tests/functional/docs/test_invalid_doc_ref.py @@ -1,8 +1,7 @@ import pytest -from dbt.tests.util import run_dbt import dbt_common.exceptions - +from dbt.tests.util import run_dbt invalid_doc_ref_model_sql = "select 1 as id, 'joe' as first_name" diff --git a/tests/functional/docs/test_missing_docs_blocks.py b/tests/functional/docs/test_missing_docs_blocks.py index 4565d3cc937..193644eca76 100644 --- a/tests/functional/docs/test_missing_docs_blocks.py +++ b/tests/functional/docs/test_missing_docs_blocks.py @@ -1,8 +1,7 @@ import pytest -from dbt.tests.util import run_dbt import dbt_common.exceptions - +from dbt.tests.util import run_dbt missing_docs_blocks_model_sql = "select 1 as id, 'joe' as first_name" diff --git a/tests/functional/docs/test_static.py b/tests/functional/docs/test_static.py index 9434b281188..05f3a1ef7ca 100644 --- a/tests/functional/docs/test_static.py +++ b/tests/functional/docs/test_static.py @@ -1,9 +1,10 @@ +import os + import pytest -from dbt_common.clients.system import load_file_contents from dbt.task.docs import DOCS_INDEX_FILE_PATH from dbt.tests.util import run_dbt -import os +from dbt_common.clients.system import load_file_contents class TestStaticGenerate: diff --git a/tests/functional/duplicates/test_duplicate_analysis.py b/tests/functional/duplicates/test_duplicate_analysis.py index 44dc4c6f167..126f6ae6907 100644 --- a/tests/functional/duplicates/test_duplicate_analysis.py +++ b/tests/functional/duplicates/test_duplicate_analysis.py @@ -3,7 +3,6 @@ from dbt.exceptions import CompilationError from dbt.tests.util import run_dbt - my_model_sql = """ select 1 as id """ diff --git a/tests/functional/duplicates/test_duplicate_exposure.py b/tests/functional/duplicates/test_duplicate_exposure.py index 140db21cd07..349c6b78cc7 100644 --- a/tests/functional/duplicates/test_duplicate_exposure.py +++ b/tests/functional/duplicates/test_duplicate_exposure.py @@ -3,7 +3,6 @@ from dbt.exceptions import CompilationError from dbt.tests.util import run_dbt - exposure_dupes_schema_yml = """ version: 2 exposures: diff --git a/tests/functional/duplicates/test_duplicate_macro.py b/tests/functional/duplicates/test_duplicate_macro.py index 35b843f5891..0c1ba3d76d3 100644 --- a/tests/functional/duplicates/test_duplicate_macro.py +++ b/tests/functional/duplicates/test_duplicate_macro.py @@ -3,7 +3,6 @@ from dbt.exceptions import CompilationError from dbt.tests.util import run_dbt - bad_same_macros_sql = """ {% macro some_macro() %} {% endmacro %} diff --git a/tests/functional/duplicates/test_duplicate_metric.py b/tests/functional/duplicates/test_duplicate_metric.py index a5f6b60e8f3..1b172b09caf 100644 --- a/tests/functional/duplicates/test_duplicate_metric.py +++ b/tests/functional/duplicates/test_duplicate_metric.py @@ -3,7 +3,6 @@ from dbt.exceptions import CompilationError from dbt.tests.util import run_dbt - metric_dupes_schema_yml = """ version: 2 diff --git a/tests/functional/duplicates/test_duplicate_model.py b/tests/functional/duplicates/test_duplicate_model.py index be9e8754d1f..01fad6e949d 100644 --- a/tests/functional/duplicates/test_duplicate_model.py +++ b/tests/functional/duplicates/test_duplicate_model.py @@ -1,9 +1,8 @@ import pytest -from dbt.exceptions import CompilationError, AmbiguousAliasError +from dbt.exceptions import AmbiguousAliasError, CompilationError from dbt.tests.fixtures.project import write_project_files -from dbt.tests.util import run_dbt, get_manifest - +from dbt.tests.util import get_manifest, run_dbt disabled_model_sql = """ {{ diff --git a/tests/functional/duplicates/test_duplicate_resource.py b/tests/functional/duplicates/test_duplicate_resource.py index 0bc070ff39f..87c52cf5712 100644 --- a/tests/functional/duplicates/test_duplicate_resource.py +++ b/tests/functional/duplicates/test_duplicate_resource.py @@ -2,7 +2,6 @@ from dbt.tests.util import run_dbt - models_naming_dupes_schema_yml = """ version: 2 models: diff --git a/tests/functional/duplicates/test_duplicate_source.py b/tests/functional/duplicates/test_duplicate_source.py index 1100345aabc..4b9b6c4a08e 100644 --- a/tests/functional/duplicates/test_duplicate_source.py +++ b/tests/functional/duplicates/test_duplicate_source.py @@ -3,7 +3,6 @@ from dbt.exceptions import CompilationError from dbt.tests.util import run_dbt - source_dupes_schema_yml = """ version: 2 sources: diff --git a/tests/functional/exit_codes/test_exit_codes.py b/tests/functional/exit_codes/test_exit_codes.py index 44672beecae..5013d6fc070 100644 --- a/tests/functional/exit_codes/test_exit_codes.py +++ b/tests/functional/exit_codes/test_exit_codes.py @@ -4,10 +4,10 @@ from dbt.tests.util import check_table_does_exist, check_table_does_not_exist, run_dbt from tests.functional.exit_codes.fixtures import ( BaseConfigProject, - snapshots_bad_sql, - snapshots_good_sql, data_seed_bad_csv, data_seed_good_csv, + snapshots_bad_sql, + snapshots_good_sql, ) diff --git a/tests/functional/experimental_parser/test_all_experimental_parser.py b/tests/functional/experimental_parser/test_all_experimental_parser.py index 87e6d2f30e1..ff481cd0c04 100644 --- a/tests/functional/experimental_parser/test_all_experimental_parser.py +++ b/tests/functional/experimental_parser/test_all_experimental_parser.py @@ -1,10 +1,10 @@ -import pytest +import os -from dbt.tests.util import run_dbt +import pytest from dbt.artifacts.resources import RefArgs from dbt.contracts.graph.manifest import Manifest -import os +from dbt.tests.util import run_dbt def get_manifest(): diff --git a/tests/functional/exposures/test_exposure_configs.py b/tests/functional/exposures/test_exposure_configs.py index 8f60778e058..2ec309623a7 100644 --- a/tests/functional/exposures/test_exposure_configs.py +++ b/tests/functional/exposures/test_exposure_configs.py @@ -1,20 +1,19 @@ import pytest from dbt.artifacts.resources import ExposureConfig +from dbt.tests.util import get_manifest, run_dbt, update_config_file from dbt_common.dataclass_schema import ValidationError - -from dbt.tests.util import run_dbt, update_config_file, get_manifest from tests.functional.exposures.fixtures import ( - models_sql, - second_model_sql, - simple_exposure_yml, disabled_models_exposure_yml, enabled_yaml_level_exposure_yml, invalid_config_exposure_yml, - source_schema_yml, metricflow_time_spine_sql, - semantic_models_schema_yml, metrics_schema_yml, + models_sql, + second_model_sql, + semantic_models_schema_yml, + simple_exposure_yml, + source_schema_yml, ) diff --git a/tests/functional/exposures/test_exposures.py b/tests/functional/exposures/test_exposures.py index 1988dd976b3..be42ffd26c0 100644 --- a/tests/functional/exposures/test_exposures.py +++ b/tests/functional/exposures/test_exposures.py @@ -1,14 +1,14 @@ import pytest -from dbt.tests.util import run_dbt, get_manifest +from dbt.tests.util import get_manifest, run_dbt from tests.functional.exposures.fixtures import ( + metricflow_time_spine_sql, + metrics_schema_yml, models_sql, second_model_sql, + semantic_models_schema_yml, simple_exposure_yml, source_schema_yml, - metrics_schema_yml, - semantic_models_schema_yml, - metricflow_time_spine_sql, ) diff --git a/tests/functional/external_reference/test_external_reference.py b/tests/functional/external_reference/test_external_reference.py index 8b5294155d8..7ac561ce862 100644 --- a/tests/functional/external_reference/test_external_reference.py +++ b/tests/functional/external_reference/test_external_reference.py @@ -2,7 +2,6 @@ from dbt.tests.util import run_dbt - external_model_sql = """ {{ config( diff --git a/tests/functional/graph_selection/fixtures.py b/tests/functional/graph_selection/fixtures.py index 846502fc6f5..b4d4a677d25 100644 --- a/tests/functional/graph_selection/fixtures.py +++ b/tests/functional/graph_selection/fixtures.py @@ -1,6 +1,6 @@ import pytest -from dbt.tests.util import read_file +from dbt.tests.util import read_file schema_yml = """ version: 2 diff --git a/tests/functional/graph_selection/test_graph_selection.py b/tests/functional/graph_selection/test_graph_selection.py index 9000fb73924..36a8203ef4f 100644 --- a/tests/functional/graph_selection/test_graph_selection.py +++ b/tests/functional/graph_selection/test_graph_selection.py @@ -1,11 +1,11 @@ -import os import json +import os + import pytest -from dbt.tests.util import run_dbt, check_result_nodes_by_name +from dbt.tests.util import check_result_nodes_by_name, run_dbt from tests.functional.graph_selection.fixtures import SelectionFixtures - selectors_yml = """ selectors: - name: bi_selector diff --git a/tests/functional/graph_selection/test_group_selection.py b/tests/functional/graph_selection/test_group_selection.py index c14f008b7d9..fe028666956 100644 --- a/tests/functional/graph_selection/test_group_selection.py +++ b/tests/functional/graph_selection/test_group_selection.py @@ -1,22 +1,21 @@ import pytest -from dbt.tests.util import run_dbt, read_file +from dbt.tests.util import read_file, run_dbt from tests.functional.graph_selection.fixtures import ( - schema_yml, + alternative_users_sql, base_users_sql, - users_sql, - users_rollup_sql, - users_rollup_dependency_sql, - emails_sql, emails_alt_sql, - alternative_users_sql, - never_selected_sql, - subdir_sql, + emails_sql, nested_users_sql, + never_selected_sql, properties_yml, + schema_yml, + subdir_sql, + users_rollup_dependency_sql, + users_rollup_sql, + users_sql, ) - selectors_yml = """ selectors: - name: group_specified_as_string_str diff --git a/tests/functional/graph_selection/test_intersection_syntax.py b/tests/functional/graph_selection/test_intersection_syntax.py index 29c53fd405c..35cf78e6d6d 100644 --- a/tests/functional/graph_selection/test_intersection_syntax.py +++ b/tests/functional/graph_selection/test_intersection_syntax.py @@ -1,9 +1,8 @@ import pytest -from dbt.tests.util import run_dbt, check_result_nodes_by_name +from dbt.tests.util import check_result_nodes_by_name, run_dbt from tests.functional.graph_selection.fixtures import SelectionFixtures - selectors_yml = """ selectors: - name: same_intersection diff --git a/tests/functional/graph_selection/test_schema_test_graph_selection.py b/tests/functional/graph_selection/test_schema_test_graph_selection.py index 105397d4112..48ca572f370 100644 --- a/tests/functional/graph_selection/test_schema_test_graph_selection.py +++ b/tests/functional/graph_selection/test_schema_test_graph_selection.py @@ -1,8 +1,7 @@ import pytest -from dbt.tests.util import run_dbt from dbt.tests.fixtures.project import write_project_files - +from dbt.tests.util import run_dbt from tests.fixtures.dbt_integration_project import dbt_integration_project # noqa: F401 from tests.functional.graph_selection.fixtures import SelectionFixtures diff --git a/tests/functional/graph_selection/test_tag_selection.py b/tests/functional/graph_selection/test_tag_selection.py index 7e954ad22db..7561937e18d 100644 --- a/tests/functional/graph_selection/test_tag_selection.py +++ b/tests/functional/graph_selection/test_tag_selection.py @@ -1,9 +1,8 @@ import pytest -from dbt.tests.util import run_dbt, check_result_nodes_by_name +from dbt.tests.util import check_result_nodes_by_name, run_dbt from tests.functional.graph_selection.fixtures import SelectionFixtures - selectors_yml = """ selectors: - name: tag_specified_as_string_str diff --git a/tests/functional/graph_selection/test_version_selection.py b/tests/functional/graph_selection/test_version_selection.py index 4f9325a1fb8..335fad25270 100644 --- a/tests/functional/graph_selection/test_version_selection.py +++ b/tests/functional/graph_selection/test_version_selection.py @@ -1,15 +1,14 @@ import pytest -from dbt.tests.util import run_dbt, read_file +from dbt.tests.util import read_file, run_dbt from tests.functional.graph_selection.fixtures import ( - schema_yml, base_users_sql, - users_sql, - users_rollup_sql, properties_yml, + schema_yml, + users_rollup_sql, + users_sql, ) - selectors_yml = """ selectors: - name: version_specified_as_string_str diff --git a/tests/functional/incremental_schema_tests/test_incremental_schema.py b/tests/functional/incremental_schema_tests/test_incremental_schema.py index 8203f497331..28d4ab546bf 100644 --- a/tests/functional/incremental_schema_tests/test_incremental_schema.py +++ b/tests/functional/incremental_schema_tests/test_incremental_schema.py @@ -1,31 +1,27 @@ import pytest -from dbt.tests.util import ( - check_relations_equal, - run_dbt, -) - +from dbt.tests.util import check_relations_equal, run_dbt from tests.functional.incremental_schema_tests.fixtures import ( - _PROPERTIES__SCHEMA, - _MODELS__INCREMENTAL_SYNC_REMOVE_ONLY, + _MODELS__A, + _MODELS__INCREMENTAL_APPEND_NEW_COLUMNS, + _MODELS__INCREMENTAL_APPEND_NEW_COLUMNS_REMOVE_ONE, + _MODELS__INCREMENTAL_APPEND_NEW_COLUMNS_REMOVE_ONE_TARGET, + _MODELS__INCREMENTAL_APPEND_NEW_COLUMNS_TARGET, + _MODELS__INCREMENTAL_FAIL, _MODELS__INCREMENTAL_IGNORE, - _MODELS__INCREMENTAL_SYNC_REMOVE_ONLY_TARGET, _MODELS__INCREMENTAL_IGNORE_TARGET, - _MODELS__INCREMENTAL_FAIL, _MODELS__INCREMENTAL_SYNC_ALL_COLUMNS, - _MODELS__INCREMENTAL_APPEND_NEW_COLUMNS_REMOVE_ONE, - _MODELS__A, - _MODELS__INCREMENTAL_APPEND_NEW_COLUMNS_TARGET, - _MODELS__INCREMENTAL_APPEND_NEW_COLUMNS, _MODELS__INCREMENTAL_SYNC_ALL_COLUMNS_TARGET, - _MODELS__INCREMENTAL_APPEND_NEW_COLUMNS_REMOVE_ONE_TARGET, - _TESTS__SELECT_FROM_INCREMENTAL_IGNORE, + _MODELS__INCREMENTAL_SYNC_REMOVE_ONLY, + _MODELS__INCREMENTAL_SYNC_REMOVE_ONLY_TARGET, + _PROPERTIES__SCHEMA, _TESTS__SELECT_FROM_A, + _TESTS__SELECT_FROM_INCREMENTAL_APPEND_NEW_COLUMNS, _TESTS__SELECT_FROM_INCREMENTAL_APPEND_NEW_COLUMNS_TARGET, + _TESTS__SELECT_FROM_INCREMENTAL_IGNORE, + _TESTS__SELECT_FROM_INCREMENTAL_IGNORE_TARGET, _TESTS__SELECT_FROM_INCREMENTAL_SYNC_ALL_COLUMNS, _TESTS__SELECT_FROM_INCREMENTAL_SYNC_ALL_COLUMNS_TARGET, - _TESTS__SELECT_FROM_INCREMENTAL_IGNORE_TARGET, - _TESTS__SELECT_FROM_INCREMENTAL_APPEND_NEW_COLUMNS, ) diff --git a/tests/functional/init/test_init.py b/tests/functional/init/test_init.py index 6aee523320c..1c477f9bf0c 100644 --- a/tests/functional/init/test_init.py +++ b/tests/functional/init/test_init.py @@ -1,13 +1,13 @@ -import click import os -import yaml -import pytest from pathlib import Path from unittest import mock from unittest.mock import Mock, call -from dbt.exceptions import DbtRuntimeError +import click +import pytest +import yaml +from dbt.exceptions import DbtRuntimeError from dbt.tests.util import run_dbt diff --git a/tests/functional/invalid_model_tests/test_invalid_models.py b/tests/functional/invalid_model_tests/test_invalid_models.py index 09db17bc325..d931b81331a 100644 --- a/tests/functional/invalid_model_tests/test_invalid_models.py +++ b/tests/functional/invalid_model_tests/test_invalid_models.py @@ -1,10 +1,7 @@ import pytest from dbt.exceptions import CompilationError, ParsingError - -from dbt.tests.util import ( - run_dbt, -) +from dbt.tests.util import run_dbt # from `test/integration/011_invalid_model_tests`, invalid_model_tests diff --git a/tests/functional/list/fixtures.py b/tests/functional/list/fixtures.py index 7681e1c5632..48cd5710347 100644 --- a/tests/functional/list/fixtures.py +++ b/tests/functional/list/fixtures.py @@ -1,6 +1,6 @@ import pytest -from dbt.tests.fixtures.project import write_project_files +from dbt.tests.fixtures.project import write_project_files snapshots__snapshot_sql = """ {% snapshot my_snapshot %} diff --git a/tests/functional/list/test_list.py b/tests/functional/list/test_list.py index 4eb8cb8e2f9..388fea029b2 100644 --- a/tests/functional/list/test_list.py +++ b/tests/functional/list/test_list.py @@ -1,21 +1,21 @@ -import pytest -import os import json +import os -from dbt.tests.util import run_dbt -from dbt.logger import log_manager +import pytest +from dbt.logger import log_manager +from dbt.tests.util import run_dbt from tests.functional.list.fixtures import ( # noqa: F401 - snapshots, - tests, - models, - macros, - seeds, analyses, - semantic_models, + macros, metrics, - saved_queries, + models, project_files, + saved_queries, + seeds, + semantic_models, + snapshots, + tests, ) diff --git a/tests/functional/logging/test_logging.py b/tests/functional/logging/test_logging.py index c4799f609d9..9205a8faab4 100644 --- a/tests/functional/logging/test_logging.py +++ b/tests/functional/logging/test_logging.py @@ -1,10 +1,11 @@ -import pytest -from dbt.tests.util import run_dbt, get_manifest, read_file import json import os -from dbt_common.events.functions import fire_event -from dbt.events.types import InvalidOptionYAML +import pytest + +from dbt.events.types import InvalidOptionYAML +from dbt.tests.util import get_manifest, read_file, run_dbt +from dbt_common.events.functions import fire_event my_model_sql = """ select 1 as fun diff --git a/tests/functional/logging/test_meta_logging.py b/tests/functional/logging/test_meta_logging.py index aa262730077..19b10725273 100644 --- a/tests/functional/logging/test_meta_logging.py +++ b/tests/functional/logging/test_meta_logging.py @@ -1,7 +1,9 @@ -import pytest -from dbt.tests.util import run_dbt, read_file import json +import pytest + +from dbt.tests.util import read_file, run_dbt + model1 = "select 1 as fun" model2 = '{{ config(meta={"owners": ["team1", "team2"]})}} select 1 as fun' model3 = '{{ config(meta={"key": 1})}} select 1 as fun' diff --git a/tests/functional/macros/test_macros.py b/tests/functional/macros/test_macros.py index 7838e713be9..fb3d808526b 100644 --- a/tests/functional/macros/test_macros.py +++ b/tests/functional/macros/test_macros.py @@ -1,33 +1,28 @@ -import pytest import shutil - -import dbt_common.exceptions - from pathlib import Path -from dbt.tests.util import ( - run_dbt, - check_relations_equal, -) +import pytest +import dbt_common.exceptions from dbt.tests.fixtures.project import write_project_files +from dbt.tests.util import check_relations_equal, run_dbt from tests.functional.macros.fixtures import ( dbt_project__incorrect_dispatch, - models__dep_macro, - models__with_undefined_macro, - models__local_macro, - models__ref_macro, - models__override_get_columns_macros, - models__deprecated_adapter_macro_model, - models__incorrect_dispatch, - models__materialization_macro, + macros__deprecated_adapter_macro, + macros__incorrect_dispatch, macros__my_macros, + macros__named_materialization, macros__no_default_macros, macros__override_get_columns_macros, macros__package_override_get_columns_macros, - macros__deprecated_adapter_macro, - macros__incorrect_dispatch, - macros__named_materialization, + models__dep_macro, + models__deprecated_adapter_macro_model, + models__incorrect_dispatch, + models__local_macro, + models__materialization_macro, + models__override_get_columns_macros, + models__ref_macro, + models__with_undefined_macro, ) diff --git a/tests/functional/manifest_validations/test_check_for_spaces_in_model_names.py b/tests/functional/manifest_validations/test_check_for_spaces_in_model_names.py index 1e7b8fc0364..4ba25a530f9 100644 --- a/tests/functional/manifest_validations/test_check_for_spaces_in_model_names.py +++ b/tests/functional/manifest_validations/test_check_for_spaces_in_model_names.py @@ -1,12 +1,16 @@ +from typing import Dict + import pytest -from dbt.cli.main import dbtRunner from dbt import deprecations -from dbt_common.events.base_types import EventLevel -from dbt.events.types import SpacesInResourceNameDeprecation, ResourceNamesWithSpacesDeprecation +from dbt.cli.main import dbtRunner +from dbt.events.types import ( + ResourceNamesWithSpacesDeprecation, + SpacesInResourceNameDeprecation, +) from dbt.tests.util import update_config_file +from dbt_common.events.base_types import EventLevel from tests.functional.utils import EventCatcher -from typing import Dict class TestSpacesInModelNamesHappyPath: diff --git a/tests/functional/materializations/conftest.py b/tests/functional/materializations/conftest.py index 8441e72c0b2..f8b483d46cd 100644 --- a/tests/functional/materializations/conftest.py +++ b/tests/functional/materializations/conftest.py @@ -1,6 +1,6 @@ import pytest -from dbt.tests.fixtures.project import write_project_files +from dbt.tests.fixtures.project import write_project_files override_view_adapter_pass_dep__dbt_project_yml = """ name: view_adapter_override diff --git a/tests/functional/materializations/test_custom_materialization.py b/tests/functional/materializations/test_custom_materialization.py index 0a100021db2..ae377cdb428 100644 --- a/tests/functional/materializations/test_custom_materialization.py +++ b/tests/functional/materializations/test_custom_materialization.py @@ -1,7 +1,7 @@ import pytest -from dbt.tests.util import run_dbt from dbt import deprecations +from dbt.tests.util import run_dbt models__model_sql = """ {{ config(materialized='view') }} diff --git a/tests/functional/materializations/test_ephemeral_compilation.py b/tests/functional/materializations/test_ephemeral_compilation.py index f8419e40fd5..3b8ea9d4a86 100644 --- a/tests/functional/materializations/test_ephemeral_compilation.py +++ b/tests/functional/materializations/test_ephemeral_compilation.py @@ -1,31 +1,31 @@ +import pytest + from dbt.contracts.graph.nodes import ModelNode from dbt.contracts.results import RunExecutionResult, RunResult -import pytest from dbt.tests.util import run_dbt - -# Note: This tests compilation only, so is a dbt Core test and not an adapter test. -# There is some complicated logic in core/dbt/compilation.py having to do with -# ephemeral nodes and handling multiple threads at the same time. This test -# fails fairly regularly if that is broken, but does occasionally work (depending -# on the order in which things are compiled). It requires multi-threading to fail. - from tests.functional.materializations.fixtures import ( - fct_eph_first_sql, - int_eph_first_sql, - schema_yml, - bar_sql, bar1_sql, bar2_sql, bar3_sql, bar4_sql, bar5_sql, - baz_sql, + bar_sql, baz1_sql, - foo_sql, + baz_sql, + fct_eph_first_sql, foo1_sql, foo2_sql, + foo_sql, + int_eph_first_sql, + schema_yml, ) +# Note: This tests compilation only, so is a dbt Core test and not an adapter test. +# There is some complicated logic in core/dbt/compilation.py having to do with +# ephemeral nodes and handling multiple threads at the same time. This test +# fails fairly regularly if that is broken, but does occasionally work (depending +# on the order in which things are compiled). It requires multi-threading to fail. + SUPPRESSED_CTE_EXPECTED_OUTPUT = """-- fct_eph_first.sql diff --git a/tests/functional/materializations/test_incremental.py b/tests/functional/materializations/test_incremental.py index b331c9d14b5..48745d0f987 100644 --- a/tests/functional/materializations/test_incremental.py +++ b/tests/functional/materializations/test_incremental.py @@ -1,8 +1,8 @@ import pytest -from dbt.tests.util import run_dbt, get_manifest -from dbt.exceptions import DbtRuntimeError -from dbt.context.providers import generate_runtime_model_context +from dbt.context.providers import generate_runtime_model_context +from dbt.exceptions import DbtRuntimeError +from dbt.tests.util import get_manifest, run_dbt my_model_sql = """ select 1 as fun diff --git a/tests/functional/materializations/test_runtime_materialization.py b/tests/functional/materializations/test_runtime_materialization.py index 336aac561f2..6f84b478e2b 100644 --- a/tests/functional/materializations/test_runtime_materialization.py +++ b/tests/functional/materializations/test_runtime_materialization.py @@ -1,6 +1,6 @@ import pytest -from dbt.tests.util import run_dbt, check_relations_equal, check_table_does_not_exist +from dbt.tests.util import check_relations_equal, check_table_does_not_exist, run_dbt models__view_sql = """ {{ diff --git a/tests/functional/materializations/test_supported_languages.py b/tests/functional/materializations/test_supported_languages.py index a2ef8077de5..5e7b8b332e4 100644 --- a/tests/functional/materializations/test_supported_languages.py +++ b/tests/functional/materializations/test_supported_languages.py @@ -1,6 +1,6 @@ import pytest -from dbt.tests.util import run_dbt +from dbt.tests.util import run_dbt custom_mat_tmpl = """ {% materialization custom_mat{} %} diff --git a/tests/functional/metrics/test_metric_configs.py b/tests/functional/metrics/test_metric_configs.py index 5a1246dae9a..2be68d9e17f 100644 --- a/tests/functional/metrics/test_metric_configs.py +++ b/tests/functional/metrics/test_metric_configs.py @@ -1,19 +1,18 @@ import pytest + from dbt.artifacts.resources import MetricConfig -from dbt_common.dataclass_schema import ValidationError from dbt.exceptions import CompilationError, ParsingError -from dbt.tests.util import run_dbt, update_config_file, get_manifest - - +from dbt.tests.util import get_manifest, run_dbt, update_config_file +from dbt_common.dataclass_schema import ValidationError from tests.functional.metrics.fixtures import ( - models_people_sql, - models_people_metrics_yml, - models_people_metrics_meta_top_yml, - metricflow_time_spine_sql, disabled_metric_level_schema_yml, enabled_metric_level_schema_yml, - models_people_metrics_sql, invalid_config_metric_yml, + metricflow_time_spine_sql, + models_people_metrics_meta_top_yml, + models_people_metrics_sql, + models_people_metrics_yml, + models_people_sql, semantic_model_people_yml, ) diff --git a/tests/functional/metrics/test_metric_deferral.py b/tests/functional/metrics/test_metric_deferral.py index 8803bf249da..603016acb0c 100644 --- a/tests/functional/metrics/test_metric_deferral.py +++ b/tests/functional/metrics/test_metric_deferral.py @@ -1,7 +1,9 @@ import os -import pytest -from dbt.tests.util import run_dbt, copy_file, write_file from pathlib import Path + +import pytest + +from dbt.tests.util import copy_file, run_dbt, write_file from tests.functional.metrics.fixtures import ( metrics_1_yml, metrics_2_yml, diff --git a/tests/functional/metrics/test_metric_helper_functions.py b/tests/functional/metrics/test_metric_helper_functions.py index a5775a0ed74..8abdce4af29 100644 --- a/tests/functional/metrics/test_metric_helper_functions.py +++ b/tests/functional/metrics/test_metric_helper_functions.py @@ -1,14 +1,13 @@ import pytest -from dbt.tests.util import run_dbt from dbt.contracts.graph.manifest import Manifest from dbt.contracts.graph.metrics import ResolvedMetricReference - +from dbt.tests.util import run_dbt from tests.functional.metrics.fixtures import ( - models_people_sql, basic_metrics_yml, - semantic_model_people_yml, metricflow_time_spine_sql, + models_people_sql, + semantic_model_people_yml, ) diff --git a/tests/functional/metrics/test_metrics.py b/tests/functional/metrics/test_metrics.py index f87cc56b9b3..b640c90c199 100644 --- a/tests/functional/metrics/test_metrics.py +++ b/tests/functional/metrics/test_metrics.py @@ -3,34 +3,32 @@ from dbt.cli.main import dbtRunner from dbt.contracts.graph.manifest import Manifest from dbt.exceptions import ParsingError -from dbt.tests.util import run_dbt, get_manifest - - +from dbt.tests.util import get_manifest, run_dbt from tests.functional.metrics.fixtures import ( - conversion_semantic_model_purchasing_yml, + basic_metrics_yml, conversion_metric_yml, - mock_purchase_data_csv, - models_people_sql, - models_people_metrics_yml, - invalid_models_people_metrics_yml, - invalid_metrics_missing_model_yml, - invalid_metrics_missing_expression_yml, - names_with_spaces_metrics_yml, - names_with_special_chars_metrics_yml, - names_with_leading_numeric_metrics_yml, - long_name_metrics_yml, + conversion_semantic_model_purchasing_yml, + derived_metric_yml, downstream_model_sql, + duplicate_measure_metric_yml, + filtered_metrics_yml, invalid_derived_metric_contains_model_yml, - derived_metric_yml, invalid_metric_without_timestamp_with_time_grains_yml, invalid_metric_without_timestamp_with_window_yml, + invalid_metrics_missing_expression_yml, + invalid_metrics_missing_model_yml, + invalid_models_people_metrics_yml, + long_name_metrics_yml, metricflow_time_spine_sql, + mock_purchase_data_csv, + models_people_metrics_yml, + models_people_sql, + names_with_leading_numeric_metrics_yml, + names_with_spaces_metrics_yml, + names_with_special_chars_metrics_yml, + purchasing_model_sql, semantic_model_people_yml, semantic_model_purchasing_yml, - purchasing_model_sql, - filtered_metrics_yml, - basic_metrics_yml, - duplicate_measure_metric_yml, ) diff --git a/tests/functional/partial_parsing/test_file_diff.py b/tests/functional/partial_parsing/test_file_diff.py index f2493de19df..3661a823a65 100644 --- a/tests/functional/partial_parsing/test_file_diff.py +++ b/tests/functional/partial_parsing/test_file_diff.py @@ -1,10 +1,10 @@ import os + import pytest from dbt.tests.util import run_dbt, write_artifact, write_file from tests.functional.partial_parsing.fixtures import model_one_sql, model_two_sql - first_file_diff = { "deleted": [], "changed": [], diff --git a/tests/functional/partial_parsing/test_partial_parsing.py b/tests/functional/partial_parsing/test_partial_parsing.py index 6b5ba8895cd..5a1f496c511 100644 --- a/tests/functional/partial_parsing/test_partial_parsing.py +++ b/tests/functional/partial_parsing/test_partial_parsing.py @@ -1,85 +1,84 @@ +import os +import re from argparse import Namespace -import pytest from unittest import mock +import pytest +import yaml + import dbt.flags as flags +from dbt.contracts.files import ParseFileType +from dbt.contracts.results import TestStatus +from dbt.exceptions import CompilationError +from dbt.plugins.manifest import ModelNodeArgs, PluginNodes +from dbt.tests.fixtures.project import write_project_files from dbt.tests.util import ( - run_dbt, get_manifest, - write_file, + rename_dir, rm_file, + run_dbt, run_dbt_and_capture, - rename_dir, + write_file, ) -import yaml -from tests.functional.utils import up_one -from dbt.tests.fixtures.project import write_project_files from tests.functional.partial_parsing.fixtures import ( + custom_schema_tests1_sql, + custom_schema_tests2_sql, + customers1_md, + customers2_md, + customers_sql, + empty_schema_with_version_yml, + empty_schema_yml, + generic_schema_yml, + generic_test_edited_sql, + generic_test_schema_yml, + generic_test_sql, + gsm_override2_sql, + gsm_override_sql, + local_dependency__dbt_project_yml, + local_dependency__macros__dep_macro_sql, + local_dependency__models__model_to_import_sql, + local_dependency__models__schema_yml, + local_dependency__seeds__seed_csv, + macros_schema_yml, + macros_yml, + model_a_sql, + model_b_sql, + model_four1_sql, + model_four2_sql, model_one_sql, + model_three_disabled2_sql, + model_three_disabled_sql, + model_three_modified_sql, + model_three_sql, model_two_sql, models_schema1_yml, models_schema2_yml, models_schema2b_yml, - model_three_sql, - model_three_modified_sql, - model_four1_sql, - model_four2_sql, + models_schema3_yml, models_schema4_yml, models_schema4b_yml, - models_schema3_yml, - my_macro_sql, + my_analysis_sql, my_macro2_sql, - macros_yml, - empty_schema_yml, - empty_schema_with_version_yml, - model_three_disabled_sql, - model_three_disabled2_sql, + my_macro_sql, + my_test_sql, + orders_sql, raw_customers_csv, - customers_sql, - sources_tests1_sql, + ref_override2_sql, + ref_override_sql, + schema_models_c_yml, schema_sources1_yml, schema_sources2_yml, schema_sources3_yml, schema_sources4_yml, schema_sources5_yml, - customers1_md, - customers2_md, - test_macro_sql, - my_test_sql, - test_macro2_sql, - my_analysis_sql, - sources_tests2_sql, - local_dependency__dbt_project_yml, - local_dependency__models__schema_yml, - local_dependency__models__model_to_import_sql, - local_dependency__macros__dep_macro_sql, - local_dependency__seeds__seed_csv, - schema_models_c_yml, - model_a_sql, - model_b_sql, - macros_schema_yml, - custom_schema_tests1_sql, - custom_schema_tests2_sql, - ref_override_sql, - ref_override2_sql, - gsm_override_sql, - gsm_override2_sql, - orders_sql, - snapshot_sql, snapshot2_sql, - generic_schema_yml, - generic_test_sql, - generic_test_schema_yml, - generic_test_edited_sql, + snapshot_sql, + sources_tests1_sql, + sources_tests2_sql, + test_macro2_sql, + test_macro_sql, ) - -from dbt.exceptions import CompilationError -from dbt.contracts.files import ParseFileType -from dbt.contracts.results import TestStatus -from dbt.plugins.manifest import PluginNodes, ModelNodeArgs - -import re -import os +from tests.functional.utils import up_one os.environ["DBT_PP_TEST"] = "true" diff --git a/tests/functional/partial_parsing/test_pp_disabled_config.py b/tests/functional/partial_parsing/test_pp_disabled_config.py index 03d2e8a728b..472d84ecff6 100644 --- a/tests/functional/partial_parsing/test_pp_disabled_config.py +++ b/tests/functional/partial_parsing/test_pp_disabled_config.py @@ -1,5 +1,6 @@ import pytest -from dbt.tests.util import run_dbt, write_file, get_manifest + +from dbt.tests.util import get_manifest, run_dbt, write_file model_one_sql = """ select 1 as fun diff --git a/tests/functional/partial_parsing/test_pp_docs.py b/tests/functional/partial_parsing/test_pp_docs.py index 871e015b493..c818cca364b 100644 --- a/tests/functional/partial_parsing/test_pp_docs.py +++ b/tests/functional/partial_parsing/test_pp_docs.py @@ -1,5 +1,6 @@ import pytest -from dbt.tests.util import run_dbt, write_file, get_manifest, rm_file + +from dbt.tests.util import get_manifest, rm_file, run_dbt, write_file model_one_sql = """ select 1 as fun diff --git a/tests/functional/partial_parsing/test_pp_groups.py b/tests/functional/partial_parsing/test_pp_groups.py index 5871d3dd98f..57a0917105e 100644 --- a/tests/functional/partial_parsing/test_pp_groups.py +++ b/tests/functional/partial_parsing/test_pp_groups.py @@ -1,17 +1,16 @@ import pytest -from dbt.tests.util import run_dbt, get_manifest, write_file from dbt.exceptions import ParsingError - +from dbt.tests.util import get_manifest, run_dbt, write_file from tests.functional.partial_parsing.fixtures import ( - orders_sql, - orders_downstream_sql, groups_schema_yml_one_group, + groups_schema_yml_one_group_model_in_group2, groups_schema_yml_two_groups, groups_schema_yml_two_groups_edited, - groups_schema_yml_one_group_model_in_group2, - groups_schema_yml_two_groups_private_orders_valid_access, groups_schema_yml_two_groups_private_orders_invalid_access, + groups_schema_yml_two_groups_private_orders_valid_access, + orders_downstream_sql, + orders_sql, ) diff --git a/tests/functional/partial_parsing/test_pp_metrics.py b/tests/functional/partial_parsing/test_pp_metrics.py index 19da625604b..9aa5530c419 100644 --- a/tests/functional/partial_parsing/test_pp_metrics.py +++ b/tests/functional/partial_parsing/test_pp_metrics.py @@ -2,20 +2,19 @@ from dbt.cli.main import dbtRunner from dbt.contracts.graph.manifest import Manifest -from dbt.tests.util import run_dbt, rm_file, write_file, get_manifest +from dbt.exceptions import CompilationError +from dbt.tests.util import get_manifest, rm_file, run_dbt, write_file from tests.functional.partial_parsing.fixtures import ( - people_sql, + metric_model_a_sql, metricflow_time_spine_sql, - people_semantic_models_yml, - people_metrics_yml, people_metrics2_yml, - metric_model_a_sql, people_metrics3_yml, + people_metrics_yml, + people_semantic_models_yml, people_sl_yml, + people_sql, ) -from dbt.exceptions import CompilationError - class TestMetrics: @pytest.fixture(scope="class") diff --git a/tests/functional/partial_parsing/test_pp_vars.py b/tests/functional/partial_parsing/test_pp_vars.py index 10cb5c6219f..a2e915dcb34 100644 --- a/tests/functional/partial_parsing/test_pp_vars.py +++ b/tests/functional/partial_parsing/test_pp_vars.py @@ -2,11 +2,11 @@ from pathlib import Path import pytest -from dbt_common.constants import SECRET_ENV_PREFIX -from dbt.exceptions import ParsingError + from dbt.adapters.exceptions import FailedToConnectError +from dbt.exceptions import ParsingError from dbt.tests.util import get_manifest, run_dbt, run_dbt_and_capture, write_file - +from dbt_common.constants import SECRET_ENV_PREFIX from tests.functional.partial_parsing.fixtures import ( env_var_macro_sql, env_var_macros_yml, diff --git a/tests/functional/partial_parsing/test_versioned_models.py b/tests/functional/partial_parsing/test_versioned_models.py index 06e56d9c0cd..0e6ef22cd2f 100644 --- a/tests/functional/partial_parsing/test_versioned_models.py +++ b/tests/functional/partial_parsing/test_versioned_models.py @@ -1,13 +1,9 @@ -import pytest import pathlib -from dbt.tests.util import ( - run_dbt, - get_manifest, - write_file, - rm_file, - read_file, -) + +import pytest + from dbt.exceptions import DuplicateVersionedUnversionedError +from dbt.tests.util import get_manifest, read_file, rm_file, run_dbt, write_file model_one_sql = """ select 1 as fun diff --git a/tests/functional/permission/fixtures.py b/tests/functional/permission/fixtures.py index e6014b09754..7ac2f6f3665 100644 --- a/tests/functional/permission/fixtures.py +++ b/tests/functional/permission/fixtures.py @@ -1,6 +1,6 @@ import pytest -from dbt.tests.fixtures.project import write_project_files +from dbt.tests.fixtures.project import write_project_files models__view_model_sql = """ diff --git a/tests/functional/postgres/test_postgres_indexes.py b/tests/functional/postgres/test_postgres_indexes.py index 143a0888755..ceb9d0514bd 100644 --- a/tests/functional/postgres/test_postgres_indexes.py +++ b/tests/functional/postgres/test_postgres_indexes.py @@ -1,21 +1,19 @@ -import pytest import re -from dbt.tests.util import ( - run_dbt, - run_dbt_and_capture, -) + +import pytest + +from dbt.tests.util import run_dbt, run_dbt_and_capture from tests.functional.postgres.fixtures import ( models__incremental_sql, models__table_sql, - models_invalid__missing_columns_sql, models_invalid__invalid_columns_type_sql, models_invalid__invalid_type_sql, models_invalid__invalid_unique_config_sql, + models_invalid__missing_columns_sql, seeds__seed_csv, snapshots__colors_sql, ) - INDEX_DEFINITION_PATTERN = re.compile(r"using\s+(\w+)\s+\((.+)\)\Z") diff --git a/tests/functional/postgres/test_postgres_unlogged_table.py b/tests/functional/postgres/test_postgres_unlogged_table.py index bfb739ef41e..50c23635b64 100644 --- a/tests/functional/postgres/test_postgres_unlogged_table.py +++ b/tests/functional/postgres/test_postgres_unlogged_table.py @@ -1,6 +1,6 @@ import pytest -from dbt.tests.util import run_dbt +from dbt.tests.util import run_dbt schema_yml = """ version: 2 diff --git a/tests/functional/profiles/test_profile_dir.py b/tests/functional/profiles/test_profile_dir.py index b9237af5dce..8545e2c4773 100644 --- a/tests/functional/profiles/test_profile_dir.py +++ b/tests/functional/profiles/test_profile_dir.py @@ -1,19 +1,13 @@ import os -import pytest -import yaml - +from argparse import Namespace from contextlib import contextmanager from pathlib import Path -from argparse import Namespace -import dbt.flags as flags +import pytest +import yaml -from dbt.tests.util import ( - run_dbt, - run_dbt_and_capture, - write_file, - rm_file, -) +import dbt.flags as flags +from dbt.tests.util import rm_file, run_dbt, run_dbt_and_capture, write_file @pytest.fixture(scope="class") diff --git a/tests/functional/profiles/test_profiles_yml.py b/tests/functional/profiles/test_profiles_yml.py index 50771c24132..2af18b5f982 100644 --- a/tests/functional/profiles/test_profiles_yml.py +++ b/tests/functional/profiles/test_profiles_yml.py @@ -1,4 +1,5 @@ import pathlib + from test_profile_dir import environ from dbt.cli.main import dbtRunner diff --git a/tests/functional/ref_override/test_ref_override.py b/tests/functional/ref_override/test_ref_override.py index d77dcc78bc4..97ffa790173 100644 --- a/tests/functional/ref_override/test_ref_override.py +++ b/tests/functional/ref_override/test_ref_override.py @@ -1,7 +1,6 @@ import pytest -from dbt.tests.util import run_dbt, check_relations_equal - +from dbt.tests.util import check_relations_equal, run_dbt models__ref_override_sql = """ select diff --git a/tests/functional/retry/test_retry.py b/tests/functional/retry/test_retry.py index 7bf8d8a0ef5..012db25e42f 100644 --- a/tests/functional/retry/test_retry.py +++ b/tests/functional/retry/test_retry.py @@ -5,13 +5,13 @@ from dbt.contracts.results import RunStatus, TestStatus from dbt.exceptions import DbtRuntimeError, TargetNotFoundError -from dbt.tests.util import run_dbt, write_file, rm_file +from dbt.tests.util import rm_file, run_dbt, write_file from tests.functional.retry.fixtures import ( + macros__alter_timezone_sql, models__sample_model, + models__second_model, models__union_model, schema_yml, - models__second_model, - macros__alter_timezone_sql, simple_model, simple_schema, ) diff --git a/tests/functional/run_operations/test_run_operations.py b/tests/functional/run_operations/test_run_operations.py index 465deb6c643..064c98b3a51 100644 --- a/tests/functional/run_operations/test_run_operations.py +++ b/tests/functional/run_operations/test_run_operations.py @@ -3,17 +3,21 @@ import pytest import yaml -from dbt_common.exceptions import DbtInternalError from dbt.tests.util import ( check_table_does_exist, - run_dbt, - write_file, mkdir, - run_dbt_and_capture, rm_dir, rm_file, + run_dbt, + run_dbt_and_capture, + write_file, +) +from dbt_common.exceptions import DbtInternalError +from tests.functional.run_operations.fixtures import ( + happy_macros_sql, + model_sql, + sad_macros_sql, ) -from tests.functional.run_operations.fixtures import happy_macros_sql, sad_macros_sql, model_sql class TestOperations: diff --git a/tests/functional/saved_queries/test_configs.py b/tests/functional/saved_queries/test_configs.py index ef63888441a..1ce068bc261 100644 --- a/tests/functional/saved_queries/test_configs.py +++ b/tests/functional/saved_queries/test_configs.py @@ -1,18 +1,20 @@ import pytest +from dbt_semantic_interfaces.type_enums.export_destination_type import ( + ExportDestinationType, +) from dbt.contracts.graph.manifest import Manifest from dbt.tests.util import update_config_file -from dbt_semantic_interfaces.type_enums.export_destination_type import ExportDestinationType from tests.functional.assertions.test_runner import dbtTestRunner from tests.functional.configs.fixtures import BaseConfigProject from tests.functional.saved_queries.fixtures import ( + saved_queries_with_defaults_yml, saved_queries_yml, saved_query_description, saved_query_with_cache_configs_defined_yml, - saved_query_with_extra_config_attributes_yml, saved_query_with_export_configs_defined_at_saved_query_level_yml, + saved_query_with_extra_config_attributes_yml, saved_query_without_export_configs_defined_yml, - saved_queries_with_defaults_yml, ) from tests.functional.semantic_models.fixtures import ( fct_revenue_sql, diff --git a/tests/functional/saved_queries/test_saved_query_build.py b/tests/functional/saved_queries/test_saved_query_build.py index 2f721b15337..dc89521f380 100644 --- a/tests/functional/saved_queries/test_saved_query_build.py +++ b/tests/functional/saved_queries/test_saved_query_build.py @@ -1,7 +1,10 @@ import pytest from dbt.tests.util import run_dbt -from tests.functional.saved_queries.fixtures import saved_queries_yml, saved_query_description +from tests.functional.saved_queries.fixtures import ( + saved_queries_yml, + saved_query_description, +) from tests.functional.semantic_models.fixtures import ( fct_revenue_sql, metricflow_time_spine_sql, diff --git a/tests/functional/saved_queries/test_saved_query_parsing.py b/tests/functional/saved_queries/test_saved_query_parsing.py index 9c02b7c5418..ce3763acfbc 100644 --- a/tests/functional/saved_queries/test_saved_query_parsing.py +++ b/tests/functional/saved_queries/test_saved_query_parsing.py @@ -1,16 +1,18 @@ from typing import List import pytest +from dbt_semantic_interfaces.type_enums.export_destination_type import ( + ExportDestinationType, +) from dbt.contracts.graph.manifest import Manifest -from dbt_common.events.base_types import BaseEvent from dbt.tests.util import write_file -from dbt_semantic_interfaces.type_enums.export_destination_type import ExportDestinationType +from dbt_common.events.base_types import BaseEvent from tests.functional.assertions.test_runner import dbtTestRunner from tests.functional.saved_queries.fixtures import ( + saved_queries_with_diff_filters_yml, saved_queries_yml, saved_query_description, - saved_queries_with_diff_filters_yml, ) from tests.functional.semantic_models.fixtures import ( fct_revenue_sql, diff --git a/tests/functional/schema/test_custom_schema.py b/tests/functional/schema/test_custom_schema.py index 7262a79cce9..5a9969e4284 100644 --- a/tests/functional/schema/test_custom_schema.py +++ b/tests/functional/schema/test_custom_schema.py @@ -1,5 +1,6 @@ import pytest -from dbt.tests.util import run_dbt, check_relations_equal + +from dbt.tests.util import check_relations_equal, run_dbt from tests.functional.schema.fixtures.macros import ( _CUSTOM_MACRO, _CUSTOM_MACRO_MULTI_SCHEMA, diff --git a/tests/functional/schema_tests/test_schema_v2_tests.py b/tests/functional/schema_tests/test_schema_v2_tests.py index 34286d82532..ea33e62bce3 100644 --- a/tests/functional/schema_tests/test_schema_v2_tests.py +++ b/tests/functional/schema_tests/test_schema_v2_tests.py @@ -1,102 +1,103 @@ -import pytest import os import re -from dbt.tests.util import run_dbt, write_file +import pytest + +from dbt.contracts.results import TestStatus +from dbt.exceptions import CompilationError, DuplicateResourceNameError, ParsingError from dbt.tests.fixtures.project import write_project_files +from dbt.tests.util import run_dbt, write_file from tests.fixtures.dbt_integration_project import dbt_integration_project # noqa: F401 from tests.functional.schema_tests.fixtures import ( - wrong_specification_block__schema_yml, - test_context_where_subq_models__schema_yml, - test_context_where_subq_models__model_a_sql, - test_utils__dbt_project_yml, - test_utils__macros__current_timestamp_sql, - test_utils__macros__custom_test_sql, - local_dependency__dbt_project_yml, - local_dependency__macros__equality_sql, - case_sensitive_models__schema_yml, + all_quotes_schema__schema_yml, + alt_local_utils__macros__type_timestamp_sql, case_sensitive_models__lowercase_sql, - test_context_macros__my_test_sql, - test_context_macros__test_my_datediff_sql, - test_context_macros__custom_schema_tests_sql, - test_context_models_namespaced__schema_yml, - test_context_models_namespaced__model_c_sql, - test_context_models_namespaced__model_b_sql, - test_context_models_namespaced__model_a_sql, - macros_v2__override_get_test_macros_fail__get_test_sql_sql, - macros_v2__macros__tests_sql, - macros_v2__custom_configs__test_sql, - macros_v2__override_get_test_macros__get_test_sql_sql, - test_context_macros_namespaced__my_test_sql, - test_context_macros_namespaced__custom_schema_tests_sql, - seeds__some_seed_csv, - test_context_models__schema_yml, - test_context_models__model_c_sql, - test_context_models__model_b_sql, - test_context_models__model_a_sql, - name_collision__schema_yml, - name_collision__base_sql, - name_collision__base_extension_sql, - dupe_generic_tests_collide__schema_yml, - dupe_generic_tests_collide__model_a, - custom_generic_test_config_custom_macro__schema_yml, + case_sensitive_models__schema_yml, + case_sensitive_models__uppercase_SQL, custom_generic_test_config_custom_macro__model_a, - custom_generic_test_names__schema_yml, + custom_generic_test_config_custom_macro__schema_yml, custom_generic_test_names__model_a, - custom_generic_test_names_alt_format__schema_yml, + custom_generic_test_names__schema_yml, custom_generic_test_names_alt_format__model_a, - test_context_where_subq_macros__custom_generic_test_sql, - invalid_schema_models__schema_yml, + custom_generic_test_names_alt_format__schema_yml, + dupe_generic_tests_collide__model_a, + dupe_generic_tests_collide__schema_yml, + ephemeral__ephemeral_sql, + ephemeral__schema_yml, invalid_schema_models__model_sql, + invalid_schema_models__schema_yml, + local_dependency__dbt_project_yml, + local_dependency__macros__equality_sql, + local_utils__dbt_project_yml, + local_utils__macros__current_timestamp_sql, + local_utils__macros__custom_test_sql, + local_utils__macros__datediff_sql, + macro_resolution_order_macros__my_custom_test_sql, + macro_resolution_order_models__config_yml, + macro_resolution_order_models__my_model_sql, + macros_v2__custom_configs__test_sql, + macros_v2__macros__tests_sql, + macros_v2__override_get_test_macros__get_test_sql_sql, + macros_v2__override_get_test_macros_fail__get_test_sql_sql, + models_v2__custom__schema_yml, + models_v2__custom__table_copy_sql, + models_v2__custom_configs__schema_yml, + models_v2__custom_configs__table_copy_another_one_sql, + models_v2__custom_configs__table_copy_sql, + models_v2__custom_configs__table_copy_with_dots_sql, + models_v2__limit_null__schema_yml, + models_v2__limit_null__table_failure_limit_null_sql, + models_v2__limit_null__table_limit_null_sql, + models_v2__limit_null__table_warning_limit_null_sql, + models_v2__malformed__schema_yml, + models_v2__malformed__table_copy_sql, + models_v2__malformed__table_summary_sql, models_v2__models__schema_yml, - models_v2__models__table_summary_sql, - models_v2__models__table_failure_summary_sql, + models_v2__models__table_copy_sql, models_v2__models__table_disabled_sql, - models_v2__models__table_failure_null_relation_sql, models_v2__models__table_failure_copy_sql, - models_v2__models__table_copy_sql, - models_v2__limit_null__schema_yml, - models_v2__limit_null__table_warning_limit_null_sql, - models_v2__limit_null__table_limit_null_sql, - models_v2__limit_null__table_failure_limit_null_sql, - models_v2__override_get_test_models__schema_yml, - models_v2__override_get_test_models__my_model_warning_sql, - models_v2__override_get_test_models__my_model_pass_sql, + models_v2__models__table_failure_null_relation_sql, + models_v2__models__table_failure_summary_sql, + models_v2__models__table_summary_sql, models_v2__override_get_test_models__my_model_failure_sql, - models_v2__override_get_test_models_fail__schema_yml, + models_v2__override_get_test_models__my_model_pass_sql, + models_v2__override_get_test_models__my_model_warning_sql, + models_v2__override_get_test_models__schema_yml, models_v2__override_get_test_models_fail__my_model_sql, - models_v2__malformed__schema_yml, - models_v2__malformed__table_summary_sql, - models_v2__malformed__table_copy_sql, - models_v2__custom_configs__schema_yml, - models_v2__custom_configs__table_copy_another_one_sql, - models_v2__custom_configs__table_copy_sql, - models_v2__custom_configs__table_copy_with_dots_sql, - models_v2__custom__schema_yml, - models_v2__custom__table_copy_sql, - models_v2__render_test_cli_arg_models__schema_yml, + models_v2__override_get_test_models_fail__schema_yml, models_v2__render_test_cli_arg_models__model_sql, - models_v2__render_test_configured_arg_models__schema_yml, + models_v2__render_test_cli_arg_models__schema_yml, models_v2__render_test_configured_arg_models__model_sql, - local_utils__dbt_project_yml, - local_utils__macros__datediff_sql, - local_utils__macros__current_timestamp_sql, - local_utils__macros__custom_test_sql, - ephemeral__schema_yml, - ephemeral__ephemeral_sql, - quote_required_models__schema_yml, + models_v2__render_test_configured_arg_models__schema_yml, + name_collision__base_extension_sql, + name_collision__base_sql, + name_collision__schema_yml, quote_required_models__model_again_sql, quote_required_models__model_noquote_sql, quote_required_models__model_sql, - case_sensitive_models__uppercase_SQL, - macro_resolution_order_macros__my_custom_test_sql, - macro_resolution_order_models__config_yml, - macro_resolution_order_models__my_model_sql, - alt_local_utils__macros__type_timestamp_sql, - all_quotes_schema__schema_yml, + quote_required_models__schema_yml, + seeds__some_seed_csv, + test_context_macros__custom_schema_tests_sql, + test_context_macros__my_test_sql, + test_context_macros__test_my_datediff_sql, + test_context_macros_namespaced__custom_schema_tests_sql, + test_context_macros_namespaced__my_test_sql, + test_context_models__model_a_sql, + test_context_models__model_b_sql, + test_context_models__model_c_sql, + test_context_models__schema_yml, + test_context_models_namespaced__model_a_sql, + test_context_models_namespaced__model_b_sql, + test_context_models_namespaced__model_c_sql, + test_context_models_namespaced__schema_yml, + test_context_where_subq_macros__custom_generic_test_sql, + test_context_where_subq_models__model_a_sql, + test_context_where_subq_models__schema_yml, + test_utils__dbt_project_yml, + test_utils__macros__current_timestamp_sql, + test_utils__macros__custom_test_sql, + wrong_specification_block__schema_yml, ) -from dbt.exceptions import ParsingError, CompilationError, DuplicateResourceNameError -from dbt.contracts.results import TestStatus class TestSchemaTests: diff --git a/tests/functional/selected_resources/test_selected_resources.py b/tests/functional/selected_resources/test_selected_resources.py index 550db700af7..25025c56286 100644 --- a/tests/functional/selected_resources/test_selected_resources.py +++ b/tests/functional/selected_resources/test_selected_resources.py @@ -1,10 +1,11 @@ import pytest + from dbt.tests.util import run_dbt from tests.functional.selected_resources.fixtures import ( - on_run_start_macro_assert_selected_models_expected_list, my_model1, my_model2, my_snapshot, + on_run_start_macro_assert_selected_models_expected_list, ) diff --git a/tests/functional/selectors/test_default_selectors.py b/tests/functional/selectors/test_default_selectors.py index 3be42bea132..fac60af8545 100644 --- a/tests/functional/selectors/test_default_selectors.py +++ b/tests/functional/selectors/test_default_selectors.py @@ -1,4 +1,5 @@ import pytest + from dbt.tests.util import run_dbt models__schema_yml = """ diff --git a/tests/functional/semantic_models/test_semantic_model_configs.py b/tests/functional/semantic_models/test_semantic_model_configs.py index 407fb2c3d4d..cac38e92bd3 100644 --- a/tests/functional/semantic_models/test_semantic_model_configs.py +++ b/tests/functional/semantic_models/test_semantic_model_configs.py @@ -1,17 +1,17 @@ import pytest + from dbt.artifacts.resources import SemanticModelConfig from dbt.exceptions import ParsingError -from dbt.tests.util import run_dbt, update_config_file, get_manifest - +from dbt.tests.util import get_manifest, run_dbt, update_config_file from tests.functional.semantic_models.fixtures import ( - models_people_sql, - metricflow_time_spine_sql, - semantic_model_people_yml, disabled_models_people_metrics_yml, - models_people_metrics_yml, disabled_semantic_model_people_yml, enabled_semantic_model_people_yml, groups_yml, + metricflow_time_spine_sql, + models_people_metrics_yml, + models_people_sql, + semantic_model_people_yml, ) diff --git a/tests/functional/semantic_models/test_semantic_model_parsing.py b/tests/functional/semantic_models/test_semantic_model_parsing.py index c5e4d2bb00d..0e8b6d7b5e4 100644 --- a/tests/functional/semantic_models/test_semantic_model_parsing.py +++ b/tests/functional/semantic_models/test_semantic_model_parsing.py @@ -1,18 +1,16 @@ from typing import List import pytest - from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity from dbt.contracts.graph.manifest import Manifest -from dbt_common.events.base_types import BaseEvent from dbt.tests.util import write_file +from dbt_common.events.base_types import BaseEvent from tests.functional.assertions.test_runner import dbtTestRunner - from tests.functional.semantic_models.fixtures import ( - schema_without_semantic_model_yml, fct_revenue_sql, metricflow_time_spine_sql, + schema_without_semantic_model_yml, schema_yml, ) diff --git a/tests/functional/semantic_models/test_semantic_models.py b/tests/functional/semantic_models/test_semantic_models.py index 945b7fdc04b..f773a4f8c5e 100644 --- a/tests/functional/semantic_models/test_semantic_models.py +++ b/tests/functional/semantic_models/test_semantic_models.py @@ -2,16 +2,15 @@ from dbt.contracts.graph.manifest import Manifest from dbt.exceptions import CompilationError -from dbt.tests.util import run_dbt -from dbt.tests.util import write_file +from dbt.tests.util import run_dbt, write_file from tests.functional.semantic_models.fixtures import ( - models_people_sql, - simple_metricflow_time_spine_sql, - semantic_model_people_yml, models_people_metrics_yml, + models_people_sql, + semantic_model_descriptions, semantic_model_people_diff_name_yml, + semantic_model_people_yml, semantic_model_people_yml_with_docs, - semantic_model_descriptions, + simple_metricflow_time_spine_sql, ) diff --git a/tests/functional/show/test_show.py b/tests/functional/show/test_show.py index 5c5ac51f9b1..b1aa16210b8 100644 --- a/tests/functional/show/test_show.py +++ b/tests/functional/show/test_show.py @@ -1,17 +1,18 @@ import pytest -from dbt_common.exceptions import DbtRuntimeError, DbtBaseException as DbtException -from dbt.tests.util import run_dbt_and_capture, run_dbt +from dbt.tests.util import run_dbt, run_dbt_and_capture +from dbt_common.exceptions import DbtBaseException as DbtException +from dbt_common.exceptions import DbtRuntimeError from tests.functional.show.fixtures import ( - models__second_ephemeral_model, - seeds__sample_seed, + models__ephemeral_model, models__sample_model, models__sample_number_model, models__sample_number_model_with_nulls, + models__second_ephemeral_model, models__second_model, - models__ephemeral_model, - schema_yml, private_model_yml, + schema_yml, + seeds__sample_seed, ) diff --git a/tests/functional/simple_snapshot/test_basic_snapshot.py b/tests/functional/simple_snapshot/test_basic_snapshot.py index ff4799f10ab..b1a290f6b99 100644 --- a/tests/functional/simple_snapshot/test_basic_snapshot.py +++ b/tests/functional/simple_snapshot/test_basic_snapshot.py @@ -1,20 +1,27 @@ import os from datetime import datetime -import pytz + import pytest -from dbt.tests.util import run_dbt, check_relations_equal, relation_from_name, write_file +import pytz + +from dbt.tests.util import ( + check_relations_equal, + relation_from_name, + run_dbt, + write_file, +) from tests.functional.simple_snapshot.fixtures import ( - models__schema_yml, - models__schema_with_target_schema_yml, + macros__test_no_overlaps_sql, + macros_custom_snapshot__custom_sql, models__ref_snapshot_sql, - seeds__seed_newcol_csv, + models__schema_with_target_schema_yml, + models__schema_yml, seeds__seed_csv, - snapshots_pg__snapshot_sql, + seeds__seed_newcol_csv, snapshots_pg__snapshot_no_target_schema_sql, - macros__test_no_overlaps_sql, - macros_custom_snapshot__custom_sql, - snapshots_pg_custom_namespaced__snapshot_sql, + snapshots_pg__snapshot_sql, snapshots_pg_custom__snapshot_sql, + snapshots_pg_custom_namespaced__snapshot_sql, ) snapshots_check_col__snapshot_sql = """ diff --git a/tests/functional/simple_snapshot/test_changing_check_cols_snapshot.py b/tests/functional/simple_snapshot/test_changing_check_cols_snapshot.py index 0aee4aedb99..fa5edb51410 100644 --- a/tests/functional/simple_snapshot/test_changing_check_cols_snapshot.py +++ b/tests/functional/simple_snapshot/test_changing_check_cols_snapshot.py @@ -1,5 +1,6 @@ import pytest -from dbt.tests.util import run_dbt, check_relations_equal + +from dbt.tests.util import check_relations_equal, run_dbt snapshot_sql = """ {% snapshot snapshot_check_cols_new_column %} diff --git a/tests/functional/simple_snapshot/test_changing_strategy_snapshot.py b/tests/functional/simple_snapshot/test_changing_strategy_snapshot.py index 73afa1fc244..b553485e674 100644 --- a/tests/functional/simple_snapshot/test_changing_strategy_snapshot.py +++ b/tests/functional/simple_snapshot/test_changing_strategy_snapshot.py @@ -1,8 +1,8 @@ import pytest + from dbt.tests.util import run_dbt from tests.functional.simple_snapshot.fixtures import models_slow__gen_sql - test_snapshots_changing_strategy__test_snapshot_sql = """ {# /* diff --git a/tests/functional/simple_snapshot/test_check_cols_snapshot.py b/tests/functional/simple_snapshot/test_check_cols_snapshot.py index bb32f27721c..8ee2817c45d 100644 --- a/tests/functional/simple_snapshot/test_check_cols_snapshot.py +++ b/tests/functional/simple_snapshot/test_check_cols_snapshot.py @@ -1,6 +1,6 @@ import pytest -from dbt.tests.util import run_dbt +from dbt.tests.util import run_dbt snapshot_sql = """ {% snapshot check_cols_cycle %} diff --git a/tests/functional/simple_snapshot/test_check_cols_updated_at_snapshot.py b/tests/functional/simple_snapshot/test_check_cols_updated_at_snapshot.py index c72fb1a1c73..31265c4121f 100644 --- a/tests/functional/simple_snapshot/test_check_cols_updated_at_snapshot.py +++ b/tests/functional/simple_snapshot/test_check_cols_updated_at_snapshot.py @@ -1,5 +1,6 @@ import pytest -from dbt.tests.util import run_dbt, check_relations_equal + +from dbt.tests.util import check_relations_equal, run_dbt snapshot_sql = """ {% snapshot snapshot_check_cols_updated_at_actual %} diff --git a/tests/functional/simple_snapshot/test_comment_ending_snapshot.py b/tests/functional/simple_snapshot/test_comment_ending_snapshot.py index 257afb042be..c0d482d9b7d 100644 --- a/tests/functional/simple_snapshot/test_comment_ending_snapshot.py +++ b/tests/functional/simple_snapshot/test_comment_ending_snapshot.py @@ -1,6 +1,8 @@ +import os + import pytest + from dbt.tests.util import run_dbt -import os snapshots_with_comment_at_end__snapshot_sql = """ {% snapshot snapshot_actual %} diff --git a/tests/functional/simple_snapshot/test_cross_schema_snapshot.py b/tests/functional/simple_snapshot/test_cross_schema_snapshot.py index 874f4ef2007..562bb6e0c61 100644 --- a/tests/functional/simple_snapshot/test_cross_schema_snapshot.py +++ b/tests/functional/simple_snapshot/test_cross_schema_snapshot.py @@ -1,14 +1,15 @@ import os + import pytest + from dbt.tests.util import run_dbt from tests.functional.simple_snapshot.fixtures import ( - models__schema_yml, - models__ref_snapshot_sql, macros__test_no_overlaps_sql, + models__ref_snapshot_sql, + models__schema_yml, snapshots_pg__snapshot_sql, ) - NUM_SNAPSHOT_MODELS = 1 diff --git a/tests/functional/simple_snapshot/test_hard_delete_snapshot.py b/tests/functional/simple_snapshot/test_hard_delete_snapshot.py index 53c61bb8c7f..befd06097f4 100644 --- a/tests/functional/simple_snapshot/test_hard_delete_snapshot.py +++ b/tests/functional/simple_snapshot/test_hard_delete_snapshot.py @@ -1,17 +1,18 @@ import os from datetime import datetime, timedelta -import pytz + import pytest -from dbt.tests.util import run_dbt, check_relations_equal +import pytz + +from dbt.tests.util import check_relations_equal, run_dbt from tests.functional.simple_snapshot.fixtures import ( - models__schema_yml, - models__ref_snapshot_sql, macros__test_no_overlaps_sql, + models__ref_snapshot_sql, + models__schema_yml, snapshots_pg__snapshot_sql, ) from tests.functional.utils import is_aware - # These tests uses the same seed data, containing 20 records of which we hard delete the last 10. # These deleted records set the dbt_valid_to to time the snapshot was ran. diff --git a/tests/functional/simple_snapshot/test_invalid_namespace_snapshot.py b/tests/functional/simple_snapshot/test_invalid_namespace_snapshot.py index 40b91edf051..c4f6b88f247 100644 --- a/tests/functional/simple_snapshot/test_invalid_namespace_snapshot.py +++ b/tests/functional/simple_snapshot/test_invalid_namespace_snapshot.py @@ -1,13 +1,15 @@ import os + import pytest + from dbt.tests.util import run_dbt from tests.functional.simple_snapshot.fixtures import ( - models__schema_yml, - models__ref_snapshot_sql, macros__test_no_overlaps_sql, macros_custom_snapshot__custom_sql, - seeds__seed_newcol_csv, + models__ref_snapshot_sql, + models__schema_yml, seeds__seed_csv, + seeds__seed_newcol_csv, ) NUM_SNAPSHOT_MODELS = 1 diff --git a/tests/functional/simple_snapshot/test_long_text_snapshot.py b/tests/functional/simple_snapshot/test_long_text_snapshot.py index 332bc384f61..453c4164be3 100644 --- a/tests/functional/simple_snapshot/test_long_text_snapshot.py +++ b/tests/functional/simple_snapshot/test_long_text_snapshot.py @@ -1,9 +1,10 @@ import pytest + from dbt.tests.util import run_dbt from tests.functional.simple_snapshot.fixtures import ( - models__schema_yml, - models__ref_snapshot_sql, macros__test_no_overlaps_sql, + models__ref_snapshot_sql, + models__schema_yml, ) seed_longtext_sql = """ diff --git a/tests/functional/simple_snapshot/test_missing_strategy_snapshot.py b/tests/functional/simple_snapshot/test_missing_strategy_snapshot.py index dfb51f7992e..407cd15439f 100644 --- a/tests/functional/simple_snapshot/test_missing_strategy_snapshot.py +++ b/tests/functional/simple_snapshot/test_missing_strategy_snapshot.py @@ -1,10 +1,11 @@ import pytest -from dbt.tests.util import run_dbt + from dbt.exceptions import ParsingError +from dbt.tests.util import run_dbt from tests.functional.simple_snapshot.fixtures import ( - models__schema_yml, - models__ref_snapshot_sql, macros__test_no_overlaps_sql, + models__ref_snapshot_sql, + models__schema_yml, ) snapshots_invalid__snapshot_sql = """ diff --git a/tests/functional/simple_snapshot/test_renamed_source_snapshot.py b/tests/functional/simple_snapshot/test_renamed_source_snapshot.py index 6e71ce7cad5..e59f2192051 100644 --- a/tests/functional/simple_snapshot/test_renamed_source_snapshot.py +++ b/tests/functional/simple_snapshot/test_renamed_source_snapshot.py @@ -1,13 +1,13 @@ import pytest + from dbt.tests.util import run_dbt from tests.functional.simple_snapshot.fixtures import ( - seeds__seed_newcol_csv, - seeds__seed_csv, macros__test_no_overlaps_sql, macros_custom_snapshot__custom_sql, + seeds__seed_csv, + seeds__seed_newcol_csv, ) - snapshots_checkall__snapshot_sql = """ {% snapshot my_snapshot %} {{ config(check_cols='all', unique_key='id', strategy='check', target_database=database, target_schema=schema) }} diff --git a/tests/functional/simple_snapshot/test_select_exclude_snapshot.py b/tests/functional/simple_snapshot/test_select_exclude_snapshot.py index f763c838915..6055ebbff04 100644 --- a/tests/functional/simple_snapshot/test_select_exclude_snapshot.py +++ b/tests/functional/simple_snapshot/test_select_exclude_snapshot.py @@ -1,12 +1,14 @@ import os + import pytest -from dbt.tests.util import run_dbt, check_relations_equal, check_table_does_not_exist + +from dbt.tests.util import check_relations_equal, check_table_does_not_exist, run_dbt from tests.functional.simple_snapshot.fixtures import ( - seeds__seed_newcol_csv, - seeds__seed_csv, - models__schema_yml, - models__ref_snapshot_sql, macros__test_no_overlaps_sql, + models__ref_snapshot_sql, + models__schema_yml, + seeds__seed_csv, + seeds__seed_newcol_csv, snapshots_pg__snapshot_sql, snapshots_select__snapshot_sql, snapshots_select_noconfig__snapshot_sql, diff --git a/tests/functional/simple_snapshot/test_slow_query_snapshot.py b/tests/functional/simple_snapshot/test_slow_query_snapshot.py index 63dc939dfdd..19a3b83c0e7 100644 --- a/tests/functional/simple_snapshot/test_slow_query_snapshot.py +++ b/tests/functional/simple_snapshot/test_slow_query_snapshot.py @@ -1,4 +1,5 @@ import pytest + from dbt.tests.util import run_dbt from tests.functional.simple_snapshot.fixtures import models_slow__gen_sql diff --git a/tests/functional/source_overrides/fixtures.py b/tests/functional/source_overrides/fixtures.py index f7f49235d91..ca6d4a03e66 100644 --- a/tests/functional/source_overrides/fixtures.py +++ b/tests/functional/source_overrides/fixtures.py @@ -1,6 +1,5 @@ import pytest - dupe_models__schema2_yml = """ version: 2 sources: diff --git a/tests/functional/source_overrides/test_simple_source_override.py b/tests/functional/source_overrides/test_simple_source_override.py index da1b4856e32..5505f8ca9ba 100644 --- a/tests/functional/source_overrides/test_simple_source_override.py +++ b/tests/functional/source_overrides/test_simple_source_override.py @@ -1,8 +1,9 @@ from datetime import datetime, timedelta + import pytest -from dbt.tests.util import run_dbt, update_config_file, check_relations_equal from dbt.tests.fixtures.project import write_project_files +from dbt.tests.util import check_relations_equal, run_dbt, update_config_file from tests.functional.source_overrides.fixtures import ( # noqa: F401 local_dependency, models__schema_yml, diff --git a/tests/functional/source_overrides/test_source_overrides_duplicate_model.py b/tests/functional/source_overrides/test_source_overrides_duplicate_model.py index e3cdebe4794..b07b04a7f63 100644 --- a/tests/functional/source_overrides/test_source_overrides_duplicate_model.py +++ b/tests/functional/source_overrides/test_source_overrides_duplicate_model.py @@ -1,12 +1,13 @@ import os -from dbt.exceptions import CompilationError + import pytest -from dbt.tests.util import run_dbt +from dbt.exceptions import CompilationError from dbt.tests.fixtures.project import write_project_files +from dbt.tests.util import run_dbt from tests.functional.source_overrides.fixtures import ( # noqa: F401 - dupe_models__schema2_yml, dupe_models__schema1_yml, + dupe_models__schema2_yml, local_dependency, ) diff --git a/tests/functional/sources/common_source_setup.py b/tests/functional/sources/common_source_setup.py index c1e7f0a2568..8608754855d 100644 --- a/tests/functional/sources/common_source_setup.py +++ b/tests/functional/sources/common_source_setup.py @@ -1,19 +1,20 @@ import os + import pytest import yaml from dbt.tests.util import run_dbt, run_dbt_and_capture from tests.functional.sources.fixtures import ( - models_schema_yml, - models_view_model_sql, - models_ephemeral_model_sql, models_descendant_model_sql, + models_ephemeral_model_sql, models_multi_source_model_sql, models_nonsource_descendant_sql, - seeds_source_csv, - seeds_other_table_csv, + models_schema_yml, + models_view_model_sql, seeds_expected_multi_source_csv, seeds_other_source_table_csv, + seeds_other_table_csv, + seeds_source_csv, ) diff --git a/tests/functional/sources/test_simple_source.py b/tests/functional/sources/test_simple_source.py index cd08647f367..3d84dd8a167 100644 --- a/tests/functional/sources/test_simple_source.py +++ b/tests/functional/sources/test_simple_source.py @@ -1,23 +1,22 @@ import os + import pytest import yaml -from dbt.exceptions import ParsingError +from dbt.exceptions import ParsingError from dbt.tests.util import ( - run_dbt, - update_config_file, check_relations_equal, check_table_does_not_exist, + run_dbt, + update_config_file, ) -from tests.functional.sources.common_source_setup import ( - BaseSourcesTest, -) +from tests.functional.sources.common_source_setup import BaseSourcesTest from tests.functional.sources.fixtures import ( macros_macro_sql, - malformed_models_schema_yml, malformed_models_descendant_model_sql, - malformed_schema_tests_schema_yml, + malformed_models_schema_yml, malformed_schema_tests_model_sql, + malformed_schema_tests_schema_yml, ) diff --git a/tests/functional/sources/test_source_configs.py b/tests/functional/sources/test_source_configs.py index 1a967d69269..1ceca5d0522 100644 --- a/tests/functional/sources/test_source_configs.py +++ b/tests/functional/sources/test_source_configs.py @@ -1,15 +1,15 @@ import pytest from dbt.artifacts.resources import SourceConfig +from dbt.tests.util import get_manifest, run_dbt, update_config_file from dbt_common.dataclass_schema import ValidationError -from dbt.tests.util import run_dbt, update_config_file, get_manifest from tests.functional.sources.fixtures import ( - basic_source_schema_yml, - disabled_source_level_schema_yml, - disabled_source_table_schema_yml, all_configs_everywhere_schema_yml, all_configs_not_table_schema_yml, all_configs_project_source_schema_yml, + basic_source_schema_yml, + disabled_source_level_schema_yml, + disabled_source_table_schema_yml, invalid_config_source_schema_yml, ) diff --git a/tests/functional/sources/test_source_fresher_state.py b/tests/functional/sources/test_source_fresher_state.py index ce61395f298..e1756b220e0 100644 --- a/tests/functional/sources/test_source_fresher_state.py +++ b/tests/functional/sources/test_source_fresher_state.py @@ -1,22 +1,20 @@ -import os import json +import os import shutil -import pytest from datetime import datetime, timedelta -from dbt_common.exceptions import DbtInternalError - +import pytest -from dbt.tests.util import AnyStringWith, AnyFloat import dbt.version +from dbt.contracts.results import FreshnessExecutionResultArtifact +from dbt.tests.util import AnyFloat, AnyStringWith +from dbt_common.exceptions import DbtInternalError from tests.functional.sources.common_source_setup import BaseSourcesTest - from tests.functional.sources.fixtures import ( error_models_schema_yml, - models_newly_added_model_sql, models_newly_added_error_model_sql, + models_newly_added_model_sql, ) -from dbt.contracts.results import FreshnessExecutionResultArtifact # TODO: We may create utility classes to handle reusable fixtures. diff --git a/tests/functional/sources/test_source_freshness.py b/tests/functional/sources/test_source_freshness.py index b5c04c58e86..565b93a81e6 100644 --- a/tests/functional/sources/test_source_freshness.py +++ b/tests/functional/sources/test_source_freshness.py @@ -1,24 +1,25 @@ -import os import json -import pytest +import os from datetime import datetime, timedelta + +import pytest import yaml import dbt.version +from dbt import deprecations from dbt.artifacts.schemas.freshness import FreshnessResult from dbt.artifacts.schemas.results import FreshnessStatus from dbt.cli.main import dbtRunner -from dbt import deprecations +from dbt.tests.util import AnyFloat, AnyStringWith from tests.functional.sources.common_source_setup import BaseSourcesTest from tests.functional.sources.fixtures import ( - error_models_schema_yml, + collect_freshness_macro_override_previous_return_signature, error_models_model_sql, + error_models_schema_yml, filtered_models_schema_yml, - override_freshness_models_schema_yml, - collect_freshness_macro_override_previous_return_signature, freshness_via_metadata_schema_yml, + override_freshness_models_schema_yml, ) -from dbt.tests.util import AnyStringWith, AnyFloat class SuccessfulSourceFreshnessTest(BaseSourcesTest): diff --git a/tests/functional/sources/test_source_loaded_at_field.py b/tests/functional/sources/test_source_loaded_at_field.py index bc5e5fc05bc..b89b8ddd372 100644 --- a/tests/functional/sources/test_source_loaded_at_field.py +++ b/tests/functional/sources/test_source_loaded_at_field.py @@ -1,7 +1,7 @@ import pytest -from dbt.tests.util import run_dbt, get_manifest, write_file -from dbt.exceptions import YamlParseDictError +from dbt.exceptions import YamlParseDictError +from dbt.tests.util import get_manifest, run_dbt, write_file loaded_at_field_null_schema_yml = """ sources: diff --git a/tests/functional/statements/test_statements.py b/tests/functional/statements/test_statements.py index 87933af20fa..9e3d5005759 100644 --- a/tests/functional/statements/test_statements.py +++ b/tests/functional/statements/test_statements.py @@ -1,7 +1,8 @@ import pathlib + import pytest -from dbt.tests.util import run_dbt, check_relations_equal, write_file +from dbt.tests.util import check_relations_equal, run_dbt, write_file from tests.functional.statements.fixtures import ( models__statement_actual, models__statement_duplicated_load, diff --git a/tests/functional/test_empty.py b/tests/functional/test_empty.py index 8e6e834427f..d284fdcc3e5 100644 --- a/tests/functional/test_empty.py +++ b/tests/functional/test_empty.py @@ -1,6 +1,6 @@ import pytest -from dbt.tests.util import run_dbt, relation_from_name +from dbt.tests.util import relation_from_name, run_dbt model_input_sql = """ select 1 as id diff --git a/tests/functional/test_selection/fixtures.py b/tests/functional/test_selection/fixtures.py index af591604299..37cce1bbae9 100644 --- a/tests/functional/test_selection/fixtures.py +++ b/tests/functional/test_selection/fixtures.py @@ -1,6 +1,6 @@ import pytest -from dbt.tests.fixtures.project import write_project_files +from dbt.tests.fixtures.project import write_project_files tests__cf_a_b_sql = """ select * from {{ ref('model_a') }} diff --git a/tests/functional/test_selection/test_selection_expansion.py b/tests/functional/test_selection/test_selection_expansion.py index 3e6f1f82ae3..e42d6196328 100644 --- a/tests/functional/test_selection/test_selection_expansion.py +++ b/tests/functional/test_selection/test_selection_expansion.py @@ -2,9 +2,9 @@ from dbt.tests.util import run_dbt from tests.functional.test_selection.fixtures import ( # noqa: F401 - tests, models, project_files, + tests, ) diff --git a/tests/functional/threading/test_thread_count.py b/tests/functional/threading/test_thread_count.py index c31f5ed6312..9c94356e630 100644 --- a/tests/functional/threading/test_thread_count.py +++ b/tests/functional/threading/test_thread_count.py @@ -1,6 +1,6 @@ import pytest -from dbt.tests.util import run_dbt +from dbt.tests.util import run_dbt models__do_nothing__sql = """ with x as (select pg_sleep(1)) select 1 diff --git a/tests/functional/timezones/test_timezones.py b/tests/functional/timezones/test_timezones.py index a4627fb63c3..1e2de2585f3 100644 --- a/tests/functional/timezones/test_timezones.py +++ b/tests/functional/timezones/test_timezones.py @@ -1,9 +1,9 @@ import os + import pytest from dbt.tests.util import run_dbt - # Canada/Saskatchewan does not observe DST so the time diff won't change depending on when it is in the year model_sql = """ {{ diff --git a/tests/functional/unit_testing/test_csv_fixtures.py b/tests/functional/unit_testing/test_csv_fixtures.py index 6aae95abed6..83e4b269b9a 100644 --- a/tests/functional/unit_testing/test_csv_fixtures.py +++ b/tests/functional/unit_testing/test_csv_fixtures.py @@ -1,27 +1,28 @@ import pytest -from dbt.exceptions import ParsingError, YamlParseDictError, DuplicateResourceNameError -from dbt.tests.util import run_dbt, write_file, rm_file from fixtures import ( - my_model_sql, - my_model_a_sql, - my_model_b_sql, - test_my_model_csv_yml, datetime_test, - datetime_test_invalid_format_key, datetime_test_invalid_csv_values, - test_my_model_file_csv_yml, - test_my_model_fixture_csv, + datetime_test_invalid_format_key, + my_model_a_sql, + my_model_b_sql, + my_model_sql, + test_my_model_a_empty_fixture_csv, test_my_model_a_fixture_csv, + test_my_model_a_numeric_fixture_csv, test_my_model_b_fixture_csv, test_my_model_basic_fixture_csv, - test_my_model_a_numeric_fixture_csv, - test_my_model_a_empty_fixture_csv, test_my_model_concat_fixture_csv, - test_my_model_mixed_csv_yml, - test_my_model_missing_csv_yml, + test_my_model_csv_yml, test_my_model_duplicate_csv_yml, + test_my_model_file_csv_yml, + test_my_model_fixture_csv, + test_my_model_missing_csv_yml, + test_my_model_mixed_csv_yml, ) +from dbt.exceptions import DuplicateResourceNameError, ParsingError, YamlParseDictError +from dbt.tests.util import rm_file, run_dbt, write_file + class TestUnitTestsWithInlineCSV: @pytest.fixture(scope="class") diff --git a/tests/functional/unit_testing/test_sql_format.py b/tests/functional/unit_testing/test_sql_format.py index 6b5af93e1ba..700008eaf9c 100644 --- a/tests/functional/unit_testing/test_sql_format.py +++ b/tests/functional/unit_testing/test_sql_format.py @@ -1,4 +1,5 @@ import pytest + from dbt.tests.util import run_dbt wizards_csv = """id,w_name,email,email_tld,phone,world diff --git a/tests/functional/unit_testing/test_state.py b/tests/functional/unit_testing/test_state.py index 7235a5411d7..cf87f49b406 100644 --- a/tests/functional/unit_testing/test_state.py +++ b/tests/functional/unit_testing/test_state.py @@ -1,24 +1,20 @@ import os -import pytest import shutil from copy import deepcopy -from dbt.tests.util import ( - run_dbt, - write_file, - write_config_file, -) +import pytest from fixtures import ( - my_model_vars_sql, - my_model_a_sql, - my_model_b_sql, - test_my_model_simple_fixture_yml, - test_my_model_fixture_csv, - test_my_model_b_fixture_csv as test_my_model_fixture_csv_modified, model_select_1_sql, model_select_2_sql, + my_model_a_sql, + my_model_b_sql, + my_model_vars_sql, test_expect_2_yml, ) +from fixtures import test_my_model_b_fixture_csv as test_my_model_fixture_csv_modified +from fixtures import test_my_model_fixture_csv, test_my_model_simple_fixture_yml + +from dbt.tests.util import run_dbt, write_config_file, write_file class UnitTestState: diff --git a/tests/functional/unit_testing/test_unit_testing.py b/tests/functional/unit_testing/test_unit_testing.py index 887c1907e76..7332ddccb64 100644 --- a/tests/functional/unit_testing/test_unit_testing.py +++ b/tests/functional/unit_testing/test_unit_testing.py @@ -1,37 +1,39 @@ -import pytest import os from unittest import mock -from dbt.tests.util import ( - run_dbt, - write_file, - get_manifest, - run_dbt_and_capture, - read_file, - file_exists, -) -from dbt.contracts.results import NodeStatus -from dbt.exceptions import DuplicateResourceNameError, ParsingError -from dbt.plugins.manifest import PluginNodes, ModelNodeArgs -from dbt.tests.fixtures.project import write_project_files + +import pytest from fixtures import ( # noqa: F401 - my_model_sql, - my_model_vars_sql, - my_model_a_sql, - my_model_b_sql, - test_my_model_yml, datetime_test, - my_incremental_model_sql, event_sql, + external_package, + external_package__accounts_seed_csv, + my_incremental_model_sql, + my_model_a_sql, + my_model_b_sql, + my_model_sql, + my_model_vars_sql, test_my_model_incremental_yml_basic, + test_my_model_incremental_yml_no_override, + test_my_model_incremental_yml_no_this_input, + test_my_model_incremental_yml_wrong_override, + test_my_model_yml, test_my_model_yml_invalid, test_my_model_yml_invalid_ref, - valid_emails_sql, top_level_domains_sql, - external_package__accounts_seed_csv, - external_package, - test_my_model_incremental_yml_no_override, - test_my_model_incremental_yml_wrong_override, - test_my_model_incremental_yml_no_this_input, + valid_emails_sql, +) + +from dbt.contracts.results import NodeStatus +from dbt.exceptions import DuplicateResourceNameError, ParsingError +from dbt.plugins.manifest import ModelNodeArgs, PluginNodes +from dbt.tests.fixtures.project import write_project_files +from dbt.tests.util import ( + file_exists, + get_manifest, + read_file, + run_dbt, + run_dbt_and_capture, + write_file, ) from tests.unit.utils import normalize diff --git a/tests/functional/unit_testing/test_ut_dependency.py b/tests/functional/unit_testing/test_ut_dependency.py index 4ff22a1f119..32e5a0111b7 100644 --- a/tests/functional/unit_testing/test_ut_dependency.py +++ b/tests/functional/unit_testing/test_ut_dependency.py @@ -1,6 +1,7 @@ import pytest -from dbt.tests.util import run_dbt, get_unique_ids_in_results + from dbt.tests.fixtures.project import write_project_files +from dbt.tests.util import get_unique_ids_in_results, run_dbt local_dependency__dbt_project_yml = """ diff --git a/tests/functional/unit_testing/test_ut_ephemeral.py b/tests/functional/unit_testing/test_ut_ephemeral.py index 2898633ec40..cb2de2d2596 100644 --- a/tests/functional/unit_testing/test_ut_ephemeral.py +++ b/tests/functional/unit_testing/test_ut_ephemeral.py @@ -1,7 +1,7 @@ import pytest -from dbt.tests.util import run_dbt, write_file -from dbt.contracts.results import RunStatus, TestStatus +from dbt.contracts.results import RunStatus, TestStatus +from dbt.tests.util import run_dbt, write_file ephemeral_model_sql = """ {{ config(materialized="ephemeral") }} diff --git a/tests/functional/unit_testing/test_ut_list.py b/tests/functional/unit_testing/test_ut_list.py index f952d2fe484..0b4f263909b 100644 --- a/tests/functional/unit_testing/test_ut_list.py +++ b/tests/functional/unit_testing/test_ut_list.py @@ -1,16 +1,17 @@ -import pytest -from dbt.tests.util import run_dbt import json import os +import pytest from fixtures import ( # noqa: F401 - my_model_vars_sql, + datetime_test, my_model_a_sql, my_model_b_sql, + my_model_vars_sql, test_my_model_yml, - datetime_test, ) +from dbt.tests.util import run_dbt + class TestUnitTestList: @pytest.fixture(scope="class") diff --git a/tests/functional/unit_testing/test_ut_names.py b/tests/functional/unit_testing/test_ut_names.py index d1721438576..a2de3764da4 100644 --- a/tests/functional/unit_testing/test_ut_names.py +++ b/tests/functional/unit_testing/test_ut_names.py @@ -1,8 +1,4 @@ import pytest - -from dbt.tests.util import run_dbt, run_dbt_and_capture -from dbt.exceptions import DuplicateResourceNameError - from fixtures import ( my_model_a_sql, my_model_b_sql, @@ -10,6 +6,9 @@ test_model_a_with_duplicate_test_name_yml, ) +from dbt.exceptions import DuplicateResourceNameError +from dbt.tests.util import run_dbt, run_dbt_and_capture + class TestUnitTestDuplicateTestNamesAcrossModels: @pytest.fixture(scope="class") diff --git a/tests/functional/unit_testing/test_ut_overrides.py b/tests/functional/unit_testing/test_ut_overrides.py index c8102e47ce2..466ceadc437 100644 --- a/tests/functional/unit_testing/test_ut_overrides.py +++ b/tests/functional/unit_testing/test_ut_overrides.py @@ -1,6 +1,6 @@ import pytest -from dbt.tests.util import run_dbt +from dbt.tests.util import run_dbt my_model_with_macros = """ SELECT diff --git a/tests/functional/unit_testing/test_ut_snapshot_dependency.py b/tests/functional/unit_testing/test_ut_snapshot_dependency.py index f1b20d3e554..a76fe1a39f4 100644 --- a/tests/functional/unit_testing/test_ut_snapshot_dependency.py +++ b/tests/functional/unit_testing/test_ut_snapshot_dependency.py @@ -1,6 +1,7 @@ import pytest -from dbt.tests.util import run_dbt + from dbt.contracts.results import RunStatus, TestStatus +from dbt.tests.util import run_dbt raw_customers_csv = """id,first_name,last_name,email,gender,ip_address,updated_at 1,'Judith','Kennedy','(not provided)','Female','54.60.24.128','2015-12-24 12:19:28' diff --git a/tests/functional/unit_testing/test_ut_sources.py b/tests/functional/unit_testing/test_ut_sources.py index 2779d698790..61a45f70f76 100644 --- a/tests/functional/unit_testing/test_ut_sources.py +++ b/tests/functional/unit_testing/test_ut_sources.py @@ -1,6 +1,7 @@ import pytest -from dbt.tests.util import run_dbt, write_file + from dbt.contracts.results import RunStatus, TestStatus +from dbt.tests.util import run_dbt, write_file raw_customers_csv = """id,first_name,last_name,email 1,Michael,Perez,mperez0@chronoengine.com diff --git a/tests/functional/unit_testing/test_ut_versions.py b/tests/functional/unit_testing/test_ut_versions.py index 98afbcf28ad..059688ce473 100644 --- a/tests/functional/unit_testing/test_ut_versions.py +++ b/tests/functional/unit_testing/test_ut_versions.py @@ -1,23 +1,23 @@ import pytest -from dbt.tests.util import run_dbt, get_unique_ids_in_results, write_file -from dbt.exceptions import YamlParseDictError, ParsingError +from dbt.exceptions import ParsingError, YamlParseDictError +from dbt.tests.util import get_unique_ids_in_results, run_dbt, write_file from tests.functional.unit_testing.fixtures import ( - my_model_versioned_yml, + my_model_a_sql, + my_model_b_sql, + my_model_sql, + my_model_v1_sql, + my_model_v2_sql, + my_model_v3_sql, + my_model_version_ref_sql, my_model_versioned_no_2_yml, + my_model_versioned_yml, test_my_model_all_versions_yml, test_my_model_exclude_versions_yml, - test_my_model_include_versions_yml, test_my_model_include_exclude_versions_yml, test_my_model_include_unversioned_yml, + test_my_model_include_versions_yml, test_my_model_version_ref_yml, - my_model_v1_sql, - my_model_v2_sql, - my_model_v3_sql, - my_model_a_sql, - my_model_b_sql, - my_model_sql, - my_model_version_ref_sql, ) diff --git a/tests/functional/utils.py b/tests/functional/utils.py index a5c705780b7..8af471e7c04 100644 --- a/tests/functional/utils.py +++ b/tests/functional/utils.py @@ -2,9 +2,10 @@ from contextlib import contextmanager from dataclasses import dataclass, field from datetime import datetime -from dbt_common.events.base_types import BaseEvent, EventMsg -from typing import List, Optional from pathlib import Path +from typing import List, Optional + +from dbt_common.events.base_types import BaseEvent, EventMsg @contextmanager diff --git a/tests/unit/cli/test_flags.py b/tests/unit/cli/test_flags.py index 6bf9d692e0e..da5a8490d84 100644 --- a/tests/unit/cli/test_flags.py +++ b/tests/unit/cli/test_flags.py @@ -9,9 +9,9 @@ from dbt.cli.main import cli from dbt.cli.types import Command from dbt.contracts.project import ProjectFlags +from dbt.tests.util import rm_file, write_file from dbt_common.exceptions import DbtInternalError from dbt_common.helper_types import WarnErrorOptions -from dbt.tests.util import rm_file, write_file class TestFlags: diff --git a/tests/unit/cli/test_option_types.py b/tests/unit/cli/test_option_types.py index 67d3c5e941f..1067f64a3c3 100644 --- a/tests/unit/cli/test_option_types.py +++ b/tests/unit/cli/test_option_types.py @@ -1,5 +1,5 @@ -from click import Option, BadParameter import pytest +from click import BadParameter, Option from dbt.cli.option_types import YAML diff --git a/tests/unit/config/__init__.py b/tests/unit/config/__init__.py index 073cf3d6499..b9f943c78e2 100644 --- a/tests/unit/config/__init__.py +++ b/tests/unit/config/__init__.py @@ -1,10 +1,9 @@ -from contextlib import contextmanager import os import shutil import tempfile import unittest from argparse import Namespace - +from contextlib import contextmanager import yaml @@ -12,10 +11,7 @@ import dbt.exceptions from dbt import flags from dbt.constants import PACKAGES_FILE_NAME - - from dbt.flags import set_from_args - from tests.unit.utils import normalize INITIAL_ROOT = os.getcwd() diff --git a/tests/unit/config/test_profile.py b/tests/unit/config/test_profile.py index 7c53b715ab9..e79d0935582 100644 --- a/tests/unit/config/test_profile.py +++ b/tests/unit/config/test_profile.py @@ -1,18 +1,17 @@ -from copy import deepcopy - import os +from copy import deepcopy from unittest import mock + import dbt.config import dbt.exceptions - from dbt.adapters.postgres import PostgresCredentials - - from dbt.flags import set_from_args from dbt.tests.util import safe_set_invocation_context - - -from tests.unit.config import BaseConfigTest, empty_profile_renderer, project_from_config_norender +from tests.unit.config import ( + BaseConfigTest, + empty_profile_renderer, + project_from_config_norender, +) class TestProfile(BaseConfigTest): diff --git a/tests/unit/config/test_project.py b/tests/unit/config/test_project.py index a4aa63f9585..7d0006570af 100644 --- a/tests/unit/config/test_project.py +++ b/tests/unit/config/test_project.py @@ -1,30 +1,27 @@ -from copy import deepcopy import json import os import unittest -import pytest - +from copy import deepcopy from unittest import mock +import pytest + import dbt.config -from dbt.constants import DEPENDENCIES_FILE_NAME import dbt.exceptions +from dbt.adapters.contracts.connection import DEFAULT_QUERY_COMMENT, QueryComment from dbt.adapters.factory import load_plugin -from dbt.adapters.contracts.connection import QueryComment, DEFAULT_QUERY_COMMENT from dbt.config.project import Project -from dbt.contracts.project import PackageConfig, LocalPackage, GitPackage +from dbt.constants import DEPENDENCIES_FILE_NAME +from dbt.contracts.project import GitPackage, LocalPackage, PackageConfig +from dbt.flags import set_from_args from dbt.node_types import NodeType +from dbt.tests.util import safe_set_invocation_context from dbt_common.exceptions import DbtRuntimeError from dbt_common.semver import VersionSpecifier - -from dbt.flags import set_from_args -from dbt.tests.util import safe_set_invocation_context - - from tests.unit.config import ( BaseConfigTest, - project_from_config_norender, empty_project_renderer, + project_from_config_norender, project_from_config_rendered, ) diff --git a/tests/unit/config/test_runtime.py b/tests/unit/config/test_runtime.py index 84220d53bbf..6d2b18fd896 100644 --- a/tests/unit/config/test_runtime.py +++ b/tests/unit/config/test_runtime.py @@ -1,16 +1,13 @@ import os from argparse import Namespace - from unittest import mock import dbt.config import dbt.exceptions from dbt import tracking from dbt.contracts.project import PackageConfig - from dbt.flags import set_from_args from dbt.tests.util import safe_set_invocation_context - from tests.unit.config import ( BaseConfigTest, empty_profile_renderer, diff --git a/tests/unit/config/test_selectors.py b/tests/unit/config/test_selectors.py index 017c7dee22b..9688647a00e 100644 --- a/tests/unit/config/test_selectors.py +++ b/tests/unit/config/test_selectors.py @@ -1,10 +1,10 @@ -import dbt.exceptions import textwrap -import yaml import unittest -from dbt.config.selectors import selector_config_from_data -from dbt.config.selectors import SelectorConfig +import yaml + +import dbt.exceptions +from dbt.config.selectors import SelectorConfig, selector_config_from_data def get_selector_dict(txt: str) -> dict: diff --git a/tests/unit/context/test_context.py b/tests/unit/context/test_context.py index 6070c24a1b7..3df0109191a 100644 --- a/tests/unit/context/test_context.py +++ b/tests/unit/context/test_context.py @@ -1,35 +1,29 @@ import os -from typing import Set, Dict, Any +from argparse import Namespace +from typing import Any, Dict, Set from unittest import mock import pytest -from dbt.adapters import postgres -from dbt.adapters import factory +import dbt_common.exceptions +from dbt.adapters import factory, postgres from dbt.clients.jinja import MacroStack +from dbt.config.project import VarProvider +from dbt.context import base, docs, macros, providers, query_header +from dbt.contracts.files import FileHash from dbt.contracts.graph.nodes import ( - ModelNode, - NodeConfig, DependsOn, Macro, + ModelNode, + NodeConfig, UnitTestNode, UnitTestOverrides, ) -from dbt.config.project import VarProvider -from dbt.context import base, providers, docs, macros, query_header -from dbt.contracts.files import FileHash -from dbt_common.events.functions import reset_metadata_vars from dbt.flags import set_from_args from dbt.node_types import NodeType -import dbt_common.exceptions - -from tests.unit.utils import ( - config_from_parts_or_dicts, - inject_adapter, - clear_plugin, -) +from dbt_common.events.functions import reset_metadata_vars from tests.unit.mock_adapter import adapter_factory -from argparse import Namespace +from tests.unit.utils import clear_plugin, config_from_parts_or_dicts, inject_adapter set_from_args(Namespace(WARN_ERROR=False), None) diff --git a/tests/unit/context/test_macro_resolver.py b/tests/unit/context/test_macro_resolver.py index 57e8e9e47db..4611d4dc949 100644 --- a/tests/unit/context/test_macro_resolver.py +++ b/tests/unit/context/test_macro_resolver.py @@ -1,8 +1,8 @@ import unittest from unittest import mock -from dbt.contracts.graph.nodes import Macro from dbt.context.macro_resolver import MacroResolver +from dbt.contracts.graph.nodes import Macro def mock_macro(name, package_name): diff --git a/tests/unit/context/test_providers.py b/tests/unit/context/test_providers.py index 0baeffa3973..224675143e4 100644 --- a/tests/unit/context/test_providers.py +++ b/tests/unit/context/test_providers.py @@ -1,9 +1,14 @@ -import pytest from unittest import mock +import pytest + from dbt.adapters.base import BaseRelation from dbt.artifacts.resources import Quoting -from dbt.context.providers import BaseResolver, RuntimeRefResolver, RuntimeSourceResolver +from dbt.context.providers import ( + BaseResolver, + RuntimeRefResolver, + RuntimeSourceResolver, +) class TestBaseResolver: diff --git a/tests/unit/context/test_query_header.py b/tests/unit/context/test_query_header.py index aa9e99821a2..40c0f1284d9 100644 --- a/tests/unit/context/test_query_header.py +++ b/tests/unit/context/test_query_header.py @@ -1,13 +1,13 @@ -import pytest import re +from argparse import Namespace from unittest import mock +import pytest + from dbt.adapters.base.query_headers import MacroQueryStringSetter from dbt.context.query_header import generate_query_header_context - -from tests.unit.utils import config_from_parts_or_dicts from dbt.flags import set_from_args -from argparse import Namespace +from tests.unit.utils import config_from_parts_or_dicts set_from_args(Namespace(WARN_ERROR=False), None) diff --git a/tests/unit/contracts/graph/test_manifest.py b/tests/unit/contracts/graph/test_manifest.py index a1ff4beec09..7f53951bdeb 100644 --- a/tests/unit/contracts/graph/test_manifest.py +++ b/tests/unit/contracts/graph/test_manifest.py @@ -9,23 +9,13 @@ import freezegun import pytest +from dbt_semantic_interfaces.type_enums import MetricType import dbt.flags import dbt.version +import dbt_common.invocation from dbt import tracking from dbt.adapters.base.plugin import AdapterPlugin -from dbt.contracts.files import FileHash -from dbt.contracts.graph.manifest import Manifest, ManifestMetadata -from dbt.contracts.graph.nodes import ( - ModelNode, - DependsOn, - ModelConfig, - SeedNode, - SourceDefinition, - Exposure, - Metric, - Group, -) from dbt.artifacts.resources import ( ExposureType, MaturityType, @@ -36,20 +26,29 @@ WhereFilter, WhereFilterIntersection, ) -import dbt_common.invocation -from dbt_common.events.functions import reset_metadata_vars +from dbt.contracts.files import FileHash +from dbt.contracts.graph.manifest import Manifest, ManifestMetadata +from dbt.contracts.graph.nodes import ( + DependsOn, + Exposure, + Group, + Metric, + ModelConfig, + ModelNode, + SeedNode, + SourceDefinition, +) from dbt.exceptions import AmbiguousResourceNameRefError from dbt.flags import set_from_args from dbt.node_types import NodeType -from dbt_semantic_interfaces.type_enums import MetricType - +from dbt_common.events.functions import reset_metadata_vars from tests.unit.utils import ( - MockMacro, MockDocumentation, - MockSource, - MockNode, - MockMaterialization, MockGenerateMacro, + MockMacro, + MockMaterialization, + MockNode, + MockSource, inject_plugin, ) diff --git a/tests/unit/contracts/graph/test_semantic_manifest.py b/tests/unit/contracts/graph/test_semantic_manifest.py index 4eb389ea0f5..cf3121dc9b0 100644 --- a/tests/unit/contracts/graph/test_semantic_manifest.py +++ b/tests/unit/contracts/graph/test_semantic_manifest.py @@ -1,4 +1,5 @@ import pytest + from dbt.contracts.graph.semantic_manifest import SemanticManifest diff --git a/tests/unit/contracts/graph/test_unparsed.py b/tests/unit/contracts/graph/test_unparsed.py index f613a358e7c..65d29ad0947 100644 --- a/tests/unit/contracts/graph/test_unparsed.py +++ b/tests/unit/contracts/graph/test_unparsed.py @@ -1,6 +1,6 @@ import pytest -from dbt.contracts.graph.unparsed import UnparsedColumn, HasColumnTests +from dbt.contracts.graph.unparsed import HasColumnTests, UnparsedColumn from dbt.exceptions import ParsingError from dbt.parser.schemas import ParserRef diff --git a/tests/unit/fixtures.py b/tests/unit/fixtures.py index f74e381741e..5cd18f49bc0 100644 --- a/tests/unit/fixtures.py +++ b/tests/unit/fixtures.py @@ -1,15 +1,14 @@ +from dbt.artifacts.resources import Contract, TestConfig, TestMetadata from dbt.contracts.files import FileHash from dbt.contracts.graph.nodes import ( DependsOn, + GenericTestNode, InjectedCTE, - ModelNode, ModelConfig, - GenericTestNode, + ModelNode, ) from dbt.node_types import NodeType -from dbt.artifacts.resources import Contract, TestConfig, TestMetadata - def model_node(): return ModelNode( diff --git a/tests/unit/graph/test_nodes.py b/tests/unit/graph/test_nodes.py index 9512e8983ad..897eee5111c 100644 --- a/tests/unit/graph/test_nodes.py +++ b/tests/unit/graph/test_nodes.py @@ -1,13 +1,18 @@ from copy import deepcopy -import pytest from typing import List -from dbt.artifacts.resources import Dimension, Entity, Measure, Defaults -from dbt.contracts.graph.nodes import SemanticModel +import pytest +from dbt_semantic_interfaces.references import MeasureReference +from dbt_semantic_interfaces.type_enums import ( + AggregationType, + DimensionType, + EntityType, +) + +from dbt.artifacts.resources import Defaults, Dimension, Entity, Measure from dbt.artifacts.resources.v1.semantic_model import NodeRelation +from dbt.contracts.graph.nodes import SemanticModel from dbt.node_types import NodeType -from dbt_semantic_interfaces.references import MeasureReference -from dbt_semantic_interfaces.type_enums import AggregationType, DimensionType, EntityType class TestSemanticModel: diff --git a/tests/unit/graph/test_selector.py b/tests/unit/graph/test_selector.py index 7c90996faee..677fb1c46bd 100644 --- a/tests/unit/graph/test_selector.py +++ b/tests/unit/graph/test_selector.py @@ -1,41 +1,39 @@ import os - +import string import unittest +from argparse import Namespace +from queue import Empty from unittest.mock import MagicMock, patch -from dbt.adapters.postgres import Plugin as PostgresPlugin -from dbt.adapters.factory import reset_adapters, register_adapter +import networkx as nx +import pytest + import dbt.compilation +import dbt.config import dbt.exceptions +import dbt.graph.cli as graph_cli +import dbt.graph.selector as graph_selector import dbt.parser -import dbt.config -import dbt.utils import dbt.parser.manifest +import dbt.utils +import dbt_common.exceptions from dbt import tracking +from dbt.adapters.factory import register_adapter, reset_adapters +from dbt.adapters.postgres import Plugin as PostgresPlugin from dbt.cli.flags import convert_config -from dbt.contracts.files import SourceFile, FileHash, FilePath +from dbt.contracts.files import FileHash, FilePath, SourceFile from dbt.contracts.graph.manifest import MacroManifest, ManifestStateCheck from dbt.contracts.project import ProjectFlags +from dbt.events.logging import setup_event_logger from dbt.flags import get_flags, set_from_args from dbt.graph import NodeSelector, parse_difference -from dbt.events.logging import setup_event_logger from dbt.mp_context import get_mp_context -from queue import Empty -from tests.unit.utils import config_from_parts_or_dicts, generate_name_macros, inject_plugin - -from argparse import Namespace - - -import pytest - -import string -import dbt_common.exceptions -import dbt.graph.selector as graph_selector -import dbt.graph.cli as graph_cli from dbt.node_types import NodeType - -import networkx as nx - +from tests.unit.utils import ( + config_from_parts_or_dicts, + generate_name_macros, + inject_plugin, +) set_from_args(Namespace(WARN_ERROR=False), None) diff --git a/tests/unit/graph/test_selector_spec.py b/tests/unit/graph/test_selector_spec.py index 3de4d0b69c7..265e387bc0a 100644 --- a/tests/unit/graph/test_selector_spec.py +++ b/tests/unit/graph/test_selector_spec.py @@ -1,7 +1,8 @@ -import pytest from unittest.mock import patch -from dbt.graph.selector_spec import SelectionCriteria, IndirectSelection +import pytest + +from dbt.graph.selector_spec import IndirectSelection, SelectionCriteria @pytest.mark.parametrize( diff --git a/tests/unit/mock_adapter.py b/tests/unit/mock_adapter.py index 8858542619b..c1f8a062668 100644 --- a/tests/unit/mock_adapter.py +++ b/tests/unit/mock_adapter.py @@ -1,7 +1,7 @@ +from contextlib import contextmanager from unittest import mock from dbt.adapters.base import BaseAdapter -from contextlib import contextmanager def adapter_factory(): diff --git a/tests/unit/parser/test_manifest.py b/tests/unit/parser/test_manifest.py index 6a643e444f3..9a84414a99e 100644 --- a/tests/unit/parser/test_manifest.py +++ b/tests/unit/parser/test_manifest.py @@ -1,12 +1,12 @@ -import pytest -from unittest.mock import patch, MagicMock from argparse import Namespace +from unittest.mock import MagicMock, patch +import pytest -from dbt.contracts.graph.manifest import Manifest -from dbt.parser.manifest import ManifestLoader from dbt.config import RuntimeConfig +from dbt.contracts.graph.manifest import Manifest from dbt.flags import set_from_args +from dbt.parser.manifest import ManifestLoader @pytest.fixture diff --git a/tests/unit/parser/test_partial.py b/tests/unit/parser/test_partial.py index a1907b922f2..40f2e6e8022 100644 --- a/tests/unit/parser/test_partial.py +++ b/tests/unit/parser/test_partial.py @@ -1,23 +1,22 @@ +import time from copy import deepcopy +from typing import Dict, List import pytest -import time -from typing import Dict, List -from dbt.parser.partial import PartialParsing from dbt.contracts.files import ( + BaseSourceFile, + FileHash, + FilePath, ParseFileType, - SourceFile, SchemaSourceFile, - FilePath, - FileHash, - BaseSourceFile, + SourceFile, ) from dbt.node_types import NodeType +from dbt.parser.partial import PartialParsing from dbt.tests.util import safe_set_invocation_context from tests.unit.utils import normalize -from tests.unit.utils.manifest import make_model, make_generic_test - +from tests.unit.utils.manifest import make_generic_test, make_model PROJECT_NAME = "my_test" diff --git a/tests/unit/parser/test_unit_tests.py b/tests/unit/parser/test_unit_tests.py index dfcf059dcf2..39832fa89f9 100644 --- a/tests/unit/parser/test_unit_tests.py +++ b/tests/unit/parser/test_unit_tests.py @@ -1,14 +1,12 @@ -from dbt.contracts.graph.nodes import UnitTestDefinition, NodeType -from dbt.artifacts.resources import UnitTestConfig, DependsOn +from unittest import mock + +from dbt.artifacts.resources import DependsOn, UnitTestConfig +from dbt.contracts.graph.nodes import NodeType, UnitTestDefinition +from dbt.contracts.graph.unparsed import UnitTestOutputFixture from dbt.parser import SchemaParser from dbt.parser.unit_tests import UnitTestParser - -from tests.unit.utils import MockNode from tests.unit.test_parser import SchemaParserTest, assertEqualNodes - -from unittest import mock -from dbt.contracts.graph.unparsed import UnitTestOutputFixture - +from tests.unit.utils import MockNode UNIT_TEST_MODEL_NOT_FOUND_SOURCE = """ unit_tests: diff --git a/tests/unit/plugins/test_manager.py b/tests/unit/plugins/test_manager.py index bf25d810729..b67677879be 100644 --- a/tests/unit/plugins/test_manager.py +++ b/tests/unit/plugins/test_manager.py @@ -1,11 +1,12 @@ -import pytest from unittest import mock +import pytest + from dbt.exceptions import DbtRuntimeError -from dbt.plugins import PluginManager, dbtPlugin, dbt_hook -from dbt.plugins.manifest import PluginNodes, ModelNodeArgs -from dbt.plugins.contracts import PluginArtifacts, PluginArtifact +from dbt.plugins import PluginManager, dbt_hook, dbtPlugin +from dbt.plugins.contracts import PluginArtifact, PluginArtifacts from dbt.plugins.exceptions import dbtPluginError +from dbt.plugins.manifest import ModelNodeArgs, PluginNodes class ExceptionInitializePlugin(dbtPlugin): diff --git a/tests/unit/task/test_base.py b/tests/unit/task/test_base.py index b8f84fffa5e..c28d59f0df7 100644 --- a/tests/unit/task/test_base.py +++ b/tests/unit/task/test_base.py @@ -1,8 +1,8 @@ import os -from dbt.task.base import BaseRunner, ConfiguredTask -from dbt.contracts.graph.nodes import SourceDefinition -import dbt_common.exceptions +import dbt_common.exceptions +from dbt.contracts.graph.nodes import SourceDefinition +from dbt.task.base import BaseRunner, ConfiguredTask from tests.unit.config import BaseConfigTest INITIAL_ROOT = os.getcwd() diff --git a/tests/unit/task/test_freshness.py b/tests/unit/task/test_freshness.py index 05c00df75da..4816ae98f05 100644 --- a/tests/unit/task/test_freshness.py +++ b/tests/unit/task/test_freshness.py @@ -1,8 +1,9 @@ import datetime -import pytest from unittest import mock -from dbt.task.freshness import FreshnessTask, FreshnessResponse +import pytest + +from dbt.task.freshness import FreshnessResponse, FreshnessTask class TestFreshnessTaskMetadataCache: diff --git a/tests/unit/task/test_retry.py b/tests/unit/task/test_retry.py index 3eb151cb6a3..0e0c8898b4e 100644 --- a/tests/unit/task/test_retry.py +++ b/tests/unit/task/test_retry.py @@ -1,5 +1,5 @@ from dbt.cli.types import Command -from dbt.task.retry import TASK_DICT, CMD_DICT +from dbt.task.retry import CMD_DICT, TASK_DICT EXCLUDED_COMMANDS = { "clean", diff --git a/tests/unit/task/test_runnable.py b/tests/unit/task/test_runnable.py index 50fda4f2c82..a16e627a1bb 100644 --- a/tests/unit/task/test_runnable.py +++ b/tests/unit/task/test_runnable.py @@ -1,9 +1,9 @@ -import pytest - from dataclasses import dataclass -from dbt.task.runnable import GraphRunnableTask from typing import AbstractSet, Any, Dict, Optional +import pytest + +from dbt.task.runnable import GraphRunnableTask from dbt.tests.util import safe_set_invocation_context diff --git a/tests/unit/test_base_context.py b/tests/unit/test_base_context.py index 0dc2d93ddca..2246c1f77ff 100644 --- a/tests/unit/test_base_context.py +++ b/tests/unit/test_base_context.py @@ -1,8 +1,9 @@ import os -from dbt.context.base import BaseContext from jinja2.runtime import Undefined +from dbt.context.base import BaseContext + class TestBaseContext: def test_log_jinja_undefined(self): diff --git a/tests/unit/test_compilation.py b/tests/unit/test_compilation.py index 8f002e340fc..458efb90901 100644 --- a/tests/unit/test_compilation.py +++ b/tests/unit/test_compilation.py @@ -1,15 +1,14 @@ import os import tempfile import unittest +from argparse import Namespace +from queue import Empty from unittest import mock from dbt import compilation -from dbt.graph.selector import NodeSelector -from dbt.graph.cli import parse_difference -from queue import Empty - from dbt.flags import set_from_args -from argparse import Namespace +from dbt.graph.cli import parse_difference +from dbt.graph.selector import NodeSelector set_from_args(Namespace(WARN_ERROR=False), None) diff --git a/tests/unit/test_contracts_graph_compiled.py b/tests/unit/test_contracts_graph_compiled.py index 7a34f826747..e345899e4d6 100644 --- a/tests/unit/test_contracts_graph_compiled.py +++ b/tests/unit/test_contracts_graph_compiled.py @@ -1,24 +1,18 @@ import pickle -import pytest - from dataclasses import replace -from dbt.artifacts.resources import ColumnInfo +import pytest + +from dbt.artifacts.resources import ColumnInfo, TestConfig, TestMetadata from dbt.contracts.files import FileHash -from dbt.contracts.graph.nodes import ( - DependsOn, - GenericTestNode, - ModelNode, - ModelConfig, -) -from dbt.artifacts.resources import TestConfig, TestMetadata -from tests.unit.fixtures import generic_test_node, model_node +from dbt.contracts.graph.nodes import DependsOn, GenericTestNode, ModelConfig, ModelNode from dbt.node_types import NodeType +from tests.unit.fixtures import generic_test_node, model_node from .utils import ( - assert_symmetric, - assert_from_dict, assert_fails_validation, + assert_from_dict, + assert_symmetric, replace_config, ) diff --git a/tests/unit/test_contracts_graph_parsed.py b/tests/unit/test_contracts_graph_parsed.py index 63800a69b7c..3a1861af462 100644 --- a/tests/unit/test_contracts_graph_parsed.py +++ b/tests/unit/test_contracts_graph_parsed.py @@ -1,10 +1,13 @@ import pickle -import pytest - +from argparse import Namespace from dataclasses import replace + +import pytest +from dbt_semantic_interfaces.type_enums import MetricType from hypothesis import given from hypothesis.strategies import builds, lists +from dbt import flags from dbt.artifacts.resources import ( ColumnInfo, Dimension, @@ -12,6 +15,8 @@ ExposureConfig, ExposureType, FreshnessThreshold, + Hook, + MacroDependsOn, MaturityType, Measure, MetricInputMeasure, @@ -19,51 +24,45 @@ Owner, Quoting, RefArgs, - MacroDependsOn, - TestMetadata, SourceConfig, - Time, - Hook, ) +from dbt.artifacts.resources import SourceDefinition as SourceDefinitionResource +from dbt.artifacts.resources import TestMetadata, Time from dbt.artifacts.resources.types import TimePeriod -from dbt.node_types import NodeType, AccessType from dbt.contracts.files import FileHash from dbt.contracts.graph.model_config import ( + EmptySnapshotConfig, + ModelConfig, NodeConfig, SeedConfig, - TestConfig, SnapshotConfig, - EmptySnapshotConfig, - ModelConfig, + TestConfig, ) from dbt.contracts.graph.nodes import ( - ModelNode, DependsOn, + Docs, + Documentation, + Exposure, GenericTestNode, - SnapshotNode, + HookNode, IntermediateSnapshotNode, Macro, - Exposure, Metric, + ModelNode, SeedNode, - Docs, - SourceDefinition, - Documentation, - HookNode, SemanticModel, + SnapshotNode, + SourceDefinition, ) -from dbt.artifacts.resources import SourceDefinition as SourceDefinitionResource -from dbt import flags -from argparse import Namespace - +from dbt.node_types import AccessType, NodeType from dbt_common.dataclass_schema import ValidationError -from dbt_semantic_interfaces.type_enums import MetricType + from .utils import ( ContractTestCase, - assert_symmetric, + assert_fails_validation, assert_from_dict, + assert_symmetric, compare_dicts, - assert_fails_validation, dict_replace, replace_config, ) diff --git a/tests/unit/test_contracts_graph_unparsed.py b/tests/unit/test_contracts_graph_unparsed.py index 16cc5c7c4b7..e1105b80820 100644 --- a/tests/unit/test_contracts_graph_unparsed.py +++ b/tests/unit/test_contracts_graph_unparsed.py @@ -1,24 +1,8 @@ -from datetime import timedelta import pickle +from datetime import timedelta + import pytest -from dbt.contracts.graph.unparsed import ( - UnparsedNode, - UnparsedRunHook, - UnparsedMacro, - UnparsedSourceDefinition, - UnparsedSourceTableDefinition, - UnparsedDocumentationFile, - UnparsedColumn, - UnparsedNodeUpdate, - UnparsedModelUpdate, - Docs, - UnparsedExposure, - UnparsedMetric, - UnparsedMetricTypeParams, - UnparsedMetricInputMeasure, - UnparsedVersion, -) from dbt.artifacts.resources import ( ExposureType, FreshnessThreshold, @@ -29,7 +13,25 @@ ) from dbt.artifacts.resources.types import TimePeriod from dbt.artifacts.schemas.results import FreshnessStatus +from dbt.contracts.graph.unparsed import ( + Docs, + UnparsedColumn, + UnparsedDocumentationFile, + UnparsedExposure, + UnparsedMacro, + UnparsedMetric, + UnparsedMetricInputMeasure, + UnparsedMetricTypeParams, + UnparsedModelUpdate, + UnparsedNode, + UnparsedNodeUpdate, + UnparsedRunHook, + UnparsedSourceDefinition, + UnparsedSourceTableDefinition, + UnparsedVersion, +) from dbt.node_types import NodeType + from .utils import ContractTestCase diff --git a/tests/unit/test_contracts_project.py b/tests/unit/test_contracts_project.py index 89713f6860d..b080326fcd2 100644 --- a/tests/unit/test_contracts_project.py +++ b/tests/unit/test_contracts_project.py @@ -1,8 +1,7 @@ -from .utils import ContractTestCase - +from dbt.contracts.project import Project from dbt_common.dataclass_schema import ValidationError -from dbt.contracts.project import Project +from .utils import ContractTestCase class TestProject(ContractTestCase): diff --git a/tests/unit/test_deprecations.py b/tests/unit/test_deprecations.py index ca8b8006cbc..85d1ea4add5 100644 --- a/tests/unit/test_deprecations.py +++ b/tests/unit/test_deprecations.py @@ -1,7 +1,8 @@ -from dbt.internal_deprecations import deprecated -from dbt.flags import set_from_args from argparse import Namespace +from dbt.flags import set_from_args +from dbt.internal_deprecations import deprecated + @deprecated(reason="just because", version="1.23.0", suggested_action="Make some updates") def to_be_decorated(): diff --git a/tests/unit/test_deps.py b/tests/unit/test_deps.py index d4edd90b134..1ca640c50c3 100644 --- a/tests/unit/test_deps.py +++ b/tests/unit/test_deps.py @@ -1,30 +1,29 @@ -from copy import deepcopy - import unittest +from argparse import Namespace +from copy import deepcopy from unittest import mock import dbt.deps import dbt.exceptions -from dbt.deps.git import GitUnpinnedPackage -from dbt.deps.local import LocalUnpinnedPackage, LocalPinnedPackage -from dbt.deps.tarball import TarballUnpinnedPackage -from dbt.deps.registry import RegistryUnpinnedPackage from dbt.clients.registry import is_compatible_version +from dbt.config.project import PartialProject from dbt.config.renderer import DbtProjectYamlRenderer -from dbt.deps.resolver import resolve_packages from dbt.contracts.project import ( - LocalPackage, - TarballPackage, GitPackage, + LocalPackage, + PackageConfig, RegistryPackage, + TarballPackage, ) -from dbt.config.project import PartialProject -from dbt.contracts.project import PackageConfig -from dbt_common.semver import VersionSpecifier +from dbt.deps.git import GitUnpinnedPackage +from dbt.deps.local import LocalPinnedPackage, LocalUnpinnedPackage +from dbt.deps.registry import RegistryUnpinnedPackage +from dbt.deps.resolver import resolve_packages +from dbt.deps.tarball import TarballUnpinnedPackage +from dbt.flags import set_from_args from dbt.version import get_installed_version from dbt_common.dataclass_schema import ValidationError -from dbt.flags import set_from_args -from argparse import Namespace +from dbt_common.semver import VersionSpecifier set_from_args(Namespace(WARN_ERROR=False), None) diff --git a/tests/unit/test_docs_blocks.py b/tests/unit/test_docs_blocks.py index cdf9933ce50..cb1b5e5e3cc 100644 --- a/tests/unit/test_docs_blocks.py +++ b/tests/unit/test_docs_blocks.py @@ -1,18 +1,17 @@ import os import unittest +from argparse import Namespace -from dbt.contracts.files import SourceFile, FileHash, FilePath +from dbt.contracts.files import FileHash, FilePath, SourceFile from dbt.contracts.graph.manifest import Manifest from dbt.contracts.graph.nodes import Documentation +from dbt.flags import set_from_args from dbt.node_types import NodeType from dbt.parser import docs from dbt.parser.search import FileBlock from .utils import config_from_parts_or_dicts -from dbt.flags import set_from_args -from argparse import Namespace - set_from_args(Namespace(WARN_ERROR=False), None) SNOWPLOW_SESSIONS_DOCS = r""" diff --git a/tests/unit/test_docs_generate.py b/tests/unit/test_docs_generate.py index 25cb2655a72..171b081c781 100644 --- a/tests/unit/test_docs_generate.py +++ b/tests/unit/test_docs_generate.py @@ -1,6 +1,6 @@ +import unittest from decimal import Decimal from unittest import mock -import unittest from dbt.task.docs import generate diff --git a/tests/unit/test_events.py b/tests/unit/test_events.py index 075136b028a..bd9892bcc6c 100644 --- a/tests/unit/test_events.py +++ b/tests/unit/test_events.py @@ -6,12 +6,9 @@ import pytest from dbt.adapters.events import types as adapter_types -from dbt_common.events.event_manager_client import ctx_set_event_manager -from dbt.artifacts.schemas.results import TimingInfo, RunStatus -from dbt.artifacts.schemas.run import RunResult -from dbt_common.events import types from dbt.adapters.events.logging import AdapterLogger -from dbt_common.events.base_types import msg_from_base_event +from dbt.artifacts.schemas.results import RunStatus, TimingInfo +from dbt.artifacts.schemas.run import RunResult from dbt.events import types as core_types from dbt.events.base_types import ( CoreBaseEvent, @@ -22,12 +19,15 @@ TestLevel, WarnLevel, ) -from dbt_common.events.event_manager import TestEventManager, EventManager -from dbt_common.events.functions import msg_to_dict, msg_to_json -from dbt_common.events.helpers import get_json_string_utcnow from dbt.events.types import RunResultError from dbt.flags import set_from_args from dbt.task.printer import print_run_result_error +from dbt_common.events import types +from dbt_common.events.base_types import msg_from_base_event +from dbt_common.events.event_manager import EventManager, TestEventManager +from dbt_common.events.event_manager_client import ctx_set_event_manager +from dbt_common.events.functions import msg_to_dict, msg_to_json +from dbt_common.events.helpers import get_json_string_utcnow set_from_args(Namespace(WARN_ERROR=False), None) diff --git a/tests/unit/test_functions.py b/tests/unit/test_functions.py index 24b332c1daa..e218178bf1c 100644 --- a/tests/unit/test_functions.py +++ b/tests/unit/test_functions.py @@ -1,17 +1,15 @@ from argparse import Namespace -import pytest +import pytest import dbt.flags as flags -from dbt_common.events.functions import msg_to_dict, warn_or_error -from dbt_common.events.event_manager_client import cleanup_event_logger - +from dbt.adapters.events.types import AdapterDeprecationWarning from dbt.events.logging import setup_event_logger -from dbt_common.events.types import InfoLevel -from dbt_common.exceptions import EventCompilationError from dbt.events.types import NoNodesForSelectionCriteria -from dbt.adapters.events.types import AdapterDeprecationWarning -from dbt_common.events.types import RetryExternalCall +from dbt_common.events.event_manager_client import cleanup_event_logger +from dbt_common.events.functions import msg_to_dict, warn_or_error +from dbt_common.events.types import InfoLevel, RetryExternalCall +from dbt_common.exceptions import EventCompilationError @pytest.mark.parametrize( diff --git a/tests/unit/test_graph_selection.py b/tests/unit/test_graph_selection.py index ac0cb0a1d01..be283e59926 100644 --- a/tests/unit/test_graph_selection.py +++ b/tests/unit/test_graph_selection.py @@ -1,19 +1,16 @@ +import string +from argparse import Namespace from unittest import mock +import networkx as nx import pytest -import string -import dbt_common.exceptions -import dbt.graph.selector as graph_selector import dbt.graph.cli as graph_cli -from dbt.node_types import NodeType - -import networkx as nx - +import dbt.graph.selector as graph_selector +import dbt_common.exceptions from dbt import flags - -from argparse import Namespace from dbt.contracts.project import ProjectFlags +from dbt.node_types import NodeType flags.set_from_args(Namespace(), ProjectFlags()) diff --git a/tests/unit/test_graph_selector_methods.py b/tests/unit/test_graph_selector_methods.py index 136131806f4..bc717f90ce8 100644 --- a/tests/unit/test_graph_selector_methods.py +++ b/tests/unit/test_graph_selector_methods.py @@ -1,46 +1,47 @@ import copy -import pytest from dataclasses import replace +from pathlib import Path from unittest import mock -from pathlib import Path +import pytest + +import dbt_common.exceptions from dbt.artifacts.resources import ColumnInfo, FileHash from dbt.contracts.graph.manifest import Manifest - from dbt.contracts.state import PreviousState from dbt.graph.selector_methods import ( - MethodManager, - QualifiedNameSelectorMethod, - TagSelectorMethod, - GroupSelectorMethod, AccessSelectorMethod, - SourceSelectorMethod, - PathSelectorMethod, - FileSelectorMethod, - PackageSelectorMethod, ConfigSelectorMethod, - TestNameSelectorMethod, - TestTypeSelectorMethod, - StateSelectorMethod, ExposureSelectorMethod, + FileSelectorMethod, + GroupSelectorMethod, + MethodManager, MetricSelectorMethod, - VersionSelectorMethod, + PackageSelectorMethod, + PathSelectorMethod, + QualifiedNameSelectorMethod, SavedQuerySelectorMethod, SemanticModelSelectorMethod, + SourceSelectorMethod, + StateSelectorMethod, + TagSelectorMethod, + TestNameSelectorMethod, + TestTypeSelectorMethod, + VersionSelectorMethod, ) -import dbt_common.exceptions -from .utils import replace_config from tests.unit.utils.manifest import ( - make_model, - make_seed, make_exposure, + make_group, + make_macro, make_metric, + make_model, make_saved_query, + make_seed, make_semantic_model, - make_group, - make_macro, ) +from .utils import replace_config + def search_manifest_using_method(manifest, method, selection): selected = method.search( diff --git a/tests/unit/test_graph_selector_parsing.py b/tests/unit/test_graph_selector_parsing.py index f330412ffc8..62cabab14f6 100644 --- a/tests/unit/test_graph_selector_parsing.py +++ b/tests/unit/test_graph_selector_parsing.py @@ -1,15 +1,16 @@ -from dbt.graph import ( - cli, - SelectionUnion, - SelectionIntersection, - SelectionDifference, - SelectionCriteria, -) -from dbt.graph.selector_methods import MethodName import textwrap + import yaml from dbt.contracts.selection import SelectorFile +from dbt.graph import ( + SelectionCriteria, + SelectionDifference, + SelectionIntersection, + SelectionUnion, + cli, +) +from dbt.graph.selector_methods import MethodName def parse_file(txt: str) -> SelectorFile: diff --git a/tests/unit/test_graph_selector_spec.py b/tests/unit/test_graph_selector_spec.py index 8a19a8b5934..6164f113158 100644 --- a/tests/unit/test_graph_selector_spec.py +++ b/tests/unit/test_graph_selector_spec.py @@ -1,14 +1,15 @@ +import os + import pytest from dbt.exceptions import DbtRuntimeError +from dbt.graph.selector_methods import MethodName from dbt.graph.selector_spec import ( SelectionCriteria, - SelectionIntersection, SelectionDifference, + SelectionIntersection, SelectionUnion, ) -from dbt.graph.selector_methods import MethodName -import os def test_raw_parse_simple(): diff --git a/tests/unit/test_infer_primary_key.py b/tests/unit/test_infer_primary_key.py index 4afa2bf4652..8500c8ea7fe 100644 --- a/tests/unit/test_infer_primary_key.py +++ b/tests/unit/test_infer_primary_key.py @@ -1,18 +1,13 @@ +from dbt.artifacts.resources import TestMetadata +from dbt.contracts.graph.model_config import TestConfig +from dbt.contracts.graph.nodes import ColumnInfo from dbt_common.contracts.constraints import ( + ColumnLevelConstraint, ConstraintType, ModelLevelConstraint, - ColumnLevelConstraint, ) -from .fixtures import model_node, generic_test_node - -from dbt.contracts.graph.model_config import ( - TestConfig, -) -from dbt.contracts.graph.nodes import ( - ColumnInfo, -) -from dbt.artifacts.resources import TestMetadata +from .fixtures import generic_test_node, model_node def test_no_primary_key(): diff --git a/tests/unit/test_inject_ctes.py b/tests/unit/test_inject_ctes.py index 8b459f92e7c..e6efdd4f1a6 100644 --- a/tests/unit/test_inject_ctes.py +++ b/tests/unit/test_inject_ctes.py @@ -1,6 +1,7 @@ +import re + from dbt.compilation import inject_ctes_into_sql from dbt.contracts.graph.nodes import InjectedCTE -import re def norm_whitespace(string): diff --git a/tests/unit/test_jinja.py b/tests/unit/test_jinja.py index e4b0596fb02..94150be8e26 100644 --- a/tests/unit/test_jinja.py +++ b/tests/unit/test_jinja.py @@ -1,10 +1,10 @@ +import unittest from contextlib import contextmanager + import pytest -import unittest import yaml -from dbt.clients.jinja import get_rendered -from dbt.clients.jinja import get_template +from dbt.clients.jinja import get_rendered, get_template from dbt_common.exceptions import JinjaRenderingError diff --git a/tests/unit/test_manifest_selectors.py b/tests/unit/test_manifest_selectors.py index f9b7ff279f9..36ab31a5874 100644 --- a/tests/unit/test_manifest_selectors.py +++ b/tests/unit/test_manifest_selectors.py @@ -1,7 +1,9 @@ import textwrap -import yaml -from collections import OrderedDict import unittest +from collections import OrderedDict + +import yaml + from dbt.config.selectors import SelectorDict from dbt.exceptions import DbtSelectorsError diff --git a/tests/unit/test_node_types.py b/tests/unit/test_node_types.py index 9611429a934..87bbf51e3a1 100644 --- a/tests/unit/test_node_types.py +++ b/tests/unit/test_node_types.py @@ -1,4 +1,5 @@ import pytest + from dbt.node_types import NodeType node_type_pluralizations = { diff --git a/tests/unit/test_parser.py b/tests/unit/test_parser.py index 420354f585e..c57dd306dcd 100644 --- a/tests/unit/test_parser.py +++ b/tests/unit/test_parser.py @@ -9,52 +9,52 @@ import dbt.flags import dbt.parser from dbt import tracking -from dbt.artifacts.resources import ModelConfig -from dbt.artifacts.resources import RefArgs +from dbt.artifacts.resources import ModelConfig, RefArgs from dbt.context.context_config import ContextConfig -from dbt.contracts.files import SourceFile, FileHash, FilePath, SchemaSourceFile +from dbt.contracts.files import FileHash, FilePath, SchemaSourceFile, SourceFile from dbt.contracts.graph.manifest import Manifest -from dbt.contracts.graph.model_config import NodeConfig, TestConfig, SnapshotConfig +from dbt.contracts.graph.model_config import NodeConfig, SnapshotConfig, TestConfig from dbt.contracts.graph.nodes import ( - ModelNode, - Macro, + AnalysisNode, DependsOn, + Macro, + ModelNode, SingularTestNode, SnapshotNode, - AnalysisNode, UnpatchedSourceDefinition, ) from dbt.exceptions import CompilationError, ParsingError, SchemaConfigError from dbt.flags import set_from_args from dbt.node_types import NodeType from dbt.parser import ( - ModelParser, - MacroParser, - SingularTestParser, + AnalysisParser, GenericTestParser, + MacroParser, + ModelParser, SchemaParser, + SingularTestParser, SnapshotParser, - AnalysisParser, ) from dbt.parser.common import YamlBlock from dbt.parser.models import ( _get_config_call_dict, - _shift_sources, _get_exp_sample_result, - _get_stable_sample_result, _get_sample_result, + _get_stable_sample_result, + _shift_sources, ) from dbt.parser.schemas import ( - TestablePatchParser, - ModelPatchParser, - SourceParser, AnalysisPatchParser, MacroPatchParser, + ModelPatchParser, + SourceParser, + TestablePatchParser, yaml_from_file, ) from dbt.parser.search import FileBlock from dbt.parser.sources import SourcePatcher -from .utils import config_from_parts_or_dicts, normalize, generate_name_macros, MockNode + +from .utils import MockNode, config_from_parts_or_dicts, generate_name_macros, normalize set_from_args(Namespace(WARN_ERROR=False), None) diff --git a/tests/unit/test_proto_events.py b/tests/unit/test_proto_events.py index 906e061a409..7d369e6b00d 100644 --- a/tests/unit/test_proto_events.py +++ b/tests/unit/test_proto_events.py @@ -1,22 +1,26 @@ -from dbt.adapters.events.types import ( - RollbackFailed, - PluginLoadError, -) -from dbt_common.events.functions import msg_to_dict, msg_to_json, LOG_VERSION, reset_metadata_vars -from dbt_common.events import types_pb2 -from dbt_common.events.base_types import msg_from_base_event, EventLevel +from argparse import Namespace + +from google.protobuf.json_format import MessageToDict + +from dbt.adapters.events.types import PluginLoadError, RollbackFailed +from dbt.events import core_types_pb2 from dbt.events.types import ( - MainReportVersion, - MainReportArgs, - MainEncounteredError, LogStartLine, LogTestResult, + MainEncounteredError, + MainReportArgs, + MainReportVersion, ) -from dbt.events import core_types_pb2 -from dbt.version import installed -from google.protobuf.json_format import MessageToDict from dbt.flags import set_from_args -from argparse import Namespace +from dbt.version import installed +from dbt_common.events import types_pb2 +from dbt_common.events.base_types import EventLevel, msg_from_base_event +from dbt_common.events.functions import ( + LOG_VERSION, + msg_to_dict, + msg_to_json, + reset_metadata_vars, +) set_from_args(Namespace(WARN_ERROR=False), None) diff --git a/tests/unit/test_registry_get_request_exception.py b/tests/unit/test_registry_get_request_exception.py index 615f9024462..d6afd9c8f66 100644 --- a/tests/unit/test_registry_get_request_exception.py +++ b/tests/unit/test_registry_get_request_exception.py @@ -1,7 +1,7 @@ import unittest -from dbt_common.exceptions import ConnectionError from dbt.clients.registry import _get_with_retries +from dbt_common.exceptions import ConnectionError class testRegistryGetRequestException(unittest.TestCase): diff --git a/tests/unit/test_semantic_layer_nodes_satisfy_protocols.py b/tests/unit/test_semantic_layer_nodes_satisfy_protocols.py index e2765499355..99d364b5da4 100644 --- a/tests/unit/test_semantic_layer_nodes_satisfy_protocols.py +++ b/tests/unit/test_semantic_layer_nodes_satisfy_protocols.py @@ -1,11 +1,25 @@ -import pytest import copy +from typing import Protocol, runtime_checkable -from dbt.contracts.graph.nodes import ( - Metric, - SavedQuery, - SemanticModel, +import pytest +from dbt_semantic_interfaces.protocols import WhereFilter as WhereFilterProtocol +from dbt_semantic_interfaces.protocols import dimension as DimensionProtocols +from dbt_semantic_interfaces.protocols import entity as EntityProtocols +from dbt_semantic_interfaces.protocols import measure as MeasureProtocols +from dbt_semantic_interfaces.protocols import metadata as MetadataProtocols +from dbt_semantic_interfaces.protocols import metric as MetricProtocols +from dbt_semantic_interfaces.protocols import saved_query as SavedQueryProtocols +from dbt_semantic_interfaces.protocols import semantic_model as SemanticModelProtocols +from dbt_semantic_interfaces.type_enums import ( + AggregationType, + DimensionType, + EntityType, + MetricType, + TimeGranularity, ) +from hypothesis import given +from hypothesis.strategies import builds, none, text + from dbt.artifacts.resources import ( ConstantPropertyInput, ConversionTypeParams, @@ -26,27 +40,8 @@ SourceFileMetadata, WhereFilter, ) +from dbt.contracts.graph.nodes import Metric, SavedQuery, SemanticModel from dbt.node_types import NodeType -from dbt_semantic_interfaces.protocols import ( - dimension as DimensionProtocols, - entity as EntityProtocols, - measure as MeasureProtocols, - metadata as MetadataProtocols, - metric as MetricProtocols, - saved_query as SavedQueryProtocols, - semantic_model as SemanticModelProtocols, - WhereFilter as WhereFilterProtocol, -) -from dbt_semantic_interfaces.type_enums import ( - AggregationType, - DimensionType, - EntityType, - MetricType, - TimeGranularity, -) -from hypothesis import given -from hypothesis.strategies import builds, none, text -from typing import Protocol, runtime_checkable @runtime_checkable diff --git a/tests/unit/test_semver.py b/tests/unit/test_semver.py index deb155586b6..ae48e592fc0 100644 --- a/tests/unit/test_semver.py +++ b/tests/unit/test_semver.py @@ -1,16 +1,16 @@ -import unittest import itertools - +import unittest from typing import List + from dbt_common.exceptions import VersionsNotCompatibleError from dbt_common.semver import ( - VersionSpecifier, UnboundedVersionSpecifier, VersionRange, + VersionSpecifier, + filter_installable, reduce_versions, - versions_compatible, resolve_to_specific_version, - filter_installable, + versions_compatible, ) diff --git a/tests/unit/test_tracking.py b/tests/unit/test_tracking.py index d2bea6b152e..685f1108c1b 100644 --- a/tests/unit/test_tracking.py +++ b/tests/unit/test_tracking.py @@ -1,8 +1,9 @@ +import datetime +import tempfile + import pytest import dbt.tracking -import datetime -import tempfile @pytest.fixture(scope="function") diff --git a/tests/unit/utils/__init__.py b/tests/unit/utils/__init__.py index 608249aa114..7df68c949cc 100644 --- a/tests/unit/utils/__init__.py +++ b/tests/unit/utils/__init__.py @@ -3,15 +3,15 @@ Note that all imports should be inside the functions to avoid import/mocking issues. """ -import string import os -from unittest import mock -from unittest import TestCase +import string +from unittest import TestCase, mock import agate import pytest -from dbt_common.dataclass_schema import ValidationError + from dbt.config.project import PartialProject +from dbt_common.dataclass_schema import ValidationError def normalize(path): @@ -76,9 +76,10 @@ def project_from_dict(project, profile, packages=None, selectors=None, cli_vars= def config_from_parts_or_dicts(project, profile, packages=None, selectors=None, cli_vars={}): - from dbt.config import Project, Profile, RuntimeConfig from copy import deepcopy + from dbt.config import Profile, Project, RuntimeConfig + if isinstance(project, Project): profile_name = project.profile_name else: @@ -305,8 +306,8 @@ def MockGenerateMacro(package, component="some_component", **kwargs): def MockSource(package, source_name, name, **kwargs): - from dbt.node_types import NodeType from dbt.contracts.graph.nodes import SourceDefinition + from dbt.node_types import NodeType src = mock.MagicMock( __class__=SourceDefinition, @@ -322,8 +323,8 @@ def MockSource(package, source_name, name, **kwargs): def MockNode(package, name, resource_type=None, **kwargs): - from dbt.node_types import NodeType from dbt.contracts.graph.nodes import ModelNode, SeedNode + from dbt.node_types import NodeType if resource_type is None: resource_type = NodeType.Model @@ -351,8 +352,8 @@ def MockNode(package, name, resource_type=None, **kwargs): def MockDocumentation(package, name, **kwargs): - from dbt.node_types import NodeType from dbt.contracts.graph.nodes import Documentation + from dbt.node_types import NodeType doc = mock.MagicMock( __class__=Documentation, diff --git a/tests/unit/utils/manifest.py b/tests/unit/utils/manifest.py index d1210694762..c62d0bd0edf 100644 --- a/tests/unit/utils/manifest.py +++ b/tests/unit/utils/manifest.py @@ -1,46 +1,43 @@ from argparse import Namespace + import pytest +from dbt_semantic_interfaces.type_enums import MetricType +from dbt.artifacts.resources import ( + ExposureType, + MacroDependsOn, + MetricInputMeasure, + MetricTypeParams, + NodeRelation, + Owner, + QueryParams, + RefArgs, + TestConfig, + TestMetadata, +) from dbt.artifacts.resources.v1.model import ModelConfig from dbt.contracts.files import FileHash +from dbt.contracts.graph.manifest import Manifest, ManifestMetadata from dbt.contracts.graph.nodes import ( + AccessType, DependsOn, - NodeConfig, - Macro, - ModelNode, Exposure, - Metric, + GenericTestNode, Group, + Macro, + Metric, + ModelNode, + NodeConfig, SavedQuery, SeedNode, SemanticModel, SingularTestNode, - GenericTestNode, SourceDefinition, - AccessType, UnitTestDefinition, ) -from dbt.contracts.graph.manifest import Manifest, ManifestMetadata -from dbt.artifacts.resources import ( - ExposureType, - MetricInputMeasure, - MetricTypeParams, - NodeRelation, - Owner, - QueryParams, - MacroDependsOn, - TestConfig, - TestMetadata, - RefArgs, -) -from dbt.contracts.graph.unparsed import ( - UnitTestInputFixture, - UnitTestOutputFixture, -) -from dbt.node_types import NodeType - -from dbt_semantic_interfaces.type_enums import MetricType +from dbt.contracts.graph.unparsed import UnitTestInputFixture, UnitTestOutputFixture from dbt.flags import set_from_args +from dbt.node_types import NodeType set_from_args(Namespace(WARN_ERROR=False), None)