On Tue, 30 Jul 2019 at 17:44, Guido van Rossum <guido@python.org> wrote:
[...] MyAlias: TypeAlias = int This is nice because it's a simple transformation from old style to new style: just like annotating a variable with a type, here we are annotating an alias (a variable at the meta-level) with a type (a meta-type). That makes it my favorite, with the first one (MyAlias = TypeAlias[int]) as the runner-up.
I don't have any preference between x: TypeAlias = int and x = TypeAlias[int]. I like the general idea of allowing the explicit form in parallel to the existing implicit syntax. The problem that currently exists is that there are few corner cases where mypy decides between a variable of type Type[C] and an alias to C (moreover the rules are still undocumented, see https://github.com/python/mypy/issues/3494). For example: class C: ... x = C # this is a type alias from mypy point of view class D: x = C # this is a variable with type Type[C] This default behaviour is kind of a heuristics that matches most typical use in each case, but I think it would be nice to have a simple way to be explicit either way: x: TypeAlias = C y: Type[C] = C -- Ivan