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/format_all.sh b/scripts/format_all.sh index 0e374a3cc..903923046 100755 --- a/scripts/format_all.sh +++ b/scripts/format_all.sh @@ -14,8 +14,8 @@ # 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 +python3 -m yapf --in-place --recursive ./tensorflow_quantum 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..407d3a155 100755 --- a/scripts/format_check.sh +++ b/scripts/format_check.sh @@ -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=$(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..d43c84323 100644 --- a/scripts/format_ipynb.py +++ b/scripts/format_ipynb.py @@ -28,8 +28,7 @@ lines = cell.get('source') # This will safely skip over cells containing !% magic try: - fmt_lines = yapf.yapf_api.FormatCode(''.join(lines), - style_config="google")[0] + fmt_lines = yapf.yapf_api.FormatCode(''.join(lines))[0] except (SyntaxError, yapf.yapflib.errors.YapfError): continue # google style always adds an EOF newline; undo this.