From 992cdc4d1c9924cd50e123cecc368405fb6c240f Mon Sep 17 00:00:00 2001 From: Tim Schwenke Date: Wed, 1 Jan 2025 23:21:03 +0100 Subject: [PATCH] Remove custom validation and just use nargs --- src/filter_pre_commit_hooks.py | 5 +---- tests/test_filter_pre_commit_hooks.py | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/filter_pre_commit_hooks.py b/src/filter_pre_commit_hooks.py index 5e435c6..fe0c70b 100644 --- a/src/filter_pre_commit_hooks.py +++ b/src/filter_pre_commit_hooks.py @@ -78,7 +78,7 @@ parser.add_argument( "filters", type=str, - nargs="*", + nargs="+", help=( "What to filter out, i.e. what should not show up in the resulting " "list. In the `id` mode, these are the hook identifiers themselves to " @@ -95,9 +95,6 @@ mode: Literal["id", "tag"] = args.mode filters: list[str] = args.filters - if not filters: - parser.error("No filters provided.") - with open(args.config) as pre_commit_config: pre_commit_config_content: str = pre_commit_config.read() diff --git a/tests/test_filter_pre_commit_hooks.py b/tests/test_filter_pre_commit_hooks.py index b30f8bc..a7c00bf 100644 --- a/tests/test_filter_pre_commit_hooks.py +++ b/tests/test_filter_pre_commit_hooks.py @@ -32,7 +32,7 @@ def test_filter_empty() -> None: result = run_with() assert result.returncode != 0 - assert "No filters provided." in result.stderr + assert "the following arguments are required: filters" in result.stderr def test_unknown_fail_default() -> None: