Skip to content

Commit f391a92

Browse files
committed
Require paths (would crash with commonpath() arg is an empty sequence otherwise)
1 parent 2eec88b commit f391a92

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
@@ -210,3 +210,10 @@ def test_project_in_subdirectory_that_would_be_ignored(project_dir: ProjectDirT)
210210
main([str(project_root)])
211211
for file in files:
212212
assert file.read_text() == SRC_CHANGED, f"Unexpected result for {file}"
213+
214+
215+
def test_complains_when_no_paths(capsys: pytest.CaptureFixture[str]) -> None:
216+
with pytest.raises(SystemExit) as ei:
217+
main([])
218+
assert ei.value.code == 2
219+
assert "the following arguments are required" in capsys.readouterr().err

0 commit comments

Comments
 (0)