File tree Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Expand file tree Collapse file tree 1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change 1818from mypy .checker_shared import ExpressionCheckerSharedApi
1919from mypy .checkmember import analyze_member_access , has_operator
2020from mypy .checkstrformat import StringFormatterChecker
21+ from mypy .constant_fold import constant_fold_expr
2122from mypy .erasetype import erase_type , remove_instance_last_known_values , replace_meta_vars
2223from mypy .errors import ErrorInfo , ErrorWatcher , report_internal_error
2324from mypy .expandtype import (
@@ -4620,8 +4621,8 @@ def union_tuple_fallback_item(self, left_type: TupleType) -> Type:
46204621 def visit_typeddict_index_expr (
46214622 self , td_type : TypedDictType , index : Expression , setitem : bool = False
46224623 ) -> tuple [Type , set [str ]]:
4623- if isinstance (index , StrExpr ):
4624- key_names = [index . value ]
4624+ if isinstance (folded_index := constant_fold_expr ( index , "unused" ), str ):
4625+ key_names = [folded_index ]
46254626 else :
46264627 typ = get_proper_type (self .accept (index ))
46274628 if isinstance (typ , UnionType ):
You can’t perform that action at this time.
0 commit comments