Remove type cycle in click (#2277)

This commit is contained in:
Ethan Smith
2018-06-26 10:24:55 -04:00
committed by Jelle Zijlstra
parent 41e5fe4457
commit de1755b263
4 changed files with 42 additions and 44 deletions

View File

@@ -17,8 +17,6 @@ from typing import (
from click.formatting import HelpFormatter
from click.parser import OptionParser
from click.types import ParamType, _ConvertibleType
def invoke_param_callback(
callback: Callable[['Context', 'Parameter', Optional[str]], Any],
@@ -313,12 +311,50 @@ class CommandCollection(MultiCommand):
...
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] = ...) -> None:
...
# This type is here to resolve https://github.com/python/mypy/issues/5275
_ConvertibleType = Union[type, _ParamType, Tuple[type, ...], Callable[[str], Any], Callable[[Optional[str]], Any]]
class Parameter:
param_type_name: str
name: str
opts: List[str]
secondary_opts: List[str]
type: ParamType
type: _ParamType
required: bool
callback: Optional[Callable[[Context, 'Parameter', str], Any]]
nargs: int

View File

@@ -1,8 +1,7 @@
from distutils.version import Version
from typing import Any, Callable, Dict, List, Optional, Type, TypeVar, Union, Text
from click.core import Command, Group, Argument, Option, Parameter, Context
from click.types import _ConvertibleType
from click.core import Command, Group, Argument, Option, Parameter, Context, _ConvertibleType
_T = TypeVar('_T')
_Decorator = Callable[[_T], _T]

View File

@@ -12,7 +12,7 @@ from typing import (
TypeVar,
)
from click.types import _ConvertibleType
from click.core import _ConvertibleType
from click._termui_impl import ProgressBar as _ProgressBar

View File

@@ -1,42 +1,7 @@
from typing import Any, Callable, IO, Iterable, List, Optional, TypeVar, Union, Tuple as _PyTuple, Type
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: 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] = ...) -> None:
...
from click.core import Context, Parameter, _ParamType as ParamType, _ConvertibleType
class BoolParamType(ParamType):
def __call__(
@@ -270,8 +235,6 @@ class UUIDParameterType(ParamType):
...
_ConvertibleType = Union[type, ParamType, _PyTuple[type, ...], Callable[[str], Any], Callable[[Optional[str]], Any]]
def convert_type(ty: Optional[_ConvertibleType], default: Optional[Any] = ...) -> ParamType:
...