Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci-file-checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions .style.yapf
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[style]
based_on_style = google
Comment thread
mhucka marked this conversation as resolved.
4 changes: 2 additions & 2 deletions scripts/format_all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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..."
Expand Down
2 changes: 1 addition & 1 deletion scripts/format_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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})
Comment thread
mhucka marked this conversation as resolved.
Outdated

# Print colorized error messages.
if [ ! -z "${results}" ]; then
Expand Down
3 changes: 1 addition & 2 deletions scripts/format_ipynb.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Check warning on line 31 in scripts/format_ipynb.py

View workflow job for this annotation

GitHub Actions / Check Python lint

C0103: Constant name "fmt_lines" doesn't conform to '(([A-Z_][A-Z0-9_]*)|(__.*__))$' pattern ('(([A-Z_][A-Z0-9_]*)|(__.*__))$' pattern) (invalid-name)
Comment thread
mhucka marked this conversation as resolved.
Outdated
except (SyntaxError, yapf.yapflib.errors.YapfError):
continue
# google style always adds an EOF newline; undo this.
Expand Down
Loading