MCPcopy
hub / github.com/python/mypy / visit_Subscript

Method visit_Subscript

mypy/fastparse.py:2101–2123  ·  view source on GitHub ↗
(self, n: ast3.Subscript)

Source from the content-addressed store, hash-verified

2099
2100 # Subscript(expr value, expr slice, expr_context ctx)
2101 def visit_Subscript(self, n: ast3.Subscript) -> Type:
2102 empty_tuple_index = False
2103 if isinstance(n.slice, ast3.Tuple):
2104 params = self.translate_expr_list(n.slice.elts)
2105 if len(n.slice.elts) == 0:
2106 empty_tuple_index = True
2107 else:
2108 params = [self.visit(n.slice)]
2109
2110 value = self.visit(n.value)
2111 if isinstance(value, UnboundType) and not value.args:
2112 result = UnboundType(
2113 value.name,
2114 params,
2115 line=self.line,
2116 column=value.column,
2117 empty_tuple_index=empty_tuple_index,
2118 )
2119 result.end_column = n.end_col_offset
2120 result.end_line = n.end_lineno
2121 return result
2122 else:
2123 return self.invalid_type(n)
2124
2125 def visit_Tuple(self, n: ast3.Tuple) -> Type:
2126 return TupleType(

Callers

nothing calls this directly

Calls 6

translate_expr_listMethod · 0.95
visitMethod · 0.95
invalid_typeMethod · 0.95
UnboundTypeClass · 0.90
isinstanceFunction · 0.85
lenFunction · 0.85

Tested by

no test coverage detected