Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update local linting/formatting #332

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
BasedOnStyle: LLVM
7 changes: 6 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,12 @@ tox

## Style

Use [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) for C++ code, and `black` with defaults for Python code.
Use [`clang-format`](https://clang.llvm.org/docs/ClangFormat.html) for C++ code and `ruff` for Python code. After setting up tox, one can run:
```
tox -e check-python-formatting
tox -e format-python
tox -e format-cpp
```

## Issues

Expand Down
4 changes: 3 additions & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
-r test-requirements.txt
-r docs-requirements.txt
bumpversion==0.5.3
clang-format==14
ipython
ipdb
pip>=20
pybind11>=2.10.4
ruff
setuptools>=42
wheel
wheel
2 changes: 2 additions & 0 deletions scripts/format_cpp.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
find pedalboard/ -name '*.cpp' -o -name '*.h' | xargs clang-format -i
26 changes: 12 additions & 14 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,23 @@ deps = -rdocs-requirements.txt
commands =
# interrogate -vv --fail-under 40 pedalboard


; "black" is a code formatter, much like gofmt. It requires 3.6 or higher.
; This env just runs `black` and fails tox if it's not formatted correctly.
; If this env fails on Tingle, run `tox -e format` locally in order to apply changes.
[testenv:check-formatting]
[testenv:check-python-formatting]
basepython = python3
deps = black
deps = ruff
skip_install = true
commands =
# black pedalboard tests --line-length 120 --experimental-string-processing --diff --check
# clang-format -style=LLVM pedalboard.cpp
commands = ruff check ./ --ignore=E203,F541 --exclude .git,dist,doc,build,vendors,'*.pyi' --line-length 100

[testenv:format]
[testenv:format-python]
basepython = python3
deps = black
deps = ruff
skip_install = true
commands =
# black pedalboard tests --line-length 120 --experimental-string-processing
clang-format -style=LLVM -i pedalboard.cpp
commands = ruff format ./ --exclude .git,dist,doc,build,JUCE,examples,vendors,'*.pyi' --line-length 100

[testenv:format-cpp]
skip_install = true
deps =
allowlist_externals = find, xargs, clang-format, echo, ./scripts/format_cpp.sh
commands = ./scripts/format_cpp.sh

[testenv:lint]
; feel free to add flake8 plugins (i.e. flake8-import-order), add isort,
Expand Down
Loading