Skip to content
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

pyreverse should ignore class level attribute declarations #8189

Closed
DudeNr33 opened this issue Feb 5, 2023 · 0 comments · Fixed by #9004 or #9093
Closed

pyreverse should ignore class level attribute declarations #8189

DudeNr33 opened this issue Feb 5, 2023 · 0 comments · Fixed by #9004 or #9093
Labels
Bug 🪲 pyreverse Related to pyreverse component
Milestone

Comments

@DudeNr33
Copy link
Collaborator

DudeNr33 commented Feb 5, 2023

Bug description

If an attribute is only declared on class level (with type annotation), but not assigned to a value, it is currently displayed twice in pyreverse diagrams:

class ExampleClass():
    example1: int
    example2: int

    def __init__(self):
        self.example1 = 1
        self.example2 = 2
@startuml classes
set namespaceSeparator none
class "ExampleClass" as asdf.ExampleClass {
  example1 : int
  example1 : int
  example2 : int
  example2 : int
}
@enduml

However it should be ignored, and only the type information should be picked up by pyreverse.

Note: if a value is assigned on class level, the attribute is a class attribute and the attributes defined in __init__ are instance attributes.
Both exist independently from one another, and the class attribute should be shown as "static attribute" with an underline.
See also the discussion in this issue.

Configuration

No response

Command used

pyreverse a.py

Pylint output

See above

Expected behavior

Only show the attribute once.

Pylint version

pylint 2.16.0-dev
astroid 2.12.13
Python 3.10.8 (main, Nov  1 2022, 14:18:21) [GCC 12.2.0]

OS / Environment

No response

Additional dependencies

No response

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
2 participants