-
-
Notifications
You must be signed in to change notification settings - Fork 273
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
Fix namedtuple parent #2555
Fix namedtuple parent #2555
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2555 +/- ##
==========================================
+ Coverage 93.22% 93.25% +0.02%
==========================================
Files 93 93
Lines 11048 11044 -4
==========================================
- Hits 10300 10299 -1
+ Misses 748 745 -3
Flags with carried forward coverage won't be shown. Click here to find out more.
|
d3995cc
to
32cf624
Compare
end_col_offset=None, | ||
) | ||
] | ||
tuple_base = util.safe_infer(_extract_single_node("tuple")) |
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.
Why are you inferring here? Shouldn't this just be the nodes.Name
for tuple
? Similar to the comment you make about EnumMeta
preferably being the Name
reference?
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.
My motivation for using the actual definition instead of a Name was to avoid the situation where the actual tuple is shadowed, and thus the Name refers to something different.
However, looking at it my current implementation doesn't achieve that. A better way to do it would be something like tuple_base = builtin_module["tuple"]
. If you think that my worry above is weakly-founded, I can revert to a Name
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 talk about it in some more detail in the commit message)
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 makes sense. I think your idea of doing builtin_module["tuple"]
makes the most sense. Let's do that!
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.
Hmm, actually it appears that tuple_base: nodes.Name = _extract_single_node("tuple")
works pretty well. It's not going to be shadowed, because it belongs to an empty module. Should we go with that?
43e8c5b
to
29d6e84
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.
Although I think I'd like @Pierre-Sassoulas to also have a look here
a147888
to
c4d1be7
Compare
c4d1be7
to
534d230
Compare
(removed outdated comment, "#set base class=tuple") |
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 feel like those kind of change would benefit from being tested in pylint using the primers. This is not done automatically it would be bad to have surprises after we release a version of astroid. Do you know how to do that @temyurchenko ? (pip install a branch of astroid in editable mode then launch pylint's tests then pylint's primer)
I'll try and report |
534d230
to
5b637fa
Compare
5b637fa
to
c307783
Compare
@Pierre-Sassoulas, the pylint tests have a fail due to a bug unrelated to this PR (I've submitted a fix here: pylint-dev/pylint#9966). The primer succeeds. So, this one should be safe to merge. |
Is there anything else to be done with this PR or is it okay to merge, @Pierre-Sassoulas? |
it's a part of the campaign to get rid of non-module roots
c307783
to
6a6fc8f
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.
Sorry this went under my radar. Great job !
A part of getting rid of non-Module roots, see #2536