Skip to content

Pyreverse: Duplicate arrows when class attribute is assigned more than once #9267

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
bMorgan01 opened this issue Nov 28, 2023 · 2 comments · May be fixed by #10333
Open

Pyreverse: Duplicate arrows when class attribute is assigned more than once #9267

bMorgan01 opened this issue Nov 28, 2023 · 2 comments · May be fixed by #10333
Labels
Bug 🪲 Good first issue Friendly and approachable by new contributors pyreverse Related to pyreverse component
Milestone

Comments

@bMorgan01
Copy link

bMorgan01 commented Nov 28, 2023

Bug description

I get an issue similar to #8522, but it seems to have a different cause. Supposedly this issue was fixed in pylint 3.0.0, but I still see it.

Code:

class A:
    def __init__(self) -> None:
        self.var = 2

class B:
    def __init__(self) -> None:
        self.a_obj = A()

    def func(self):
        self.a_obj = A()
        self.a_obj = A()

Result:
classes

Configuration

No response

Command used

pyreverse . -o png

Pylint output

Format png is not supported natively. Pyreverse will try to generate it using Graphviz...
Analysed 2 modules with a total of 0 imports

Expected behavior

Duplicate arrows do not appear

Pylint version

pylint 3.0.2
astroid 3.0.1
Python 3.10.11 (tags/v3.10.11:7d4cc5a, Apr  5 2023, 00:38:17) [MSC v.1929 64 bit (AMD64)]

OS / Environment

Windows 10 / powershell

Additional dependencies

No response

@bMorgan01 bMorgan01 added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Nov 28, 2023
@nickdrozd nickdrozd added Bug 🪲 pyreverse Related to pyreverse component Good first issue Friendly and approachable by new contributors and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Nov 28, 2023
@nickdrozd
Copy link
Contributor

The previous issue had to do with the duplication between field declarations and assignments, while this one has to do with multiple assignments. There are many ways to create duplicates in Pyreverse!

For anyone who wants to fix this one, take a look at #9029.

@pranav-data
Copy link

I have a fix for this issue. The output I get with this fix is below:

classDiagram
class A {
var : int
}
class B {
a_obj
func()
}
A --* B : a_obj

I will issue a pull request once I review the contributing guidelines and setup my environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug 🪲 Good first issue Friendly and approachable by new contributors pyreverse Related to pyreverse component
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants