Based on @elazarg comment on gitter:
I believe that instead of hard-coding behavior for NamedTuple and other constructs, we should make the building blocks needed to put them in a stub file. For NamedTuple we need a class that is parametrized with TypedDict, and maybe some magical "*Attributes" parameter, or maybe something else. A metaclass can replace some of the methods we've hard-coded. Perhaps we'll still need special treatment inside mypy, but we won't have problems with other mechanisms such as generic types. And the handling inside mypy won't require 100+LOC like it does today.
This was in response to my question about how to make NamedTuple support generics (#2875, #685, #1682).
I can try to do that, but wanted to get feedback first.
Also, @JelleZijlstra:
there's currently code in visit_class_def in semanal.py that treats normal classes and namedtuples in a similar but not quite identical way (I have a pending #3081 that changes it further). it's possible that just changing that code would make generic namedtuples work, but I haven't tried
Based on @elazarg comment on gitter:
This was in response to my question about how to make
NamedTuplesupport generics (#2875, #685, #1682).I can try to do that, but wanted to get feedback first.
Also, @JelleZijlstra: