2

I noticed that when a class has a single instance of another class that the arrow between the two classes is being displayed without any problems. But Pyreverse doesn't display arrows between classes if the instance variable is a list. Is there any way to display the arrow between two classes in that case?

Given is the following Python code:

class Class1:
    def __init__(self):
        self.attribute: str

class Class2:
    def __init__(self):
        self.attribute: str

class Class3:
    def __init__(self):
        self.class1_single_instance: Class1
        self.class2_list_instance: list[Class2]

The following UML diagram is produced by Pyreverse: actual output

However I would like to have an output like this: ideal output

As you can see in the ideal output there is an arrow between Class1 and Class2 and the cardinality * is given in order to differentiate between instance variables with cardinality 1 and instance variables with arbitrary cardinality.

I appreciate your help!

Christophe
  • 68,716
  • 7
  • 72
  • 138
  • 1
    Does this answer your question? [Pyreverse UML with complex type hints (Union, List, ...)](https://stackoverflow.com/questions/72388388/pyreverse-uml-with-complex-type-hints-union-list) - it's more general but also covers lists, and the author of perverse confirmed in an comment to the selected answer that this feature is currently not implemented by pyreverese. – Christophe Jan 14 '23 at 10:31
  • 1
    Yeah, this answers my question. Thank you very much for linking me to this post. I checked the pull request to add multiplicities to Pyreverse and it's still open. So I guess that lists are just not supported by Pyreverse yet. – Dennis Davari Jan 16 '23 at 18:18

0 Answers0