-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Python: Add support for global attribute writes #8890
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
Ideally, we would add a test showing the missed flow and then see the situation improve by the widened attribute write. |
Ah, good point. I'll add one. |
9dee4a0
to
f71cf2e
Compare
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.
I found one of the tests confusing, otherwise this looks fine to me.
def test_local_attribute_read(): | ||
x = local_var.foo |
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.
What are we testing here? That local_var
is different from the one defined in the assignment test?
Perhaps add a comment to explain our expectations. Or perhaps assign to the variable inside the function?
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.
The intent was to show that even though we have an attribute assignment to a (local) variable that shadows a global of the same name, this does not result in additional flow. I can add global local_var
if you think that'll make it clearer (though it is redundant). Assigning to the variable inside the function would make it a local variable, which would prevent the ModuleVariableNode
from even existing.
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.
Ah, the shadowing is an extra twist.
…sts.py Co-authored-by: Taus <tausbn@github.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
I'm still not convinced that this is the best solution, but it fixes the
issue in the short term. When we eventually clean up the whole
EssaNode
business, we can consider whether there's a better way to dothis.
I don't think this requires a change note, but will happily add one if needed.