Skip to content

Commit 0044857

Browse files
authored
Update ruff to latest version. NFC (emscripten-core#27415)
1 parent 7054160 commit 0044857

22 files changed

Lines changed: 95 additions & 98 deletions

emrun.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1596,7 +1596,7 @@ def parse_args(args):
15961596
return parser.parse_args(args)
15971597

15981598

1599-
def run(args): # noqa: C901, PLR0912, PLR0915
1599+
def run(args): # ruff: ignore[complex-structure, too-many-branches, too-many-statements]
16001600
"""Future modifications should consider refactoring to reduce complexity.
16011601
16021602
* The McCabe cyclomatiic complexity is currently 74 vs 10 recommended.

pyproject.toml

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -39,59 +39,59 @@ lint.select = [
3939
]
4040
lint.external = [ "D" ]
4141
lint.ignore = [
42-
"D100", # https://docs.astral.sh/ruff/rules/undocumented-public-module/
43-
"D101", # https://docs.astral.sh/ruff/rules/undocumented-public-class/
44-
"D102", # https://docs.astral.sh/ruff/rules/undocumented-public-method/
45-
"D103", # https://docs.astral.sh/ruff/rules/undocumented-public-function/
46-
"D104", # https://docs.astral.sh/ruff/rules/undocumented-public-package/
47-
"D105", # https://docs.astral.sh/ruff/rules/undocumented-magic-method/
48-
"D106", # https://docs.astral.sh/ruff/rules/undocumented-public-nested-class/
49-
"D107", # https://docs.astral.sh/ruff/rules/undocumented-public-init/
50-
"D203", # https://docs.astral.sh/ruff/rules/incorrect-blank-line-before-class/
51-
"D213", # https://docs.astral.sh/ruff/rules/multi-line-summary-second-line/
52-
"D401", # https://docs.astral.sh/ruff/rules/non-imperative-mood/
53-
"B011", # See https://github.com/PyCQA/flake8-bugbear/issues/66
54-
"B023",
55-
"B026",
56-
"E272",
57-
"E402",
58-
"E241",
59-
"E266",
60-
"E501",
61-
"E721",
62-
"E741",
63-
"E111", # Does not seem to honor `indent-width = 2` above
64-
"E114", # Does not seem to honor `indent-width = 2` above
65-
"E261",
66-
"PERF203",
67-
"PERF401",
68-
"PLC0415",
69-
"PLR0904",
70-
"PLR0916",
71-
"PLR0914",
72-
"PLR1702",
73-
"PLR1704",
74-
"PLR5501",
75-
"PLR6301",
76-
"PLW0602",
77-
"PLW0603",
78-
"PLW0717", # https://docs.astral.sh/ruff/rules/too-many-statements-in-try-clause
79-
"PLW1510",
80-
"PLW2901",
81-
"RUF012", # https://docs.astral.sh/ruff/rules/mutable-class-default/
82-
"RUF015", # https://docs.astral.sh/ruff/rules/unnecessary-iterable-allocation-for-first-element/
83-
"RUF027", # https://docs.astral.sh/ruff/rules/missing-f-string-syntax/
84-
"RUF039", # https://docs.astral.sh/ruff/rules/unraw-re-pattern/
85-
"RUF067", # https://docs.astral.sh/ruff/rules/non-empty-init-module/
86-
"UP030", # TODO
87-
"UP031", # TODO
88-
"UP032", # TODO
42+
"undocumented-public-module",
43+
"undocumented-public-class",
44+
"undocumented-public-method",
45+
"undocumented-public-function",
46+
"undocumented-public-package",
47+
"undocumented-magic-method",
48+
"undocumented-public-nested-class",
49+
"undocumented-public-init",
50+
"incorrect-blank-line-before-class",
51+
"multi-line-summary-second-line",
52+
"non-imperative-mood",
53+
"assert-false", # See https://github.com/PyCQA/flake8-bugbear/issues/66
54+
"function-uses-loop-variable",
55+
"star-arg-unpacking-after-keyword-arg",
56+
"multiple-spaces-before-keyword",
57+
"module-import-not-at-top-of-file",
58+
"multiple-spaces-after-comma",
59+
"multiple-leading-hashes-for-block-comment",
60+
"line-too-long",
61+
"type-comparison",
62+
"ambiguous-variable-name",
63+
"indentation-with-invalid-multiple", # Does not seem to honor `indent-width = 2` above
64+
"indentation-with-invalid-multiple-comment", # Does not seem to honor `indent-width = 2` above
65+
"too-few-spaces-before-inline-comment",
66+
"try-except-in-loop",
67+
"manual-list-comprehension",
68+
"import-outside-top-level",
69+
"too-many-public-methods",
70+
"too-many-boolean-expressions",
71+
"too-many-locals",
72+
"too-many-nested-blocks",
73+
"redefined-argument-from-local",
74+
"collapsible-else-if",
75+
"no-self-use",
76+
"global-variable-not-assigned",
77+
"global-statement",
78+
"too-many-statements-in-try-clause",
79+
"subprocess-run-without-check",
80+
"redefined-loop-name",
81+
"mutable-class-default",
82+
"unnecessary-iterable-allocation-for-first-element",
83+
"missing-f-string-syntax",
84+
"unraw-re-pattern",
85+
"non-empty-init-module",
86+
"format-literals", # TODO
87+
"printf-string-formatting", # TODO
88+
"f-string", # TODO
8989
]
90-
lint.per-file-ignores."tools/ports/*.py" = [ "ARG001", "ARG005" ]
91-
lint.per-file-ignores."test/other/ports/*.py" = [ "ARG001" ]
92-
lint.per-file-ignores."test/parallel_testsuite.py" = [ "ARG002" ]
93-
lint.per-file-ignores."test/test_benchmark.py" = [ "ARG002" ]
94-
lint.per-file-ignores."test/*.py" = [ "RUF005" ]
90+
lint.per-file-ignores."tools/ports/*.py" = [ "unused-function-argument", "unused-lambda-argument" ]
91+
lint.per-file-ignores."test/other/ports/*.py" = [ "unused-function-argument" ]
92+
lint.per-file-ignores."test/parallel_testsuite.py" = [ "unused-method-argument" ]
93+
lint.per-file-ignores."test/test_benchmark.py" = [ "unused-method-argument" ]
94+
lint.per-file-ignores."test/*.py" = [ "collection-literal-concatenation" ]
9595
lint.mccabe.max-complexity = 51 # Recommended: 10
9696
lint.pylint.allow-magic-value-types = [
9797
"bytes",

requirements-dev.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
coverage[toml]==7.15.0
88
mypy==2.3.0
99
psutil==7.0.0
10-
ruff==0.15.21
10+
ruff==0.16.0
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
@@ -912,7 +912,7 @@ def is_ldflag(f):
912912
for i, arg in enumerate(args):
913913
if arg in {'--pre-js', '--post-js'}:
914914
args[i] = None
915-
args[i + 1] = None # noqa: B909
915+
args[i + 1] = None # ruff: ignore[loop-iterator-mutation]
916916
args = [arg for arg in args if arg is not None]
917917
return args
918918

@@ -1199,7 +1199,7 @@ def get_build_dir(self):
11991199
ensure_dir(ret)
12001200
return ret
12011201

1202-
def get_library(self, name, generated_libs, configure=['sh', './configure'], # noqa
1202+
def get_library(self, name, generated_libs, configure=['sh', './configure'], # ruff: ignore[mutable-argument-default]
12031203
configure_args=None, make=None, make_args=None,
12041204
env_init=None, cache_name_extra='', native=False,
12051205
force_rebuild=False):
@@ -1288,7 +1288,7 @@ def run_process(self, cmd, check=True, **kwargs):
12881288
rtn.stderr = None
12891289
return rtn
12901290

1291-
def emcc(self, filename, args=[], **kwargs): # noqa
1291+
def emcc(self, filename, args=[], **kwargs): # ruff: ignore[mutable-argument-default]
12921292
filename = maybe_test_file(filename)
12931293
compile_only = '-c' in args or '-sSIDE_MODULE' in args
12941294
cmd = [compiler_for(filename), filename] + self.get_cflags(compile_only=compile_only) + args

test/sockets/socket_relay.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424

2525
class Listener(threading.Thread):
26-
other: Listener | None = None # noqa: F821
26+
other: Listener | None = None # ruff: ignore[undefined-name]
2727

2828
def run(self):
2929
self.conn = None

test/test_benchmark.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1188,7 +1188,7 @@ def test_zzz_poppler(self):
11881188
}
11891189
''' % DEFAULT_ARG)
11901190

1191-
def lib_builder(name, native, env_init): # noqa
1191+
def lib_builder(_name, _native, env_init):
11921192
if '-m64' in env_init.get('CFLAGS', ''):
11931193
env_init['CPPFLAGS'] = '-m64'
11941194
env_init['LDFLAGS'] = '-m64'

test/test_closure_args_port.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
import os
22

33

4-
def get(ports, settings, shared): # noqa: ARG001
4+
def get(_ports, _settings, _shared):
55
return []
66

77

8-
def clear(ports, settings, shared):
8+
def clear(_ports, _settings, _shared):
99
pass
1010

1111

12-
def linker_setup(ports, settings): # noqa: ARG001
12+
def linker_setup(_ports, settings):
1313
externs_file = os.path.join(os.path.dirname(os.path.realpath(__file__)),
1414
'test_closure_externs.js')
1515
settings.CLOSURE_ARGS += [f'--externs={externs_file}']

test/test_codesize.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ def test_codesize_cxx(self, args):
404404
# prune unused imports/exports from it. See #27217.
405405
'esm_integration': (['-O3', '-sWASM_ESM_INTEGRATION', '-Wno-experimental'],),
406406
})
407-
def test_codesize_hello(self, args, kwargs={}): # noqa
407+
def test_codesize_hello(self, args, kwargs={}): # ruff: ignore[mutable-argument-default]
408408
self.run_codesize_test('hello_world.c', args, **kwargs)
409409

410410
@parameterized({

test/test_core.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9953,8 +9953,9 @@ def test_fcoverage_mapping(self):
99539953
self.assertExists('out.profdata')
99549954
self.assertEqual(expected, self.run_process([LLVM_COV, 'show', 'test_hello_world.wasm', '-instr-profile=out.profdata'], stdout=PIPE).stdout)
99559955

9956+
99569957
# Generate tests for everything
9957-
def make_run(name, cflags=None, settings=None, env=None, # noqa
9958+
def make_run(name, cflags=None, settings=None, env=None,
99589959
v8_args=None, node_args=None,
99599960
require_wasm64=False,
99609961
init=None):
@@ -9969,7 +9970,7 @@ def make_run(name, cflags=None, settings=None, env=None, # noqa
99699970
# we need to pass this flag here to avoid warnings from compile-only commands.
99709971
cflags.append('-Wno-unused-command-line-argument')
99719972

9972-
TT = type(name, (TestCoreBase,), dict(run_name=name, env=env, __module__=__name__)) # noqa
9973+
TT = type(name, (TestCoreBase,), dict(run_name=name, env=env, __module__=__name__)) # ruff: ignore[unnecessary-collection-call, undefined-name]
99739974

99749975
def tearDown(self):
99759976
try:

test/test_other.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -901,11 +901,11 @@ def test_cmake(self, test_dir, output_file, cmake_args):
901901
generators = ['Unix Makefiles', 'Ninja', 'Eclipse CDT4 - Ninja']
902902

903903
configurations = {
904-
'MinGW Makefiles' : {'build' : ['mingw32-make'] }, # noqa
905-
'NMake Makefiles' : {'build' : ['nmake', '/NOLOGO']}, # noqa
906-
'Unix Makefiles' : {'build' : ['make']}, # noqa
907-
'Ninja' : {'build' : ['ninja']}, # noqa
908-
'Eclipse CDT4 - Ninja': {'build' : ['ninja']}, # noqa
904+
'MinGW Makefiles' : {'build' : ['mingw32-make'] }, # ruff: ignore[whitespace-before-close-bracket, whitespace-before-punctuation]
905+
'NMake Makefiles' : {'build' : ['nmake', '/NOLOGO']}, # ruff: ignore[whitespace-before-punctuation]
906+
'Unix Makefiles' : {'build' : ['make']}, # ruff: ignore[whitespace-before-punctuation]
907+
'Ninja' : {'build' : ['ninja']}, # ruff: ignore[whitespace-before-punctuation]
908+
'Eclipse CDT4 - Ninja': {'build' : ['ninja']}, # ruff: ignore[whitespace-before-punctuation]
909909
}
910910
for generator in generators:
911911
conf = configurations[generator]
@@ -7949,15 +7949,15 @@ def test(p1, p2, p3, last, expected):
79497949
return os.path.getsize('a.out.wasm')
79507950

79517951
print('no bad ctor')
7952-
first = test(1000, 2000, 3000, 0xe, 0x58e) # noqa: E221
7952+
first = test(1000, 2000, 3000, 0xe, 0x58e) # ruff: ignore[multiple-spaces-before-operator]
79537953
second = test(3000, 1000, 2000, 0xe, 0x8e5)
7954-
third = test(2000, 3000, 1000, 0xe, 0xe58) # noqa: E221
7954+
third = test(2000, 3000, 1000, 0xe, 0xe58) # ruff: ignore[multiple-spaces-before-operator]
79557955
print(first, second, third)
79567956
assert first == second and second == third
79577957
print('with bad ctor')
7958-
first = test(1000, 2000, 3000, 0xf, 0x58f) # noqa: E221, 2 will succeed
7958+
first = test(1000, 2000, 3000, 0xf, 0x58f) # ruff: ignore[multiple-spaces-before-operator], 2 will succeed
79597959
second = test(3000, 1000, 2000, 0xf, 0x8f5) # 1 will succeed
7960-
third = test(2000, 3000, 1000, 0xf, 0xf58) # noqa: E221, 0 will succeed
7960+
third = test(2000, 3000, 1000, 0xf, 0xf58) # ruff: ignore[multiple-spaces-before-operator], 0 will succeed
79617961
print(first, second, third)
79627962
self.assertLess(first, second)
79637963
self.assertLess(second, third)
@@ -8224,7 +8224,7 @@ def test(contents):
82248224
self.assertNotContained(error, read_file('a.out.js'))
82258225

82268226
def test_warn_module_out_err(self):
8227-
def test(contents, expected, args=[], assert_returncode=0): # noqa
8227+
def test(contents, expected, args=[], assert_returncode=0): # ruff: ignore[mutable-argument-default]
82288228
create_file('src.c', r'''
82298229
#include <emscripten.h>
82308230
int main() {

0 commit comments

Comments
 (0)