Skip to content

Commit 4679a90

Browse files
andrewleechdpgeorge
authored andcommitted
CODECONVENTIONS: Update for change from black to ruff format.
Also add notes on running pre-commit manually. Signed-off-by: Andrew Leech <andrew@alelec.net>
1 parent 26d5032 commit 4679a90

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

CODECONVENTIONS.md

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,16 @@ are then certifying and signing off against the following:
5353
Code auto-formatting
5454
====================
5555

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.
6366

6467
uncrustify
6568
==========
@@ -151,12 +154,22 @@ Tips:
151154
* To ignore the pre-commit message format check temporarily, start the commit
152155
message subject line with "WIP" (for "Work In Progress").
153156

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+
154167
Python code conventions
155168
=======================
156169

157170
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.
160173

161174
Naming conventions:
162175
- Module names are short and all lowercase; eg pyb, stm.

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy