diff --git a/stubs/invoke/invoke/tasks.pyi b/stubs/invoke/invoke/tasks.pyi index cc20ae2ff..a42064558 100644 --- a/stubs/invoke/invoke/tasks.pyi +++ b/stubs/invoke/invoke/tasks.pyi @@ -1,57 +1,76 @@ from _typeshed import Self -from typing import Any +from collections.abc import Callable, Iterable +from typing import Any, TypeVar from .config import Config from .context import Context +from .parser import Argument + +_TaskT = TypeVar("_TaskT", bound=Task) NO_DEFAULT: object class Task: - body: Any - __doc__: str + body: Callable[..., Any] + __doc__: str | None __name__: str - __module__: Any - aliases: Any + __module__: str + aliases: tuple[str, ...] is_default: bool - positional: Any - optional: Any - iterable: Any - incrementable: Any - auto_shortflags: Any - help: Any - pre: Any - post: Any + positional: Iterable[str] + optional: Iterable[str] + iterable: Iterable[str] + incrementable: Iterable[str] + auto_shortflags: bool + help: dict[str, str] + pre: list[Task] + post: list[Task] times_called: int - autoprint: Any + autoprint: bool def __init__( self, - body, - name=..., - aliases=..., - positional=..., - optional=..., + body: Callable[..., Any], + name: str | None = ..., + aliases: tuple[str, ...] = ..., + positional: Iterable[str] | None = ..., + optional: Iterable[str] = ..., default: bool = ..., auto_shortflags: bool = ..., - help=..., - pre=..., - post=..., + help: dict[str, str] | None = ..., + pre: list[Task] | None = ..., + post: list[Task] | None = ..., autoprint: bool = ..., - iterable=..., - incrementable=..., + iterable: Iterable[str] | None = ..., + incrementable: Iterable[str] | None = ..., ) -> None: ... @property def name(self): ... - def __eq__(self, other): ... - def __hash__(self): ... + def __eq__(self, other: Task) -> bool: ... # type: ignore[override] + def __hash__(self) -> int: ... def __call__(self, *args, **kwargs): ... @property - def called(self): ... + def called(self) -> bool: ... def argspec(self, body): ... - def fill_implicit_positionals(self, positional): ... - def arg_opts(self, name, default, taken_names): ... - def get_arguments(self): ... + def fill_implicit_positionals(self, positional: Iterable[str] | None) -> Iterable[str]: ... + def arg_opts(self, name: str, default: Any, taken_names: Iterable[str]) -> dict[str, Any]: ... + def get_arguments(self) -> list[Argument]: ... -def task(*args, **kwargs) -> Task: ... +def task( + *args: Task, + name: str | None = ..., + aliases: tuple[str, ...] = ..., + positional: Iterable[str] | None = ..., + optional: Iterable[str] = ..., + default: bool = ..., + auto_shortflags: bool = ..., + help: dict[str, str] | None = ..., + pre: list[Task] | None = ..., + post: list[Task] | None = ..., + autoprint: bool = ..., + iterable: Iterable[str] | None = ..., + incrementable: Iterable[str] | None = ..., + klass: type[_TaskT] = ..., +) -> _TaskT: ... class Call: task: Task