Skip to content

Commit 5effeab

Browse files
freundTechtushar-deepsource
authored andcommitted
Support for python 3.10 match statement (python#10191)
1 parent 132ac0d commit 5effeab

39 files changed

+3620
-133
lines changed

mypy/checker.py

+216-69
Large diffs are not rendered by default.

mypy/checkexpr.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -3077,7 +3077,11 @@ def nonliteral_tuple_index_helper(self, left_type: TupleType, index: Expression)
30773077
else:
30783078
return union
30793079

3080-
def visit_typeddict_index_expr(self, td_type: TypedDictType, index: Expression) -> Type:
3080+
def visit_typeddict_index_expr(self, td_type: TypedDictType,
3081+
index: Expression,
3082+
local_errors: Optional[MessageBuilder] = None
3083+
) -> Type:
3084+
local_errors = local_errors or self.msg
30813085
if isinstance(index, (StrExpr, UnicodeExpr)):
30823086
key_names = [index.value]
30833087
else:
@@ -3097,14 +3101,14 @@ def visit_typeddict_index_expr(self, td_type: TypedDictType, index: Expression)
30973101
and key_type.fallback.type.fullname != 'builtins.bytes'):
30983102
key_names.append(key_type.value)
30993103
else:
3100-
self.msg.typeddict_key_must_be_string_literal(td_type, index)
3104+
local_errors.typeddict_key_must_be_string_literal(td_type, index)
31013105
return AnyType(TypeOfAny.from_error)
31023106

31033107
value_types = []
31043108
for key_name in key_names:
31053109
value_type = td_type.items.get(key_name)
31063110
if value_type is None:
3107-
self.msg.typeddict_key_not_found(td_type, key_name, index)
3111+
local_errors.typeddict_key_not_found(td_type, key_name, index)
31083112
return AnyType(TypeOfAny.from_error)
31093113
else:
31103114
value_types.append(value_type)

0 commit comments

Comments
 (0)