Skip to content

Commit

Permalink
ci: bump black and add pre-commit hook
Browse files Browse the repository at this point in the history
  • Loading branch information
JoepVanlier committed Jul 23, 2024
1 parent 58e2cba commit 14a1e60
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/pylake_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
run: python -c "import lumicks.pylake as lk; lk.benchmark(repeat=1)"
- name: Black
run: |
pip install black==23.7.0 isort==5.12.0
pip install black==24.4.2 isort==5.13.2
black --check --diff --color .
isort --check-only --diff .
- name: flake8
Expand Down
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
repos:
- repo: https://github.com/psf/black
rev: 24.4.2
hooks:
- id: black
- repo: https://github.com/pycqa/isort
rev: 5.13.2
hooks:
- id: isort
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: end-of-file-fixer
exclude: ^.*\.png$ ^.*\.gif$
- id: requirements-txt-fixer
- id: trailing-whitespace
exclude: ^.*\.png$ ^.*\.gif$
- repo: https://github.com/pycqa/flake8
rev: 7.1.0
hooks:
- id: flake8
language_version: python3
additional_dependencies:
- flake8-bugbear==24.4.26
14 changes: 14 additions & 0 deletions contributing.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,17 @@ Code and documentation contributions will generally proceed through a Pull Reque
- Please set up your editor to follow PEP8 (remove trailing white space, no tabs, etc.). Use [black](https://github.com/psf/black) to format your code.
- All public functions and classes require an informative docstring. Document these using the [numpydoc](https://numpydoc.readthedocs.io/en/latest/format.html) style.
- Features should ideally be grouped by category in their own folder, with implementational details in a sub-folder named `detail`. Tests for each specific category should be placed in a sub-folder `tests`.

### Installing pre-commit hooks

To help with formatting and code-style consider installing the pre-commit hooks.
These will check the formatting whenever you commit.
Install `pre-commit` with:

pip install pre-commit

Next, set up the hook with::

pre-commit install

That's all there is to it.

0 comments on commit 14a1e60

Please sign in to comment.