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 AlexWaygood, Gobot1234, JelleZijlstra, gvanrossum, kj, med2277
Date 2022-02-14.11:06:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1644836767.59.0.860191212667.issue46743@roundup.psfhosted.org>
In-reply-to
Content
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 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.

I think you could make this work with a Protocol as the bound TypeVar("T", bound=HasTheCorrectNewSignature)?

> I'm also not sure what static type checkers would make of this. But I presume you don't care about that.

Yeah considering this is only accessed in one place and how likely difficult it would be to implement it doesn't bother me much no. (You can avoid the attribute access errors using __orig_class__: GenericAlias if you know what your doing is always safe).

> Or is the main goal that the original code is simpler then this lazy initialization workaround.

Pretty much yeah I'd like the code to be much simplier and avoid this work around (although you could probably simplify it with a cached_property)
History
Date User Action Args
2022-02-14 11:06:07Gobot1234setrecipients: + Gobot1234, gvanrossum, JelleZijlstra, kj, AlexWaygood, med2277
2022-02-14 11:06:07Gobot1234setmessageid: <1644836767.59.0.860191212667.issue46743@roundup.psfhosted.org>
2022-02-14 11:06:07Gobot1234linkissue46743 messages
2022-02-14 11:06:07Gobot1234create