This is offtopic here, but I think that it is better to make it a callable rather than a subscroptable: callable_type(some_func). Then it could be used as a decorator:
That looks pretty promising! I find the examples in the “Motivation” section pretty convincing. A few thoughts right off the bat:
You use the term “bidirectional inference” in the second sentence, which is quite type-theory-jargon-y. It would be good to use less jargony language or explain what the jargon means or link to a definition of the term. (Mypy also more often refers to this concept as “type context” in their documentation/codebase.)
You refer to Unknown several times, which is a pyright-specific concept. It would be better to say something like “type checker cannot infer the type of T” instead of “revealed type is list[Unknown]” – then it can apply to all type checkers equally
You say “This proposal also opens the door for runtime reflection of type parameters similar to Rust, C++ and Scala.” Discussing those concepts would be beyond the scope of the PEP, I think, but it might be good to link to an explanation of what you’re referring to here.
It might be worth noting explicitly that type checkers should be able to infer the type here if an explicit annotation is given as the “expected type” for the returned object, e.g.:
There are drawbacks to this solution: it forces users to split expressions into multiple parts, making code unnecessarily verbose. But it would be good to explicitly state in the PEP what the current solution is, and why it’s insufficient; situations where it won’t suffice, etc.
Thank you Jelle, Alex and Guido for offering to sponsor the PEP, you’re really spoiling me for choice after consulting random.choice I’m happy to say I’m picking Guido to sponsor the PEP.