Hi everyone,
I’d like to continue the discussion from our last typing summit on explicit type aliases. A quick summary of the current state and the proposal --
Current state:
```
from typing import List
x = List[int] # considered a type alias
y : Type[List[int]] = List[int] # considered an expression
z : Any # considered a type alias
z : x = [] # fine
z : y = [] # invalid type error
```
Proposal (with explicit aliases):
```
from typing import List, TypeAlias
x = TypeAlias[List[int]] # considered a type alias
y = List[int] # considered an expression
z : Any # considered an expression
z = TypeAlias[Any] # considered a type alias
reveal_type(x) # Type[List[int]]
reveal_type(y) # Any (return type of __getitem__)
z : x = [] # fine
z : y = [] # invalid type error
```
Some of the benefits we’re hoping to gain from explicit type aliases:
* Clearly distinguish between an unannotated global assignment and a type alias, especially when parsing forward-referencing string annotations.
* Avoid the confusing case of type aliases in which some part of the type is invalid or undefined. This would facilitate warnings on invalid types at the alias definition rather than later on when the alias is used.
* Make valid and invalid types more intuitive to Python programmers by shifting from delineation of non-aliases with a meta annotation toward delineation of aliases with `TypeAlias`.
* Remove special treatment of values annotated as `Any`, which currently break all type aliasing rules. This will also allow us to clean up some of the distinctions we maintain between unannotated values and explicit Anys.
Note: We also considered denoting the alias as an annotation (e.g. `x: TypeAlias = int`) as an alternative to the syntax above.
I’m interested to hear your thoughts and suggestions on making type aliasing explicit going forward – we’d like to start implementing a version of this in Pyre soon!
Shannon