Big diff: Use new "|" union syntax (#5872)

This commit is contained in:
Akuli
2021-08-08 12:05:21 +03:00
committed by GitHub
parent b9adb7a874
commit ee487304d7
578 changed files with 8080 additions and 8966 deletions

View File

@@ -1,5 +1,5 @@
from types import TracebackType
from typing import Generic, Optional, Type, TypeVar
from typing import Generic, Type, TypeVar
_T = TypeVar("_T")
@@ -8,10 +8,10 @@ class ProgressBar(Generic[_T]):
def finish(self) -> None: ...
def __enter__(self) -> ProgressBar[_T]: ...
def __exit__(
self, exctype: Optional[Type[BaseException]], excinst: Optional[BaseException], exctb: Optional[TracebackType]
self, exctype: Type[BaseException] | None, excinst: BaseException | None, exctb: TracebackType | None
) -> None: ...
def __iter__(self) -> ProgressBar[_T]: ...
def next(self) -> _T: ...
def __next__(self) -> _T: ...
length: Optional[int]
length: int | None
label: str

View File

@@ -1,6 +1,6 @@
from _typeshed import IdentityFunction
from distutils.version import Version
from typing import Any, Callable, Dict, Iterable, List, Optional, Text, Tuple, Type, TypeVar, Union, overload
from typing import Any, Callable, Dict, Iterable, List, Text, Tuple, Type, TypeVar, Union, overload
from click.core import Argument, Command, Context, Group, Option, Parameter, _ConvertibleType
@@ -17,13 +17,13 @@ def make_pass_decorator(object_type: type, ensure: bool = ...) -> IdentityFuncti
# arguments from core.pyi to help with type checking.
def command(
name: Optional[str] = ...,
cls: Optional[Type[Command]] = ...,
name: str | None = ...,
cls: Type[Command] | None = ...,
# Command
context_settings: Optional[Dict[Any, Any]] = ...,
help: Optional[str] = ...,
epilog: Optional[str] = ...,
short_help: Optional[str] = ...,
context_settings: Dict[Any, Any] | None = ...,
help: str | None = ...,
epilog: str | None = ...,
short_help: str | None = ...,
options_metavar: str = ...,
add_help_option: bool = ...,
no_args_is_help: bool = ...,
@@ -34,20 +34,20 @@ def command(
# This inherits attrs from Group, MultiCommand and Command.
def group(
name: Optional[str] = ...,
name: str | None = ...,
cls: Type[Command] = ...,
# Group
commands: Optional[Dict[str, Command]] = ...,
commands: Dict[str, Command] | None = ...,
# MultiCommand
invoke_without_command: bool = ...,
no_args_is_help: Optional[bool] = ...,
subcommand_metavar: Optional[str] = ...,
no_args_is_help: bool | None = ...,
subcommand_metavar: str | None = ...,
chain: bool = ...,
result_callback: Optional[Callable[..., Any]] = ...,
result_callback: Callable[..., Any] | None = ...,
# Command
help: Optional[str] = ...,
epilog: Optional[str] = ...,
short_help: Optional[str] = ...,
help: str | None = ...,
epilog: str | None = ...,
short_help: str | None = ...,
options_metavar: str = ...,
add_help_option: bool = ...,
hidden: bool = ...,
@@ -59,44 +59,44 @@ def argument(
*param_decls: Text,
cls: Type[Argument] = ...,
# Argument
required: Optional[bool] = ...,
required: bool | None = ...,
# Parameter
type: Optional[_ConvertibleType] = ...,
default: Optional[Any] = ...,
callback: Optional[_Callback] = ...,
nargs: Optional[int] = ...,
metavar: Optional[str] = ...,
type: _ConvertibleType | None = ...,
default: Any | None = ...,
callback: _Callback | None = ...,
nargs: int | None = ...,
metavar: str | None = ...,
expose_value: bool = ...,
is_eager: bool = ...,
envvar: Optional[Union[str, List[str]]] = ...,
autocompletion: Optional[Callable[[Context, List[str], str], Iterable[Union[str, Tuple[str, str]]]]] = ...,
envvar: str | List[str] | None = ...,
autocompletion: Callable[[Context, List[str], str], Iterable[str | Tuple[str, str]]] | None = ...,
) -> IdentityFunction: ...
@overload
def option(
*param_decls: Text,
cls: Type[Option] = ...,
# Option
show_default: Union[bool, Text] = ...,
prompt: Union[bool, Text] = ...,
show_default: bool | Text = ...,
prompt: bool | Text = ...,
confirmation_prompt: bool = ...,
hide_input: bool = ...,
is_flag: Optional[bool] = ...,
flag_value: Optional[Any] = ...,
is_flag: bool | None = ...,
flag_value: Any | None = ...,
multiple: bool = ...,
count: bool = ...,
allow_from_autoenv: bool = ...,
type: Optional[_ConvertibleType] = ...,
help: Optional[Text] = ...,
type: _ConvertibleType | None = ...,
help: Text | None = ...,
show_choices: bool = ...,
# Parameter
default: Optional[Any] = ...,
default: Any | None = ...,
required: bool = ...,
callback: Optional[_Callback] = ...,
nargs: Optional[int] = ...,
metavar: Optional[str] = ...,
callback: _Callback | None = ...,
nargs: int | None = ...,
metavar: str | None = ...,
expose_value: bool = ...,
is_eager: bool = ...,
envvar: Optional[Union[str, List[str]]] = ...,
envvar: str | List[str] | None = ...,
# User-defined
**kwargs: Any,
) -> IdentityFunction: ...
@@ -105,27 +105,27 @@ def option(
*param_decls: str,
cls: Type[Option] = ...,
# Option
show_default: Union[bool, Text] = ...,
prompt: Union[bool, Text] = ...,
show_default: bool | Text = ...,
prompt: bool | Text = ...,
confirmation_prompt: bool = ...,
hide_input: bool = ...,
is_flag: Optional[bool] = ...,
flag_value: Optional[Any] = ...,
is_flag: bool | None = ...,
flag_value: Any | None = ...,
multiple: bool = ...,
count: bool = ...,
allow_from_autoenv: bool = ...,
type: _T = ...,
help: Optional[str] = ...,
help: str | None = ...,
show_choices: bool = ...,
# Parameter
default: Optional[Any] = ...,
default: Any | None = ...,
required: bool = ...,
callback: Optional[Callable[[Context, Union[Option, Parameter], Union[bool, int, str]], _T]] = ...,
nargs: Optional[int] = ...,
metavar: Optional[str] = ...,
callback: Callable[[Context, Option | Parameter, bool | int | str], _T] | None = ...,
nargs: int | None = ...,
metavar: str | None = ...,
expose_value: bool = ...,
is_eager: bool = ...,
envvar: Optional[Union[str, List[str]]] = ...,
envvar: str | List[str] | None = ...,
# User-defined
**kwargs: Any,
) -> IdentityFunction: ...
@@ -134,27 +134,27 @@ def option(
*param_decls: str,
cls: Type[Option] = ...,
# Option
show_default: Union[bool, Text] = ...,
prompt: Union[bool, Text] = ...,
show_default: bool | Text = ...,
prompt: bool | Text = ...,
confirmation_prompt: bool = ...,
hide_input: bool = ...,
is_flag: Optional[bool] = ...,
flag_value: Optional[Any] = ...,
is_flag: bool | None = ...,
flag_value: Any | None = ...,
multiple: bool = ...,
count: bool = ...,
allow_from_autoenv: bool = ...,
type: Type[str] = ...,
help: Optional[str] = ...,
help: str | None = ...,
show_choices: bool = ...,
# Parameter
default: Optional[Any] = ...,
default: Any | None = ...,
required: bool = ...,
callback: Callable[[Context, Union[Option, Parameter], str], Any] = ...,
nargs: Optional[int] = ...,
metavar: Optional[str] = ...,
callback: Callable[[Context, Option | Parameter, str], Any] = ...,
nargs: int | None = ...,
metavar: str | None = ...,
expose_value: bool = ...,
is_eager: bool = ...,
envvar: Optional[Union[str, List[str]]] = ...,
envvar: str | List[str] | None = ...,
# User-defined
**kwargs: Any,
) -> IdentityFunction: ...
@@ -163,27 +163,27 @@ def option(
*param_decls: str,
cls: Type[Option] = ...,
# Option
show_default: Union[bool, Text] = ...,
prompt: Union[bool, Text] = ...,
show_default: bool | Text = ...,
prompt: bool | Text = ...,
confirmation_prompt: bool = ...,
hide_input: bool = ...,
is_flag: Optional[bool] = ...,
flag_value: Optional[Any] = ...,
is_flag: bool | None = ...,
flag_value: Any | None = ...,
multiple: bool = ...,
count: bool = ...,
allow_from_autoenv: bool = ...,
type: Type[int] = ...,
help: Optional[str] = ...,
help: str | None = ...,
show_choices: bool = ...,
# Parameter
default: Optional[Any] = ...,
default: Any | None = ...,
required: bool = ...,
callback: Callable[[Context, Union[Option, Parameter], int], Any] = ...,
nargs: Optional[int] = ...,
metavar: Optional[str] = ...,
callback: Callable[[Context, Option | Parameter, int], Any] = ...,
nargs: int | None = ...,
metavar: str | None = ...,
expose_value: bool = ...,
is_eager: bool = ...,
envvar: Optional[Union[str, List[str]]] = ...,
envvar: str | List[str] | None = ...,
# User-defined
**kwargs: Any,
) -> IdentityFunction: ...
@@ -191,102 +191,102 @@ def confirmation_option(
*param_decls: str,
cls: Type[Option] = ...,
# Option
show_default: Union[bool, Text] = ...,
prompt: Union[bool, Text] = ...,
show_default: bool | Text = ...,
prompt: bool | Text = ...,
confirmation_prompt: bool = ...,
hide_input: bool = ...,
is_flag: bool = ...,
flag_value: Optional[Any] = ...,
flag_value: Any | None = ...,
multiple: bool = ...,
count: bool = ...,
allow_from_autoenv: bool = ...,
type: Optional[_ConvertibleType] = ...,
type: _ConvertibleType | None = ...,
help: str = ...,
show_choices: bool = ...,
# Parameter
default: Optional[Any] = ...,
callback: Optional[_Callback] = ...,
nargs: Optional[int] = ...,
metavar: Optional[str] = ...,
default: Any | None = ...,
callback: _Callback | None = ...,
nargs: int | None = ...,
metavar: str | None = ...,
expose_value: bool = ...,
is_eager: bool = ...,
envvar: Optional[Union[str, List[str]]] = ...,
envvar: str | List[str] | None = ...,
) -> IdentityFunction: ...
def password_option(
*param_decls: str,
cls: Type[Option] = ...,
# Option
show_default: Union[bool, Text] = ...,
prompt: Union[bool, Text] = ...,
show_default: bool | Text = ...,
prompt: bool | Text = ...,
confirmation_prompt: bool = ...,
hide_input: bool = ...,
is_flag: Optional[bool] = ...,
flag_value: Optional[Any] = ...,
is_flag: bool | None = ...,
flag_value: Any | None = ...,
multiple: bool = ...,
count: bool = ...,
allow_from_autoenv: bool = ...,
type: Optional[_ConvertibleType] = ...,
help: Optional[str] = ...,
type: _ConvertibleType | None = ...,
help: str | None = ...,
show_choices: bool = ...,
# Parameter
default: Optional[Any] = ...,
callback: Optional[_Callback] = ...,
nargs: Optional[int] = ...,
metavar: Optional[str] = ...,
default: Any | None = ...,
callback: _Callback | None = ...,
nargs: int | None = ...,
metavar: str | None = ...,
expose_value: bool = ...,
is_eager: bool = ...,
envvar: Optional[Union[str, List[str]]] = ...,
envvar: str | List[str] | None = ...,
) -> IdentityFunction: ...
def version_option(
version: Optional[Union[str, Version]] = ...,
version: str | Version | None = ...,
*param_decls: str,
cls: Type[Option] = ...,
# Option
prog_name: Optional[str] = ...,
message: Optional[str] = ...,
show_default: Union[bool, Text] = ...,
prompt: Union[bool, Text] = ...,
prog_name: str | None = ...,
message: str | None = ...,
show_default: bool | Text = ...,
prompt: bool | Text = ...,
confirmation_prompt: bool = ...,
hide_input: bool = ...,
is_flag: bool = ...,
flag_value: Optional[Any] = ...,
flag_value: Any | None = ...,
multiple: bool = ...,
count: bool = ...,
allow_from_autoenv: bool = ...,
type: Optional[_ConvertibleType] = ...,
type: _ConvertibleType | None = ...,
help: str = ...,
show_choices: bool = ...,
# Parameter
default: Optional[Any] = ...,
callback: Optional[_Callback] = ...,
nargs: Optional[int] = ...,
metavar: Optional[str] = ...,
default: Any | None = ...,
callback: _Callback | None = ...,
nargs: int | None = ...,
metavar: str | None = ...,
expose_value: bool = ...,
is_eager: bool = ...,
envvar: Optional[Union[str, List[str]]] = ...,
envvar: str | List[str] | None = ...,
) -> IdentityFunction: ...
def help_option(
*param_decls: str,
cls: Type[Option] = ...,
# Option
show_default: Union[bool, Text] = ...,
prompt: Union[bool, Text] = ...,
show_default: bool | Text = ...,
prompt: bool | Text = ...,
confirmation_prompt: bool = ...,
hide_input: bool = ...,
is_flag: bool = ...,
flag_value: Optional[Any] = ...,
flag_value: Any | None = ...,
multiple: bool = ...,
count: bool = ...,
allow_from_autoenv: bool = ...,
type: Optional[_ConvertibleType] = ...,
type: _ConvertibleType | None = ...,
help: str = ...,
show_choices: bool = ...,
# Parameter
default: Optional[Any] = ...,
callback: Optional[_Callback] = ...,
nargs: Optional[int] = ...,
metavar: Optional[str] = ...,
default: Any | None = ...,
callback: _Callback | None = ...,
nargs: int | None = ...,
metavar: str | None = ...,
expose_value: bool = ...,
is_eager: bool = ...,
envvar: Optional[Union[str, List[str]]] = ...,
envvar: str | List[str] | None = ...,
) -> IdentityFunction: ...

View File

@@ -1,4 +1,4 @@
from typing import IO, Any, List, Optional
from typing import IO, Any, List
from click.core import Command, Context, Parameter
@@ -7,54 +7,50 @@ class ClickException(Exception):
message: str
def __init__(self, message: str) -> None: ...
def format_message(self) -> str: ...
def show(self, file: Optional[Any] = ...) -> None: ...
def show(self, file: Any | None = ...) -> None: ...
class UsageError(ClickException):
ctx: Optional[Context]
cmd: Optional[Command]
def __init__(self, message: str, ctx: Optional[Context] = ...) -> None: ...
def show(self, file: Optional[IO[Any]] = ...) -> None: ...
ctx: Context | None
cmd: Command | None
def __init__(self, message: str, ctx: Context | None = ...) -> None: ...
def show(self, file: IO[Any] | None = ...) -> None: ...
class BadParameter(UsageError):
param: Optional[Parameter]
param_hint: Optional[str]
param: Parameter | None
param_hint: str | None
def __init__(
self, message: str, ctx: Optional[Context] = ..., param: Optional[Parameter] = ..., param_hint: Optional[str] = ...
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: Optional[str] = ...,
ctx: Optional[Context] = ...,
param: Optional[Parameter] = ...,
param_hint: Optional[str] = ...,
param_type: Optional[str] = ...,
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]]
possibilities: List[str] | None
def __init__(
self,
option_name: str,
message: Optional[str] = ...,
possibilities: Optional[List[str]] = ...,
ctx: Optional[Context] = ...,
self, option_name: str, message: str | None = ..., possibilities: List[str] | None = ..., ctx: Context | None = ...
) -> None: ...
class BadOptionUsage(UsageError):
option_name: str
def __init__(self, option_name: str, message: str, ctx: Optional[Context] = ...) -> None: ...
def __init__(self, option_name: str, message: str, ctx: Context | None = ...) -> None: ...
class BadArgumentUsage(UsageError):
def __init__(self, message: str, ctx: Optional[Context] = ...) -> None: ...
def __init__(self, message: str, ctx: Context | None = ...) -> None: ...
class FileError(ClickException):
ui_filename: str
filename: str
def __init__(self, filename: str, hint: Optional[str] = ...) -> None: ...
def __init__(self, filename: str, hint: str | None = ...) -> None: ...
class Abort(RuntimeError): ...

View File

@@ -1,6 +1,6 @@
from typing import ContextManager, Generator, Iterable, List, Optional, Tuple
from typing import ContextManager, Generator, Iterable, List, Tuple
FORCED_WIDTH: Optional[int]
FORCED_WIDTH: int | None
def measure_table(rows: Iterable[Iterable[str]]) -> Tuple[int, ...]: ...
def iter_rows(rows: Iterable[Iterable[str]], col_count: int) -> Generator[Tuple[str, ...], None, None]: ...
@@ -10,10 +10,10 @@ def wrap_text(
class HelpFormatter:
indent_increment: int
width: Optional[int]
width: int | None
current_indent: int
buffer: List[str]
def __init__(self, indent_increment: int = ..., width: Optional[int] = ..., max_width: Optional[int] = ...) -> None: ...
def __init__(self, indent_increment: int = ..., width: int | None = ..., max_width: int | None = ...) -> None: ...
def write(self, string: str) -> None: ...
def indent(self) -> None: ...
def dedent(self) -> None: ...

View File

@@ -1,8 +1,6 @@
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]: ...
def resolve_color_default(color: bool | None = ...) -> bool | None: ...

View File

@@ -1,8 +1,8 @@
from typing import Any, Dict, Iterable, List, Optional, Set, Tuple
from typing import Any, Dict, Iterable, List, 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 _unpack_args(args: Iterable[str], nargs_spec: Iterable[int]) -> Tuple[Tuple[Tuple[str, ...] | None, ...], 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]: ...
@@ -20,10 +20,10 @@ class Option:
self,
opts: Iterable[str],
dest: str,
action: Optional[str] = ...,
action: str | None = ...,
nargs: int = ...,
const: Optional[Any] = ...,
obj: Optional[Any] = ...,
const: Any | None = ...,
obj: Any | None = ...,
) -> None: ...
@property
def takes_value(self) -> bool: ...
@@ -33,7 +33,7 @@ class Argument:
dest: str
nargs: int
obj: Any
def __init__(self, dest: str, nargs: int = ..., obj: Optional[Any] = ...) -> None: ...
def __init__(self, dest: str, nargs: int = ..., obj: Any | None = ...) -> None: ...
def process(self, value: Any, state: ParsingState) -> None: ...
class ParsingState:
@@ -44,22 +44,22 @@ class ParsingState:
def __init__(self, rargs: List[str]) -> None: ...
class OptionParser:
ctx: Optional[Context]
ctx: Context | None
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 __init__(self, ctx: Context | None = ...) -> None: ...
def add_option(
self,
opts: Iterable[str],
dest: str,
action: Optional[str] = ...,
action: str | None = ...,
nargs: int = ...,
const: Optional[Any] = ...,
obj: Optional[Any] = ...,
const: Any | None = ...,
obj: Any | None = ...,
) -> None: ...
def add_argument(self, dest: str, nargs: int = ..., obj: Optional[Any] = ...) -> None: ...
def add_argument(self, dest: str, nargs: int = ..., obj: Any | None = ...) -> None: ...
def parse_args(self, args: List[str]) -> Tuple[Dict[str, Any], List[str], List[Any]]: ...

View File

@@ -1,17 +1,17 @@
from typing import IO, Any, Callable, Generator, Iterable, Optional, Text, Tuple, TypeVar, Union, overload
from typing import IO, Any, Callable, Generator, Iterable, Text, Tuple, TypeVar, 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 _build_prompt(text: str, suffix: str, show_default: bool = ..., default: str | None = ...) -> str: ...
def prompt(
text: str,
default: Optional[str] = ...,
default: str | None = ...,
hide_input: bool = ...,
confirmation_prompt: bool = ...,
type: Optional[_ConvertibleType] = ...,
value_proc: Optional[Callable[[Optional[str]], Any]] = ...,
type: _ConvertibleType | None = ...,
value_proc: Callable[[str | None], Any] | None = ...,
prompt_suffix: str = ...,
show_default: bool = ...,
err: bool = ...,
@@ -22,7 +22,7 @@ def confirm(
) -> 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] = ...
text_or_generator: str | Iterable[str] | Callable[[], Generator[str, None, None]], color: bool | None = ...
) -> None: ...
_T = TypeVar("_T")
@@ -30,74 +30,74 @@ _T = TypeVar("_T")
@overload
def progressbar(
iterable: Iterable[_T],
length: Optional[int] = ...,
label: Optional[str] = ...,
length: int | None = ...,
label: str | None = ...,
show_eta: bool = ...,
show_percent: Optional[bool] = ...,
show_percent: bool | None = ...,
show_pos: bool = ...,
item_show_func: Optional[Callable[[_T], str]] = ...,
item_show_func: Callable[[_T], str] | None = ...,
fill_char: str = ...,
empty_char: str = ...,
bar_template: str = ...,
info_sep: str = ...,
width: int = ...,
file: Optional[IO[Any]] = ...,
color: Optional[bool] = ...,
file: IO[Any] | None = ...,
color: bool | None = ...,
) -> _ProgressBar[_T]: ...
@overload
def progressbar(
iterable: None = ...,
length: Optional[int] = ...,
label: Optional[str] = ...,
length: int | None = ...,
label: str | None = ...,
show_eta: bool = ...,
show_percent: Optional[bool] = ...,
show_percent: bool | None = ...,
show_pos: bool = ...,
item_show_func: Optional[Callable[[Any], str]] = ...,
item_show_func: Callable[[Any], str] | None = ...,
fill_char: str = ...,
empty_char: str = ...,
bar_template: str = ...,
info_sep: str = ...,
width: int = ...,
file: Optional[IO[Any]] = ...,
color: Optional[bool] = ...,
file: IO[Any] | None = ...,
color: bool | None = ...,
) -> _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] = ...,
fg: Text | None = ...,
bg: Text | None = ...,
bold: bool | None = ...,
dim: bool | None = ...,
underline: bool | None = ...,
blink: bool | None = ...,
reverse: bool | None = ...,
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]] = ...,
message: str | None = ...,
file: IO[Any] | None = ...,
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] = ...,
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 = ...,
) -> None: ...
def edit(
text: Optional[str] = ...,
editor: Optional[str] = ...,
env: Optional[str] = ...,
text: str | None = ...,
editor: str | None = ...,
env: str | None = ...,
require_save: bool = ...,
extension: str = ...,
filename: Optional[str] = ...,
filename: str | None = ...,
) -> str: ...
def launch(url: str, wait: bool = ..., locate: bool = ...) -> int: ...
def getchar(echo: bool = ...) -> Text: ...

