Skip to content

Commit

Permalink
top: Add pre-commit config.
Browse files Browse the repository at this point in the history
This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <[email protected]>
  • Loading branch information
jimmo authored and dpgeorge committed Jul 27, 2023
1 parent 2328592 commit 5cdfe71
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 4 deletions.
11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
repos:
- repo: local
hooks:
- id: codeformat
name: MicroPython codeformat.py for changed files
entry: tools/codeformat.py -v -f
language: python
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.280
hooks:
- id: ruff
18 changes: 14 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,21 @@ or packages from micropython-lib, please post at the
### Pull requests

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

There are some specific conventions and guidelines for micropython-lib:
All Python code is formatted using the [black](https://github.com/psf/black)
tool. You can run [`tools/codeformat.py`](tools/codeformat.py) to apply
`black` automatically before submitting a PR. The GitHub CI will also run the
[ruff](https://github.com/astral-sh/ruff) tool to apply further "linting"
checks.

Similar to the main repository, a configuration is provided for the
[pre-commit](https://pre-commit.com/) tool to apply `black` code formatting
rules and run `ruff` automatically. See the documentation for using pre-commit
in [the code conventions document](https://github.com/micropython/micropython/blob/master/CODECONVENTIONS.md#automatic-pre-commit-hooks)

In addition to the conventions from the main repository, there are some
specific conventions and guidelines for micropython-lib:

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

0 comments on commit 5cdfe71

Please sign in to comment.