Skip to content

Commit 6b01c48

Browse files
committed
Enable more ruff checks and remove flake8. NFC
1 parent af1dd5b commit 6b01c48

23 files changed

Lines changed: 163 additions & 103 deletions

.flake8

Lines changed: 0 additions & 9 deletions
This file was deleted.

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ jobs:
3838
sudo chmod +x llvm.sh
3939
sudo ./llvm.sh ${LLVM_VERSION}
4040
sudo apt-get install clang-format clang-format-${LLVM_VERSION} clang-tidy-${LLVM_VERSION}
41-
- run: flake8
4241
- run: ruff check
4342
- run: ./scripts/clang-format-diff.sh
4443
- name: clang-tidy

.ruff.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,25 @@
11
target-version = "py310"
2+
preview = true
23

34
exclude = [
45
'third_party',
56
'test/lit/lit.cfg.py',
67
'test/spec/testsuite',
78
]
89

10+
[lint.pylint]
11+
max-locals = 30
12+
max-positional-args = 7
13+
14+
[lint.per-file-ignores]
15+
"test/**.py" = ["PLR6301", "PLW1514", "PLR0914"]
16+
917
[lint]
1018
select = [
1119
"ARG",
1220
"ASYNC",
1321
"B",
22+
"D",
1423
"C4",
1524
"C90",
1625
"COM",
@@ -27,17 +36,29 @@ select = [
2736

2837
ignore = [
2938
"C901", # https://docs.astral.sh/ruff/rules/complex-structure/
39+
"D100", # https://docs.astral.sh/ruff/rules/undocumented-public-module/
40+
"D101", # https://docs.astral.sh/ruff/rules/undocumented-public-class/
41+
"D102", # https://docs.astral.sh/ruff/rules/undocumented-public-method/
42+
"D103", # https://docs.astral.sh/ruff/rules/undocumented-public-function/
43+
"D104", # https://docs.astral.sh/ruff/rules/undocumented-public-package/
44+
"D105", # https://docs.astral.sh/ruff/rules/undocumented-magic-method/
45+
"D203", # https://docs.astral.sh/ruff/rules/incorrect-blank-line-before-class/
46+
"D213", # https://docs.astral.sh/ruff/rules/multi-line-summary-second-line/
47+
"D107", # https://docs.astral.sh/ruff/rules/undocumented-public-init/
3048
"B006", # https://docs.astral.sh/ruff/rules/mutable-argument-default/
3149
"B011", # https://docs.astral.sh/ruff/rules/assert-false/
3250
"B023", # https://docs.astral.sh/ruff/rules/function-uses-loop-variable/
3351
"E501", # https://docs.astral.sh/ruff/rules/line-too-long/
3452
"E741", # https://docs.astral.sh/ruff/rules/ambiguous-variable-name/
3553
"PERF401", # https://docs.astral.sh/ruff/rules/manual-list-comprehension/
54+
"PLR0904", # https://docs.astral.sh/ruff/rules/too-many-public-methods/
3655
"PLR0912", # https://docs.astral.sh/ruff/rules/too-many-branches/
3756
"PLR0913", # https://docs.astral.sh/ruff/rules/too-many-arguments/
3857
"PLR0915", # https://docs.astral.sh/ruff/rules/too-many-statements/
58+
"PLR1702", # https://docs.astral.sh/ruff/rules/too-many-nested-blocks/
3959
"PLR2004", # https://docs.astral.sh/ruff/rules/magic-value-comparison/
4060
"PLW0603", # https://docs.astral.sh/ruff/rules/global-statement/
4161
"PLW1510", # https://docs.astral.sh/ruff/rules/subprocess-run-without-check/
4262
"PLW2901", # https://docs.astral.sh/ruff/rules/redefined-loop-name/
63+
"PLW1514", # https://docs.astral.sh/ruff/rules/unspecified-encoding/
4364
]

check.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,9 @@ def run_one_spec_test(wast: Path, stdout=None):
265265

266266

267267
def run_spec_test_with_wrapped_stdout(wast: Path):
268-
"""Return (bool, str) where the first element is whether the test was
268+
"""Run a single spec test while capturing stdout.
269+
270+
Return (bool, str) where the first element is whether the test was
269271
successful and the second is the combined stdout and stderr of the test.
270272
"""
271273
out = io.StringIO()

requirements-dev.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
# These requirements are only needed for developers who want to run the test
2-
# suite or flake8, not for end users.
2+
# suite, or CI checks, not for end users.
33

44
# Install with `pip3 install -r requirements-dev.txt`
55

6-
flake8==7.3.0
76
ruff==0.14.1
87
filecheck==0.0.22
98
lit==0.11.0.post1

scripts/bundle_clusterfuzz.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#!/usr/bin/python3
22

3-
'''
4-
Bundle files for uploading to ClusterFuzz.
3+
"""Bundle files for uploading to ClusterFuzz.
54
65
Usage:
76
@@ -68,7 +67,7 @@
6867
6968
3. Check the stats and crashes page (known crashes should at least be showing
7069
up). Note that these may take longer to show up than 1 and 2.
71-
'''
70+
"""
7271

7372
import glob
7473
import os

scripts/clusterfuzz/embed_wasms.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,12 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
'''
17-
Reverse script for extract_wasms.py: That one extracts wasm files from a
18-
JavaScript testcase (which has wasm files embedded as arrays of numbers), and
19-
this one re-embeds them back. To do so, we use the magic comments that the
20-
extractor uses: it replaces each wasm array with
16+
"""Reverse of extract_wasms.py.
17+
18+
extract_wasms.py extracts wasm files from a JavaScript testcase (which has wasm
19+
files embedded as arrays of numbers), and this script re-embeds them back. To
20+
do so, we use the magic comments that the extractor uses: it replaces each
21+
wasm array with
2122
2223
'undefined /* extracted wasm */'
2324
@@ -39,7 +40,7 @@
3940
4041
The first argument is the input JS, then the wasm files, then the last argument
4142
is the output JS.
42-
'''
43+
"""
4344

4445
import re
4546
import sys

scripts/clusterfuzz/extract_wasms.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
'''
17-
Wasm extractor for testcases generated by the ClusterFuzz run.py script. This is
18-
general enough to also handle Fuzzilli output.
16+
"""Wasm extractor for testcases generated by the ClusterFuzz run.py script.
17+
18+
This is general enough to also handle Fuzzilli output.
1919
2020
Usage:
2121
@@ -32,7 +32,7 @@
3232
d8 OUTFILE.js -- OUTFILE.0.wasm
3333
3434
That is, the embedded file can now be provided as a filename argument.
35-
'''
35+
"""
3636

3737
import re
3838
import sys

scripts/clusterfuzz/run.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,16 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
'''
17-
ClusterFuzz run.py script: when run by ClusterFuzz, it uses wasm-opt to generate
18-
a fixed number of testcases. This is a "blackbox fuzzer", see
16+
"""ClusterFuzz run.py script.
17+
18+
When run by ClusterFuzz, it uses wasm-opt to generate a fixed number of
19+
testcases. This is a "blackbox fuzzer", see
1920
2021
https://google.github.io/clusterfuzz/setting-up-fuzzing/blackbox-fuzzing/
2122
2223
This file should be bundled up together with the other files it needs, see
2324
bundle_clusterfuzz.py.
24-
'''
25+
"""
2526

2627
import getopt
2728
import math

0 commit comments

Comments
 (0)