[format] Improve formatting with a real .flake8 file (#12800)

Change-Id: I42acd948dd915bad6b132f8caa9038898b55d6e4
This commit is contained in:
Barak Michener
2020-12-12 11:34:30 -08:00
committed by GitHub
parent 2f2bd884a3
commit 6eb0e6f734
2 changed files with 27 additions and 6 deletions
+23
View File
@@ -0,0 +1,23 @@
[flake8]
exclude =
python/ray/core/generated/
streaming/python/generated
doc/source/conf.py
python/ray/cloudpickle/
python/ray/thirdparty_files/
python/build/
python/.eggs/
max-line-length = 79
inline-quotes = "
ignore =
C408
E121
E123
E126
E226
E24
E704
W503
W504
W605
avoid-escape = no
+4 -6
View File
@@ -114,8 +114,6 @@ GIT_LS_EXCLUDES=(
# TODO(barakmich): This should be cleaned up. I've at least excised the copies
# of these arguments to this location, but the long-term answer is to actually
# make a flake8 config file
FLAKE8_EXCLUDE="--exclude=python/ray/core/generated/,streaming/python/generated,doc/source/conf.py,python/ray/cloudpickle/,python/ray/thirdparty_files/,python/build/,python/.eggs/"
FLAKE8_IGNORES="--ignore=C408,E121,E123,E126,E226,E24,E704,W503,W504,W605"
FLAKE8_PYX_IGNORES="--ignore=C408,E121,E123,E126,E211,E225,E226,E227,E24,E704,E999,W503,W504,W605"
shellcheck_scripts() {
@@ -195,10 +193,10 @@ format_all() {
if [ $HAS_FLAKE8 ]; then
echo "$(date)" "Flake8...."
git ls-files -- '*.py' "${GIT_LS_EXCLUDES[@]}" | xargs -P 5 \
flake8 --inline-quotes '"' --no-avoid-escape "$FLAKE8_EXCLUDE" "$FLAKE8_IGNORES"
flake8 --config=.flake8
git ls-files -- '*.pyx' '*.pxd' '*.pxi' "${GIT_LS_EXCLUDES[@]}" | xargs -P 5 \
flake8 --inline-quotes '"' --no-avoid-escape "$FLAKE8_EXCLUDE" "$FLAKE8_PYX_IGNORES"
flake8 --config=.flake8 "$FLAKE8_PYX_IGNORES"
fi
echo "$(date)" "clang-format...."
@@ -237,14 +235,14 @@ format_changed() {
yapf --in-place "${YAPF_EXCLUDES[@]}" "${YAPF_FLAGS[@]}"
if which flake8 >/dev/null; then
git diff --name-only --diff-filter=ACRM "$MERGEBASE" -- '*.py' | xargs -P 5 \
flake8 --inline-quotes '"' --no-avoid-escape "$FLAKE8_EXCLUDE" "$FLAKE8_IGNORES"
flake8 --config=.flake8
fi
fi
if ! git diff --diff-filter=ACRM --quiet --exit-code "$MERGEBASE" -- '*.pyx' '*.pxd' '*.pxi' &>/dev/null; then
if which flake8 >/dev/null; then
git diff --name-only --diff-filter=ACRM "$MERGEBASE" -- '*.pyx' '*.pxd' '*.pxi' | xargs -P 5 \
flake8 --inline-quotes '"' --no-avoid-escape "$FLAKE8_EXCLUDE" "$FLAKE8_PYX_IGNORES"
flake8 --config=.flake8 "$FLAKE8_PYX_IGNORES"
fi
fi