New backward-compatible NamedTuple#282
New backward-compatible NamedTuple#282gvanrossum merged 7 commits intopython:masterpython/typing:masterfrom
Conversation
|
Oops, sorry, didn't check this on some older Python 3. Will fix this in a second. |
|
OK, now all green. Sorry for exploitation of your Travis, I don't have so many older Python versions here. |
|
@gvanrossum Important note: here I am relying on ordered |
|
I am actually so excited now: two cool new features -- ordered dicts and annotations -- allowed to realize this beautiful new |
|
Very cool to see this! You realize mypy doesn't understand this yet, right? But it's still pretty cool, so I'll push it now. Will you be a dear and prep a diff to copy typing.py back to 3.5 and 3.6? |
|
Ok, I will open an issue on b.p.o. and will submit patches there. I think we could just copy the same files to both, since these files work for both 3.5. and 3.6. |
|
OK, then just submit the 3.5 patch, and I'll merge forward. |
|
@gvanrossum |
I am glad that you like this :-) Btw, I want to work more on mypy internals, but I would like to try few things before. Namely:
Ideally, I would like to do this by 3.6b3 and then to focus on mypy for a month or two. |
But it's just a bug with a confusing diagnostic, right? If it gets less confusing, fine, but hardly a priority.
I can't actually follow that thread -- isn't there a bug for it?
OK -- but isn't #207 also intending to fix that?
That sounds fine -- maybe someone else will beat you to it, but probably not anyone from Dropbox, since we're mostly focused on 2.7 still... |
Indeed, I find the current behavior (binding
Unfortunately, there is no separate issue for this yet, it was discovered in http://bugs.python.org/issue24379 , but again I don't think it is something high priority in general, it is rather interesting for me.
Yes, but I would like to propose an alternative way, by making most thing like |
@gvanrossum
I implemented your idea:
in a backward-compatible manner. Namely, the same code is triggered on instantiation and on subclassing, so that one can use the new form above as well as
Employee = NamedTuple('Employee', [('name', str), ('id', int)]). All old tests pass unmodified.I didn't backport this to Python 2 since it is not possible to use the new form there anyway.