@@ -200,7 +200,9 @@ def get_supported_platform():
200200 m = macosVersionString .match (plat )
201201 if m is not None and sys .platform == "darwin" :
202202 try :
203- plat = 'macosx-%s-%s' % ('.' .join (_macos_vers ()[:2 ]), m .group (3 ))
203+ major_minor = '.' .join (_macos_vers ()[:2 ])
204+ build = m .group (3 )
205+ plat = f'macosx-{ major_minor } -{ build } '
204206 except ValueError :
205207 # not macOS
206208 pass
@@ -449,12 +451,8 @@ def get_build_platform():
449451 if sys .platform == "darwin" and not plat .startswith ('macosx-' ):
450452 try :
451453 version = _macos_vers ()
452- machine = os .uname ()[4 ].replace (" " , "_" )
453- return "macosx-%d.%d-%s" % (
454- int (version [0 ]),
455- int (version [1 ]),
456- _macos_arch (machine ),
457- )
454+ machine = _macos_arch (os .uname ()[4 ].replace (" " , "_" ))
455+ return f"macosx-{ version [0 ]} .{ version [1 ]} -{ machine } "
458456 except ValueError :
459457 # if someone is running a non-Mac darwin system, this will fall
460458 # through to the default implementation
@@ -492,7 +490,7 @@ def compatible_platforms(provided: str | None, required: str | None) -> bool:
492490 provDarwin = darwinVersionString .match (provided )
493491 if provDarwin :
494492 dversion = int (provDarwin .group (1 ))
495- macosversion = "%s.%s" % ( reqMac .group (1 ), reqMac .group (2 ))
493+ macosversion = f" { reqMac .group (1 )} . { reqMac .group (2 )} "
496494 if (
497495 dversion == 7
498496 and macosversion >= "10.3"
@@ -1316,7 +1314,7 @@ def __iadd__(self, other: Distribution | Environment) -> Self:
13161314 for dist in other [project ]:
13171315 self .add (dist )
13181316 else :
1319- raise TypeError ("Can't add %r to environment" % ( other ,) )
1317+ raise TypeError (f "Can't add { other !r } to environment" )
13201318 return self
13211319
13221320 def __add__ (self , other : Distribution | Environment ) -> Self :
@@ -1699,7 +1697,7 @@ def get_metadata(self, name: str) -> str:
16991697 except UnicodeDecodeError as exc :
17001698 # Include the path in the error message to simplify
17011699 # troubleshooting, and without changing the exception type.
1702- exc .reason += ' in {} file at path: {}' . format ( name , path )
1700+ exc .reason += f ' in { name } file at path: { path } '
17031701 raise
17041702
17051703 def get_metadata_lines (self , name : str ) -> Iterator [str ]:
@@ -2018,15 +2016,15 @@ def _zipinfo_name(self, fspath):
20182016 return ''
20192017 if fspath .startswith (self .zip_pre ):
20202018 return fspath [len (self .zip_pre ) :]
2021- raise AssertionError ("%s is not a subpath of %s" % ( fspath , self .zip_pre ) )
2019+ raise AssertionError (f" { fspath } is not a subpath of { self .zip_pre } " )
20222020
20232021 def _parts (self , zip_path ):
20242022 # Convert a zipfile subpath into an egg-relative path part list.
20252023 # pseudo-fs path
20262024 fspath = self .zip_pre + zip_path
20272025 if fspath .startswith (self .egg_root + os .sep ):
20282026 return fspath [len (self .egg_root ) + 1 :].split (os .sep )
2029- raise AssertionError ("%s is not a subpath of %s" % ( fspath , self .egg_root ) )
2027+ raise AssertionError (f" { fspath } is not a subpath of { self .egg_root } " )
20302028
20312029 @property
20322030 def zipinfo (self ):
@@ -2729,15 +2727,16 @@ def __init__(
27292727 self .dist = dist
27302728
27312729 def __str__ (self ) -> str :
2732- s = "%s = %s" % ( self .name , self .module_name )
2730+ s = f" { self .name } = { self .module_name } "
27332731 if self .attrs :
27342732 s += ':' + '.' .join (self .attrs )
27352733 if self .extras :
2736- s += ' [%s]' % ',' .join (self .extras )
2734+ extras = ',' .join (self .extras )
2735+ s += f' [{ extras } ]'
27372736 return s
27382737
27392738 def __repr__ (self ) -> str :
2740- return "EntryPoint.parse(%r)" % str (self )
2739+ return f "EntryPoint.parse({ str (self )!r } )"
27412740
27422741 @overload
27432742 def load (
@@ -3049,9 +3048,7 @@ def version(self):
30493048 version = self ._get_version ()
30503049 if version is None :
30513050 path = self ._get_metadata_path_for_display (self .PKG_INFO )
3052- msg = ("Missing 'Version:' header and/or {} file at path: {}" ).format (
3053- self .PKG_INFO , path
3054- )
3051+ msg = f"Missing 'Version:' header and/or { self .PKG_INFO } file at path: { path } "
30553052 raise ValueError (msg , self ) from e
30563053
30573054 return version
@@ -3107,9 +3104,7 @@ def requires(self, extras: Iterable[str] = ()) -> list[Requirement]:
31073104 try :
31083105 deps .extend (dm [safe_extra (ext )])
31093106 except KeyError as e :
3110- raise UnknownExtra (
3111- "%s has no such extra feature %r" % (self , ext )
3112- ) from e
3107+ raise UnknownExtra (f"{ self } has no such extra feature { ext !r} " ) from e
31133108 return deps
31143109
31153110 def _get_metadata_path_for_display (self , name ):
@@ -3150,19 +3145,15 @@ def activate(self, path: list[str] | None = None, replace: bool = False) -> None
31503145
31513146 def egg_name (self ):
31523147 """Return what this distribution's standard .egg filename should be"""
3153- filename = "%s-%s-py%s" % (
3154- to_filename (self .project_name ),
3155- to_filename (self .version ),
3156- self .py_version or PY_MAJOR ,
3157- )
3148+ filename = f"{ to_filename (self .project_name )} -{ to_filename (self .version )} -py{ self .py_version or PY_MAJOR } "
31583149
31593150 if self .platform :
31603151 filename += '-' + self .platform
31613152 return filename
31623153
31633154 def __repr__ (self ) -> str :
31643155 if self .location :
3165- return "%s (%s)" % ( self , self .location )
3156+ return f" { self } ( { self .location } )"
31663157 else :
31673158 return str (self )
31683159
@@ -3172,7 +3163,7 @@ def __str__(self) -> str:
31723163 except ValueError :
31733164 version = None
31743165 version = version or "[unknown version]"
3175- return "%s %s" % ( self .project_name , version )
3166+ return f" { self .project_name } { version } "
31763167
31773168 def __getattr__ (self , attr : str ):
31783169 """Delegate all unrecognized public attributes to .metadata provider"""
@@ -3200,17 +3191,17 @@ def from_filename(
32003191 def as_requirement (self ):
32013192 """Return a ``Requirement`` that matches this distribution exactly"""
32023193 if isinstance (self .parsed_version , packaging .version .Version ):
3203- spec = "%s==%s" % ( self .project_name , self .parsed_version )
3194+ spec = f" { self .project_name } == { self .parsed_version } "
32043195 else :
3205- spec = "%s ===%s" % ( self .project_name , self . parsed_version )
3196+ spec = f" { self . project_name } ==={ self .parsed_version } "
32063197
32073198 return Requirement .parse (spec )
32083199
32093200 def load_entry_point (self , group : str , name : str ) -> _ResolvedEntryPoint :
32103201 """Return the `name` entry point of `group` or raise ImportError"""
32113202 ep = self .get_entry_info (group , name )
32123203 if ep is None :
3213- raise ImportError ("Entry point %r not found" % (( group , name ),) )
3204+ raise ImportError (f "Entry point { ( group , name )!r } not found" )
32143205 return ep .load ()
32153206
32163207 @overload
@@ -3327,8 +3318,8 @@ def check_version_conflict(self):
33273318 ):
33283319 continue
33293320 issue_warning (
3330- "Module %s was already imported from %s, but %s is being added "
3331- " to sys.path" % ( modname , fn , self . location ) ,
3321+ f "Module { modname } was already imported from { fn } , "
3322+ f"but { self . location } is being added to sys.path" ,
33323323 )
33333324
33343325 def has_version (self ) -> bool :
@@ -3512,7 +3503,7 @@ def __hash__(self) -> int:
35123503 return self .__hash
35133504
35143505 def __repr__ (self ) -> str :
3515- return "Requirement.parse(%r)" % str (self )
3506+ return f "Requirement.parse({ str (self )!r } )"
35163507
35173508 @staticmethod
35183509 def parse (s : str | Iterable [str ]) -> Requirement :
0 commit comments