diff --git a/third_party/3.6/click/README.md b/third_party/3.6/click/README.md new file mode 100644 index 000000000..d7410e3fc --- /dev/null +++ b/third_party/3.6/click/README.md @@ -0,0 +1,11 @@ +# click 6.6, Python 3 + +`__init__.pyi` is literally a copy of click/__init__.py. It's a shortcut module +anyway in the actual sources so it works well without additional 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. diff --git a/third_party/3.6/click/__init__.pyi b/third_party/3.6/click/__init__.pyi new file mode 100644 index 000000000..3a7e3ee76 --- /dev/null +++ b/third_party/3.6/click/__init__.pyi @@ -0,0 +1,98 @@ +# -*- coding: utf-8 -*- +""" + click + ~~~~~ + + Click is a simple Python module that wraps the stdlib's optparse to make + writing command line scripts fun. Unlike other modules, it's based around + a simple API that does not come with too much magic and is composable. + + In case optparse ever gets removed from the stdlib, it will be shipped by + this module. + + :copyright: (c) 2014 by Armin Ronacher. + :license: BSD, see LICENSE for more details. +""" + +# Core classes +from .core import Context, BaseCommand, Command, MultiCommand, Group, \ + CommandCollection, Parameter, Option, Argument + +# Globals +from .globals import get_current_context + +# Decorators +from .decorators import pass_context, pass_obj, make_pass_decorator, \ + command, group, argument, option, confirmation_option, \ + password_option, version_option, help_option + +# Types +from .types import ParamType, File, Path, Choice, IntRange, Tuple, \ + STRING, INT, FLOAT, BOOL, UUID, UNPROCESSED + +# Utilities +from .utils import echo, get_binary_stream, get_text_stream, open_file, \ + format_filename, get_app_dir, get_os_args + +# Terminal functions +from .termui import prompt, confirm, get_terminal_size, echo_via_pager, \ + progressbar, clear, style, unstyle, secho, edit, launch, getchar, \ + pause + +# Exceptions +from .exceptions import ClickException, UsageError, BadParameter, \ + FileError, Abort, NoSuchOption, BadOptionUsage, BadArgumentUsage, \ + MissingParameter + +# Formatting +from .formatting import HelpFormatter, wrap_text + +# Parsing +from .parser import OptionParser + + +__all__ = [ + # Core classes + 'Context', 'BaseCommand', 'Command', 'MultiCommand', 'Group', + 'CommandCollection', 'Parameter', 'Option', 'Argument', + + # Globals + 'get_current_context', + + # Decorators + 'pass_context', 'pass_obj', 'make_pass_decorator', 'command', 'group', + 'argument', 'option', 'confirmation_option', 'password_option', + 'version_option', 'help_option', + + # Types + 'ParamType', 'File', 'Path', 'Choice', 'IntRange', 'Tuple', 'STRING', + 'INT', 'FLOAT', 'BOOL', 'UUID', 'UNPROCESSED', + + # Utilities + 'echo', 'get_binary_stream', 'get_text_stream', 'open_file', + 'format_filename', 'get_app_dir', 'get_os_args', + + # Terminal functions + 'prompt', 'confirm', 'get_terminal_size', 'echo_via_pager', + 'progressbar', 'clear', 'style', 'unstyle', 'secho', 'edit', 'launch', + 'getchar', 'pause', + + # Exceptions + 'ClickException', 'UsageError', 'BadParameter', 'FileError', + 'Abort', 'NoSuchOption', 'BadOptionUsage', 'BadArgumentUsage', + 'MissingParameter', + + # Formatting + 'HelpFormatter', 'wrap_text', + + # Parsing + 'OptionParser', +] + + +# Controls if click should emit the warning about the use of unicode +# literals. +disable_unicode_literals_warning = False + + +__version__ = '6.6' diff --git a/third_party/3.6/click/core.pyi b/third_party/3.6/click/core.pyi new file mode 100644 index 000000000..66b5b840c --- /dev/null +++ b/third_party/3.6/click/core.pyi @@ -0,0 +1,434 @@ +from contextlib import contextmanager +from typing import ( + Any, + Callable, + Dict, + Generator, + Iterable, + List, + Mapping, + Optional, + Sequence, + Tuple, + TypeVar, + Union, +) + +from click.formatting import HelpFormatter +from click.parser import OptionParser + + +def invoke_param_callback( + callback: Callable[['Context', 'Parameter', Optional[str]], Any], + ctx: 'Context', + param: 'Parameter', + value: Optional[str] +) -> Any: + ... + + +@contextmanager +def augment_usage_errors( + ctx: 'Context', param: 'Parameter' = None +) -> Generator[None, None, 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 + args: List[str] + protected_args: List[str] + obj: Any + default_map: 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 + _depth: int + + # properties + meta: Dict[str, Any] + command_path: str + + def __init__( + self, + command: 'Command', + parent: 'Context' = None, + info_name: str = None, + obj: Any = None, + auto_envvar_prefix: str = None, + default_map: Mapping[str, Any] = None, + terminal_width: int = None, + max_content_width: int = None, + resilient_parsing: bool = False, + allow_extra_args: bool = None, + allow_interspersed_args: bool = None, + ignore_unknown_options: bool = None, + help_option_names: List[str] = None, + token_normalize_func: Callable[[str], str] = None, + color: bool = None + ) -> None: + ... + + @contextmanager + def scope(self, cleanup: bool = True) -> Generator['Context', None, None]: + ... + + def make_formatter(self) -> HelpFormatter: + ... + + def call_on_close(self, f: Callable) -> Callable: + ... + + 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) -> None: + ... + + def abort(self) -> None: + ... + + def exit(self, code: Union[int, str] = 0) -> None: + ... + + def get_usage(self) -> str: + ... + + def get_help(self) -> str: + ... + + def invoke( + self, callback: Union['Command', Callable], *args, **kwargs + ) -> Any: + ... + + def forward( + self, callback: Union['Command', Callable], *args, **kwargs + ) -> Any: + ... + +class BaseCommand: + allow_extra_args: bool + allow_interspersed_args: bool + ignore_unknown_options: bool + name: str + context_settings: Dict + + def __init__(self, name: str, context_settings: Dict = None) -> 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: Context = None, **extra + ) -> Context: + ... + + def parse_args(self, ctx: Context, args: List[str]) -> List[str]: + ... + + def invoke(self, ctx: Context) -> Any: + ... + + def main( + self, + args: List[str] = None, + prog_name: str = None, + complete_var: str = None, + standalone_mode: bool = True, + **extra + ) -> Any: + ... + + def __call__(self, *args, **kwargs) -> Any: + ... + + +class Command(BaseCommand): + callback: Optional[Callable] + params: List['Parameter'] + help: Optional[str] + epilog: Optional[str] + short_help: Optional[str] + options_metavar: str + add_help_option: bool + + def __init__( + self, + name: str, + context_settings: Dict = None, + callback: Callable = None, + params: List['Parameter'] = None, + help: str = None, + epilog: str = None, + short_help: str = None, + options_metavar: str = '[OPTIONS]', + add_help_option: bool = True + ) -> 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 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') +Decorator = Callable[[T], T] + + +class MultiCommand(Command): + no_args_is_help: bool + invoke_without_command: bool + subcommand_metavar: str + chain: bool + result_callback: Callable + + def __init__( + self, + name: str = None, + invoke_without_command: bool = False, + no_args_is_help: bool = None, + subcommand_metavar: str = None, + chain: bool = False, + result_callback: Callable = None, + **attrs + ) -> None: + ... + + def resultcallback( + self, replace: bool = False + ) -> Decorator: + ... + + 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[Command]: + ... + + +class Group(MultiCommand): + commands: Dict[str, Command] + + def __init__( + self, name: str = None, commands: Dict[str, Command] = None, **attrs + ) -> None: + ... + + def add_command(self, cmd: Command, name: str = None): + ... + + def command(self, *args, **kwargs) -> Decorator: + ... + + def group(self, *args, **kwargs) -> Decorator: + ... + + +class CommandCollection(MultiCommand): + sources: List[MultiCommand] + + def __init__( + self, name: str = None, sources: List[MultiCommand] = None, **attrs + ) -> None: + ... + + def add_source(self, multi_cmd: MultiCommand) -> None: + ... + + +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] + # properties + human_readable_name: str + + def __init__( + self, + param_decls: List[str] = None, + type: Union[type, 'ParamType'] = None, + required: bool = False, + default: Any = None, + callback: Callable[[Context, 'Parameter', str], Any] = None, + nargs: int = None, + metavar: str = None, + expose_value: bool = True, + is_eager: bool = False, + envvar: Union[str, List[str]] = None + ) -> None: + ... + + 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]: + ... + + +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] + show_default: bool + + def __init__( + self, + param_decls: List[str] = None, + show_default: bool = False, + prompt: Union[bool, str] = False, + confirmation_prompt: bool = False, + hide_input: bool = False, + is_flag: bool = None, + flag_value: Any = None, + multiple: bool = False, + count: bool = False, + allow_from_autoenv: bool = True, + type: Union[type, 'ParamType'] = None, + help: str = None, + **attrs + ) -> None: + ... + + def prompt_for_value(self, ctx: Context) -> Any: + ... + + +class Argument(Parameter): + def __init__( + self, + param_decls: List[str] = None, + required: bool = None, + **attrs + ) -> None: + ... + + +from click.types import ParamType # cyclic dependency diff --git a/third_party/3.6/click/decorators.pyi b/third_party/3.6/click/decorators.pyi new file mode 100644 index 000000000..ded17df6a --- /dev/null +++ b/third_party/3.6/click/decorators.pyi @@ -0,0 +1,218 @@ +from typing import Any, Callable, TypeVar, Union + +from click.core import Command, Group, Argument, Option, Parameter, Context +from click.types import ParamType + +T = TypeVar('T') +Decorator = Callable[[T], T] + + +def pass_context(T) -> T: + ... + + +def pass_obj(T) -> T: + ... + + +def make_pass_decorator( + object_type: type, ensure: bool = False +) -> Callable[[T], T]: + ... + + +# NOTE: Decorators below have **attrs converted to concrete constructor +# arguments from core.pyi to help with type checking. + +def command( + name: str = None, + cls: type = Command, + # Command + help: str = None, + epilog: str = None, + short_help: str = None, + options_metavar: str = '[OPTIONS]', + add_help_option: bool = True, +) -> Decorator: + ... + + +# This inherits attrs from Group, MultiCommand and Command. + +def group( + name: str = None, + cls: type = Group, + # Group + commands: Dict[str, Command] = None, + # MultiCommand + invoke_without_command: bool = False, + no_args_is_help: bool = None, + subcommand_metavar: str = None, + chain: bool = False, + result_callback: Callable = None, + # Command + help: str = None, + epilog: str = None, + short_help: str = None, + options_metavar: str = '[OPTIONS]', + add_help_option: bool = True, +) -> Decorator: + ... + + +def argument( + *param_decls: str, + cls: type = Argument, + # Argument + required: bool = None, + # Parameter + type: Union[type, ParamType] = None, + default: Any = None, + callback: Callable[[Context, Parameter, str], Any] = None, + nargs: int = None, + metavar: str = None, + expose_value: bool = True, + is_eager: bool = False, + envvar: Union[str, List[str]] = None +) -> Decorator: + ... + + +def option( + *param_decls: str, + cls: type = Option, + # Option + show_default: bool = False, + prompt: bool = False, + confirmation_prompt: bool = False, + hide_input: bool = False, + is_flag: bool = None, + flag_value: Any = None, + multiple: bool = False, + count: bool = False, + allow_from_autoenv: bool = True, + type: Union[type, ParamType] = None, + help: str = None, + # Parameter + default: Any = None, + callback: Callable[[Context, Parameter, str], Any] = None, + nargs: int = None, + metavar: str = None, + expose_value: bool = True, + is_eager: bool = False, + envvar: Union[str, List[str]] = None +) -> Decorator: + ... + + +# Defaults copied from the decorator body. +def confirmation_option( + *param_decls: str, + cls: type = Option, + # Option + show_default: bool = False, + prompt: str = 'Do you want to continue?', + confirmation_prompt: bool = False, + hide_input: bool = False, + is_flag: bool = True, + flag_value: Any = None, + multiple: bool = False, + count: bool = False, + allow_from_autoenv: bool = True, + type: Union[type, ParamType] = None, + help: str = 'Confirm the action without prompting.', + # Parameter + default: Any = None, + callback: Callable[[Context, Parameter, str], Any] = None, + nargs: int = None, + metavar: str = None, + expose_value: bool = False, + is_eager: bool = False, + envvar: Union[str, List[str]] = None +) -> Decorator: + ... + + +# Defaults copied from the decorator body. +def password_option( + *param_decls: str, + cls: type = Option, + # Option + show_default: bool = False, + prompt: bool = True, + confirmation_prompt: bool = True, + hide_input: bool = True, + is_flag: bool = None, + flag_value: Any = None, + multiple: bool = False, + count: bool = False, + allow_from_autoenv: bool = True, + type: Union[type, ParamType] = None, + help: str = None, + # Parameter + default: Any = None, + callback: Callable[[Context, Parameter, str], Any] = None, + nargs: int = None, + metavar: str = None, + expose_value: bool = True, + is_eager: bool = False, + envvar: Union[str, List[str]] = None +) -> Decorator: + ... + + +# Defaults copied from the decorator body. +def version_option( + version: str = None, + *param_decls: str, + cls: type = Option, + # Option + show_default: bool = False, + prompt: bool = False, + confirmation_prompt: bool = False, + hide_input: bool = False, + is_flag: bool = True, + flag_value: Any = None, + multiple: bool = False, + count: bool = False, + allow_from_autoenv: bool = True, + type: Union[type, ParamType] = None, + help: str = 'Show the version and exit.', + # Parameter + default: Any = None, + callback: Callable[[Context, Parameter, str], Any] = None, + nargs: int = None, + metavar: str = None, + expose_value: bool = False, + is_eager: bool = True, + envvar: Union[str, List[str]] = None +) -> Decorator: + ... + + +# Defaults copied from the decorator body. +def help_option( + *param_decls: str, + cls: type = Option, + # Option + show_default: bool = False, + prompt: bool = False, + confirmation_prompt: bool = False, + hide_input: bool = False, + is_flag: bool = True, + flag_value: Any = None, + multiple: bool = False, + count: bool = False, + allow_from_autoenv: bool = True, + type: Union[type, ParamType] = None, + help: str = 'Show this message and exit.', + # Parameter + default: Any = None, + callback: Callable[[Context, Parameter, str], Any] = None, + nargs: int = None, + metavar: str = None, + expose_value: bool = False, + is_eager: bool = True, + envvar: Union[str, List[str]] = None +) -> Decorator: + ... diff --git a/third_party/3.6/click/exceptions.pyi b/third_party/3.6/click/exceptions.pyi new file mode 100644 index 000000000..7d49ae69f --- /dev/null +++ b/third_party/3.6/click/exceptions.pyi @@ -0,0 +1,91 @@ +from typing import IO, 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=None) -> None: + ... + + +class UsageError(ClickException): + ctx: Optional[Context] + + def __init__(self, message: str, ctx: Context = None) -> None: + ... + + def show(self, file: IO = None) -> None: + ... + + +class BadParameter(UsageError): + param: Optional[Parameter] + param_hint: Optional[str] + + def __init__( + self, + message: str, + ctx: Context = None, + param: Parameter = None, + param_hint: str = None + ) -> None: + ... + + +class MissingParameter(BadParameter): + param_type: str # valid values: 'parameter', 'option', 'argument' + + def __init__( + self, + message: str = None, + ctx: Context = None, + param: Parameter = None, + param_hint: str = None, + param_type: str = None + ) -> None: + ... + + +class NoSuchOption(UsageError): + option_name: str + possibilities: Optional[List[str]] + + def __init__( + self, + option_name: str, + message: str = None, + possibilities: List[str] = None, + ctx: Context = None + ) -> None: + ... + + +class BadOptionUsage(UsageError): + def __init__(self, message: str, ctx: Context = None) -> None: + ... + + +class BadArgumentUsage(UsageError): + def __init__(self, message: str, ctx: Context = None) -> None: + ... + + +class FileError(ClickException): + ui_filename: str + filename: str + + def __init__(self, filename: str, hint: str = None) -> None: + ... + + +class Abort(RuntimeError): + ... diff --git a/third_party/3.6/click/formatting.pyi b/third_party/3.6/click/formatting.pyi new file mode 100644 index 000000000..57920abe5 --- /dev/null +++ b/third_party/3.6/click/formatting.pyi @@ -0,0 +1,89 @@ +from contextlib import contextmanager +from typing import Generator, Iterable, 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 = 78, + initial_indent: str = '', + subsequent_indent: str = '', + preserve_paragraphs = False +) -> str: + ... + + +class HelpFormatter: + indent_increment: int + width: Optional[int] + current_indent: int + buffer: List[str] + + def __init__( + self, + indent_increment: int = 2, + width: int = None, + max_width: int = None, + ) -> 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 = 'Usage: ', + ): + ... + + 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 = 30, + col_spacing: int = 2, + ) -> None: + ... + + @contextmanager + def section(self, name) -> Generator[None, None, None]: + ... + + @contextmanager + def indentation(self) -> Generator[None, None, None]: + ... + + def getvalue(self) -> str: + ... + + +def join_options(options: List[str]) -> Tuple[str, bool]: + ... diff --git a/third_party/3.6/click/globals.pyi b/third_party/3.6/click/globals.pyi new file mode 100644 index 000000000..934ca7d20 --- /dev/null +++ b/third_party/3.6/click/globals.pyi @@ -0,0 +1,17 @@ +from click.core import Optional, Context + + +def get_current_context(silent: bool = False) -> Context: + ... + + +def push_context(ctx: Context) -> None: + ... + + +def pop_context() -> None: + ... + + +def resolve_color_default(color: bool = None) -> Optional[bool]: + ... diff --git a/third_party/3.6/click/parser.pyi b/third_party/3.6/click/parser.pyi new file mode 100644 index 000000000..879060979 --- /dev/null +++ b/third_party/3.6/click/parser.pyi @@ -0,0 +1,102 @@ +from typing import Any, Iterable, List, Optional, 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] + # properties + takes_value: bool + + def __init__( + self, + opts: Iterable[str], + dest: str, + action: str = None, + nargs: int = 1, + const: Any = None, + obj: Any = None + ) -> None: + ... + + def process(self, value: Any, state: 'ParsingState') -> None: + ... + + +class Argument: + dest: str + nargs: int + obj: Any + + def __init__(self, dest: str, nargs: int = 1, obj: Any = None) -> 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: Context = None) -> None: + ... + + def add_option( + self, + opts: Iterable[str], + dest: str, + action: str = None, + nargs: int = 1, + const: Any = None, + obj: Any = None + ) -> None: + ... + + def add_argument(self, dest: str, nargs: int = 1, obj: Any = None) -> None: + ... + + def parse_args( + self, args: List[str] + ) -> Tuple[Dict[str, Any], List[str], List[Any]]: + ... diff --git a/third_party/3.6/click/termui.pyi b/third_party/3.6/click/termui.pyi new file mode 100644 index 000000000..33ea7f497 --- /dev/null +++ b/third_party/3.6/click/termui.pyi @@ -0,0 +1,147 @@ +from contextlib import contextmanager +from typing import ( + Any, + Callable, + Generator, + Iterable, + IO, + List, + Optional, + Tuple, + TypeVar, +) + + +def hidden_prompt_func(prompt: str) -> str: + ... + + +def _build_prompt( + text: str, + suffix: str, + show_default: bool = False, + default: str = None, +) -> str: + ... + + +def prompt( + text: str, + default: str = None, + hide_input: bool = False, + confirmation_prompt: bool = False, + type: Any = None, + value_proc: Callable[[Optional[str]], Any] = None, + prompt_suffix: str = ': ', + show_default: bool = True, + err: bool = False, +) -> Any: + ... + + +def confirm( + text: str, + default: bool = False, + abort: bool = False, + prompt_suffix: str = ': ', + show_default: bool = True, + err: bool = False, +) -> bool: + ... + + +def get_terminal_size() -> Tuple[int, int]: + ... + + +def echo_via_pager(text: str, color: bool = None) -> None: + ... + + +T = TypeVar('T') + + +@contextmanager +def progressbar( + iterable=Iterable[T], + length: int = None, + label: str = None, + show_eta: bool = True, + show_percent: bool = None, + show_pos: bool = False, + item_show_func: Callable[[T], str] = None, + fill_char: str = '#', + empty_char: str = '-', + bar_template: str = '%(label)s [%(bar)s] %(info)s', + info_sep: str = ' ', + width: int = 36, + file: IO = None, + color: bool = None, +) -> Generator[T, None, None]: + ... + + +def clear() -> None: + ... + + +def style( + text: str, + fg: str = None, + bg: str = None, + bold: bool = None, + dim: bool = None, + underline: bool = None, + blink: bool = None, + reverse: bool = None, + reset: bool = True, +): + ... + + +def unstyle(text: str) -> str: + ... + + +# Styling options copied from style() for nicer type checking. +def secho( + text: str, + file: IO = None, + nl: bool =True, + err: bool = False, + color: bool = None, + fg: str = None, + bg: str = None, + bold: bool = None, + dim: bool = None, + underline: bool = None, + blink: bool = None, + reverse: bool = None, + reset: bool = True, +): + ... + + +def edit( + text: str = None, + editor: str = None, + env: str = None, + require_save: bool = True, + extension: str = '.txt', + filename: str = None, +) -> str: + ... + + +def launch(url: str, wait: bool = False, locate: bool = False) -> int: + ... + + +def getchar(echo: bool = False) -> str: + ... + + +def pause( + info: str ='Press any key to continue ...', err: bool = False +) -> None: + ... diff --git a/third_party/3.6/click/types.pyi b/third_party/3.6/click/types.pyi new file mode 100644 index 000000000..c56b4f0c2 --- /dev/null +++ b/third_party/3.6/click/types.pyi @@ -0,0 +1,283 @@ +from typing import Any, Callable, IO, Iterable, Optional, TypeVar, Union +import uuid + +from click.core import Context, Parameter + + +class ParamType: + name: str + is_composite: bool + envvar_list_splitter: Optional[str] + + def __call__( + self, + value: Optional[str], + param: Parameter = None, + ctx: Context = None, + ) -> 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 = None, ctx: Context = None) -> None: + ... + + +class BoolParamType(ParamType): + def __call__( + self, + value: Optional[str], + param: Parameter = None, + ctx: Context = None, + ) -> bool: + ... + + def convert( + self, + value: str, + param: Optional[Parameter], + ctx: Optional[Context], + ) -> bool: + ... + + +class CompositeParamType(ParamType): + arity: int + + +class Choice(ParamType): + choices: Iterable[str] + def __init__(self, choices: Iterable[str]) -> None: + ... + + +class FloatParamType(ParamType): + def __call__( + self, + value: Optional[str], + param: Parameter = None, + ctx: Context = None, + ) -> float: + ... + + def convert( + self, + value: str, + param: Optional[Parameter], + ctx: Optional[Context], + ) -> float: + ... + + +class FloatRange(FloatParamType): + ... + + +class File(ParamType): + def __init__( + self, + mode: str = 'r', + encoding: str = None, + errors: str = None, + lazy: bool = None, + atomic: bool = None, + ) -> None: + ... + + def __call__( + self, + value: Optional[str], + param: Parameter = None, + ctx: Context = None, + ) -> IO: + ... + + def convert( + self, + value: str, + param: Optional[Parameter], + ctx: Optional[Context], + ) -> IO: + ... + + def resolve_lazy_flag(self, value: str) -> bool: + ... + + +F = TypeVar('F') # result of the function +Func = Callable[[Optional[str]], F] + + +class FuncParamType(ParamType): + func: Func + + def __init__(self, func: Func) -> None: + ... + + def __call__( + self, + value: Optional[str], + param: Parameter = None, + ctx: Context = None, + ) -> F: + ... + + def convert( + self, + value: str, + param: Optional[Parameter], + ctx: Optional[Context], + ) -> F: + ... + + +class IntParamType(ParamType): + def __call__( + self, + value: Optional[str], + param: Parameter = None, + ctx: Context = None, + ) -> int: + ... + + def convert( + self, + value: str, + param: Optional[Parameter], + ctx: Optional[Context], + ) -> int: + ... + + +class IntRange(IntParamType): + def __init__( + self, min: int = None, max: int = None, clamp: bool = False + ) -> None: + ... + + +PathType = TypeVar('PathType', str, bytes) + + +class Path(ParamType): + def __init__( + self, + exists: bool = False, + file_okay: bool = True, + dir_okay: bool = True, + writable: bool = False, + readable: bool = True, + resolve_path: bool = False, + allow_dash: bool = False, + path_type: PathType = None, + ) -> None: + ... + + def coerce_path_result(self, rv: Union[str, bytes]) -> PathType: + ... + + def __call__( + self, + value: Optional[str], + param: Parameter = None, + ctx: Context = None, + ) -> PathType: + ... + + def convert( + self, + value: str, + param: Optional[Parameter], + ctx: Optional[Context], + ) -> PathType: + ... + +class StringParamType(ParamType): + def __call__( + self, + value: Optional[str], + param: Parameter = None, + ctx: Context = None, + ) -> 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: Parameter = None, + ctx: Context = None, + ) -> 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: Parameter = None, + ctx: Context = None, + ) -> uuid.UUID: + ... + + def convert( + self, + value: str, + param: Optional[Parameter], + ctx: Optional[Context], + ) -> uuid.UUID: + ... + + +def convert_type(ty: Any, default: Any = None) -> ParamType: + ... + +# parameter type shortcuts + +BOOL = BoolParamType() +FLOAT = FloatParamType() +INT = IntParamType() +STRING = StringParamType() +UNPROCESSED = UnprocessedParamType() +UUID = UUIDParameterType() diff --git a/third_party/3.6/click/utils.pyi b/third_party/3.6/click/utils.pyi new file mode 100644 index 000000000..362a46162 --- /dev/null +++ b/third_party/3.6/click/utils.pyi @@ -0,0 +1,119 @@ +from typing import Any, Callable, Iterator, IO, Optional, TypeVar, Union + + +T = TypeVar('T') +Decorator = Callable[[T], 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 = 45): + ... + + +class LazyFile: + name: str + mode: str + encoding: Optional[str] + errors: str + atomic: bool + + def __init__( + self, + filename: str, + mode: str = 'r', + encoding: str = None, + errors: str = 'strict', + atomic: bool = False + ) -> None: + ... + + def open(self) -> IO: + ... + + 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: + ... + + + +class KeepOpenFile(object): + _file: IO + + def __init__(self, file: IO) -> None: + ... + + def __enter__(self) -> 'KeepOpenFile': + ... + + def __exit__(self, exc_type, exc_value, tb): + ... + + def __iter__(self) -> Iterator: + ... + + +def echo( + message: str = None, + file: IO = None, + nl: bool = True, + err: bool = False, + color: bool = None, +) -> None: + ... + + +def get_binary_stream(name: str) -> IO[bytes]: + ... + + +def get_text_stream( + name: str, encoding: str = None, errors: str = 'strict' +) -> IO[str]: + ... + + +def open_file( + filename: str, + mode: str = 'r', + encoding: str = None, + errors: str = 'strict', + lazy: bool = False, + atomic: bool = False +) -> Union[IO, LazyFile, KeepOpenFile]: + ... + + +def get_os_args() -> List[str]: + ... + + +def format_filename(filename: str, shorten: bool = False) -> str: + ... + + +def get_app_dir( + app_name: str, roaming: bool = True, force_posix: bool = False +) -> str: + ...