diff --git a/doc/whatsnew/fragments/8522.bugfix b/doc/whatsnew/fragments/8522.bugfix new file mode 100644 index 0000000000..2bfc88ee5f --- /dev/null +++ b/doc/whatsnew/fragments/8522.bugfix @@ -0,0 +1,3 @@ +Don't show arrows more than once in Pyreverse diagrams. + +Closes #8522 diff --git a/pylint/pyreverse/diagrams.py b/pylint/pyreverse/diagrams.py index 3d668f6487..4692c8e9af 100644 --- a/pylint/pyreverse/diagrams.py +++ b/pylint/pyreverse/diagrams.py @@ -230,9 +230,13 @@ def extract_relationships(self) -> None: value, obj, name, "aggregation" ) - for name, values in list(node.associations_type.items()) + list( - node.locals_type.items() - ): + associations = node.associations_type.copy() + + for name, values in node.locals_type.items(): + if name not in associations: + associations[name] = values + + for name, values in associations.items(): for value in values: self.assign_association_relationship( value, obj, name, "association" diff --git a/tests/pyreverse/functional/class_diagrams/attributes/duplicates.mmd b/tests/pyreverse/functional/class_diagrams/attributes/duplicates.mmd index 9e1224314c..97bb305b27 100644 --- a/tests/pyreverse/functional/class_diagrams/attributes/duplicates.mmd +++ b/tests/pyreverse/functional/class_diagrams/attributes/duplicates.mmd @@ -14,4 +14,3 @@ classDiagram example2 : int } A --* DuplicateArrows : a - A --* DuplicateArrows : a diff --git a/tests/pyreverse/functional/class_diagrams/attributes/duplicates.py b/tests/pyreverse/functional/class_diagrams/attributes/duplicates.py index 78bec08af1..648eed2a32 100644 --- a/tests/pyreverse/functional/class_diagrams/attributes/duplicates.py +++ b/tests/pyreverse/functional/class_diagrams/attributes/duplicates.py @@ -8,7 +8,7 @@ def __init__(self): self.example2 = 2 -# OPEN BUG: https://github.com/pylint-dev/pylint/issues/8522 +# Test for https://github.com/pylint-dev/pylint/issues/8522 class A: pass