Closed and3rson closed 1 year ago
@and3rson Thank you for the detailed and very helpful description and steps to reproduce 👍. Will have a look at this issue in the following days and hopefully provide a fix.
@and3rson The issue you found is pretty interesting in the sense that one can maybe reduce it to the problem of trying to decide (no matter of the import syntax) if you're dealing with an import from pythons own libraries. So my approach/fix does exactly this, in checking if the dependency can be found in sys.modules
and if so - setting global_import
to True
. This seems to solve the reproducible example you've described above (see my screenshot). Also tried it on a bigger codebase (Django), as one would assume it reduces nodes and edges.
Your feedback would be great, you can find the quick fix in PR #30.
Describe the bug It seems that the behavior of determining dependency names differs based on the import style used.
Example project:
This yields four nodes with the following dependencies (using graphviz syntax for demo purposes here):
Logs:
I did some introspection on
pyparser.py
and it seems that:from io import StringIO
form setsglobal_import
toTrue
(due to thefrom
keyword being used)import io
setsglobal_import
toFalse
This leads to inconsistency of final names because the condition on line 260 requiresglobal_import
to beFalse
.Describe your environment
To Reproduce Steps to reproduce the behavior:
xxx
in two different files usingimport xxx
andfrom xxx import yyy
fomsxxx
andfoobar/xxx
listed as two separate dependenciesExpected behavior In both cases, only
xxx
should be shown.Screenshots