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 Gobot1234
Recipients Gobot1234, gvanrossum, kj
Date 2022-02-13.23:49:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1644796195.73.0.52600427485.issue46743@roundup.psfhosted.org>
In-reply-to
Content
When using `__call__` on a `typing/types.GenericAlias` `__orig_class__` is set to the `GenericAlias` instance, however currently the mechanism for this does not allow the `__origin__` to access the `GenericAlias` from `__origin__.__init__` as it performs something akin to:
```py
def __call__(self, *args, **kwargs):
    object = self.__origin__(*args, **kwargs)
    object.__orig_class__ = self
    return object
```
I'd like to propose changing this to something like:
```py
def __call__(self, *args, **kwargs):
    object = self.__origin__.__new__(*args, **kwargs)
    object.__orig_class__ = self
    object.__init__(*args, **kwargs)
    return object
```
(Ideally `__orig_class__` should also be available in `__new__` but I'm not entirely sure if that's possible)

AFAICT this was possible in the typing version back in 3.6 (https://github.com/python/typing/issues/658 and maybe https://github.com/python/typing/issues/519). Was there a reason this was removed?
History
Date User Action Args
2022-02-13 23:49:55Gobot1234setrecipients: + Gobot1234, gvanrossum, kj
2022-02-13 23:49:55Gobot1234setmessageid: <1644796195.73.0.52600427485.issue46743@roundup.psfhosted.org>
2022-02-13 23:49:55Gobot1234linkissue46743 messages
2022-02-13 23:49:55Gobot1234create