@@ -214,16 +214,24 @@ def lang_files(exts):
214214 if os .path .splitext (file )[1 ].lower () in exts :
215215 yield file
216216
217+ def bindings_files ():
218+ for file in lang_files (C_EXTS ):
219+ if file .startswith ("shared-bindings/" ) or "/bindings/" in file :
220+ yield file
221+
217222 # Run tool on N files at a time (to avoid making the command line too long).
218- def batch (cmd , files , N = 200 ):
223+ def batch (cmd , files , N = 200 , check = False ):
219224 while True :
220225 file_args = list (itertools .islice (files , N ))
221226 if not file_args :
222227 break
223228 if args .dry_run :
224229 print (" " .join (cmd + file_args ))
225230 else :
226- subprocess .call (cmd + file_args )
231+ if check :
232+ subprocess .check_call (cmd + file_args )
233+ else :
234+ subprocess .run (cmd + file_args )
227235
228236 # Format C files with uncrustify.
229237 if format_c :
@@ -234,6 +242,10 @@ def batch(cmd, files, N=200):
234242 batch (command , lang_files (C_EXTS ))
235243 for file in lang_files (C_EXTS ):
236244 fixup_c (file )
245+ # Format bindings with black_bindings
246+ if format_py :
247+ command = ["python3" , "tools/black_bindings.py" ]
248+ batch (command , bindings_files (), check = True )
237249
238250 # Format Python files with black.
239251 if format_py :
0 commit comments