Skip to content

Commit

Permalink
chore: replace list type by Iterable for nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulFarault committed Nov 13, 2023
1 parent 880735b commit 62ad7fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions tdp/core/dag.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ def priority_key(node: str) -> str:

def topological_sort(
self,
nodes: Optional[list[str]] = None,
nodes: Optional[Iterable[str]] = None,
restart: bool = False,
stop: bool = False,
) -> list[Operation]:
Expand All @@ -254,8 +254,8 @@ def topological_sort(

def get_operations(
self,
sources: Optional[list[str]] = None,
targets: Optional[list[str]] = None,
sources: Optional[Iterable[str]] = None,
targets: Optional[Iterable[str]] = None,
restart: bool = False,
stop: bool = False,
) -> list[Operation]:
Expand All @@ -268,7 +268,7 @@ def get_operations(
return self.get_all_operations(restart=restart, stop=stop)

def get_operations_to_nodes(
self, nodes: list[str], restart: bool = False, stop: bool = False
self, nodes: Iterable[str], restart: bool = False, stop: bool = False
) -> list[Operation]:
nodes_set = set(nodes)
for node in nodes:
Expand All @@ -278,7 +278,7 @@ def get_operations_to_nodes(
return self.topological_sort(nodes_set, restart=restart, stop=stop)

def get_operations_from_nodes(
self, nodes: list[str], restart: bool = False, stop: bool = False
self, nodes: Iterable[str], restart: bool = False, stop: bool = False
) -> list[Operation]:
nodes_set = set(nodes)
for node in nodes:
Expand Down Expand Up @@ -335,12 +335,12 @@ def get_operation_descendants(
)

def filter_operations_glob(
self, operations: list[Operation], glob: str
self, operations: Iterable[Operation], glob: str
) -> list[Operation]:
return list(filter(lambda o: fnmatch.fnmatch(o.name, glob), operations)) # type: ignore

def filter_operations_regex(
self, operations: list[Operation], regex: str
self, operations: Iterable[Operation], regex: str
) -> list[Operation]:
compiled_regex = re.compile(regex)
return list(filter(lambda o: compiled_regex.match(o.name), operations)) # type: ignore
Expand Down
4 changes: 2 additions & 2 deletions tdp/core/models/deployment_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ def __str__(self):
@staticmethod
def from_dag(
dag: Dag,
targets: Optional[list[str]] = None,
sources: Optional[list[str]] = None,
targets: Optional[Iterable[str]] = None,
sources: Optional[Iterable[str]] = None,
filter_expression: Optional[str] = None,
filter_type: Optional[FilterTypeEnum] = None,
restart: bool = False,
Expand Down

0 comments on commit 62ad7fc

Please sign in to comment.