Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion emrun.py
Original file line number Diff line number Diff line change
Expand Up @@ -1596,7 +1596,7 @@ def parse_args(args):
return parser.parse_args(args)


def run(args): # noqa: C901, PLR0912, PLR0915
def run(args): # ruff: ignore[complex-structure, too-many-branches, too-many-statements]
"""Future modifications should consider refactoring to reduce complexity.

* The McCabe cyclomatiic complexity is currently 74 vs 10 recommended.
Expand Down
104 changes: 52 additions & 52 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,59 +39,59 @@ lint.select = [
]
lint.external = [ "D" ]
lint.ignore = [
"D100", # https://docs.astral.sh/ruff/rules/undocumented-public-module/
"D101", # https://docs.astral.sh/ruff/rules/undocumented-public-class/
"D102", # https://docs.astral.sh/ruff/rules/undocumented-public-method/
"D103", # https://docs.astral.sh/ruff/rules/undocumented-public-function/
"D104", # https://docs.astral.sh/ruff/rules/undocumented-public-package/
"D105", # https://docs.astral.sh/ruff/rules/undocumented-magic-method/
"D106", # https://docs.astral.sh/ruff/rules/undocumented-public-nested-class/
"D107", # https://docs.astral.sh/ruff/rules/undocumented-public-init/
"D203", # https://docs.astral.sh/ruff/rules/incorrect-blank-line-before-class/
"D213", # https://docs.astral.sh/ruff/rules/multi-line-summary-second-line/
"D401", # https://docs.astral.sh/ruff/rules/non-imperative-mood/
"B011", # See https://github.com/PyCQA/flake8-bugbear/issues/66
"B023",
"B026",
"E272",
"E402",
"E241",
"E266",
"E501",
"E721",
"E741",
"E111", # Does not seem to honor `indent-width = 2` above
"E114", # Does not seem to honor `indent-width = 2` above
"E261",
"PERF203",
"PERF401",
"PLC0415",
"PLR0904",
"PLR0916",
"PLR0914",
"PLR1702",
"PLR1704",
"PLR5501",
"PLR6301",
"PLW0602",
"PLW0603",
"PLW0717", # https://docs.astral.sh/ruff/rules/too-many-statements-in-try-clause
"PLW1510",
"PLW2901",
"RUF012", # https://docs.astral.sh/ruff/rules/mutable-class-default/
"RUF015", # https://docs.astral.sh/ruff/rules/unnecessary-iterable-allocation-for-first-element/
"RUF027", # https://docs.astral.sh/ruff/rules/missing-f-string-syntax/
"RUF039", # https://docs.astral.sh/ruff/rules/unraw-re-pattern/
"RUF067", # https://docs.astral.sh/ruff/rules/non-empty-init-module/
"UP030", # TODO
"UP031", # TODO
"UP032", # TODO
"undocumented-public-module",
"undocumented-public-class",
"undocumented-public-method",
"undocumented-public-function",
"undocumented-public-package",
"undocumented-magic-method",
"undocumented-public-nested-class",
"undocumented-public-init",
"incorrect-blank-line-before-class",
"multi-line-summary-second-line",
"non-imperative-mood",
"assert-false", # See https://github.com/PyCQA/flake8-bugbear/issues/66
"function-uses-loop-variable",
"star-arg-unpacking-after-keyword-arg",
"multiple-spaces-before-keyword",
"module-import-not-at-top-of-file",
"multiple-spaces-after-comma",
"multiple-leading-hashes-for-block-comment",
"line-too-long",
"type-comparison",
"ambiguous-variable-name",
"indentation-with-invalid-multiple", # Does not seem to honor `indent-width = 2` above
"indentation-with-invalid-multiple-comment", # Does not seem to honor `indent-width = 2` above
"too-few-spaces-before-inline-comment",
"try-except-in-loop",
"manual-list-comprehension",
"import-outside-top-level",
"too-many-public-methods",
"too-many-boolean-expressions",
"too-many-locals",
"too-many-nested-blocks",
"redefined-argument-from-local",
"collapsible-else-if",
"no-self-use",
"global-variable-not-assigned",
"global-statement",
"too-many-statements-in-try-clause",
"subprocess-run-without-check",
"redefined-loop-name",
"mutable-class-default",
"unnecessary-iterable-allocation-for-first-element",
"missing-f-string-syntax",
"unraw-re-pattern",
"non-empty-init-module",
"format-literals", # TODO
"printf-string-formatting", # TODO
"f-string", # TODO
]
lint.per-file-ignores."tools/ports/*.py" = [ "ARG001", "ARG005" ]
lint.per-file-ignores."test/other/ports/*.py" = [ "ARG001" ]
lint.per-file-ignores."test/parallel_testsuite.py" = [ "ARG002" ]
lint.per-file-ignores."test/test_benchmark.py" = [ "ARG002" ]
lint.per-file-ignores."test/*.py" = [ "RUF005" ]
lint.per-file-ignores."tools/ports/*.py" = [ "unused-function-argument", "unused-lambda-argument" ]
lint.per-file-ignores."test/other/ports/*.py" = [ "unused-function-argument" ]
lint.per-file-ignores."test/parallel_testsuite.py" = [ "unused-method-argument" ]
lint.per-file-ignores."test/test_benchmark.py" = [ "unused-method-argument" ]
lint.per-file-ignores."test/*.py" = [ "collection-literal-concatenation" ]
lint.mccabe.max-complexity = 51 # Recommended: 10
lint.pylint.allow-magic-value-types = [
"bytes",
Expand Down
2 changes: 1 addition & 1 deletion requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
coverage[toml]==7.15.0
mypy==2.3.0
psutil==7.0.0
ruff==0.15.21
ruff==0.16.0
types-requests==2.32.0.20241016
unittest-xml-reporting==3.2.0
deadcode==2.3.1
Expand Down
6 changes: 3 additions & 3 deletions test/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -912,7 +912,7 @@ def is_ldflag(f):
for i, arg in enumerate(args):
if arg in {'--pre-js', '--post-js'}:
args[i] = None
args[i + 1] = None # noqa: B909
args[i + 1] = None # ruff: ignore[loop-iterator-mutation]
args = [arg for arg in args if arg is not None]
return args

Expand Down Expand Up @@ -1199,7 +1199,7 @@ def get_build_dir(self):
ensure_dir(ret)
return ret

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

def emcc(self, filename, args=[], **kwargs): # noqa
def emcc(self, filename, args=[], **kwargs): # ruff: ignore[mutable-argument-default]
filename = maybe_test_file(filename)
compile_only = '-c' in args or '-sSIDE_MODULE' in args
cmd = [compiler_for(filename), filename] + self.get_cflags(compile_only=compile_only) + args
Expand Down
2 changes: 1 addition & 1 deletion test/sockets/socket_relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


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

def run(self):
self.conn = None
Expand Down
2 changes: 1 addition & 1 deletion test/test_benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,7 @@ def test_zzz_poppler(self):
}
''' % DEFAULT_ARG)

def lib_builder(name, native, env_init): # noqa
def lib_builder(name, native, env_init): # ruff: ignore[unused-function-argument]
if '-m64' in env_init.get('CFLAGS', ''):
env_init['CPPFLAGS'] = '-m64'
env_init['LDFLAGS'] = '-m64'
Expand Down
4 changes: 2 additions & 2 deletions test/test_closure_args_port.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import os


def get(ports, settings, shared): # noqa: ARG001
def get(ports, settings, shared): # ruff: ignore[unused-function-argument]
return []


def clear(ports, settings, shared):
pass


def linker_setup(ports, settings): # noqa: ARG001
def linker_setup(ports, settings): # ruff: ignore[unused-function-argument]
externs_file = os.path.join(os.path.dirname(os.path.realpath(__file__)),
'test_closure_externs.js')
settings.CLOSURE_ARGS += [f'--externs={externs_file}']
2 changes: 1 addition & 1 deletion test/test_codesize.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ def test_codesize_cxx(self, args):
# prune unused imports/exports from it. See #27217.
'esm_integration': (['-O3', '-sWASM_ESM_INTEGRATION', '-Wno-experimental'],),
})
def test_codesize_hello(self, args, kwargs={}): # noqa
def test_codesize_hello(self, args, kwargs={}): # ruff: ignore[mutable-argument-default]
self.run_codesize_test('hello_world.c', args, **kwargs)

@parameterized({
Expand Down
4 changes: 2 additions & 2 deletions test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -9954,7 +9954,7 @@ def test_fcoverage_mapping(self):
self.assertEqual(expected, self.run_process([LLVM_COV, 'show', 'test_hello_world.wasm', '-instr-profile=out.profdata'], stdout=PIPE).stdout)

# Generate tests for everything
def make_run(name, cflags=None, settings=None, env=None, # noqa
def make_run(name, cflags=None, settings=None, env=None, # ruff: ignore[blank-lines-top-level]
v8_args=None, node_args=None,
require_wasm64=False,
init=None):
Expand All @@ -9969,7 +9969,7 @@ def make_run(name, cflags=None, settings=None, env=None, # noqa
# we need to pass this flag here to avoid warnings from compile-only commands.
cflags.append('-Wno-unused-command-line-argument')

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

def tearDown(self):
try:
Expand Down
20 changes: 10 additions & 10 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -901,11 +901,11 @@ def test_cmake(self, test_dir, output_file, cmake_args):
generators = ['Unix Makefiles', 'Ninja', 'Eclipse CDT4 - Ninja']

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

print('no bad ctor')
first = test(1000, 2000, 3000, 0xe, 0x58e) # noqa: E221
first = test(1000, 2000, 3000, 0xe, 0x58e) # ruff: ignore[multiple-spaces-before-operator]
second = test(3000, 1000, 2000, 0xe, 0x8e5)
third = test(2000, 3000, 1000, 0xe, 0xe58) # noqa: E221
third = test(2000, 3000, 1000, 0xe, 0xe58) # ruff: ignore[multiple-spaces-before-operator]
print(first, second, third)
assert first == second and second == third
print('with bad ctor')
first = test(1000, 2000, 3000, 0xf, 0x58f) # noqa: E221, 2 will succeed
first = test(1000, 2000, 3000, 0xf, 0x58f) # ruff: ignore[multiple-spaces-before-operator], 2 will succeed
second = test(3000, 1000, 2000, 0xf, 0x8f5) # 1 will succeed
third = test(2000, 3000, 1000, 0xf, 0xf58) # noqa: E221, 0 will succeed
third = test(2000, 3000, 1000, 0xf, 0xf58) # ruff: ignore[multiple-spaces-before-operator], 0 will succeed
print(first, second, third)
self.assertLess(first, second)
self.assertLess(second, third)
Expand Down Expand Up @@ -8224,7 +8224,7 @@ def test(contents):
self.assertNotContained(error, read_file('a.out.js'))

def test_warn_module_out_err(self):
def test(contents, expected, args=[], assert_returncode=0): # noqa
def test(contents, expected, args=[], assert_returncode=0): # ruff: ignore[mutable-argument-default]
create_file('src.c', r'''
#include <emscripten.h>
int main() {
Expand Down
2 changes: 0 additions & 2 deletions test/test_posixtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ class posixtest(RunnerCore):
This class get populated dynamically below.
"""

