mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-23 20:31:32 +08:00
Make click decorators not modify the type (#2322)
This commit is contained in:
committed by
Jelle Zijlstra
parent
0bc98a18f0
commit
2899d0a6aa
8
third_party/2and3/click/core.pyi
vendored
8
third_party/2and3/click/core.pyi
vendored
@@ -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]:
|
||||
...
|
||||
|
||||
|
||||
|
||||
21
third_party/2and3/click/decorators.pyi
vendored
21
third_party/2and3/click/decorators.pyi
vendored
@@ -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]:
|
||||
...
|
||||
|
||||
1
third_party/2and3/click/utils.pyi
vendored
1
third_party/2and3/click/utils.pyi
vendored
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user