@@ -53,13 +53,16 @@ are then certifying and signing off against the following:
53
53
Code auto-formatting
54
54
====================
55
55
56
- Both C and Python code are auto-formatted using the ` tools/codeformat.py `
57
- script. This uses [ uncrustify] ( https://github.com/uncrustify/uncrustify ) to
58
- format C code and [ black] ( https://github.com/psf/black ) to format Python code.
59
- After making changes, and before committing, run this tool to reformat your
60
- changes to the correct style. Without arguments this tool will reformat all
61
- source code (and may take some time to run). Otherwise pass as arguments to
62
- the tool the files that changed and it will only reformat those.
56
+ Both C and Python code formatting are controlled for consistency across the
57
+ MicroPython codebase. C code is formatted using the ` tools/codeformat.py `
58
+ script which uses [ uncrustify] ( https://github.com/uncrustify/uncrustify ) .
59
+ Python code is linted and formatted using
60
+ [ ruff & ruff format] ( https://github.com/astral-sh/ruff ) .
61
+ After making changes, and before committing, run ` tools/codeformat.py ` to
62
+ reformat your C code and ` ruff format ` for any Python code. Without
63
+ arguments this tool will reformat all source code (and may take some time
64
+ to run). Otherwise pass as arguments to the tool the files that changed,
65
+ and it will only reformat those.
63
66
64
67
uncrustify
65
68
==========
@@ -151,12 +154,22 @@ Tips:
151
154
* To ignore the pre-commit message format check temporarily, start the commit
152
155
message subject line with "WIP" (for "Work In Progress").
153
156
157
+ Running pre-commit manually
158
+ ===========================
159
+
160
+ Once pre-commit is installed as per the previous section it can be manually
161
+ run against the MicroPython python codebase to update file formatting on
162
+ demand, with either:
163
+ * ` pre-commit run --all-files ` to fix all files in the MicroPython codebase
164
+ * ` pre-commit run --file ./path/to/my/file ` to fix just one file
165
+ * ` pre-commit run --file ./path/to/my/folder/* ` to fix just one folder
166
+
154
167
Python code conventions
155
168
=======================
156
169
157
170
Python code follows [ PEP 8] ( https://legacy.python.org/dev/peps/pep-0008/ ) and
158
- is auto-formatted using [ black ] ( https://github.com/psf/black ) with a line-length
159
- of 99 characters.
171
+ is auto-formatted using [ ruff format ] ( https://docs.astral.sh/ruff/formatter )
172
+ with a line-length of 99 characters.
160
173
161
174
Naming conventions:
162
175
- Module names are short and all lowercase; eg pyb, stm.
0 commit comments