Skip to content

Commit

Permalink
Add YAPF job
Browse files Browse the repository at this point in the history
  • Loading branch information
jmgate committed Mar 24, 2022
1 parent 5e35357 commit c9523d9
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 1 deletion.
23 changes: 22 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ pytest:
junit: tests/coverage.xml


# Ensure we adhere to PEP8.
# Ensure we pass the `flake8` linter.
flake8:
stage: test
timeout: 5m
Expand All @@ -157,6 +157,27 @@ flake8:
--exclude=shelllogger-env


# Ensure we adhere to our style guide.variables:
yapf:
stage: test
timeout: 5m
cache:
<<: *global_cache
script:
- python3 -m yapf
--diff
--recursive
. > yapf.diff.txt
- |-
if [[ "$(wc -l yapf.diff.txt | awk '{print $1}')" != "0" ]]; then
echo "----------"
echo "Your code does not match our Python style guide."
echo "Run 'yapf -i' on the following files:"
grep "^+++.*(reformatted)$" yapf.diff.txt | awk '{print $2}'
exit 1
fi
# Ensure the examples run without problems.
examples:
stage: test
Expand Down
18 changes: 18 additions & 0 deletions .style.yapf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# YAPF Style Configuration

# See: /~https://github.com/google/yapf#knobs for available options

[style]
# Base style
based_on_style = pep8

# Customizations
arithmetic_precedence_indication = True
blank_line_before_nested_class_or_def = True
coalesce_brackets = True
dedent_closing_brackets = True
join_multiple_lines = False
split_all_comma_separated_values = True
split_before_arithmetic_operator = True
split_before_dot = True
split_complex_comprehension = True
1 change: 1 addition & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ psutil
pytest >= 6.2
pytest-cov >= 2.12
pytest-mock >= 3.6
yapf

0 comments on commit c9523d9

Please sign in to comment.