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): ...

stubs/invoke/invoke/executor.pyi

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from typing import Any, Iterable
2+
3+
from .collection import Collection
4+
from .config import Config
5+
from .parser import ParserContext, ParseResult
6+
from .tasks import Call, Task
7+
8+
class Executor:
9+
collection: Collection
10+
config: Config
11+
core: ParseResult | None
12+
def __init__(self, collection: Collection, config: Config | None = ..., core: ParseResult | None = ...) -> None: ...
13+
def execute(self, *tasks: str | tuple[str, dict[str, Any]] | ParserContext) -> dict[Task, Any]: ...
14+
def normalize(self, tasks: Iterable[str | tuple[str, dict[str, Any]] | ParserContext]): ...
15+
def dedupe(self, calls: Iterable[Call]) -> list[Call]: ...
16+
def expand_calls(self, calls: Iterable[Call | Task]) -> list[Call]: ...

stubs/invoke/invoke/loader.pyi

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from types import ModuleType
2+
from typing import IO, Any
3+
4+
from . import Config
5+
6+
class Loader:
7+
config: Config
8+
def __init__(self, config: Config | None = ...) -> None: ...
9+
def find(self, name: str) -> tuple[str, IO[Any], str, tuple[str, str, int]]: ...
10+
def load(self, name: str | None = ...) -> tuple[ModuleType, str]: ...
11+
12+
class FilesystemLoader(Loader):
13+
def __init__(self, start: str | None = ..., **kwargs: Any) -> None: ...
14+
@property
15+
def start(self) -> str: ...

stubs/invoke/invoke/main.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from . import Program
2+
3+
program: Program
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
from .argument import Argument as Argument
2+
from .context import ParserContext as ParserContext, to_flag as to_flag, translate_underscores as translate_underscores
3+
from .parser import *
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+
class Argument:
4+
names: Any
5+
kind: Any
6+
raw_value: Any
7+
default: Any
8+
help: Any
9+
positional: Any
10+
optional: Any
11+
incrementable: Any
12+
attr_name: Any
13+
def __init__(
14+
self,
15+
name=...,
16+
names=...,
17+
kind=...,
18+
default=...,
19+
help=...,
20+
positional: bool = ...,
21+
optional: bool = ...,
22+
incrementable: bool = ...,
23+
attr_name=...,
24+
) -> None: ...
25+
@property
26+
def name(self): ...
27+
@property
28+
def nicknames(self): ...
29+
@property
30+
def takes_value(self): ...
31+
@property
32+
def value(self): ...
33+
@value.setter
34+
def value(self, arg) -> None: ...
35+
def set_value(self, value, cast: bool = ...): ...
36+
@property
37+
def got_value(self): ...
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+
def translate_underscores(name: str) -> str: ...
4+
def to_flag(name: str) -> str: ...
5+
def sort_candidate(arg): ...
6+
def flag_key(x): ...
7+
8+
class ParserContext:
9+
args: Any
10+
positional_args: Any
11+
flags: Any
12+
inverse_flags: Any
13+
name: Any
14+
aliases: Any
15+
def __init__(self, name=..., aliases=..., args=...) -> None: ...
16+
def add_arg(self, *args, **kwargs) -> None: ...
17+
@property
18+
def missing_positional_args(self): ...
19+
@property
20+
def as_kwargs(self): ...
21+
def names_for(self, flag): ...
22+
def help_for(self, flag): ...
23+
def help_tuples(self): ...
24+
def flag_names(self): ...

stubs/invoke/invoke/parser/parser.pyi

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
from typing import Any
2+
3+
from .context import ParserContext
4+
5+
def is_flag(value: str) -> bool: ...
6+
def is_long_flag(value: str) -> bool: ...
7+
8+
class Parser:
9+
initial: Any
10+
contexts: Any
11+
ignore_unknown: Any
12+
def __init__(self, contexts=..., initial=..., ignore_unknown: bool = ...) -> None: ...
13+
def parse_argv(self, argv): ...
14+
15+
class ParseMachine:
16+
initial_state: str
17+
def changing_state(self, from_, to) -> None: ...
18+
ignore_unknown: Any
19+
initial: Any
20+
flag: Any
21+
flag_got_value: bool
22+
result: Any
23+
contexts: Any
24+
def __init__(self, initial, contexts, ignore_unknown) -> None: ...
25+
@property
26+
def waiting_for_flag_value(self): ...
27+
def handle(self, token) -> None: ...
28+
def store_only(self, token) -> None: ...
29+
def complete_context(self) -> None: ...
30+
context: Any
31+
def switch_to_context(self, name) -> None: ...
32+
def complete_flag(self) -> None: ...
33+
def check_ambiguity(self, value): ...
34+
def switch_to_flag(self, flag, inverse: bool = ...) -> None: ...
35+
def see_value(self, value) -> None: ...
36+
def see_positional_arg(self, value) -> None: ...
37+
def error(self, msg) -> None: ...
38+
39+
class ParseResult(list[ParserContext]):
40+
remainder: str
41+
unparsed: Any
42+
def __init__(self, *args, **kwargs) -> None: ...

0 commit comments

Comments
 (0)