Message413198
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? |
|
Date |
User |
Action |
Args |
2022-02-13 23:49:55 | Gobot1234 | set | recipients:
+ Gobot1234, gvanrossum, kj |
2022-02-13 23:49:55 | Gobot1234 | set | messageid: <1644796195.73.0.52600427485.issue46743@roundup.psfhosted.org> |
2022-02-13 23:49:55 | Gobot1234 | link | issue46743 messages |
2022-02-13 23:49:55 | Gobot1234 | create | |
|