Skip to content

Commit

Permalink
fix: some types
Browse files Browse the repository at this point in the history
  • Loading branch information
arjendev committed Nov 15, 2023
1 parent 920f272 commit 8f41d28
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
from typing import Any, Generic, TypeVar
from typing import Union

from data_factory_testing_framework.functions.function_parser import parse_expression
from data_factory_testing_framework.generated.models import DataFactoryElement
from data_factory_testing_framework.models.state.run_state import RunState

T = TypeVar("T")

class DataFactoryElement():
def __init__(self) -> None:
"""DataFactoryElement."""
self.value: Union[str, int, bool] = None

class DataFactoryElement(Generic[T]):
def evaluate(self: DataFactoryElement, state: Any) -> None: # noqa: ANN401
def evaluate(self: DataFactoryElement, state: RunState) -> None:
self.value = parse_expression(self.expression).evaluate(state)
return self.value
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
from typing import TypeVar, Any
from typing import Union

from data_factory_testing_framework.functions.function_parser import parse_expression
from data_factory_testing_framework.generated.models import Expression
from data_factory_testing_framework.models.state.pipeline_run_state import PipelineRunState

TResult = TypeVar("TResult")


class Expression:
def __init__(self) -> None:
"""Expression."""
self.evaluated: Any = None
self.evaluated: Union[str, int, bool] = None

def evaluate(self: Expression, state: PipelineRunState) -> TResult:
def evaluate(self: Expression, state: PipelineRunState) -> Union[str, int, bool]:
"""Evaluates the expression by replacing all parameters and variables with their values and then evaluating the expression.
Args:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def validate_parameters(self: PipelineResource, parameters: List[RunParameter])
parameters: List of parameters.
"""
# Check if all parameters are provided
for pipeline_parameter_name, pipeline_parameter_specification in self.parameters.items():
for pipeline_parameter_name, _ in self.parameters.items():
found = False
for parameter in parameters:
if pipeline_parameter_name == parameter.name and parameter.type == RunParameterType.Pipeline:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, Dict, List, Optional
from typing import Any, Dict, List, Optional, Union

from data_factory_testing_framework.exceptions.variable_being_evaluated_does_not_exist_error import (
VariableBeingEvaluatedDoesNotExistError,
Expand Down Expand Up @@ -95,7 +95,7 @@ def try_get_scoped_activity_result_by_name(self, name: str) -> Optional[Dict[str
"""
return self.pipeline_activity_results[name] if name in self.pipeline_activity_results else None

def set_variable(self, variable_name: str, value: Any) -> None: # noqa: ANN401
def set_variable(self, variable_name: str, value: Union[str, int, bool]) -> None:
"""Sets the value of a variable if it exists. Otherwise throws an exception.
Args:
Expand Down

0 comments on commit 8f41d28

Please sign in to comment.