mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-21 02:22:07 +08:00
Require black and isort for contributions (#3329)
* Add explanation to CONTRIBUTNG.md * Add sample pre-commit script * Check for correctly formatted files in CI Co-authored-by: Jelle Zijlstra <jelle.zijlstra@gmail.com>
This commit is contained in:
28
pre-commit
Executable file
28
pre-commit
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# An example hook script that will run flake8, black, and isort
|
||||
# prior to committing and will stop the commit if there are any
|
||||
# warnings. Adjust BIN_DIR to the virtual environment where flake8,
|
||||
# black, and isort are installed.
|
||||
#
|
||||
# To enable this hook, copy this file to ".git/hooks".
|
||||
|
||||
BIN_DIR=./.venv/bin
|
||||
|
||||
CHANGED_FILES=$(git diff --cached --name-only --diff-filter=AM | grep .pyi || true)
|
||||
|
||||
if test -n "${CHANGED_FILES}" -a -d "${BIN_DIR}"; then
|
||||
${BIN_DIR}/flake8 ${CHANGED_FILES}
|
||||
${BIN_DIR}/black --check ${CHANGED_FILES}
|
||||
${BIN_DIR}/isort --check-only ${CHANGED_FILES}
|
||||
|
||||
# Replace the last two lines with the following lines
|
||||
# if you want to reformat changed files automatically
|
||||
# before committing. Please note that partial commits
|
||||
# (git add -p) will not work and will commit the whole
|
||||
# file!
|
||||
#
|
||||
# ${BIN_DIR}/black ${CHANGED_FILES} || true
|
||||
# ${BIN_DIR}/isort -y ${CHANGED_FILES} || true
|
||||
# git add ${CHANGED_FILES}
|
||||
fi
|
||||
Reference in New Issue
Block a user