diff --git a/numpydoc/cli.py b/numpydoc/cli.py index ef8cff2c..37a9ab6b 100644 --- a/numpydoc/cli.py +++ b/numpydoc/cli.py @@ -2,6 +2,7 @@ import argparse import ast +import re from collections.abc import Sequence from pathlib import Path from typing import List, Union @@ -100,8 +101,6 @@ def _parse_config(s): ) lint_parser.add_argument( "--ignore", - type=str, - nargs="*", help=( f"""Check codes to ignore.{ ' Currently ignoring the following from ' @@ -110,6 +109,7 @@ def _parse_config(s): if ignored_checks else '' }""" ), + action="append", ) lint_parser.set_defaults(func=validate_docstrings.run_hook) @@ -122,6 +122,13 @@ def main(argv: Union[Sequence[str], None] = None) -> int: args = vars(ap.parse_args(argv)) + # Parse --ignored=SA01,EX01 + ignored_checks = [] + if args.get("ignore", None) is not None: + for checks in args["ignore"]: + ignored_checks += re.split("\\W+", checks) + args["ignore"] = ignored_checks + try: func = args.pop("func") return func(**args) diff --git a/numpydoc/tests/test_main.py b/numpydoc/tests/test_main.py index 12c06840..f42e3964 100644 --- a/numpydoc/tests/test_main.py +++ b/numpydoc/tests/test_main.py @@ -117,7 +117,10 @@ def test_validate_perfect_docstring(): assert exit_status == 0 -@pytest.mark.parametrize("args", [[], ["--ignore", "ES01", "SA01", "EX01"]]) +@pytest.mark.parametrize( + "args", + [[], ["--ignore", "ES01,SA01,EX01"], ["--ignore", "ES01", "--ignore", "SA01 EX01"]], +) def test_lint(capsys, args): argv = ["lint", "numpydoc/__main__.py"] + args if args: