@@ -87,20 +87,20 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
87
87
if e .errno == errno .ENOENT :
88
88
continue
89
89
if verbose :
90
- print ("unable to run %s" % dispcmd )
90
+ print (f "unable to run { dispcmd } " )
91
91
print (e )
92
92
return None , None
93
93
else :
94
94
if verbose :
95
- print ("unable to find command, tried %s" % ( commands ,) )
95
+ print (f "unable to find command, tried { commands } " )
96
96
return None , None
97
97
stdout = p .communicate ()[0 ].strip ()
98
98
if sys .version_info [0 ] >= 3 :
99
99
stdout = stdout .decode ()
100
100
if p .returncode != 0 :
101
101
if verbose :
102
- print ("unable to run %s (error)" % dispcmd )
103
- print ("stdout was %s" % stdout )
102
+ print (f "unable to run { dispcmd } (error)" )
103
+ print (f "stdout was { stdout } " )
104
104
return None , p .returncode
105
105
return stdout , p .returncode
106
106
@@ -201,9 +201,9 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
201
201
# "stabilization", as well as "HEAD" and "master".
202
202
tags = set ([r for r in refs if re .search (r'\d' , r )])
203
203
if verbose :
204
- print ("discarding '%s', no digits" % "," .join (refs - tags ))
204
+ print (f "discarding '{ ',' .join (refs - tags )} ', no digits" )
205
205
if verbose :
206
- print ("likely tags: %s" % "," .join (sorted (tags )))
206
+ print (f "likely tags: { ',' .join (sorted (tags ))} " )
207
207
for ref in sorted (tags ):
208
208
# sorting will prefer e.g. "2.0" over "2.0rc1"
209
209
if ref .startswith (tag_prefix ):
@@ -214,7 +214,7 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
214
214
if not re .match (r'\d' , r ):
215
215
continue
216
216
if verbose :
217
- print ("picking %s" % r )
217
+ print (f "picking { r } " )
218
218
return {"version" : r ,
219
219
"full-revisionid" : keywords ["full" ].strip (),
220
220
"dirty" : False , "error" : None ,
@@ -243,14 +243,14 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
243
243
hide_stderr = True )
244
244
if rc != 0 :
245
245
if verbose :
246
- print ("Directory %s not under git control" % root )
246
+ print (f "Directory { root } not under git control" )
247
247
raise NotThisMethod ("'git rev-parse --git-dir' returned error" )
248
248
249
249
# if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty]
250
250
# if there isn't one, this yields HEX[-dirty] (no NUM)
251
251
describe_out , rc = run_command (GITS , ["describe" , "--tags" , "--dirty" ,
252
252
"--always" , "--long" ,
253
- "--match" , "%s*" % tag_prefix ],
253
+ "--match" , f" { tag_prefix } *" ],
254
254
cwd = root )
255
255
# --long was added in git-1.5.5
256
256
if describe_out is None :
@@ -283,8 +283,7 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
283
283
mo = re .search (r'^(.+)-(\d+)-g([0-9a-f]+)$' , git_describe )
284
284
if not mo :
285
285
# unparseable. Maybe git-describe is misbehaving?
286
- pieces ["error" ] = ("unable to parse git-describe output: '%s'"
287
- % describe_out )
286
+ pieces ["error" ] = (f"unable to parse git-describe output: '{ describe_out } '" )
288
287
return pieces
289
288
290
289
# tag
@@ -384,13 +383,13 @@ def render_pep440_post(pieces):
384
383
if pieces ["dirty" ]:
385
384
rendered += ".dev0"
386
385
rendered += plus_or_dot (pieces )
387
- rendered += "g%s" % pieces [" short" ]
386
+ rendered += f"g { pieces [' short' ] } "
388
387
else :
389
388
# exception #1
390
389
rendered = "0.post%d" % pieces ["distance" ]
391
390
if pieces ["dirty" ]:
392
391
rendered += ".dev0"
393
- rendered += "+g%s" % pieces [" short" ]
392
+ rendered += f "+g{ pieces [' short' ] } "
394
393
return rendered
395
394
396
395
@@ -481,7 +480,7 @@ def render(pieces, style):
481
480
elif style == "git-describe-long" :
482
481
rendered = render_git_describe_long (pieces )
483
482
else :
484
- raise ValueError ("unknown style '%s'" % style )
483
+ raise ValueError (f "unknown style '{ style } '" )
485
484
486
485
return {"version" : rendered , "full-revisionid" : pieces ["long" ],
487
486
"dirty" : pieces ["dirty" ], "error" : None ,
0 commit comments