mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-16 00:37:10 +08:00
Re-organize directory structure (#4971)
See discussion in #2491 Co-authored-by: Ivan Levkivskyi <ilevkivskyi@dropbox.com>
This commit is contained in:
2
stubs/click/METADATA.toml
Normal file
2
stubs/click/METADATA.toml
Normal file
@@ -0,0 +1,2 @@
|
||||
version = "0.1"
|
||||
python2 = true
|
||||
11
stubs/click/click/README.md
Normal file
11
stubs/click/click/README.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# click 7.0
|
||||
|
||||
`__init__.pyi` is almost a copy of `click/__init__.py`. It's a shortcut module
|
||||
anyway in the actual sources so it works well with minimal changes.
|
||||
|
||||
The types are pretty complete but they were created mostly for public API use
|
||||
so some internal modules (`_compat`) or functions (`core._bashcomplete`) are
|
||||
deliberately missing. If you feel the need to add those, pull requests accepted.
|
||||
|
||||
Speaking of pull requests, it would be great if the option decorators informed
|
||||
the type checker on what types the command callback should accept.
|
||||
84
stubs/click/click/__init__.pyi
Normal file
84
stubs/click/click/__init__.pyi
Normal file
@@ -0,0 +1,84 @@
|
||||
from .core import (
|
||||
Argument as Argument,
|
||||
BaseCommand as BaseCommand,
|
||||
Command as Command,
|
||||
CommandCollection as CommandCollection,
|
||||
Context as Context,
|
||||
Group as Group,
|
||||
MultiCommand as MultiCommand,
|
||||
Option as Option,
|
||||
Parameter as Parameter,
|
||||
)
|
||||
from .decorators import (
|
||||
argument as argument,
|
||||
command as command,
|
||||
confirmation_option as confirmation_option,
|
||||
group as group,
|
||||
help_option as help_option,
|
||||
make_pass_decorator as make_pass_decorator,
|
||||
option as option,
|
||||
pass_context as pass_context,
|
||||
pass_obj as pass_obj,
|
||||
password_option as password_option,
|
||||
version_option as version_option,
|
||||
)
|
||||
from .exceptions import (
|
||||
Abort as Abort,
|
||||
BadArgumentUsage as BadArgumentUsage,
|
||||
BadOptionUsage as BadOptionUsage,
|
||||
BadParameter as BadParameter,
|
||||
ClickException as ClickException,
|
||||
FileError as FileError,
|
||||
MissingParameter as MissingParameter,
|
||||
NoSuchOption as NoSuchOption,
|
||||
UsageError as UsageError,
|
||||
)
|
||||
from .formatting import HelpFormatter as HelpFormatter, wrap_text as wrap_text
|
||||
from .globals import get_current_context as get_current_context
|
||||
from .parser import OptionParser as OptionParser
|
||||
from .termui import (
|
||||
clear as clear,
|
||||
confirm as confirm,
|
||||
echo_via_pager as echo_via_pager,
|
||||
edit as edit,
|
||||
get_terminal_size as get_terminal_size,
|
||||
getchar as getchar,
|
||||
launch as launch,
|
||||
pause as pause,
|
||||
progressbar as progressbar,
|
||||
prompt as prompt,
|
||||
secho as secho,
|
||||
style as style,
|
||||
unstyle as unstyle,
|
||||
)
|
||||
from .types import (
|
||||
BOOL as BOOL,
|
||||
FLOAT as FLOAT,
|
||||
INT as INT,
|
||||
STRING as STRING,
|
||||
UNPROCESSED as UNPROCESSED,
|
||||
UUID as UUID,
|
||||
Choice as Choice,
|
||||
DateTime as DateTime,
|
||||
File as File,
|
||||
FloatRange as FloatRange,
|
||||
IntRange as IntRange,
|
||||
ParamType as ParamType,
|
||||
Path as Path,
|
||||
Tuple as Tuple,
|
||||
)
|
||||
from .utils import (
|
||||
echo as echo,
|
||||
format_filename as format_filename,
|
||||
get_app_dir as get_app_dir,
|
||||
get_binary_stream as get_binary_stream,
|
||||
get_os_args as get_os_args,
|
||||
get_text_stream as get_text_stream,
|
||||
open_file as open_file,
|
||||
)
|
||||
|
||||
# Controls if click should emit the warning about the use of unicode
|
||||
# literals.
|
||||
disable_unicode_literals_warning: bool
|
||||
|
||||
__version__: str
|
||||
14
stubs/click/click/_termui_impl.pyi
Normal file
14
stubs/click/click/_termui_impl.pyi
Normal file
@@ -0,0 +1,14 @@
|
||||
from typing import Generic, Optional, TypeVar
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
class ProgressBar(Generic[_T]):
|
||||
def update(self, n_steps: int) -> None: ...
|
||||
def finish(self) -> None: ...
|
||||
def __enter__(self) -> ProgressBar[_T]: ...
|
||||
def __exit__(self, exc_type, exc_value, tb) -> None: ...
|
||||
def __iter__(self) -> ProgressBar[_T]: ...
|
||||
def next(self) -> _T: ...
|
||||
def __next__(self) -> _T: ...
|
||||
length: Optional[int]
|
||||
label: str
|
||||
285
stubs/click/click/core.pyi
Normal file
285
stubs/click/click/core.pyi
Normal file
@@ -0,0 +1,285 @@
|
||||
from typing import (
|
||||
Any,
|
||||
Callable,
|
||||
ContextManager,
|
||||
Dict,
|
||||
Iterable,
|
||||
List,
|
||||
Mapping,
|
||||
NoReturn,
|
||||
Optional,
|
||||
Sequence,
|
||||
Set,
|
||||
Tuple,
|
||||
TypeVar,
|
||||
Union,
|
||||
)
|
||||
|
||||
from click.formatting import HelpFormatter
|
||||
from click.parser import OptionParser
|
||||
|
||||
_CC = TypeVar("_CC", bound=Callable[[], Any])
|
||||
|
||||
def invoke_param_callback(
|
||||
callback: Callable[[Context, Parameter, Optional[str]], Any], ctx: Context, param: Parameter, value: Optional[str]
|
||||
) -> Any: ...
|
||||
def augment_usage_errors(ctx: Context, param: Optional[Parameter] = ...) -> ContextManager[None]: ...
|
||||
def iter_params_for_processing(
|
||||
invocation_order: Sequence[Parameter], declaration_order: Iterable[Parameter]
|
||||
) -> Iterable[Parameter]: ...
|
||||
|
||||
class Context:
|
||||
parent: Optional[Context]
|
||||
command: Command
|
||||
info_name: Optional[str]
|
||||
params: Dict[Any, Any]
|
||||
args: List[str]
|
||||
protected_args: List[str]
|
||||
obj: Any
|
||||
default_map: Optional[Mapping[str, Any]]
|
||||
invoked_subcommand: Optional[str]
|
||||
terminal_width: Optional[int]
|
||||
max_content_width: Optional[int]
|
||||
allow_extra_args: bool
|
||||
allow_interspersed_args: bool
|
||||
ignore_unknown_options: bool
|
||||
help_option_names: List[str]
|
||||
token_normalize_func: Optional[Callable[[str], str]]
|
||||
resilient_parsing: bool
|
||||
auto_envvar_prefix: Optional[str]
|
||||
color: Optional[bool]
|
||||
_meta: Dict[str, Any]
|
||||
_close_callbacks: List[Any]
|
||||
_depth: int
|
||||
def __init__(
|
||||
self,
|
||||
command: Command,
|
||||
parent: Optional[Context] = ...,
|
||||
info_name: Optional[str] = ...,
|
||||
obj: Optional[Any] = ...,
|
||||
auto_envvar_prefix: Optional[str] = ...,
|
||||
default_map: Optional[Mapping[str, Any]] = ...,
|
||||
terminal_width: Optional[int] = ...,
|
||||
max_content_width: Optional[int] = ...,
|
||||
resilient_parsing: bool = ...,
|
||||
allow_extra_args: Optional[bool] = ...,
|
||||
allow_interspersed_args: Optional[bool] = ...,
|
||||
ignore_unknown_options: Optional[bool] = ...,
|
||||
help_option_names: Optional[List[str]] = ...,
|
||||
token_normalize_func: Optional[Callable[[str], str]] = ...,
|
||||
color: Optional[bool] = ...,
|
||||
) -> None: ...
|
||||
@property
|
||||
def meta(self) -> Dict[str, Any]: ...
|
||||
@property
|
||||
def command_path(self) -> str: ...
|
||||
def scope(self, cleanup: bool = ...) -> ContextManager[Context]: ...
|
||||
def make_formatter(self) -> HelpFormatter: ...
|
||||
def call_on_close(self, f: _CC) -> _CC: ...
|
||||
def close(self) -> None: ...
|
||||
def find_root(self) -> Context: ...
|
||||
def find_object(self, object_type: type) -> Any: ...
|
||||
def ensure_object(self, object_type: type) -> Any: ...
|
||||
def lookup_default(self, name: str) -> Any: ...
|
||||
def fail(self, message: str) -> NoReturn: ...
|
||||
def abort(self) -> NoReturn: ...
|
||||
def exit(self, code: Union[int, str] = ...) -> NoReturn: ...
|
||||
def get_usage(self) -> str: ...
|
||||
def get_help(self) -> str: ...
|
||||
def invoke(self, callback: Union[Command, Callable[..., Any]], *args, **kwargs) -> Any: ...
|
||||
def forward(self, callback: Union[Command, Callable[..., Any]], *args, **kwargs) -> Any: ...
|
||||
|
||||
class BaseCommand:
|
||||
allow_extra_args: bool
|
||||
allow_interspersed_args: bool
|
||||
ignore_unknown_options: bool
|
||||
name: str
|
||||
context_settings: Dict[Any, Any]
|
||||
def __init__(self, name: str, context_settings: Optional[Dict[Any, Any]] = ...) -> None: ...
|
||||
def get_usage(self, ctx: Context) -> str: ...
|
||||
def get_help(self, ctx: Context) -> str: ...
|
||||
def make_context(self, info_name: str, args: List[str], parent: Optional[Context] = ..., **extra) -> Context: ...
|
||||
def parse_args(self, ctx: Context, args: List[str]) -> List[str]: ...
|
||||
def invoke(self, ctx: Context) -> Any: ...
|
||||
def main(
|
||||
self,
|
||||
args: Optional[List[str]] = ...,
|
||||
prog_name: Optional[str] = ...,
|
||||
complete_var: Optional[str] = ...,
|
||||
standalone_mode: bool = ...,
|
||||
**extra,
|
||||
) -> Any: ...
|
||||
def __call__(self, *args, **kwargs) -> Any: ...
|
||||
|
||||
class Command(BaseCommand):
|
||||
callback: Optional[Callable[..., Any]]
|
||||
params: List[Parameter]
|
||||
help: Optional[str]
|
||||
epilog: Optional[str]
|
||||
short_help: Optional[str]
|
||||
options_metavar: str
|
||||
add_help_option: bool
|
||||
hidden: bool
|
||||
deprecated: bool
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
context_settings: Optional[Dict[Any, Any]] = ...,
|
||||
callback: Optional[Callable[..., Any]] = ...,
|
||||
params: Optional[List[Parameter]] = ...,
|
||||
help: Optional[str] = ...,
|
||||
epilog: Optional[str] = ...,
|
||||
short_help: Optional[str] = ...,
|
||||
options_metavar: str = ...,
|
||||
add_help_option: bool = ...,
|
||||
hidden: bool = ...,
|
||||
deprecated: bool = ...,
|
||||
) -> None: ...
|
||||
def get_params(self, ctx: Context) -> List[Parameter]: ...
|
||||
def format_usage(self, ctx: Context, formatter: HelpFormatter) -> None: ...
|
||||
def collect_usage_pieces(self, ctx: Context) -> List[str]: ...
|
||||
def get_help_option_names(self, ctx: Context) -> Set[str]: ...
|
||||
def get_help_option(self, ctx: Context) -> Optional[Option]: ...
|
||||
def make_parser(self, ctx: Context) -> OptionParser: ...
|
||||
def get_short_help_str(self, limit: int = ...) -> str: ...
|
||||
def format_help(self, ctx: Context, formatter: HelpFormatter) -> None: ...
|
||||
def format_help_text(self, ctx: Context, formatter: HelpFormatter) -> None: ...
|
||||
def format_options(self, ctx: Context, formatter: HelpFormatter) -> None: ...
|
||||
def format_epilog(self, ctx: Context, formatter: HelpFormatter) -> None: ...
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_F = TypeVar("_F", bound=Callable[..., Any])
|
||||
|
||||
class MultiCommand(Command):
|
||||
no_args_is_help: bool
|
||||
invoke_without_command: bool
|
||||
subcommand_metavar: str
|
||||
chain: bool
|
||||
result_callback: Callable[..., Any]
|
||||
def __init__(
|
||||
self,
|
||||
name: Optional[str] = ...,
|
||||
invoke_without_command: bool = ...,
|
||||
no_args_is_help: Optional[bool] = ...,
|
||||
subcommand_metavar: Optional[str] = ...,
|
||||
chain: bool = ...,
|
||||
result_callback: Optional[Callable[..., Any]] = ...,
|
||||
**attrs,
|
||||
) -> None: ...
|
||||
def resultcallback(self, replace: bool = ...) -> Callable[[_F], _F]: ...
|
||||
def format_commands(self, ctx: Context, formatter: HelpFormatter) -> None: ...
|
||||
def resolve_command(self, ctx: Context, args: List[str]) -> Tuple[str, Command, List[str]]: ...
|
||||
def get_command(self, ctx: Context, cmd_name: str) -> Optional[Command]: ...
|
||||
def list_commands(self, ctx: Context) -> Iterable[str]: ...
|
||||
|
||||
class Group(MultiCommand):
|
||||
commands: Dict[str, Command]
|
||||
def __init__(self, name: Optional[str] = ..., commands: Optional[Dict[str, Command]] = ..., **attrs) -> None: ...
|
||||
def add_command(self, cmd: Command, name: Optional[str] = ...): ...
|
||||
def command(self, *args, **kwargs) -> Callable[[Callable[..., Any]], Command]: ...
|
||||
def group(self, *args, **kwargs) -> Callable[[Callable[..., Any]], Group]: ...
|
||||
|
||||
class CommandCollection(MultiCommand):
|
||||
sources: List[MultiCommand]
|
||||
def __init__(self, name: Optional[str] = ..., sources: Optional[List[MultiCommand]] = ..., **attrs) -> None: ...
|
||||
def add_source(self, multi_cmd: MultiCommand) -> None: ...
|
||||
|
||||
class _ParamType:
|
||||
name: str
|
||||
is_composite: bool
|
||||
envvar_list_splitter: Optional[str]
|
||||
def __call__(self, value: Optional[str], param: Optional[Parameter] = ..., ctx: Optional[Context] = ...) -> Any: ...
|
||||
def get_metavar(self, param: Parameter) -> str: ...
|
||||
def get_missing_message(self, param: Parameter) -> str: ...
|
||||
def convert(self, value: str, param: Optional[Parameter], ctx: Optional[Context]) -> Any: ...
|
||||
def split_envvar_value(self, rv: str) -> List[str]: ...
|
||||
def fail(self, message: str, param: Optional[Parameter] = ..., ctx: Optional[Context] = ...) -> NoReturn: ...
|
||||
|
||||
# This type is here to resolve https://github.com/python/mypy/issues/5275
|
||||
_ConvertibleType = Union[
|
||||
type, _ParamType, Tuple[Union[type, _ParamType], ...], Callable[[str], Any], Callable[[Optional[str]], Any]
|
||||
]
|
||||
|
||||
class Parameter:
|
||||
param_type_name: str
|
||||
name: str
|
||||
opts: List[str]
|
||||
secondary_opts: List[str]
|
||||
type: _ParamType
|
||||
required: bool
|
||||
callback: Optional[Callable[[Context, Parameter, str], Any]]
|
||||
nargs: int
|
||||
multiple: bool
|
||||
expose_value: bool
|
||||
default: Any
|
||||
is_eager: bool
|
||||
metavar: Optional[str]
|
||||
envvar: Union[str, List[str], None]
|
||||
def __init__(
|
||||
self,
|
||||
param_decls: Optional[List[str]] = ...,
|
||||
type: Optional[_ConvertibleType] = ...,
|
||||
required: bool = ...,
|
||||
default: Optional[Any] = ...,
|
||||
callback: Optional[Callable[[Context, Parameter, str], Any]] = ...,
|
||||
nargs: Optional[int] = ...,
|
||||
metavar: Optional[str] = ...,
|
||||
expose_value: bool = ...,
|
||||
is_eager: bool = ...,
|
||||
envvar: Optional[Union[str, List[str]]] = ...,
|
||||
) -> None: ...
|
||||
@property
|
||||
def human_readable_name(self) -> str: ...
|
||||
def make_metavar(self) -> str: ...
|
||||
def get_default(self, ctx: Context) -> Any: ...
|
||||
def add_to_parser(self, parser: OptionParser, ctx: Context) -> None: ...
|
||||
def consume_value(self, ctx: Context, opts: Dict[str, Any]) -> Any: ...
|
||||
def type_cast_value(self, ctx: Context, value: Any) -> Any: ...
|
||||
def process_value(self, ctx: Context, value: Any) -> Any: ...
|
||||
def value_is_missing(self, value: Any) -> bool: ...
|
||||
def full_process_value(self, ctx: Context, value: Any) -> Any: ...
|
||||
def resolve_envvar_value(self, ctx: Context) -> str: ...
|
||||
def value_from_envvar(self, ctx: Context) -> Union[str, List[str]]: ...
|
||||
def handle_parse_result(self, ctx: Context, opts: Dict[str, Any], args: List[str]) -> Tuple[Any, List[str]]: ...
|
||||
def get_help_record(self, ctx: Context) -> Tuple[str, str]: ...
|
||||
def get_usage_pieces(self, ctx: Context) -> List[str]: ...
|
||||
def get_error_hint(self, ctx: Context) -> str: ...
|
||||
|
||||
class Option(Parameter):
|
||||
prompt: str # sic
|
||||
confirmation_prompt: bool
|
||||
hide_input: bool
|
||||
is_flag: bool
|
||||
flag_value: Any
|
||||
is_bool_flag: bool
|
||||
count: bool
|
||||
multiple: bool
|
||||
allow_from_autoenv: bool
|
||||
help: Optional[str]
|
||||
hidden: bool
|
||||
show_default: bool
|
||||
show_choices: bool
|
||||
show_envvar: bool
|
||||
def __init__(
|
||||
self,
|
||||
param_decls: Optional[List[str]] = ...,
|
||||
show_default: bool = ...,
|
||||
prompt: Union[bool, str] = ...,
|
||||
confirmation_prompt: bool = ...,
|
||||
hide_input: bool = ...,
|
||||
is_flag: Optional[bool] = ...,
|
||||
flag_value: Optional[Any] = ...,
|
||||
multiple: bool = ...,
|
||||
count: bool = ...,
|
||||
allow_from_autoenv: bool = ...,
|
||||
type: Optional[_ConvertibleType] = ...,
|
||||
help: Optional[str] = ...,
|
||||
hidden: bool = ...,
|
||||
show_choices: bool = ...,
|
||||
show_envvar: bool = ...,
|
||||
**attrs,
|
||||
) -> None: ...
|
||||
def prompt_for_value(self, ctx: Context) -> Any: ...
|
||||
|
||||
class Argument(Parameter):
|
||||
def __init__(self, param_decls: Optional[List[str]] = ..., required: Optional[bool] = ..., **attrs) -> None: ...
|
||||
293
stubs/click/click/decorators.pyi
Normal file
293
stubs/click/click/decorators.pyi
Normal file
@@ -0,0 +1,293 @@
|
||||
from distutils.version import Version
|
||||
from typing import Any, Callable, Dict, List, Optional, Protocol, Text, Tuple, Type, TypeVar, Union, overload
|
||||
|
||||
from click.core import Argument, Command, Context, Group, Option, Parameter, _ConvertibleType
|
||||
|
||||
_T = TypeVar("_T")
|
||||
_F = TypeVar("_F", bound=Callable[..., Any])
|
||||
|
||||
class _IdentityFunction(Protocol):
|
||||
def __call__(self, __x: _T) -> _T: ...
|
||||
|
||||
_Callback = Callable[[Context, Union[Option, Parameter], Any], Any]
|
||||
|
||||
def pass_context(__f: _T) -> _T: ...
|
||||
def pass_obj(__f: _T) -> _T: ...
|
||||
def make_pass_decorator(object_type: type, ensure: bool = ...) -> _IdentityFunction: ...
|
||||
|
||||
# NOTE: Decorators below have **attrs converted to concrete constructor
|
||||
# arguments from core.pyi to help with type checking.
|
||||
|
||||
def command(
|
||||
name: Optional[str] = ...,
|
||||
cls: Optional[Type[Command]] = ...,
|
||||
# Command
|
||||
context_settings: Optional[Dict[Any, Any]] = ...,
|
||||
help: Optional[str] = ...,
|
||||
epilog: Optional[str] = ...,
|
||||
short_help: Optional[str] = ...,
|
||||
options_metavar: str = ...,
|
||||
add_help_option: bool = ...,
|
||||
hidden: bool = ...,
|
||||
deprecated: bool = ...,
|
||||
) -> Callable[[Callable[..., Any]], Command]: ...
|
||||
|
||||
# This inherits attrs from Group, MultiCommand and Command.
|
||||
|
||||
def group(
|
||||
name: Optional[str] = ...,
|
||||
cls: Type[Command] = ...,
|
||||
# Group
|
||||
commands: Optional[Dict[str, Command]] = ...,
|
||||
# MultiCommand
|
||||
invoke_without_command: bool = ...,
|
||||
no_args_is_help: Optional[bool] = ...,
|
||||
subcommand_metavar: Optional[str] = ...,
|
||||
chain: bool = ...,
|
||||
result_callback: Optional[Callable[..., Any]] = ...,
|
||||
# Command
|
||||
help: Optional[str] = ...,
|
||||
epilog: Optional[str] = ...,
|
||||
short_help: Optional[str] = ...,
|
||||
options_metavar: str = ...,
|
||||
add_help_option: bool = ...,
|
||||
hidden: bool = ...,
|
||||
deprecated: bool = ...,
|
||||
# User-defined
|
||||
**kwargs: Any,
|
||||
) -> Callable[[Callable[..., Any]], Group]: ...
|
||||
def argument(
|
||||
*param_decls: Text,
|
||||
cls: Type[Argument] = ...,
|
||||
# Argument
|
||||
required: Optional[bool] = ...,
|
||||
# Parameter
|
||||
type: Optional[_ConvertibleType] = ...,
|
||||
default: Optional[Any] = ...,
|
||||
callback: Optional[_Callback] = ...,
|
||||
nargs: Optional[int] = ...,
|
||||
metavar: Optional[str] = ...,
|
||||
expose_value: bool = ...,
|
||||
is_eager: bool = ...,
|
||||
envvar: Optional[Union[str, List[str]]] = ...,
|
||||
autocompletion: Optional[Callable[[Any, List[str], str], List[Union[str, Tuple[str, str]]]]] = ...,
|
||||
) -> _IdentityFunction: ...
|
||||
@overload
|
||||
def option(
|
||||
*param_decls: Text,
|
||||
cls: Type[Option] = ...,
|
||||
# Option
|
||||
show_default: Union[bool, Text] = ...,
|
||||
prompt: Union[bool, Text] = ...,
|
||||
confirmation_prompt: bool = ...,
|
||||
hide_input: bool = ...,
|
||||
is_flag: Optional[bool] = ...,
|
||||
flag_value: Optional[Any] = ...,
|
||||
multiple: bool = ...,
|
||||
count: bool = ...,
|
||||
allow_from_autoenv: bool = ...,
|
||||
type: Optional[_ConvertibleType] = ...,
|
||||
help: Optional[Text] = ...,
|
||||
show_choices: bool = ...,
|
||||
# Parameter
|
||||
default: Optional[Any] = ...,
|
||||
required: bool = ...,
|
||||
callback: Optional[_Callback] = ...,
|
||||
nargs: Optional[int] = ...,
|
||||
metavar: Optional[str] = ...,
|
||||
expose_value: bool = ...,
|
||||
is_eager: bool = ...,
|
||||
envvar: Optional[Union[str, List[str]]] = ...,
|
||||
# User-defined
|
||||
**kwargs: Any,
|
||||
) -> _IdentityFunction: ...
|
||||
@overload
|
||||
def option(
|
||||
*param_decls: str,
|
||||
cls: Type[Option] = ...,
|
||||
# Option
|
||||
show_default: Union[bool, Text] = ...,
|
||||
prompt: Union[bool, Text] = ...,
|
||||
confirmation_prompt: bool = ...,
|
||||
hide_input: bool = ...,
|
||||
is_flag: Optional[bool] = ...,
|
||||
flag_value: Optional[Any] = ...,
|
||||
multiple: bool = ...,
|
||||
count: bool = ...,
|
||||
allow_from_autoenv: bool = ...,
|
||||
type: _T = ...,
|
||||
help: Optional[str] = ...,
|
||||
show_choices: bool = ...,
|
||||
# Parameter
|
||||
default: Optional[Any] = ...,
|
||||
required: bool = ...,
|
||||
callback: Optional[Callable[[Context, Union[Option, Parameter], Union[bool, int, str]], _T]] = ...,
|
||||
nargs: Optional[int] = ...,
|
||||
metavar: Optional[str] = ...,
|
||||
expose_value: bool = ...,
|
||||
is_eager: bool = ...,
|
||||
envvar: Optional[Union[str, List[str]]] = ...,
|
||||
# User-defined
|
||||
**kwargs: Any,
|
||||
) -> _IdentityFunction: ...
|
||||
@overload
|
||||
def option(
|
||||
*param_decls: str,
|
||||
cls: Type[Option] = ...,
|
||||
# Option
|
||||
show_default: Union[bool, Text] = ...,
|
||||
prompt: Union[bool, Text] = ...,
|
||||
confirmation_prompt: bool = ...,
|
||||
hide_input: bool = ...,
|
||||
is_flag: Optional[bool] = ...,
|
||||
flag_value: Optional[Any] = ...,
|
||||
multiple: bool = ...,
|
||||
count: bool = ...,
|
||||
allow_from_autoenv: bool = ...,
|
||||
type: Type[str] = ...,
|
||||
help: Optional[str] = ...,
|
||||
show_choices: bool = ...,
|
||||
# Parameter
|
||||
default: Optional[Any] = ...,
|
||||
required: bool = ...,
|
||||
callback: Callable[[Context, Union[Option, Parameter], str], Any] = ...,
|
||||
nargs: Optional[int] = ...,
|
||||
metavar: Optional[str] = ...,
|
||||
expose_value: bool = ...,
|
||||
is_eager: bool = ...,
|
||||
envvar: Optional[Union[str, List[str]]] = ...,
|
||||
# User-defined
|
||||
**kwargs: Any,
|
||||
) -> _IdentityFunction: ...
|
||||
@overload
|
||||
def option(
|
||||
*param_decls: str,
|
||||
cls: Type[Option] = ...,
|
||||
# Option
|
||||
show_default: Union[bool, Text] = ...,
|
||||
prompt: Union[bool, Text] = ...,
|
||||
confirmation_prompt: bool = ...,
|
||||
hide_input: bool = ...,
|
||||
is_flag: Optional[bool] = ...,
|
||||
flag_value: Optional[Any] = ...,
|
||||
multiple: bool = ...,
|
||||
count: bool = ...,
|
||||
allow_from_autoenv: bool = ...,
|
||||
type: Type[int] = ...,
|
||||
help: Optional[str] = ...,
|
||||
show_choices: bool = ...,
|
||||
# Parameter
|
||||
default: Optional[Any] = ...,
|
||||
required: bool = ...,
|
||||
callback: Callable[[Context, Union[Option, Parameter], int], Any] = ...,
|
||||
nargs: Optional[int] = ...,
|
||||
metavar: Optional[str] = ...,
|
||||
expose_value: bool = ...,
|
||||
is_eager: bool = ...,
|
||||
envvar: Optional[Union[str, List[str]]] = ...,
|
||||
# User-defined
|
||||
**kwargs: Any,
|
||||
) -> _IdentityFunction: ...
|
||||
def confirmation_option(
|
||||
*param_decls: str,
|
||||
cls: Type[Option] = ...,
|
||||
# Option
|
||||
show_default: Union[bool, Text] = ...,
|
||||
prompt: Union[bool, Text] = ...,
|
||||
confirmation_prompt: bool = ...,
|
||||
hide_input: bool = ...,
|
||||
is_flag: bool = ...,
|
||||
flag_value: Optional[Any] = ...,
|
||||
multiple: bool = ...,
|
||||
count: bool = ...,
|
||||
allow_from_autoenv: bool = ...,
|
||||
type: Optional[_ConvertibleType] = ...,
|
||||
help: str = ...,
|
||||
show_choices: bool = ...,
|
||||
# Parameter
|
||||
default: Optional[Any] = ...,
|
||||
callback: Optional[_Callback] = ...,
|
||||
nargs: Optional[int] = ...,
|
||||
metavar: Optional[str] = ...,
|
||||
expose_value: bool = ...,
|
||||
is_eager: bool = ...,
|
||||
envvar: Optional[Union[str, List[str]]] = ...,
|
||||
) -> _IdentityFunction: ...
|
||||
def password_option(
|
||||
*param_decls: str,
|
||||
cls: Type[Option] = ...,
|
||||
# Option
|
||||
show_default: Union[bool, Text] = ...,
|
||||
prompt: Union[bool, Text] = ...,
|
||||
confirmation_prompt: bool = ...,
|
||||
hide_input: bool = ...,
|
||||
is_flag: Optional[bool] = ...,
|
||||
flag_value: Optional[Any] = ...,
|
||||
multiple: bool = ...,
|
||||
count: bool = ...,
|
||||
allow_from_autoenv: bool = ...,
|
||||
type: Optional[_ConvertibleType] = ...,
|
||||
help: Optional[str] = ...,
|
||||
show_choices: bool = ...,
|
||||
# Parameter
|
||||
default: Optional[Any] = ...,
|
||||
callback: Optional[_Callback] = ...,
|
||||
nargs: Optional[int] = ...,
|
||||
metavar: Optional[str] = ...,
|
||||
expose_value: bool = ...,
|
||||
is_eager: bool = ...,
|
||||
envvar: Optional[Union[str, List[str]]] = ...,
|
||||
) -> _IdentityFunction: ...
|
||||
def version_option(
|
||||
version: Optional[Union[str, Version]] = ...,
|
||||
*param_decls: str,
|
||||
cls: Type[Option] = ...,
|
||||
# Option
|
||||
prog_name: Optional[str] = ...,
|
||||
message: Optional[str] = ...,
|
||||
show_default: Union[bool, Text] = ...,
|
||||
prompt: Union[bool, Text] = ...,
|
||||
confirmation_prompt: bool = ...,
|
||||
hide_input: bool = ...,
|
||||
is_flag: bool = ...,
|
||||
flag_value: Optional[Any] = ...,
|
||||
multiple: bool = ...,
|
||||
count: bool = ...,
|
||||
allow_from_autoenv: bool = ...,
|
||||
type: Optional[_ConvertibleType] = ...,
|
||||
help: str = ...,
|
||||
show_choices: bool = ...,
|
||||
# Parameter
|
||||
default: Optional[Any] = ...,
|
||||
callback: Optional[_Callback] = ...,
|
||||
nargs: Optional[int] = ...,
|
||||
metavar: Optional[str] = ...,
|
||||
expose_value: bool = ...,
|
||||
is_eager: bool = ...,
|
||||
envvar: Optional[Union[str, List[str]]] = ...,
|
||||
) -> _IdentityFunction: ...
|
||||
def help_option(
|
||||
*param_decls: str,
|
||||
cls: Type[Option] = ...,
|
||||
# Option
|
||||
show_default: Union[bool, Text] = ...,
|
||||
prompt: Union[bool, Text] = ...,
|
||||
confirmation_prompt: bool = ...,
|
||||
hide_input: bool = ...,
|
||||
is_flag: bool = ...,
|
||||
flag_value: Optional[Any] = ...,
|
||||
multiple: bool = ...,
|
||||
count: bool = ...,
|
||||
allow_from_autoenv: bool = ...,
|
||||
type: Optional[_ConvertibleType] = ...,
|
||||
help: str = ...,
|
||||
show_choices: bool = ...,
|
||||
# Parameter
|
||||
default: Optional[Any] = ...,
|
||||
callback: Optional[_Callback] = ...,
|
||||
nargs: Optional[int] = ...,
|
||||
metavar: Optional[str] = ...,
|
||||
expose_value: bool = ...,
|
||||
is_eager: bool = ...,
|
||||
envvar: Optional[Union[str, List[str]]] = ...,
|
||||
) -> _IdentityFunction: ...
|
||||
60
stubs/click/click/exceptions.pyi
Normal file
60
stubs/click/click/exceptions.pyi
Normal file
@@ -0,0 +1,60 @@
|
||||
from typing import IO, Any, List, Optional
|
||||
|
||||
from click.core import Context, Parameter
|
||||
|
||||
class ClickException(Exception):
|
||||
exit_code: int
|
||||
message: str
|
||||
def __init__(self, message: str) -> None: ...
|
||||
def format_message(self) -> str: ...
|
||||
def show(self, file: Optional[Any] = ...) -> None: ...
|
||||
|
||||
class UsageError(ClickException):
|
||||
ctx: Optional[Context]
|
||||
def __init__(self, message: str, ctx: Optional[Context] = ...) -> None: ...
|
||||
def show(self, file: Optional[IO[Any]] = ...) -> None: ...
|
||||
|
||||
class BadParameter(UsageError):
|
||||
param: Optional[Parameter]
|
||||
param_hint: Optional[str]
|
||||
def __init__(
|
||||
self, message: str, ctx: Optional[Context] = ..., param: Optional[Parameter] = ..., param_hint: Optional[str] = ...
|
||||
) -> None: ...
|
||||
|
||||
class MissingParameter(BadParameter):
|
||||
param_type: str # valid values: 'parameter', 'option', 'argument'
|
||||
def __init__(
|
||||
self,
|
||||
message: Optional[str] = ...,
|
||||
ctx: Optional[Context] = ...,
|
||||
param: Optional[Parameter] = ...,
|
||||
param_hint: Optional[str] = ...,
|
||||
param_type: Optional[str] = ...,
|
||||
) -> None: ...
|
||||
|
||||
class NoSuchOption(UsageError):
|
||||
option_name: str
|
||||
possibilities: Optional[List[str]]
|
||||
def __init__(
|
||||
self,
|
||||
option_name: str,
|
||||
message: Optional[str] = ...,
|
||||
possibilities: Optional[List[str]] = ...,
|
||||
ctx: Optional[Context] = ...,
|
||||
) -> None: ...
|
||||
|
||||
class BadOptionUsage(UsageError):
|
||||
def __init__(self, option_name: str, message: str, ctx: Optional[Context] = ...) -> None: ...
|
||||
|
||||
class BadArgumentUsage(UsageError):
|
||||
def __init__(self, message: str, ctx: Optional[Context] = ...) -> None: ...
|
||||
|
||||
class FileError(ClickException):
|
||||
ui_filename: str
|
||||
filename: str
|
||||
def __init__(self, filename: str, hint: Optional[str] = ...) -> None: ...
|
||||
|
||||
class Abort(RuntimeError): ...
|
||||
|
||||
class Exit(RuntimeError):
|
||||
def __init__(self, code: int = ...) -> None: ...
|
||||
34
stubs/click/click/formatting.pyi
Normal file
34
stubs/click/click/formatting.pyi
Normal file
@@ -0,0 +1,34 @@
|
||||
from typing import ContextManager, Generator, Iterable, List, Optional, Tuple
|
||||
|
||||
FORCED_WIDTH: Optional[int]
|
||||
|
||||
def measure_table(rows: Iterable[Iterable[str]]) -> Tuple[int, ...]: ...
|
||||
def iter_rows(rows: Iterable[Iterable[str]], col_count: int) -> Generator[Tuple[str, ...], None, None]: ...
|
||||
def wrap_text(
|
||||
text: str, width: int = ..., initial_indent: str = ..., subsequent_indent: str = ..., preserve_paragraphs: bool = ...
|
||||
) -> str: ...
|
||||
|
||||
class HelpFormatter:
|
||||
indent_increment: int
|
||||
width: Optional[int]
|
||||
current_indent: int
|
||||
buffer: List[str]
|
||||
def __init__(self, indent_increment: int = ..., width: Optional[int] = ..., max_width: Optional[int] = ...) -> None: ...
|
||||
def write(self, string: str) -> None: ...
|
||||
def indent(self) -> None: ...
|
||||
def dedent(self) -> None: ...
|
||||
def write_usage(
|
||||
self,
|
||||
prog: str,
|
||||
args: str = ...,
|
||||
prefix: str = ...,
|
||||
): ...
|
||||
def write_heading(self, heading: str) -> None: ...
|
||||
def write_paragraph(self) -> None: ...
|
||||
def write_text(self, text: str) -> None: ...
|
||||
def write_dl(self, rows: Iterable[Iterable[str]], col_max: int = ..., col_spacing: int = ...) -> None: ...
|
||||
def section(self, name) -> ContextManager[None]: ...
|
||||
def indentation(self) -> ContextManager[None]: ...
|
||||
def getvalue(self) -> str: ...
|
||||
|
||||
def join_options(options: List[str]) -> Tuple[str, bool]: ...
|
||||
8
stubs/click/click/globals.pyi
Normal file
8
stubs/click/click/globals.pyi
Normal file
@@ -0,0 +1,8 @@
|
||||
from typing import Optional
|
||||
|
||||
from click.core import Context
|
||||
|
||||
def get_current_context(silent: bool = ...) -> Context: ...
|
||||
def push_context(ctx: Context) -> None: ...
|
||||
def pop_context() -> None: ...
|
||||
def resolve_color_default(color: Optional[bool] = ...) -> Optional[bool]: ...
|
||||
65
stubs/click/click/parser.pyi
Normal file
65
stubs/click/click/parser.pyi
Normal file
@@ -0,0 +1,65 @@
|
||||
from typing import Any, Dict, Iterable, List, Optional, Set, Tuple
|
||||
|
||||
from click.core import Context
|
||||
|
||||
def _unpack_args(args: Iterable[str], nargs_spec: Iterable[int]) -> Tuple[Tuple[Optional[Tuple[str, ...]], ...], List[str]]: ...
|
||||
def split_opt(opt: str) -> Tuple[str, str]: ...
|
||||
def normalize_opt(opt: str, ctx: Context) -> str: ...
|
||||
def split_arg_string(string: str) -> List[str]: ...
|
||||
|
||||
class Option:
|
||||
dest: str
|
||||
action: str
|
||||
nargs: int
|
||||
const: Any
|
||||
obj: Any
|
||||
prefixes: Set[str]
|
||||
_short_opts: List[str]
|
||||
_long_opts: List[str]
|
||||
def __init__(
|
||||
self,
|
||||
opts: Iterable[str],
|
||||
dest: str,
|
||||
action: Optional[str] = ...,
|
||||
nargs: int = ...,
|
||||
const: Optional[Any] = ...,
|
||||
obj: Optional[Any] = ...,
|
||||
) -> None: ...
|
||||
@property
|
||||
def takes_value(self) -> bool: ...
|
||||
def process(self, value: Any, state: ParsingState) -> None: ...
|
||||
|
||||
class Argument:
|
||||
dest: str
|
||||
nargs: int
|
||||
obj: Any
|
||||
def __init__(self, dest: str, nargs: int = ..., obj: Optional[Any] = ...) -> None: ...
|
||||
def process(self, value: Any, state: ParsingState) -> None: ...
|
||||
|
||||
class ParsingState:
|
||||
opts: Dict[str, Any]
|
||||
largs: List[str]
|
||||
rargs: List[str]
|
||||
order: List[Any]
|
||||
def __init__(self, rargs: List[str]) -> None: ...
|
||||
|
||||
class OptionParser:
|
||||
ctx: Optional[Context]
|
||||
allow_interspersed_args: bool
|
||||
ignore_unknown_options: bool
|
||||
_short_opt: Dict[str, Option]
|
||||
_long_opt: Dict[str, Option]
|
||||
_opt_prefixes: Set[str]
|
||||
_args: List[Argument]
|
||||
def __init__(self, ctx: Optional[Context] = ...) -> None: ...
|
||||
def add_option(
|
||||
self,
|
||||
opts: Iterable[str],
|
||||
dest: str,
|
||||
action: Optional[str] = ...,
|
||||
nargs: int = ...,
|
||||
const: Optional[Any] = ...,
|
||||
obj: Optional[Any] = ...,
|
||||
) -> None: ...
|
||||
def add_argument(self, dest: str, nargs: int = ..., obj: Optional[Any] = ...) -> None: ...
|
||||
def parse_args(self, args: List[str]) -> Tuple[Dict[str, Any], List[str], List[Any]]: ...
|
||||
103
stubs/click/click/termui.pyi
Normal file
103
stubs/click/click/termui.pyi
Normal file
@@ -0,0 +1,103 @@
|
||||
from typing import IO, Any, Callable, Generator, Iterable, Optional, Text, Tuple, TypeVar, Union, overload
|
||||
|
||||
from click._termui_impl import ProgressBar as _ProgressBar
|
||||
from click.core import _ConvertibleType
|
||||
|
||||
def hidden_prompt_func(prompt: str) -> str: ...
|
||||
def _build_prompt(text: str, suffix: str, show_default: bool = ..., default: Optional[str] = ...) -> str: ...
|
||||
def prompt(
|
||||
text: str,
|
||||
default: Optional[str] = ...,
|
||||
hide_input: bool = ...,
|
||||
confirmation_prompt: bool = ...,
|
||||
type: Optional[_ConvertibleType] = ...,
|
||||
value_proc: Optional[Callable[[Optional[str]], Any]] = ...,
|
||||
prompt_suffix: str = ...,
|
||||
show_default: bool = ...,
|
||||
err: bool = ...,
|
||||
show_choices: bool = ...,
|
||||
) -> Any: ...
|
||||
def confirm(
|
||||
text: str, default: bool = ..., abort: bool = ..., prompt_suffix: str = ..., show_default: bool = ..., err: bool = ...
|
||||
) -> bool: ...
|
||||
def get_terminal_size() -> Tuple[int, int]: ...
|
||||
def echo_via_pager(
|
||||
text_or_generator: Union[str, Iterable[str], Callable[[], Generator[str, None, None]]], color: Optional[bool] = ...
|
||||
) -> None: ...
|
||||
|
||||
_T = TypeVar("_T")
|
||||
@overload
|
||||
def progressbar(
|
||||
iterable: Iterable[_T],
|
||||
length: Optional[int] = ...,
|
||||
label: Optional[str] = ...,
|
||||
show_eta: bool = ...,
|
||||
show_percent: Optional[bool] = ...,
|
||||
show_pos: bool = ...,
|
||||
item_show_func: Optional[Callable[[_T], str]] = ...,
|
||||
fill_char: str = ...,
|
||||
empty_char: str = ...,
|
||||
bar_template: str = ...,
|
||||
info_sep: str = ...,
|
||||
width: int = ...,
|
||||
file: Optional[IO[Any]] = ...,
|
||||
color: Optional[bool] = ...,
|
||||
) -> _ProgressBar[_T]: ...
|
||||
@overload
|
||||
def progressbar(
|
||||
iterable: None = ...,
|
||||
length: Optional[int] = ...,
|
||||
label: Optional[str] = ...,
|
||||
show_eta: bool = ...,
|
||||
show_percent: Optional[bool] = ...,
|
||||
show_pos: bool = ...,
|
||||
item_show_func: Optional[Callable[[_T], str]] = ...,
|
||||
fill_char: str = ...,
|
||||
empty_char: str = ...,
|
||||
bar_template: str = ...,
|
||||
info_sep: str = ...,
|
||||
width: int = ...,
|
||||
file: Optional[IO[Any]] = ...,
|
||||
color: Optional[bool] = ...,
|
||||
) -> _ProgressBar[int]: ...
|
||||
def clear() -> None: ...
|
||||
def style(
|
||||
text: Text,
|
||||
fg: Optional[Text] = ...,
|
||||
bg: Optional[Text] = ...,
|
||||
bold: Optional[bool] = ...,
|
||||
dim: Optional[bool] = ...,
|
||||
underline: Optional[bool] = ...,
|
||||
blink: Optional[bool] = ...,
|
||||
reverse: Optional[bool] = ...,
|
||||
reset: bool = ...,
|
||||
) -> str: ...
|
||||
def unstyle(text: Text) -> str: ...
|
||||
|
||||
# Styling options copied from style() for nicer type checking.
|
||||
def secho(
|
||||
message: Optional[str] = ...,
|
||||
file: Optional[IO[Any]] = ...,
|
||||
nl: bool = ...,
|
||||
err: bool = ...,
|
||||
color: Optional[bool] = ...,
|
||||
fg: Optional[str] = ...,
|
||||
bg: Optional[str] = ...,
|
||||
bold: Optional[bool] = ...,
|
||||
dim: Optional[bool] = ...,
|
||||
underline: Optional[bool] = ...,
|
||||
blink: Optional[bool] = ...,
|
||||
reverse: Optional[bool] = ...,
|
||||
reset: bool = ...,
|
||||
): ...
|
||||
def edit(
|
||||
text: Optional[str] = ...,
|
||||
editor: Optional[str] = ...,
|
||||
env: Optional[str] = ...,
|
||||
require_save: bool = ...,
|
||||
extension: str = ...,
|
||||
filename: Optional[str] = ...,
|
||||
) -> str: ...
|
||||
def launch(url: str, wait: bool = ..., locate: bool = ...) -> int: ...
|
||||
def getchar(echo: bool = ...) -> Text: ...
|
||||
def pause(info: str = ..., err: bool = ...) -> None: ...
|
||||
67
stubs/click/click/testing.pyi
Normal file
67
stubs/click/click/testing.pyi
Normal file
@@ -0,0 +1,67 @@
|
||||
from typing import IO, Any, BinaryIO, ContextManager, Dict, Iterable, List, Mapping, Optional, Text, Union
|
||||
|
||||
from .core import BaseCommand
|
||||
|
||||
clickpkg: Any
|
||||
|
||||
class EchoingStdin:
|
||||
def __init__(self, input: BinaryIO, output: BinaryIO) -> None: ...
|
||||
def __getattr__(self, x: str) -> Any: ...
|
||||
def read(self, n: int = ...) -> bytes: ...
|
||||
def readline(self, n: int = ...) -> bytes: ...
|
||||
def readlines(self) -> List[bytes]: ...
|
||||
def __iter__(self) -> Iterable[bytes]: ...
|
||||
|
||||
def make_input_stream(input: Optional[Union[bytes, Text, IO[Any]]], charset: Text) -> BinaryIO: ...
|
||||
|
||||
class Result:
|
||||
runner: CliRunner
|
||||
exit_code: int
|
||||
exception: Any
|
||||
exc_info: Optional[Any]
|
||||
stdout_bytes: bytes
|
||||
stderr_bytes: bytes
|
||||
def __init__(
|
||||
self,
|
||||
runner: CliRunner,
|
||||
stdout_bytes: bytes,
|
||||
stderr_bytes: bytes,
|
||||
exit_code: int,
|
||||
exception: Any,
|
||||
exc_info: Optional[Any] = ...,
|
||||
) -> None: ...
|
||||
@property
|
||||
def output(self) -> Text: ...
|
||||
@property
|
||||
def stdout(self) -> Text: ...
|
||||
@property
|
||||
def stderr(self) -> Text: ...
|
||||
|
||||
class CliRunner:
|
||||
charset: str
|
||||
env: Mapping[str, str]
|
||||
echo_stdin: bool
|
||||
mix_stderr: bool
|
||||
def __init__(
|
||||
self,
|
||||
charset: Optional[Text] = ...,
|
||||
env: Optional[Mapping[str, str]] = ...,
|
||||
echo_stdin: bool = ...,
|
||||
mix_stderr: bool = ...,
|
||||
) -> None: ...
|
||||
def get_default_prog_name(self, cli: BaseCommand) -> str: ...
|
||||
def make_env(self, overrides: Optional[Mapping[str, str]] = ...) -> Dict[str, str]: ...
|
||||
def isolation(
|
||||
self, input: Optional[Union[bytes, Text, IO[Any]]] = ..., env: Optional[Mapping[str, str]] = ..., color: bool = ...
|
||||
) -> ContextManager[BinaryIO]: ...
|
||||
def invoke(
|
||||
self,
|
||||
cli: BaseCommand,
|
||||
args: Optional[Union[str, Iterable[str]]] = ...,
|
||||
input: Optional[Union[bytes, Text, IO[Any]]] = ...,
|
||||
env: Optional[Mapping[str, str]] = ...,
|
||||
catch_exceptions: bool = ...,
|
||||
color: bool = ...,
|
||||
**extra: Any,
|
||||
) -> Result: ...
|
||||
def isolated_filesystem(self) -> ContextManager[str]: ...
|
||||
125
stubs/click/click/types.pyi
Normal file
125
stubs/click/click/types.pyi
Normal file
@@ -0,0 +1,125 @@
|
||||
import datetime
|
||||
import uuid
|
||||
from typing import IO, Any, Callable, Generic, Iterable, List, Optional, Sequence, Text, Tuple as _PyTuple, Type, TypeVar, Union
|
||||
|
||||
from click.core import Context, Parameter, _ConvertibleType, _ParamType
|
||||
|
||||
ParamType = _ParamType
|
||||
|
||||
class BoolParamType(ParamType):
|
||||
def __call__(self, value: Optional[str], param: Optional[Parameter] = ..., ctx: Optional[Context] = ...) -> bool: ...
|
||||
def convert(self, value: str, param: Optional[Parameter], ctx: Optional[Context]) -> bool: ...
|
||||
|
||||
class CompositeParamType(ParamType):
|
||||
arity: int
|
||||
|
||||
class Choice(ParamType):
|
||||
choices: Iterable[str]
|
||||
case_sensitive: bool
|
||||
def __init__(self, choices: Iterable[str], case_sensitive: bool = ...) -> None: ...
|
||||
|
||||
class DateTime(ParamType):
|
||||
formats: Sequence[str]
|
||||
def __init__(self, formats: Optional[Sequence[str]] = ...) -> None: ...
|
||||
def convert(self, value: str, param: Optional[Parameter], ctx: Optional[Context]) -> datetime.datetime: ...
|
||||
|
||||
class FloatParamType(ParamType):
|
||||
def __call__(self, value: Optional[str], param: Optional[Parameter] = ..., ctx: Optional[Context] = ...) -> float: ...
|
||||
def convert(self, value: str, param: Optional[Parameter], ctx: Optional[Context]) -> float: ...
|
||||
|
||||
class FloatRange(FloatParamType):
|
||||
min: Optional[float]
|
||||
max: Optional[float]
|
||||
clamp: bool
|
||||
def __init__(self, min: Optional[float] = ..., max: Optional[float] = ..., clamp: bool = ...) -> None: ...
|
||||
|
||||
class File(ParamType):
|
||||
mode: str
|
||||
encoding: Optional[str]
|
||||
errors: Optional[str]
|
||||
lazy: Optional[bool]
|
||||
atomic: bool
|
||||
def __init__(
|
||||
self,
|
||||
mode: Text = ...,
|
||||
encoding: Optional[str] = ...,
|
||||
errors: Optional[str] = ...,
|
||||
lazy: Optional[bool] = ...,
|
||||
atomic: Optional[bool] = ...,
|
||||
) -> None: ...
|
||||
def __call__(self, value: Optional[str], param: Optional[Parameter] = ..., ctx: Optional[Context] = ...) -> IO[Any]: ...
|
||||
def convert(self, value: str, param: Optional[Parameter], ctx: Optional[Context]) -> IO[Any]: ...
|
||||
def resolve_lazy_flag(self, value: str) -> bool: ...
|
||||
|
||||
_F = TypeVar("_F") # result of the function
|
||||
_Func = Callable[[Optional[str]], _F]
|
||||
|
||||
class FuncParamType(ParamType, Generic[_F]):
|
||||
func: _Func[_F]
|
||||
def __init__(self, func: _Func[_F]) -> None: ...
|
||||
def __call__(self, value: Optional[str], param: Optional[Parameter] = ..., ctx: Optional[Context] = ...) -> _F: ...
|
||||
def convert(self, value: str, param: Optional[Parameter], ctx: Optional[Context]) -> _F: ...
|
||||
|
||||
class IntParamType(ParamType):
|
||||
def __call__(self, value: Optional[str], param: Optional[Parameter] = ..., ctx: Optional[Context] = ...) -> int: ...
|
||||
def convert(self, value: str, param: Optional[Parameter], ctx: Optional[Context]) -> int: ...
|
||||
|
||||
class IntRange(IntParamType):
|
||||
min: Optional[int]
|
||||
max: Optional[int]
|
||||
clamp: bool
|
||||
def __init__(self, min: Optional[int] = ..., max: Optional[int] = ..., clamp: bool = ...) -> None: ...
|
||||
|
||||
_PathType = TypeVar("_PathType", str, bytes)
|
||||
_PathTypeBound = Union[Type[str], Type[bytes]]
|
||||
|
||||
class Path(ParamType):
|
||||
exists: bool
|
||||
file_okay: bool
|
||||
dir_okay: bool
|
||||
writable: bool
|
||||
readable: bool
|
||||
resolve_path: bool
|
||||
allow_dash: bool
|
||||
type: Optional[_PathTypeBound]
|
||||
def __init__(
|
||||
self,
|
||||
exists: bool = ...,
|
||||
file_okay: bool = ...,
|
||||
dir_okay: bool = ...,
|
||||
writable: bool = ...,
|
||||
readable: bool = ...,
|
||||
resolve_path: bool = ...,
|
||||
allow_dash: bool = ...,
|
||||
path_type: Optional[Type[_PathType]] = ...,
|
||||
) -> None: ...
|
||||
def coerce_path_result(self, rv: Union[str, bytes]) -> _PathType: ...
|
||||
def __call__(self, value: Optional[str], param: Optional[Parameter] = ..., ctx: Optional[Context] = ...) -> _PathType: ...
|
||||
def convert(self, value: str, param: Optional[Parameter], ctx: Optional[Context]) -> _PathType: ...
|
||||
|
||||
class StringParamType(ParamType):
|
||||
def __call__(self, value: Optional[str], param: Optional[Parameter] = ..., ctx: Optional[Context] = ...) -> str: ...
|
||||
def convert(self, value: str, param: Optional[Parameter], ctx: Optional[Context]) -> str: ...
|
||||
|
||||
class Tuple(CompositeParamType):
|
||||
types: List[ParamType]
|
||||
def __init__(self, types: Iterable[Any]) -> None: ...
|
||||
def __call__(self, value: Optional[str], param: Optional[Parameter] = ..., ctx: Optional[Context] = ...) -> Tuple: ...
|
||||
def convert(self, value: str, param: Optional[Parameter], ctx: Optional[Context]) -> Tuple: ...
|
||||
|
||||
class UnprocessedParamType(ParamType): ...
|
||||
|
||||
class UUIDParameterType(ParamType):
|
||||
def __call__(self, value: Optional[str], param: Optional[Parameter] = ..., ctx: Optional[Context] = ...) -> uuid.UUID: ...
|
||||
def convert(self, value: str, param: Optional[Parameter], ctx: Optional[Context]) -> uuid.UUID: ...
|
||||
|
||||
def convert_type(ty: Optional[_ConvertibleType], default: Optional[Any] = ...) -> ParamType: ...
|
||||
|
||||
# parameter type shortcuts
|
||||
|
||||
BOOL: BoolParamType
|
||||
FLOAT: FloatParamType
|
||||
INT: IntParamType
|
||||
STRING: StringParamType
|
||||
UNPROCESSED: UnprocessedParamType
|
||||
UUID: UUIDParameterType
|
||||
43
stubs/click/click/utils.pyi
Normal file
43
stubs/click/click/utils.pyi
Normal file
@@ -0,0 +1,43 @@
|
||||
from typing import IO, Any, AnyStr, Generic, Iterator, List, Optional, Text, TypeVar
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
def _posixify(name: str) -> str: ...
|
||||
def safecall(func: _T) -> _T: ...
|
||||
def make_str(value: Any) -> str: ...
|
||||
def make_default_short_help(help: str, max_length: int = ...): ...
|
||||
|
||||
class LazyFile(object):
|
||||
name: str
|
||||
mode: str
|
||||
encoding: Optional[str]
|
||||
errors: str
|
||||
atomic: bool
|
||||
def __init__(
|
||||
self, filename: str, mode: str = ..., encoding: Optional[str] = ..., errors: str = ..., atomic: bool = ...
|
||||
) -> None: ...
|
||||
def open(self) -> IO[Any]: ...
|
||||
def close(self) -> None: ...
|
||||
def close_intelligently(self) -> None: ...
|
||||
def __enter__(self) -> LazyFile: ...
|
||||
def __exit__(self, exc_type, exc_value, tb): ...
|
||||
def __iter__(self) -> Iterator[Any]: ...
|
||||
|
||||
class KeepOpenFile(Generic[AnyStr]):
|
||||
_file: IO[AnyStr]
|
||||
def __init__(self, file: IO[AnyStr]) -> None: ...
|
||||
def __enter__(self) -> KeepOpenFile[AnyStr]: ...
|
||||
def __exit__(self, exc_type, exc_value, tb): ...
|
||||
def __iter__(self) -> Iterator[AnyStr]: ...
|
||||
|
||||
def echo(
|
||||
message: object = ..., file: Optional[IO[Text]] = ..., nl: bool = ..., err: bool = ..., color: Optional[bool] = ...
|
||||
) -> None: ...
|
||||
def get_binary_stream(name: str) -> IO[bytes]: ...
|
||||
def get_text_stream(name: str, encoding: Optional[str] = ..., errors: str = ...) -> IO[str]: ...
|
||||
def open_file(
|
||||
filename: str, mode: str = ..., encoding: Optional[str] = ..., errors: str = ..., lazy: bool = ..., atomic: bool = ...
|
||||
) -> Any: ... # really Union[IO, LazyFile, KeepOpenFile]
|
||||
def get_os_args() -> List[str]: ...
|
||||
def format_filename(filename: str, shorten: bool = ...) -> str: ...
|
||||
def get_app_dir(app_name: str, roaming: bool = ..., force_posix: bool = ...) -> str: ...
|
||||
Reference in New Issue
Block a user