From 29eeceb36be01377c0e698975b80a0b35b1fb6a8 Mon Sep 17 00:00:00 2001 From: Devon Fulcher Date: Mon, 18 Sep 2023 11:11:18 -0500 Subject: [PATCH] fixed formatting & linting --- .../implementations/filters/where_filter.py | 4 +++- .../where_filter/parameter_set_factory.py | 13 +++++++++++-- .../where_filter/where_filter_dimension.py | 14 ++++++-------- .../parsing/where_filter/where_filter_entity.py | 13 ++++++++++--- .../parsing/where_filter/where_filter_parser.py | 17 ++++++++++++----- .../where_filter/where_filter_time_dimension.py | 15 ++++++++++----- 6 files changed, 52 insertions(+), 24 deletions(-) diff --git a/dbt_semantic_interfaces/implementations/filters/where_filter.py b/dbt_semantic_interfaces/implementations/filters/where_filter.py index b8fd7bc3..437d7f78 100644 --- a/dbt_semantic_interfaces/implementations/filters/where_filter.py +++ b/dbt_semantic_interfaces/implementations/filters/where_filter.py @@ -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): diff --git a/dbt_semantic_interfaces/parsing/where_filter/parameter_set_factory.py b/dbt_semantic_interfaces/parsing/where_filter/parameter_set_factory.py index 950c2f0a..eebe5258 100644 --- a/dbt_semantic_interfaces/parsing/where_filter/parameter_set_factory.py +++ b/dbt_semantic_interfaces/parsing/where_filter/parameter_set_factory.py @@ -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 ( diff --git a/dbt_semantic_interfaces/parsing/where_filter/where_filter_dimension.py b/dbt_semantic_interfaces/parsing/where_filter/where_filter_dimension.py index 956c6cf7..feed320f 100644 --- a/dbt_semantic_interfaces/parsing/where_filter/where_filter_dimension.py +++ b/dbt_semantic_interfaces/parsing/where_filter/where_filter_dimension.py @@ -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 @@ -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 @@ -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 diff --git a/dbt_semantic_interfaces/parsing/where_filter/where_filter_entity.py b/dbt_semantic_interfaces/parsing/where_filter/where_filter_entity.py index 2075d2e6..ee747561 100644 --- a/dbt_semantic_interfaces/parsing/where_filter/where_filter_entity.py +++ b/dbt_semantic_interfaces/parsing/where_filter/where_filter_entity.py @@ -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: diff --git a/dbt_semantic_interfaces/parsing/where_filter/where_filter_parser.py b/dbt_semantic_interfaces/parsing/where_filter/where_filter_parser.py index 0d0bb717..aa069cc2 100644 --- a/dbt_semantic_interfaces/parsing/where_filter/where_filter_parser.py +++ b/dbt_semantic_interfaces/parsing/where_filter/where_filter_parser.py @@ -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 @@ -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: diff --git a/dbt_semantic_interfaces/parsing/where_filter/where_filter_time_dimension.py b/dbt_semantic_interfaces/parsing/where_filter/where_filter_time_dimension.py index 971a5740..979a0665 100644 --- a/dbt_semantic_interfaces/parsing/where_filter/where_filter_time_dimension.py +++ b/dbt_semantic_interfaces/parsing/where_filter/where_filter_time_dimension.py @@ -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(