Skip to content

AstroidError raised by AttributeError: 'TreeRebuilder' object has no attribute 'visit_typealias' #10407

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

Closed
jfolker opened this issue May 27, 2025 · 1 comment
Labels
Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling

Comments

@jfolker
Copy link

jfolker commented May 27, 2025

Bug description

This error only happens when I try to run inside of a Conda environment, which leads me to believe that 
some incompatibility between dependency versions is the real culprit.

I put the versions of my dependencies when I encounter this error in the appropriate sections below. 
Here are my deps when everything is copacetic:

pylint 3.1.0
astroid 3.1.0
Python 3.10.12

pyepics==3.5.7
redis==5.0.7

In the Conda environment where I get the error, pylint and astroid use older versions while Python and 
the redis module are newer versions. pyepics uses the same version in both libraries, and the good folks 
working on mxcube3 who use Conda have no trouble running code which uses pyepics.

I suspect the proper resolution of this bug report is "ENVIRONMENT" or "WON'T FIX", but I reported it 
so that other people who run into the same error can know why and resolve their problem the same way I did.

Configuration

Command used

pylint -E lspvmonitor2.py

Pylint output

Exception on node <Call l.56 at 0x786f095195b0> in file '/home/jfolker-local/git/lscat/lsnode/backend/lspvmonitor2.py'
Traceback (most recent call last):
  File "/home/jfolker-local/opt/anaconda3/lib/python3.12/site-packages/pylint/utils/ast_walker.py", line 91, in walk
    callback(astroid)
  File "/home/jfolker-local/opt/anaconda3/lib/python3.12/site-packages/pylint/checkers/base/basic_error_checker.py", line 431, in visit_call
    self._check_inferred_class_is_abstract(inferred, node)
  File "/home/jfolker-local/opt/anaconda3/lib/python3.12/site-packages/pylint/checkers/base/basic_error_checker.py", line 448, in _check_inferred_class_is_abstract
    abstract_methods = _has_abstract_methods(inferred)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jfolker-local/opt/anaconda3/lib/python3.12/site-packages/pylint/checkers/base/basic_error_checker.py", line 78, in _has_abstract_methods
    return len(utils.unimplemented_abstract_methods(node)) > 0
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jfolker-local/opt/anaconda3/lib/python3.12/site-packages/pylint/checkers/utils.py", line 963, in unimplemented_abstract_methods
    mro = reversed(node.mro())
                   ^^^^^^^^^^
  File "/home/jfolker-local/opt/anaconda3/lib/python3.12/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 3043, in mro
    return self._compute_mro(context=context)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jfolker-local/opt/anaconda3/lib/python3.12/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 3019, in _compute_mro
    mro = base._compute_mro(context=context)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jfolker-local/opt/anaconda3/lib/python3.12/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 3019, in _compute_mro
    mro = base._compute_mro(context=context)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jfolker-local/opt/anaconda3/lib/python3.12/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 3019, in _compute_mro
    mro = base._compute_mro(context=context)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jfolker-local/opt/anaconda3/lib/python3.12/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 3012, in _compute_mro
    inferred_bases = list(self._inferred_bases(context=context))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jfolker-local/opt/anaconda3/lib/python3.12/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2995, in _inferred_bases
    baseobj = next(
              ^^^^^
  File "/home/jfolker-local/opt/anaconda3/lib/python3.12/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2995, in <genexpr>
    baseobj = next(
                  ^
  File "/home/jfolker-local/opt/anaconda3/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 "/home/jfolker-local/opt/anaconda3/lib/python3.12/site-packages/astroid/decorators.py", line 142, in raise_if_nothing_inferred
    yield next(generator)
          ^^^^^^^^^^^^^^^
  File "/home/jfolker-local/opt/anaconda3/lib/python3.12/site-packages/astroid/decorators.py", line 111, in wrapped
    for res in _func(node, context, **kwargs):
  File "/home/jfolker-local/opt/anaconda3/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 "/home/jfolker-local/opt/anaconda3/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 "/home/jfolker-local/opt/anaconda3/lib/python3.12/site-packages/astroid/decorators.py", line 142, in raise_if_nothing_inferred
    yield next(generator)
          ^^^^^^^^^^^^^^^
  File "/home/jfolker-local/opt/anaconda3/lib/python3.12/site-packages/astroid/decorators.py", line 111, in wrapped
    for res in _func(node, context, **kwargs):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jfolker-local/opt/anaconda3/lib/python3.12/site-packages/astroid/inference.py", line 334, in infer_import_from
    module = self.do_import_module()
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jfolker-local/opt/anaconda3/lib/python3.12/site-packages/astroid/nodes/_base_nodes.py", line 146, in do_import_module
    return mymodule.import_module(
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jfolker-local/opt/anaconda3/lib/python3.12/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 527, in import_module
    return AstroidManager().ast_from_module_name(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jfolker-local/opt/anaconda3/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 "/home/jfolker-local/opt/anaconda3/lib/python3.12/site-packages/astroid/manager.py", line 124, in ast_from_file
    return AstroidBuilder(self).file_build(filepath, modname)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jfolker-local/opt/anaconda3/lib/python3.12/site-packages/astroid/builder.py", line 144, in file_build
    module, builder = self._data_build(data, modname, path)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jfolker-local/opt/anaconda3/lib/python3.12/site-packages/astroid/builder.py", line 204, in _data_build
    module = builder.visit_module(node, modname, node_file, package)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jfolker-local/opt/anaconda3/lib/python3.12/site-packages/astroid/rebuilder.py", line 254, in visit_module
    [self.visit(child, newnode) for child in node.body],
     ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/jfolker-local/opt/anaconda3/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'
************* Module lspvmonitor2
lspvmonitor2.py:1:0: F0002: lspvmonitor2.py: Fatal error while checking 'lspvmonitor2.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in '/home/jfolker-local/.cache/pylint/pylint-crash-2025-05-27-13-56-31.txt'. (astroid-error)

Expected behavior

************* Module lspvmonitor2
lspvmonitor2.py:56:18: E1123: Unexpected keyword argument 'healthCheckInterval' in constructor call (unexpected-keyword-arg)
lspvmonitor2.py:63:18: E1123: Unexpected keyword argument 'healthCheckInterval' in constructor call (unexpected-keyword-arg)
lspvmonitor2.py:107:4: E1141: Unpacking a dictionary in iteration without calling .items() (dict-iter-missing-items)

Pylint version

pylint 2.16.2
astroid 2.14.2
Python 3.12.7 | packaged by Anaconda, Inc. | (main, Oct  4 2024, 13:27:36) [GCC 11.2.0]

OS / Environment

Ubuntu 22.04

Additional dependencies

pyepics==3.5.7
redis==6.1.0
@jfolker jfolker added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label May 27, 2025
@DanielNoord
Copy link
Collaborator

Yes, you are indeed using a version of astroid and pylint that doens't support the modern code you wrote. To parse code that uses TypeAliases like your you need at least pylint/astroid 3.0 and higher.

There isn't much we can do about that, sorry!

@DanielNoord DanielNoord closed this as not planned Won't fix, can't repro, duplicate, stale May 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling
Projects
None yet
Development

No branches or pull requests

2 participants