Skip to content

Commit 20b19b2

Browse files
authored
Fix flake8 errors/warnings. NFC (#23930)
Turns out ruff still doesn't support several flake8 warnings. I've enabled some more that are in preview-only mode. See #23085
1 parent 79ee3d1 commit 20b19b2

File tree

7 files changed

+31
-32
lines changed

7 files changed

+31
-32
lines changed

.circleci/config.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -437,8 +437,8 @@ jobs:
437437
- checkout
438438
- pip-install
439439
- run: ruff check
440-
# TODO (cclauss): When ruff supports rules E20,E30 without --preview, remove following line
441-
- run: ruff check --preview --select=E20,E30
440+
# TODO (cclauss): When ruff supports rules these errors without --preview, remove following line
441+
- run: ruff check --preview --select=E20,E30,E221,E225,E226
442442
mypy:
443443
executor: focal
444444
steps:

emsymbolizer.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ def symbolize_address_sourcemap(module, address, force_file):
211211
print(sm.mappings)
212212
# Print with section offsets to easily compare against dwarf
213213
for k, v in sm.mappings.items():
214-
print(f'{k-csoff:x}: {v}')
214+
print(f'{k - csoff:x}: {v}')
215215
sm.lookup(address).print()
216216

217217

test/test_browser.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -1370,7 +1370,7 @@ def test_fs_idbfs_fsync(self):
13701370

13711371
args = ['--pre-js', 'pre.js', '-lidbfs.js', '-sEXIT_RUNTIME', '-sASYNCIFY']
13721372
secret = str(time.time())
1373-
self.btest('fs/test_idbfs_fsync.c', '1', emcc_args=args + ['-DFIRST', f'-DSECRET="{secret }"', '-lidbfs.js'])
1373+
self.btest('fs/test_idbfs_fsync.c', '1', emcc_args=args + ['-DFIRST', f'-DSECRET="{secret}"', '-lidbfs.js'])
13741374
self.btest('fs/test_idbfs_fsync.c', '1', emcc_args=args + [f'-DSECRET="{secret}"', '-lidbfs.js'])
13751375

13761376
def test_fs_memfs_fsync(self):
@@ -1392,7 +1392,7 @@ def test_fs_workerfs_read(self):
13921392
}, '/work');
13931393
};
13941394
''' % (secret, secret2))
1395-
self.btest_exit('fs/test_workerfs_read.c', emcc_args=['-lworkerfs.js', '--pre-js', 'pre.js', f'-DSECRET="{secret }"', f'-DSECRET2="{secret2}"', '--proxy-to-worker', '-lworkerfs.js'])
1395+
self.btest_exit('fs/test_workerfs_read.c', emcc_args=['-lworkerfs.js', '--pre-js', 'pre.js', f'-DSECRET="{secret}"', f'-DSECRET2="{secret2}"', '--proxy-to-worker', '-lworkerfs.js'])
13961396

13971397
def test_fs_workerfs_package(self):
13981398
self.set_setting('DEFAULT_LIBRARY_FUNCS_TO_INCLUDE', '$ccall')
@@ -1445,8 +1445,8 @@ def test_fs_lz4fs_package(self):
14451445
self.btest_exit('fs/test_lz4fs.cpp', 1, emcc_args=['-DLOAD_MANUALLY', '-sLZ4', '-sFORCE_FILESYSTEM', '-O2'])
14461446
print(' opts+closure')
14471447
self.btest_exit('fs/test_lz4fs.cpp', 1, emcc_args=['-DLOAD_MANUALLY', '-sLZ4',
1448-
'-sFORCE_FILESYSTEM', '-O2',
1449-
'--closure=1', '-g1', '-Wno-closure'])
1448+
'-sFORCE_FILESYSTEM', '-O2',
1449+
'--closure=1', '-g1', '-Wno-closure'])
14501450

14511451
'''# non-lz4 for comparison
14521452
try:
@@ -4367,12 +4367,12 @@ def test_webgl_multi_draw(self, args):
43674367
def test_webgl_draw_base_vertex_base_instance(self, multi_draw, draw_elements):
43684368
self.reftest('webgl_draw_base_vertex_base_instance_test.c', 'webgl_draw_instanced_base_vertex_base_instance.png',
43694369
emcc_args=['-lGL',
4370-
'-sMAX_WEBGL_VERSION=2',
4371-
'-sOFFSCREEN_FRAMEBUFFER',
4372-
'-DMULTI_DRAW=' + str(multi_draw),
4373-
'-DDRAW_ELEMENTS=' + str(draw_elements),
4374-
'-DEXPLICIT_SWAP=1',
4375-
'-DWEBGL_CONTEXT_VERSION=2'])
4370+
'-sMAX_WEBGL_VERSION=2',
4371+
'-sOFFSCREEN_FRAMEBUFFER',
4372+
'-DMULTI_DRAW=' + str(multi_draw),
4373+
'-DDRAW_ELEMENTS=' + str(draw_elements),
4374+
'-DEXPLICIT_SWAP=1',
4375+
'-DWEBGL_CONTEXT_VERSION=2'])
43764376

43774377
@requires_graphics_hardware
43784378
def test_webgl_sample_query(self):
@@ -5390,8 +5390,8 @@ def test_wasmfs_fetch_backend(self, args):
53905390
create_file('subdir/backendfile2', 'file 2')
53915391
self.btest_exit('wasmfs/wasmfs_fetch.c',
53925392
emcc_args=['-sWASMFS', '-pthread', '-sPROXY_TO_PTHREAD',
5393-
'-sFORCE_FILESYSTEM', '-lfetchfs.js',
5394-
'--js-library', test_file('wasmfs/wasmfs_fetch.js')] + args)
5393+
'-sFORCE_FILESYSTEM', '-lfetchfs.js',
5394+
'--js-library', test_file('wasmfs/wasmfs_fetch.js')] + args)
53955395

53965396
@no_firefox('no OPFS support yet')
53975397
@no_wasm64()

test/test_core.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -3778,8 +3778,7 @@ def test_dlfcn_jspi(self):
37783778
"side.so",
37793779
test_file("core/test_dlfcn_jspi_side.c"),
37803780
"-sSIDE_MODULE",
3781-
]
3782-
+ self.get_emcc_args()
3781+
] + self.get_emcc_args()
37833782
)
37843783
self.do_run_in_out_file_test("core/test_dlfcn_jspi.c", emcc_args=["side.so", "-sMAIN_MODULE=2"])
37853784

@@ -8068,7 +8067,7 @@ def test_async_ccall_good(self):
80688067
})
80698068
@with_asyncify_and_jspi
80708069
def test_async_ccall_promise(self, exit_runtime):
8071-
if self.get_setting('ASYNCIFY') == 2:
8070+
if self.get_setting('ASYNCIFY') == 2:
80728071
self.set_setting('JSPI_EXPORTS', ['stringf', 'floatf'])
80738072
self.set_setting('ASSERTIONS')
80748073
self.set_setting('INVOKE_RUN', 0)

test/test_other.py

+12-12
Original file line numberDiff line numberDiff line change
@@ -8501,15 +8501,15 @@ def test(p1, p2, p3, last, expected):
85018501
return os.path.getsize('a.out.wasm')
85028502

85038503
print('no bad ctor')
8504-
first = test(1000, 2000, 3000, 0xe, 0x58e) # noqa
8505-
second = test(3000, 1000, 2000, 0xe, 0x8e5) # noqa
8506-
third = test(2000, 3000, 1000, 0xe, 0xe58) # noqa
8504+
first = test(1000, 2000, 3000, 0xe, 0x58e) # noqa: E221
8505+
second = test(3000, 1000, 2000, 0xe, 0x8e5)
8506+
third = test(2000, 3000, 1000, 0xe, 0xe58) # noqa: E221
85078507
print(first, second, third)
85088508
assert first == second and second == third
85098509
print('with bad ctor')
8510-
first = test(1000, 2000, 3000, 0xf, 0x58f) # noqa; 2 will succeed
8511-
second = test(3000, 1000, 2000, 0xf, 0x8f5) # noqa; 1 will succedd
8512-
third = test(2000, 3000, 1000, 0xf, 0xf58) # noqa; 0 will succeed
8510+
first = test(1000, 2000, 3000, 0xf, 0x58f) # noqa: E221. 2 will succeed
8511+
second = test(3000, 1000, 2000, 0xf, 0x8f5) # 1 will succedd
8512+
third = test(2000, 3000, 1000, 0xf, 0xf58) # noqa: E221. 0 will succeed
85138513
print(first, second, third)
85148514
self.assertLess(first, second)
85158515
self.assertLess(second, third)
@@ -9182,12 +9182,12 @@ def test_codesize_cxx(self, *args):
91829182
self.run_codesize_test('hello_libcxx.cpp', *args, check_funcs=False)
91839183

91849184
@parameterized({
9185-
'O0': ([], [], ['waka']), # noqa
9186-
'O1': (['-O1'], [], ['waka']), # noqa
9187-
'O2': (['-O2'], [], ['waka']), # noqa
9188-
'O3': (['-O3'], [], []), # noqa; in -O3, -Os and -Oz we metadce
9189-
'Os': (['-Os'], [], []), # noqa
9190-
'Oz': (['-Oz'], [], []), # noqa
9185+
'O0': ([], [], ['waka']),
9186+
'O1': (['-O1'], [], ['waka']),
9187+
'O2': (['-O2'], [], ['waka']),
9188+
'O3': (['-O3'], [], []), # in -O3, -Os and -Oz we metadce
9189+
'Os': (['-Os'], [], []),
9190+
'Oz': (['-Oz'], [], []),
91919191
# finally, check what happens when we export nothing. wasm should be almost empty
91929192
'export_nothing':
91939193
(['-Os', '-sEXPORTED_FUNCTIONS=[]'], [], []), # noqa

tools/file_packager.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ def generate_object_file(data_files):
284284
# The name of file
285285
{f.c_symbol_name}_name:
286286
.asciz "{dstpath}"
287-
.size {f.c_symbol_name}_name, {len(dstpath)+1}
287+
.size {f.c_symbol_name}_name, {len(dstpath) + 1}
288288
289289
# The size of the file followed by the content itself
290290
{f.c_symbol_name}:

tools/maint/npm_update.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def run(cmd, **args):
2323
def main():
2424
if run(['git', 'status', '-uno', '--porcelain']).strip():
2525
print('tree is not clean')
26-
#return 1
26+
return 1
2727

2828
output = run(['npx', 'npm-check-updates', '-u'], stderr=subprocess.STDOUT).strip()
2929

0 commit comments

Comments
 (0)