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

Pydeps mydir not detecting imports #25

Closed
Jflick58 opened this issue Mar 11, 2019 · 2 comments
Closed

Pydeps mydir not detecting imports #25

Jflick58 opened this issue Mar 11, 2019 · 2 comments

Comments

@Jflick58
Copy link

Hello,

So I have the following directory:

Directory
L__init__.py
L database.py
L controller.py
L exceptions.py
L models.py
L mainclass.py

If I run pydeps directory, it only seems to detect the database.py file, and then traces the sqlalchemy dependencies in that file. I'm importing all of these files in each other, so there should be a graph of those imports. I saw your example in your documentation, how were you able to trace imports of multiple .py files in the same directory? for example, pydeps.colors and pydeps.depgraph?

@thebjorn
Copy link
Owner

Hi Justin, and thank you for your interest in Pydeps.

Strongly connected modules, i.e. modules that are imported by other modules are automatically included. E.g. if I create a package with empty files, except that the models file includes exceptions:

(dev) go|c:\srv\tmp> tree mydir
mydir
|   `-- __init__.py
|   `-- controller.py
|   `-- database.py
|   `-- exceptions.py
|   `-- mainclass.py
    `-- models.py

(dev) go|c:\srv\tmp> cat mydir\models.py
from . import exceptions

then

(dev) go|c:\srv\tmp> pydeps mydir

will create

mydir

It's arguably a bug that the other modules are not included.

A workaround is to import the missing modules in your __init__.py file:

(dev) go|c:\srv\tmp> cat mydir\__init__.py
from . import (
    controller, database, mainclass, models
)

which will let pydeps produce:
mydir

@Jflick58
Copy link
Author

That helped! thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants