Hello everybody :-)
PEP 613 appears to disallow explicit type aliases in nested scopes:
> With explicit aliases, [...] the inner assignment can either be a valid local variable or a clear error [...]
It also maybe seem to not allow for the possibility of type aliases in nested scope at all:
> [...] because type aliases cannot be defined inside a nested scope
If this was the intention of the PEP, this restriction feels unnecessary to me. Type aliases in nested scope are a valid use case. mypy previously never considered assignments in nested scopes to be type aliases, and we've had multiple issues concerning this.
Eric mentioned that as a result of this wording, Pyright errors for explicit type aliases in nested scope, but allows implicit type aliases.
I propose we loosen the wording in PEP 613. If type checkers don't wish to add support for type aliases in nested scope that seems fine, but I see no reason to prohibit this via PEP. The following code seems very clear to me in its intention (as a result of PEP 613!) and type checkers should be free to follow that intention:
```
import typing
T = typing.NewType('T', int)
class C:
V: typing.TypeAlias = T
x: C.V = C.V(5)
```
Conversely, if this proves controversial and we decide we do actually want to prohibit type aliases in nested scopes, we should probably amend PEP 484 to mention this.
Thanks to Nipunn for bringing this up!