aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Leech <andrew@alelec.net>2023-11-08 15:50:47 +1100
committerDamien George <damien@micropython.org>2023-11-09 13:36:21 +1100
commit4679a90097cc881c9d53d6e0dd0dde1c4c2de99c (patch)
treed1506e9c6bb288aedb44a05030c1719b0c4f1fe3
parent26d5032980335ccdfe81234ad7a24030a580f6d3 (diff)
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>
-rw-r--r--CODECONVENTIONS.md31
1 files changed, 22 insertions, 9 deletions
diff --git a/CODECONVENTIONS.md b/CODECONVENTIONS.md
index d44b382b2..d6b0a5926 100644
--- a/CODECONVENTIONS.md
+++ b/CODECONVENTIONS.md
@@ -53,13 +53,16 @@ are then certifying and signing off against the following:
Code auto-formatting
====================
-Both C and Python code are auto-formatted using the `tools/codeformat.py`
-script. This uses [uncrustify](https://github.com/uncrustify/uncrustify) to
-format C code and [black](https://github.com/psf/black) to format Python code.
-After making changes, and before committing, run this tool to reformat your
-changes to the correct style. Without arguments this tool will reformat all
-source code (and may take some time to run). Otherwise pass as arguments to
-the tool the files that changed and it will only reformat those.
+Both C and Python code formatting are controlled for consistency across the
+MicroPython codebase. C code is formatted using the `tools/codeformat.py`
+script which uses [uncrustify](https://github.com/uncrustify/uncrustify).
+Python code is linted and formatted using
+[ruff & ruff format](https://github.com/astral-sh/ruff).
+After making changes, and before committing, run `tools/codeformat.py` to
+reformat your C code and `ruff format` for any Python code. Without
+arguments this tool will reformat all source code (and may take some time
+to run). Otherwise pass as arguments to the tool the files that changed,
+and it will only reformat those.
uncrustify
==========
@@ -151,12 +154,22 @@ Tips:
* To ignore the pre-commit message format check temporarily, start the commit
message subject line with "WIP" (for "Work In Progress").
+Running pre-commit manually
+===========================
+
+Once pre-commit is installed as per the previous section it can be manually
+run against the MicroPython python codebase to update file formatting on
+demand, with either:
+* `pre-commit run --all-files` to fix all files in the MicroPython codebase
+* `pre-commit run --file ./path/to/my/file` to fix just one file
+* `pre-commit run --file ./path/to/my/folder/*` to fix just one folder
+
Python code conventions
=======================
Python code follows [PEP 8](https://legacy.python.org/dev/peps/pep-0008/) and
-is auto-formatted using [black](https://github.com/psf/black) with a line-length
-of 99 characters.
+is auto-formatted using [ruff format](https://docs.astral.sh/ruff/formatter)
+with a line-length of 99 characters.
Naming conventions:
- Module names are short and all lowercase; eg pyb, stm.