Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/loopzero/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def _build(data: dict[str, Any]) -> Config:
)
review[family] = ReviewConfig(table.get("model"), table.get("effort"), allowed)

commands = _strings("checks.commands", checks.get("commands", []))
commands = _commands(checks.get("commands", []))
kwargs: dict[str, Any] = {}
if "runner" in checks:
runner = _strings("checks.runner", checks["runner"])
Expand Down Expand Up @@ -272,6 +272,13 @@ def _reject_unknown(where: str, table: dict[str, Any], allowed: Any) -> None:
raise ConfigError(f"unknown key(s) in {where}: {', '.join(unknown)}")


def _commands(value: list[Any]) -> tuple[str, ...]:
commands = _strings("checks.commands", value)
if any(not command.strip() for command in commands):
raise ConfigError("checks.commands entries must each be a nonblank command")
return commands


def _strings(label: str, value: list[Any]) -> tuple[str, ...]:
if not isinstance(value, list) or not all(isinstance(item, str) and item for item in value):
raise ConfigError(f"{label} must be a list of non-empty strings")
Expand Down
5 changes: 5 additions & 0 deletions tests/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ def test_load_full_config(tmp_path):
limits=ResourceLimits(memory_mb=1024, file_mb=512),
)

padded = FULL.replace('"uv run pytest -q"', '" uv run pytest -q "')
assert config.load(write(tmp_path, padded)).checks[0] == " uv run pytest -q "


def test_load_applies_defaults(tmp_path):
loaded = config.load(write(tmp_path, '[repo]\nname = "o/n"\n'))
Expand Down Expand Up @@ -112,6 +115,8 @@ def test_invalid_toml(tmp_path):
('[repo]\nname = 3\n', "repo.name must be a str"),
('[repo]\nname = "o/n"\n[checks]\ncommands = "pytest"\n', "checks.commands must be a list"),
('[repo]\nname = "o/n"\n[checks]\ncommands = ["ok", 1]\n', "non-empty strings"),
('[repo]\nname = "o/n"\n[checks]\ncommands = ["true", " "]\n',
r"workflow\.toml: checks\.commands.*nonblank command"),
('[repo]\nname = "o/n"\n[checks]\nnetwork = "yes"\n', "checks.network must be a bool"),
('[repo]\nname = "o/n"\n[delivery]\nmerge = "ff"\n', "delivery.merge must be one of"),
('[repo]\nname = "o/n"\n[delivery]\nreviewers = ["gpt"]\n', "delivery.reviewers entries"),
Expand Down
Loading