module documentation
(source)

Astroid hooks for type support.

Starting from python3.9, type object behaves as it had __class_getitem__ method. However it was not possible to simply add this method inside type's body, otherwise all types would also have this method. In this case it would have been possible to write str[int]. Guido Van Rossum proposed a hack to handle this in the interpreter: https://github.com/python/cpython/blob/67e394562d67cbcd0ac8114e5439494e7645b8f5/Objects/abstract.c#L181-L184

This brain follows the same logic. It is no wise to add permanently the __class_getitem__ method to the type object. Instead we choose to add it only in the case of a subscript node which inside name node is type. Doing this type[int] is allowed whereas str[int] is not.

Thanks to Lukasz Langa for fruitful discussion.

Function infer​_type​_sub Infer a type[...] subscript
Function _looks​_like​_type​_subscript Try to figure out if a Name node is used inside a type related subscript
def infer_type_sub(node, context=None): (source)
Infer a type[...] subscript
Parameters
node:astroid.nodes.node_classes.NodeNGnode to infer
context:astroid.context.InferenceContextinference context
Returns
nodes.NodeNGthe inferred node
def _looks_like_type_subscript(node): (source)
Try to figure out if a Name node is used inside a type related subscript
Parameters
node:astroid.nodes.node_classes.NodeNGnode to check
Returns
booltrue if the node is a Name node inside a type related subscript