Skip to content

Gracefully handle invalid ‘ignore-paths’ regex crash #9680

@RaulWCosta

Description

@RaulWCosta

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 = 88

Command used

pylint -rn -sn --rcfile=pyproject.toml teste.py

Pylint 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 26

Expected behavior

Pylint should run without exceptions

Pylint version

pylint==3.2.2

OS / Environment

MacOS Sonoma 14.5

Additional dependencies

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Crash 💥A bug that makes pylint crashNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions