Skip to content

Commit f85cd31

Browse files
committed
Also enable ruff check
1 parent 20b8dfa commit f85cd31

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

.pre-commit-config.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ repos:
3434
name: Run Ruff (format) on Tools/build/check_warnings.py
3535
args: [--check, --config=Tools/build/.ruff.toml]
3636
files: ^Tools/build/check_warnings.py
37+
- id: ruff-check
38+
name: Run Ruff (lint) on Tools/wasm/
39+
args: [--exit-non-zero-on-fix, --config=Tools/wasm/.ruff.toml]
40+
files: ^Tools/wasm/
3741
- id: ruff-format
3842
name: Run Ruff (format) on Tools/wasm/
3943
args: [--check, --config=Tools/wasm/.ruff.toml]

Tools/wasm/.ruff.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ select = [
2020
"W", # pycodestyle
2121
"YTT", # flake8-2020
2222
]
23+
ignore = [
24+
"E501", # Line too long
25+
]

Tools/wasm/emscripten/__main__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33
import argparse
44
import contextlib
55
import functools
6+
import hashlib
67
import os
78
import shutil
89
import subprocess
910
import sys
1011
import sysconfig
11-
import hashlib
1212
import tempfile
13-
from urllib.request import urlopen
1413
from pathlib import Path
1514
from textwrap import dedent
15+
from urllib.request import urlopen
1616

1717
try:
1818
from os import process_cpu_count as cpu_count
@@ -33,9 +33,7 @@
3333
PREFIX_DIR = CROSS_BUILD_DIR / HOST_TRIPLE / "prefix"
3434

3535
LOCAL_SETUP = CHECKOUT / "Modules" / "Setup.local"
36-
LOCAL_SETUP_MARKER = "# Generated by Tools/wasm/emscripten.py\n".encode(
37-
"utf-8"
38-
)
36+
LOCAL_SETUP_MARKER = b"# Generated by Tools/wasm/emscripten.py\n"
3937

4038

4139
def updated_env(updates={}):
@@ -432,6 +430,7 @@ def main():
432430
make_build,
433431
configure_host,
434432
make_host,
433+
clean,
435434
):
436435
subcommand.add_argument(
437436
"--quiet",

Tools/wasm/emscripten/wasm_assets.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
import sys
1616
import sysconfig
1717
import zipfile
18-
from typing import Dict
1918

2019
# source directory
2120
SRCDIR = pathlib.Path(__file__).parents[3].absolute()
@@ -134,7 +133,7 @@ def filterfunc(filename: str) -> bool:
134133
pzf.writepy(entry, filterfunc=filterfunc)
135134

136135

137-
def detect_extension_modules(args: argparse.Namespace) -> Dict[str, bool]:
136+
def detect_extension_modules(args: argparse.Namespace) -> dict[str, bool]:
138137
modules = {}
139138

140139
# disabled by Modules/Setup.local ?
@@ -149,7 +148,7 @@ def detect_extension_modules(args: argparse.Namespace) -> Dict[str, bool]:
149148
# disabled by configure?
150149
with open(args.sysconfig_data) as f:
151150
data = f.read()
152-
loc: Dict[str, Dict[str, str]] = {}
151+
loc: dict[str, dict[str, str]] = {}
153152
exec(data, globals(), loc)
154153

155154
for key, value in loc["build_time_vars"].items():

Tools/wasm/wasi/__main__.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import sysconfig
1717
import tempfile
1818

19-
2019
CHECKOUT = pathlib.Path(__file__).parent.parent.parent.parent
2120
assert (CHECKOUT / "configure").is_file(), (
2221
"Please update the location of the file"
@@ -28,9 +27,9 @@
2827

2928
LOCAL_SETUP = CHECKOUT / "Modules" / "Setup.local"
3029
LOCAL_SETUP_MARKER = (
31-
"# Generated by Tools/wasm/wasi .\n"
32-
"# Required to statically build extension modules."
33-
).encode("utf-8")
30+
b"# Generated by Tools/wasm/wasi .\n"
31+
b"# Required to statically build extension modules."
32+
)
3433

3534
WASI_SDK_VERSION = 24
3635

@@ -154,8 +153,7 @@ def build_python_is_pydebug():
154153
test = "import sys, test.support; sys.exit(test.support.Py_DEBUG)"
155154
result = subprocess.run(
156155
[build_python_path(), "-c", test],
157-
stdout=subprocess.PIPE,
158-
stderr=subprocess.PIPE,
156+
capture_output=True,
159157
)
160158
return bool(result.returncode)
161159

0 commit comments

Comments
 (0)