From 323c7a6d906c5213b085c7fbf9c5da27e893c3d7 Mon Sep 17 00:00:00 2001 From: Jamie Wong Date: Tue, 14 Jul 2015 15:58:37 -0700 Subject: [PATCH] Don't fail out if the python docstring on the first line of a file is too long Summary: See https://app.asana.com/0/27216215224639/40389455104495 Test Plan: In webapp: python -c "print '\"\"\"' + '.' * 80 + '\"\"\"\n'" > foo.py ~/khan/devtools/khan-linter/runlint.py foo.py And see that it outputs this: foo.py:1:80: E501 line too long (86 characters) Instead of this: local variable 'linenum' referenced before assignment Reviewers: csilvers Reviewed By: csilvers Subscribers: colin Differential Revision: https://phabricator.khanacademy.org/D19293 --- .arcconfig | 5 +++++ .arclint | 9 +++++++++ linters.py | 6 ++++-- 3 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 .arcconfig create mode 100644 .arclint diff --git a/.arcconfig b/.arcconfig new file mode 100644 index 00000000..8ce7a31f --- /dev/null +++ b/.arcconfig @@ -0,0 +1,5 @@ +{ + "project_id": "khan-linter", + "conduit_uri": "https://phabricator.khanacademy.org/", + "lint.engine": "ArcanistConfigurationDrivenLintEngine" +} diff --git a/.arclint b/.arclint new file mode 100644 index 00000000..3573db90 --- /dev/null +++ b/.arclint @@ -0,0 +1,9 @@ +{ + "linters": { + "khan-linter": { + "type": "script-and-regex", + "script-and-regex.script": "~\/khan\/devtools\/khan-linter\/runlint.py --always-exit-0 --blacklist=yes --propose-arc-fixes", + "script-and-regex.regex": "\/^((?P[^:]*):(?P\\d+):((?P\\d+):)? (?P((?PE)|(?PW))\\S+) (?P[^\\x00]*)(\\x00(?P[^\\x00]*)\\x00(?P[^\\x00]*)\\x00)?)|(?PSKIPPING.*)$\/m" + } + } +} diff --git a/linters.py b/linters.py index 3095712a..c09d2904 100644 --- a/linters.py +++ b/linters.py @@ -131,8 +131,10 @@ def _process_one_line(self, output_line, contents_lines): # should work well enough. if ('E501 line too long' in lintline and bad_line.lstrip().startswith('"') and - bad_line.rstrip(',\n').endswith('"')): - for linenum in xrange(bad_linenum - 1, 0, -1): + bad_line.rstrip(',\n').endswith('"') and + bad_linenum): + + for linenum in xrange(bad_linenum, 0, -1): if (contents_lines[linenum].lstrip().startswith('"""') or contents_lines[linenum].lstrip().startswith("'''")): break