Message414892
There are two empty typing.Tuple. They have the same repr but are not equal.
>>> from typing import *
>>> t1 = Tuple[()]
>>> t2 = t1.copy_with(())
>>> t1
typing.Tuple[()]
>>> t2
typing.Tuple[()]
>>> t1 == t2
False
>>> t1.__args__
((),)
>>> t2.__args__
()
The only differences is that one has empty __args__, while other has __args__ containing an empty tuple. There is a code purposed to make __args__ containing an empty tuple in this case. What is the purpose?
It is not pure theoretical question. This affects unpacked TypeVarTuple substitution. With natural implementation Tuple[Unpack[Ts]][()] is not equal to Tuple[()] and I still have not figured which and where code should be added to handle this special case. It would be easier if such special case did not exist.
Built-in tuple does not have a special case:
>>> tuple[()].__args__
() |
|
Date |
User |
Action |
Args |
2022-03-11 08:21:12 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, gvanrossum, kj |
2022-03-11 08:21:12 | serhiy.storchaka | set | messageid: <1646986872.43.0.932223345125.issue46981@roundup.psfhosted.org> |
2022-03-11 08:21:12 | serhiy.storchaka | link | issue46981 messages |
2022-03-11 08:21:12 | serhiy.storchaka | create | |
|