3939# Relative to top-level repo dir.
4040# CIRCUITPY-CHANGE: different directory trees
4141PATHS = [
42- # C
4342 "main.c" ,
4443 "devices/**/*.[ch]" ,
4544 "extmod/*.[ch]" ,
5251 "shared-bindings/**/*.[ch]" ,
5352 "shared-module/**/*.[ch]" ,
5453 "supervisor/**/*.[ch]" ,
55- # Python
56- "extmod/*.py" ,
57- "ports/**/*.py" ,
58- "py/**/*.py" ,
59- "tools/**/*.py" ,
60- "tests/circuitpython-*/**/*.py" ,
6154]
6255
6356# CIRCUITPY-CHANGE: different exclusions
6457EXCLUSIONS = [
6558 # STM32 build includes generated Python code.
6659 "ports/*/build*" ,
67- # gitignore in ports/unix ignores *.py, so also do it here.
68- "ports/unix/**/*.py" ,
69- # not real python files
70- "tests/**/repl_*.py" ,
7160 # don't reindent this third-party code we vendored in
7261 "ports/raspberrypi/lwip_src" ,
73- # line breaks
74- "tools/mpy-tool.py" ,
7562]
7663
7764
@@ -119,12 +106,6 @@ def transform(m):
119106TOP = os .path .abspath (os .path .join (os .path .dirname (__file__ ), ".." ))
120107
121108UNCRUSTIFY_CFG = os .path .join (TOP , "tools/uncrustify.cfg" )
122- # CIRCUITPY-CHANGE
123- C_EXTS = (
124- ".c" ,
125- ".h" ,
126- )
127- PY_EXTS = (".py" ,)
128109
129110
130111def check_uncrustify_version ():
@@ -217,14 +198,8 @@ def main():
217198 # Expand the arguments passed on the command line, subject to the PATHS and EXCLUSIONS
218199 files = list_files (args .files )
219200
220- # Extract files matching a specific language.
221- def lang_files (exts ):
222- for file in files :
223- if os .path .splitext (file )[1 ].lower () in exts :
224- yield file
225-
226201 def bindings_files ():
227- for file in lang_files ( C_EXTS ) :
202+ for file in files :
228203 if file .startswith ("shared-bindings/" ) or "/bindings/" in file :
229204 yield file
230205
@@ -248,8 +223,8 @@ def batch(cmd, files, N=200, check=False):
248223 command = ["uncrustify" , "-c" , UNCRUSTIFY_CFG , "-lC" , "--no-backup" ]
249224 if not args .v :
250225 command .append ("-q" )
251- batch (command , lang_files ( C_EXTS ) )
252- for file in lang_files ( C_EXTS ) :
226+ batch (command , files )
227+ for file in files :
253228 fixup_c (file )
254229 # Format bindings with black_bindings
255230 if format_py :
@@ -258,12 +233,13 @@ def batch(cmd, files, N=200, check=False):
258233
259234 # Format Python files with black.
260235 if format_py :
261- command = ["black " , "--fast" , "--line-length=99 " ]
236+ command = ["rust " , "format " ]
262237 if args .v :
263238 command .append ("-v" )
264239 else :
265240 command .append ("-q" )
266- batch (command , lang_files (PY_EXTS ))
241+ command .append ("." )
242+ subprocess .check_call (command , cwd = TOP )
267243
268244
269245if __name__ == "__main__" :
0 commit comments