Skip to content

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

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

Open
Julfried opened this issue May 6, 2025 · 1 comment · May be fixed by #10379
Open

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

Julfried opened this issue May 6, 2025 · 1 comment · May be fixed by #10379
Labels
Bug 🪲 pyreverse Related to pyreverse component
Milestone

Comments

@Julfried
Copy link
Contributor

Julfried commented May 6, 2025

Bug description

When using Pyreverse with filter modes like PUB_ONLY, relationships between classes (arrows in diagrams) are still shown even when the attributes themselves are filtered out due to visibility settings.
For example, with this code:

class P:
    pass

class A:
    x: P = P()

class B:
    __x: P = P()

And running with default settings (PUB_ONLY), the diagram shows:

classDiagram
  class A {
    x
  }
  class B {
  }
  class P {
  }
  P --* A : x
  P --* B : __x

Now __x is correctly filtered out from class B's attributes due to being private, but the relationship arrow P --* B : __x is still displayed.

When using --filter-mode=ALL, both attributes and relationships are shown correctly:

classDiagram
  class A {
    x
  }
  class B {
    __x
  }
  class P {
  }
  P --* A : x
  P --* B : __x

The relationships (arrows) should be filtered according to the same visibility rules as attributes for consistency.

Command used

pyreverse -o mmd example.py

Pylint output

Generates diagrams with relationships that don't respect the filter mode.

Expected behavior

If an attribute is filtered out due to visibility (private, protected, etc.), its relationship arrow should also be filtered out.

Pylint version

pylint 4.0.0-dev0
astroid 4.0.0a0
Python 3.13.2 (main, Feb 12 2025, 14:49:53) [MSC v.1942 64 bit (AMD64)]
@Julfried Julfried added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label May 6, 2025
@Pierre-Sassoulas Pierre-Sassoulas added Bug 🪲 pyreverse Related to pyreverse component and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels May 6, 2025
@pavan-msys
Copy link

Hi @Julfried

I’m working on a fix for the issue where aggregations and associations aren’t being filtered according to the selected filter mode (PUB_ONLY, ALL, etc.) in Pyreverse.

To fix this, I added a check in the extract_relationships() method to filter out aggregations and associations based on visibility before adding them to the diagram. I used self.show_attr(name) to handle this filtering.

Before I submit a PR, I wanted to check if this is the right approach. Does this look good, or is there something else I should consider for filtering these relationships based on the filter mode?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 pyreverse Related to pyreverse component
Projects
None yet
3 participants