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 duplication issue #7634

Closed
WilliamMiteff opened this issue Oct 17, 2022 · 4 comments
Closed

pyreverse duplication issue #7634

WilliamMiteff opened this issue Oct 17, 2022 · 4 comments
Labels
Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling pyreverse Related to pyreverse component

Comments

@WilliamMiteff
Copy link

WilliamMiteff commented Oct 17, 2022

Bug description

When using pyreverse on the below syntax I get the follow output.

from inspect import currentframe, FrameInfo, getouterframes
from random import randint
from time import sleep
from typing import Any, Literal  # pylint: disable=unused-import

from pandas import (  # pylint: disable=unused-import
    concat,
    DataFrame,
    json_normalize,
    NaT,
    read_sql_query,
    Series,
)

from utils.doless import LOG_ERROR  # pylint: disable=unused-import
from utils.errors import (  # pylint: disable=unused-import
    LoggedException,
    NonLoggedException,
)
from utils.loghelper import get_logger, verbose_logging


class baseclass:
    _verbose: bool = False
    _retryable: bool = False
    _msg: str = ''

    def verbose(self) -> None:
        ...

    def __getcallerfunction(self, back: int = 1) -> str:
        ...

    def __init__(self, friendly_name: str, verbose: bool = False) -> None:
        ...

    def _writer(self, message: str, mode: Literal["info", "debug", "warning", "error", "critical"] = "info") -> None:
        ...

    def sleeptimer(self, max_duration: int = 15) -> None:
        ...
class baseclass {
    _log
    _msg
    _msg
    _retryable
    _verbose
    _verbose
    __getcallerfunction(back: int) str
    __init__(friendly_name: str, verbose: bool) None
    _writer(message: str, mode: Literal['info', 'debug', 'warning', 'error', 'critical']) None
    sleeptimer(max_duration: int) None
    verbose() None
  }

Command used

pyreverse -o mmd -d utils -c baseclass utils/baseclass.py -f ALL -my

Pylint output

class baseclass {
    _log
    _msg
    _msg
    _retryable
    _verbose
    _verbose
    __getcallerfunction(back: int) str
    __init__(friendly_name: str, verbose: bool) None
    _writer(message: str, mode: Literal['info', 'debug', 'warning', 'error', 'critical']) None
    sleeptimer(max_duration: int) None
    verbose() None
  }

Expected behavior

class baseclass {
_log
_msg
_retryable
_verbose
__getcallerfunction(back: int) str
init(friendly_name: str, verbose: bool) None
_writer(message: str, mode: Literal['info', 'debug', 'warning', 'error', 'critical']) None
sleeptimer(max_duration: int) None
verbose() None
}

Pylint version

pylint 2.15.4
astroid 2.12.11
Python 3.9.14 (main, Oct  3 2022, 12:55:59)
[GCC 9.4.0]

OS / Environment

ubuntu 20 (windows 10 wsl)

@WilliamMiteff WilliamMiteff added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Oct 17, 2022
@Pierre-Sassoulas Pierre-Sassoulas added the pyreverse Related to pyreverse component label Oct 17, 2022
@WilliamMiteff
Copy link
Author

Found that this is a coding issue with how I did my class. I have both a global and instance level variable of the same name. it is a shame that pyreverse doesn't visualize this as well.

@DudeNr33
Copy link
Collaborator

Could you update the original post with this global/instance level variable? Is "global" a module level variable or a class attribute?

Do you have a proposal how this visualization could look like in a class diagram?

@WilliamMiteff
Copy link
Author

Yes when I state global, this would be a class attribute. I would like to see class variables should be listed first. I don't know what options are available to denote them as a class attribute.

@nickdrozd
Copy link
Contributor

Fixed with #9004

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling pyreverse Related to pyreverse component
Projects
None yet
Development

No branches or pull requests

4 participants