PyCQA/pylint
The issue has been closed
Pylint crashing: AstroidError -- RecursionError in node_classes because of scipy #7543
hongha912 posted onGitHub
Bug description
pylint crashes while running on a file with a recursion error thrown by astroid in node_classes.py
.
Configuration
[MASTER]
load-plugins= pylint_quotes
string-quote=single-avoid-escape
triple-quote=double
docstring-quote=double
[REPORTS]
reports = no
[MESSAGES CONTROL]
disable=
C, # convention
R, # refactor
W, # warning
no-member,
invalid-unary-operand-type,
unpacking-non-sequence
enable=
anomalous-backslash-in-string,
bad-format-string,
bad-open-mode,
binary-op-exception,
consider-using-dict-comprehension,
consider-using-in,
consider-using-set-comprehension,
duplicate-key,
global-variable-not-assigned,
inconsistent-return-statements,
line-too-long,
no-default-true,
string_quotes,
too-many-arguments,
undefined-loop-variable,
ungrouped-imports,
unnecessary-semicolon,
unreachable,
unused-import,
unused-variable,
useless-return,
wildcard-import,
wrong-import-order
extension-pkg-whitelist=
numpy,
scipy.spatial,
Command used
pylint <file_path.py>
Content
from scipy import spatial
Pylint output
pylint crashed with a ``AstroidError`` and with the following stacktrace:
Traceback (most recent call last):
File "<venv folder>/lib/python3.8/site-packages/pylint/checkers/imports.py", line 798, in _get_imported_module
return importnode.do_import_module(modname)
File "<venv folder>/lib/python3.8/site-packages/astroid/nodes/_base_nodes.py", line 148, in do_import_module
return mymodule.import_module(
File "<venv folder>/lib/python3.8/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 521, in import_module
return AstroidManager().ast_from_module_name(absmodname)
File "<venv folder>/lib/python3.8/site-packages/astroid/manager.py", line 209, in ast_from_module_name
return self.ast_from_file(found_spec.location, modname, fallback=False)
File "<venv folder>/lib/python3.8/site-packages/astroid/manager.py", line 118, in ast_from_file
return AstroidBuilder(self).file_build(filepath, modname)
File "<venv folder>/lib/python3.8/site-packages/astroid/builder.py", line 135, in file_build
return self._post_build(module, builder, encoding)
File "<venv folder>/lib/python3.8/site-packages/astroid/builder.py", line 154, in _post_build
self.add_from_names_to_locals(from_node)
File "<venv folder>/lib/python3.8/site-packages/astroid/builder.py", line 210, in add_from_names_to_locals
imported = node.do_import_module()
File "<venv folder>/lib/python3.8/site-packages/astroid/nodes/_base_nodes.py", line 148, in do_import_module
return mymodule.import_module(
File "<venv folder>/lib/python3.8/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 521, in import_module
return AstroidManager().ast_from_module_name(absmodname)
File "<venv folder>/lib/python3.8/site-packages/astroid/manager.py", line 184, in ast_from_module_name
return self.ast_from_module(module, modname)
File "<venv folder>/lib/python3.8/site-packages/astroid/manager.py", line 286, in ast_from_module
return AstroidBuilder(self).module_build(module, modname)
File "<venv folder>/lib/python3.8/site-packages/astroid/builder.py", line 92, in module_build
node = self.inspect_build(module, modname=modname, path=path)
File "<venv folder>/lib/python3.8/site-packages/astroid/raw_building.py", line 373, in inspect_build
self.object_build(node, module)
File "<venv folder>/lib/python3.8/site-packages/astroid/raw_building.py", line 433, in object_build
self.object_build(module, member)
File "<venv folder>/lib/python3.8/site-packages/astroid/raw_building.py", line 433, in object_build
self.object_build(module, member)
File "<venv folder>/lib/python3.8/site-packages/astroid/raw_building.py", line 433, in object_build
self.object_build(module, member)
[Previous line repeated 1 more time]
File "<venv folder>/lib/python3.8/site-packages/astroid/raw_building.py", line 424, in object_build
attach_const_node(node, name, member)
File "<venv folder>/lib/python3.8/site-packages/astroid/raw_building.py", line 82, in attach_const_node
_attach_local_node(node, nodes.const_factory(value), name)
File "<venv folder>/lib/python3.8/site-packages/astroid/nodes/node_classes.py", line 5413, in const_factory
instance.postinit(_create_dict_items(value, instance))
File "<venv folder>/lib/python3.8/site-packages/astroid/nodes/node_classes.py", line 5387, in _create_dict_items
value_node = const_factory(value)
File "<venv folder>/lib/python3.8/site-packages/astroid/nodes/node_classes.py", line 5413, in const_factory
instance.postinit(_create_dict_items(value, instance))
File "<venv folder>/lib/python3.8/site-packages/astroid/nodes/node_classes.py", line 5387, in _create_dict_items
value_node = const_factory(value)
File "<venv folder>/lib/python3.8/site-packages/astroid/nodes/node_classes.py", line 5413, in const_factory
instance.postinit(_create_dict_items(value, instance))
File "<venv folder>/lib/python3.8/site-packages/astroid/nodes/node_classes.py", line 5387, in _create_dict_items
value_node = const_factory(value)
File "<venv folder>/lib/python3.8/site-packages/astroid/nodes/node_classes.py", line 5413, in const_factory
instance.postinit(_create_dict_items(value, instance))
File "<venv folder>/lib/python3.8/site-packages/astroid/nodes/node_classes.py", line 5387, in _create_dict_items
value_node = const_factory(value)
File "<venv folder>/lib/python3.8/site-packages/astroid/nodes/node_classes.py", line 5413, in const_factory
instance.postinit(_create_dict_items(value, instance))
File "<venv folder>/lib/python3.8/site-packages/astroid/nodes/node_classes.py", line 5387, in _create_dict_items
value_node = const_factory(value)
File "<venv folder>/lib/python3.8/site-packages/astroid/nodes/node_classes.py", line 5413, in const_factory
instance.postinit(_create_dict_items(value, instance))
File "<venv folder>/lib/python3.8/site-packages/astroid/nodes/node_classes.py", line 5387, in _create_dict_items
value_node = const_factory(value)
File "<venv folder>/lib/python3.8/site-packages/astroid/nodes/node_classes.py", line 5413, in const_factory
instance.postinit(_create_dict_items(value, instance))
(continue like this)
This continues -- tail end of the stack trace:
File "<venv folder>/lib/python3.8/site-packages/astroid/nodes/node_classes.py", line 5413, in const_factory
instance.postinit(_create_dict_items(value, instance))
File "<venv folder>/lib/python3.8/site-packages/astroid/nodes/node_classes.py", line 5385, in _create_dict_items
key_node = const_factory(key)
File "<venv folder>/lib/python3.8/site-packages/astroid/nodes/node_classes.py", line 5407, in const_factory
if issubclass(initializer_cls, (List, Set, Tuple)):
File "/usr/local/google/home/hongvu/.pyenv/versions/3.8.12/lib/python3.8/abc.py", line 102, in __subclasscheck__
return _abc_subclasscheck(cls, subclass)
RecursionError: maximum recursion depth exceeded in comparison
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<venv folder>/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 782, in _lint_file
check_astroid_module(module)
File "<venv folder>/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1049, in check_astroid_module
retval = self._check_astroid_module(
File "<venv folder>/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 1099, in _check_astroid_module
walker.walk(node)
File "<venv folder>/lib/python3.8/site-packages/pylint/utils/ast_walker.py", line 93, in walk
self.walk(child)
File "<venv folder>/lib/python3.8/site-packages/pylint/utils/ast_walker.py", line 90, in walk
callback(astroid)
File "<venv folder>/lib/python3.8/site-packages/pylint/checkers/imports.py", line 502, in visit_importfrom
imported_module = self._get_imported_module(node, basename)
File "<venv folder>/lib/python3.8/site-packages/pylint/checkers/imports.py", line 823, in _get_imported_module
raise astroid.AstroidError from e
astroid.exceptions.AstroidError
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "<venv folder>/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 747, in _lint_files
self._lint_file(fileitem, module, check_astroid_module)
File "<venv folder>/lib/python3.8/site-packages/pylint/lint/pylinter.py", line 784, in _lint_file
raise astroid.AstroidError from e
astroid.exceptions.AstroidError
Expected behavior
Pylint should not crash.
Pylint version
pylint 2.15.3
astroid 2.12.10
Python 3.8.12 (default, Mar 14 2022, 20:18:12)
[GCC 11.2.0]
OS / Environment
Debian 5
Additional dependencies
scipy==1.4.1