File tree Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Expand file tree Collapse file tree 1 file changed +6
-4
lines changed Original file line number Diff line number Diff line change @@ -1021,14 +1021,16 @@ def is_typed_namedtuple(self, expr: CallExpr) -> bool:
10211021 def _get_namedtuple_fields (self , call : CallExpr ) -> list [tuple [str , str ]] | None :
10221022 if self .is_namedtuple (call ):
10231023 fields_arg = call .args [1 ]
1024- if isinstance (fields_arg , StrExpr ):
1025- field_names = fields_arg .value .replace ("," , " " ).split ()
1024+ folded = constant_fold_expr (fields_arg , "unused" )
1025+ if isinstance (folded , str ):
1026+ field_names = folded .replace ("," , " " ).split ()
10261027 elif isinstance (fields_arg , (ListExpr , TupleExpr )):
10271028 field_names = []
10281029 for field in fields_arg .items :
1029- if not isinstance (field , StrExpr ):
1030+ folded = constant_fold_expr (fields_arg , "unused" )
1031+ if not isinstance (folded , str ):
10301032 return None
1031- field_names .append (field . value )
1033+ field_names .append (folded )
10321034 else :
10331035 return None # Invalid namedtuple fields type
10341036 if field_names :
You can’t perform that action at this time.
0 commit comments