@@ -92,10 +92,10 @@ def ensure_environment_is_ready(mypy_path: str, temp_repo_path: str, mypy_cache_
9292
9393
9494def initialize_repo (repo_url : str , temp_repo_path : str , branch : str ) -> None :
95- print ("Cloning repo {0 } to {1}" . format ( repo_url , temp_repo_path ) )
95+ print (f "Cloning repo { repo_url } to { temp_repo_path } " )
9696 execute (["git" , "clone" , repo_url , temp_repo_path ])
9797 if branch is not None :
98- print ("Checking out branch {}" . format ( branch ) )
98+ print (f "Checking out branch { branch } " )
9999 execute (["git" , "-C" , temp_repo_path , "checkout" , branch ])
100100
101101
@@ -110,13 +110,13 @@ def get_commits(repo_folder_path: str, commit_range: str) -> List[Tuple[str, str
110110
111111
112112def get_commits_starting_at (repo_folder_path : str , start_commit : str ) -> List [Tuple [str , str ]]:
113- print ("Fetching commits starting at {0}" . format ( start_commit ) )
114- return get_commits (repo_folder_path , '{0 }^..HEAD'. format ( start_commit ) )
113+ print (f "Fetching commits starting at { start_commit } " )
114+ return get_commits (repo_folder_path , f' { start_commit } ^..HEAD' )
115115
116116
117117def get_nth_commit (repo_folder_path : str , n : int ) -> Tuple [str , str ]:
118- print ("Fetching last {} commits (or all, if there are fewer commits than n)" . format ( n ) )
119- return get_commits (repo_folder_path , '-{}' . format ( n ) )[0 ]
118+ print (f "Fetching last { n } commits (or all, if there are fewer commits than n)" )
119+ return get_commits (repo_folder_path , f '-{ n } ' )[0 ]
120120
121121
122122def run_mypy (target_file_path : Optional [str ],
@@ -187,7 +187,7 @@ def stop_daemon() -> None:
187187
188188def load_cache (incremental_cache_path : str = CACHE_PATH ) -> JsonDict :
189189 if os .path .exists (incremental_cache_path ):
190- with open (incremental_cache_path , 'r' ) as stream :
190+ with open (incremental_cache_path ) as stream :
191191 return json .load (stream )
192192 else :
193193 return {}
@@ -213,17 +213,17 @@ def set_expected(commits: List[Tuple[str, str]],
213213 skip evaluating that commit and move on to the next."""
214214 for commit_id , message in commits :
215215 if commit_id in cache :
216- print ('Skipping commit (already cached): {0 }: "{1 }"' . format ( commit_id , message ) )
216+ print (f 'Skipping commit (already cached): { commit_id } : "{ message } "' )
217217 else :
218- print ('Caching expected output for commit {0 }: "{1 }"' . format ( commit_id , message ) )
218+ print (f 'Caching expected output for commit { commit_id } : "{ message } "' )
219219 execute (["git" , "-C" , temp_repo_path , "checkout" , commit_id ])
220220 runtime , output , stats = run_mypy (target_file_path , mypy_cache_path , mypy_script ,
221221 incremental = False )
222222 cache [commit_id ] = {'runtime' : runtime , 'output' : output }
223223 if output == "" :
224- print (" Clean output ({:.3f} sec)" . format ( runtime ) )
224+ print (f " Clean output ({ runtime :.3f} sec)" )
225225 else :
226- print (" Output ({:.3f} sec)" . format ( runtime ) )
226+ print (f " Output ({ runtime :.3f} sec)" )
227227 print_offset (output , 8 )
228228 print ()
229229
@@ -246,7 +246,7 @@ def test_incremental(commits: List[Tuple[str, str]],
246246 commits = [commits [0 ]] + commits
247247 overall_stats = {} # type: Dict[str, float]
248248 for commit_id , message in commits :
249- print ('Now testing commit {0 }: "{1 }"' . format ( commit_id , message ) )
249+ print (f 'Now testing commit { commit_id } : "{ message } "' )
250250 execute (["git" , "-C" , temp_repo_path , "checkout" , commit_id ])
251251 runtime , output , stats = run_mypy (target_file_path , mypy_cache_path , mypy_script ,
252252 incremental = True , daemon = daemon )
@@ -255,18 +255,18 @@ def test_incremental(commits: List[Tuple[str, str]],
255255 expected_output = cache [commit_id ]['output' ] # type: str
256256 if output != expected_output :
257257 print (" Output does not match expected result!" )
258- print (" Expected output ({:.3f} sec):" . format ( expected_runtime ) )
258+ print (f " Expected output ({ expected_runtime :.3f} sec):" )
259259 print_offset (expected_output , 8 )
260- print (" Actual output: ({:.3f} sec):" . format ( runtime ) )
260+ print (f " Actual output: ({ runtime :.3f} sec):" )
261261 print_offset (output , 8 )
262262 if exit_on_error :
263263 break
264264 else :
265265 print (" Output matches expected result!" )
266- print (" Incremental: {:.3f} sec" . format ( runtime ) )
267- print (" Original: {:.3f} sec" . format ( expected_runtime ) )
266+ print (f " Incremental: { runtime :.3f} sec" )
267+ print (f " Original: { expected_runtime :.3f} sec" )
268268 if relevant_stats :
269- print (" Stats: {}" . format ( relevant_stats ) )
269+ print (f " Stats: { relevant_stats } " )
270270 if overall_stats :
271271 print ("Overall stats:" , overall_stats )
272272
@@ -324,7 +324,7 @@ def test_repo(target_repo_url: str, temp_repo_path: str,
324324 elif range_type == "commit" :
325325 start_commit = range_start
326326 else :
327- raise RuntimeError ("Invalid option: {}" . format ( range_type ) )
327+ raise RuntimeError (f "Invalid option: { range_type } " )
328328 commits = get_commits_starting_at (temp_repo_path , start_commit )
329329 if params .limit :
330330 commits = commits [:params .limit ]
@@ -419,10 +419,10 @@ def main() -> None:
419419 # The path to store the mypy incremental mode cache data
420420 mypy_cache_path = os .path .abspath (os .path .join (mypy_path , "misc" , ".mypy_cache" ))
421421
422- print ("Assuming mypy is located at {0}" . format ( mypy_path ) )
423- print ("Temp repo will be cloned at {0}" . format ( temp_repo_path ) )
424- print ("Testing file/dir located at {0}" . format ( target_file_path ) )
425- print ("Using cache data located at {0}" . format ( incremental_cache_path ) )
422+ print (f "Assuming mypy is located at { mypy_path } " )
423+ print (f "Temp repo will be cloned at { temp_repo_path } " )
424+ print (f "Testing file/dir located at { target_file_path } " )
425+ print (f "Using cache data located at { incremental_cache_path } " )
426426 print ()
427427
428428 test_repo (params .repo_url , temp_repo_path , target_file_path ,
0 commit comments