From b950567b872c7177f976066e9b8982f08e62eb6c Mon Sep 17 00:00:00 2001 From: Alvaro Frias Date: Sun, 27 Nov 2022 12:18:43 -0300 Subject: Feature: distinct Composition and Aggregation arrows (#7836) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Update Linker to add aggregations_type and associations_type to nodes Update logic of nodes to check what kind of relationship does nodes have (association, aggregation) Signed-off-by: Alvaro Frias Garay * Update ClassDiagram's extrac_relationship method to add aggregations links Signed-off-by: Alvaro Frias Garay * Update DiagramWriter to generate AGGREGATION edges Signed-off-by: Alvaro Frias Garay * Update printers to show aggregations Signed-off-by: Alvaro Frias Garay * Update tests with changes on aggregations Signed-off-by: Alvaro Frias Garay * Update Linker to add aggregations_type and associations_type to nodes Update logic of nodes to check what kind of relationship does nodes have (association, aggregation) Signed-off-by: Alvaro Frias Garay * Update ClassDiagram's extrac_relationship method to add aggregations links Signed-off-by: Alvaro Frias Garay * Update DiagramWriter to generate AGGREGATION edges Signed-off-by: Alvaro Frias Garay * Update tests with changes on aggregations Signed-off-by: Alvaro Frias Garay * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Apply pylint pre-commit correction Signed-off-by: Alvaro Frias Garay * Apply mypy corrections Signed-off-by: Alvaro Frias Garay * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add towrncrier fragment Signed-off-by: Alvaro Frias Garay * Update towncrier fragment Signed-off-by: Alvaro Frias Garay * Update towncrier fragment Signed-off-by: Alvaro Frias Garay * Update doc/whatsnew/fragments/6543.feature Co-authored-by: Andreas Finkler <3929834+DudeNr33@users.noreply.github.com> * Add documentation Signed-off-by: Alvaro Frias Garay * fix typo Signed-off-by: Alvaro Frias Garay * Add type hints Signed-off-by: Alvaro Frias Garay * Update pylint/pyreverse/diagrams.py Co-authored-by: Daniël van Noord <13665637+DanielNoord@users.noreply.github.com> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update type hints Signed-off-by: Alvaro Frias Garay * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update fragment * Update fragment Signed-off-by: Alvaro Frias Garay Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Andreas Finkler <3929834+DudeNr33@users.noreply.github.com> Co-authored-by: Daniël van Noord <13665637+DanielNoord@users.noreply.github.com> --- pylint/pyreverse/diagrams.py | 37 ++++++++++++++++++++++++++----------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'pylint/pyreverse/diagrams.py') diff --git a/pylint/pyreverse/diagrams.py b/pylint/pyreverse/diagrams.py index a9dcd1c5e..382d76bf7 100644 --- a/pylint/pyreverse/diagrams.py +++ b/pylint/pyreverse/diagrams.py @@ -214,20 +214,35 @@ class ClassDiagram(Figure, FilterMixIn): self.add_relationship(obj, impl_obj, "implements") except KeyError: continue - # associations link - for name, values in list(node.instance_attrs_type.items()) + list( + + # associations & aggregations links + for name, values in list(node.aggregations_type.items()): + for value in values: + self.assign_association_relationship( + value, obj, name, "aggregation" + ) + + for name, values in list(node.associations_type.items()) + list( node.locals_type.items() ): + for value in values: - if value is astroid.Uninferable: - continue - if isinstance(value, astroid.Instance): - value = value._proxied - try: - associated_obj = self.object_from_node(value) - self.add_relationship(associated_obj, obj, "association", name) - except KeyError: - continue + self.assign_association_relationship( + value, obj, name, "association" + ) + + def assign_association_relationship( + self, value: astroid.NodeNG, obj: ClassEntity, name: str, type_relationship: str + ) -> None: + if value is astroid.Uninferable: + return + if isinstance(value, astroid.Instance): + value = value._proxied + try: + associated_obj = self.object_from_node(value) + self.add_relationship(associated_obj, obj, type_relationship, name) + except KeyError: + return class PackageDiagram(ClassDiagram): -- cgit v1.2.1