Skip to content
4 changes: 2 additions & 2 deletions mypy/checkexpr.py
Original file line number Diff line number Diff line change
Expand Up @@ -4651,8 +4651,8 @@ def union_tuple_fallback_item(self, left_type: TupleType) -> Type:
def visit_typeddict_index_expr(
self, td_type: TypedDictType, index: Expression, setitem: bool = False
) -> tuple[Type, set[str]]:
if isinstance(index, StrExpr):
key_names = [index.value]
if isinstance(folded_index := constant_fold_expr(index, "unused"), str):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we make cur_mod_id an invalid identifier?

Suggested change
if isinstance(folded_index := constant_fold_expr(index, "unused"), str):
if isinstance(folded_index := constant_fold_expr(index, "--dummy.name--"), str):

key_names = [folded_index]
else:
typ = get_proper_type(self.accept(index))
if isinstance(typ, UnionType):
Expand Down