Closed
Description
Bug description
Run Pyreverse on a file with this:
class X:
def f(self):
self.x += 0
Crashes with error from Astroid:
lhs_iter = self.target.infer_lhs(context=context)
^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'AssignAttr' object has no attribute 'infer_lhs'
Configuration
No response
Command used
pyreverse asdf.py
Pylint output
pyreverse asdf.py
parsing asdf.py...
Traceback (most recent call last):
File ".local/bin/pyreverse", line 33, in <module>
sys.exit(load_entry_point('pylint', 'console_scripts', 'pyreverse')())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "pylint/pylint/__init__.py", line 56, in run_pyreverse
PyreverseRun(argv or sys.argv[1:])
File "pylint/pylint/pyreverse/main.py", line 289, in __init__
sys.exit(self.run(args))
^^^^^^^^^^^^^^
File "pylint/pylint/pyreverse/main.py", line 307, in run
diadefs = handler.get_diadefs(project, linker)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "pylint/pylint/pyreverse/diadefslib.py", line 232, in get_diadefs
diagrams = DefaultDiadefGenerator(linker, self).visit(project)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "pylint/pylint/pyreverse/utils.py", line 160, in visit
self.visit(local_node)
File "pylint/pylint/pyreverse/utils.py", line 160, in visit
self.visit(local_node)
File "pylint/pylint/pyreverse/utils.py", line 157, in visit
methods[0](node)
File "pylint/pylint/pyreverse/diadefslib.py", line 176, in visit_classdef
self.extract_classes(node, anc_level, association_level)
File "pylint/pylint/pyreverse/diadefslib.py", line 118, in extract_classes
self.add_class(klass_node)
File "pylint/pylint/pyreverse/diadefslib.py", line 82, in add_class
self.linker.visit(node)
File "pylint/pylint/pyreverse/utils.py", line 157, in visit
methods[0](node)
File "pylint/pylint/pyreverse/inspector.py", line 168, in visit_classdef
self.associations_handler.handle(assignattr, node)
File "pylint/pylint/pyreverse/inspector.py", line 332, in handle
super().handle(node, parent)
File "pylint/pylint/pyreverse/inspector.py", line 319, in handle
self._next_handler.handle(node, parent)
File "pylint/pylint/pyreverse/inspector.py", line 338, in handle
parent.associations_type[node.attrname] = list(current | utils.infer_node(node))
^^^^^^^^^^^^^^^^^^^^^^
File "pylint/pylint/pyreverse/utils.py", line 214, in infer_node
ann = get_annotation(node)
^^^^^^^^^^^^^^^^^^^^
File "pylint/pylint/pyreverse/utils.py", line 192, in get_annotation
default, *_ = node.infer()
^^^^^^^^^^^
File "astroid/astroid/nodes/node_ng.py", line 166, in infer
yield from self._infer(context=context, **kwargs)
File "astroid/astroid/decorators.py", line 90, in inner
yield next(generator)
^^^^^^^^^^^^^^^
File "astroid/astroid/decorators.py", line 49, in wrapped
for res in _func(node, context, **kwargs):
File "astroid/astroid/nodes/node_ng.py", line 179, in infer
for i, result in enumerate(self._infer(context=context, **kwargs)):
File "astroid/astroid/decorators.py", line 90, in inner
yield next(generator)
^^^^^^^^^^^^^^^
File "astroid/astroid/decorators.py", line 49, in wrapped
for res in _func(node, context, **kwargs):
File "astroid/astroid/nodes/_base_nodes.py", line 329, in _filter_operation_errors
for result in infer_callable(context):
File "astroid/astroid/nodes/node_classes.py", line 1331, in _infer_augassign
lhs_iter = self.target.infer_lhs(context=context)
^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'AssignAttr' object has no attribute 'infer_lhs'
Expected behavior
No crash.
In contrast, pylint asdf.py
succeeds.
Also, there is no crash with Astroid 2.15.5
Pylint version
pyreverse is included in pylint:
pylint 3.0.0b1
astroid 3.0.0a6-dev0
Python 3.11.0
OS / Environment
No response
Additional dependencies
No response