What would it take to implement type mapping for generics?

I posted a similar idea a while back: Make `@overload` less verbose - #10 by jorenham, and in false positive with `divmod` and overloaded `__divmod__` · Issue #9835 · microsoft/pyright · GitHub I explained it in a bit more detail.

Maybe we’re talking about the same thing here?

The “type mappings” I had in mind can do at least everything that overloads can do, i.e. they generalize overloads. Overloads in python are notoriously difficult, and very underspecified.

So if we’re indeed talking about the same thing here, then the PEP for these type-mappings is going to be a beefy one, and considering the current state of overloads, likely to be contentious.

I don’t mean to discourage you, but if you’re seriously considering this, then you should know what you’re getting yourself into.

2 Likes