Skip to content

Commit 5cdfe71

Browse files
jimmodpgeorge
authored andcommitted
top: Add pre-commit config.
This work was funded through GitHub Sponsors. Signed-off-by: Jim Mussared <[email protected]>
1 parent 2328592 commit 5cdfe71

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

.pre-commit-config.yaml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
repos:
2+
- repo: local
3+
hooks:
4+
- id: codeformat
5+
name: MicroPython codeformat.py for changed files
6+
entry: tools/codeformat.py -v -f
7+
language: python
8+
- repo: https://github.com/charliermarsh/ruff-pre-commit
9+
rev: v0.0.280
10+
hooks:
11+
- id: ruff

CONTRIBUTING.md

+14-4
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,21 @@ or packages from micropython-lib, please post at the
2525
### Pull requests
2626

2727
The same rules for commit messages, signing-off commits, and commit structure
28-
apply as for the main MicroPython repository. All Python code is formatted
29-
using `black`. See [`tools/codeformat.py`](tools/codeformat.py) to apply
30-
`black` automatically before submitting a PR.
28+
apply [as for the main MicroPython repository](https://github.com/micropython/micropython/blob/master/CODECONVENTIONS.md).
3129

32-
There are some specific conventions and guidelines for micropython-lib:
30+
All Python code is formatted using the [black](https://github.com/psf/black)
31+
tool. You can run [`tools/codeformat.py`](tools/codeformat.py) to apply
32+
`black` automatically before submitting a PR. The GitHub CI will also run the
33+
[ruff](https://github.com/astral-sh/ruff) tool to apply further "linting"
34+
checks.
35+
36+
Similar to the main repository, a configuration is provided for the
37+
[pre-commit](https://pre-commit.com/) tool to apply `black` code formatting
38+
rules and run `ruff` automatically. See the documentation for using pre-commit
39+
in [the code conventions document](https://github.com/micropython/micropython/blob/master/CODECONVENTIONS.md#automatic-pre-commit-hooks)
40+
41+
In addition to the conventions from the main repository, there are some
42+
specific conventions and guidelines for micropython-lib:
3343

3444
* The first line of the commit message should start with the name of the
3545
package, followed by a short description of the commit. Package names are

0 commit comments

Comments
 (0)