Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(728)

Unified Diff: presubmit_canned_checks.py

Issue 1234333002: Don't throw "line too long" presubmit error on python import statements. (Closed) Base URL: https://chromium.googlesource.com/chromium/tools/depot_tools.git@master
Patch Set: Also respect pylint disable Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: presubmit_canned_checks.py
diff --git a/presubmit_canned_checks.py b/presubmit_canned_checks.py
index 620661f38e96b7a71a80eb73d4f8edf39a8de5de..5ed86568fffec4c766f90d8de396673e2ea6fda7 100644
--- a/presubmit_canned_checks.py
+++ b/presubmit_canned_checks.py
@@ -345,11 +345,14 @@ def CheckLongLines(input_api, output_api, maxlen, source_file_filter=None):
OBJC_FILE_EXTS = ('h', 'm', 'mm')
OBJC_EXCEPTIONS = ('#define', '#endif', '#if', '#import', '#include',
'#pragma')
+ PY_FILE_EXTS = ('py')
+ PY_EXCEPTIONS = ('import', 'from')
LANGUAGE_EXCEPTIONS = [
(CPP_FILE_EXTS, CPP_EXCEPTIONS),
(JAVA_FILE_EXTS, JAVA_EXCEPTIONS),
(OBJC_FILE_EXTS, OBJC_EXCEPTIONS),
+ (PY_FILE_EXTS, PY_EXCEPTIONS),
]
def no_long_lines(file_extension, line):
@@ -381,6 +384,9 @@ def CheckLongLines(input_api, output_api, maxlen, source_file_filter=None):
if '<include' in line and file_extension in ('css', 'html', 'js'):
return True
+ if 'pylint: disable=line-too-long' in line and file_extension == 'py':
+ return True
+
return input_api.re.match(
r'.*[A-Za-z][A-Za-z_0-9]{%d,}.*' % long_symbol, line)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698