tooling: add black and flake8 for python formatting/linting (#6454)

This commit is contained in:
Matthew Peveler
2021-09-03 15:17:51 +00:00
committed by GitHub
parent f4390b1637
commit 3fa29ea1c2
7 changed files with 188 additions and 123 deletions

View File

@@ -16,6 +16,21 @@ function run_tests {
for f in ./pages.*; do
tldr-lint --ignore "TLDR003,TLDR004,TLDR005,TLDR015,TLDR104" ${f}
done
run_black
flake8 scripts
}
# Wrapper around black as it outputs everything to stderr,
# but we want to only print if there are actual errors, and not
# the "All done!" success message.
function run_black {
# we want to ignore the exit code from black on failure, so that we can
# do the conditional printing below
errs=$(black scripts --check 2>&1 || true)
if [[ ${errs} != "All done!"* ]]; then
echo -e "${errs}" >&2
return 1
fi
}
# Special test function for GitHub Actions pull request builds.