On Wed, Feb 3, 2021 at 11:15 AM Eric Traut <eric@traut.com> wrote:
I consider it a bug in mypy that it accepts `Tensor[()]`. Pyright does generate an error for this case. As you said, this expression causes a runtime exception. Interestingly, mypy does emit an error if you try to pass other illegal values as a type argument (like `Tensor[0]`).

I think it's because mypy internally represents "parameters absent" as an empty tuple of parameters.
 
I don't think we should promote the use of "bare" generic types — those with no type arguments. That's typically indicative of an error on the programmer's part. Pyright accepts them, but it flags it as an error when "strict" mode is enabled. This check has been really useful in helping developers to fix problems in their code, and I don't want to water it down. So I'm not in favor of saying that `Tensor` is the only legitimate way to specify "a `Tensor` whose type arguments can be anything". If we think that concept is needed, then we should support `Tensor[Any, ...]`. As I said, adding support for open-ended tuples will add yet more complexity to the specification and implementation of this PEP, but maybe it's required to meet all of the intended use cases.

Agreed. I think they are mostly a legacy feature.

--
--Guido van Rossum (python.org/~guido)