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>
pull/12911/head
Andrew Leech 2023-11-08 15:50:47 +11:00 zatwierdzone przez Damien George
rodzic 26d5032980
commit 4679a90097
1 zmienionych plików z 22 dodań i 9 usunięć

Wyświetl plik

@ -53,13 +53,16 @@ are then certifying and signing off against the following:
Code auto-formatting Code auto-formatting
==================== ====================
Both C and Python code are auto-formatted using the `tools/codeformat.py` Both C and Python code formatting are controlled for consistency across the
script. This uses [uncrustify](https://github.com/uncrustify/uncrustify) to MicroPython codebase. C code is formatted using the `tools/codeformat.py`
format C code and [black](https://github.com/psf/black) to format Python code. script which uses [uncrustify](https://github.com/uncrustify/uncrustify).
After making changes, and before committing, run this tool to reformat your Python code is linted and formatted using
changes to the correct style. Without arguments this tool will reformat all [ruff & ruff format](https://github.com/astral-sh/ruff).
source code (and may take some time to run). Otherwise pass as arguments to After making changes, and before committing, run `tools/codeformat.py` to
the tool the files that changed and it will only reformat those. 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 uncrustify
========== ==========
@ -151,12 +154,22 @@ Tips:
* To ignore the pre-commit message format check temporarily, start the commit * To ignore the pre-commit message format check temporarily, start the commit
message subject line with "WIP" (for "Work In Progress"). 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 conventions
======================= =======================
Python code follows [PEP 8](https://legacy.python.org/dev/peps/pep-0008/) and 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 is auto-formatted using [ruff format](https://docs.astral.sh/ruff/formatter)
of 99 characters. with a line-length of 99 characters.
Naming conventions: Naming conventions:
- Module names are short and all lowercase; eg pyb, stm. - Module names are short and all lowercase; eg pyb, stm.