From c27e5fdbb6793372fea4b0a8624138b4041b93a5 Mon Sep 17 00:00:00 2001 From: David Sanders Date: Mon, 19 Oct 2020 04:55:27 -0700 Subject: [PATCH] chore: fix linter errors (#25996) --- script/lib/patches.py | 3 +- script/release/uploaders/upload-symbols.py | 4 ++- script/release/uploaders/upload.py | 33 +++++++++++++--------- script/strip-binaries.py | 4 ++- script/update-external-binaries.py | 9 ++++-- script/verify-chromedriver.py | 4 ++- 6 files changed, 37 insertions(+), 20 deletions(-) diff --git a/script/lib/patches.py b/script/lib/patches.py index 2365303de0cb..8910dd412668 100644 --- a/script/lib/patches.py +++ b/script/lib/patches.py @@ -12,7 +12,8 @@ def read_patch(patch_dir, patch_filename): patch_path = os.path.join(patch_dir, patch_filename) with codecs.open(patch_path, encoding='utf-8') as f: for l in f.readlines(): - if not added_filename_line and (l.startswith('diff -') or l.startswith('---')): + line_has_correct_start = l.startswith('diff -') or l.startswith('---') + if not added_filename_line and line_has_correct_start: ret.append('Patch-Filename: {}\n'.format(patch_filename)) added_filename_line = True ret.append(l) diff --git a/script/release/uploaders/upload-symbols.py b/script/release/uploaders/upload-symbols.py index 86ce0ae5a8a8..a2d561b56d3e 100755 --- a/script/release/uploaders/upload-symbols.py +++ b/script/release/uploaders/upload-symbols.py @@ -46,7 +46,9 @@ def main(): for symbol_file in files: print("Generating Sentry src bundle for: " + symbol_file) - subprocess.check_output([NPX_CMD, '@sentry/cli@1.51.1', 'difutil', 'bundle-sources', symbol_file]) + subprocess.check_output([ + NPX_CMD, '@sentry/cli@1.51.1', 'difutil', 'bundle-sources', + symbol_file]) files += glob.glob(SYMBOLS_DIR + '/*/*/*.src.zip') diff --git a/script/release/uploaders/upload.py b/script/release/uploaders/upload.py index 2e82ce780907..02026c7f295e 100755 --- a/script/release/uploaders/upload.py +++ b/script/release/uploaders/upload.py @@ -36,7 +36,8 @@ SYMBOLS_NAME = get_zip_name(PROJECT_NAME, ELECTRON_VERSION, 'symbols') DSYM_NAME = get_zip_name(PROJECT_NAME, ELECTRON_VERSION, 'dsym') PDB_NAME = get_zip_name(PROJECT_NAME, ELECTRON_VERSION, 'pdb') DEBUG_NAME = get_zip_name(PROJECT_NAME, ELECTRON_VERSION, 'debug') -TOOLCHAIN_PROFILE_NAME = get_zip_name(PROJECT_NAME, ELECTRON_VERSION, 'toolchain-profile') +TOOLCHAIN_PROFILE_NAME = get_zip_name(PROJECT_NAME, ELECTRON_VERSION, + 'toolchain-profile') def main(): @@ -59,7 +60,8 @@ def main(): tag_exists = True if not args.upload_to_s3: - assert release['exists'], 'Release does not exist; cannot upload to GitHub!' + assert release['exists'], \ + 'Release does not exist; cannot upload to GitHub!' assert tag_exists == args.overwrite, \ 'You have to pass --overwrite to overwrite a published release' @@ -114,7 +116,8 @@ def main(): if PLATFORM == 'linux' and get_target_arch() == 'x64': # Upload the hunspell dictionaries only from the linux x64 build - hunspell_dictionaries_zip = os.path.join(OUT_DIR, 'hunspell_dictionaries.zip') + hunspell_dictionaries_zip = os.path.join( + OUT_DIR, 'hunspell_dictionaries.zip') upload_electron(release, hunspell_dictionaries_zip, args) if not tag_exists and not args.upload_to_s3: @@ -126,7 +129,9 @@ def main(): if PLATFORM == 'win32': toolchain_profile_zip = os.path.join(OUT_DIR, TOOLCHAIN_PROFILE_NAME) with ZipFile(toolchain_profile_zip, 'w') as myzip: - myzip.write(os.path.join(OUT_DIR, 'windows_toolchain_profile.json'), 'toolchain_profile.json') + myzip.write( + os.path.join(OUT_DIR, 'windows_toolchain_profile.json'), + 'toolchain_profile.json') upload_electron(release, toolchain_profile_zip, args) @@ -170,12 +175,10 @@ class NonZipFileError(ValueError): def zero_zip_date_time(fname): """ Wrap strip-zip zero_zip_date_time within a file opening operation """ try: - zip = open(fname, 'r+b') - _zero_zip_date_time(zip) + with open(fname, 'r+b') as f: + _zero_zip_date_time(f) except: raise NonZipFileError(fname) - finally: - zip.close() def _zero_zip_date_time(zip_): @@ -208,7 +211,7 @@ def _zero_zip_date_time(zip_): _, header_length = values extra_struct = Struct("