File tree Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Expand file tree Collapse file tree 1 file changed +44
-0
lines changed Original file line number Diff line number Diff line change 1+ from argparse import ArgumentParser , Namespace
2+
3+ from pylint .lint import Run
4+
5+
6+ def get_configuration () -> Namespace :
7+ parser = ArgumentParser (prog = 'LINT' )
8+ parser .add_argument (
9+ '-p' ,
10+ '--path' ,
11+ help = 'path to directory you want to run pylint | ' 'Default: %(default)s | ' 'Type: %(type)s ' ,
12+ default = 'pytorch_optimizer' ,
13+ type = str ,
14+ )
15+ parser .add_argument (
16+ '-t' ,
17+ '--threshold' ,
18+ help = 'score threshold to fail pylint runner | ' 'Default: %(default)s | ' 'Type: %(type)s ' ,
19+ default = 9.5 ,
20+ type = float ,
21+ )
22+
23+ return parser .parse_args ()
24+
25+
26+ def main ():
27+ args : Namespace = get_configuration ()
28+
29+ path : str = str (args .path )
30+ threshold : float = float (args .threshold )
31+ print (f'PyLint Starting | path: { path } | threshold: { threshold :.2f} ' )
32+
33+ results = Run ([path ], do_exit = False )
34+
35+ final_score : float = results .linter .stats ['global_note' ]
36+ if final_score < threshold :
37+ print (f'PyLint Failed | score: { final_score :.2f} | threshold: { threshold :.2f} ' )
38+ raise Exception
39+ else :
40+ print (f'PyLint Passed | score: { final_score :.2f} | threshold: { threshold :.2f} ' )
41+
42+
43+ if __name__ == '__main__' :
44+ main ()
You can’t perform that action at this time.
0 commit comments