Skip to content

Commit

Permalink
fixed formatting & linting
Browse files Browse the repository at this point in the history
  • Loading branch information
DevonFulcher committed Sep 18, 2023
1 parent 1aff3c9 commit 29eeceb
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
PydanticCustomInputParser,
PydanticParseableValueType,
)
from dbt_semantic_interfaces.parsing.where_filter.where_filter_parser import WhereFilterParser
from dbt_semantic_interfaces.parsing.where_filter.where_filter_parser import (
WhereFilterParser,
)


class PydanticWhereFilter(PydanticCustomInputParser, HashableBaseModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,21 @@
TimeDimensionCallParameterSet,
)
from dbt_semantic_interfaces.naming.dundered import DunderedNameFormatter
from dbt_semantic_interfaces.naming.keywords import METRIC_TIME_ELEMENT_NAME, is_metric_time_name
from dbt_semantic_interfaces.references import DimensionReference, EntityReference, TimeDimensionReference
from dbt_semantic_interfaces.naming.keywords import (
METRIC_TIME_ELEMENT_NAME,
is_metric_time_name,
)
from dbt_semantic_interfaces.references import (
DimensionReference,
EntityReference,
TimeDimensionReference,
)
from dbt_semantic_interfaces.type_enums import TimeGranularity


class ParameterSetFactory:
"""Creates parameter sets for use in the Jinja sandbox."""

@staticmethod
def _exception_message_for_incorrect_format(element_name: str) -> str:
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,17 @@

from typing import List, Optional, Sequence

from dbt_semantic_interfaces.call_parameter_sets import (
DimensionCallParameterSet,
TimeDimensionCallParameterSet,
from typing_extensions import override

from dbt_semantic_interfaces.call_parameter_sets import TimeDimensionCallParameterSet
from dbt_semantic_interfaces.parsing.where_filter.parameter_set_factory import (
ParameterSetFactory,
)
from dbt_semantic_interfaces.parsing.where_filter.parameter_set_factory import ParameterSetFactory
from dbt_semantic_interfaces.parsing.where_filter.query_interface import (
QueryInterfaceDimension,
QueryInterfaceDimensionFactory,
)
from dbt_semantic_interfaces.protocols.protocol_hint import ProtocolHint
from typing_extensions import override

from dbt_semantic_interfaces.type_enums.time_granularity import TimeGranularity


Expand All @@ -39,7 +38,7 @@ def grain(self, time_granularity: str) -> QueryInterfaceDimension:
"""The time granularity."""
self.time_granularity = TimeGranularity(time_granularity)
self._time_dimension_call_parameter_sets.append(
ParameterSetFactory.create_time_dimension(self.name, self.time_granularity, self.entity_path)
ParameterSetFactory.create_time_dimension(self.name, time_granularity, self.entity_path)
)
return self

Expand All @@ -59,7 +58,6 @@ def _implements_protocol(self) -> QueryInterfaceDimensionFactory:
return self

def __init__(self, time_dimension_call_parameter_sets: List[TimeDimensionCallParameterSet]): # noqa
self.dimension_call_parameter_sets: List[DimensionCallParameterSet] = []
self.created: List[WhereFilterDimension] = []
self._time_dimension_call_parameter_sets = time_dimension_call_parameter_sets

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,35 @@

from typing import List, Sequence

from typing_extensions import override

from dbt_semantic_interfaces.call_parameter_sets import EntityCallParameterSet
from dbt_semantic_interfaces.parsing.where_filter.parameter_set_factory import ParameterSetFactory
from dbt_semantic_interfaces.parsing.where_filter.parameter_set_factory import (
ParameterSetFactory,
)
from dbt_semantic_interfaces.parsing.where_filter.query_interface import (
QueryInterfaceEntity,
QueryInterfaceEntityFactory,
)
from dbt_semantic_interfaces.protocols.protocol_hint import ProtocolHint
from typing_extensions import override


class EntityStub(ProtocolHint[QueryInterfaceEntity]):
"""An Entity implementation that does nothing."""

@override
def _implements_protocol(self) -> QueryInterfaceEntity:
return self


class WhereFilterEntityFactory(ProtocolHint[QueryInterfaceEntityFactory]):
"""Executes in the Jinja sandbox to produce parameter sets and append them to a list."""

@override
def _implements_protocol(self) -> QueryInterfaceEntityFactory:
return self

def __init__(self): # noqa
def __init__(self) -> None: # noqa
self.entity_call_parameter_sets: List[EntityCallParameterSet] = []

def create(self, entity_name: str, entity_path: Sequence[str] = ()) -> EntityStub:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
from __future__ import annotations
from dbt_semantic_interfaces.parsing.where_filter.parameter_set_factory import ParameterSetFactory

from dbt_semantic_interfaces.parsing.where_filter.where_filter_dimension import WhereFilterDimensionFactory
from dbt_semantic_interfaces.parsing.where_filter.where_filter_entity import WhereFilterEntityFactory
from dbt_semantic_interfaces.parsing.where_filter.where_filter_time_dimension import WhereFilterTimeDimensionFactory

from jinja2 import StrictUndefined
from jinja2.exceptions import SecurityError, TemplateSyntaxError, UndefinedError
Expand All @@ -13,6 +8,18 @@
FilterCallParameterSets,
ParseWhereFilterException,
)
from dbt_semantic_interfaces.parsing.where_filter.parameter_set_factory import (
ParameterSetFactory,
)
from dbt_semantic_interfaces.parsing.where_filter.where_filter_dimension import (
WhereFilterDimensionFactory,
)
from dbt_semantic_interfaces.parsing.where_filter.where_filter_entity import (
WhereFilterEntityFactory,
)
from dbt_semantic_interfaces.parsing.where_filter.where_filter_time_dimension import (
WhereFilterTimeDimensionFactory,
)


class WhereFilterParser:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,35 @@

from typing import List, Sequence

from dbt_semantic_interfaces.call_parameter_sets import (
TimeDimensionCallParameterSet,
from typing_extensions import override

from dbt_semantic_interfaces.call_parameter_sets import TimeDimensionCallParameterSet
from dbt_semantic_interfaces.parsing.where_filter.parameter_set_factory import (
ParameterSetFactory,
)
from dbt_semantic_interfaces.parsing.where_filter.parameter_set_factory import ParameterSetFactory
from dbt_semantic_interfaces.parsing.where_filter.query_interface import (
QueryInterfaceTimeDimension,
QueryInterfaceTimeDimensionFactory,
)
from dbt_semantic_interfaces.protocols.protocol_hint import ProtocolHint
from typing_extensions import override


class TimeDimensionStub(ProtocolHint[QueryInterfaceTimeDimension]):
"""A TimeDimension implementation that does nothing."""

@override
def _implements_protocol(self) -> QueryInterfaceTimeDimension:
return self


class WhereFilterTimeDimensionFactory(ProtocolHint[QueryInterfaceTimeDimensionFactory]):
"""Executes in the Jinja sandbox to produce parameter sets and append them to a list."""

@override
def _implements_protocol(self) -> QueryInterfaceTimeDimensionFactory:
return self

def __init__(self): # noqa
def __init__(self) -> None: # noqa
self.time_dimension_call_parameter_sets: List[TimeDimensionCallParameterSet] = []

def create(
Expand Down

0 comments on commit 29eeceb

Please sign in to comment.