Commit 4b2c35f4 authored by Brad King's avatar Brad King Committed by Kitware Robot

Merge topic 'add-yapf-formatter'

e4665439 yapf: add a new formatter
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Reviewed-by: Brad King's avatarBrad King <brad.king@kitware.com>
Merge-request: !9
parents d342a814 e4665439
add_formatter(autopep8 reformat autopep8)
add_formatter(pep8 check pep8)
add_formatter(flake8 check flake8)
add_formatter(yapf reformat yapf)
#!/bin/sh
# This formatter uses the `yapf` tool to perform formatting checks of files
# written in Python.
#
# It uses the `yapf` executable in `$PATH`. The configuration file is named
# `.style.yapf` in any parent directory of the target file. They are optional,
# but are used if they exist.
set -e
readonly path="$1"
shift
if ! [ -f "$path" ]; then
echo >&2 'error: could not find file to format: '"$path"
exit 4
fi
if ! which "yapf" > /dev/null; then
echo >&2 'error: could not find the `yapf` binary'
exit 3
fi
exec yapf --in-place "$path"
# This script is only suitable for checking, not reformatting.
formatter_yapf:
kind: "yapf"
script: "@CMAKE_INSTALL_PREFIX@/bin/format.yapf"
config_files:
- ".style.yapf"
- "**/.style.yapf"
add_formatter_test(yapf pass format.py pass)
add_formatter_test(yapf format format.py format)
add_formatter_test(yapf with-config format.py pass)
def weird_formatting ():
pass
def weird_formatting ():
pass
def weird_formatting():
pass
def ok_formatting():
pass
def ok_formatting():
pass
[style]
based_on_style = pep8
indent_width = 2
def weird_formatting():
pass
def weird_formatting():
pass
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment