diff --git a/.travis/yapf.sh b/.travis/yapf.sh index 4ec36d35b..45cabf587 100755 --- a/.travis/yapf.sh +++ b/.travis/yapf.sh @@ -19,24 +19,23 @@ git fetch upstream master YAPF_FLAGS=( '--style' "$ROOT/.style.yapf" - '--in-place' '--recursive' '--parallel' ) YAPF_EXCLUDES=( - '--exclude' 'python/ray/dataframe' - '--exclude' 'python/ray/rllib' - '--exclude' 'python/ray/cloudpickle' - '--exclude' 'python/build' - '--exclude' 'python/ray/pyarrow_files' - '--exclude' 'python/ray/core/src/ray/gcs' - '--exclude' 'python/ray/common/thirdparty' + '--exclude' 'python/ray/dataframe/*' + '--exclude' 'python/ray/rllib/*' + '--exclude' 'python/ray/cloudpickle/*' + '--exclude' 'python/build/*' + '--exclude' 'python/ray/pyarrow_files/*' + '--exclude' 'python/ray/core/src/ray/gcs/*' + '--exclude' 'python/ray/common/thirdparty/*' ) # Format specified files format() { - yapf "${YAPF_FLAGS[@]}" -- "$@" + yapf --in-place "${YAPF_FLAGS[@]}" -- "$@" } # Format files that differ from main branch. Ignores dirs that are not slated @@ -52,13 +51,13 @@ format_changed() { if ! git diff --diff-filter=ACM --quiet --exit-code "$MERGEBASE" -- '*.py' &>/dev/null; then declare -a unformatted_files && mapfile -t unformatted_files < <(git diff --name-only --diff-filter=ACM "$MERGEBASE" -- '*.py') - yapf "${YAPF_EXCLUDES[@]}" "${YAPF_FLAGS[@]}" -- "${unformatted_files[@]}" + yapf --in-place "${YAPF_EXCLUDES[@]}" "${YAPF_FLAGS[@]}" -- "${unformatted_files[@]}" fi } -# Format all files +# Format all files, and print the diff to stdout for travis. format_all() { - yapf "${YAPF_FLAGS[@]}" "${YAPF_EXCLUDES[@]}" test python + yapf --diff "${YAPF_FLAGS[@]}" "${YAPF_EXCLUDES[@]}" test python } # This flag formats individual files. --files *must* be the first command line diff --git a/doc/source/development.rst b/doc/source/development.rst index bd82a1a48..dc1e53b2c 100644 --- a/doc/source/development.rst +++ b/doc/source/development.rst @@ -56,7 +56,7 @@ helpful. 5. **Autoformatting code**. We use ``yapf`` https://github.com/google/yapf for linting, and the config file is located at ``.style.yapf``. We recommend - running ``.travis/yapf.sh`` prior to pushing to format changed files. + running ``scripts/yapf.sh`` prior to pushing to format changed files. Note that some projects such as dataframes and rllib are currently excluded. 6. **Inspecting Redis shards by hand:** To inspect the primary Redis shard by