Skip to content

Even after #7429 merged, a crash AttributeError: 'ClassDef' object has no attribute 'value' #7467

Closed
@akaihola

Description

@akaihola

Bug description

When parsing the following file, Pylint crashes:

class AnotherClass:
    ...


class Pylint7429:
    def foo(self):
        self.__class__, myvar = AnotherClass, "myvalue"

Pylint versions prior to 2.9 run fine on the same file.

Configuration

No response

Command used

pylint /tmp/pylint7429.py

Pylint output

************* Module pylint7429
[...]
Exception on node <AssignAttr.__class__ l.7 at 0x7fb5f19060d0> in file '/tmp/pylint7429.py'
Traceback (most recent call last):
  File "pylint/utils/ast_walker.py", line 90, in walk
    callback(astroid)
  File "pylint/checkers/classes/class_checker.py", line 1556, in visit_assignattr
    self._check_invalid_class_object(node)
  File "pylint/checkers/classes/class_checker.py", line 1561, in _check_invalid_class_object
    inferred = safe_infer(node.parent.value)
  File "astroid/bases.py", line 134, in __getattr__
    return getattr(self._proxied, name)
AttributeError: 'ClassDef' object has no attribute 'value'
/tmp/pylint7429.py:1:0: F0002: /tmp/pylint7429.py: Fatal error while checking '/tmp/pylint7429.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/akaihola/.cache/pylint/pylint-crash-2022-09-15-14-06-01.txt'. (astroid-error)

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

Expected behavior

Expect pylint to not crash

Pylint version

pylint 2.15.2
astroid 2.12.9
Python 3.8.13 (default, Mar 16 2022, 13:02:57) 
[GCC 11.3.0]

OS / Environment

NixOS 22.05

Additional dependencies

No response

Metadata

Metadata

Labels

Crash 💥A bug that makes pylint crashNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions