mirror of
https://github.com/servo/servo.git
synced 2025-09-30 08:39:16 +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
|
@ -19,7 +19,7 @@ import logging
|
|||
import os
|
||||
import textwrap
|
||||
|
||||
from typing import TYPE_CHECKING, Generic, Optional, TypeVar
|
||||
from typing import TYPE_CHECKING, Generic, Optional, TypeVar, Callable, Any
|
||||
|
||||
from .common import COULD_NOT_APPLY_CHANGES_DOWNSTREAM_COMMENT
|
||||
from .common import COULD_NOT_APPLY_CHANGES_UPSTREAM_COMMENT
|
||||
|
@ -36,7 +36,7 @@ PATCH_FILE_NAME = "tmp.patch"
|
|||
|
||||
|
||||
class Step:
|
||||
def __init__(self, name) -> None:
|
||||
def __init__(self, name: str) -> None:
|
||||
self.name = name
|
||||
|
||||
def provides(self) -> Optional[AsyncValue]:
|
||||
|
@ -91,7 +91,9 @@ class CreateOrUpdateBranchForPRStep(Step):
|
|||
if run.upstream_pr.has_value():
|
||||
run.add_step(CommentStep(run.upstream_pr.value(), COULD_NOT_APPLY_CHANGES_UPSTREAM_COMMENT))
|
||||
|
||||
def _get_upstreamable_commits_from_local_servo_repo(self, sync: WPTSync):
|
||||
def _get_upstreamable_commits_from_local_servo_repo(
|
||||
self, sync: WPTSync
|
||||
) -> list[dict[str, bytes | str] | dict[str, str]]:
|
||||
local_servo_repo = sync.local_servo_repo
|
||||
number_of_commits = self.pull_data["commits"]
|
||||
pr_head = self.pull_data["head"]["sha"]
|
||||
|
@ -143,7 +145,9 @@ class CreateOrUpdateBranchForPRStep(Step):
|
|||
run.sync.local_wpt_repo.run("add", "--all")
|
||||
run.sync.local_wpt_repo.run("commit", "--message", commit["message"], "--author", commit["author"])
|
||||
|
||||
def _create_or_update_branch_for_pr(self, run: SyncRun, commits: list[dict], pre_commit_callback=None) -> str:
|
||||
def _create_or_update_branch_for_pr(
|
||||
self, run: SyncRun, commits: list[dict], pre_commit_callback: Callable[[], None] | None = None
|
||||
) -> str:
|
||||
branch_name = wpt_branch_name_from_servo_pr_number(self.pull_data["number"])
|
||||
try:
|
||||
# Create a new branch with a unique name that is consistent between
|
||||
|
@ -180,7 +184,7 @@ class CreateOrUpdateBranchForPRStep(Step):
|
|||
|
||||
|
||||
class RemoveBranchForPRStep(Step):
|
||||
def __init__(self, pull_request) -> None:
|
||||
def __init__(self, pull_request: dict[str, Any]) -> None:
|
||||
Step.__init__(self, "RemoveBranchForPRStep")
|
||||
self.branch_name = wpt_branch_name_from_servo_pr_number(pull_request["number"])
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue