| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
There was a problem hiding this comment.
I think this goes too far because it's not realistic to expect type checkers to support arbitrary base classes on NamedTuple. Also, there haven't been any user requests that I can see for multiple inheritance with anything other than Generic. So I'd prefer to merge the other PR that allows multiple inheritance with Generic only.
Sorry, something went wrong.
I also think it makes sense to only allow multiple inheritance with Generic, for now. It's a smaller change; and, there should be opportunity to rethink it in the future if it turns out that people really need arbitrary multiple inheritance for whatever reason. |
Sorry, something went wrong.
|
So, let's just close this? |
Sorry, something went wrong.
There was a problem hiding this comment.
people really need arbitrary multiple inheritance for whatever reason
Thanks for reopening! This looks like the case now indeed
Sorry, something went wrong.
There was a problem hiding this comment.
Looks great! I ended up doing nearly exactly the same thing in some code of my own to get around this limitation.
Sorry, something went wrong.
|
Thank you @AlexWaygood and @gvanrossum. Updated to 3.14 and applied the suggestions. |
Sorry, something went wrong.
There was a problem hiding this comment.
Given that we've had multiple requests for this, I'm okay with landing it. But please get sign-offs from @gvanrossum and @JelleZijlstra before merging.
Sorry, something went wrong.
There was a problem hiding this comment.
Let's do it! (I approve of the idea, I haven't carefully reviewed the code.)
Sorry, something went wrong.
|
I'm OK with this given the discussion on the issue; will take another look at the code soon. |
Sorry, something went wrong.
|
Reminder for this: the 3.14 beta freeze is in two weeks. |
Sorry, something went wrong.
There was a problem hiding this comment.
That'd be great to have. I needed this more than once!
Sorry, something went wrong.
| disallowed in Python 3.15. To create a NamedTuple class with 0 fields, | ||
| use ``class NT(NamedTuple): pass`` or ``NT = NamedTuple("NT", [])``. | ||
|
|
||
| .. versionchanged:: 3.14 |
There was a problem hiding this comment.
| .. versionchanged:: 3.14 | |
| .. versionchanged:: next |
Sorry, something went wrong.
| self.assertEqual(a.y, 5) | ||
| self.assertEqual(len(a), 1) | ||
|
|
||
| class Y(A, NamedTuple): |
There was a problem hiding this comment.
Maybe add a test to check the order of the members as well when doing unpacking? And maybe test class Z(X, Y, NamedTuple)? (I don't know if this leads to a MRO incompatibilty though)
Sorry, something went wrong.
There was a problem hiding this comment.
It will be error. This is tested in the next test.
Sorry, something went wrong.
|
This PR is stale because it has been open for 30 days with no activity. |
Sorry, something went wrong.
| for base in bases: | ||
| if base is not _NamedTuple and base is not Generic: | ||
| raise TypeError( | ||
| 'can only inherit from a NamedTuple type and Generic') |
There was a problem hiding this comment.
Please consider addressing https://gist.github.com/johnslavik/4d0e22df6cb61868f74269fe7d401f5b.
Sorry, something went wrong.
|
This PR is stale because it has been open for 90 days with no activity. |
Sorry, something went wrong.
|
Any progress? |
Sorry, something went wrong.
|
This PR is stale because it has been open for 90 days with no activity. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
https://bugs.python.org/issue43923