@@ -84,7 +84,7 @@ def _download_and_cache_classifiers():
8484def _verify_classifiers (classifiers , valid_classifiers ):
8585 """Check classifiers against a set of known classifiers"""
8686 invalid = classifiers - valid_classifiers
87- return ["Unrecognised classifier: {!r}" . format ( c )
87+ return [f "Unrecognised classifier: { c !r} "
8888 for c in sorted (invalid )]
8989
9090
@@ -152,8 +152,7 @@ def _is_identifier_attr(s):
152152 valid = _is_identifier_attr (v )
153153
154154 if not valid :
155- problems .append ('Invalid entry point in group {}: '
156- '{} = {}' .format (groupname , k , v ))
155+ problems .append (f'Invalid entry point in group { groupname } : { k } = { v } ' )
157156 return problems
158157
159158# Distribution name, not quite the same as a Python identifier
@@ -171,7 +170,7 @@ def validate_name(metadata):
171170 name = metadata .get ('name' , None )
172171 if name is None or NAME .match (name ):
173172 return []
174- return ['Invalid name: {!r}' . format ( name ) ]
173+ return [f 'Invalid name: { name !r} ' ]
175174
176175
177176def _valid_version_specifier (s ):
@@ -184,7 +183,7 @@ def validate_requires_python(metadata):
184183 spec = metadata .get ('requires_python' , None )
185184 if spec is None or _valid_version_specifier (spec ):
186185 return []
187- return ['Invalid requires-python: {!r}' . format ( spec ) ]
186+ return [f 'Invalid requires-python: { spec !r} ' ]
188187
189188MARKER_VARS = {
190189 'python_version' , 'python_full_version' , 'os_name' , 'sys_platform' ,
@@ -200,38 +199,37 @@ def validate_environment_marker(em):
200199 # TODO: validate parentheses properly. They're allowed by PEP 508.
201200 parts = MARKER_OP .split (c .strip ('()' ))
202201 if len (parts ) != 3 :
203- problems .append ("Invalid expression in environment marker: {!r}" . format ( c ) )
202+ problems .append (f "Invalid expression in environment marker: { c !r} " )
204203 continue
205204 l , op , r = parts
206205 for var in (l .strip (), r .strip ()):
207206 if var [:1 ] in {'"' , "'" }:
208207 if len (var ) < 2 or var [- 1 :] != var [:1 ]:
209- problems .append ("Invalid string in environment marker: {}" . format ( var ) )
208+ problems .append (f "Invalid string in environment marker: { var } " )
210209 elif var not in MARKER_VARS :
211- problems .append ("Invalid variable name in environment marker: {!r}" . format ( var ) )
210+ problems .append (f "Invalid variable name in environment marker: { var !r} " )
212211 return problems
213212
214213def validate_requires_dist (metadata ):
215214 probs = []
216215 for req in metadata .get ('requires_dist' , []):
217216 m = REQUIREMENT .match (req )
218217 if not m :
219- probs .append ("Could not parse requirement: {!r}" . format ( req ) )
218+ probs .append (f "Could not parse requirement: { req !r} " )
220219 continue
221220
222221 extras , version , envmark = m .group ('extras' , 'version' , 'envmark' )
223222 if not (extras is None or all (NAME .match (e .strip ())
224223 for e in extras [1 :- 1 ].split (',' ))):
225- probs .append ("Invalid extras in requirement: {!r}" . format ( req ) )
224+ probs .append (f "Invalid extras in requirement: { req !r} " )
226225 if version is not None :
227226 if version .startswith ('(' ) and version .endswith (')' ):
228227 version = version [1 :- 1 ]
229228 if version .startswith ('@' ):
230229 pass # url specifier TODO: validate URL
231230 elif not _valid_version_specifier (version ):
232231 print ((extras , version , envmark ))
233- probs .append ("Invalid version specifier {!r} in requirement {!r}"
234- .format (version , req ))
232+ probs .append (f"Invalid version specifier { version !r} in requirement { req !r} " )
235233 if envmark is not None :
236234 probs .extend (validate_environment_marker (envmark [1 :]))
237235 return probs
@@ -241,8 +239,7 @@ def validate_url(url):
241239 return []
242240 probs = []
243241 if not url .startswith (('http://' , 'https://' )):
244- probs .append ("URL {!r} doesn't start with https:// or http://"
245- .format (url ))
242+ probs .append (f"URL { url !r} doesn't start with https:// or http://" )
246243 elif not url .split ('//' , 1 )[1 ]:
247244 probs .append ("URL missing address" )
248245 return probs
@@ -253,10 +250,9 @@ def validate_project_urls(metadata):
253250 name , url = prurl .split (',' , 1 )
254251 url = url .lstrip ()
255252 if not name :
256- probs .append ("No name for project URL {!r}" . format ( url ) )
253+ probs .append (f "No name for project URL { url !r} " )
257254 elif len (name ) > 32 :
258- probs .append ("Project URL name {!r} longer than 32 characters"
259- .format (name ))
255+ probs .append (f"Project URL name { name !r} longer than 32 characters" )
260256 probs .extend (validate_url (url ))
261257
262258 return probs
0 commit comments