Skip to content

Commit 3f93f1e

Browse files
authored
Fix Pyreverse duplicate arrows bug (#9029)
1 parent 6d9b07d commit 3f93f1e

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

doc/whatsnew/fragments/8522.bugfix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Don't show arrows more than once in Pyreverse diagrams.
2+
3+
Closes #8522

pylint/pyreverse/diagrams.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,9 +225,13 @@ def extract_relationships(self) -> None:
225225
value, obj, name, "aggregation"
226226
)
227227

228-
for name, values in list(node.associations_type.items()) + list(
229-
node.locals_type.items()
230-
):
228+
associations = node.associations_type.copy()
229+
230+
for name, values in node.locals_type.items():
231+
if name not in associations:
232+
associations[name] = values
233+
234+
for name, values in associations.items():
231235
for value in values:
232236
self.assign_association_relationship(
233237
value, obj, name, "association"

tests/pyreverse/functional/class_diagrams/attributes/duplicates.mmd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,3 @@ classDiagram
1414
example2 : int
1515
}
1616
A --* DuplicateArrows : a
17-
A --* DuplicateArrows : a

tests/pyreverse/functional/class_diagrams/attributes/duplicates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ def __init__(self):
88
self.example2 = 2
99

1010

11-
# OPEN BUG: https://github.com/pylint-dev/pylint/issues/8522
11+
# Test for https://github.com/pylint-dev/pylint/issues/8522
1212
class A:
1313
pass
1414

0 commit comments

Comments
 (0)