Closed fhightower closed 3 years ago
I may be able to use https://docs.python.org/3.7/library/modulefinder.html#modulefinder-example for this (may have to write code to a temp file and then read it out using the modulefinder).
Hi there. I'd like to give this a shot. I messed around with modulefinder a bit, but I didn't really like it. Instead, I think I can make a function that uses the ast module. My idea is to parse the given string into an AST and then look for nodes of the type Import or ImportFrom and extracting the names from them.
Hi @mCallesen! Thanks for being willing to help. That sounds like a plan! There are a number of ast search functions in this library, so feel free to use those as needed. Let me know if you have any questions. Thanks again!
Looks like this one was done with #33 🎉
I would like a
python_imports
function to list all packages (and, if present, functions/variables) being imported:Function Signature
The function should accept a string argument and return a dict with package names as keys and with a list containing each explicitly imported function/variable name for each package (see the example above).
The annotated signature should look something like: