Skip to content

Commit 43da2c7

Browse files
authored
Update flake8 and fix errors (WebAssembly#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.
1 parent ac7cae5 commit 43da2c7

File tree

10 files changed

+17
-69
lines changed

10 files changed

+17
-69
lines changed

.flake8

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
[flake8]
22
ignore =
3-
E501, # line too long
4-
E241, # space after comma (ignored for list in gen-s-parser.py)
5-
W504 # line break after binary operator
3+
; line too long
4+
E501,
5+
; space after comma (ignored for list in gen-s-parser.py)
6+
E241,
7+
; line break after binary operator
8+
W504
69
exclude = third_party,./test/emscripten,./test/spec,./test/wasm-install,./test/lit

.github/workflows/ci.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
fetch-depth: 0
2929
- name: install tools
3030
run: |
31-
sudo pip3 install -r requirements-dev.txt
31+
pip3 install -r requirements-dev.txt
3232
sudo apt install lsb-release wget software-properties-common gnupg
3333
wget https://apt.llvm.org/llvm.sh
3434
sudo chmod +x llvm.sh

check.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
def get_changelog_version():
3333
with open(os.path.join(shared.options.binaryen_root, 'CHANGELOG.md')) as f:
3434
lines = f.readlines()
35-
lines = [l for l in lines if len(l.split()) == 1]
36-
lines = [l for l in lines if l.startswith('v')]
35+
lines = [line for line in lines if len(line.split()) == 1]
36+
lines = [line for line in lines if line.startswith('v')]
3737
version = lines[0][1:]
3838
print("Parsed CHANGELOG.md version: %s" % version)
3939
return int(version)

requirements-dev.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
# Install with `pip3 install -r requirements-dev.txt`
55

6-
flake8==3.7.8
6+
flake8==7.1.1
77
filecheck==0.0.22
88
lit==0.11.0.post1

scripts/fuzz_opt.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ def run_vms(self, wasm):
990990
print('(ignored, so not running other VMs)')
991991

992992
# the ignoring should have been noted during run_vms()
993-
assert(ignored_vm_runs > ignored_before)
993+
assert ignored_vm_runs > ignored_before
994994

995995
return vm_results
996996

scripts/port_passes_tests_to_lit.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def port_test(args, test):
6767
run_line = (f';; RUN: foreach %s %t wasm-opt {" ".join(opts)} -S -o -'
6868
' | filecheck %s')
6969

70-
notice = (f';; NOTE: This test was ported using'
70+
notice = (';; NOTE: This test was ported using'
7171
' port_passes_tests_to_lit.py and could be cleaned up.')
7272

7373
with open(test, 'r') as src_file:

scripts/storage.py

-55
This file was deleted.

scripts/test/shared.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ def __init__(self, returncode, cmd, output=None, stderr=None):
315315

316316

317317
def run_process(cmd, check=True, input=None, capture_output=False, decode_output=True, *args, **kw):
318-
if input and type(input) == str:
318+
if input and type(input) is str:
319319
input = bytes(input, 'utf-8')
320320
if capture_output:
321321
kw['stdout'] = subprocess.PIPE
@@ -358,7 +358,7 @@ def fail_if_not_contained(actual, expected):
358358

359359

360360
def fail_if_not_identical_to_file(actual, expected_file):
361-
binary = expected_file.endswith(".wasm") or type(actual) == bytes
361+
binary = expected_file.endswith(".wasm") or type(actual) is bytes
362362
with open(expected_file, 'rb' if binary else 'r') as f:
363363
fail_if_not_identical(actual, f.read(), fromfile=expected_file)
364364

scripts/test/support.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def to_end(j):
170170
# write a split wast from split_wast. the wast may be binary if the original
171171
# file was binary
172172
def write_wast(filename, wast, asserts=[]):
173-
if type(wast) == bytes:
173+
if type(wast) is bytes:
174174
assert not asserts
175175
with open(filename, 'wb') as o:
176176
o.write(wast)
@@ -182,7 +182,7 @@ def write_wast(filename, wast, asserts=[]):
182182
def run_command(cmd, expected_status=0, stderr=None,
183183
expected_err=None, err_contains=False, err_ignore=None):
184184
if expected_err is not None:
185-
assert stderr == subprocess.PIPE or stderr is None,\
185+
assert stderr == subprocess.PIPE or stderr is None, \
186186
"Can't redirect stderr if using expected_err"
187187
stderr = subprocess.PIPE
188188
print('executing: ', ' '.join(cmd))

scripts/update_lit_checks.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def itertests(args):
8888

8989

9090
def find_run_lines(test, lines):
91-
line_matches = [RUN_LINE_RE.match(l) for l in lines]
91+
line_matches = [RUN_LINE_RE.match(line) for line in lines]
9292
matches = [match.group(1) for match in line_matches if match]
9393
if not matches:
9494
warn(f'No RUN lines found in {test}. Ignoring.')

0 commit comments

Comments
 (0)