Big diff: use lower-case list and dict (#5888)

This commit is contained in:
Akuli
2021-08-08 19:26:35 +03:00
committed by GitHub
parent 11f54c3407
commit ce11072dbe
325 changed files with 2196 additions and 2334 deletions

View File

@@ -1,19 +1,4 @@
from typing import (
Any,
Callable,
ContextManager,
Dict,
Iterable,
List,
Mapping,
NoReturn,
Optional,
Sequence,
Set,
Tuple,
TypeVar,
Union,
)
from typing import Any, Callable, ContextManager, Iterable, Mapping, NoReturn, Optional, Sequence, Set, Tuple, TypeVar, Union
from click.formatting import HelpFormatter
from click.parser import OptionParser
@@ -32,9 +17,9 @@ class Context:
parent: Context | None
command: Command
info_name: str | None
params: Dict[Any, Any]
args: List[str]
protected_args: List[str]
params: dict[Any, Any]
args: list[str]
protected_args: list[str]
obj: Any
default_map: Mapping[str, Any] | None
invoked_subcommand: str | None
@@ -43,13 +28,13 @@ class Context:
allow_extra_args: bool
allow_interspersed_args: bool
ignore_unknown_options: bool
help_option_names: List[str]
help_option_names: list[str]
token_normalize_func: Callable[[str], str] | None
resilient_parsing: bool
auto_envvar_prefix: str | None
color: bool | None
_meta: Dict[str, Any]
_close_callbacks: List[Any]
_meta: dict[str, Any]
_close_callbacks: list[Any]
_depth: int
def __init__(
self,
@@ -65,12 +50,12 @@ class Context:
allow_extra_args: bool | None = ...,
allow_interspersed_args: bool | None = ...,
ignore_unknown_options: bool | None = ...,
help_option_names: List[str] | None = ...,
help_option_names: list[str] | None = ...,
token_normalize_func: Callable[[str], str] | None = ...,
color: bool | None = ...,
) -> None: ...
@property
def meta(self) -> Dict[str, Any]: ...
def meta(self) -> dict[str, Any]: ...
@property
def command_path(self) -> str: ...
def scope(self, cleanup: bool = ...) -> ContextManager[Context]: ...
@@ -94,16 +79,16 @@ class BaseCommand:
allow_interspersed_args: bool
ignore_unknown_options: bool
name: str
context_settings: Dict[Any, Any]
def __init__(self, name: str, context_settings: Dict[Any, Any] | None = ...) -> None: ...
context_settings: dict[Any, Any]
def __init__(self, name: str, context_settings: dict[Any, Any] | 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: Any) -> Context: ...
def parse_args(self, ctx: Context, args: List[str]) -> List[str]: ...
def make_context(self, info_name: str, args: list[str], parent: Context | None = ..., **extra: Any) -> 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 = ...,
args: list[str] | None = ...,
prog_name: str | None = ...,
complete_var: str | None = ...,
standalone_mode: bool = ...,
@@ -113,7 +98,7 @@ class BaseCommand:
class Command(BaseCommand):
callback: Callable[..., Any] | None
params: List[Parameter]
params: list[Parameter]
help: str | None
epilog: str | None
short_help: str | None
@@ -125,9 +110,9 @@ class Command(BaseCommand):
def __init__(
self,
name: str,
context_settings: Dict[Any, Any] | None = ...,
context_settings: dict[Any, Any] | None = ...,
callback: Callable[..., Any] | None = ...,
params: List[Parameter] | None = ...,
params: list[Parameter] | None = ...,
help: str | None = ...,
epilog: str | None = ...,
short_help: str | None = ...,
@@ -137,9 +122,9 @@ class Command(BaseCommand):
hidden: bool = ...,
deprecated: bool = ...,
) -> None: ...
def get_params(self, ctx: Context) -> List[Parameter]: ...
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 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) -> Option | None: ...
def make_parser(self, ctx: Context) -> OptionParser: ...
@@ -170,20 +155,20 @@ class MultiCommand(Command):
) -> 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 resolve_command(self, ctx: Context, args: list[str]) -> Tuple[str, Command, list[str]]: ...
def get_command(self, ctx: Context, cmd_name: str) -> Command | None: ...
def list_commands(self, ctx: Context) -> Iterable[str]: ...
class Group(MultiCommand):
commands: Dict[str, Command]
def __init__(self, name: str | None = ..., commands: Dict[str, Command] | None = ..., **attrs: Any) -> None: ...
commands: dict[str, Command]
def __init__(self, name: str | None = ..., commands: dict[str, Command] | None = ..., **attrs: Any) -> None: ...
def add_command(self, cmd: Command, name: str | None = ...) -> None: ...
def command(self, *args: Any, **kwargs: Any) -> Callable[[Callable[..., Any]], Command]: ...
def group(self, *args: Any, **kwargs: Any) -> Callable[[Callable[..., Any]], Group]: ...
class CommandCollection(MultiCommand):
sources: List[MultiCommand]
def __init__(self, name: str | None = ..., sources: List[MultiCommand] | None = ..., **attrs: Any) -> None: ...
sources: list[MultiCommand]
def __init__(self, name: str | None = ..., sources: list[MultiCommand] | None = ..., **attrs: Any) -> None: ...
def add_source(self, multi_cmd: MultiCommand) -> None: ...
class _ParamType:
@@ -194,7 +179,7 @@ class _ParamType:
def get_metavar(self, param: Parameter) -> str: ...
def get_missing_message(self, param: Parameter) -> str: ...
def convert(self, value: str, param: Parameter | None, ctx: Context | None) -> Any: ...
def split_envvar_value(self, rv: str) -> List[str]: ...
def split_envvar_value(self, rv: str) -> list[str]: ...
def fail(self, message: str, param: Parameter | None = ..., ctx: Context | None = ...) -> NoReturn: ...
# This type is here to resolve https://github.com/python/mypy/issues/5275
@@ -205,8 +190,8 @@ _ConvertibleType = Union[
class Parameter:
param_type_name: str
name: str
opts: List[str]
secondary_opts: List[str]
opts: list[str]
secondary_opts: list[str]
type: _ParamType
required: bool
callback: Callable[[Context, Parameter, str], Any] | None
@@ -216,7 +201,7 @@ class Parameter:
default: Any
is_eager: bool
metavar: str | None
envvar: str | List[str] | None
envvar: str | list[str] | None
def __init__(
self,
param_decls: Iterable[str] | None = ...,
@@ -228,23 +213,23 @@ class Parameter:
metavar: str | None = ...,
expose_value: bool = ...,
is_eager: bool = ...,
envvar: str | List[str] | None = ...,
envvar: str | list[str] | None = ...,
) -> 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 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) -> str | List[str]: ...
def handle_parse_result(self, ctx: Context, opts: Dict[str, Any], args: List[str]) -> Tuple[Any, List[str]]: ...
def value_from_envvar(self, ctx: Context) -> 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_usage_pieces(self, ctx: Context) -> list[str]: ...
def get_error_hint(self, ctx: Context) -> str: ...
class Option(Parameter):

