@@ -163,14 +163,14 @@ def parse(cls, location, package_only=False):
163
163
args = {}
164
164
for kw in statement .value .keywords :
165
165
arg_name = kw .arg
166
- if isinstance (kw .value , ast .Str ):
167
- args [arg_name ] = kw .value .s
166
+ if isinstance (kw .value , ast .Constant ) and isinstance ( kw . value . value , str ):
167
+ args [arg_name ] = kw .value .value
168
168
169
169
if isinstance (kw .value , ast .List ):
170
170
# We collect the elements of a list if the element is
171
171
# not a function call
172
172
args [arg_name ] = [
173
- elt .s for elt in kw .value .elts
173
+ elt .value for elt in kw .value .elts
174
174
if not isinstance (elt , ast .Call )
175
175
]
176
176
if args :
@@ -351,17 +351,17 @@ def parse(cls, location, package_only=True):
351
351
statement_keys = statement .value .keys
352
352
statement_values = statement .value .values
353
353
for statement_k , statement_v in zip (statement_keys , statement_values ):
354
- if isinstance (statement_k , ast .Str ):
355
- key_name = statement_k .s
354
+ if isinstance (statement_k , ast .Constant ) and isinstance ( statement_k . value , str ):
355
+ key_name = statement_k .value
356
356
# The list values in a `METADATA.bzl` file seem to only contain strings
357
357
if isinstance (statement_v , ast .List ):
358
358
value = []
359
359
for e in statement_v .elts :
360
- if not isinstance (e , ast .Str ):
360
+ if not ( isinstance (e , ast .Constant ) and isinstance ( e . value , str ) ):
361
361
continue
362
- value .append (e .s )
363
- if isinstance (statement_v , ( ast .Str , ast . Constant )):
364
- value = statement_v .s
362
+ value .append (e .value )
363
+ if isinstance (statement_v , ast .Constant ) and isinstance ( statement_v . value , str ):
364
+ value = statement_v .value
365
365
metadata_fields [key_name ] = value
366
366
367
367
parties = []
0 commit comments