Lines Matching refs:__class_getitem__
2218 class method ``__class_getitem__()``.
2220 .. classmethod:: object.__class_getitem__(cls, key)
2225 When defined on a class, ``__class_getitem__()`` is automatically a class
2230 The purpose of *__class_getitem__*
2233 The purpose of :meth:`~object.__class_getitem__` is to allow runtime
2239 library class that already implements :meth:`~object.__class_getitem__`, or
2241 ``__class_getitem__()``.
2243 Custom implementations of :meth:`~object.__class_getitem__` on classes defined
2245 type-checkers such as mypy. Using ``__class_getitem__()`` on any class for
2252 *__class_getitem__* versus *__getitem__*
2258 the class method :meth:`~object.__class_getitem__` may be called instead.
2259 ``__class_getitem__()`` should return a :ref:`GenericAlias<types-genericalias>`
2264 :meth:`~object.__getitem__` or :meth:`~object.__class_getitem__` should be
2279 # Else, if obj is a class and defines __class_getitem__,
2280 # call obj.__class_getitem__(x)
2281 elif isclass(obj) and hasattr(obj, '__class_getitem__'):
2282 return obj.__class_getitem__(x)
2295 :meth:`~object.__class_getitem__` being called::
2302 >>> # "list[int]" calls "list.__class_getitem__(int)"
2305 >>> # list.__class_getitem__ returns a GenericAlias object:
2323 >>> # so __class_getitem__ is not called,
2333 Introducing :meth:`~object.__class_getitem__`, and outlining when a
2334 :ref:`subscription<subscriptions>` results in ``__class_getitem__()``
2458 class method :meth:`~object.__class_getitem__` may be called instead of