diff --git a/tools/devtools.py b/tools/devtools.py index 114aee1..5e72d0f 100644 --- a/tools/devtools.py +++ b/tools/devtools.py @@ -3,7 +3,6 @@ import platform import shlex import sys -import typing as tp from collections.abc import Callable from pathlib import Path @@ -16,18 +15,16 @@ class Command: - __is_command__: bool - - def __call__(self, bin_dir: Path, args: list[str]) -> None: + def __call__(self, bin_dir, args) -> None: ... -def command(func: Callable) -> Callable: - tp.cast(Command, func).__is_command__ = True +def command(func) -> Callable: + func.__is_command__ = True return func -def run(*args: str | Path) -> None: +def run(*args) -> None: cmd = " ".join(shlex.quote(str(part)) for part in args) print(f"Running '{cmd}'") ret = os.system(cmd) @@ -36,8 +33,6 @@ def run(*args: str | Path) -> None: class App: - commands: dict[str, Command] - def __init__(self): self.commands = {} @@ -51,7 +46,7 @@ def __init__(self): ), f"Expected '{name}' to have correct signature, have {inspect.signature(val)} instead of {compare}" self.commands[name] = val - def __call__(self, args: list[str]) -> None: + def __call__(self, args) -> None: bin_dir = Path(sys.executable).parent if args and args[0] in self.commands: @@ -62,27 +57,27 @@ def __call__(self, args: list[str]) -> None: sys.exit(f"Unknown command:\nAvailable: {sorted(self.commands)}\nWanted: {args}") @command - def format(self, bin_dir: Path, args: list[str]) -> None: + def format(self, bin_dir, args) -> None: if not args: args = [".", *args] run(bin_dir / "black", *args) run(bin_dir / "isort", *args) @command - def lint(self, bin_dir: Path, args: list[str]) -> None: + def lint(self, bin_dir, args) -> None: run(bin_dir / "pylama", *args) @command - def tests(self, bin_dir: Path, args: list[str]) -> None: + def tests(self, bin_dir, args) -> None: if "-q" not in args: args = ["-q", *args] env = os.environ env["NOSE_OF_YETI_BLACK_COMPAT"] = "false" - files: list[str] = [] + files = [] if "TESTS_CHDIR" in env: - ags: list[str] = [] + ags = [] test_dir = Path(env["TESTS_CHDIR"]).absolute() for a in args: test_name = "" @@ -108,10 +103,6 @@ def tests(self, bin_dir: Path, args: list[str]) -> None: run(bin_dir / "pytest", *files, *args) - @command - def tox(self, bin_dir: Path, args: list[str]) -> None: - run(bin_dir / "tox", *args) - app = App()