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