From 185e9fca7332135af052701947cbf6c1f107ddc6 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 14 Jul 2026 14:38:40 -0700 Subject: [PATCH] Bump pip dev dependency: coverage, ruff and mypy. NFC --- embuilder.py | 9 +++++---- pyproject.toml | 1 + requirements-dev.txt | 6 +++--- site/source/get_api_items.py | 2 +- test/common.py | 3 +-- test/jsrun.py | 2 +- test/parallel_testsuite.py | 2 +- test/test_benchmark.py | 3 ++- tools/feature_matrix.py | 4 ++-- tools/file_packager.py | 15 +++++++-------- tools/maint/rebaseline_tests.py | 2 +- tools/ports/__init__.py | 6 +++--- 12 files changed, 28 insertions(+), 27 deletions(-) diff --git a/embuilder.py b/embuilder.py index 19749dc658d62..69faad238315f 100755 --- a/embuilder.py +++ b/embuilder.py @@ -166,10 +166,11 @@ def get_port_variant(name): else: old_settings = None - yield name - - if old_settings: - settings.dict().update(old_settings) + try: + yield name + finally: + if old_settings: + settings.dict().update(old_settings) def clear_port(port_name): diff --git a/pyproject.toml b/pyproject.toml index cf36dec16ebf0..161cd32986b42 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -76,6 +76,7 @@ lint.ignore = [ "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/ diff --git a/requirements-dev.txt b/requirements-dev.txt index 8c362e7347a7a..ffdb62469338d 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -4,10 +4,10 @@ # the codebase and generate docs using Sphinx, not for users of emscripten. # Install with `pip3 install -r requirements-dev.txt` -coverage[toml]==6.5 -mypy==1.14 +coverage[toml]==7.15.0 +mypy==2.3.0 psutil==7.0.0 -ruff==0.15.7 +ruff==0.15.21 types-requests==2.32.0.20241016 unittest-xml-reporting==3.2.0 deadcode==2.3.1 diff --git a/site/source/get_api_items.py b/site/source/get_api_items.py index ff56b5875ca0b..7962181433a38 100755 --- a/site/source/get_api_items.py +++ b/site/source/get_api_items.py @@ -22,7 +22,7 @@ # if you change here, change everywhere. api_item_filename = 'api_items.py' -api_reference_items = {} +api_reference_items: dict[str, str] = {} def parseFiles(): diff --git a/test/common.py b/test/common.py index 92b27cae480fa..82989326e0fae 100644 --- a/test/common.py +++ b/test/common.py @@ -1433,8 +1433,7 @@ def ccshared(src, linkto=None): cfunc_ptr(); return 0; } - ''' % locals(), - 'a: loaded\na: b (prev: (null))\na: c (prev: b)\n', cflags=extra_args) + ''', 'a: loaded\na: b (prev: (null))\na: c (prev: b)\n', cflags=extra_args) def do_run(self, src, *args, force_c=False, **kwargs): if 'no_build' in kwargs: diff --git a/test/jsrun.py b/test/jsrun.py index 9e2debe499594..4ddca6935e44d 100644 --- a/test/jsrun.py +++ b/test/jsrun.py @@ -14,7 +14,7 @@ from tools import utils -WORKING_ENGINES = {} # Holds all configured engines and whether they work: maps path -> True/False +WORKING_ENGINES: dict[str, bool] = {} # Holds all configured engines and whether they work: maps path -> True/False DEFAULT_TIMEOUT = int(os.environ.get('EMTEST_TIMEOUT', str(5 * 60))) diff --git a/test/parallel_testsuite.py b/test/parallel_testsuite.py index d84603c0c774d..2554735eadb68 100644 --- a/test/parallel_testsuite.py +++ b/test/parallel_testsuite.py @@ -21,7 +21,7 @@ EMTEST_VISUALIZE = os.getenv('EMTEST_VISUALIZE') NUM_CORES = None -seen_class = set() +seen_class: set[str] = set() torn_down = False diff --git a/test/test_benchmark.py b/test/test_benchmark.py index 53db5089216f9..e0c833427a758 100644 --- a/test/test_benchmark.py +++ b/test/test_benchmark.py @@ -313,7 +313,8 @@ def __init__(self, name): super().__init__(name, engine=None) # we will not actually run the benchmarks - run = None + def run(self, args): + assert False CHEERP_BIN = '/opt/cheerp/bin/' diff --git a/tools/feature_matrix.py b/tools/feature_matrix.py index 1667e88ba0359..04916949aa618 100644 --- a/tools/feature_matrix.py +++ b/tools/feature_matrix.py @@ -44,8 +44,8 @@ class Feature(IntEnum): GROWABLE_ARRAYBUFFERS = auto() -disable_override_features = set() -enable_override_features = set() +disable_override_features: set[Feature] = set() +enable_override_features: set[Feature] = set() min_browser_versions = { # https://caniuse.com/wasm-nontrapping-fptoint diff --git a/tools/file_packager.py b/tools/file_packager.py index 703cf5f1016b3..26713f07c80a3 100755 --- a/tools/file_packager.py +++ b/tools/file_packager.py @@ -91,10 +91,6 @@ # chrome limit is 2MB under 2Gi PRELOAD_DATA_FILE_LIMIT = int(os.environ.get('EM_FILE_PACKAGER_MAX_CHUNK_SIZE_MB', '2046')) * 1024 * 1024 -excluded_patterns: list[str] = [] -new_data_files = [] -walked = [] - class Options: def __init__(self): @@ -133,6 +129,9 @@ class DataFile: options = Options() +excluded_patterns: list[str] = [] +new_data_files: list[DataFile] = [] +walked: list[str] = [] def err(*args): @@ -323,13 +322,13 @@ def generate_object_file(data_files): # The `.dc.a` directive gives us a pointer (address) sized entry. # See https://sourceware.org/binutils/docs/as/Dc.html out.write(dedent(f'''\ - .p2align %s + .p2align {align} .dc.a {f.c_symbol_name}_name - .p2align %s + .p2align {align} .int32 {os.path.getsize(f.srcpath)} - .p2align %s + .p2align {align} .dc.a {f.c_symbol_name} - ''' % (align, align, align))) + ''')) ptr_size = 4 elem_size = (2 * ptr_size) + 4 diff --git a/tools/maint/rebaseline_tests.py b/tools/maint/rebaseline_tests.py index b8df708f85811..8c1e54bb62e75 100755 --- a/tools/maint/rebaseline_tests.py +++ b/tools/maint/rebaseline_tests.py @@ -29,7 +29,7 @@ def run(cmd, **args): return subprocess.check_output(cmd, text=True, cwd=root_dir, **args) -all_deltas = [] +all_deltas: list[int] = [] def read_size_from_json(content): diff --git a/tools/ports/__init__.py b/tools/ports/__init__.py index d92ddf81734bb..60cb8d791e41c 100644 --- a/tools/ports/__init__.py +++ b/tools/ports/__init__.py @@ -19,15 +19,15 @@ from tools.settings import settings from tools.toolchain_profiler import ToolchainProfiler -ports = [] +ports: list[dict] = [] ports_by_name: dict[str, object] = {} -ports_needed = set() +ports_needed: set[str] = set() # Variant builds that we want to support for certain ports # {variant_name: (port_name, extra_settings)} -port_variants = {} +port_variants: dict[str, tuple] = {} ports_dir = os.path.dirname(os.path.abspath(__file__))