Skip to content

Commit e6e0daf

Browse files
committed
Correctly infer the node type for Composition
1 parent bedf32f commit e6e0daf

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

pylint/pyreverse/inspector.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,11 +365,13 @@ def handle(self, node: nodes.AssignAttr, parent: nodes.ClassDef) -> None:
365365

366366
# If the element is a Call (object creation), it's composition
367367
if isinstance(element, nodes.Call):
368-
current = set(parent.compositions_type[node.attrname])
369-
parent.compositions_type[node.attrname] = list(
370-
current | utils.infer_node(node)
371-
)
372-
return
368+
element_type = safe_infer(element)
369+
if element_type:
370+
current = set(parent.compositions_type[node.attrname])
371+
parent.compositions_type[node.attrname] = list(
372+
current | {element_type}
373+
)
374+
return
373375

374376
# Not a composition, pass to next handler
375377
super().handle(node, parent)

0 commit comments

Comments
 (0)