mirror of
https://github.com/servo/servo.git
synced 2025-09-30 00:29:14 +01:00
mach: Enable ANN rules (type annotations) for ruff Python linter (#38531)
This changes will introduce [flake8-annotations (ANN)](https://docs.astral.sh/ruff/rules/#flake8-annotations-ann) for python type annotation, this will make all thing related to function strictly typed in python This rule will start to affected this directory from now: - /python -> Root directory - /python/tidy - /python/wpt Testing: `./mach test-tidy` Fixes: Not related to any issues --------- Signed-off-by: Jerens Lensun <jerensslensun@gmail.com>
This commit is contained in:
parent
9c1ee4be83
commit
797db25c4e
13 changed files with 122 additions and 70 deletions
|
@ -14,7 +14,8 @@ import urllib.error
|
|||
import urllib.parse
|
||||
import urllib.request
|
||||
|
||||
from typing import List, NamedTuple, Optional, Union, cast, Callable
|
||||
from typing import List, NamedTuple, Optional, Union, cast, Any
|
||||
from collections.abc import Callable
|
||||
|
||||
import mozlog
|
||||
import mozlog.formatters
|
||||
|
@ -37,7 +38,7 @@ def set_if_none(args: dict, key: str, value: bool | int | str) -> None:
|
|||
args[key] = value
|
||||
|
||||
|
||||
def run_tests(default_binary_path: str, **kwargs) -> int:
|
||||
def run_tests(default_binary_path: str, **kwargs: Any) -> int:
|
||||
print(f"Running WPT tests with {default_binary_path}")
|
||||
|
||||
# By default, Rayon selects the number of worker threads based on the
|
||||
|
@ -249,7 +250,12 @@ def filter_intermittents(unexpected_results: List[UnexpectedResult], output_path
|
|||
print(f"Filtering {len(unexpected_results)} unexpected results for known intermittents via <{dashboard.url}>")
|
||||
dashboard.report_failures(unexpected_results)
|
||||
|
||||
def add_result(output: list[str], text: str, results: List[UnexpectedResult], filter_func) -> None:
|
||||
def add_result(
|
||||
output: list[str],
|
||||
text: str,
|
||||
results: List[UnexpectedResult],
|
||||
filter_func: Callable[[UnexpectedResult], bool],
|
||||
) -> None:
|
||||
filtered = [str(result) for result in filter(filter_func, results)]
|
||||
if filtered:
|
||||
output += [f"{text} ({len(filtered)}): ", *filtered]
|
||||
|
@ -263,7 +269,7 @@ def filter_intermittents(unexpected_results: List[UnexpectedResult], output_path
|
|||
output,
|
||||
"Stable unexpected results that are known-intermittent",
|
||||
unexpected_results,
|
||||
lambda result: not result.flaky and result.issues,
|
||||
lambda result: not result.flaky and bool(result.issues),
|
||||
)
|
||||
add_result(output, "Stable unexpected results", unexpected_results, is_stable_and_unexpected)
|
||||
print("\n".join(output))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue