@@ -197,7 +197,7 @@ def _write_atomic(path, data, mode=0o666):
197197 Be prepared to handle a FileExistsError if concurrent writing of the
198198 temporary file is attempted."""
199199 # id() is used to generate a pseudo-random filename.
200- path_tmp = '{ }.{}' . format ( path , id (path ))
200+ path_tmp = f' { path } .{ id (path )} '
201201 fd = _os .open (path_tmp ,
202202 _os .O_EXCL | _os .O_CREAT | _os .O_WRONLY , mode & 0o666 )
203203 try :
@@ -492,8 +492,8 @@ def cache_from_source(path, debug_override=None, *, optimization=None):
492492 optimization = str (optimization )
493493 if optimization != '' :
494494 if not optimization .isalnum ():
495- raise ValueError ('{ !r} is not alphanumeric'. format ( optimization ) )
496- almost_filename = '{ }.{}{}' . format ( almost_filename , _OPT , optimization )
495+ raise ValueError (f' { optimization !r} is not alphanumeric' )
496+ almost_filename = f' { almost_filename } .{ _OPT } { optimization } '
497497 filename = almost_filename + BYTECODE_SUFFIXES [0 ]
498498 if sys .pycache_prefix is not None :
499499 # We need an absolute path to the py file to avoid the possibility of
@@ -651,8 +651,8 @@ def _find_module_shim(self, fullname):
651651 # return None.
652652 loader , portions = self .find_loader (fullname )
653653 if loader is None and len (portions ):
654- msg = 'Not importing directory {}: missing __init__'
655- _warnings .warn (msg . format ( portions [ 0 ]) , ImportWarning )
654+ msg = f 'Not importing directory { portions [ 0 ] } : missing __init__'
655+ _warnings .warn (msg , ImportWarning )
656656 return loader
657657
658658
@@ -750,7 +750,7 @@ def _compile_bytecode(data, name=None, bytecode_path=None, source_path=None):
750750 _imp ._fix_co_filename (code , source_path )
751751 return code
752752 else :
753- raise ImportError ('Non-code object in {!r}' . format ( bytecode_path ) ,
753+ raise ImportError (f 'Non-code object in { bytecode_path !r} ' ,
754754 name = name , path = bytecode_path )
755755
756756
@@ -951,8 +951,8 @@ def exec_module(self, module):
951951 """Execute the module."""
952952 code = self .get_code (module .__name__ )
953953 if code is None :
954- raise ImportError ('cannot load module {!r} when get_code() '
955- 'returns None' . format ( module . __name__ ) )
954+ raise ImportError (f 'cannot load module { module . __name__ !r} when '
955+ 'get_code() returns None' )
956956 _bootstrap ._call_with_frames_removed (exec , code , module .__dict__ )
957957
958958 def load_module (self , fullname ):
@@ -1337,7 +1337,7 @@ def __len__(self):
13371337 return len (self ._recalculate ())
13381338
13391339 def __repr__ (self ):
1340- return '_NamespacePath({!r})' . format ( self . _path )
1340+ return f '_NamespacePath({ self . _path !r} )'
13411341
13421342 def __contains__ (self , item ):
13431343 return item in self ._recalculate ()
@@ -1678,7 +1678,7 @@ def _fill_cache(self):
16781678 for item in contents :
16791679 name , dot , suffix = item .partition ('.' )
16801680 if dot :
1681- new_name = '{ }.{}' . format ( name , suffix .lower ())
1681+ new_name = f' { name } .{ suffix .lower ()} '
16821682 else :
16831683 new_name = name
16841684 lower_suffix_contents .add (new_name )
@@ -1705,7 +1705,7 @@ def path_hook_for_FileFinder(path):
17051705 return path_hook_for_FileFinder
17061706
17071707 def __repr__ (self ):
1708- return 'FileFinder({!r})' . format ( self . path )
1708+ return f 'FileFinder({ self . path !r} )'
17091709
17101710
17111711# Import setup ###############################################################
0 commit comments