Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash AstroidError AttributeError: 'TreeRebuilder' object has no attribute 'visit_typealias' #9436

Closed
Hanspe-3019 opened this issue Feb 14, 2024 · 1 comment
Labels
Duplicate 🐫 Duplicate of an already existing issue

Comments

@Hanspe-3019
Copy link

Bug description

When parsing the following file:


''' Test für menu.py
'''
import matplotlib.pyplot as plt

import menu

def main():
    ''' Test
    '''
    fig = plt.figure()
    fig.subplots_adjust(left=0.3)
    props = menu.ItemProperties(labelcolor='black', bgcolor='yellow',
                           fontsize=10, alpha=0.2)
    hoverprops = menu.ItemProperties(labelcolor='white', bgcolor='blue',
                                fontsize=10, alpha=0.2)

    menuitems = []
    def dummy():
        ' wie der Name sagt'
        return 'no problem'
    texts = 'eins zwei drei vier fünf sechs'.split()
    for text in texts:
        item = menu.MenuItem(fig, (text, dummy), props=props, hoverprops=hoverprops,)
        menuitems.append(item)

    _ = menu.Menu(fig, menuitems)

    def on_pick(event):
        ' pick handler'
        item = event.artist
        print(
            f'picked {item}'
            f'\n\t{item.labelstr}'
            f'\n\t{item.problem()}'
        )

    cid = fig.canvas.mpl_connect('pick_event', on_pick)
    print(f'cid={cid}')
    plt.show()

if __name__ == '__main__':
    main()



pylint crashed with a ``AstroidError`` and with the following stacktrace:

Traceback (most recent call last):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/pylint/checkers/imports.py", line 846, in _get_imported_module
return importnode.do_import_module(modname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/nodes/_base_nodes.py", line 146, in do_import_module
return mymodule.import_module(
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 527, in import_module
return AstroidManager().ast_from_module_name(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/manager.py", line 232, in ast_from_module_name
return self.ast_from_file(found_spec.location, modname, fallback=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/manager.py", line 124, in ast_from_file
return AstroidBuilder(self).file_build(filepath, modname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/builder.py", line 145, in file_build
return self._post_build(module, builder, encoding)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/builder.py", line 169, in _post_build
self.delayed_assattr(delayed)
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/builder.py", line 240, in delayed_assattr
for inferred in node.expr.infer():
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/nodes/node_ng.py", line 171, in infer
yield from self._infer(context=context, **kwargs)
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/decorators.py", line 142, in raise_if_nothing_inferred
yield next(generator)
^^^^^^^^^^^^^^^
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/decorators.py", line 111, in wrapped
for res in _func(node, context, **kwargs):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/bases.py", line 176, in _infer_stmts
for inf in stmt.infer(context=context): # type: ignore[union-attr]
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/nodes/node_ng.py", line 184, in infer
for i, result in enumerate(self._infer(context=context, **kwargs)):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/decorators.py", line 142, in raise_if_nothing_inferred
yield next(generator)
^^^^^^^^^^^^^^^
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/decorators.py", line 111, in wrapped
for res in _func(node, context, **kwargs):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/bases.py", line 176, in _infer_stmts
for inf in stmt.infer(context=context): # type: ignore[union-attr]
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/nodes/node_ng.py", line 184, in infer
for i, result in enumerate(self._infer(context=context, **kwargs)):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/decorators.py", line 142, in raise_if_nothing_inferred
yield next(generator)
^^^^^^^^^^^^^^^
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/decorators.py", line 111, in wrapped
for res in _func(node, context, **kwargs):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/inference.py", line 358, in infer_attribute
for owner in self.expr.infer(context):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/nodes/node_ng.py", line 184, in infer
for i, result in enumerate(self._infer(context=context, **kwargs)):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/decorators.py", line 142, in raise_if_nothing_inferred
yield next(generator)
^^^^^^^^^^^^^^^
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/decorators.py", line 111, in wrapped
for res in _func(node, context, **kwargs):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/inference.py", line 358, in infer_attribute
for owner in self.expr.infer(context):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/nodes/node_ng.py", line 184, in infer
for i, result in enumerate(self._infer(context=context, **kwargs)):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/decorators.py", line 142, in raise_if_nothing_inferred
yield next(generator)
^^^^^^^^^^^^^^^
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/decorators.py", line 111, in wrapped
for res in _func(node, context, **kwargs):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/bases.py", line 176, in _infer_stmts
for inf in stmt.infer(context=context): # type: ignore[union-attr]
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/nodes/node_ng.py", line 184, in infer
for i, result in enumerate(self._infer(context=context, **kwargs)):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/decorators.py", line 142, in raise_if_nothing_inferred
yield next(generator)
^^^^^^^^^^^^^^^
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/decorators.py", line 111, in wrapped
for res in _func(node, context, **kwargs):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/bases.py", line 176, in _infer_stmts
for inf in stmt.infer(context=context): # type: ignore[union-attr]
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/nodes/node_ng.py", line 184, in infer
for i, result in enumerate(self._infer(context=context, **kwargs)):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/decorators.py", line 142, in raise_if_nothing_inferred
yield next(generator)
^^^^^^^^^^^^^^^
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/decorators.py", line 111, in wrapped
for res in _func(node, context, **kwargs):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/inference.py", line 279, in infer_call
yield from callee.infer_call_result(caller=self, context=callcontext)
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 1733, in infer_call_result
yield from returnnode.value.infer(context)
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/nodes/node_ng.py", line 184, in infer
for i, result in enumerate(self._infer(context=context, **kwargs)):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/decorators.py", line 142, in raise_if_nothing_inferred
yield next(generator)
^^^^^^^^^^^^^^^
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/decorators.py", line 111, in wrapped
for res in _func(node, context, **kwargs):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/inference.py", line 270, in infer_call
for callee in self.func.infer(context):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/nodes/node_ng.py", line 184, in infer
for i, result in enumerate(self._infer(context=context, **kwargs)):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/decorators.py", line 142, in raise_if_nothing_inferred
yield next(generator)
^^^^^^^^^^^^^^^
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/decorators.py", line 111, in wrapped
for res in _func(node, context, **kwargs):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/inference.py", line 358, in infer_attribute
for owner in self.expr.infer(context):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/nodes/node_ng.py", line 184, in infer
for i, result in enumerate(self._infer(context=context, **kwargs)):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/decorators.py", line 142, in raise_if_nothing_inferred
yield next(generator)
^^^^^^^^^^^^^^^
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/decorators.py", line 111, in wrapped
for res in _func(node, context, **kwargs):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/inference.py", line 279, in infer_call
yield from callee.infer_call_result(caller=self, context=callcontext)
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 1733, in infer_call_result
yield from returnnode.value.infer(context)
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/nodes/node_ng.py", line 184, in infer
for i, result in enumerate(self._infer(context=context, **kwargs)):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/decorators.py", line 142, in raise_if_nothing_inferred
yield next(generator)
^^^^^^^^^^^^^^^
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/decorators.py", line 111, in wrapped
for res in _func(node, context, **kwargs):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/inference.py", line 270, in infer_call
for callee in self.func.infer(context):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/nodes/node_ng.py", line 184, in infer
for i, result in enumerate(self._infer(context=context, **kwargs)):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/decorators.py", line 142, in raise_if_nothing_inferred
yield next(generator)
^^^^^^^^^^^^^^^
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/decorators.py", line 111, in wrapped
for res in _func(node, context, **kwargs):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/bases.py", line 176, in _infer_stmts
for inf in stmt.infer(context=context): # type: ignore[union-attr]
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/nodes/node_ng.py", line 184, in infer
for i, result in enumerate(self._infer(context=context, **kwargs)):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/decorators.py", line 142, in raise_if_nothing_inferred
yield next(generator)
^^^^^^^^^^^^^^^
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/decorators.py", line 111, in wrapped
for res in _func(node, context, **kwargs):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/inference.py", line 334, in infer_import_from
module = self.do_import_module()
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/nodes/_base_nodes.py", line 146, in do_import_module
return mymodule.import_module(
^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 527, in import_module
return AstroidManager().ast_from_module_name(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/manager.py", line 232, in ast_from_module_name
return self.ast_from_file(found_spec.location, modname, fallback=False)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/manager.py", line 124, in ast_from_file
return AstroidBuilder(self).file_build(filepath, modname)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/builder.py", line 144, in file_build
module, builder = self._data_build(data, modname, path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/builder.py", line 204, in _data_build
module = builder.visit_module(node, modname, node_file, package)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/rebuilder.py", line 254, in visit_module
[self.visit(child, newnode) for child in node.body],
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/astroid/rebuilder.py", line 603, in visit
visit_method = getattr(self, visit_name)
^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'TreeRebuilder' object has no attribute 'visit_typealias'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/pylint/lint/pylinter.py", line 798, in _lint_file
check_astroid_module(module)
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/pylint/lint/pylinter.py", line 1067, in check_astroid_module
retval = self._check_astroid_module(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/pylint/lint/pylinter.py", line 1117, in _check_astroid_module
walker.walk(node)
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/pylint/utils/ast_walker.py", line 94, in walk
self.walk(child)
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/pylint/utils/ast_walker.py", line 91, in walk
callback(astroid)
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/pylint/checkers/imports.py", line 526, in visit_import
imported_module = self._get_imported_module(node, name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/pylint/checkers/imports.py", line 871, 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 "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/pylint/lint/pylinter.py", line 763, in _lint_files
self._lint_file(fileitem, module, check_astroid_module)
File "/Users/mb/miniconda3/envs/py3c/lib/python3.12/site-packages/pylint/lint/pylinter.py", line 800, in _lint_file
raise astroid.AstroidError from e
astroid.exceptions.AstroidError

Configuration

No response

Command used

pylint test_menu.py

Pylint output

test_menu.py:1:0: F0002: test_menu.py: Fatal error while checking 'test_menu.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in '/Volumes/Nobackup/Library/Caches/pylint/pylint-crash-2024-02-14-18-26-34.txt'. (astroid-error)

Expected behavior

No crash

Pylint version

pylint 2.16.2
astroid 2.14.2
Python 3.12.1 | packaged by Anaconda, Inc. | (main, Jan 19 2024, 09:52:31) [Clang 14.0.6 ]

OS / Environment

macOS Ventura 13.6.4

Additional dependencies

No response

@Hanspe-3019 Hanspe-3019 added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Feb 14, 2024
@jacobtylerwalls
Copy link
Member

Python 3.12 can only be used to run pylint with pylint 3 or higher.

@jacobtylerwalls jacobtylerwalls closed this as not planned Won't fix, can't repro, duplicate, stale Feb 14, 2024
@jacobtylerwalls jacobtylerwalls added Duplicate 🐫 Duplicate of an already existing issue and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Feb 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Duplicate 🐫 Duplicate of an already existing issue
Projects
None yet
Development

No branches or pull requests

2 participants