summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Lively <tlively@google.com>2024-12-20 12:10:18 -0800
committerGitHub <noreply@github.com>2024-12-20 12:10:18 -0800
commit43da2c7ff5069a4cb5733b4efcdbd573977e3c46 (patch)
tree0a7a8505fb2cc9f060bb77a37845a99a5ad47b74
parentac7cae5ba45f2995b045927ed1d7c03f1fded227 (diff)
downloadbinaryen-43da2c7ff5069a4cb5733b4efcdbd573977e3c46.tar.gz
binaryen-43da2c7ff5069a4cb5733b4efcdbd573977e3c46.tar.bz2
binaryen-43da2c7ff5069a4cb5733b4efcdbd573977e3c46.zip
Update flake8 and fix errors (#7172)
The flake8 we were running on CI was too old and began giving spurious errors about the uninterpreted contents of f-strings. Update to the latest flake8 and fix all the new errors, including the previously incorrect comment syntax in the .flake8 file. Also remove scripts/storage.py, since it didn't seem to be used for anything we currently need.
-rw-r--r--.flake89
-rw-r--r--.github/workflows/ci.yml2
-rwxr-xr-xcheck.py4
-rw-r--r--requirements-dev.txt2
-rwxr-xr-xscripts/fuzz_opt.py2
-rwxr-xr-xscripts/port_passes_tests_to_lit.py2
-rwxr-xr-xscripts/storage.py55
-rw-r--r--scripts/test/shared.py4
-rw-r--r--scripts/test/support.py4
-rwxr-xr-xscripts/update_lit_checks.py2
10 files changed, 17 insertions, 69 deletions
diff --git a/.flake8 b/.flake8
index 83735a2f0..4e967e908 100644
--- a/.flake8
+++ b/.flake8
@@ -1,6 +1,9 @@
[flake8]
ignore =
- E501, # line too long
- E241, # space after comma (ignored for list in gen-s-parser.py)
- W504 # line break after binary operator
+ ; line too long
+ E501,
+ ; space after comma (ignored for list in gen-s-parser.py)
+ E241,
+ ; line break after binary operator
+ W504
exclude = third_party,./test/emscripten,./test/spec,./test/wasm-install,./test/lit
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 01b125a7a..b826c840b 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -28,7 +28,7 @@ jobs:
fetch-depth: 0
- name: install tools
run: |
- sudo pip3 install -r requirements-dev.txt
+ pip3 install -r requirements-dev.txt
sudo apt install lsb-release wget software-properties-common gnupg
wget https://apt.llvm.org/llvm.sh
sudo chmod +x llvm.sh
diff --git a/check.py b/check.py
index 66493dd3c..dfaada0ab 100755
--- a/check.py
+++ b/check.py
@@ -32,8 +32,8 @@ from scripts.test import wasm_opt
def get_changelog_version():
with open(os.path.join(shared.options.binaryen_root, 'CHANGELOG.md')) as f:
lines = f.readlines()
- lines = [l for l in lines if len(l.split()) == 1]
- lines = [l for l in lines if l.startswith('v')]
+ lines = [line for line in lines if len(line.split()) == 1]
+ lines = [line for line in lines if line.startswith('v')]
version = lines[0][1:]
print("Parsed CHANGELOG.md version: %s" % version)
return int(version)
diff --git a/requirements-dev.txt b/requirements-dev.txt
index 8bffeb2a9..511ad43bd 100644
--- a/requirements-dev.txt
+++ b/requirements-dev.txt
@@ -3,6 +3,6 @@
# Install with `pip3 install -r requirements-dev.txt`
-flake8==3.7.8
+flake8==7.1.1
filecheck==0.0.22
lit==0.11.0.post1
diff --git a/scripts/fuzz_opt.py b/scripts/fuzz_opt.py
index 58d1a022a..27f85e7a0 100755
--- a/scripts/fuzz_opt.py
+++ b/scripts/fuzz_opt.py
@@ -990,7 +990,7 @@ class CompareVMs(TestCaseHandler):
print('(ignored, so not running other VMs)')
# the ignoring should have been noted during run_vms()
- assert(ignored_vm_runs > ignored_before)
+ assert ignored_vm_runs > ignored_before
return vm_results
diff --git a/scripts/port_passes_tests_to_lit.py b/scripts/port_passes_tests_to_lit.py
index 659cc20d2..6e82c4551 100755
--- a/scripts/port_passes_tests_to_lit.py
+++ b/scripts/port_passes_tests_to_lit.py
@@ -67,7 +67,7 @@ def port_test(args, test):
run_line = (f';; RUN: foreach %s %t wasm-opt {" ".join(opts)} -S -o -'
' | filecheck %s')
- notice = (f';; NOTE: This test was ported using'
+ notice = (';; NOTE: This test was ported using'
' port_passes_tests_to_lit.py and could be cleaned up.')
with open(test, 'r') as src_file:
diff --git a/scripts/storage.py b/scripts/storage.py
deleted file mode 100755
index d7ae42e13..000000000
--- a/scripts/storage.py
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/usr/bin/env python3
-#
-# Copyright 2016 WebAssembly Community Group participants
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-from __future__ import print_function
-
-import glob
-import json
-import os
-import urllib2
-
-
-STORAGE_BASE = 'https://storage.googleapis.com/wasm-llvm/builds/git/'
-
-
-def download_revision(force_latest):
- name = 'latest' if force_latest else 'lkgr'
- downloaded = urllib2.urlopen(STORAGE_BASE + name).read().strip()
- # TODO: for now try opening as JSON, if that doesn't work then the content is
- # just a hash. The waterfall is in the process of migrating to JSON.
- info = None
- try:
- info = json.loads(downloaded)
- except ValueError:
- pass
- return info['build'] if type(info) == dict else downloaded
-
-
-def download_tar(tar_pattern, directory, revision):
- tar_path = os.path.join(directory, tar_pattern)
- revision_tar_path = tar_path % revision
- if os.path.isfile(revision_tar_path):
- print('Already have `%s`' % revision_tar_path)
- else:
- print('Downloading `%s`' % revision_tar_path)
- with open(revision_tar_path, 'w+') as f:
- f.write(urllib2.urlopen(STORAGE_BASE + tar_pattern % revision).read())
- # Remove any previous tarfiles.
- for older_tar in glob.glob(tar_path % '*'):
- if older_tar != revision_tar_path:
- print('Removing older tar file `%s`' % older_tar)
- os.remove(older_tar)
- return revision_tar_path
diff --git a/scripts/test/shared.py b/scripts/test/shared.py
index e0a51a73a..ac9a408b6 100644
--- a/scripts/test/shared.py
+++ b/scripts/test/shared.py
@@ -315,7 +315,7 @@ class Py2CalledProcessError(subprocess.CalledProcessError):
def run_process(cmd, check=True, input=None, capture_output=False, decode_output=True, *args, **kw):
- if input and type(input) == str:
+ if input and type(input) is str:
input = bytes(input, 'utf-8')
if capture_output:
kw['stdout'] = subprocess.PIPE
@@ -358,7 +358,7 @@ def fail_if_not_contained(actual, expected):
def fail_if_not_identical_to_file(actual, expected_file):
- binary = expected_file.endswith(".wasm") or type(actual) == bytes
+ binary = expected_file.endswith(".wasm") or type(actual) is bytes
with open(expected_file, 'rb' if binary else 'r') as f:
fail_if_not_identical(actual, f.read(), fromfile=expected_file)
diff --git a/scripts/test/support.py b/scripts/test/support.py
index 43bd00fe8..a41fee227 100644
--- a/scripts/test/support.py
+++ b/scripts/test/support.py
@@ -170,7 +170,7 @@ def split_wast(wastFile):
# write a split wast from split_wast. the wast may be binary if the original
# file was binary
def write_wast(filename, wast, asserts=[]):
- if type(wast) == bytes:
+ if type(wast) is bytes:
assert not asserts
with open(filename, 'wb') as o:
o.write(wast)
@@ -182,7 +182,7 @@ def write_wast(filename, wast, asserts=[]):
def run_command(cmd, expected_status=0, stderr=None,
expected_err=None, err_contains=False, err_ignore=None):
if expected_err is not None:
- assert stderr == subprocess.PIPE or stderr is None,\
+ assert stderr == subprocess.PIPE or stderr is None, \
"Can't redirect stderr if using expected_err"
stderr = subprocess.PIPE
print('executing: ', ' '.join(cmd))
diff --git a/scripts/update_lit_checks.py b/scripts/update_lit_checks.py
index 345ff39d0..b6bb213a8 100755
--- a/scripts/update_lit_checks.py
+++ b/scripts/update_lit_checks.py
@@ -88,7 +88,7 @@ def itertests(args):
def find_run_lines(test, lines):
- line_matches = [RUN_LINE_RE.match(l) for l in lines]
+ line_matches = [RUN_LINE_RE.match(line) for line in lines]
matches = [match.group(1) for match in line_matches if match]
if not matches:
warn(f'No RUN lines found in {test}. Ignoring.')