mirror of
https://github.com/servo/servo.git
synced 2025-09-27 15:20:09 +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
|
@ -4,9 +4,11 @@
|
|||
|
||||
import hashlib
|
||||
import os
|
||||
from os import PathLike
|
||||
import subprocess
|
||||
import sys
|
||||
import runpy
|
||||
from typing import TYPE_CHECKING
|
||||
|
||||
SCRIPT_PATH = os.path.abspath(os.path.dirname(__file__))
|
||||
TOP_DIR = os.path.abspath(os.path.join(SCRIPT_PATH, ".."))
|
||||
|
@ -80,7 +82,11 @@ CATEGORIES = {
|
|||
}
|
||||
|
||||
|
||||
def _process_exec(args: list[str], cwd) -> None:
|
||||
if TYPE_CHECKING:
|
||||
from mach.main import Mach
|
||||
|
||||
|
||||
def _process_exec(args: list[str], cwd: PathLike[bytes] | PathLike[str] | bytes | str) -> None:
|
||||
try:
|
||||
subprocess.check_output(args, stderr=subprocess.STDOUT, cwd=cwd)
|
||||
except subprocess.CalledProcessError as exception:
|
||||
|
@ -188,7 +194,7 @@ def bootstrap_command_only(topdir: str) -> int:
|
|||
return 0
|
||||
|
||||
|
||||
def bootstrap(topdir: str):
|
||||
def bootstrap(topdir: str) -> "Mach":
|
||||
_ensure_case_insensitive_if_windows()
|
||||
|
||||
topdir = os.path.abspath(topdir)
|
||||
|
@ -202,7 +208,7 @@ def bootstrap(topdir: str):
|
|||
|
||||
_activate_virtualenv(topdir)
|
||||
|
||||
def populate_context(context, key=None):
|
||||
def populate_context(context: None, key: None | str = None) -> str | None:
|
||||
if key is None:
|
||||
return
|
||||
if key == "topdir":
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue