Skip to content

Commit 734001d

Browse files
committed
fix(types): update level_dag.py to correct pylance typings
1 parent 284ddc9 commit 734001d

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

CodeEntropy/levels/level_dag.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
from typing import Any
2121

2222
import networkx as nx
23+
from rich.progress import TaskID
2324

2425
from CodeEntropy.levels.axes import AxesCalculator
2526
from CodeEntropy.levels.frame_dag import FrameGraph
@@ -29,6 +30,7 @@
2930
from CodeEntropy.levels.nodes.detect_levels import DetectLevelsNode
3031
from CodeEntropy.levels.nodes.detect_molecules import DetectMoleculesNode
3132
from CodeEntropy.levels.nodes.find_neighbors import ComputeNeighborsNode
33+
from CodeEntropy.results.reporter import _RichProgressSink
3234

3335
logger = logging.getLogger(__name__)
3436

@@ -90,7 +92,7 @@ def build(self) -> LevelDAG:
9092
return self
9193

9294
def execute(
93-
self, shared_data: dict[str, Any], *, progress: object | None = None
95+
self, shared_data: dict[str, Any], *, progress: _RichProgressSink | None = None
9496
) -> dict[str, Any]:
9597
"""Execute the full hierarchy workflow and mutate shared_data.
9698
@@ -113,7 +115,7 @@ def execute(
113115
return shared_data
114116

115117
def _run_static_stage(
116-
self, shared_data: dict[str, Any], *, progress: object | None = None
118+
self, shared_data: dict[str, Any], *, progress: _RichProgressSink | None = None
117119
) -> None:
118120
"""Run all static nodes in dependency order.
119121
@@ -151,7 +153,7 @@ def _add_static(self, name: str, node: Any, deps: list[str] | None = None) -> No
151153
self._static_graph.add_edge(dep, name)
152154

153155
def _run_frame_stage(
154-
self, shared_data: dict[str, Any], *, progress: object | None = None
156+
self, shared_data: dict[str, Any], *, progress: _RichProgressSink | None = None
155157
) -> None:
156158
"""Execute the per-frame DAG stage and reduce frame outputs.
157159
@@ -180,8 +182,8 @@ def _run_frame_stage(
180182
u = shared_data["reduced_universe"]
181183
start, end, step = shared_data["start"], shared_data["end"], shared_data["step"]
182184

183-
task = None
184-
total_frames = None
185+
task: TaskID | None = None
186+
total_frames: int | None = None
185187

186188
if progress is not None:
187189
try:
@@ -209,13 +211,13 @@ def _run_frame_stage(
209211
)
210212

211213
for ts in u.trajectory[start:end:step]:
212-
if task is not None:
214+
if progress is not None and task is not None:
213215
progress.update(task, title=f"Frame {ts.frame}")
214216

215217
frame_out = self._frame_dag.execute_frame(shared_data, ts.frame)
216218
self._reduce_one_frame(shared_data, frame_out)
217219

218-
if task is not None:
220+
if progress is not None and task is not None:
219221
progress.advance(task)
220222

221223
@staticmethod

0 commit comments

Comments
 (0)