[CodeHealth] Bump some scripts to pylint 2.6
And fix the lint warnings.
Bug: 1223892
Change-Id: Iadb7e59a6baf9c2f7abd92b1db81995d44cbf4fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3110310
Commit-Queue: Dirk Pranke <dpranke@google.com>
Auto-Submit: Victor Vianna <victorvianna@google.com>
Reviewed-by: Dirk Pranke <dpranke@google.com>
Cr-Commit-Position: refs/heads/main@{#917422}
NOKEYCHECK=True
GitOrigin-RevId: 0686307eed463d6f49515eea665aac8f64291071
diff --git a/development/scripts/PRESUBMIT.py b/development/scripts/PRESUBMIT.py
index 8d98b9a..6254928 100644
--- a/development/scripts/PRESUBMIT.py
+++ b/development/scripts/PRESUBMIT.py
@@ -13,7 +13,8 @@
def CommonChecks(input_api, output_api):
output = []
- output.extend(input_api.canned_checks.RunPylint(input_api, output_api))
+ output.extend(
+ input_api.canned_checks.RunPylint(input_api, output_api, version='2.6'))
py_tests = input_api.canned_checks.GetUnitTestsRecursively(
input_api,
diff --git a/development/scripts/stack.py b/development/scripts/stack.py
index 8b70781..de79a05 100755
--- a/development/scripts/stack.py
+++ b/development/scripts/stack.py
@@ -133,11 +133,11 @@
android_symbols = glob.glob("%s/out/target/product/*/symbols" % symdir)
if android_symbols:
return (symdir, android_symbols[0])
- else:
- # This is a zip of Chrome symbols, so symbol.CHROME_SYMBOLS_DIR needs to be
- # updated to point here.
- symbol.CHROME_SYMBOLS_DIR = symdir
- return (symdir, symdir)
+
+ # This is a zip of Chrome symbols, so symbol.CHROME_SYMBOLS_DIR needs to be
+ # updated to point here.
+ symbol.CHROME_SYMBOLS_DIR = symdir
+ return (symdir, symdir)
def main(argv, test_symbolizer=None):
diff --git a/development/scripts/stack_core.py b/development/scripts/stack_core.py
index 4cea454..4b7e67b 100755
--- a/development/scripts/stack_core.py
+++ b/development/scripts/stack_core.py
@@ -119,7 +119,6 @@
normalized = os.path.normpath(location)
print(' %8s %s %s' % (addr, symbol_with_offset.ljust(maxlen),
normalized))
- return
def PrintValueLines(value_lines):
@@ -132,7 +131,6 @@
(addr, value, symbol_with_offset, location) = vl
print(' %8s %8s %s %s' % (addr, value, symbol_with_offset.ljust(maxlen),
location))
- return
def PrintJavaLines(java_lines):
@@ -274,7 +272,7 @@
"""
offset_match = _SHARED_LIB_OFFSET_IN_APK.match(symbol_present)
if not offset_match:
- return
+ return None
offset = offset_match.group('offset')
key = '%s:%s' % (lib, offset)
if key in self._shared_libraries_mapping:
@@ -453,7 +451,7 @@
pid = -1
last_frame = frame
- if area == UNKNOWN or area == HEAP or area == STACK:
+ if area in (UNKNOWN, HEAP, STACK):
trace_lines.append((code_addr, '', area))
else:
logging.debug('Identified lib: %s' % area)
@@ -505,11 +503,10 @@
so_dir_len = len(so_dir)
if so_dir_len > 0:
if so_dir_len > 1:
- raise Exception("Found different so dirs, they are %s", repr(so_dir))
- else:
- search_path = so_dir.pop()
- logging.info("Search libraries in %s", search_path)
- symbol.SetSecondaryAbiOutputPath(search_path)
+ raise Exception("Found different so dirs, they are %s" % repr(so_dir))
+ search_path = so_dir.pop()
+ logging.info("Search libraries in %s", search_path)
+ symbol.SetSecondaryAbiOutputPath(search_path)
def GetUncompressedSharedLibraryFromAPK(apkname, offset):
@@ -594,7 +591,7 @@
if apks_directory:
if not os.path.isdir(apks_directory):
- raise Exception('Explicit APKs directory does not exist: %s',
+ raise Exception('Explicit APKs directory does not exist: %s' %
repr(apks_directory))
else:
apks_directory = os.path.join(output_directory, 'apks')
@@ -626,7 +623,7 @@
number_of_library = len(shared_libraries)
if number_of_library == 1:
return shared_libraries[0]
- elif number_of_library > 1:
+ if number_of_library > 1:
logging.warning("More than one libraries could be loaded from APK.")
return (None, None)
@@ -636,3 +633,4 @@
match = _ABI_LINE.search(line)
if match:
return match.group('abi')
+ return None
diff --git a/development/scripts/symbol.py b/development/scripts/symbol.py
index c7c617d..f0a2dea 100755
--- a/development/scripts/symbol.py
+++ b/development/scripts/symbol.py
@@ -156,6 +156,8 @@
if match:
return match.group(1)
+ return None
+
def GetApkFromLibrary(device_library_path):
match = re.match(r'.*/([^/]*)-[0-9]+(\/[^/]*)?\.apk$', device_library_path)
if not match:
@@ -192,6 +194,8 @@
if crazy_lib:
return crazy_lib
+ return None
+
def GetLibrarySearchPaths():
"""Return a list of directories where to find native shared libraries."""
@@ -280,8 +284,7 @@
raise Exception ('SetSecondaryAbiOutputPath() was already called with a ' +
'different value, previous: %s new: %s' % (
_SECONDARY_ABI_OUTPUT_PATH, path))
- else:
- _SECONDARY_ABI_OUTPUT_PATH = path
+ _SECONDARY_ABI_OUTPUT_PATH = path
def SymbolInformationForSet(lib, unique_addrs, get_detailed_info,
@@ -338,7 +341,7 @@
return result
-class _MemoizedForSet(object):
+class _MemoizedForSet:
"""Decorator class used to memoize CallXXXForSet() results."""
def __init__(self, fn):
self.fn = fn