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

Method visit_enum_index_expr

mypy/checkexpr.py:4792–4803  ·  view source on GitHub ↗
(
        self, enum_type: TypeInfo, index: Expression, context: Context
    )

Source from the content-addressed store, hash-verified

4790 return make_simplified_union(value_types), set(key_names)
4791
4792 def visit_enum_index_expr(
4793 self, enum_type: TypeInfo, index: Expression, context: Context
4794 ) -> Type:
4795 string_type: Type = self.named_type("builtins.str")
4796 self.chk.check_subtype(
4797 self.accept(index),
4798 string_type,
4799 context,
4800 "Enum index should be a string",
4801 "actual index type",
4802 )
4803 return Instance(enum_type, [])
4804
4805 def visit_cast_expr(self, expr: CastExpr) -> Type:
4806 """Type check a cast expression."""

Callers 1

visit_index_with_typeMethod · 0.95

Calls 4

named_typeMethod · 0.95
acceptMethod · 0.95
InstanceClass · 0.90
check_subtypeMethod · 0.45

Tested by

no test coverage detected