Skip to content

Commit 43ecd7d

Browse files
Fix handling of -- as separator between positional args and flags (#7551)
Co-authored-by: Pierre Sassoulas <[email protected]>
1 parent 66ae21c commit 43ecd7d

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

doc/whatsnew/fragments/7003.bugfix

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Fixed handling of ``--`` as separator between positional arguments and flags.
2+
This was not actually fixed in 2.14.5.
3+
4+
Closes #7003, Refs #7096

pylint/config/config_initialization.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,17 @@ def _config_initialization(
7272
# the configuration file
7373
parsed_args_list = linter._parse_command_line_configuration(args_list)
7474

75+
# Remove the positional arguments separator from the list of arguments if it exists
76+
try:
77+
parsed_args_list.remove("--")
78+
except ValueError:
79+
pass
80+
7581
# Check if there are any options that we do not recognize
7682
unrecognized_options: list[str] = []
7783
for opt in parsed_args_list:
7884
if opt.startswith("--"):
79-
if len(opt) > 2:
80-
unrecognized_options.append(opt[2:])
85+
unrecognized_options.append(opt[2:])
8186
elif opt.startswith("-"):
8287
unrecognized_options.append(opt[1:])
8388
if unrecognized_options:

tests/config/test_config.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,10 @@ def test_short_verbose(capsys: CaptureFixture) -> None:
148148
assert "Using config file" in output.err
149149

150150

151-
def test_argument_separator(capsys: CaptureFixture) -> None:
151+
def test_argument_separator() -> None:
152152
"""Check that we support using '--' to separate argument types.
153153
154154
Reported in https://github.com/PyCQA/pylint/issues/7003.
155155
"""
156-
Run(["--", str(EMPTY_MODULE)], exit=False)
157-
output = capsys.readouterr()
158-
assert not output.err
156+
runner = Run(["--", str(EMPTY_MODULE)], exit=False)
157+
assert not runner.linter.stats.by_msg

0 commit comments

Comments
 (0)