Hi again -
Congrats on the big OpenAI news - very exciting!
To business 😆 - below is a proposal I have to make analyze graph a little more effective for additional cases:
Problem Statement
When detect-string-imports is enabled, strings like "a.b.c.MyClass" are dropped because a/b/c/MyClass.py doesn't exist.
One common pattern (for better or worse) we have in our codebase is a fully-specified import-like string to an attribute in a module. We specifically use pydoc.locate() for this resolution, so the proposal here is for analyze graph to also see these types of string "imports".
Proposed Fix
The proposed fix is pretty simple - just allow the resolver to try progressively shorter prefixes only for string imports
eg. a.b.c, then a.b, etc. — until one resolves to an actual module file.
I have implemented this in #24058 if this is of interest to upstream!
Thanks for reading!
Hi again -
Congrats on the big OpenAI news - very exciting!
To business 😆 - below is a proposal I have to make
analyze grapha little more effective for additional cases:Problem Statement
When
detect-string-importsis enabled, strings like"a.b.c.MyClass"are dropped becausea/b/c/MyClass.pydoesn't exist.One common pattern (for better or worse) we have in our codebase is a fully-specified import-like string to an attribute in a module. We specifically use
pydoc.locate()for this resolution, so the proposal here is foranalyze graphto also see these types of string "imports".Proposed Fix
The proposed fix is pretty simple - just allow the resolver to try progressively shorter prefixes only for string imports
eg.
a.b.c, thena.b, etc. — until one resolves to an actual module file.I have implemented this in #24058 if this is of interest to upstream!
Thanks for reading!