@@ -17,42 +17,47 @@ class DefaultParameters:
1717def parse_args ():
1818 parser = argparse .ArgumentParser ()
1919 parser .add_argument (
20- "-m" , "--modified-files" ,
20+ "-m" ,
21+ "--modified-files" ,
2122 type = bool ,
2223 default = DefaultParameters .modified_files ,
2324 action = argparse .BooleanOptionalAction ,
24- help = "run clang-format only on the files modified since last pushed commit"
25+ help = "run clang-format only on the files modified since last pushed commit" ,
2526 )
2627 parser .add_argument (
27- "-p" , "--search-paths" ,
28+ "-p" ,
29+ "--search-paths" ,
2830 type = str ,
2931 default = DefaultParameters .search_paths ,
3032 nargs = "*" ,
3133 action = "extend" ,
32- help = "list of search directory paths"
34+ help = "list of search directory paths" ,
3335 )
3436 parser .add_argument (
35- "-f" , "--file-patterns" ,
37+ "-f" ,
38+ "--file-patterns" ,
3639 type = str ,
3740 default = DefaultParameters .file_patterns ,
3841 nargs = "*" ,
3942 action = "extend" ,
40- help = "list of file patterns to include"
43+ help = "list of file patterns to include" ,
4144 )
4245 parser .add_argument (
43- "-e" , "--exclude-paths" ,
46+ "-e" ,
47+ "--exclude-paths" ,
4448 type = str ,
4549 default = DefaultParameters .exclude_paths ,
4650 nargs = "*" ,
4751 action = "extend" ,
48- help = "list of directory paths to exclude"
52+ help = "list of directory paths to exclude" ,
4953 )
5054 parser .add_argument (
51- "-c" , "--check" ,
55+ "-c" ,
56+ "--check" ,
5257 type = bool ,
5358 default = DefaultParameters .check ,
5459 action = argparse .BooleanOptionalAction ,
55- help = "run format check"
60+ help = "run format check" ,
5661 )
5762
5863 return vars (parser .parse_args ())
@@ -65,7 +70,7 @@ def get_modified_files(files: set[Path]) -> set[Path]:
6570 check = True ,
6671 stdout = subprocess .PIPE ,
6772 stderr = subprocess .PIPE ,
68- text = True
73+ text = True ,
6974 )
7075
7176 modified_files = {Path (file ) for file in result .stdout .splitlines () if file }
@@ -95,7 +100,9 @@ def run_clang_format(files: set[Path], check: bool) -> int:
95100 result = subprocess .run (cmd , capture_output = True , text = True )
96101 if result .returncode != 0 :
97102 return_code = result .returncode
98- print (f"[Format error]\n [stdout]\n { result .stdout } \n [stderr]\n { result .stderr } " )
103+ print (
104+ f"[Format error]\n [stdout]\n { result .stdout } \n [stderr]\n { result .stderr } "
105+ )
99106
100107 print ("Done!" )
101108 return return_code
@@ -106,7 +113,7 @@ def main(
106113 search_paths : list [str ],
107114 file_patterns : list [str ],
108115 exclude_paths : list [str ],
109- check : bool
116+ check : bool ,
110117):
111118 files_to_format = find_files (search_paths , file_patterns , exclude_paths )
112119 if modified_files :
0 commit comments