diff --git a/.github/workflows/ci-file-checks.yaml b/.github/workflows/ci-file-checks.yaml index 166af5c90..bf3a5e704 100644 --- a/.github/workflows/ci-file-checks.yaml +++ b/.github/workflows/ci-file-checks.yaml @@ -336,7 +336,7 @@ jobs: - name: Run Yapf on the Python changed files run: | set +e - yapf --parallel --diff --style=google \ + yapf --parallel --diff \ ${{needs.Changes.outputs.python_files}} > diff.out 2>&1 exit_code=$? if [[ -s ./diff.out ]]; then diff --git a/.style.yapf b/.style.yapf new file mode 100644 index 000000000..0e9640c29 --- /dev/null +++ b/.style.yapf @@ -0,0 +1,2 @@ +[style] +based_on_style = google diff --git a/scripts/build_docs.py b/scripts/build_docs.py index dc47df224..733ba72e8 100644 --- a/scripts/build_docs.py +++ b/scripts/build_docs.py @@ -43,8 +43,6 @@ FLAGS = flags.FLAGS - - def main(unused_argv): doc_generator = generate_lib.DocGenerator( diff --git a/scripts/format_all.sh b/scripts/format_all.sh index 0e374a3cc..65488d49e 100755 --- a/scripts/format_all.sh +++ b/scripts/format_all.sh @@ -14,8 +14,7 @@ # limitations under the License. # ============================================================================== echo "Doing python language formatting..." -python3 -m yapf --style=google --in-place --recursive ./benchmarks -python3 -m yapf --style=google --in-place --recursive ./tensorflow_quantum +python3 -m yapf --in-place --recursive ./benchmarks ./tensorflow_quantum ./scripts echo -e "Done! \nDoing notebook formatting..." python3 ./scripts/format_ipynb.py echo -e "Done! \nDoing C++ formatting..." diff --git a/scripts/format_check.sh b/scripts/format_check.sh index f0de918dc..40d65aa27 100755 --- a/scripts/format_check.sh +++ b/scripts/format_check.sh @@ -1,12 +1,12 @@ #!/bin/bash # Copyright 2020 The TensorFlow Quantum Authors. All Rights Reserved. -# +# # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at -# +# # http://www.apache.org/licenses/LICENSE-2.0 -# +# # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -72,7 +72,7 @@ for changed_file in ${changed_files}; do ) if [[ "${changed_line_ranges}" != "--lines=0-0 " ]]; then # Do the formatting. - results=$(yapf --style=google --diff "${changed_file}" ${changed_line_ranges}) + results=$(python3 -m yapf --diff "${changed_file}" ${changed_line_ranges}) # Print colorized error messages. if [ ! -z "${results}" ]; then diff --git a/scripts/format_ipynb.py b/scripts/format_ipynb.py index a0e475e9c..c0e91d465 100644 --- a/scripts/format_ipynb.py +++ b/scripts/format_ipynb.py @@ -29,7 +29,7 @@ # This will safely skip over cells containing !% magic try: fmt_lines = yapf.yapf_api.FormatCode(''.join(lines), - style_config="google")[0] + filename=fname)[0] except (SyntaxError, yapf.yapflib.errors.YapfError): continue # google style always adds an EOF newline; undo this.