Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

Commit

Permalink
chore: fix pylint-2.7 errors (electron#33233)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsanders11 authored and khalwa committed Feb 22, 2023
1 parent 0e11e53 commit 53aab6a
Show file tree
Hide file tree
Showing 13 changed files with 30 additions and 32 deletions.
3 changes: 1 addition & 2 deletions script/add-debug-link.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ def add_debug_link_into_binaries(directory, target_cpu, debug_dir):
add_debug_link_into_binary(binary_path, target_cpu, debug_dir)

def add_debug_link_into_binary(binary_path, target_cpu, debug_dir):
if PLATFORM == 'linux' and (target_cpu == 'x86' or target_cpu == 'arm' or
target_cpu == 'arm64'):
if PLATFORM == 'linux' and target_cpu in ('x86', 'arm', 'arm64'):
# Skip because no objcopy binary on the given target.
return

Expand Down
2 changes: 1 addition & 1 deletion script/check-relative-doc-links.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def main():
filepaths.append(os.path.join(root, f))
except KeyboardInterrupt:
print('Keyboard interruption. Please try again.')
return
return 0

totalBrokenLinks = 0
for path in filepaths:
Expand Down
4 changes: 1 addition & 3 deletions script/copy-debug-symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ def copy_debug_from_binaries(directory, out_dir, target_cpu, compress):
copy_debug_from_binary(binary_path, out_dir, target_cpu, compress)

def copy_debug_from_binary(binary_path, out_dir, target_cpu, compress):
if PLATFORM == 'linux' and (target_cpu == 'x86' or target_cpu == 'arm' or
target_cpu == 'arm64'):
if PLATFORM == 'linux' and target_cpu in ('x86', 'arm', 'arm64'):
# Skip because no objcopy binary on the given target.
return
debug_name = get_debug_name(binary_path)
Expand All @@ -25,7 +24,6 @@ def copy_debug_from_binary(binary_path, out_dir, target_cpu, compress):
cmd.extend(['--compress-debug-sections'])
cmd.extend([binary_path, os.path.join(out_dir, debug_name)])
execute(cmd)
return debug_name

def get_debug_name(binary_path):
return os.path.basename(binary_path) + '.debug'
Expand Down
4 changes: 2 additions & 2 deletions script/generate-config-gypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def run_node_configure(target_cpu):
configure = os.path.join(NODE_DIR, 'configure.py')
args = ['--dest-cpu', target_cpu]
# Enabled in Chromium's V8.
if target_cpu == 'arm64' or target_cpu == 'x64':
if target_cpu in ('arm64', 'x64'):
args += ['--experimental-enable-pointer-compression']

# Work around "No acceptable ASM compiler found" error on some System,
Expand Down Expand Up @@ -62,4 +62,4 @@ def main(target_file, target_cpu):
f.write(pprint.pformat(config, indent=2))

if __name__ == '__main__':
sys.exit(main(*sys.argv[1:]))
sys.exit(main(sys.argv[1], sys.argv[2]))
2 changes: 1 addition & 1 deletion script/generate-zip-manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ def main(zip_path, manifest_out):
return 0

if __name__ == '__main__':
sys.exit(main(*sys.argv[1:]))
sys.exit(main(sys.argv[1], sys.argv[2]))
4 changes: 2 additions & 2 deletions script/lib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
def get_platform_key():
if 'MAS_BUILD' in os.environ:
return 'mas'
else:
return PLATFORM

return PLATFORM


def get_target_arch():
Expand Down
7 changes: 3 additions & 4 deletions script/lib/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,8 @@ def to_utf8(patch):
"""Python 2/3 compatibility: unicode has been renamed to str in Python3"""
if sys.version_info[0] >= 3:
return str(patch, "utf-8")
else:
return unicode(patch, "utf-8")

return unicode(patch, "utf-8")


def export_patches(repo, out_dir, patch_range=None, dry_run=False):
Expand Down Expand Up @@ -268,7 +268,7 @@ def export_patches(repo, out_dir, patch_range=None, dry_run=False):
out_dir, len(bad_patches), "\n-- ".join(bad_patches)
)
)
exit(1)
sys.exit(1)
else:
# Remove old patches so that deleted commits are correctly reflected in the
# patch files (as a removed file)
Expand All @@ -291,4 +291,3 @@ def export_patches(repo, out_dir, patch_range=None, dry_run=False):
) as f:
f.write(formatted_patch.encode('utf-8'))
pl.write(filename + '\n')

