Skip to content

Commit e35d118

Browse files
authored
Update ruff to latest version. NFC (#25598)
1 parent 6ca3700 commit e35d118

File tree

11 files changed

+24
-15
lines changed

11 files changed

+24
-15
lines changed

emcc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ def run(args):
315315
linker_args = separate_linker_flags(newargs)[1]
316316
linker_args = [f.value for f in linker_args]
317317
# Delay import of link.py to avoid processing this file when only compiling
318-
from tools import link
318+
from tools import link # noqa: PLC0415
319319
link.run_post_link(options.input_files[0], options, linker_args)
320320
return 0
321321

emrun.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ def kill_browser_process():
387387
# so clear that record out.
388388
processname_killed_atexit = ''
389389

390-
if len(processname_killed_atexit):
390+
if processname_killed_atexit:
391391
if emrun_options.android:
392392
logv("Terminating Android app '" + processname_killed_atexit + "'.")
393393
subprocess.call([ADB, 'shell', 'am', 'force-stop', processname_killed_atexit])

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ lint.ignore = [
4343
"E741",
4444
"PERF203",
4545
"PERF401",
46+
"PLC0415",
4647
"PLR1704",
4748
"PLR5501",
4849
"PLW0602",

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
coverage[toml]==6.5
88
mypy==1.14
99
psutil==7.0.0
10-
ruff==0.11.7
10+
ruff==0.14.1
1111
types-requests==2.32.0.20241016
1212
unittest-xml-reporting==3.2.0
1313
deadcode==2.3.1

test/common.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1439,11 +1439,11 @@ def tearDown(self):
14391439

14401440
left_over_files = set(temp_files_after_run) - set(self.temp_files_before_run)
14411441
left_over_files = [f for f in left_over_files if not any(f.startswith(p) for p in ignorable_file_prefixes)]
1442-
if len(left_over_files):
1443-
errlog('ERROR: After running test, there are ' + str(len(left_over_files)) + ' new temporary files/directories left behind:')
1442+
if left_over_files:
1443+
errlog(f'ERROR: After running test, there are {len(left_over_files)} new temporary files/directories left behind:')
14441444
for f in left_over_files:
14451445
errlog('leaked file: ', f)
1446-
self.fail('Test leaked ' + str(len(left_over_files)) + ' temporary files!')
1446+
self.fail(f'Test leaked {len(left_over_files)} temporary files!')
14471447

14481448
def get_setting(self, key, default=None):
14491449
return self.settings_mods.get(key, default)

test/runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ def run_tests(options, suites):
421421
os.makedirs('out', exist_ok=True)
422422
# output fd must remain open until after testRunner.run() below
423423
output = open('out/test-results.xml', 'wb')
424-
import xmlrunner # type: ignore
424+
import xmlrunner # type: ignore # noqa: PLC0415
425425
testRunner = xmlrunner.XMLTestRunner(output=output, verbosity=2,
426426
failfast=options.failfast)
427427
print('Writing XML test output to ' + os.path.abspath(output.name))

test/test_other.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import importlib
1010
import itertools
1111
import json
12+
import locale
1213
import os
1314
import random
1415
import re
@@ -13164,7 +13165,6 @@ def test_response_file_encoding(self):
1316413165
open('a.rsp.cp437', 'w', encoding='cp437').write('äö.c') # Write a response file with Windows CP-437 encoding ...
1316513166
self.run_process([EMCC, '@a.rsp.cp437']) # ... and test that with the explicit suffix present, it is properly decoded
1316613167

13167-
import locale
1316813168
preferred_encoding = locale.getpreferredencoding(do_setlocale=False)
1316913169
print('Python locale preferredencoding: ' + preferred_encoding)
1317013170
open('a.rsp', 'w', encoding=preferred_encoding).write('äö.c') # Write a response file using Python preferred encoding

test/test_sockets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ def __enter__(self):
8989
self.processes.append(process)
9090

9191
try:
92-
import websockify # type: ignore
92+
import websockify # type: ignore # noqa: PLC0415
9393
except ModuleNotFoundError:
9494
raise Exception('Unable to import module websockify. Run "python3 -m pip install websockify" or set environment variable EMTEST_SKIP_PYTHON_DEV_PACKAGES=1 to skip this test.') from None
9595

tools/building.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,16 @@
1515
from subprocess import PIPE
1616
from typing import Dict, Set
1717

18-
from . import cache, config, diagnostics, response_file, shared, utils, webassembly
18+
from . import (
19+
cache,
20+
config,
21+
diagnostics,
22+
js_optimizer,
23+
response_file,
24+
shared,
25+
utils,
26+
webassembly,
27+
)
1928
from .feature_matrix import UNSUPPORTED
2029
from .settings import settings
2130
from .shared import (
@@ -354,8 +363,7 @@ def opt_level_to_str(opt_level, shrink_level=0):
354363
return f'-O{min(opt_level, 3)}'
355364

356365

357-
def js_optimizer(filename, passes):
358-
from . import js_optimizer
366+
def run_js_optimizer(filename, passes):
359367
try:
360368
return js_optimizer.run_on_file(filename, passes)
361369
except subprocess.CalledProcessError as e:
@@ -975,7 +983,7 @@ def wasm2js(js_file, wasm_file, opt_level, use_closure_compiler, debug_info, sym
975983
wasm2js_js = wasm2js_js.replace('\n }', '\n}')
976984
temp = shared.get_temp_files().get('.js').name
977985
utils.write_file(temp, wasm2js_js)
978-
temp = js_optimizer(temp, passes)
986+
temp = run_js_optimizer(temp, passes)
979987
wasm2js_js = utils.read_file(temp)
980988
# Closure compiler: in mode 1, we just minify the shell. In mode 2, we
981989
# minify the wasm2js output as well, which is ok since it isn't

tools/file_packager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ def was_seen(name):
571571

572572
ret = generate_js(data_target, data_files, metadata)
573573

574-
if options.force or len(data_files):
574+
if options.force or data_files:
575575
if options.jsoutput is None:
576576
print(ret)
577577
else:

0 commit comments

Comments
 (0)