Skip to content

Commit 2bf7458

Browse files
authored
Add stubs for invoke (#6938)
1 parent 46159ae commit 2bf7458

23 files changed

+653
-0
lines changed

pyrightconfig.stricter.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"stubs/html5lib",
3737
"stubs/httplib2",
3838
"stubs/humanfriendly",
39+
"stubs/invoke",
3940
"stubs/jmespath",
4041
"stubs/jsonschema",
4142
"stubs/ldap3",

stubs/invoke/METADATA.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version = "1.6.*"

stubs/invoke/invoke/__init__.pyi

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
from typing import Any
2+
3+
from .collection import Collection as Collection
4+
from .config import Config as Config
5+
from .context import Context as Context, MockContext as MockContext
6+
from .exceptions import (
7+
AmbiguousEnvVar as AmbiguousEnvVar,
8+
AuthFailure as AuthFailure,
9+
CollectionNotFound as CollectionNotFound,
10+
CommandTimedOut as CommandTimedOut,
11+
Exit as Exit,
12+
Failure as Failure,
13+
ParseError as ParseError,
14+
PlatformError as PlatformError,
15+
ResponseNotAccepted as ResponseNotAccepted,
16+
SubprocessPipeError as SubprocessPipeError,
17+
ThreadException as ThreadException,
18+
UncastableEnvVar as UncastableEnvVar,
19+
UnexpectedExit as UnexpectedExit,
20+
UnknownFileType as UnknownFileType,
21+
UnpicklableConfigMember as UnpicklableConfigMember,
22+
WatcherError as WatcherError,
23+
)
24+
from .executor import Executor as Executor
25+
from .loader import FilesystemLoader as FilesystemLoader
26+
from .parser import Argument as Argument, Parser as Parser, ParserContext as ParserContext, ParseResult as ParseResult
27+
from .program import Program as Program
28+
from .runners import Local as Local, Promise as Promise, Result as Result, Runner as Runner
29+
from .tasks import Call as Call, Task as Task, call as call, task as task
30+
from .terminals import pty_size as pty_size
31+
from .watchers import FailingResponder as FailingResponder, Responder as Responder, StreamWatcher as StreamWatcher
32+
33+
__version_info__: tuple[int, int, int]
34+
__version__: str
35+
36+
def run(command: str, **kwargs: Any) -> Result: ...
37+
def sudo(command: str, **kwargs: Any) -> Result: ...

stubs/invoke/invoke/collection.pyi

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
from typing import Any
2+
3+
class Collection:
4+
tasks: Any
5+
collections: Any
6+
default: str | None
7+
name: str | None
8+
loaded_from: Any
9+
auto_dash_names: bool
10+
def __init__(self, *args, **kwargs) -> None: ...
11+
@classmethod
12+
def from_module(cls, module, name=..., config=..., loaded_from=..., auto_dash_names=...): ...
13+
def add_task(self, task, name=..., aliases=..., default=...) -> None: ...
14+
def add_collection(self, coll, name=..., default=...) -> None: ...
15+
def subcollection_from_path(self, path): ...
16+
def task_with_config(self, name): ...
17+
def to_contexts(self): ...
18+
def subtask_name(self, collection_name, task_name): ...
19+
def transform(self, name): ...
20+
@property
21+
def task_names(self): ...
22+
def configuration(self, taskpath=...): ...
23+
def configure(self, options) -> None: ...
24+
def serialized(self): ...

stubs/invoke/invoke/completion/__init__.pyi

Whitespace-only changes.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
from typing import Iterable, NoReturn, Sequence
2+
3+
from ..collection import Collection
4+
from ..parser import ParserContext, ParseResult
5+
6+
def complete(names: Iterable[str], core: ParseResult, initial_context: ParserContext, collection: Collection) -> NoReturn: ...
7+
def print_task_names(collection: Collection) -> None: ...
8+
def print_completion_script(shell: str, names: Sequence[str]) -> None: ...

stubs/invoke/invoke/config.pyi

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
from typing import Any
2+
3+
def load_source(name: str, path: str) -> dict[str, Any]: ...
4+
5+
class DataProxy:
6+
@classmethod
7+
def from_data(cls, data, root=..., keypath=...): ...
8+
def __getattr__(self, key): ...
9+
def __setattr__(self, key, value) -> None: ...
10+
def __iter__(self): ...
11+
def __eq__(self, other): ...
12+
__hash__: Any
13+
def __len__(self): ...
14+
def __setitem__(self, key, value) -> None: ...
15+
def __getitem__(self, key): ...
16+
def __contains__(self, key): ...
17+
def __delitem__(self, key) -> None: ...
18+
def __delattr__(self, name) -> None: ...
19+
def clear(self) -> None: ...
20+
def pop(self, *args): ...
21+
def popitem(self): ...
22+
def setdefault(self, *args): ...
23+
def update(self, *args, **kwargs) -> None: ...
24+
25+
class Config(DataProxy):
26+
prefix: str
27+
file_prefix: Any
28+
env_prefix: Any
29+
@staticmethod
30+
def global_defaults(): ...
31+
def __init__(
32+
self,
33+
overrides=...,
34+
defaults=...,
35+
system_prefix=...,
36+
user_prefix=...,
37+
project_location=...,
38+
runtime_path=...,
39+
lazy: bool = ...,
40+
) -> None: ...
41+
def load_base_conf_files(self) -> None: ...
42+
def load_defaults(self, data, merge: bool = ...) -> None: ...
43+
def load_overrides(self, data, merge: bool = ...) -> None: ...
44+
def load_system(self, merge: bool = ...) -> None: ...
45+
def load_user(self, merge: bool = ...) -> None: ...
46+
def load_project(self, merge: bool = ...) -> None: ...
47+
def set_runtime_path(self, path) -> None: ...
48+
def load_runtime(self, merge: bool = ...) -> None: ...
49+
def load_shell_env(self) -> None: ...
50+
def load_collection(self, data, merge: bool = ...) -> None: ...
51+
def set_project_location(self, path) -> None: ...
52+
def merge(self) -> None: ...
53+
def clone(self, into=...): ...
54+
55+
class AmbiguousMergeError(ValueError): ...
56+
57+
def merge_dicts(base, updates): ...
58+
def copy_dict(source): ...
59+
def excise(dict_, keypath) -> None: ...
60+
def obliterate(base, deletions) -> None: ...

stubs/invoke/invoke/context.pyi

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
from contextlib import AbstractContextManager
2+
3+
from .config import Config, DataProxy
4+
5+
class Context(DataProxy):
6+
def __init__(self, config: Config | None = ...) -> None: ...
7+
@property
8+
def config(self) -> Config: ...
9+
@config.setter
10+
def config(self, value: Config) -> None: ...
11+
def run(self, command: str, **kwargs): ...
12+
def sudo(self, command: str, *, password: str = ..., user: str = ..., **kwargs): ...
13+
def prefix(self, command: str) -> AbstractContextManager[None]: ...
14+
@property
15+
def cwd(self) -> str: ...
16+
def cd(self, path: str) -> AbstractContextManager[None]: ...
17+
18+
class MockContext(Context):
19+
def __init__(self, config: Config | None = ..., **kwargs) -> None: ...
20+
def run(self, command: str, *args, **kwargs): ...
21+
def sudo(self, command: str, *args, **kwargs): ...
22+
def set_result_for(self, attname, command, result) -> None: ...

stubs/invoke/invoke/env.pyi

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
from typing import Any
2+
3+
class Environment:
4+
data: Any
5+
def __init__(self, config, prefix) -> None: ...
6+
def load(self): ...

stubs/invoke/invoke/exceptions.pyi

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
from typing import Any
2+
3+
class CollectionNotFound(Exception):
4+
name: Any
5+
start: Any
6+
def __init__(self, name, start) -> None: ...
7+
8+
class Failure(Exception):
9+
result: Any
10+
reason: Any
11+
def __init__(self, result, reason=...) -> None: ...
12+
def streams_for_display(self): ...
13+
14+
class UnexpectedExit(Failure): ...
15+
16+
class CommandTimedOut(Failure):
17+
timeout: Any
18+
def __init__(self, result, timeout) -> None: ...
19+
20+
class AuthFailure(Failure):
21+
result: Any
22+
prompt: Any
23+
def __init__(self, result, prompt) -> None: ...
24+
25+
class ParseError(Exception):
26+
context: Any
27+
def __init__(self, msg, context=...) -> None: ...
28+
29+
class Exit(Exception):
30+
message: Any
31+
def __init__(self, message=..., code=...) -> None: ...
32+
@property
33+
def code(self): ...
34+
35+
class PlatformError(Exception): ...
36+
class AmbiguousEnvVar(Exception): ...
37+
class UncastableEnvVar(Exception): ...
38+
class UnknownFileType(Exception): ...
39+
class UnpicklableConfigMember(Exception): ...
40+
41+
class ThreadException(Exception):
42+
exceptions: Any
43+
def __init__(self, exceptions) -> None: ...
44+
45+
class WatcherError(Exception): ...
46+
class ResponseNotAccepted(WatcherError): ...
47+
class SubprocessPipeError(Exception): ...

0 commit comments

Comments
 (0)