Skip to content

Commit cbb6eed

Browse files
committed
Fix handling of -- as separator of positional arguments and flags
1 parent e876f04 commit cbb6eed

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

doc/whatsnew/2/2.14/full.rst

Lines changed: 3 additions & 0 deletions
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

Lines changed: 2 additions & 1 deletion
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

Lines changed: 10 additions & 0 deletions
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)