Skip to content

Commit 9677666

Browse files
committed
Correctly infer the node type for Composition
1 parent 6ee8117 commit 9677666

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
@@ -366,11 +366,13 @@ def handle(self, node: nodes.AssignAttr, parent: nodes.ClassDef) -> None:
366366

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

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

0 commit comments

Comments
 (0)