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

Unified Diff: PRESUBMIT.py

Issue 330423004: Use new common tools in Python scripts (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: append Created 6 years, 6 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 | « DEPS ('k') | tools/add_codereview_message.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: PRESUBMIT.py
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index dc8cb77c0c002e829c005b65920efb07802d01ea..81bb257b9284481a4c91c9a731133cf693352337 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -46,6 +46,31 @@ def _CheckChangeHasEol(input_api, output_api, source_file_filter=None):
return []
+def _PythonChecks(input_api, output_api):
+ """Run checks on any modified Python files."""
+ pylint_disabled_warnings = (
+ 'F0401', # Unable to import.
+ 'E0611', # No name in module.
+ 'W0232', # Class has no __init__ method.
+ 'E1002', # Use of super on an old style class.
+ 'W0403', # Relative import used.
+ 'R0201', # Method could be a function.
+ 'E1003', # Using class name in super.
+ 'W0613', # Unused argument.
+ )
+ # Run Pylint on only the modified python files. Unfortunately it still runs
+ # Pylint on the whole file instead of just the modified lines.
+ affected_python_files = []
+ for affected_file in input_api.AffectedSourceFiles(None):
+ affected_file_path = affected_file.LocalPath()
+ if affected_file_path.endswith('.py'):
+ affected_python_files.append(affected_file_path)
+ return input_api.canned_checks.RunPylint(
+ input_api, output_api,
+ disabled_warnings=pylint_disabled_warnings,
+ white_list=affected_python_files)
+
+
def _CommonChecks(input_api, output_api):
"""Presubmit checks common to upload and commit."""
results = []
@@ -58,6 +83,7 @@ def _CommonChecks(input_api, output_api):
results.extend(
_CheckChangeHasEol(
input_api, output_api, source_file_filter=sources))
+ results.extend(_PythonChecks(input_api, output_api))
return results
@@ -189,7 +215,7 @@ def _CheckLGTMsForPublicAPI(input_api, output_api):
'lgtm' in message['text'].lower()):
# Found an lgtm in a message from an owner.
lgtm_from_owner = True
- break;
+ break
if not lgtm_from_owner:
results.append(
« no previous file with comments | « DEPS ('k') | tools/add_codereview_message.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698