This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author josh.r
Recipients josh.r, levkivskyi, rhettinger
Date 2019-03-18.16:33:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1552926786.99.0.420963598675.issue36320@roundup.psfhosted.org>
In-reply-to
Content
Blech. Just remembered _field_types is a *class* attribute, not an instance attribute, so it (just) can't be a plain property on NamedTuple itself.

And because NamedTuple is super-weird (AFAICT, class X(typing.NamedTuple): pass defines a class where the class is not a subclass of typing.NamedTuple, nor are its instances instances of NamedTuple, it's just wrapping an invocation of collections.namedtuple, which directly subclasses tuple with no metaclass involvement), and making a "class property" of the type we'd need requires a metaclass (which for tuple subclasses isn't an option), serious hackery or both ( https://stackoverflow.com/q/5189699/364696 ), it's probably not worth the effort to provide this warning. The only way to do it, AFAICT, would be to give the root tuple class a metaclass to provide the _field_types property, and that's a non-starter given it would, among other things, probably slow every single use of tuples just to provide the warning for this one niche case.

Boo.
History
Date User Action Args
2019-03-18 16:33:07josh.rsetrecipients: + josh.r, rhettinger, levkivskyi
2019-03-18 16:33:06josh.rsetmessageid: <1552926786.99.0.420963598675.issue36320@roundup.psfhosted.org>
2019-03-18 16:33:06josh.rlinkissue36320 messages
2019-03-18 16:33:06josh.rcreate