@@ -18,28 +18,28 @@ def adjust_file_contents(target_file: str):
1818 file_content = file .read_text ()
1919 adjusted_import = 'from AlgorithmImports import *;from datetime import date, time, datetime, timedelta;import pandas as pd;import numpy as np;'
2020
21- tmpFile = tempfile .NamedTemporaryFile (prefix = f"{ file .name } _" , delete = False )
22- Path (tmpFile .name ).write_text ("# mypy: disable-error-code=\" no-redef\" \n " + file_content .replace ("from AlgorithmImports import *" , adjusted_import ))
23- return tmpFile
21+ tmp_file = tempfile .NamedTemporaryFile (prefix = f"{ file .name } _" , delete = False )
22+ Path (tmp_file .name ).write_text ("# mypy: disable-error-code=\" no-redef\" \n " + file_content .replace ("from AlgorithmImports import *" , adjusted_import ))
23+ return tmp_file
2424
2525def run_syntax_check (target_file : str ):
26- tmpFile = adjust_file_contents (target_file )
26+ tmp_file = adjust_file_contents (target_file )
2727 try :
28- result = run ([sys .executable , "-m" , "mypy" , "--skip-cache-mtime-checks" , "--skip-version-check" , "--show-error-codes" ,
28+ algorithm_result = run ([sys .executable , "-m" , "mypy" , "--skip-cache-mtime-checks" , "--skip-version-check" , "--show-error-codes" ,
2929 "--no-error-summary" , "--no-color-output" , "--ignore-missing-imports" , "--check-untyped-defs" , "--cache-fine-grained" , "--install-types" ,
30- "--non-interactive" , "--cache-dir" , "mypy_cache" , tmpFile .name ], capture_output = True , text = True )
30+ "--non-interactive" , "--cache-dir" , "mypy_cache" , tmp_file .name ], capture_output = True , text = True )
3131
32- print (result .stdout )
33- if result .stderr :
34- print (result .stderr )
32+ print (algorithm_result .stdout )
33+ if algorithm_result .stderr :
34+ print (algorithm_result .stderr )
3535 return False
3636 return True
3737 except :
3838 import traceback
3939 print (f"{ target_file } failed An exception occurred: { traceback .format_exc ()} " )
4040 finally :
41- tmpFile .close ()
42- os .unlink (tmpFile .name )
41+ tmp_file .close ()
42+ os .unlink (tmp_file .name )
4343 return False
4444
4545if __name__ == '__main__' :
@@ -50,4 +50,5 @@ def run_syntax_check(target_file: str):
5050 target_files = [target for target in target_files if sys .argv [1 ] in target ]
5151 result = pool .map (run_syntax_check , target_files )
5252 print (result )
53+ print (f"SUCCESS RATE { round ((sum (result ) / len (result )) * 100 , 1 )} %" )
5354 exit (0 if all (result ) else 1 )
0 commit comments