@@ -149,11 +149,11 @@ def get_value_str(self) -> str:
149149 def __str__ (self ):
150150 if self .value is not None :
151151 if self .description :
152- return "%s(%s = %s)" % ( self .get_name_str (), self .get_value_str (), self .description )
152+ return f" { self .get_name_str ()} ( { self .get_value_str ()} = { self .description } )"
153153 else :
154- return "%s(%s)" % ( self .get_name_str (), self .get_value_str ())
154+ return f" { self .get_name_str ()} ( { self .get_value_str ()} )"
155155 else :
156- return "%s" % self .get_name_str ()
156+ return f" { self .get_name_str ()} "
157157
158158 def __repr__ (self ):
159159 return str (self )
@@ -242,7 +242,7 @@ def get_value_str(self) -> str:
242242
243243 def __str__ (self ):
244244 assert isinstance (self .value , str )
245- return "substring(%s)" % escape_string (self .value )
245+ return f "substring({ escape_string (self .value )} )"
246246
247247
248248class _MatchedSubstring (Substring ):
@@ -267,11 +267,9 @@ def __init__(self, substring: Substring, matches: Dict[str, Set[Address]]):
267267 self .matches = matches
268268
269269 def __str__ (self ):
270+ matches = ", " .join (map (lambda s : '"' + s + '"' , (self .matches or {}).keys ()))
270271 assert isinstance (self .value , str )
271- return 'substring("%s", matches = %s)' % (
272- self .value ,
273- ", " .join (map (lambda s : '"' + s + '"' , (self .matches or {}).keys ())),
274- )
272+ return f'substring("{ self .value } ", matches = { matches } )'
275273
276274
277275class Regex (String ):
@@ -290,7 +288,7 @@ def __init__(self, value: str, description=None):
290288 if value .endswith ("/i" ):
291289 value = value [: - len ("i" )]
292290 raise ValueError (
293- "invalid regular expression: %s it should use Python syntax, try it at https://pythex.org" % value
291+ f "invalid regular expression: { value } it should use Python syntax, try it at https://pythex.org"
294292 ) from exc
295293
296294 def evaluate (self , ctx , short_circuit = True ):
@@ -336,7 +334,7 @@ def evaluate(self, ctx, short_circuit=True):
336334
337335 def __str__ (self ):
338336 assert isinstance (self .value , str )
339- return "regex(string =~ %s)" % self .value
337+ return f "regex(string =~ { self .value } )"
340338
341339
342340class _MatchedRegex (Regex ):
@@ -361,11 +359,9 @@ def __init__(self, regex: Regex, matches: Dict[str, Set[Address]]):
361359 self .matches = matches
362360
363361 def __str__ (self ):
362+ matches = ", " .join (map (lambda s : '"' + s + '"' , (self .matches or {}).keys ()))
364363 assert isinstance (self .value , str )
365- return "regex(string =~ %s, matches = %s)" % (
366- self .value ,
367- ", " .join (map (lambda s : '"' + s + '"' , (self .matches or {}).keys ())),
368- )
364+ return f"regex(string =~ { self .value } , matches = { matches } )"
369365
370366
371367class StringFactory :
0 commit comments