diff --git a/.ruff.toml b/.ruff.toml index e48daa90671..33af7fda773 100644 --- a/.ruff.toml +++ b/.ruff.toml @@ -12,7 +12,7 @@ max-locals = 30 max-positional-args = 7 [lint.per-file-ignores] -"test/**.py" = ["PLR6301", "PLW1514", "PLR0914"] +"test/**.py" = ["no-self-use", "unspecified-encoding", "too-many-locals"] [lint] select = [ @@ -31,34 +31,39 @@ select = [ "PL", "UP", "W", + "RUF", "YTT", ] ignore = [ - "C901", # https://docs.astral.sh/ruff/rules/complex-structure/ - "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/ - "D203", # https://docs.astral.sh/ruff/rules/incorrect-blank-line-before-class/ - "D213", # https://docs.astral.sh/ruff/rules/multi-line-summary-second-line/ - "D107", # https://docs.astral.sh/ruff/rules/undocumented-public-init/ - "B006", # https://docs.astral.sh/ruff/rules/mutable-argument-default/ - "B011", # https://docs.astral.sh/ruff/rules/assert-false/ - "B023", # https://docs.astral.sh/ruff/rules/function-uses-loop-variable/ - "E501", # https://docs.astral.sh/ruff/rules/line-too-long/ - "E741", # https://docs.astral.sh/ruff/rules/ambiguous-variable-name/ - "PERF401", # https://docs.astral.sh/ruff/rules/manual-list-comprehension/ - "PLR0904", # https://docs.astral.sh/ruff/rules/too-many-public-methods/ - "PLR0912", # https://docs.astral.sh/ruff/rules/too-many-branches/ - "PLR0913", # https://docs.astral.sh/ruff/rules/too-many-arguments/ - "PLR0915", # https://docs.astral.sh/ruff/rules/too-many-statements/ - "PLR1702", # https://docs.astral.sh/ruff/rules/too-many-nested-blocks/ - "PLR2004", # https://docs.astral.sh/ruff/rules/magic-value-comparison/ - "PLW0603", # https://docs.astral.sh/ruff/rules/global-statement/ - "PLW1510", # https://docs.astral.sh/ruff/rules/subprocess-run-without-check/ - "PLW2901", # https://docs.astral.sh/ruff/rules/redefined-loop-name/ - "PLW1514", # https://docs.astral.sh/ruff/rules/unspecified-encoding/ + "ambiguous-variable-name", + "assert-false", + "collection-literal-concatenation", + "complex-structure", + "float-equality-comparison", + "function-uses-loop-variable", + "global-statement", + "incorrect-blank-line-before-class", + "line-too-long", + "magic-value-comparison", + "manual-list-comprehension", + "multi-line-summary-second-line", + "mutable-argument-default", + "mutable-class-default", + "redefined-loop-name", + "subprocess-run-without-check", + "too-many-arguments", + "too-many-branches", + "too-many-nested-blocks", + "too-many-public-methods", + "too-many-statements", + "too-many-statements-in-try-clause", + "undocumented-magic-method", + "undocumented-public-class", + "undocumented-public-function", + "undocumented-public-init", + "undocumented-public-method", + "undocumented-public-module", + "undocumented-public-package", + "unspecified-encoding", ] diff --git a/requirements-dev.txt b/requirements-dev.txt index d64712fe2e8..500c11b34e0 100644 --- a/requirements-dev.txt +++ b/requirements-dev.txt @@ -3,6 +3,6 @@ # Install with `pip3 install -r requirements-dev.txt` -ruff==0.14.1 +ruff==0.16.0 filecheck==0.0.22 lit==0.11.0.post1 diff --git a/scripts/bundle_clusterfuzz.py b/scripts/bundle_clusterfuzz.py index 5dcf56e86dc..6a526b47b1a 100755 --- a/scripts/bundle_clusterfuzz.py +++ b/scripts/bundle_clusterfuzz.py @@ -88,9 +88,11 @@ # Delete the argument, as importing |shared| scans it. sys.argv.pop() -from test import fuzzing # noqa -from test import shared # noqa -from test import support # noqa +from test import ( # ruff: ignore[module-import-not-at-top-of-file] + fuzzing, + shared, + support, +) # Pick where to get the builds if build_dir: diff --git a/scripts/clusterfuzz/run.py b/scripts/clusterfuzz/run.py index fe814a2b048..44f27a5f58e 100755 --- a/scripts/clusterfuzz/run.py +++ b/scripts/clusterfuzz/run.py @@ -218,7 +218,7 @@ def get_js_file_contents(i, output_dir): args = [] if system_random.random() < 0.8: args = [f'--fuzz-import={wasm_file}'] - second_wasm_contents, second_wasm_file = \ + second_wasm_contents, _second_wasm_file = \ get_wasm_contents(f'{i}_second', output_dir, args) pre += f'var secondBinary = {second_wasm_contents};\n' bytes += second_wasm_contents.count(',') diff --git a/scripts/fuzz_opt.py b/scripts/fuzz_opt.py index 5d290e3c876..a36282c17fc 100755 --- a/scripts/fuzz_opt.py +++ b/scripts/fuzz_opt.py @@ -25,7 +25,7 @@ script covers different options being passed) """ -# ruff: noqa: COM819, ARG002 +# ruff: file-ignore[prohibited-trailing-comma, unused-method-argument] import contextlib import difflib @@ -1149,7 +1149,7 @@ def fix_output_for_js(x): # of the wrong type - which would be cast on use, but if we remove # the casts, we end up returning null here and not 0, which the # fuzzer can notice. - x = re.sub(r' null', ' 0', x) + x = x.replace(r' null', ' 0') # wasm2js converts exports to valid JS forms, which affects some of # the names in the test suite. Fix those up. @@ -2117,8 +2117,8 @@ def compare_to_merged_output(output, merged_output): assert b.startswith(FUZZ_EXEC_NOTE_RESULT) assert a.count(' => ') == 1 assert b.count(' => ') == 1 - a_prefix, a_result = a.split(' => ') - b_prefix, b_result = b.split(' => ') + a_prefix, _a_result = a.split(' => ') + _b_prefix, b_result = b.split(' => ') # Copy a's prefix with b's result. merged_output_lines[i] = a_prefix + ' => ' + b_result diff --git a/scripts/fuzz_relooper.py b/scripts/fuzz_relooper.py index 4fd65e40c8e..03067bc0d54 100755 --- a/scripts/fuzz_relooper.py +++ b/scripts/fuzz_relooper.py @@ -16,7 +16,7 @@ """Script that fuzzes the relooper using the C API.""" -# ruff: noqa: UP031 +# ruff: file-ignore[printf-string-formatting] import difflib import os diff --git a/scripts/gen-s-parser.py b/scripts/gen-s-parser.py index b56a7f50b9f..93c70b7d755 100755 --- a/scripts/gen-s-parser.py +++ b/scripts/gen-s-parser.py @@ -18,7 +18,7 @@ assert sys.version_info >= (3, 10), 'requires Python 3.10' -# ruff: noqa: E241 +# ruff: file-ignore[multiple-spaces-after-comma] instructions = [ ("unreachable", "makeUnreachable()"), diff --git a/test/unit/test_fuzz_preserve.py b/test/unit/test_fuzz_preserve.py index e1a3dc2fe93..3cfed2cc0cd 100644 --- a/test/unit/test_fuzz_preserve.py +++ b/test/unit/test_fuzz_preserve.py @@ -115,9 +115,8 @@ def process_wat(self, wat): # Given the types we saw for params or results, look in detail for the # things we expect to see. - def found_expected(self, data): + def found_expected(self, data): # ruff: ignore[too-many-return-statements] # The many returns here seem to be the best way to write this code. - # ruff: noqa: PLR0911 # Look for significant variety. if len(data) < 5: