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 asvetlov
Recipients asvetlov, gvanrossum, levkivskyi, yselivanov
Date 2019-12-05.16:01:20
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I thought __class_getitem__ was invented exactly to simplify generic types support.

The only thing that confuses me an example from PEP 560:

class MyList:
    def __getitem__(self, index):
        return index + 1
    def __class_getitem__(cls, item):
        return f"{cls.__name__}[{item.__name__}]"

It prevents from instantiating a generic on inheritance, e.g. the following code raises TypeError:

class MyOtherList(MyList[int]):

It would be nice if Ivan clarifies what is the best practice in this case.
I think the method should return unmodified class, not a string.
Date User Action Args
2019-12-05 16:01:20asvetlovsetrecipients: + asvetlov, gvanrossum, yselivanov, levkivskyi
2019-12-05 16:01:20asvetlovsetmessageid: <>
2019-12-05 16:01:20asvetlovlinkissue38978 messages
2019-12-05 16:01:20asvetlovcreate