Message408306
Yes, it is related to issue45665. It is a complicated case due to coincidence of several circumstances.
1. isinstance(list[int], type) is True, while isinstance(typing.List[int], type) is False. list[int] is considered a type in this check.
2. list[int].__mro__ == list.__mro__, while typing.List[int] does not have the __mro__ attribute. list[int] is considered a type in this check.
3. issubclass(cls, list[int]) raises a TypeError (the same for typing.List[int]). list[int] cannot be used as a type here.
4. 2-argument registry() does not check the type of its first argument. f.registry(42, ...) is silently passed.
In 2-argument registry() typing.List[int] is passed due to (4) and ignored in dispatch() due to (2). list[int] is passed due to (4), but caused error due to (3).
In other uses of registry() (1-argument decorator factory and decorator with annotations) typing.List[int] is not passed due to 1. list[int] is passed due to (1) and caused error due to (3).
The proposed PR makes list[int] be treated the same way as typing.List[int]. It also makes 2-argument registry() rejecting invalid first argument, so all three forms of registry() accept and reject now the same types. |
|
Date |
User |
Action |
Args |
2021-12-11 14:13:32 | serhiy.storchaka | set | recipients:
+ serhiy.storchaka, rhettinger, lukasz.langa, kumaraditya, AlexWaygood |
2021-12-11 14:13:32 | serhiy.storchaka | set | messageid: <1639232012.5.0.575825911453.issue46032@roundup.psfhosted.org> |
2021-12-11 14:13:32 | serhiy.storchaka | link | issue46032 messages |
2021-12-11 14:13:32 | serhiy.storchaka | create | |
|