-
-
Notifications
You must be signed in to change notification settings - Fork 275
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
control setting nodes as local outside of the constructor #2588
control setting nodes as local outside of the constructor #2588
Conversation
Unfortunately, this PR turned out to be a bit big. A big part of changes is renaming |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2588 +/- ##
=======================================
Coverage 93.20% 93.20%
=======================================
Files 93 93
Lines 11065 11052 -13
=======================================
- Hits 10313 10301 -12
+ Misses 752 751 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
d7590bd
to
17360c4
Compare
Supersedes #2564, quoting my comment from there for clarity:
|
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.
Changes make sense to me!
I have asked Jacob for review as he has looked into this pattern before and might know of edge cases that I don't know about.
Awesome work on the investigation!
Thanks for this! Does this close #1490? If so, can you add a changelog?
Thank you for checking the pylint test suite. I think these are the kinds of PRs that would also benefit from a pylint primer run. I've toyed with adding a github action to astroid to run the pylint primer action. I need to just finish it up and get it in. Would you mind waiting for me to do that? I promise I won't hold this up for weeks. |
I've ran the primer as well.
There are a few other PRs dependent on this one (#2562, and, eventually #2536), but if it doesn't take too long, I'm happy to wait. |
Oh that's great news that you ran the primer. No need to wait then. |
Let me give it just one more try, to be safe |
Yep, all good |
The wording of #1490 is confusing. It says that the problem is that the parent is added to the locals of the child, but the problem solved by this PR is that the child is added to the locals of the parent. Looking at #1489, indeed it is the latter that is the problem. I initially intended for #2536 (comment) to close #1490, but this one can probably also be considered to be closing #1490. What should changelog look like? Can I just add the following to the
|
1. The main reason is that a node might be assigned to its parent via an «alias»: Sometimes a class accesses a member by a different name than "__name__" of that member: in pypy3 `list.__mul__.__name__ == "__rmul__"`. As a result, in the example above we weren't able to find "list.__mul__", because it was recorded only as "list.__rmul__". 2. Sometimes we want to have a parent semantically, but we don't want to add it to the list of locals. For example, when inferring properties we are creating ad-hoc properties. We wouldn't want to add another symbol to the locals every time we do an inference. (actually, there's a very good question as to why we are doing those ad-hoc properties but that's out of scope) it's a part of the campaign to get rid of non-module roots
17360c4
to
579f7a9
Compare
Yes, only this syntax is used for pylint issues, for issues from astroid it can be simplified to:
|
Thanks, I'll note this for the future. |
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'm drowning in astroid myself, so take this approve for what it's worth but I think this change is pretty good and going into the right direction design wise.
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.
Wonderful, I can remove the workarounds that stemmed from #1490 in another PR, and many thanks for noticing that the wording was wrong 👍 .
Sometimes a class accesses a member by a different name than
"name" of that member: in pypy3
list.__mul__.__name__ == "__rmul__"
.As a result, in the example above we weren't able to find
"list.mul", because it was recorded only as "list.rmul".
it's a part of the campaign to get rid of non-module roots
No pylint regressions.