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 does not show inheritance relation when using a flat folder #7686

Open
DudeNr33 opened this issue Oct 28, 2022 · 5 comments
Open
Labels
Needs PR This issue is accepted, sufficiently specified and now needs an implementation pyreverse Related to pyreverse component

Comments

@DudeNr33
Copy link
Collaborator

Bug description

See this SO question.

Foo.py, Bar.py and __init__.py are all located in the same folder.

Foo.py:

class Foo():
    def print_foo(self):
        print("hi")

Bar.py:

from Foo import Foo

class Bar(Foo):
    pass

pyreverse is executed from within the same folder.

Configuration

No response

Command used

pyreverse -ASmy -o png .

Pylint output

The resulting image shows both classes `Foo` and `Bar`, but not the inheritance relationship between them.

Expected behavior

It could be argued that when using an __init__.py and therefore a package relative or absolute imports should be used, the code provided does run fine when just running e.g. python -c "import Bar" from inside the directory.

Therefore pyreverse should pick up the relationships between the two classes as well.

Pylint version

pylint 2.14.5
astroid 2.12.10
Python 3.10.5 (main, Jun  6 2022, 18:49:26) [GCC 12.1.0]

OS / Environment

No response

Additional dependencies

No response

@DudeNr33 DudeNr33 added the Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling label Oct 28, 2022
@Pierre-Sassoulas Pierre-Sassoulas added pyreverse Related to pyreverse component Needs PR This issue is accepted, sufficiently specified and now needs an implementation and removed Needs triage 📥 Just created, needs acknowledgment, triage, and proper labelling labels Oct 28, 2022
@nhadziosma1
Copy link

Are there any updates on this issue?

@Pierre-Sassoulas
Copy link
Member

No one worked on it yet, do you want to contribute @nhadziosma1 ? :)

@atomic-light
Copy link

Same issue here now. Are there any solutions? I can look try to contribute, but I'm not a pro though.

@Pierre-Sassoulas
Copy link
Member

Hey @atomic-light sure we can answer your question if you have some. Imo the first step is to add the test for that. Also do not hesitate to open a draft merge request early it's easier to talk about the issue when seeing the code directly.

@DudeNr33
Copy link
Collaborator Author

The way I would go at this would probably be:

  1. Create a new functional test by creating a new folder beneath tests/pyreverse/functional/class_diagrams and check if the problem stated in the opening post or linked SO question can be reproduced
  2. Debug the test to see what is going on - I could imagine that especially the visit_importfrom method could be worthwhile to investigate.
    def visit_importfrom(self, node: nodes.ImportFrom) -> None:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs PR This issue is accepted, sufficiently specified and now needs an implementation pyreverse Related to pyreverse component
Projects
None yet
Development

No branches or pull requests

4 participants