Skip to content

Commit

Permalink
ci: can't have types on old versions this library supports
Browse files Browse the repository at this point in the history
  • Loading branch information
delfick committed Nov 8, 2023
1 parent 5a08e48 commit 93898b9
Showing 1 changed file with 10 additions and 19 deletions.
29 changes: 10 additions & 19 deletions tools/devtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import platform
import shlex
import sys
import typing as tp
from collections.abc import Callable
from pathlib import Path

Expand All @@ -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)
Expand All @@ -36,8 +33,6 @@ def run(*args: str | Path) -> None:


class App:
commands: dict[str, Command]

def __init__(self):
self.commands = {}

Expand All @@ -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:
Expand All @@ -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 = ""
Expand All @@ -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()

Expand Down

0 comments on commit 93898b9

Please sign in to comment.