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 when using typing.cast #8916

Closed
jerryc05 opened this issue Aug 3, 2023 · 4 comments
Closed

Crash when using typing.cast #8916

jerryc05 opened this issue Aug 3, 2023 · 4 comments
Labels
Duplicate 🐫 Duplicate of an already existing issue python 3.12

Comments

@jerryc05
Copy link

jerryc05 commented Aug 3, 2023

Bug description

pylint this code:

from typing import cast
cast(int,0)

Configuration

default (None)

Command used

pylint test.py

Pylint output

************* Module ***
***.py:1:0: C0114: Missing module docstring (missing-module-docstring)
***.py:1:0: C0103: Module name "***" doesn't conform to snake_case naming style (invalid-name)
Exception on node <ImportFrom l.1 at 0x214235ba7b0> in file '***'
Traceback (most recent call last):
  File "***\Python\Python312\Lib\site-packages\pylint\checkers\imports.py", line 858, in _get_imported_module
    return importnode.do_import_module(modname)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "***\Python\Python312\Lib\site-packages\astroid\nodes\_base_nodes.py", line 146, in do_import_module
    return mymodule.import_module(
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "***\Python\Python312\Lib\site-packages\astroid\nodes\scoped_nodes\scoped_nodes.py", line 530, in import_module
    return AstroidManager().ast_from_module_name(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "***\Python\Python312\Lib\site-packages\astroid\manager.py", line 246, in ast_from_module_name
    return self.ast_from_file(found_spec.location, modname, fallback=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "***\Python\Python312\Lib\site-packages\astroid\manager.py", line 138, in ast_from_file
    return AstroidBuilder(self).file_build(filepath, modname)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "***\Python\Python312\Lib\site-packages\astroid\builder.py", line 144, in file_build
    module, builder = self._data_build(data, modname, path)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "***\Python\Python312\Lib\site-packages\astroid\builder.py", line 204, in _data_build
    module = builder.visit_module(node, modname, node_file, package)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "***\Python\Python312\Lib\site-packages\astroid\rebuilder.py", line 254, in visit_module
    [self.visit(child, newnode) for child in node.body],
     ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "***\Python\Python312\Lib\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 "***\Python\Python312\Lib\site-packages\pylint\utils\ast_walker.py", line 91, in walk
    callback(astroid)
  File "***\Python\Python312\Lib\site-packages\pylint\checkers\imports.py", line 549, in visit_importfrom
    imported_module = self._get_imported_module(node, basename)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "***\Python\Python312\Lib\site-packages\pylint\checkers\imports.py", line 883, in _get_imported_module
    raise astroid.AstroidError from e
astroid.exceptions.AstroidError
***.py:1:0: F0002: ***.py: Fatal error while checking '***.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in '***'. (astroid-error)

-----------------------------------
Your code has been rated at 0.00/10

Expected behavior

no error

Pylint version

pylint 2.17.5
astroid 2.15.6
Python 3.12.0b4 (tags/v3.12.0b4:97a6a41, Jul 11 2023, 13:49:15) [MSC v.1935 64 bit (AMD64)]

OS / Environment

No response

Additional dependencies

No response

@jerryc05 jerryc05 added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Aug 3, 2023
@mbyrnepr2 mbyrnepr2 added Cannot reproduce 🤷 and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Aug 3, 2023
@mbyrnepr2
Copy link
Member

Thanks @jerryc05 is there something else going on in your test module?

From the provided trace:

Exception on node <ImportFrom l.1 at 0x214235ba7b0> in file '***'

@mbyrnepr2 mbyrnepr2 added the Waiting on author Indicate that maintainers are waiting for a message of the author label Aug 3, 2023
@jerryc05
Copy link
Author

jerryc05 commented Aug 3, 2023

Thanks @jerryc05 is there something else going on in your test module?

I assume no? Here is the full terminal output, hope it helps:

$ cat test.py
from typing import cast
cast(int,0)

$ pylint --version
pylint 2.17.5
astroid 2.15.6
Python 3.12.0b4 (tags/v3.12.0b4:97a6a41, Jul 11 2023, 13:49:15) [MSC v.1935 64 bit (AMD64)]

$ pylint test.py
************* Module test
test.py:1:0: C0114: Missing module docstring (missing-module-docstring)
Exception on node <ImportFrom l.1 at 0x1fafae792b0> in file '***\test.py'
Traceback (most recent call last):
  File "C:\Users\***\AppData\Local\Programs\Python\Python312\Lib\site-packages\pylint\checkers\imports.py", line 858, in _get_imported_module
    return importnode.do_import_module(modname)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\***\AppData\Local\Programs\Python\Python312\Lib\site-packages\astroid\nodes\_base_nodes.py", line 146, in do_import_module
    return mymodule.import_module(
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\***\AppData\Local\Programs\Python\Python312\Lib\site-packages\astroid\nodes\scoped_nodes\scoped_nodes.py", line 530, in import_module
    return AstroidManager().ast_from_module_name(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\***\AppData\Local\Programs\Python\Python312\Lib\site-packages\astroid\manager.py", line 246, in ast_from_module_name
    return self.ast_from_file(found_spec.location, modname, fallback=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\***\AppData\Local\Programs\Python\Python312\Lib\site-packages\astroid\manager.py", line 138, in ast_from_file
    return AstroidBuilder(self).file_build(filepath, modname)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\***\AppData\Local\Programs\Python\Python312\Lib\site-packages\astroid\builder.py", line 144, in file_build
    module, builder = self._data_build(data, modname, path)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\***\AppData\Local\Programs\Python\Python312\Lib\site-packages\astroid\builder.py", line 204, in _data_build
    module = builder.visit_module(node, modname, node_file, package)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\***\AppData\Local\Programs\Python\Python312\Lib\site-packages\astroid\rebuilder.py", line 254, in visit_module
    [self.visit(child, newnode) for child in node.body],
     ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\***\AppData\Local\Programs\Python\Python312\Lib\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 "C:\Users\***\AppData\Local\Programs\Python\Python312\Lib\site-packages\pylint\utils\ast_walker.py", line 91, in walk
    callback(astroid)
  File "C:\Users\***\AppData\Local\Programs\Python\Python312\Lib\site-packages\pylint\checkers\imports.py", line 549, in visit_importfrom
    imported_module = self._get_imported_module(node, basename)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\***\AppData\Local\Programs\Python\Python312\Lib\site-packages\pylint\checkers\imports.py", line 883, in _get_imported_module
    raise astroid.AstroidError from e
astroid.exceptions.AstroidError
test.py:1:0: F0002: test.py: Fatal error while checking 'test.py'. Please open an issue in our bug tracker so we address this. There is a pre-filled template that you can use in 'C:\Users\***\AppData\Local\pylint\pylint\Cache\pylint-crash-2023-08-03-10-48-36.txt'. (astroid-error)

------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)

@mbyrnepr2 mbyrnepr2 removed the Waiting on author Indicate that maintainers are waiting for a message of the author label Aug 3, 2023
@DanielNoord
Copy link
Collaborator

@jacobtylerwalls Is this something to block the beta on?

@jacobtylerwalls
Copy link
Member

No, since the reported version is pylint 2.17.5.

@jerryc05 thanks for the report, but the support for running pylint on a Python 3.12 interpreter is not yet released--it only exists on the main branch.

Closing as a duplicate of #8782

@jacobtylerwalls jacobtylerwalls closed this as not planned Won't fix, can't repro, duplicate, stale Aug 4, 2023
@jacobtylerwalls jacobtylerwalls added Duplicate 🐫 Duplicate of an already existing issue python 3.12 and removed Cannot reproduce 🤷 labels Aug 4, 2023
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 python 3.12
Projects
None yet
Development

No branches or pull requests

4 participants