This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author serhiy.storchaka
Recipients AlexWaygood, kumaraditya, lukasz.langa, rhettinger, serhiy.storchaka
Date 2021-12-11.14:13:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
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:32serhiy.storchakasetrecipients: + serhiy.storchaka, rhettinger, lukasz.langa, kumaraditya, AlexWaygood
2021-12-11 14:13:32serhiy.storchakasetmessageid: <>
2021-12-11 14:13:32serhiy.storchakalinkissue46032 messages
2021-12-11 14:13:32serhiy.storchakacreate