-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Open
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
Description
Bug description
When parsing the following example.py
:
import mypy.build
Configuration
Command used
pylint --extension-pkg-allow-list=mypy example.py
Pylint output
pylint crashed with a ``AstroidError`` and with the following stacktrace:
Traceback (most recent call last):
File "/home/sbrunner/.pyenv/versions/3.11.9/lib/python3.11/site-packages/pylint/checkers/imports.py", line 1014, in _get_imported_module
return importnode.do_import_module(modname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/sbrunner/.pyenv/versions/3.11.9/lib/python3.11/site-packages/astroid/nodes/_base_nodes.py", line 168, in do_import_module
return mymodule.import_module(
^^^^^^^^^^^^^^^^^^^^^^^
File "/home/sbrunner/.pyenv/versions/3.11.9/lib/python3.11/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 462, in import_module
return AstroidManager().ast_from_module_name(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/sbrunner/.pyenv/versions/3.11.9/lib/python3.11/site-packages/astroid/manager.py", line 251, in ast_from_module_name
return self.ast_from_module(named_module, modname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/sbrunner/.pyenv/versions/3.11.9/lib/python3.11/site-packages/astroid/manager.py", line 356, in ast_from_module
return AstroidBuilder(self).module_build(module, modname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/sbrunner/.pyenv/versions/3.11.9/lib/python3.11/site-packages/astroid/builder.py", line 101, in module_build
node = self.inspect_build(module, modname=modname, path=path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/sbrunner/.pyenv/versions/3.11.9/lib/python3.11/site-packages/astroid/raw_building.py", line 463, in inspect_build
self.object_build(node, module)
File "/home/sbrunner/.pyenv/versions/3.11.9/lib/python3.11/site-packages/astroid/raw_building.py", line 504, in object_build
class_node = object_build_class(node, member, name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/sbrunner/.pyenv/versions/3.11.9/lib/python3.11/site-packages/astroid/raw_building.py", line 265, in object_build_class
return _base_class_object_build(node, member, basenames, localname=localname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/sbrunner/.pyenv/versions/3.11.9/lib/python3.11/site-packages/astroid/raw_building.py", line 373, in _base_class_object_build
instdict = member().__dict__
^^^^^^^^^^^^^^^^^
AttributeError: 'ModuleNotFound' object has no attribute '__dict__'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/sbrunner/.pyenv/versions/3.11.9/lib/python3.11/site-packages/pylint/lint/pylinter.py", line 788, in _lint_file
check_astroid_module(module)
File "/home/sbrunner/.pyenv/versions/3.11.9/lib/python3.11/site-packages/pylint/lint/pylinter.py", line 1017, in check_astroid_module
retval = self._check_astroid_module(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/sbrunner/.pyenv/versions/3.11.9/lib/python3.11/site-packages/pylint/lint/pylinter.py", line 1069, in _check_astroid_module
walker.walk(node)
File "/home/sbrunner/.pyenv/versions/3.11.9/lib/python3.11/site-packages/pylint/utils/ast_walker.py", line 90, in walk
self.walk(child)
File "/home/sbrunner/.pyenv/versions/3.11.9/lib/python3.11/site-packages/pylint/utils/ast_walker.py", line 87, in walk
callback(astroid)
File "/home/sbrunner/.pyenv/versions/3.11.9/lib/python3.11/site-packages/pylint/checkers/imports.py", line 542, in visit_import
imported_module = self._get_imported_module(node, name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/sbrunner/.pyenv/versions/3.11.9/lib/python3.11/site-packages/pylint/checkers/imports.py", line 1039, 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 "/home/sbrunner/.pyenv/versions/3.11.9/lib/python3.11/site-packages/pylint/lint/pylinter.py", line 752, in _lint_files
self._lint_file(fileitem, module, check_astroid_module)
File "/home/sbrunner/.pyenv/versions/3.11.9/lib/python3.11/site-packages/pylint/lint/pylinter.py", line 790, in _lint_file
raise astroid.AstroidError from e
astroid.exceptions.AstroidError
Expected behavior
No crash
Pylint version
pylint 3.3.3
astroid 3.3.8
Python 3.11.9 (main, May 14 2024, 13:36:26) [GCC 13.2.0]
OS / Environment
linux (Linux)
Additional dependencies
mypy==1.14.1
ei14Copilot
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