Skip to content

Fix Pyreverse: Aggregations aren't filtered according to filter mode (PUB_ONLY, etc.) #10379

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 5 commits into from
May 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/whatsnew/fragments/10373.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Fix a bug in Pyreverse where aggregations and associations were included in diagrams regardless of the selected --filter-mode (such as PUB_ONLY, ALL, etc.).

Closes #10373
6 changes: 6 additions & 0 deletions pylint/pyreverse/diagrams.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ def extract_relationships(self) -> None:
# associations & aggregations links
for name, values in list(node.aggregations_type.items()):
for value in values:
if not self.show_attr(name):
continue

self.assign_association_relationship(
value, obj, name, "aggregation"
)
Expand All @@ -249,6 +252,9 @@ def extract_relationships(self) -> None:

for name, values in associations.items():
for value in values:
if not self.show_attr(name):
continue

self.assign_association_relationship(
value, obj, name, "association"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
classDiagram
class P {
name : str
__init__(name: str)
}
class PrivateAttr {
__x
__init__()
}
class ProtectedAttr {
_x
__init__()
}
class PublicAttr {
x
__init__()
}
class SpecialAttr {
__x__
__init__()
}
P --* PrivateAttr : __x
P --* ProtectedAttr : _x
P --* PublicAttr : x
P --* SpecialAttr : __x__
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class P:
def __init__(self, name: str):
self.name = name


class PrivateAttr:
def __init__(self):
self.__x = P("private")


class ProtectedAttr:
def __init__(self):
self._x = P("protected")


class PublicAttr:
def __init__(self):
self.x = P("public")


class SpecialAttr:
def __init__(self):
self.__x__ = P("special")
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[testoptions]
command_line_args=--filter-mode=ALL
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
classDiagram
class P {
name : str
__init__(name: str)
}
class PrivateAttr {
__init__()
}
class ProtectedAttr {
__init__()
}
class PublicAttr {
x
__init__()
}
class SpecialAttr {
__x__
__init__()
}
P --* PublicAttr : x
P --* SpecialAttr : __x__
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class P:
def __init__(self, name: str):
self.name = name


class PrivateAttr:
def __init__(self):
self.__x = P("private")


class ProtectedAttr:
def __init__(self):
self._x = P("protected")


class PublicAttr:
def __init__(self):
self.x = P("public")


class SpecialAttr:
def __init__(self):
self.__x__ = P("special")
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[testoptions]
command_line_args=--filter-mode=OTHER
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
classDiagram
class P {
name : str
}
class PrivateAttr {
}
class ProtectedAttr {
}
class PublicAttr {
x
}
class SpecialAttr {
}
P --* PublicAttr : x
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class P:
def __init__(self, name: str):
self.name = name


class PrivateAttr:
def __init__(self):
self.__x = P("private")


class ProtectedAttr:
def __init__(self):
self._x = P("protected")


class PublicAttr:
def __init__(self):
self.x = P("public")


class SpecialAttr:
def __init__(self):
self.__x__ = P("special")
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[testoptions]
command_line_args=--filter-mode=PUB_ONLY
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
classDiagram
class P {
name : str
}
class PrivateAttr {
__x
}
class ProtectedAttr {
_x
}
class PublicAttr {
x
}
class SpecialAttr {
}
P --* PrivateAttr : __x
P --* ProtectedAttr : _x
P --* PublicAttr : x
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
class P:
def __init__(self, name: str):
self.name = name


class PrivateAttr:
def __init__(self):
self.__x = P("private")


class ProtectedAttr:
def __init__(self):
self._x = P("protected")


class PublicAttr:
def __init__(self):
self.x = P("public")


class SpecialAttr:
def __init__(self):
self.__x__ = P("special")
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[testoptions]
command_line_args=--filter-mode=SPECIAL
Loading