Skip to content

Remove type cycle in click #2277

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 39 additions & 3 deletions third_party/2and3/click/core.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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
Expand Down
3 changes: 1 addition & 2 deletions third_party/2and3/click/decorators.pyi
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
2 changes: 1 addition & 1 deletion third_party/2and3/click/termui.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
39 changes: 1 addition & 38 deletions third_party/2and3/click/types.pyi
Original file line number Diff line number Diff line change
@@ -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__(
Expand Down Expand Up @@ -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:
...

Expand Down