Skip to content

Commit a1fb76d

Browse files
committed
DM-48063 : fix typing
1 parent 76a8033 commit a1fb76d

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

src/lsst/cmservice/handlers/jobs.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ async def _write_script(
6868
parent: ElementMixin,
6969
**kwargs: Any,
7070
) -> StatusEnum:
71+
if TYPE_CHECKING:
72+
assert isinstance(parent, Job)
7173
# Database operations
7274
await session.refresh(parent, attribute_names=["c_"])
7375
data_dict = await script.data_dict(session)
@@ -90,7 +92,7 @@ async def _write_script(
9092
# yaml template, NOT the yaml template itself!
9193
workflow_config: dict[str, Any] = {}
9294
workflow_config["project"] = "DEFAULT"
93-
workflow_config["campaign"] = parent.c_.name # type: ignore
95+
workflow_config["campaign"] = parent.c_.name
9496
workflow_config["pipeline_yaml"] = pipeline_yaml
9597
workflow_config["lsst_version"] = lsst_version
9698
workflow_config["lsst_distrib_dir"] = lsst_distrib_dir
@@ -170,7 +172,7 @@ async def _write_script(
170172
in_collection = input_colls
171173

172174
payload = {
173-
"name": parent.c_.name, # type: ignore
175+
"name": parent.c_.name,
174176
"butler_config": butler_repo,
175177
"output_run_collection": run_coll,
176178
"input_collection": in_collection,
@@ -216,7 +218,9 @@ async def _check_slurm_job(
216218
if fake_status is not None:
217219
wms_job_id = "fake_job"
218220
else: # pragma: no cover
219-
bps_dict = await parse_bps_stdout(script.log_url) # type: ignore
221+
if TYPE_CHECKING:
222+
assert script.log_url is not None
223+
bps_dict = await parse_bps_stdout(script.log_url)
220224
wms_job_id = self.get_job_id(bps_dict)
221225
await parent.update_values(session, wms_job_id=wms_job_id)
222226
return slurm_status
@@ -243,7 +247,9 @@ async def _check_htcondor_job(
243247
if fake_status is not None:
244248
wms_job_id = "fake_job"
245249
else: # pragma: no cover
246-
bps_dict = await parse_bps_stdout(script.log_url) # type: ignore
250+
if TYPE_CHECKING:
251+
assert script.log_url is not None
252+
bps_dict = await parse_bps_stdout(script.log_url)
247253
wms_job_id = self.get_job_id(bps_dict)
248254
await parent.update_values(session, wms_job_id=wms_job_id)
249255
return htcondor_status

src/lsst/cmservice/handlers/scripts.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import os
44
import textwrap
5-
from typing import Any
5+
from typing import TYPE_CHECKING, Any
66

77
from anyio import Path
88
from sqlalchemy.ext.asyncio import async_scoped_session
@@ -470,6 +470,8 @@ async def _write_script(
470470
**kwargs: Any,
471471
) -> StatusEnum:
472472
test_type_and_raise(parent, Step, "PrepareStepScriptHandler._write_script parent")
473+
if TYPE_CHECKING:
474+
assert isinstance(parent, Step)
473475

474476
resolved_cols = await script.resolve_collections(session)
475477
data_dict = await script.data_dict(session)
@@ -482,7 +484,7 @@ async def _write_script(
482484

483485
prereq_colls: list[str] = []
484486

485-
all_prereqs = await parent.get_all_prereqs(session) # type: ignore
487+
all_prereqs = await parent.get_all_prereqs(session)
486488
for prereq_step in all_prereqs:
487489
prereq_step_colls = await prereq_step.resolve_collections(session)
488490
prereq_colls.append(prereq_step_colls["step_public_output"])

0 commit comments

Comments
 (0)