Excited to slightly belatedly announce that PEP 613 is accepted! Thanks Guido for sponsoring + all of your help through the process.
Re: the generic aliases idea --
Currently Pyre doesn't properly support generic aliases... the proposed syntax sounds reasonable. This also helps solve the issue of making ordering of generics explicit for type aliases. For example, in
A = Dict[S, List[T] A: TypeAlias[S, T] = Dict[S, List[T]]
The explicit ordering is also related to classes inheriting from generic classes; Pyre has plans to require such classes to also inherit from `typing.Generic` in order to specify each type variable in the intended order. Making this explicit would help avoid quietly breaking a lot of downstream code when modifying class bases, etc.
________________________________ From: Guido van Rossum email@example.com Sent: Wednesday, January 29, 2020 11:16 PM To: Ivan Levkivskyi firstname.lastname@example.org Cc: Shannon Zhu email@example.com; firstname.lastname@example.org email@example.com Subject: [Typing-sig] Re: PEP 613: Explicit Type Aliases
So I have another idea. Not sure if this should hold up PEP 613 or be a separate one or if it's just silly.
In mypy (not sure about pyre), if you write
T = TypeVar('T') A = List[T]
then A becomes a *parametrized* type and must itself be instantiated as A[some_type], e.g. A[int] will mean List[T]. (Plain A means List[Any], unfortunately, for historic reasons.)
It's easy to forget this behavior and accidentally end up with an unintentional List[All]. Perhaps we could reinforce it by requiring
A: TypeAlias[T] = List[T]
and otherwise reject type vars in the RHS?
-- --Guido van Rossum (python.org/~guidohttps://urldefense.proofpoint.com/v2/url?u=http-3A__python.org_-7Eguido&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=j6-YRB8UY9YIqi5vSSyJ-A&m=N358pnbEzCaAYC1jS_L_4udDTyOxk-__gjDBmbbkWfI&s=6RWJuBMSMtfhxRrMfw1xxJ8Rms9lkZXb_b3GNJ4w4jc&e=) Pronouns: he/him (why is my pronoun here?)https://urldefense.proofpoint.com/v2/url?u=http-3A__feministing.com_2015_02_03_how-2Dusing-2Dthey-2Das-2Da-2Dsingular-2Dpronoun-2Dcan-2Dchange-2Dthe-2Dworld_&d=DwMFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=j6-YRB8UY9YIqi5vSSyJ-A&m=N358pnbEzCaAYC1jS_L_4udDTyOxk-__gjDBmbbkWfI&s=xLJ1aZa_ck9rAtzb4-Tjsesnn9E19_NUP_b80hKLyKo&e=