diff --git a/third_party/2and3/click/core.pyi b/third_party/2and3/click/core.pyi index 0c291791ecd3..1c83195a17e4 100644 --- a/third_party/2and3/click/core.pyi +++ b/third_party/2and3/click/core.pyi @@ -239,7 +239,7 @@ class Command(BaseCommand): _T = TypeVar('_T') -_Decorator = Callable[[_T], _T] +_F = TypeVar('_F', bound=Callable[..., Any]) class MultiCommand(Command): @@ -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: @@ -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]: ... diff --git a/third_party/2and3/click/decorators.pyi b/third_party/2and3/click/decorators.pyi index 74c53187ccaa..c94c0761470c 100644 --- a/third_party/2and3/click/decorators.pyi +++ b/third_party/2and3/click/decorators.pyi @@ -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]], @@ -38,7 +41,7 @@ def command( short_help: Optional[str] = ..., options_metavar: str = ..., add_help_option: bool = ..., -) -> _Decorator: +) -> Callable[[_F], _F]: ... @@ -63,7 +66,7 @@ def group( add_help_option: bool = ..., # User-defined **kwargs: Any, -) -> _Decorator: +) -> Callable[[_F], _F]: ... @@ -81,7 +84,7 @@ def argument( expose_value: bool = ..., is_eager: bool = ..., envvar: Optional[Union[str, List[str]]] = ... -) -> _Decorator: +) -> Callable[[_F], _F]: ... @@ -111,7 +114,7 @@ def option( envvar: Optional[Union[str, List[str]]] = ..., # User-defined **kwargs: Any, -) -> _Decorator: +) -> Callable[[_F], _F]: ... @@ -138,7 +141,7 @@ def confirmation_option( expose_value: bool = ..., is_eager: bool = ..., envvar: Optional[Union[str, List[str]]] = ... -) -> _Decorator: +) -> Callable[[_F], _F]: ... @@ -165,7 +168,7 @@ def password_option( expose_value: bool = ..., is_eager: bool = ..., envvar: Optional[Union[str, List[str]]] = ... -) -> _Decorator: +) -> Callable[[_F], _F]: ... @@ -195,7 +198,7 @@ def version_option( expose_value: bool = ..., is_eager: bool = ..., envvar: Optional[Union[str, List[str]]] = ... -) -> _Decorator: +) -> Callable[[_F], _F]: ... @@ -222,5 +225,5 @@ def help_option( expose_value: bool = ..., is_eager: bool = ..., envvar: Optional[Union[str, List[str]]] = ... -) -> _Decorator: +) -> Callable[[_F], _F]: ... diff --git a/third_party/2and3/click/utils.pyi b/third_party/2and3/click/utils.pyi index d4c775dc8f7d..83856b296312 100644 --- a/third_party/2and3/click/utils.pyi +++ b/third_party/2and3/click/utils.pyi @@ -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: