Skip to content

Commit 2fa65a9

Browse files
committed
scripts(typing[mcp_swap]): cast claude project node return to fix CI mypy
CI runs ``uv run mypy .`` against the whole tree, picking up ``scripts/mcp_swap.py``. ``_claude_project_node`` returned a value sourced from ``Any`` JSON, and the runtime isinstance guard didn't propagate to the return site, tripping ``no-any-return``. Cast to the documented narrowed shape — the existing guards already establish the invariant.
1 parent 0820805 commit 2fa65a9

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

scripts/mcp_swap.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,11 @@ def _claude_project_node(
286286
if node is None and create:
287287
node = {"allowedTools": [], "mcpContextUris": [], "mcpServers": {}, "env": {}}
288288
projects[key] = node
289-
return node
289+
# ``projects`` came from an ``Any``-typed JSON tree, so ``node`` lands as
290+
# ``Any`` and the isinstance guard above doesn't propagate to the return
291+
# site. Cast to the documented narrowed type — the runtime guards
292+
# establish the invariant.
293+
return t.cast("dict[str, t.Any] | None", node)
290294

291295

292296
def get_server(

0 commit comments

Comments
 (0)