@@ -197,7 +197,7 @@ def _write_atomic(path, data, mode=0o666):
197
197
Be prepared to handle a FileExistsError if concurrent writing of the
198
198
temporary file is attempted."""
199
199
# id() is used to generate a pseudo-random filename.
200
- path_tmp = '{ }.{}' . format ( path , id (path ))
200
+ path_tmp = f' { path } .{ id (path )} '
201
201
fd = _os .open (path_tmp ,
202
202
_os .O_EXCL | _os .O_CREAT | _os .O_WRONLY , mode & 0o666 )
203
203
try :
@@ -492,8 +492,8 @@ def cache_from_source(path, debug_override=None, *, optimization=None):
492
492
optimization = str (optimization )
493
493
if optimization != '' :
494
494
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 } '
497
497
filename = almost_filename + BYTECODE_SUFFIXES [0 ]
498
498
if sys .pycache_prefix is not None :
499
499
# We need an absolute path to the py file to avoid the possibility of
@@ -651,8 +651,8 @@ def _find_module_shim(self, fullname):
651
651
# return None.
652
652
loader , portions = self .find_loader (fullname )
653
653
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 )
656
656
return loader
657
657
658
658
@@ -750,7 +750,7 @@ def _compile_bytecode(data, name=None, bytecode_path=None, source_path=None):
750
750
_imp ._fix_co_filename (code , source_path )
751
751
return code
752
752
else :
753
- raise ImportError ('Non-code object in {!r}' . format ( bytecode_path ) ,
753
+ raise ImportError (f 'Non-code object in { bytecode_path !r} ' ,
754
754
name = name , path = bytecode_path )
755
755
756
756
@@ -951,8 +951,8 @@ def exec_module(self, module):
951
951
"""Execute the module."""
952
952
code = self .get_code (module .__name__ )
953
953
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' )
956
956
_bootstrap ._call_with_frames_removed (exec , code , module .__dict__ )
957
957
958
958
def load_module (self , fullname ):
@@ -1337,7 +1337,7 @@ def __len__(self):
1337
1337
return len (self ._recalculate ())
1338
1338
1339
1339
def __repr__ (self ):
1340
- return '_NamespacePath({!r})' . format ( self . _path )
1340
+ return f '_NamespacePath({ self . _path !r} )'
1341
1341
1342
1342
def __contains__ (self , item ):
1343
1343
return item in self ._recalculate ()
@@ -1678,7 +1678,7 @@ def _fill_cache(self):
1678
1678
for item in contents :
1679
1679
name , dot , suffix = item .partition ('.' )
1680
1680
if dot :
1681
- new_name = '{ }.{}' . format ( name , suffix .lower ())
1681
+ new_name = f' { name } .{ suffix .lower ()} '
1682
1682
else :
1683
1683
new_name = name
1684
1684
lower_suffix_contents .add (new_name )
@@ -1705,7 +1705,7 @@ def path_hook_for_FileFinder(path):
1705
1705
return path_hook_for_FileFinder
1706
1706
1707
1707
def __repr__ (self ):
1708
- return 'FileFinder({!r})' . format ( self . path )
1708
+ return f 'FileFinder({ self . path !r} )'
1709
1709
1710
1710
1711
1711
# Import setup ###############################################################
0 commit comments