-
-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[flake8] | ||
exclude = .git,.history,.github,config,docs,lib,scripts,src,test | ||
ignore = E401,E203,W503,C901,E501,E722,E302,E303,E306,E741,F841,W605,E721 | ||
|
||
max-complexity=10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[tool.black] | ||
line-length = 80 | ||
include = '\.pyi?$' | ||
exclude = ''' | ||
( | ||
\.github/ | ||
| \.history/ | ||
| config/ | ||
| docs/ | ||
| lib/ | ||
| src/ | ||
) | ||
''' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/bin/bash | ||
# Format python files passed as arguments, or format dirty and uncached files. | ||
# If GIT_COMMIT environment variable is set to a reference, format the files | ||
# affected by this commit only. | ||
# If AMEND is set, amend the HEAD commit. | ||
|
||
set -e | ||
|
||
if [ "$#" -eq 0 ]; then | ||
if [ -z "$GIT_COMMIT" ]; then | ||
# Take dirty and cached files | ||
FILES=$(git diff-index HEAD -r --name-only) | ||
else | ||
# Take modified files by a commit (eg. for tree-filter) | ||
FILES=$(git diff-tree --no-commit-id --name-only -r --diff-filter=AM "$GIT_COMMIT") | ||
fi | ||
readarray -t PYFILES < <(echo "$FILES" | grep '\.py$' || true) | ||
else | ||
PYFILES=("$@") | ||
fi | ||
|
||
if [ ${#PYFILES[@]} -eq 0 ]; then | ||
exit 0 | ||
fi | ||
|
||
set +e # Formatters are allowed to fail | ||
|
||
black $BLACK_ARGS "${PYFILES[@]}" | ||
autoflake --in-place "${PYFILES[@]}" | ||
autopep8 --in-place -a -a "${PYFILES[@]}" | ||
black $BLACK_ARGS "${PYFILES[@]}" | ||
|
||
if [ "$AMEND" ]; then | ||
git add -u "${PYFILES[@]}" | ||
git commit --amend --no-edit -q --allow-empty | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# This file describes the Python virtualenv package requirements for | ||
# klipper CI checks and local development. | ||
black==22.6.0 | ||
flake8==5.0.4 | ||
autopep8==1.7.0 | ||
autoflake==1.4 | ||
|