MCPcopy Index your code
hub / github.com/python/mypy / visit_index_expr

Method visit_index_expr

mypy/checkexpr.py:4489–4503  ·  view source on GitHub ↗

Type check an index expression (base[index]). It may also represent type application.

(self, e: IndexExpr)

Source from the content-addressed store, hash-verified

4487 return result
4488
4489 def visit_index_expr(self, e: IndexExpr) -> Type:
4490 """Type check an index expression (base[index]).
4491
4492 It may also represent type application.
4493 """
4494 result = self.visit_index_expr_helper(e)
4495 result = self.narrow_type_from_binder(e, result)
4496 p_result = get_proper_type(result)
4497 if (
4498 self.is_literal_context()
4499 and isinstance(p_result, Instance)
4500 and p_result.last_known_value is not None
4501 ):
4502 result = p_result.last_known_value
4503 return result
4504
4505 def visit_index_expr_helper(self, e: IndexExpr) -> Type:
4506 if e.analyzed:

Callers

nothing calls this directly

Calls 5

is_literal_contextMethod · 0.95
get_proper_typeFunction · 0.90
isinstanceFunction · 0.85

Tested by

no test coverage detected