Skip to content

Commit

Permalink
Fix handling of -- as separator of positional arguments and flags
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielNoord authored and Pierre-Sassoulas committed Jul 17, 2022
1 parent bf29a55 commit f1d27ff
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions doc/whatsnew/2/2.14/full.rst
Expand Up @@ -6,6 +6,9 @@ What's New in Pylint 2.14.5?
Release date: TBA


* Fixed handling of ``--`` as separator between positional arguments and flags.

Closes #7003

What's New in Pylint 2.14.4?
----------------------------
Expand Down
3 changes: 2 additions & 1 deletion pylint/config/config_initialization.py
Expand Up @@ -76,7 +76,8 @@ def _config_initialization(
unrecognized_options: list[str] = []
for opt in parsed_args_list:
if opt.startswith("--"):
unrecognized_options.append(opt[2:])
if len(opt) > 2:
unrecognized_options.append(opt[2:])
elif opt.startswith("-"):
unrecognized_options.append(opt[1:])
if unrecognized_options:
Expand Down
10 changes: 10 additions & 0 deletions tests/config/test_config.py
Expand Up @@ -116,3 +116,13 @@ def test_short_verbose(capsys: CaptureFixture) -> None:
Run([str(EMPTY_MODULE), "-v"], exit=False)
output = capsys.readouterr()
assert "Using config file" in output.err


def test_argument_separator(capsys: CaptureFixture) -> None:
"""Check that we support using '--' to separate argument types.
Reported in https://github.com/PyCQA/pylint/issues/7003.
"""
Run(["--", str(EMPTY_MODULE)], exit=False)
output = capsys.readouterr()
assert not output.err

0 comments on commit f1d27ff

Please sign in to comment.