Skip to content

Commit 14cb040

Browse files
committed
partially revert #2812
1 parent 7abf8f4 commit 14cb040

File tree

1 file changed

+0
-13
lines changed

1 file changed

+0
-13
lines changed

mypy/checkexpr.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1454,9 +1454,6 @@ def visit_index_expr_helper(self, e: IndexExpr) -> Type:
14541454
return AnyType()
14551455
elif isinstance(left_type, TypedDictType):
14561456
return self.visit_typeddict_index_expr(left_type, e.index)
1457-
elif (isinstance(left_type, CallableType)
1458-
and left_type.is_type_obj() and left_type.type_object().is_enum):
1459-
return self.visit_enum_index_expr(left_type.type_object(), e.index, e)
14601457
else:
14611458
result, method_type = self.check_op('__getitem__', left_type, e.index, e)
14621459
e.method_type = method_type
@@ -1515,16 +1512,6 @@ def visit_typeddict_index_expr(self, td_type: TypedDictType, index: Expression)
15151512
return AnyType()
15161513
return item_type
15171514

1518-
def visit_enum_index_expr(self, enum_type: TypeInfo, index: Expression,
1519-
context: Context) -> Type:
1520-
string_type = self.named_type('builtins.str') # type: Type
1521-
if self.chk.options.python_version[0] < 3:
1522-
string_type = UnionType.make_union([string_type,
1523-
self.named_type('builtins.unicode')])
1524-
self.chk.check_subtype(self.accept(index), string_type, context,
1525-
"Enum index should be a string", "actual index type")
1526-
return Instance(enum_type, [])
1527-
15281515
def visit_cast_expr(self, expr: CastExpr) -> Type:
15291516
"""Type check a cast expression."""
15301517
source_type = self.accept(expr.expr, type_context=AnyType())

0 commit comments

Comments
 (0)