-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Pyreverse: composition / aggregation arrow strange behavior (and field annotation bug) #9045
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Nice catch ! I think we should display only the strongest of the two relations for |
Not a UML expert either, but as I understand it the example is not composition, so in all of these cases it should show just the aggregation arrow:
(from this article) Composition arrows should only be used if the parent (holding) class instantiates the That being said I agree with Pierre that if there are multiple arrows (for the same attribute as it is denoted on the arrow) we should only show the strongest relation. |
So the logic is: class P:
pass
class A:
x: P # can't tell, so default to aggregation
class B:
def __init__(self, x: P):
self.x = x # not instantiated, so aggregation
class C:
x: P
def __init__(self, x: P):
self.x = x # not instantiated, so aggregation
class D:
x: P
def __init__(self):
self.x = P() # instantiated, so composition
class E:
def __init__(self):
self.x = P() # instantiated, so composition |
At least that is my understanding from the article linked above, yes. |
@Pierre-Sassoulas I think this can be closed because it was already solved in #9055. What do you think? |
Nice catch thank you. Fixed in 3.0.0 |
@Pierre-Sassoulas I think I missed something here. Actually the differentiation between aggregation and composition is not correct in the tests files according to the article mentioned. Maybe this should be reopened (in a seperate issue)?:
|
I came across a diagram that seemed to have too many arrows and too many kinds of arrows. The code is something like this:
Classes
A
,B
, andC
each have the same relationship toP
, namely that they each have a field of that type. So it seems to me that they should all look similar in the class diagram.But instead, they look like this:
Class
A
has a "composition" arrow (black diamond), classB
has an "aggregation" arrow (white diamond), and classC
has both.Is this correct from a UML perspective? To me this output is unexpected and undesirable. I've tried reading about it, but everything I can find about "aggregation vs composition" turns into word soup and I can't make sense of it. Plus all the examples are from Java, with fine distinctions that don't seem to apply in Python. (This SO page is the best discussion I've been able to find.)
On top of all that, the
x
field is unannotated in all ofA
,B
, andC
, when it should sayx: P
.The text was updated successfully, but these errors were encountered: