Skip to content

Commit 6ac8ff5

Browse files
committed
cast for mypy
1 parent 421bacf commit 6ac8ff5

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

diracx-cli/src/diracx/cli/internal/legacy.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,16 @@
33
import json
44
import os
55
from pathlib import Path
6-
from typing import cast
6+
from typing import TYPE_CHECKING, cast
77
from urllib.parse import urljoin, urlparse
88

99
import diraccfg
1010
import typer
1111
import yaml
12+
13+
if TYPE_CHECKING:
14+
from diraccfg.cfg import CFGAsDict
15+
1216
from pydantic import BaseModel
1317
from typer import Option
1418

@@ -59,12 +63,14 @@ def cs_sync(old_file: Path, new_file: Path):
5963
cfg = diraccfg.CFG().loadFromBuffer(old_data)
6064
raw = cfg.getAsDict()
6165

62-
diracx_section = raw["DiracX"]
66+
diracx_section = cast("CFGAsDict", raw["DiracX"])
6367
# DisabledVOs cannot be set if any Legacy clients are enabled
6468
disabled_vos = diracx_section.get("DisabledVOs")
6569
enabled_clients = []
66-
for _, client_status in diracx_section.get("LegacyClientEnabled", {}).items():
67-
for _, str_status in client_status.items():
70+
for _, client_status in cast(
71+
"CFGAsDict", diracx_section.get("LegacyClientEnabled", {})
72+
).items():
73+
for _, str_status in cast("CFGAsDict", client_status).items():
6874
enabled_clients.append(str_status == "True")
6975
if disabled_vos and any(enabled_clients):
7076
raise RuntimeError(

0 commit comments

Comments
 (0)