Skip to content

Commit f1d27ff

Browse files
DanielNoordPierre-Sassoulas
authored andcommitted
Fix handling of -- as separator of positional arguments and flags
1 parent bf29a55 commit f1d27ff

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

doc/whatsnew/2/2.14/full.rst

+3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ What's New in Pylint 2.14.5?
66
Release date: TBA
77

88

9+
* Fixed handling of ``--`` as separator between positional arguments and flags.
10+
11+
Closes #7003
912

1013
What's New in Pylint 2.14.4?
1114
----------------------------

pylint/config/config_initialization.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ def _config_initialization(
7676
unrecognized_options: list[str] = []
7777
for opt in parsed_args_list:
7878
if opt.startswith("--"):
79-
unrecognized_options.append(opt[2:])
79+
if len(opt) > 2:
80+
unrecognized_options.append(opt[2:])
8081
elif opt.startswith("-"):
8182
unrecognized_options.append(opt[1:])
8283
if unrecognized_options:

tests/config/test_config.py

+10
Original file line numberDiff line numberDiff line change
@@ -116,3 +116,13 @@ def test_short_verbose(capsys: CaptureFixture) -> None:
116116
Run([str(EMPTY_MODULE), "-v"], exit=False)
117117
output = capsys.readouterr()
118118
assert "Using config file" in output.err
119+
120+
121+
def test_argument_separator(capsys: CaptureFixture) -> None:
122+
"""Check that we support using '--' to separate argument types.
123+
124+
Reported in https://github.com/PyCQA/pylint/issues/7003.
125+
"""
126+
Run(["--", str(EMPTY_MODULE)], exit=False)
127+
output = capsys.readouterr()
128+
assert not output.err

0 commit comments

Comments
 (0)