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 BvB93, JelleZijlstra, farcat, gvanrossum, kj, lars2, lukasz.langa, miss-islington, serhiy.storchaka, uriyyo
Date 2021-08-05.10:14:04
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1628158445.0.0.0189426555578.issue44524@roundup.psfhosted.org>
In-reply-to
Content
> This PRs herein have created a situation wherein the `__name__`/`__qualname__` attributes of certain typing objects can be `None`. Is this behavior intentional?

The affected objects are special forms which can hold types, so Union[], TypeGuard[], and Concatenate[].

Personally, I don't really understand the meaning of __name__ for special forms. From the docs https://docs.python.org/3/library/stdtypes.html#definition.__name__, __name__ refers to "The name of the class, function, method, descriptor, or generator instance.". __name__ make sense for GenericAlias because it's supposed to be an almost transparent proxy to the original class (eg. typing.Callable -> collections.abc.Callable).  A special form is not really any one of those things listed in the docs (though I'm aware it's implemented using GenericAlias internally).

OTOH, Python's definition of a type and typing's are wildly different. Union[X, Y] is called a "Union type" (despite being an object), and all types ought to have __name__ ;).

@Lars, would it help your use case for Union[X, Y] and friends to have __name__ too? Note that this would mean the builtin union object (int | str) will need to support __name__ too. It looks a bit strange to me, but if it's useful I'm a +0.5 on this.

CC-ed Serhiy for his opinion too.
History
Date User Action Args
2021-08-05 10:14:05kjsetrecipients: + kj, gvanrossum, farcat, lukasz.langa, serhiy.storchaka, JelleZijlstra, miss-islington, uriyyo, BvB93, lars2
2021-08-05 10:14:05kjsetmessageid: <1628158445.0.0.0189426555578.issue44524@roundup.psfhosted.org>
2021-08-05 10:14:04kjlinkissue44524 messages
2021-08-05 10:14:04kjcreate