pass # noqa: PIE790


def filter_tests(all_tests):
prefixes = (
Expand Down
2 changes: 1 addition & 1 deletion tools/building.py
Original file line number Diff line number Diff line change
Expand Up @@ -1289,7 +1289,7 @@ def run_binaryen_command(tool, infile, outfile=None, args=None, debug=False, std
return ret


def run_wasm_opt(infile, outfile=None, args=[], **kwargs): # noqa
def run_wasm_opt(infile, outfile=None, args=[], **kwargs): # ruff: ignore[mutable-argument-default]
return run_binaryen_command('wasm-opt', infile, outfile, args=args, **kwargs)


Expand Down
2 changes: 1 addition & 1 deletion tools/cmdline.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def parse_s_args():
user_settings[key] = value


def parse_args(newargs): # noqa: C901, PLR0912, PLR0915
def parse_args(newargs): # ruff: ignore[complex-structure, too-many-branches, too-many-statements]
"""Future modifications should consider refactoring to reduce complexity.

* The McCabe cyclomatiic complexity is currently 117 vs 10 recommended.
Expand Down
2 changes: 1 addition & 1 deletion tools/extract_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# University of Illinois/NCSA Open Source License. Both these licenses can be
# found in the LICENSE file.

# ruff:noqa: F841
# ruff: file-ignore[unused-variable]

import logging
from dataclasses import dataclass
Expand Down
2 changes: 1 addition & 1 deletion tools/file_packager.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ def generate_object_file(data_files):
shared.check_call(cmd)


def main(): # noqa: C901, PLR0912, PLR0915
def main(): # ruff: ignore[complex-structure, too-many-branches, too-many-statements]
"""Future modifications should consider refactoring to reduce complexity.

* The McCabe cyclomatiic complexity is currently 60 vs 10 recommended.
Expand Down
2 changes: 1 addition & 1 deletion tools/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ def add_required_heap_symbols():


@ToolchainProfiler.profile_block('linker_setup')
def phase_linker_setup(options, linker_args): # noqa: C901, PLR0912, PLR0915
def phase_linker_setup(options, linker_args): # ruff: ignore[complex-structure, too-many-branches, too-many-statements]
"""Future modifications should consider refactoring to reduce complexity.

* The McCabe cyclomatiic complexity is currently 244 vs 10 recommended.
Expand Down
2 changes: 1 addition & 1 deletion tools/ports/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def install_headers(src_dir, pattern='*.h', target=None):
maybe_copy(f, os.path.join(dest, os.path.basename(f)))

@staticmethod
def build_port(src_dir, output_path, port_name, includes=[], flags=[], cxxflags=[], exclude_files=[], exclude_dirs=[], srcs=[]): # noqa
def build_port(src_dir, output_path, port_name, includes=[], flags=[], cxxflags=[], exclude_files=[], exclude_dirs=[], srcs=[]): # ruff: ignore[mutable-argument-default]
mangled_name = str(Path(output_path).relative_to(Path(cache.get_sysroot(True)) / 'lib'))
mangled_name = mangled_name.replace(os.sep, '_').replace('.a', '').replace('-emscripten', '')
build_dir = os.path.join(Ports.get_build_dir(), port_name, mangled_name)
Expand Down
2 changes: 1 addition & 1 deletion tools/response_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def expand_response_file(arg):
if DEBUG:
logging.warning(f'failed to parse response file {response_filename} with guessed encoding "{guessed_encoding}". Trying default system encoding...')
# If that fails, try with the Python default locale.getpreferredencoding()
with open(response_filename) as f: # noqa: PLW1514
with open(response_filename, encoding=None) as f:
args = f.read()

args = shlex.split(args)
Expand Down
8 changes: 4 additions & 4 deletions tools/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,11 @@ def infer_types(self):
def dict(self):
return self.attrs

def external_dict(self, skip_keys={}): # noqa
def external_dict(self, skip_keys={}): # ruff: ignore[mutable-argument-default]
external_settings = {}
for key, value in self.dict().items():
if value != self.defaults.get(key) and key not in INTERNAL_SETTINGS and key not in skip_keys:
external_settings[key] = value # noqa: PERF403
external_settings[key] = value # ruff: ignore[manual-dict-comprehension]
if not self.attrs['STRICT']:
# When not running in strict mode we also externalize all legacy settings
# (Since the external tools do process LEGACY_SETTINGS themselves)
Expand Down Expand Up @@ -419,9 +419,9 @@ def check_type(self, name, value):
return
# Allow integers 1 and 0 for type `bool`
if expected_type == bool:
if value in (1, 0): # noqa: PLR6201
if value in {1, 0}:
value = bool(value)
if value in ('True', 'False', 'true', 'false'): # noqa: PLR6201
if value in {'True', 'False', 'true', 'false'}:
exit_with_error(f'attempt to set `{name}` to `{value}`; use 1/0 to set boolean settings')
if type(value) is not expected_type:
exit_with_error(f'setting `{name}` expects `{expected_type.__name__}` but got `{type(value).__name__}`')
Expand Down
2 changes: 1 addition & 1 deletion tools/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def exec_process(cmd):
utils.exec(cmd)


def run_js_tool(filename, jsargs=[], node_args=[], **kw): # noqa: B006
def run_js_tool(filename, jsargs=[], node_args=[], **kw): # ruff: ignore[mutable-argument-default]
"""Execute a javascript tool.

This is used by emcc to run parts of the build process that are
Expand Down
4 changes: 2 additions & 2 deletions tools/system_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# University of Illinois/NCSA Open Source License. Both these licenses can be
# found in the LICENSE file.

# ruff: noqa: RUF005
# ruff: file-ignore[collection-literal-concatenation]

import itertools
import logging
Expand Down Expand Up @@ -51,7 +51,7 @@ def files_in_path(path: str, filenames: list[str]):
return [os.path.join(srcdir, f) for f in filenames]


def glob_in_path(path: str, glob_pattern: str, excludes: set[str] = set()): # noqa: B006
def glob_in_path(path: str, glob_pattern: str, excludes: set[str] = set()): # ruff: ignore[mutable-argument-default]
srcdir = utils.path_from_root(path)
files = iglob(os.path.join(srcdir, glob_pattern), recursive=True)
return sorted(f for f in files if os.path.basename(f) not in excludes)
Expand Down
2 changes: 1 addition & 1 deletion tools/webidl_binder.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ def type_to_cdec(raw):
return ret + '*'


def render_function(class_name, func_name, sigs, return_type, non_pointer, # noqa: C901, PLR0912, PLR0915
def render_function(class_name, func_name, sigs, return_type, non_pointer, # ruff: ignore[complex-structure, too-many-branches, too-many-statements]
copy, operator, constructor, is_static, func_scope,
call_content=None, const=False, array_attribute=False,
bind_to=None):
Expand Down
Loading