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 kj
Recipients JelleZijlstra, gvanrossum, joperez, kj, levkivskyi
Date 2021-06-03.13:51:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1622728285.9.0.278900267421.issue44293@roundup.psfhosted.org>
In-reply-to
Content
@Jelle thanks for nosy-ing me too and the thorough investigation.

@Joseph

Thanks for taking the time to raise this inconvenience on the bug tracker.

> By the way, Python typing is so much unstable (every version breaks the previous one), it's very complicated to write code that support multiple versions, so whatever the typing internal implementation, we must adapt.

Compared to some of the more mature modules in Python, I have to agree that typing.py is mildly unstable. However, you're not supposed to be using/importing from the internal constructs - those have no guarantee of stability. If you feel some common use cases aren't met by the current introspection helpers, please please please create a new issue for that and we'll consider it. How we use typing may differ from how you use it and so there's a lot we don't see. User bug reports and feedback have helped to surface such issues and improved typing for everyone :). 

> I have chosen `list[int]` as an example of `types.GenericAlias` introduced by PEP 585 (i could have chosen `set[int]` or `collections.abc.Collection[int]`). But other generic aliases, e.g. `typing.List[int]` or `MyClass[int]` (where `MyClass` inherits `Generic[T]`), are not instances of `type`.

This is an implementation detail. Most typing PEPs don't usually specify the runtime behavior in detail because most of them focus on static analysis. The implementation is usually up to the contributor's judgement. FWIW, to accommodate the new 3.9 GenericAlias, typing.py just added additional checks for `isinstance(tp, types.GenericAlias)` instead of checking only for `isinstance(tp, type)` and friends.
History
Date User Action Args
2021-06-03 13:51:25kjsetrecipients: + kj, gvanrossum, levkivskyi, JelleZijlstra, joperez
2021-06-03 13:51:25kjsetmessageid: <1622728285.9.0.278900267421.issue44293@roundup.psfhosted.org>
2021-06-03 13:51:25kjlinkissue44293 messages
2021-06-03 13:51:25kjcreate