View File

@@ -1,5 +1,5 @@
import io
from typing import IO, Any, BinaryIO, ContextManager, Dict, Iterable, List, Mapping, Optional, Text, Tuple, Union
from typing import IO, Any, BinaryIO, ContextManager, Dict, Iterable, List, Mapping, Text, Tuple
from typing_extensions import Literal
from .core import BaseCommand
@@ -14,13 +14,13 @@ class EchoingStdin:
def readlines(self) -> List[bytes]: ...
def __iter__(self) -> Iterable[bytes]: ...
def make_input_stream(input: Optional[Union[bytes, Text, IO[Any]]], charset: Text) -> BinaryIO: ...
def make_input_stream(input: bytes | Text | IO[Any] | None, charset: Text) -> BinaryIO: ...
class Result:
runner: CliRunner
exit_code: int
exception: Any
exc_info: Optional[Any]
exc_info: Any | None
stdout_bytes: bytes
stderr_bytes: bytes
def __init__(
@@ -30,7 +30,7 @@ class Result:
stderr_bytes: bytes,
exit_code: int,
exception: Any,
exc_info: Optional[Any] = ...,
exc_info: Any | None = ...,
) -> None: ...
@property
def output(self) -> Text: ...
@@ -45,23 +45,19 @@ class CliRunner:
echo_stdin: bool
mix_stderr: bool
def __init__(
self,
charset: Optional[Text] = ...,
env: Optional[Mapping[str, str]] = ...,
echo_stdin: bool = ...,
mix_stderr: bool = ...,
self, charset: Text | None = ..., env: Mapping[str, str] | None = ..., 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 make_env(self, overrides: Mapping[str, str] | None = ...) -> Dict[str, str]: ...
def isolation(
self, input: Optional[Union[bytes, Text, IO[Any]]] = ..., env: Optional[Mapping[str, str]] = ..., color: bool = ...
) -> ContextManager[Tuple[io.BytesIO, Union[io.BytesIO, Literal[False]]]]: ...
self, input: bytes | Text | IO[Any] | None = ..., env: Mapping[str, str] | None = ..., color: bool = ...
) -> ContextManager[Tuple[io.BytesIO, io.BytesIO | Literal[False]]]: ...
def invoke(
self,
cli: BaseCommand,
args: Optional[Union[str, Iterable[str]]] = ...,
input: Optional[Union[bytes, Text, IO[Any]]] = ...,
env: Optional[Mapping[str, str]] = ...,
args: str | Iterable[str] | None = ...,
input: bytes | Text | IO[Any] | None = ...,
env: Mapping[str, str] | None = ...,
catch_exceptions: bool = ...,
color: bool = ...,
**extra: Any,

View File

@@ -7,8 +7,8 @@ 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: ...
def __call__(self, value: str | None, param: Parameter | None = ..., ctx: Context | None = ...) -> bool: ...
def convert(self, value: str, param: Parameter | None, ctx: Context | None) -> bool: ...
class CompositeParamType(ParamType):
arity: int
@@ -20,35 +20,35 @@ class Choice(ParamType):
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: ...
def __init__(self, formats: Sequence[str] | None = ...) -> None: ...
def convert(self, value: str, param: Parameter | None, ctx: Context | None) -> 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: ...
def __call__(self, value: str | None, param: Parameter | None = ..., ctx: Context | None = ...) -> float: ...
def convert(self, value: str, param: Parameter | None, ctx: Context | None) -> float: ...
class FloatRange(FloatParamType):
min: Optional[float]
max: Optional[float]
min: float | None
max: float | None
clamp: bool
def __init__(self, min: Optional[float] = ..., max: Optional[float] = ..., clamp: bool = ...) -> None: ...
def __init__(self, min: float | None = ..., max: float | None = ..., clamp: bool = ...) -> None: ...
class File(ParamType):
mode: str
encoding: Optional[str]
errors: Optional[str]
lazy: Optional[bool]
encoding: str | None
errors: str | None
lazy: bool | None
atomic: bool
def __init__(
self,
mode: Text = ...,
encoding: Optional[str] = ...,
errors: Optional[str] = ...,
lazy: Optional[bool] = ...,
atomic: Optional[bool] = ...,
encoding: str | None = ...,
errors: str | None = ...,
lazy: bool | None = ...,
atomic: bool | None = ...,
) -> 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 __call__(self, value: str | None, param: Parameter | None = ..., ctx: Context | None = ...) -> IO[Any]: ...
def convert(self, value: str, param: Parameter | None, ctx: Context | None) -> IO[Any]: ...
def resolve_lazy_flag(self, value: str) -> bool: ...
_F = TypeVar("_F") # result of the function
@@ -57,18 +57,18 @@ _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: ...
def __call__(self, value: str | None, param: Parameter | None = ..., ctx: Context | None = ...) -> _F: ...
def convert(self, value: str, param: Parameter | None, ctx: Context | None) -> _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: ...
def __call__(self, value: str | None, param: Parameter | None = ..., ctx: Context | None = ...) -> int: ...
def convert(self, value: str, param: Parameter | None, ctx: Context | None) -> int: ...
class IntRange(IntParamType):
min: Optional[int]
max: Optional[int]
min: int | None
max: int | None
clamp: bool
def __init__(self, min: Optional[int] = ..., max: Optional[int] = ..., clamp: bool = ...) -> None: ...
def __init__(self, min: int | None = ..., max: int | None = ..., clamp: bool = ...) -> None: ...
_PathType = TypeVar("_PathType", str, bytes)
_PathTypeBound = Union[Type[str], Type[bytes]]
@@ -81,7 +81,7 @@ class Path(ParamType):
readable: bool
resolve_path: bool
allow_dash: bool
type: Optional[_PathTypeBound]
type: _PathTypeBound | None
def __init__(
self,
exists: bool = ...,
@@ -91,29 +91,29 @@ class Path(ParamType):
readable: bool = ...,
resolve_path: bool = ...,
allow_dash: bool = ...,
path_type: Optional[Type[_PathType]] = ...,
path_type: Type[_PathType] | None = ...,
) -> 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: ...
def coerce_path_result(self, rv: str | bytes) -> _PathType: ...
def __call__(self, value: str | None, param: Parameter | None = ..., ctx: Context | None = ...) -> _PathType: ...
def convert(self, value: str, param: Parameter | None, ctx: Context | None) -> _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: ...
def __call__(self, value: str | None, param: Parameter | None = ..., ctx: Context | None = ...) -> str: ...
def convert(self, value: str, param: Parameter | None, ctx: Context | None) -> 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: ...
def __call__(self, value: str | None, param: Parameter | None = ..., ctx: Context | None = ...) -> Tuple: ...
def convert(self, value: str, param: Parameter | None, ctx: Context | None) -> 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 __call__(self, value: str | None, param: Parameter | None = ..., ctx: Context | None = ...) -> uuid.UUID: ...
def convert(self, value: str, param: Parameter | None, ctx: Context | None) -> uuid.UUID: ...
def convert_type(ty: Optional[_ConvertibleType], default: Optional[Any] = ...) -> ParamType: ...
def convert_type(ty: _ConvertibleType | None, default: Any | None = ...) -> ParamType: ...
# parameter type shortcuts

View File

@@ -1,5 +1,5 @@
from types import TracebackType
from typing import IO, Any, AnyStr, Generic, Iterator, List, Optional, Text, Type, TypeVar
from typing import IO, Any, AnyStr, Generic, Iterator, List, Text, Type, TypeVar
_T = TypeVar("_T")
@@ -11,18 +11,18 @@ def make_default_short_help(help: str, max_length: int = ...) -> str: ...
class LazyFile(object):
name: str
mode: str
encoding: Optional[str]
encoding: str | None
errors: str
atomic: bool
def __init__(
self, filename: str, mode: str = ..., encoding: Optional[str] = ..., errors: str = ..., atomic: bool = ...
self, filename: str, mode: str = ..., encoding: str | None = ..., 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, exctype: Optional[Type[BaseException]], excinst: Optional[BaseException], exctb: Optional[TracebackType]
self, exctype: Type[BaseException] | None, excinst: BaseException | None, exctb: TracebackType | None
) -> None: ...
def __iter__(self) -> Iterator[Any]: ...
@@ -31,18 +31,18 @@ class KeepOpenFile(Generic[AnyStr]):
def __init__(self, file: IO[AnyStr]) -> None: ...
def __enter__(self) -> KeepOpenFile[AnyStr]: ...
def __exit__(
self, exctype: Optional[Type[BaseException]], excinst: Optional[BaseException], exctb: Optional[TracebackType]
self, exctype: Type[BaseException] | None, excinst: BaseException | None, exctb: TracebackType | None
) -> None: ...
def __iter__(self) -> Iterator[AnyStr]: ...
def echo(
message: object = ..., file: Optional[IO[Text]] = ..., nl: bool = ..., err: bool = ..., color: Optional[bool] = ...
message: object = ..., file: IO[Text] | None = ..., nl: bool = ..., err: bool = ..., color: bool | None = ...
) -> None: ...
def get_binary_stream(name: str) -> IO[bytes]: ...
def get_text_stream(name: str, encoding: Optional[str] = ..., errors: str = ...) -> IO[str]: ...
def get_text_stream(name: str, encoding: str | None = ..., 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]
filename: str, mode: str = ..., encoding: str | None = ..., errors: str = ..., lazy: bool = ..., atomic: bool = ...
) -> Any: ... # really 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: ...