Author kj
Recipients BvB93, Jelle Zijlstra, farcat, gvanrossum, kj, lars2, lukasz.langa, miss-islington, serhiy.storchaka, uriyyo
Date 2021-08-05.17:37:10
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1628185030.6.0.727079058076.issue44524@roundup.psfhosted.org>
In-reply-to
Content
@Serhiy a summary from what I understand. I hope this helps:

> I am confused. Why do these objects should have __name__ and __qualname__ attributes? What document specifies this?

I don't think any doc specifies this. The docs for __name__ and __qualname__ say they apply only to "name of the class, function, method, descriptor, or generator instance". The typing "types" are objects, not classes, so normally they wouldn't apply, but maybe there is an exception (see below).

> How are these attributes used?

According to OP, for logging/printing purposes. Initially, I was slightly against adding this. But I realized that it make sense for ABCs and concrete classes. PEP 585 says that the builtin types.GenericAlias is a "thin proxy type that forwards all method calls and attribute accesses to the bare origin type"[1] with some exceptions. typing._GenericAlias is supposed to behave similarly to builtin version.

>>> list[int].__name__
'list'
>>> collections.abc.Callable[[int], str].__name__
'Callable'

Both typing.List[int].__name__ and typing.Callable[int].__name__ raised error before Yurii's PR. So I think it's good that we aligned typing's behavior and the builtin version.

[1] https://www.python.org/dev/peps/pep-0585/#parameters-to-generics-are-available-at-runtime

I just realized Ɓukasz wrote PEP 585, so maybe he can shed some insight too.
History
Date User Action Args
2021-08-05 17:37:10kjsetrecipients: + kj, gvanrossum, farcat, lukasz.langa, serhiy.storchaka, Jelle Zijlstra, miss-islington, uriyyo, BvB93, lars2
2021-08-05 17:37:10kjsetmessageid: <1628185030.6.0.727079058076.issue44524@roundup.psfhosted.org>
2021-08-05 17:37:10kjlinkissue44524 messages
2021-08-05 17:37:10kjcreate