You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We found an internal use case where we want to combine NamedTuple with another base class. The idea is that the other base class implements some functionality on top of NamedTuple. But since NamedTuple is a type-factory function you can't subclass it, and mypy doesn't support other functions that wrap it either (let alone a metaclass to do so). Maybe it would be possible to arrange things so that this:
It would not be quite equivalent to NamedTuple because the class wouldn't be tuple-like. However, it wouldn't be hard to teach mypy to infer attributes from __slots__. If mypy had a type system plugin system this could be a good candidate for writing an internal plugin, as the dictionary in __slots__ idiom is non-standard.
(Note also that mypy supports having NamedTuple(...) as an immediate base class.)
We found an internal use case where we want to combine NamedTuple with another base class. The idea is that the other base class implements some functionality on top of NamedTuple. But since NamedTuple is a type-factory function you can't subclass it, and mypy doesn't support other functions that wrap it either (let alone a metaclass to do so). Maybe it would be possible to arrange things so that this:
is more or less equivalent to this?
I realize this doesn't quite work because the dict doesn't have ordering, but maybe there's still something we could do here.
The text was updated successfully, but these errors were encountered: