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:
1021
1021
def _get_namedtuple_fields (self , call : CallExpr ) -> list [tuple [str , str ]] | None :
1022
1022
if self .is_namedtuple (call ):
1023
1023
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 ()
1026
1027
elif isinstance (fields_arg , (ListExpr , TupleExpr )):
1027
1028
field_names = []
1028
1029
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 ):
1030
1032
return None
1031
- field_names .append (field . value )
1033
+ field_names .append (folded )
1032
1034
else :
1033
1035
return None # Invalid namedtuple fields type
1034
1036
if field_names :
You can’t perform that action at this time.
0 commit comments