8 changes: 5 additions & 3 deletions script/lib/native_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ def get_current():
if platform in ('cygwin', 'win32'):
return Platform.WINDOWS

assert False, "unexpected current platform '{}'".format(platform)
raise AssertionError(
"unexpected current platform '{}'".format(platform))

@staticmethod
def get_all():
Expand Down Expand Up @@ -155,7 +156,7 @@ def __expand_shorthand(value):
if isinstance(value, basestring):
return {value: None}

assert False, "unexpected shorthand type: {}".format(type(value))
raise AssertionError("unexpected shorthand type: {}".format(type(value)))

@staticmethod
def __make_a_list(value):
Expand All @@ -174,7 +175,8 @@ def __merge_nested_lists(value):
# It looks ugly as hell, but it does the job.
return [list_item for key in value for list_item in value[key]]

assert False, "unexpected type for list merging: {}".format(type(value))
raise AssertionError(
"unexpected type for list merging: {}".format(type(value)))

def __platform_supports(self, binary_name):
return Platform.get_current() in self.tests[binary_name]['platforms']
Expand Down
4 changes: 2 additions & 2 deletions script/lib/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,9 @@ def get_electron_exec():

if sys.platform == 'darwin':
return '{0}/Electron.app/Contents/MacOS/Electron'.format(out_dir)
elif sys.platform == 'win32':
if sys.platform == 'win32':
return '{0}/electron.exe'.format(out_dir)
elif sys.platform == 'linux':
if sys.platform == 'linux':
return '{0}/electron'.format(out_dir)

raise Exception(
Expand Down
8 changes: 4 additions & 4 deletions script/native-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ def main():
if args.binary is not None:
return tests_list.run(args.binary, args.output_dir, args.verbosity,
args.disabled_tests_policy)
else:
return tests_list.run_all(args.output_dir, args.verbosity,
args.disabled_tests_policy)

assert False, "unexpected command '{}'".format(args.command)
return tests_list.run_all(args.output_dir, args.verbosity,
args.disabled_tests_policy)

raise AssertionError("unexpected command '{}'".format(args.command))


if __name__ == '__main__':
Expand Down
4 changes: 3 additions & 1 deletion script/release/uploaders/upload.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ def main():
'toolchain_profile.json')
upload_electron(release, toolchain_profile_zip, args)

return 0

def parse_args():
parser = argparse.ArgumentParser(description='upload distribution file')
parser.add_argument('-v', '--version', help='Specify the version',
Expand Down Expand Up @@ -205,7 +207,7 @@ def zero_zip_date_time(fname):
try:
with open(fname, 'r+b') as f:
_zero_zip_date_time(f)
except:
except Exception:
raise NonZipFileError(fname)


Expand Down
2 changes: 1 addition & 1 deletion script/run-clang-format.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def main():
extensions=args.extensions.split(','))

if not files:
return
return 0

njobs = args.j
if njobs == 0:
Expand Down
10 changes: 4 additions & 6 deletions script/zip_manifests/check-zip-manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def main(zip_path, manifest_in):
with open(manifest_in, 'r') as manifest, \
zipfile.ZipFile(zip_path, 'r', allowZip64=True) as z:
files_in_zip = set(z.namelist())
files_in_manifest = set([l.strip() for l in manifest.readlines()])
files_in_manifest = {l.strip() for l in manifest.readlines()}
added_files = files_in_zip - files_in_manifest
removed_files = files_in_manifest - files_in_zip
if added_files:
Expand All @@ -18,10 +18,8 @@ def main(zip_path, manifest_in):
print("Files removed from bundle:")
for f in sorted(list(removed_files)):
print('-' + f)
if added_files or removed_files:
return 1
else:
return 0

return 1 if added_files or removed_files else 0

if __name__ == '__main__':
sys.exit(main(*sys.argv[1:]))
sys.exit(main(sys.argv[1], sys.argv[2]))

0 comments on commit 53aab6a

Please sign in to comment.