Repository navigation
Gracefully handle invalid ‘ignore-paths’ regex crash #9680
Copy link
Copy link
Labels
Crash 💥A bug that makes pylint crashA bug that makes pylint crashNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementation
Milestone
Description
Bug description
Pylint fails with an error when executed on the following snippet:
import itertools
for i, j in enumerate(itertools.repeat(1)):
if i == 10:
break
print(j)Configuration
[tool.pylint.master]
extension-pkg-whitelist = [
'numpy,nose,nose.tools,numpy.testing,pathlib.PurePath,pathlib.PosixPath,pathlib.Path',
]
output-format = ['colorized']
ignore-paths = ['project/tooling_context/**']
[tool.pylint.'MESSAGES CONTROL']
disable = [
'C0412,C1801,duplicate-code,E0402,W0611,W1116,W1203,W1309,fixme,import-error,invalid-name,logging-format-interpolation,missing-docstring,no-else-return,no-member,protected-access,too-few-public-methods,trailing-comma-tuple',
]
[tool.pylint.'DESIGN']
max-args = 10
max-attributes = 14
[tool.pylint.'TYPECHECK']
ignored-modules = ['numpy, numpy.testing, pandas']
ignored-classes = ['numpy, numpy.testing, pandas']
[tool.pylint.'BASIC']
good-names = ['X, x, y']
[tool.pylint.'FORMAT']
max-line-length = 88Command used
pylint -rn -sn --rcfile=pyproject.toml teste.pyPylint output
Traceback (most recent call last):
File "/Users/Raul_Costa/.pyenv/versions/project/bin/pylint", line 8, in <module>
sys.exit(run_pylint())
File "/Users/Raul_Costa/.pyenv/versions/3.10.13/envs/project/lib/python3.10/site-packages/pylint/__init__.py", line 34, in run_pylint
PylintRun(argv or sys.argv[1:])
File "/Users/Raul_Costa/.pyenv/versions/3.10.13/envs/project/lib/python3.10/site-packages/pylint/lint/run.py", line 162, in __init__
args = _config_initialization(
File "/Users/Raul_Costa/.pyenv/versions/3.10.13/envs/project/lib/python3.10/site-packages/pylint/config/config_initialization.py", line 66, in _config_initialization
linter._parse_configuration_file(config_args)
File "/Users/Raul_Costa/.pyenv/versions/3.10.13/envs/project/lib/python3.10/site-packages/pylint/config/arguments_manager.py", line 212, in _parse_configuration_file
self.config, parsed_args = self._arg_parser.parse_known_args(
File "/Users/Raul_Costa/.pyenv/versions/3.10.13/lib/python3.10/argparse.py", line 1866, in parse_known_args
namespace, args = self._parse_known_args(args, namespace)
File "/Users/Raul_Costa/.pyenv/versions/3.10.13/lib/python3.10/argparse.py", line 2079, in _parse_known_args
start_index = consume_optional(start_index)
File "/Users/Raul_Costa/.pyenv/versions/3.10.13/lib/python3.10/argparse.py", line 2019, in consume_optional
take_action(action, args, option_string)
File "/Users/Raul_Costa/.pyenv/versions/3.10.13/lib/python3.10/argparse.py", line 1927, in take_action
argument_values = self._get_values(action, argument_strings)
File "/Users/Raul_Costa/.pyenv/versions/3.10.13/lib/python3.10/argparse.py", line 2462, in _get_values
value = self._get_value(action, arg_string)
File "/Users/Raul_Costa/.pyenv/versions/3.10.13/lib/python3.10/argparse.py", line 2495, in _get_value
result = type_func(arg_string)
File "/Users/Raul_Costa/.pyenv/versions/3.10.13/envs/project/lib/python3.10/site-packages/pylint/config/argument.py", line 127, in _regexp_paths_csv_transfomer
re.compile(
File "/Users/Raul_Costa/.pyenv/versions/3.10.13/lib/python3.10/re.py", line 251, in compile
return _compile(pattern, flags)
File "/Users/Raul_Costa/.pyenv/versions/3.10.13/lib/python3.10/re.py", line 303, in _compile
p = sre_compile.compile(pattern, flags)
File "/Users/Raul_Costa/.pyenv/versions/3.10.13/lib/python3.10/sre_compile.py", line 788, in compile
p = sre_parse.parse(p, flags)
File "/Users/Raul_Costa/.pyenv/versions/3.10.13/lib/python3.10/sre_parse.py", line 955, in parse
p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
File "/Users/Raul_Costa/.pyenv/versions/3.10.13/lib/python3.10/sre_parse.py", line 444, in _parse_sub
itemsappend(_parse(source, state, verbose, nested + 1,
File "/Users/Raul_Costa/.pyenv/versions/3.10.13/lib/python3.10/sre_parse.py", line 672, in _parse
raise source.error("multiple repeat",
re.error: multiple repeat at position 26Expected behavior
Pylint should run without exceptions
Pylint version
pylint==3.2.2OS / Environment
MacOS Sonoma 14.5
Additional dependencies
No response
Metadata
Metadata
Assignees
Labels
Crash 💥A bug that makes pylint crashA bug that makes pylint crashNeeds PRThis issue is accepted, sufficiently specified and now needs an implementationThis issue is accepted, sufficiently specified and now needs an implementation
Activity
Pierre-Sassoulas commentedon May 30, 2024
Thank you for opening the issue. This check created so much crashes since its creation. I would never have anticipated the crazy code constructs that can ends up in an enumerate when reviewing it.
mbyrnepr2 commentedon May 30, 2024
Thank you. It looks like the
**in the regex in the pyproject.toml is at the heart of this. Do we need a code-change @Pierre-Sassoulas, I could be missing something?Pierre-Sassoulas commentedon May 30, 2024
Hmm, you're right, I have triaged too fast, I see an enumerate with a crash and I don't think anymore 😅
mbyrnepr2 commentedon May 30, 2024
Although we could handle the crash gracefully so some change is probably required :)
[-]Linting of code with `itertools.repeat` raises Exception[/-][+]Gracefully handle invalid ‘ignore-paths’ regex crash[/+]Gracefully handle invalid paths csv regex in conf/args
Gracefully handle invalid paths csv regex in conf/args
Gracefully handle invalid paths csv regex in conf/args
Gracefully handle invalid paths csv regex in conf/args
chore(deps): update root dev dependencies (minor) (minor)
Merge branch 'renovate/root-dev-dependencies' into 'main'