Message338253
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. |
|
Date |
User |
Action |
Args |
2019-03-18 16:33:07 | josh.r | set | recipients:
+ josh.r, rhettinger, levkivskyi |
2019-03-18 16:33:06 | josh.r | set | messageid: <1552926786.99.0.420963598675.issue36320@roundup.psfhosted.org> |
2019-03-18 16:33:06 | josh.r | link | issue36320 messages |
2019-03-18 16:33:06 | josh.r | create | |
|