Skip to content

Commit bcce93d

Browse files
committed
mypy
1 parent 8aab09b commit bcce93d

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

cylc/flow/simulation.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class ModeSettings:
5252
]
5353

5454
def __init__(self):
55-
self.simulated_run_length: Optional[float] = None
55+
self.simulated_run_length: float = 0.0
5656
self.sim_task_fails: bool = False
5757

5858
def __repr__(self):
@@ -62,7 +62,7 @@ def __repr__(self):
6262
>>> this = ModeSettings()
6363
>>> print(this)
6464
<flow.simulation.ModeSettings object at ...
65-
simulated_run_length : None
65+
simulated_run_length : 0.0
6666
sim_task_fails : False
6767
"""
6868
repr_ = [super().__repr__()]
@@ -220,21 +220,20 @@ def sim_time_check(
220220
Returns:
221221
True if _any_ simulated task state has changed.
222222
"""
223-
sim_task_state_changed = False
224-
now = time()
223+
sim_task_state_changed: bool = False
224+
now: float = time()
225225
for itask in itasks:
226226
if itask.state.status != TASK_STATUS_RUNNING:
227227
continue
228228
# Started time is not set on restart
229229
if itask.summary['started_time'] is None:
230230
itask.summary['started_time'] = now
231+
started_time = itask.summary['started_time']
232+
if itask.mode_settings is None:
231233
itask.mode_settings = ModeSettings()
232234
itask.mode_settings.update(
233235
itask, broadcast_mgr)
234-
timeout = (
235-
itask.summary['started_time'] +
236-
itask.mode_settings.simulated_run_length
237-
)
236+
timeout = started_time + itask.mode_settings.simulated_run_length
238237
if now > timeout:
239238
job_d = itask.tokens.duplicate(job=str(itask.submit_num))
240239
now_str = get_current_time_string()

cylc/flow/task_proxy.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
if TYPE_CHECKING:
4141
from cylc.flow.id import Tokens
4242
from cylc.flow.cycling import PointBase
43+
from cylc.flow.simulation import ModeSettings
4344
from cylc.flow.task_action_timer import TaskActionTimer
4445
from cylc.flow.taskdef import TaskDef
4546

@@ -259,7 +260,7 @@ def __init__(
259260
else:
260261
self.graph_children = generate_graph_children(tdef, self.point)
261262

262-
self.mode_settings = None
263+
self.mode_settings: Optional['ModeSettings'] = None
263264

264265
def __repr__(self) -> str:
265266
return f"<{self.__class__.__name__} '{self.tokens}'>"

0 commit comments

Comments
 (0)