|
1 | 1 | from _typeshed import Self
|
2 |
| -from typing import Any |
| 2 | +from collections.abc import Callable, Iterable |
| 3 | +from typing import Any, TypeVar |
3 | 4 |
|
4 | 5 | from .config import Config
|
5 | 6 | from .context import Context
|
| 7 | +from .parser import Argument |
| 8 | + |
| 9 | +_TaskT = TypeVar("_TaskT", bound=Task) |
6 | 10 |
|
7 | 11 | NO_DEFAULT: object
|
8 | 12 |
|
9 | 13 | class Task:
|
10 |
| - body: Any |
11 |
| - __doc__: str |
| 14 | + body: Callable[..., Any] |
| 15 | + __doc__: str | None |
12 | 16 | __name__: str
|
13 |
| - __module__: Any |
14 |
| - aliases: Any |
| 17 | + __module__: str |
| 18 | + aliases: tuple[str, ...] |
15 | 19 | 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] |
24 | 28 | times_called: int
|
25 |
| - autoprint: Any |
| 29 | + autoprint: bool |
26 | 30 | def __init__(
|
27 | 31 | 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] = ..., |
33 | 37 | default: bool = ...,
|
34 | 38 | 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 = ..., |
38 | 42 | autoprint: bool = ...,
|
39 |
| - iterable=..., |
40 |
| - incrementable=..., |
| 43 | + iterable: Iterable[str] | None = ..., |
| 44 | + incrementable: Iterable[str] | None = ..., |
41 | 45 | ) -> None: ...
|
42 | 46 | @property
|
43 | 47 | 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: ... |
46 | 50 | def __call__(self, *args, **kwargs): ...
|
47 | 51 | @property
|
48 |
| - def called(self): ... |
| 52 | + def called(self) -> bool: ... |
49 | 53 | 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]: ... |
53 | 57 |
|
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: ... |
55 | 74 |
|
56 | 75 | class Call:
|
57 | 76 | task: Task
|
|
0 commit comments