mirror of
https://github.com/NCBM/plyngent.git
synced 2026-07-23 05:55:16 +08:00
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.
This commit is contained in:
@@ -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)."""
|
"""Indent every line of *text* (for multi-line -c bodies in confirm prompts)."""
|
||||||
if not text:
|
if not text:
|
||||||
return prefix
|
return prefix
|
||||||
return "\n".join(
|
return "\n".join(prefix + line if line else prefix.rstrip() for line in text.splitlines())
|
||||||
prefix + line if line else prefix.rstrip() for line in text.splitlines()
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
def _format_argv_for_confirm(argv: Sequence[str], *, code: str | None) -> str:
|
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:
|
if not isinstance(command, list) or not command:
|
||||||
return None
|
return None
|
||||||
argv: list[str] = []
|
argv: list[str] = []
|
||||||
for part in command:
|
for part in cast("list[object]", command):
|
||||||
if not isinstance(part, str):
|
if not isinstance(part, str):
|
||||||
return None
|
return None
|
||||||
argv.append(part)
|
argv.append(part)
|
||||||
|
|||||||
@@ -57,8 +57,9 @@ def _parse_step(raw: object, index: int) -> dict[str, Any]:
|
|||||||
if not isinstance(command, list) or not command:
|
if not isinstance(command, list) or not command:
|
||||||
msg = f"commands[{index}].command must be a non-empty argv list"
|
msg = f"commands[{index}].command must be a non-empty argv list"
|
||||||
raise WorkspaceError(msg)
|
raise WorkspaceError(msg)
|
||||||
argv = [part for part in command if isinstance(part, str)]
|
command_parts = cast("list[object]", command)
|
||||||
if len(argv) != len(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"
|
msg = f"commands[{index}].command must be a list of strings"
|
||||||
raise WorkspaceError(msg)
|
raise WorkspaceError(msg)
|
||||||
cwd = data.get("cwd")
|
cwd = data.get("cwd")
|
||||||
|
|||||||
Reference in New Issue
Block a user