[issue47006] PEP 646: Decide on substitution behavior

Serhiy Storchaka report at bugs.python.org
Sat Mar 19 11:32:54 EDT 2022


Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

I am for consistent behavior. If return GenericAlias(GenericAlias(tuple, Unpack[Ts]), (int, str)) for tuple[*Ts][int, str], we should also return GenericAlias(GenericAlias(list, T), int) for list[T][int], etc. And it will cause multiple problems:

* A repr can be less readable.
* It will break equality comparison and hashing. Good bye caching.
* What about __origin__, __parameters__, __args__? How will they be calculated?
* It can break code which uses annotations for something. For example it can break dataclasses.

It may be that will need to use it as a fallback for cases like tuple[T, *Ts][*Ts2] (currently it is error). But I am not sure that such cases should be supported.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue47006>
_______________________________________


More information about the Python-bugs-list mailing list