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 Building error when trying to create ast representation with Python 3.12 GitHub Action #9091

Closed
ortk95 opened this issue Oct 2, 2023 · 3 comments
Labels
Crash 💥 A bug that makes pylint crash python 3.12

Comments

@ortk95
Copy link

ortk95 commented Oct 2, 2023

When parsing the following file: https://github.com/ortk95/planetmapper/blob/main/planetmapper/body.py

pylint crashed with a AstroidBuildingError and with the following stacktrace:

Traceback (most recent call last):
  File "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/pylint/lint/pylinter.py", line 1044, in get_ast
    return MANAGER.ast_from_file(filepath, modname, source=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/astroid/manager.py", line 138, in ast_from_file
    return AstroidBuilder(self).file_build(filepath, modname)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/astroid/builder.py", line 145, in file_build
    return self._post_build(module, builder, encoding)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/astroid/builder.py", line 173, in _post_build
    module = self._manager.visit_transforms(module)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/astroid/manager.py", line 109, in visit_transforms
    return self._transform.visit(node)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/astroid/transforms.py", line 89, in visit
    return self._visit(module)
           ^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/astroid/transforms.py", line 54, in _visit
    visited = self._visit_generic(value)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/astroid/transforms.py", line 61, in _visit_generic
    return [self._visit_generic(child) for child in node]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/astroid/transforms.py", line 67, in _visit_generic
    return self._visit(node)
           ^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/astroid/transforms.py", line 57, in _visit
    return self._transform(node)
           ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/astroid/transforms.py", line 38, in _transform
    if predicate is None or predicate(node):
                            ^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/astroid/brain/brain_namedtuple_enum.py", line 600, in _is_enum_subclass
    return cls.is_subtype_of("enum.Enum")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2238, in is_subtype_of
    return any(anc.qname() == type_name for anc in self.ancestors(context=context))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2238, in <genexpr>
    return any(anc.qname() == type_name for anc in self.ancestors(context=context))
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 2399, in ancestors
    for baseobj in stmt.infer(context):
  File "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/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 "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
          ^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
  File "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/astroid/bases.py", line 177, in _infer_stmts
    for inf in stmt.infer(context=context):
  File "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/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 "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/astroid/decorators.py", line 143, in raise_if_nothing_inferred
    yield next(generator)
          ^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/astroid/decorators.py", line 112, in wrapped
    for res in _func(node, context, **kwargs):
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/astroid/inference.py", line 334, in infer_import_from
    module = self.do_import_module()
             ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/astroid/nodes/_base_nodes.py", line 146, in do_import_module
    return mymodule.import_module(
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/astroid/nodes/scoped_nodes/scoped_nodes.py", line 530, in import_module
    return AstroidManager().ast_from_module_name(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/astroid/manager.py", line 246, in ast_from_module_name
    return self.ast_from_file(found_spec.location, modname, fallback=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/astroid/manager.py", line 138, in ast_from_file
    return AstroidBuilder(self).file_build(filepath, modname)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/astroid/builder.py", line 144, in file_build
    module, builder = self._data_build(data, modname, path)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/astroid/builder.py", line 204, in _data_build
    module = builder.visit_module(node, modname, node_file, package)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/astroid/rebuilder.py", line 254, in visit_module
    [self.visit(child, newnode) for child in node.body],
     ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/astroid/rebuilder.py", line 609, 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 "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/pylint/lint/pylinter.py", line 730, in _get_asts
    ast_per_fileitem[fileitem] = self.get_ast(
                                 ^^^^^^^^^^^^^
  File "/opt/hostedtoolcache/Python/3.12.0-rc.3/x64/lib/python3.12/site-packages/pylint/lint/pylinter.py", line 1066, in get_ast
    raise astroid.AstroidBuildingError(
astroid.exceptions.AstroidBuildingError: Building error when trying to create ast representation of module 'planetmapper.body'

This error occurred when running a Pylint GitHub Action using Python 3.12. Pylint runs fine for Python 3.10 and 3.11, so this seems to be related to Python 3.12 specifically. The failed GitHub job can be found at https://github.com/ortk95/planetmapper/actions/runs/6381653329/job/17318563096

@Pierre-Sassoulas
Copy link
Member

Pierre-Sassoulas commented Oct 2, 2023

It seems you're using pylint-2.17.7, you need 3.0.0b0 until 3.0.0 is released. Could you confirm it's working for python 3.12 on your side ? (Your conf might need some tweak if you use compare-to-zero or compare-to-empty-string, but the migration should be painless)

@Pierre-Sassoulas Pierre-Sassoulas added the Waiting on author Indicate that maintainers are waiting for a message of the author label Oct 2, 2023
@jacobtylerwalls
Copy link
Member

3.0.0 was just released, so you could also try that. 👍

@ortk95
Copy link
Author

ortk95 commented Oct 2, 2023

Thanks for your help! I've just re-run the job and everything's now working as expected!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Crash 💥 A bug that makes pylint crash python 3.12
Projects
None yet
Development

No branches or pull requests

3 participants