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

Show only top-level imports #216

Open
ThibaudDauce opened this issue Apr 3, 2024 · 1 comment
Open

Show only top-level imports #216

ThibaudDauce opened this issue Apr 3, 2024 · 1 comment

Comments

@ThibaudDauce
Copy link

Hi,

Thanks for the awesome tool. I'm doing some research on a big Python project and I try to improve the number of top-level imports/imported_by. I don't care about imports inside function definition since they do not raise problems for import cycles… Is there a way to only report the top-level imports and exclude imports inside function definition?

Thanks!

@thebjorn
Copy link
Owner

thebjorn commented Apr 3, 2024

Hi @ThibaudDauce and thank you for your interest in pydeps.

Pydeps uses (a patched version of) the standard library moduluefinder module and unfortunaetly there is no functionality there that knows whether an import is in the global namespace.

If you want to look into the possibility of making this (i.e. making the modulefinder code context aware) work, the code that needs to change is in pydeps/mf27.py in the ModuleFinder.scan_code(..) method. (I'm always happy to merge PRs ;-) )

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