From 182546d60e8b0894d76ed24fb6e8cf941c8094da Mon Sep 17 00:00:00 2001 From: worldmozara Date: Sun, 19 Jul 2026 20:39:16 +0800 Subject: [PATCH] core/tools: narrow list[object] for batch command argv typing basedpyright treated bare list elements as Unknown after isinstance(list); cast to list[object] so prek basedpyright exits clean. --- src/plyngent/tools/danger.py | 6 ++---- src/plyngent/tools/process/run_command_batch.py | 5 +++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/plyngent/tools/danger.py b/src/plyngent/tools/danger.py index 3f5bd7d..b3abdfd 100644 --- a/src/plyngent/tools/danger.py +++ b/src/plyngent/tools/danger.py @@ -84,9 +84,7 @@ def _indent_block(text: str, *, prefix: str = " ") -> str: """Indent every line of *text* (for multi-line -c bodies in confirm prompts).""" if not text: return prefix - return "\n".join( - prefix + line if line else prefix.rstrip() for line in text.splitlines() - ) + return "\n".join(prefix + line if line else prefix.rstrip() for line in text.splitlines()) def _format_argv_for_confirm(argv: Sequence[str], *, code: str | None) -> str: @@ -198,7 +196,7 @@ def _batch_step_argv(item: object) -> list[str] | None: if not isinstance(command, list) or not command: return None argv: list[str] = [] - for part in command: + for part in cast("list[object]", command): if not isinstance(part, str): return None argv.append(part) diff --git a/src/plyngent/tools/process/run_command_batch.py b/src/plyngent/tools/process/run_command_batch.py index 8585594..e3553ae 100644 --- a/src/plyngent/tools/process/run_command_batch.py +++ b/src/plyngent/tools/process/run_command_batch.py @@ -57,8 +57,9 @@ def _parse_step(raw: object, index: int) -> dict[str, Any]: if not isinstance(command, list) or not command: msg = f"commands[{index}].command must be a non-empty argv list" raise WorkspaceError(msg) - argv = [part for part in command if isinstance(part, str)] - if len(argv) != len(command): + command_parts = cast("list[object]", command) + argv = [part for part in command_parts if isinstance(part, str)] + if len(argv) != len(command_parts): msg = f"commands[{index}].command must be a list of strings" raise WorkspaceError(msg) cwd = data.get("cwd")