View File

@@ -1,6 +1,6 @@
from _typeshed import IdentityFunction
from distutils.version import Version
from typing import Any, Callable, Dict, Iterable, List, Text, Tuple, Type, TypeVar, Union, overload
from typing import Any, Callable, Iterable, Text, Tuple, Type, TypeVar, Union, overload
from click.core import Argument, Command, Context, Group, Option, Parameter, _ConvertibleType
@@ -20,7 +20,7 @@ def command(
name: str | None = ...,
cls: Type[Command] | None = ...,
# Command
context_settings: Dict[Any, Any] | None = ...,
context_settings: dict[Any, Any] | None = ...,
help: str | None = ...,
epilog: str | None = ...,
short_help: str | None = ...,
@@ -37,7 +37,7 @@ def group(
name: str | None = ...,
cls: Type[Command] = ...,
# Group
commands: Dict[str, Command] | None = ...,
commands: dict[str, Command] | None = ...,
# MultiCommand
invoke_without_command: bool = ...,
no_args_is_help: bool | None = ...,
@@ -68,8 +68,8 @@ def argument(
metavar: str | None = ...,
expose_value: bool = ...,
is_eager: bool = ...,
envvar: str | List[str] | None = ...,
autocompletion: Callable[[Context, List[str], str], Iterable[str | Tuple[str, str]]] | None = ...,
envvar: str | list[str] | None = ...,
autocompletion: Callable[[Context, list[str], str], Iterable[str | Tuple[str, str]]] | None = ...,
) -> IdentityFunction: ...
@overload
def option(
@@ -96,7 +96,7 @@ def option(
metavar: str | None = ...,
expose_value: bool = ...,
is_eager: bool = ...,
envvar: str | List[str] | None = ...,
envvar: str | list[str] | None = ...,
# User-defined
**kwargs: Any,
) -> IdentityFunction: ...
@@ -125,7 +125,7 @@ def option(
metavar: str | None = ...,
expose_value: bool = ...,
is_eager: bool = ...,
envvar: str | List[str] | None = ...,
envvar: str | list[str] | None = ...,
# User-defined
**kwargs: Any,
) -> IdentityFunction: ...
@@ -154,7 +154,7 @@ def option(
metavar: str | None = ...,
expose_value: bool = ...,
is_eager: bool = ...,
envvar: str | List[str] | None = ...,
envvar: str | list[str] | None = ...,
# User-defined
**kwargs: Any,
) -> IdentityFunction: ...
@@ -183,7 +183,7 @@ def option(
metavar: str | None = ...,
expose_value: bool = ...,
is_eager: bool = ...,
envvar: str | List[str] | None = ...,
envvar: str | list[str] | None = ...,
# User-defined
**kwargs: Any,
) -> IdentityFunction: ...
@@ -210,7 +210,7 @@ def confirmation_option(
metavar: str | None = ...,
expose_value: bool = ...,
is_eager: bool = ...,
envvar: str | List[str] | None = ...,
envvar: str | list[str] | None = ...,
) -> IdentityFunction: ...
def password_option(
*param_decls: str,
@@ -235,7 +235,7 @@ def password_option(
metavar: str | None = ...,
expose_value: bool = ...,
is_eager: bool = ...,
envvar: str | List[str] | None = ...,
envvar: str | list[str] | None = ...,
) -> IdentityFunction: ...
def version_option(
version: str | Version | None = ...,
@@ -263,7 +263,7 @@ def version_option(
metavar: str | None = ...,
expose_value: bool = ...,
is_eager: bool = ...,
envvar: str | List[str] | None = ...,
envvar: str | list[str] | None = ...,
) -> IdentityFunction: ...
def help_option(
*param_decls: str,
@@ -288,5 +288,5 @@ def help_option(
metavar: str | None = ...,
expose_value: bool = ...,
is_eager: bool = ...,
envvar: str | List[str] | None = ...,
envvar: str | list[str] | None = ...,
) -> IdentityFunction: ...

View File

@@ -1,4 +1,4 @@
from typing import IO, Any, List
from typing import IO, Any
from click.core import Command, Context, Parameter
@@ -35,9 +35,9 @@ class MissingParameter(BadParameter):
class NoSuchOption(UsageError):
option_name: str
possibilities: List[str] | None
possibilities: list[str] | None
def __init__(
self, option_name: str, message: str | None = ..., possibilities: List[str] | None = ..., ctx: Context | None = ...
self, option_name: str, message: str | None = ..., possibilities: list[str] | None = ..., ctx: Context | None = ...
) -> None: ...
class BadOptionUsage(UsageError):

View File

@@ -1,4 +1,4 @@
from typing import ContextManager, Generator, Iterable, List, Tuple
from typing import ContextManager, Generator, Iterable, Tuple
FORCED_WIDTH: int | None
@@ -12,7 +12,7 @@ class HelpFormatter:
indent_increment: int
width: int | None
current_indent: int
buffer: List[str]
buffer: list[str]
def __init__(self, indent_increment: int = ..., width: int | None = ..., max_width: int | None = ...) -> None: ...
def write(self, string: str) -> None: ...
def indent(self) -> None: ...
@@ -26,4 +26,4 @@ class HelpFormatter:
def indentation(self) -> ContextManager[None]: ...
def getvalue(self) -> str: ...
def join_options(options: List[str]) -> Tuple[str, bool]: ...
def join_options(options: list[str]) -> Tuple[str, bool]: ...

View File

@@ -1,11 +1,11 @@
from typing import Any, Dict, Iterable, List, Set, Tuple
from typing import Any, Iterable, Set, Tuple
from click.core import Context
def _unpack_args(args: Iterable[str], nargs_spec: Iterable[int]) -> Tuple[Tuple[Tuple[str, ...] | None, ...], 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]: ...
def split_arg_string(string: str) -> list[str]: ...
class Option:
dest: str
@@ -14,8 +14,8 @@ class Option:
const: Any
obj: Any
prefixes: Set[str]
_short_opts: List[str]
_long_opts: List[str]
_short_opts: list[str]
_long_opts: list[str]
def __init__(
self,
opts: Iterable[str],
@@ -37,20 +37,20 @@ class Argument:
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: ...
opts: dict[str, Any]
largs: list[str]
rargs: list[str]
order: list[Any]
def __init__(self, rargs: list[str]) -> None: ...
class OptionParser:
ctx: Context | None
allow_interspersed_args: bool
ignore_unknown_options: bool
_short_opt: Dict[str, Option]
_long_opt: Dict[str, Option]
_short_opt: dict[str, Option]
_long_opt: dict[str, Option]
_opt_prefixes: Set[str]
_args: List[Argument]
_args: list[Argument]
def __init__(self, ctx: Context | None = ...) -> None: ...
def add_option(
self,
@@ -62,4 +62,4 @@ class OptionParser:
obj: Any | None = ...,
) -> 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]]: ...
def parse_args(self, args: list[str]) -> Tuple[dict[str, Any], list[str], list[Any]]: ...

View File

@@ -1,5 +1,5 @@
import io
from typing import IO, Any, BinaryIO, ContextManager, Dict, Iterable, List, Mapping, Text, Tuple
from typing import IO, Any, BinaryIO, ContextManager, Iterable, Mapping, Text, Tuple
from typing_extensions import Literal
from .core import BaseCommand
@@ -11,7 +11,7 @@ class EchoingStdin:
def __getattr__(self, x: str) -> Any: ...
def read(self, n: int = ...) -> bytes: ...
def readline(self, n: int = ...) -> bytes: ...
def readlines(self) -> List[bytes]: ...
def readlines(self) -> list[bytes]: ...
def __iter__(self) -> Iterable[bytes]: ...
def make_input_stream(input: bytes | Text | IO[Any] | None, charset: Text) -> BinaryIO: ...
@@ -48,7 +48,7 @@ class CliRunner:
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: Mapping[str, str] | None = ...) -> Dict[str, str]: ...
def make_env(self, overrides: Mapping[str, str] | None = ...) -> dict[str, str]: ...
def isolation(
self, input: bytes | Text | IO[Any] | None = ..., env: Mapping[str, str] | None = ..., color: bool = ...
) -> ContextManager[Tuple[io.BytesIO, io.BytesIO | Literal[False]]]: ...

View File

@@ -1,6 +1,6 @@
import datetime
import uuid
from typing import IO, Any, Callable, Generic, Iterable, List, Optional, Sequence, Text, Tuple as _PyTuple, Type, TypeVar, Union
from typing import IO, Any, Callable, Generic, Iterable, Optional, Sequence, Text, Tuple as _PyTuple, Type, TypeVar, Union
from click.core import Context, Parameter, _ConvertibleType, _ParamType
@@ -102,7 +102,7 @@ class StringParamType(ParamType):
def convert(self, value: str, param: Parameter | None, ctx: Context | None) -> str: ...
class Tuple(CompositeParamType):
types: List[ParamType]
types: list[ParamType]
def __init__(self, types: Iterable[Any]) -> None: ...
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: ...

View File

@@ -1,5 +1,5 @@
from types import TracebackType
from typing import IO, Any, AnyStr, Generic, Iterator, List, Text, Type, TypeVar
from typing import IO, Any, AnyStr, Generic, Iterator, Text, Type, TypeVar
_T = TypeVar("_T")
@@ -43,6 +43,6 @@ def get_text_stream(name: str, encoding: str | None = ..., errors: str = ...) ->
def open_file(
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 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: ...