@@ -139,15 +139,15 @@ def Fire(component=None, command=None, name=None, serialize=None):
139
139
_DisplayError (component_trace )
140
140
raise FireExit (2 , component_trace )
141
141
if component_trace .show_trace and component_trace .show_help :
142
- output = ['Fire trace:\n {trace }\n ' . format ( trace = component_trace ) ]
142
+ output = [f 'Fire trace:\n { component_trace } \n ' ]
143
143
result = component_trace .GetResult ()
144
144
help_text = helptext .HelpText (
145
145
result , trace = component_trace , verbose = component_trace .verbose )
146
146
output .append (help_text )
147
147
Display (output , out = sys .stderr )
148
148
raise FireExit (0 , component_trace )
149
149
if component_trace .show_trace :
150
- output = ['Fire trace:\n {trace}' . format ( trace = component_trace ) ]
150
+ output = [f 'Fire trace:\n { component_trace } ' ]
151
151
Display (output , out = sys .stderr )
152
152
raise FireExit (0 , component_trace )
153
153
if component_trace .show_help :
@@ -231,9 +231,9 @@ def _IsHelpShortcut(component_trace, remaining_args):
231
231
232
232
if show_help :
233
233
component_trace .show_help = True
234
- command = '{cmd } -- --help'. format ( cmd = component_trace . GetCommand ())
235
- print ('INFO: Showing help with the command {cmd }.\n ' . format (
236
- cmd = shlex . quote ( command )), file = sys .stderr )
234
+ command = f' { component_trace . GetCommand () } -- --help'
235
+ print (f 'INFO: Showing help with the command { shlex . quote ( command ) } .\n ',
236
+ file = sys .stderr )
237
237
return show_help
238
238
239
239
@@ -287,9 +287,9 @@ def _DisplayError(component_trace):
287
287
show_help = True
288
288
289
289
if show_help :
290
- command = '{cmd } -- --help'. format ( cmd = component_trace . GetCommand ())
291
- print ('INFO: Showing help with the command {cmd }.\n ' . format (
292
- cmd = shlex . quote ( command )), file = sys .stderr )
290
+ command = f' { component_trace . GetCommand () } -- --help'
291
+ print (f 'INFO: Showing help with the command { shlex . quote ( command ) } .\n ',
292
+ file = sys .stderr )
293
293
help_text = helptext .HelpText (result , trace = component_trace ,
294
294
verbose = component_trace .verbose )
295
295
output .append (help_text )
@@ -327,14 +327,13 @@ def _DictAsString(result, verbose=False):
327
327
return '{}'
328
328
329
329
longest_key = max (len (str (key )) for key in result_visible .keys ())
330
- format_string = '{{key:{padding }s}} {{value}}' . format ( padding = longest_key + 1 )
330
+ format_string = f '{{key:{ longest_key + 1 } s}} {{value}}'
331
331
332
332
lines = []
333
333
for key , value in result .items ():
334
334
if completion .MemberVisible (result , key , value , class_attrs = class_attrs ,
335
335
verbose = verbose ):
336
- line = format_string .format (key = str (key ) + ':' ,
337
- value = _OneLineResult (value ))
336
+ line = format_string .format (key = f'{ key } :' , value = _OneLineResult (value ))
338
337
lines .append (line )
339
338
return '\n ' .join (lines )
340
339
@@ -348,10 +347,10 @@ def _OneLineResult(result):
348
347
# TODO(dbieber): Show a small amount of usage information about the function
349
348
# or module if it fits cleanly on the line.
350
349
if inspect .isfunction (result ):
351
- return '<function {name}>' . format ( name = result .__name__ )
350
+ return f '<function { result .__name__ } >'
352
351
353
352
if inspect .ismodule (result ):
354
- return '<module {name}>' . format ( name = result .__name__ )
353
+ return f '<module { result .__name__ } >'
355
354
356
355
try :
357
356
# Don't force conversion to ascii.
@@ -890,9 +889,10 @@ def _ParseKeywordArgs(args, fn_spec):
890
889
if len (matching_fn_args ) == 1 :
891
890
keyword = matching_fn_args [0 ]
892
891
elif len (matching_fn_args ) > 1 :
893
- raise FireError ("The argument '{}' is ambiguous as it could "
894
- "refer to any of the following arguments: {}" .format (
895
- argument , matching_fn_args ))
892
+ raise FireError (
893
+ f"The argument '{ argument } ' is ambiguous as it could "
894
+ f"refer to any of the following arguments: { matching_fn_args } "
895
+ )
896
896
897
897
# Determine the value.
898
898
if not keyword :
0 commit comments