-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Labels
Crash 💥A bug that makes pylint crashA bug that makes pylint crash
Milestone
Description
Bug description
When parsing the following a.py
:
from dataclasses import dataclass
from enum import Enum
@dataclass
class Something(str, Enum):
asd: str = 'sdf'
Configuration
No response
Command used
pylint a.py
Pylint output
<details open>
<summary>
pylint crashed with a ``AstroidError`` and with the following stacktrace:
</summary>
Traceback (most recent call last):
File "/somewhere/test_pylint_enum/.venv/lib64/python3.11/site-packages/pylint/lint/pylinter.py", line 788, in _lint_file
check_astroid_module(module)
File "/somewhere/test_pylint_enum/.venv/lib64/python3.11/site-packages/pylint/lint/pylinter.py", line 1017, in check_astroid_module
retval = self._check_astroid_module(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/somewhere/test_pylint_enum/.venv/lib64/python3.11/site-packages/pylint/lint/pylinter.py", line 1069, in _check_astroid_module
walker.walk(node)
File "/somewhere/test_pylint_enum/.venv/lib64/python3.11/site-packages/pylint/utils/ast_walker.py", line 94, in walk
self.walk(child)
File "/somewhere/test_pylint_enum/.venv/lib64/python3.11/site-packages/pylint/utils/ast_walker.py", line 94, in walk
self.walk(child)
File "/somewhere/test_pylint_enum/.venv/lib64/python3.11/site-packages/pylint/utils/ast_walker.py", line 94, in walk
self.walk(child)
File "/somewhere/test_pylint_enum/.venv/lib64/python3.11/site-packages/pylint/utils/ast_walker.py", line 91, in walk
callback(astroid)
File "/somewhere/test_pylint_enum/.venv/lib64/python3.11/site-packages/pylint/checkers/base/name_checker/checker.py", line 488, in visit_assignname
if utils.is_enum_member(node) or utils.is_assign_name_annotated_with(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/somewhere/test_pylint_enum/.venv/lib64/python3.11/site-packages/pylint/checkers/utils.py", line 2284, in is_enum_member
enum_member_objects = frame.locals.get("__members__")[0].items
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
TypeError: 'NoneType' object is not subscriptable
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/somewhere/test_pylint_enum/.venv/lib64/python3.11/site-packages/pylint/lint/pylinter.py", line 752, in _lint_files
self._lint_file(fileitem, module, check_astroid_module)
File "/somewhere/test_pylint_enum/.venv/lib64/python3.11/site-packages/pylint/lint/pylinter.py", line 790, in _lint_file
raise astroid.AstroidError from e
astroid.exceptions.AstroidError
</details>
Expected behavior
No crash. Works on 2.17.7.
Pylint version
pylint 3.0.0
astroid 3.0.0
Python 3.11.5 (main, Aug 28 2023, 00:00:00) [GCC 13.2.1 20230728 (Red Hat 13.2.1-1)]
OS / Environment
NAME="Fedora Linux"
VERSION="38 (Workstation Edition)"
Additional dependencies
No response
Metadata
Metadata
Assignees
Labels
Crash 💥A bug that makes pylint crashA bug that makes pylint crash