Fix pylint check in presubmit
This fixes the unexpected behavior where we only run pylint over the
affected Python files *unless* there are affected Python files which we
have explicitly blacklisted, in which case we run pylint over ALL Python
files in every subdirectory of the Skia checkout, including repos in
DEPS.
- Added buildtools and common to the blacklist.
- Changed to run pylint over all Python files in Skia, like
presubmit_support expects.
- Fix existing pylint problems.
Bug: skia:
Change-Id: Ife1321f5ae5eaff2a28cc14c99a82a0716c12677
Reviewed-on: https://skia-review.googlesource.com/137126
Reviewed-by: Eric Boren <borenet@google.com>
Commit-Queue: Eric Boren <borenet@google.com>
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index f9747fa..2a3b61f 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -78,9 +78,16 @@
def _PythonChecks(input_api, output_api):
"""Run checks on any modified Python files."""
- pylint_disabled_files = (
- 'infra/bots/recipes.py',
- )
+ blacklist = [
+ r'infra[\\\/]bots[\\\/]recipes.py',
+
+ # Blacklist DEPS. Those under third_party are already covered by
+ # input_api.DEFAULT_BLACK_LIST.
+ r'common[\\\/].*',
+ r'buildtools[\\\/].*',
+ ]
+ blacklist.extend(input_api.DEFAULT_BLACK_LIST)
+
pylint_disabled_warnings = (
'F0401', # Unable to import.
'E0611', # No name in module.
@@ -92,18 +99,10 @@
'W0613', # Unused argument.
'W0105', # String statement has no effect.
)
- # 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'):
- if affected_file_path not in pylint_disabled_files:
- 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)
+ black_list=blacklist)
def _JsonChecks(input_api, output_api):
diff --git a/tools/copyright/main.py b/tools/copyright/main.py
index 24969a7..e428448 100644
--- a/tools/copyright/main.py
+++ b/tools/copyright/main.py
@@ -67,7 +67,7 @@
@param root_directory root directory within which to find all files
"""
path_list = []
- for dirpath, dirnames, filenames in os.walk(root_directory):
+ for dirpath, _, filenames in os.walk(root_directory):
for filename in filenames:
path_list.append(os.path.abspath(os.path.join(dirpath, filename)))
return path_list
diff --git a/tools/jsondiff.py b/tools/jsondiff.py
index 91e3e4b..ed4731a 100755
--- a/tools/jsondiff.py
+++ b/tools/jsondiff.py
@@ -130,7 +130,8 @@
if results_of_this_type:
for test_name in results_of_this_type.keys():
digest_pair = results_of_this_type[test_name]
- if digest_pair[0] != gm_json.JSONKEY_HASHTYPE_BITMAP_64BITMD5:
+ if (digest_pair[0] !=
+ gm_json.JSONKEY_HASHTYPE_BITMAP_64BITMD5):
raise ValueError(
'test %s has unsupported hashtype %s' % (
test_name, digest_pair[0]))
@@ -138,7 +139,7 @@
return result_dict
def _DictionaryDiff(self, old_dict, new_dict):
- """Generate a dictionary showing the diffs between old_dict and new_dict.
+ """Generate a dictionary showing diffs between old_dict and new_dict.
Any entries which are identical across them will be left out."""
diff_dict = {}
all_keys = set(old_dict.keys() + new_dict.keys())
@@ -158,8 +159,9 @@
If newfile is not specified, then 'new' is the actual results within
oldfile.
"""
- return self.GenerateDiffDictFromStrings(self._GetFileContentsAsString(oldfile),
- self._GetFileContentsAsString(newfile))
+ return self.GenerateDiffDictFromStrings(
+ self._GetFileContentsAsString(oldfile),
+ self._GetFileContentsAsString(newfile))
def GenerateDiffDictFromStrings(self, oldjson, newjson=None):
"""Generate a dictionary showing the diffs: