-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Python: Support import *
in API graphs
#6274
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
Conversation
Moves the current test out of `test.py`, as otherwise any unknown global (like, say, `sink`) would _also_ be considered to be something potentially defined in `unknown`.
This will make it possible to reuse for names defined in `import *`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice 💪 besides a few minor things 😉
I'm also thinking that maybe we should only merge this after the final 3.2 branch has been cut, just to be on the safe side 😊
Co-authored-by: Rasmus Wriedt Larsen <rasmuswriedtlarsen@gmail.com>
I debated whether to add a `MISSING: use=moduleImport("builtins").getMember("print").getReturn()` annotation to the last line. Ultimately, I decided to add it, as we likely _do_ want this information to propagate into inner functions (even if the value of `var2` may change before `func4` is called).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Besides having reviewed performance, this looks good to me 👍
Co-authored-by: Rasmus Wriedt Larsen <rasmuswriedtlarsen@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Internal performance test looks fine, so no cause for concerns there ✔️
There was a brief moment when I thought that the following annotation meant that we think that bar
is print
😆 (and I was super confused)
print(bar2) #$ use=moduleImport("builtins").getMember("print").getReturn()
A slightly awkward implementation, mostly due to the fact that
import *
may appear in a local scope, and we don't want this to pollute unrelated scopes.Also, our use of
GlobalSsaVariable
s means we don't consider the first reference to a global (which may come from animport *
in the global scope) to be aLocalSourceNode
. This should go away once we have fixed the remaining issues surroundingEssaNode
s.Needs a performance test (as we're growing the API graph yet again), and possibly also a change note.