Skip to content
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

Make click decorators not modify the type #2322

Merged
merged 1 commit into from
Jul 11, 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
8 changes: 4 additions & 4 deletions third_party/2and3/click/core.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ class Command(BaseCommand):


_T = TypeVar('_T')
_Decorator = Callable[[_T], _T]
_F = TypeVar('_F', bound=Callable[..., Any])


class MultiCommand(Command):
Expand All @@ -263,7 +263,7 @@ class MultiCommand(Command):

def resultcallback(
self, replace: bool = ...
) -> _Decorator:
) -> Callable[[_F], _F]:
...

def format_commands(self, ctx: Context, formatter: HelpFormatter) -> None:
Expand Down Expand Up @@ -292,10 +292,10 @@ class Group(MultiCommand):
def add_command(self, cmd: Command, name: Optional[str] = ...):
...

def command(self, *args, **kwargs) -> _Decorator:
def command(self, *args, **kwargs) -> Callable[[_F], _F]:
...

def group(self, *args, **kwargs) -> _Decorator:
def group(self, *args, **kwargs) -> Callable[[_F], _F]:
...


Expand Down
21 changes: 12 additions & 9 deletions third_party/2and3/click/decorators.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@ from typing import Any, Callable, Dict, List, Optional, Type, TypeVar, Union, Te
from click.core import Command, Group, Argument, Option, Parameter, Context, _ConvertibleType

_T = TypeVar('_T')
_Decorator = Callable[[_T], _T]
_F = TypeVar('_F', bound=Callable[..., Any])

# Until https://github.com/python/mypy/issues/3924 is fixed you can't do the following:
# _Decorator = Callable[[_F], _F]

_Callback = Callable[
[Context, Union[Option, Parameter], Union[bool, int, str]],
Expand Down Expand Up @@ -38,7 +41,7 @@ def command(
short_help: Optional[str] = ...,
options_metavar: str = ...,
add_help_option: bool = ...,
) -> _Decorator:
) -> Callable[[_F], _F]:
...


Expand All @@ -63,7 +66,7 @@ def group(
add_help_option: bool = ...,
# User-defined
**kwargs: Any,
) -> _Decorator:
) -> Callable[[_F], _F]:
...


Expand All @@ -81,7 +84,7 @@ def argument(
expose_value: bool = ...,
is_eager: bool = ...,
envvar: Optional[Union[str, List[str]]] = ...
) -> _Decorator:
) -> Callable[[_F], _F]:
...


Expand Down Expand Up @@ -111,7 +114,7 @@ def option(
envvar: Optional[Union[str, List[str]]] = ...,
# User-defined
**kwargs: Any,
) -> _Decorator:
) -> Callable[[_F], _F]:
...


Expand All @@ -138,7 +141,7 @@ def confirmation_option(
expose_value: bool = ...,
is_eager: bool = ...,
envvar: Optional[Union[str, List[str]]] = ...
) -> _Decorator:
) -> Callable[[_F], _F]:
...


Expand All @@ -165,7 +168,7 @@ def password_option(
expose_value: bool = ...,
is_eager: bool = ...,
envvar: Optional[Union[str, List[str]]] = ...
) -> _Decorator:
) -> Callable[[_F], _F]:
...


Expand Down Expand Up @@ -195,7 +198,7 @@ def version_option(
expose_value: bool = ...,
is_eager: bool = ...,
envvar: Optional[Union[str, List[str]]] = ...
) -> _Decorator:
) -> Callable[[_F], _F]:
...


Expand All @@ -222,5 +225,5 @@ def help_option(
expose_value: bool = ...,
is_eager: bool = ...,
envvar: Optional[Union[str, List[str]]] = ...
) -> _Decorator:
) -> Callable[[_F], _F]:
...
1 change: 0 additions & 1 deletion third_party/2and3/click/utils.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from typing import Any, Callable, Iterator, IO, List, Optional, TypeVar, Union, Text

_T = TypeVar('_T')
_Decorator = Callable[[_T], _T]


def _posixify(name: str) -> str:
Expand Down