Skip to content

Commit

Permalink
[TIDY-FIRST] Fix isort for dbt-semantic-interfaces (#10394)
Browse files Browse the repository at this point in the history
* Correct `isort` configuration to include dbt-semantic-interfaces as internal

We thought we were already doing this. However, we accidentally missed the last
`s` of `dbt-semantic-interfaces`, so imports from dbt-semantic-interfaces were not
being identified as an internal package by isort. This fixes that.

* Run isort using updated configs to mark `dbt-semantic-interfaces` as included
  • Loading branch information
QMalcolm authored Jul 2, 2024
1 parent 37fd299 commit 37e2725
Show file tree
Hide file tree
Showing 19 changed files with 72 additions and 80 deletions.
2 changes: 1 addition & 1 deletion .isort.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +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
known_first_party=dbt,dbt_adapters,dbt_common,dbt_extractor,dbt_semantic_interfaces
15 changes: 7 additions & 8 deletions core/dbt/artifacts/resources/v1/metric.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@
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,
PeriodAggregation,
TimeGranularity,
)

from dbt.artifacts.resources.base import GraphResource
from dbt.artifacts.resources.types import NodeType
from dbt.artifacts.resources.v1.components import DependsOn, RefArgs
Expand All @@ -19,6 +11,13 @@
)
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,
PeriodAggregation,
TimeGranularity,
)

