@@ -86,20 +86,20 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
86
86
if e .errno == errno .ENOENT :
87
87
continue
88
88
if verbose :
89
- print ("unable to run %s" % dispcmd )
89
+ print (f "unable to run { dispcmd } " )
90
90
print (e )
91
91
return None , None
92
92
else :
93
93
if verbose :
94
- print ("unable to find command, tried %s" % ( commands ,) )
94
+ print (f "unable to find command, tried { commands } " )
95
95
return None , None
96
96
stdout = p .communicate ()[0 ].strip ()
97
97
if sys .version_info [0 ] >= 3 :
98
98
stdout = stdout .decode ()
99
99
if p .returncode != 0 :
100
100
if verbose :
101
- print ("unable to run %s (error)" % dispcmd )
102
- print ("stdout was %s" % stdout )
101
+ print (f "unable to run { dispcmd } (error)" )
102
+ print (f "stdout was { stdout } " )
103
103
return None , p .returncode
104
104
return stdout , p .returncode
105
105
@@ -124,8 +124,7 @@ def versions_from_parentdir(parentdir_prefix, root, verbose):
124
124
root = os .path .dirname (root ) # up a level
125
125
126
126
if verbose :
127
- print ("Tried directories %s but none started with prefix %s" %
128
- (str (rootdirs ), parentdir_prefix ))
127
+ print (f"Tried directories { rootdirs } but none started with prefix { parentdir_prefix } " )
129
128
raise NotThisMethod ("rootdir doesn't start with parentdir_prefix" )
130
129
131
130
@@ -192,15 +191,15 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
192
191
# "stabilization", as well as "HEAD" and "master".
193
192
tags = set ([r for r in refs if re .search (r'\d' , r )])
194
193
if verbose :
195
- print ("discarding '%s', no digits" % "," .join (refs - tags ))
194
+ print (f "discarding '{ ',' .join (refs - tags )} ', no digits" )
196
195
if verbose :
197
- print ("likely tags: %s" % "," .join (sorted (tags )))
196
+ print (f "likely tags: { ',' .join (sorted (tags ))} " )
198
197
for ref in sorted (tags ):
199
198
# sorting will prefer e.g., "2.0" over "2.0rc1"
200
199
if ref .startswith (tag_prefix ):
201
200
r = ref [len (tag_prefix ):]
202
201
if verbose :
203
- print ("picking %s" % r )
202
+ print (f "picking { r } " )
204
203
return {"version" : r ,
205
204
"full-revisionid" : keywords ["full" ].strip (),
206
205
"dirty" : False , "error" : None ,
@@ -229,14 +228,14 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
229
228
hide_stderr = True )
230
229
if rc != 0 :
231
230
if verbose :
232
- print ("Directory %s not under git control" % root )
231
+ print (f "Directory { root } not under git control" )
233
232
raise NotThisMethod ("'git rev-parse --git-dir' returned error" )
234
233
235
234
# if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty]
236
235
# if there isn't one, this yields HEX[-dirty] (no NUM)
237
236
describe_out , rc = run_command (GITS , ["describe" , "--tags" , "--dirty" ,
238
237
"--always" , "--long" ,
239
- "--match" , "%s*" % tag_prefix ],
238
+ "--match" , f" { tag_prefix } *" ],
240
239
cwd = root )
241
240
# --long was added in git-1.5.5
242
241
if describe_out is None :
@@ -269,18 +268,16 @@ def git_pieces_from_vcs(tag_prefix, root, verbose, run_command=run_command):
269
268
mo = re .search (r'^(.+)-(\d+)-g([0-9a-f]+)$' , git_describe )
270
269
if not mo :
271
270
# unparseable. Maybe git-describe is misbehaving?
272
- pieces ["error" ] = ("unable to parse git-describe output: '%s'"
273
- % describe_out )
271
+ pieces ["error" ] = f"unable to parse git-describe output: '{ describe_out } '"
274
272
return pieces
275
273
276
274
# tag
277
275
full_tag = mo .group (1 )
278
276
if not full_tag .startswith (tag_prefix ):
279
277
if verbose :
280
- fmt = "tag '%s' doesn't start with prefix '%s'"
281
- print (fmt % (full_tag , tag_prefix ))
282
- pieces ["error" ] = ("tag '%s' doesn't start with prefix '%s'"
283
- % (full_tag , tag_prefix ))
278
+ print (
279
+ f"tag '{ full_tag } ' doesn't start with prefix '{ tag_prefix } '" )
280
+ pieces ["error" ] = (f"tag '{ full_tag } ' doesn't start with prefix '{ tag_prefix } '"
284
281
return pieces
285
282
pieces ["closest-tag" ] = full_tag [len (tag_prefix ):]
286
283
@@ -370,13 +367,13 @@ def render_pep440_post(pieces):
370
367
if pieces ["dirty" ]:
371
368
rendered += ".dev0"
372
369
rendered += plus_or_dot (pieces )
373
- rendered += "g%s" % pieces [" short" ]
370
+ rendered += f"g { pieces [' short' ] } "
374
371
else :
375
372
# exception #1
376
373
rendered = "0.post%d" % pieces ["distance" ]
377
374
if pieces ["dirty" ]:
378
375
rendered += ".dev0"
379
- rendered += "+g%s" % pieces [" short" ]
376
+ rendered += f "+g{ pieces [' short' ] } "
380
377
return rendered
381
378
382
379
@@ -467,7 +464,7 @@ def render(pieces, style):
467
464
elif style == "git-describe-long" :
468
465
rendered = render_git_describe_long (pieces )
469
466
else :
470
- raise ValueError ("unknown style '%s'" % style )
467
+ raise ValueError (f "unknown style '{ style } '" )
471
468
472
469
return {"version" : rendered , "full-revisionid" : pieces ["long" ],
473
470
"dirty" : pieces ["dirty" ], "error" : None ,
0 commit comments