Skip to content

Commit fed3728

Browse files
committed
Require paths (would crash with commonpath() arg is an empty sequence otherwise)
1 parent 58cff77 commit fed3728

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

auto_walrus.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,7 @@ def _get_config(paths: list[pathlib.Path]) -> dict[str, Any]:
348348

349349
def main(argv: Sequence[str] | None = None) -> int: # pragma: no cover
350350
parser = argparse.ArgumentParser()
351-
parser.add_argument("paths", nargs="*")
351+
parser.add_argument("paths", nargs="+", metavar="path")
352352
parser.add_argument(
353353
"--files",
354354
help="Regex pattern with which to match files to include",

tests/main_test.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,3 +198,10 @@ def test_config_file_missing(project_dir: ProjectDirT) -> None:
198198
main([str(project_root)])
199199
for file in files:
200200
assert file.read_text() == SRC_CHANGED, f"Unexpected result for {file}"
201+
202+
203+
def test_complains_when_no_paths(capsys: pytest.CaptureFixture[str]) -> None:
204+
with pytest.raises(SystemExit) as ei:
205+
main([])
206+
assert ei.value.code == 2
207+
assert "the following arguments are required" in capsys.readouterr().err

0 commit comments

Comments
 (0)