Andrew Svetlov <andrew.svet...@gmail.com> added the comment:
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]): pass 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. ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue38978> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com