Skip to content

Commit

Permalink
Solved some parameters and variables type errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
mla2001 committed Oct 3, 2024
1 parent a17cd44 commit 3a13015
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/vtlengine/API/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ class takes all of this information and checks it with the ast generated to

def run(script: Union[str, Path], data_structures: Union[dict, Path, List[Union[dict, Path]]],
datapoints: Union[dict, str, Path, List[Union[str, Path]]],
value_domains: Union[dict, Path] = None, external_routines: Union[str, Path] = None,
value_domains: Optional[Union[dict, Path]] = None, external_routines: Optional[Union[str, Path]] = None,
time_period_output_format: str = "vtl",
return_only_persistent=False,
output_folder: Optional[Union[str, Path]] = None):
output_folder: Optional[Union[str, Path]] = None) -> Any:
"""
Run is the main function of the ``API``, which mission is to ensure the vtl operation is ready
to be performed.
Expand Down
3 changes: 2 additions & 1 deletion src/vtlengine/AST/ASTVisitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
-----------
Node Dispatcher.
"""
from typing import Any


class NodeVisitor(object):
"""
"""

def visit(self, node):
def visit(self, node: Any):
"""
"""
Expand Down
24 changes: 12 additions & 12 deletions src/vtlengine/Interpreter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,9 @@ class InterpreterAnalyzer(ASTTemplate):
hr_partial_is_valid: Optional[List[bool]] = None
hr_condition: Optional[Dict[str, str]] = None
# DL
dprs: Dict[str, Dict[str, Any]] = None
udos: Dict[str, Dict[str, Any]] = None
hrs: Dict[str, Dict[str, Any]] = None
dprs: Dict[str, Optional[Dict[str, Any]]] = None
udos: Dict[str, Optional[Dict[str, Any]]] = None
hrs: Dict[str, Optional[Dict[str, Any]]] = None

# **********************************
# * *
Expand Down Expand Up @@ -1101,10 +1101,11 @@ def visit_DPRule(self, node: AST.DPRule) -> None:

def visit_HRule(self, node: AST.HRule) -> None:
self.is_from_rule = True
if self.ruleset_dataset.data is None:
self.rule_data = None
else:
self.rule_data = self.ruleset_dataset.data.copy()
if self.ruleset_dataset is not None:
if self.ruleset_dataset.data is None:
self.rule_data = None
else:
self.rule_data = self.ruleset_dataset.data.copy()
rule_result = self.visit(node.rule)
if rule_result is None:
self.is_from_rule = False
Expand Down Expand Up @@ -1305,10 +1306,9 @@ def generate_then_else_datasets(self, condition):
self.then_condition_dataset.append(then_dataset)
self.else_condition_dataset.append(else_dataset)

def merge_then_else_datasets(self, left_operand: Dataset | DataComponent, right_operand):
def merge_then_else_datasets(self, left_operand: Any, right_operand: Any) -> Any:
merge_dataset = self.then_condition_dataset.pop() if self.if_stack.pop() == THEN_ELSE[
'then'] else (
self.else_condition_dataset.pop())
'then'] else (self.else_condition_dataset.pop())
merge_index = merge_dataset.data[merge_dataset.get_measures_names()[0]].to_list()
ids = merge_dataset.get_identifiers_names()
if isinstance(left_operand, Dataset | DataComponent):
Expand Down Expand Up @@ -1338,7 +1338,7 @@ def merge_then_else_datasets(self, left_operand: Dataset | DataComponent, right_
right_operand.data = right.reindex(merge_index, fill_value=None)
return left_operand, right_operand

def visit_Identifier(self, node: AST.Identifier) -> AST.AST:
def visit_Identifier(self, node: AST.Identifier) -> Union[AST.AST, Dataset]:
"""
Identifier: (value)
Expand All @@ -1356,7 +1356,7 @@ def visit_Identifier(self, node: AST.Identifier) -> AST.AST:
return self.datasets[node.value]
return node.value

def visit_DefIdentifier(self, node: AST.DefIdentifier) -> AST.AST:
def visit_DefIdentifier(self, node: AST.DefIdentifier) -> Union[AST.AST, Dataset]:
"""
DefIdentifier: (value, kind)
Expand Down
13 changes: 7 additions & 6 deletions src/vtlengine/Operators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from vtlengine.Model import Component, Dataset, Role, Scalar, DataComponent, ScalarSet

ALL_MODEL_DATA_TYPES = Union[Dataset, Scalar, DataComponent]
ALL_DATA_TYPES = Union[ScalarType, Dataset, DataComponent, Scalar, ScalarSet]

# This allows changing the data type of the Measure in the result Data Set
# when the operator is applied to mono-measure Data Sets.
Expand All @@ -31,14 +32,14 @@

class Operator:
"""Superclass for all operators"""
op = None
py_op = None
spark_op = None
type_to_check = None
return_type = None
op: str = None
py_op: str = None
spark_op: str = None
type_to_check: ScalarType = None
return_type: ScalarType = None

@classmethod
def analyze(cls, *args, **kwargs):
def analyze(cls, *args: Any, **kwargs: Any):
if only_semantic:
return cls.validate(*args, **kwargs)
return cls.evaluate(*args, **kwargs)
Expand Down

0 comments on commit 3a13015

Please sign in to comment.