[issue46743] Enable usage of object.__orig_class__ in __init__

2022-02-14 Thread Guido van Rossum
Guido van Rossum added the comment: Yeah, that should erase the type, not have special semantics. -- ___ Python tracker ___ ___

[issue46743] Enable usage of object.__orig_class__ in __init__

2022-02-14 Thread Gobot1234
Gobot1234 added the comment: > Which classes? Every class that inherits from Generic? That would be > problematic -- we don't want the addition of typing information to change the > behavior of a construct (or at least as little as possible). The class itself would remain unchanged, the

[issue46743] Enable usage of object.__orig_class__ in __init__

2022-02-14 Thread Guido van Rossum
Guido van Rossum added the comment: > On the general class instanciation point would there be anything wrong with > just adding a big red warning saying (on the non-existent) docs for these > classes that they don't follow normal class initization or is this too > insignificant of an issue

[issue46743] Enable usage of object.__orig_class__ in __init__

2022-02-14 Thread Gobot1234
Gobot1234 added the comment: On the general class instanciation point would there be anything wrong with just adding a big red warning saying (on the non-existent) docs for these classes that they don't follow normal class initization or is this too insignificant of an issue to bother? > I

[issue46743] Enable usage of object.__orig_class__ in __init__

2022-02-13 Thread Mehdi2277
Mehdi2277 added the comment: Hmm, I actually have code that does something very similar to that. But it does not set it in `__init__` and instead uses it in a property where it is available. Tweaking your code, ```py class DefaultBox(Generic[T]): def __init__(self, value: T | None =

[issue46743] Enable usage of object.__orig_class__ in __init__

2022-02-13 Thread Guido van Rossum
Guido van Rossum added the comment: Thanks for the small example, I understand what you are trying to do now. I don't think it's possible in general, since you are blindly instantiating the type (self.__orig_class__.__args__[0]) without arguments. That doesn't work for all types. But that

[issue46743] Enable usage of object.__orig_class__ in __init__

2022-02-13 Thread Alex Waygood
Change by Alex Waygood : -- nosy: +AlexWaygood ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46743] Enable usage of object.__orig_class__ in __init__

2022-02-13 Thread Jelle Zijlstra
Change by Jelle Zijlstra : -- nosy: +Jelle Zijlstra ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue46743] Enable usage of object.__orig_class__ in __init__

2022-02-13 Thread Gobot1234
Gobot1234 added the comment: ```py class DefaultBox(Generic[T]): def __init__(self, value: T | None = None): self.value = ( value if value is not None else # the arg self.__orig_class__.__args__[0]() # or the default for the type argument )

[issue46743] Enable usage of object.__orig_class__ in __init__

2022-02-13 Thread Guido van Rossum
Guido van Rossum added the comment: I'm sorry, that's not a small example that I can follow, and I have no idea why you are doing all those things. I fear that if you cannot be more articulate this will remain unfixed. -- ___ Python tracker

[issue46743] Enable usage of object.__orig_class__ in __init__

2022-02-13 Thread Gobot1234
Gobot1234 added the comment: Currently I have code that uses the generic argument to a class as the constructor for its `items` https://github.com/Gobot1234/steam.py/blob/f99cb77d58b552f1d493663e7b3455f94977347e/steam/trade.py#L380. As this is called from `BaseInventory.__init__` it

[issue46743] Enable usage of object.__orig_class__ in __init__

2022-02-13 Thread Guido van Rossum
Guido van Rossum added the comment: In the early days the design and implementation were changed so many times, your question (why was it changed) is unanswerable. I do not actually understand your description of your problem -- you mention so many dunders that it obscures your use case.

[issue46743] Enable usage of object.__orig_class__ in __init__

2022-02-13 Thread Gobot1234
New submission from Gobot1234 : 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