"""
The following classes are dataclasses which are used to construct the Metric
Expand Down
7 changes: 3 additions & 4 deletions core/dbt/artifacts/resources/v1/saved_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@
from dataclasses import dataclass, field
from typing import Any, Dict, List, Literal, Optional

from dbt_semantic_interfaces.type_enums.export_destination_type import (
ExportDestinationType,
)

from dbt.artifacts.resources.base import GraphResource
from dbt.artifacts.resources.types import NodeType
from dbt.artifacts.resources.v1.components import DependsOn, RefArgs
Expand All @@ -17,6 +13,9 @@
)
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,
)


@dataclass
Expand Down
3 changes: 1 addition & 2 deletions core/dbt/artifacts/resources/v1/semantic_layer_components.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from dataclasses import dataclass
from typing import List, Sequence, Tuple

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 dbt_common.dataclass_schema import dbtClassMixin


@dataclass
class WhereFilter(dbtClassMixin):
Expand Down
11 changes: 5 additions & 6 deletions core/dbt/artifacts/resources/v1/semantic_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
from dataclasses import dataclass, field
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
from dbt_semantic_interfaces.references import (
DimensionReference,
EntityReference,
Expand All @@ -17,12 +22,6 @@
TimeGranularity,
)

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
Model node in dbt-core. Additionally, these classes need to at a minimum support
Expand Down
3 changes: 1 addition & 2 deletions core/dbt/contracts/graph/metrics.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from typing import Any, Dict, Iterator, List

from dbt_semantic_interfaces.type_enums import MetricType

from dbt.contracts.graph.manifest import Manifest, Metric
from dbt_semantic_interfaces.type_enums import MetricType

DERIVED_METRICS = [MetricType.DERIVED, MetricType.RATIO]
BASE_METRICS = [MetricType.SIMPLE, MetricType.CUMULATIVE, MetricType.CONVERSION]
Expand Down
13 changes: 6 additions & 7 deletions core/dbt/contracts/graph/semantic_manifest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
from dbt.constants import TIME_SPINE_MODEL_NAME
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_semantic_interfaces.implementations.metric import PydanticMetric
from dbt_semantic_interfaces.implementations.project_configuration import (
PydanticProjectConfiguration,
Expand All @@ -15,13 +21,6 @@
SemanticManifestValidator,
)

from dbt.constants import TIME_SPINE_MODEL_NAME
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


class SemanticManifest:
def __init__(self, manifest) -> None:
Expand Down
9 changes: 4 additions & 5 deletions core/dbt/contracts/graph/unparsed.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
from pathlib import Path
from typing import Any, Dict, List, Literal, Optional, Sequence, Union

from dbt_semantic_interfaces.type_enums import (
ConversionCalculationType,
PeriodAggregation,
)

# trigger the PathEncoder
import dbt_common.helper_types # noqa:F401
from dbt import deprecations
Expand Down Expand Up @@ -42,6 +37,10 @@
dbtClassMixin,
)
from dbt_common.exceptions import DbtInternalError
from dbt_semantic_interfaces.type_enums import (
ConversionCalculationType,
PeriodAggregation,
)


@dataclass
Expand Down
4 changes: 2 additions & 2 deletions core/dbt/parser/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
from typing import Any, Callable, Dict, List, Mapping, Optional, Set, Tuple, Type, Union

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
Expand Down Expand Up @@ -119,6 +117,8 @@
from dbt_common.events.types import Note
from dbt_common.exceptions.base import DbtValidationError
from dbt_common.helper_types import PathSet
from dbt_semantic_interfaces.enum_extension import assert_values_exhausted
from dbt_semantic_interfaces.type_enums import MetricType

PERF_INFO_FILE_NAME = "perf_info.json"

Expand Down
19 changes: 9 additions & 10 deletions core/dbt/parser/schema_yaml_readers.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
from typing import Any, Dict, List, Optional, Union

from dbt_semantic_interfaces.type_enums import (
AggregationType,
ConversionCalculationType,
DimensionType,
EntityType,
MetricType,
PeriodAggregation,
TimeGranularity,
)

from dbt.artifacts.resources import (
ConversionTypeParams,
CumulativeTypeParams,
Expand Down Expand Up @@ -67,6 +57,15 @@
from dbt.parser.schemas import ParseResult, SchemaParser, YamlReader
from dbt_common.dataclass_schema import ValidationError
from dbt_common.exceptions import DbtInternalError
from dbt_semantic_interfaces.type_enums import (
AggregationType,
ConversionCalculationType,
DimensionType,
EntityType,
MetricType,
PeriodAggregation,
TimeGranularity,
)


def parse_where_filter(
Expand Down
4 changes: 2 additions & 2 deletions tests/functional/metrics/test_metrics.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import pytest
from dbt_semantic_interfaces.type_enums.period_agg import PeriodAggregation
from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity

from dbt.artifacts.resources.v1.metric import CumulativeTypeParams, MetricTimeWindow
from dbt.cli.main import dbtRunner
from dbt.contracts.graph.manifest import Manifest
from dbt.exceptions import ParsingError
from dbt.tests.util import get_manifest, run_dbt
from dbt_semantic_interfaces.type_enums.period_agg import PeriodAggregation
from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity
from tests.functional.metrics.fixtures import (
basic_metrics_yml,
conversion_metric_yml,
Expand Down
6 changes: 3 additions & 3 deletions tests/functional/saved_queries/test_configs.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
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 (
Expand Down
6 changes: 3 additions & 3 deletions tests/functional/saved_queries/test_saved_query_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
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.tests.util import run_dbt, write_file
from dbt_common.events.base_types import BaseEvent
from dbt_semantic_interfaces.type_enums.export_destination_type import (
ExportDestinationType,
)
from tests.functional.assertions.test_runner import dbtTestRunner
from tests.functional.saved_queries.fixtures import (
saved_queries_with_defaults_yml,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
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.tests.util import write_file
from dbt_common.events.base_types import BaseEvent
from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity
from tests.functional.assertions.test_runner import dbtTestRunner
from tests.functional.semantic_models.fixtures import (
fct_revenue_sql,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/contracts/graph/test_manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import freezegun
import pytest
from dbt_semantic_interfaces.type_enums import MetricType

import dbt.flags
import dbt.version
Expand Down Expand Up @@ -42,6 +41,7 @@
from dbt.flags import set_from_args
from dbt.node_types import NodeType
from dbt_common.events.functions import reset_metadata_vars
from dbt_semantic_interfaces.type_enums import MetricType
from tests.unit.utils import (
MockDocumentation,
MockGenerateMacro,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/contracts/graph/test_nodes_parsed.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from dataclasses import replace

import pytest
from dbt_semantic_interfaces.type_enums import MetricType
from hypothesis import given
from hypothesis.strategies import builds, lists

Expand Down Expand Up @@ -53,6 +52,7 @@
)
from dbt.node_types import AccessType, NodeType
from dbt_common.dataclass_schema import ValidationError
from dbt_semantic_interfaces.type_enums import MetricType
from tests.unit.utils import (
ContractTestCase,
assert_fails_validation,
Expand Down
12 changes: 6 additions & 6 deletions tests/unit/graph/test_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
from typing import List

import pytest
from dbt_semantic_interfaces.references import MeasureReference
from dbt_semantic_interfaces.type_enums import (
AggregationType,
DimensionType,
EntityType,
)
from freezegun import freeze_time

from dbt.artifacts.resources import (
Expand All @@ -28,6 +22,12 @@
ConstraintType,
ModelLevelConstraint,
)
from dbt_semantic_interfaces.references import MeasureReference
from dbt_semantic_interfaces.type_enums import (
AggregationType,
DimensionType,
EntityType,
)
from tests.unit.fixtures import generic_test_node, model_node


Expand Down
30 changes: 15 additions & 15 deletions tests/unit/test_semantic_layer_nodes_satisfy_protocols.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,6 @@
from typing import Protocol, runtime_checkable

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

Expand All @@ -43,6 +28,21 @@
)
from dbt.contracts.graph.nodes import Metric, SavedQuery, SemanticModel
from dbt.node_types import NodeType
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,
)


@runtime_checkable
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/utils/manifest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from typing import Any, Dict, List

import pytest
from dbt_semantic_interfaces.type_enums import MetricType

from dbt.artifacts.resources import (
ExposureType,
Expand Down Expand Up @@ -43,6 +42,7 @@
)
from dbt.contracts.graph.unparsed import UnitTestInputFixture, UnitTestOutputFixture
from dbt.node_types import NodeType
from dbt_semantic_interfaces.type_enums import MetricType


def make_model(
Expand Down

0 comments on commit 37e2725

Please sign in to comment.