-
-
Notifications
You must be signed in to change notification settings - Fork 290
Create a NamedTuple
instance for NamedTuples
#1306
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
@cdce8p do you think you'll have time to review this ? I see you self requested a review two months ago. I'm trying to release astroid 2.10 :) |
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 beginning to understand Astroid brain a lot better after looking at this!
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.
Had finally time to look at it. Tbh I'm myself not exactly the "brain" expert. However from what I've gathered so far, I'm not sure this is the best solution to the problem.
I do understand your desire to have NamedTuple
/ namedtuple
at least somewhere which isn't the case today, but it seems strange to add a new instance type just for that. Wouldn't it be much more intuitive to insert a new base which itself has tuple
as base? That's at least roughly similar to the pattern we used in the typing brain.
Regarding the remaining changes, I would probably need more time but it looks like there are 3-4 others bundled here as well. That makes it more challenging to review.
Going forward, I would suggest we (1) move the PR back to 2.11
, (2) unbundle additional changes, and (3) explore if inserting a dummy base class would work.
Hmm, I guess this depends on what
I'll try and separate some of the work here. Some of the typing should be fairly straightforward to extract and then review for example. I'll get back to you! |
98a090a
to
806aa81
Compare
@DanielNoord can we close this ? |
I'll triage this somewhere next week to see if there is anything still relevant in here |
Closing! |
Steps
Description
This is the first step towards some improvements to the
NamedTuple
brain. One of the first things I thought we should fix is the fact that we currently lose the fact that something is aNamedTuple
. We don't add it to the object's bases and they are undistinguishable from other instances.I'm not sure if adding a new
Instance
is actually necessary. I thought it might make sense asNamedTuple
behaves differently thantuple
and can have default values for example. I have created theT(opic): NamedTuple
label to identify some issues related toNamedTuple
. I thought a newInstance
type could be the basis for solving some of these.Changes have been tested against current latest commit of
pytest
.Type of Changes
Related Issue