Skip to content

Commit 061ddad

Browse files
authored
Add annotations to invoke.tasks (#7502)
1 parent ba475a0 commit 061ddad

File tree

1 file changed

+50
-31
lines changed

1 file changed

+50
-31
lines changed

stubs/invoke/invoke/tasks.pyi

Lines changed: 50 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,76 @@
11
from _typeshed import Self
2-
from typing import Any
2+
from collections.abc import Callable, Iterable
3+
from typing import Any, TypeVar
34

45
from .config import Config
56
from .context import Context
7+
from .parser import Argument
8+
9+
_TaskT = TypeVar("_TaskT", bound=Task)
610

711
NO_DEFAULT: object
812

913
class Task:
10-
body: Any
11-
__doc__: str
14+
body: Callable[..., Any]
15+
__doc__: str | None
1216
__name__: str
13-
__module__: Any
14-
aliases: Any
17+
__module__: str
18+
aliases: tuple[str, ...]
1519
is_default: bool
16-
positional: Any
17-
optional: Any
18-
iterable: Any
19-
incrementable: Any
20-
auto_shortflags: Any
21-
help: Any
22-
pre: Any
23-
post: Any
20+
positional: Iterable[str]
21+
optional: Iterable[str]
22+
iterable: Iterable[str]
23+
incrementable: Iterable[str]
24+
auto_shortflags: bool
25+
help: dict[str, str]
26+
pre: list[Task]
27+
post: list[Task]
2428
times_called: int
25-
autoprint: Any
29+
autoprint: bool
2630
def __init__(
2731
self,
28-
body,
29-
name=...,
30-
aliases=...,
31-
positional=...,
32-
optional=...,
32+
body: Callable[..., Any],
33+
name: str | None = ...,
34+
aliases: tuple[str, ...] = ...,
35+
positional: Iterable[str] | None = ...,
36+
optional: Iterable[str] = ...,
3337
default: bool = ...,
3438
auto_shortflags: bool = ...,
35-
help=...,
36-
pre=...,
37-
post=...,
39+
help: dict[str, str] | None = ...,
40+
pre: list[Task] | None = ...,
41+
post: list[Task] | None = ...,
3842
autoprint: bool = ...,
39-
iterable=...,
40-
incrementable=...,
43+
iterable: Iterable[str] | None = ...,
44+
incrementable: Iterable[str] | None = ...,
4145
) -> None: ...
4246
@property
4347
def name(self): ...
44-
def __eq__(self, other): ...
45-
def __hash__(self): ...
48+
def __eq__(self, other: Task) -> bool: ... # type: ignore[override]
49+
def __hash__(self) -> int: ...
4650
def __call__(self, *args, **kwargs): ...
4751
@property
48-
def called(self): ...
52+
def called(self) -> bool: ...
4953
def argspec(self, body): ...
50-
def fill_implicit_positionals(self, positional): ...
51-
def arg_opts(self, name, default, taken_names): ...
52-
def get_arguments(self): ...
54+
def fill_implicit_positionals(self, positional: Iterable[str] | None) -> Iterable[str]: ...
55+
def arg_opts(self, name: str, default: Any, taken_names: Iterable[str]) -> dict[str, Any]: ...
56+
def get_arguments(self) -> list[Argument]: ...
5357

54-
def task(*args, **kwargs) -> Task: ...
58+
def task(
59+
*args: Task,
60+
name: str | None = ...,
61+
aliases: tuple[str, ...] = ...,
62+
positional: Iterable[str] | None = ...,
63+
optional: Iterable[str] = ...,
64+
default: bool = ...,
65+
auto_shortflags: bool = ...,
66+
help: dict[str, str] | None = ...,
67+
pre: list[Task] | None = ...,
68+
post: list[Task] | None = ...,
69+
autoprint: bool = ...,
70+
iterable: Iterable[str] | None = ...,
71+
incrementable: Iterable[str] | None = ...,
72+
klass: type[_TaskT] = ...,
73+
) -> _TaskT: ...
5574

5675
class Call:
5776
task: Task

0 commit comments

Comments
 (0)