Ken Jin <kenjin4...@gmail.com> added the comment:
@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. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue44293> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com