diff --git a/build b/build index d219a4c..b1863fe 100755 --- a/build +++ b/build @@ -28,4 +28,4 @@ pyflakes "${SOURCE_DIR}/" "${TEST_DIR}/" # Check docstrings for style consistency. PYTHONPATH=$PYTHONPATH:$(pwd)/third_party/docstringchecker \ - pylint --reports=n "$SOURCE_DIR" "$TEST_DIR" + pylint --reports=n --rcfile=.pylintrc "$SOURCE_DIR" "$TEST_DIR" diff --git a/dev_requirements.txt b/dev_requirements.txt index 40f16d0..9edefa8 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -1,4 +1,8 @@ +# pylint versions prior to 1.5.0 require this specific version of astroid. +astroid==1.3.8 mock pyflakes==1.6.0 -pylint==1.8.2 +# We use pylint exclusively to run the DocStringChecker linter and that linter +# expects pre-1.5.0 pylint syntax. +pylint==1.4.4 yapf==0.20.1 diff --git a/third_party/docstringchecker/lint.py b/third_party/docstringchecker/lint.py index 2e6ae75..98da1ce 100644 --- a/third_party/docstringchecker/lint.py +++ b/third_party/docstringchecker/lint.py @@ -147,7 +147,7 @@ def _docstring_indent(node): if node.display_type() == 'Module': return 0 else: - return node.col_offset + 2 + return node.col_offset + 4 def _check_common(self, node, lines=None): """Common checks we enforce on all docstrings""" diff --git a/third_party/docstringchecker/update.sh b/third_party/docstringchecker/update.sh old mode 100755 new mode 100644 index 6f26ec5..90f6ff3 --- a/third_party/docstringchecker/update.sh +++ b/third_party/docstringchecker/update.sh @@ -6,7 +6,10 @@ set -x OUTPUT_DIR=$(dirname "$0") OUTPUT_FILE="${OUTPUT_DIR}/lint.py" +# Modify DocStringChecker to expect 4-space indents instead of 2 to match Google +# Python style guide. wget \ https://chromium.googlesource.com/chromiumos/chromite/+/master/cli/cros/lint.py?format=TEXT \ -O - | \ - base64 --decode > "$OUTPUT_FILE" + base64 --decode | sed "s/return node.col_offset + 2/return node.col_offset + 4/" \ + > "$OUTPUT_FILE"