Skip to content

Commit 6ee8117

Browse files
committed
Update relationship extraction to avoid duplicate entries
1 parent 4216545 commit 6ee8117

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

pylint/pyreverse/diagrams.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -238,35 +238,38 @@ def extract_relationships(self) -> None:
238238
# Track processed attributes to avoid duplicates
239239
processed_attrs = set()
240240

241-
# Composition links
241+
# Process in priority order: Composition > Aggregation > Association
242+
243+
# 1. Composition links (highest priority)
242244
for name, values in list(node.compositions_type.items()):
245+
if not self.show_attr(name):
246+
continue
243247
for value in values:
244248
self.assign_association_relationship(
245249
value, obj, name, "composition"
246250
)
247251
processed_attrs.add(name)
248252

249-
# Aggregation links
253+
# 2. Aggregation links (medium priority)
250254
for name, values in list(node.aggregations_type.items()):
255+
if not self.show_attr(name) or name in processed_attrs:
256+
continue
251257
for value in values:
252-
if not self.show_attr(name):
253-
continue
254-
255258
self.assign_association_relationship(
256259
value, obj, name, "aggregation"
257260
)
261+
processed_attrs.add(name)
258262

259-
# Association links
263+
# 3. Association links (lowest priority)
260264
associations = node.associations_type.copy()
261265
for name, values in node.locals_type.items():
262266
if name not in associations:
263267
associations[name] = values
264268

265269
for name, values in associations.items():
270+
if not self.show_attr(name) or name in processed_attrs:
271+
continue
266272
for value in values:
267-
if not self.show_attr(name):
268-
continue
269-
270273
self.assign_association_relationship(
271274
value, obj, name, "association"
272275
)

0 commit comments

Comments
 (0)