64
64
65
65
# 3rd party
66
66
import click
67
- from click import Argument , Context , IntRange , Option , OptionParser
67
+ from click import Argument , Context , Option , OptionParser
68
68
from click .decorators import _param_memo # type: ignore
69
69
70
70
# this package
81
81
"flag_option" ,
82
82
"auto_default_option" ,
83
83
"auto_default_argument" ,
84
+ "_A" ,
85
+ "_C" ,
84
86
]
85
87
86
88
_A = TypeVar ("_A" , bound = click .Argument )
@@ -105,7 +107,7 @@ def _describe_range(self):
105
107
return ''
106
108
107
109
108
- def verbose_option (help_text : str = "Show verbose output." ) -> Callable [..., click . Command ]:
110
+ def verbose_option (help_text : str = "Show verbose output." ) -> Callable [[ _C ], _C ]:
109
111
"""
110
112
Adds an option (via the parameter ``verbose``: :class:`int`) to enable verbose output.
111
113
@@ -119,7 +121,7 @@ def verbose_option(help_text: str = "Show verbose output.") -> Callable[..., cli
119
121
return click .option ("-v" , "--verbose" , count = True , help = help_text , type = VerboseVersionCountType ())
120
122
121
123
122
- def version_option (callback : Callable [[Context , Option , int ], Any ]) -> Callable [..., click . Command ]:
124
+ def version_option (callback : Callable [[Context , Option , int ], Any ]) -> Callable [[ _C ], _C ]:
123
125
"""
124
126
Adds an option to show the version and exit.
125
127
@@ -158,7 +160,7 @@ def version_callback(ctx: click.Context, param: click.Option, value: int):
158
160
)
159
161
160
162
161
- def colour_option (help_text = "Whether to use coloured output." ) -> Callable [..., click . Command ]:
163
+ def colour_option (help_text = "Whether to use coloured output." ) -> Callable [[ _C ], _C ]:
162
164
"""
163
165
Adds an option (via the parameter ``colour``: :class:`bool`) to enable verbose output.
164
166
@@ -174,7 +176,7 @@ def colour_option(help_text="Whether to use coloured output.") -> Callable[...,
174
176
)
175
177
176
178
177
- def force_option (help_text : str ) -> Callable [..., click . Command ]:
179
+ def force_option (help_text : str ) -> Callable [[ _C ], _C ]:
178
180
"""
179
181
Decorator to add the ``-f / --force`` option to a click command.
180
182
@@ -188,7 +190,7 @@ def force_option(help_text: str) -> Callable[..., click.Command]:
188
190
return flag_option ("-f" , "--force" , help = help_text )
189
191
190
192
191
- def no_pager_option (help_text = "Disable the output pager." ) -> Callable [..., click . Command ]:
193
+ def no_pager_option (help_text = "Disable the output pager." ) -> Callable [[ _C ], _C ]:
192
194
"""
193
195
Decorator to add the ``--no-pager`` option to a click command.
194
196
@@ -202,7 +204,7 @@ def no_pager_option(help_text="Disable the output pager.") -> Callable[..., clic
202
204
return flag_option ("--no-pager" , help = help_text )
203
205
204
206
205
- def flag_option (* args , default : Optional [bool ] = False , ** kwargs ) -> Callable [..., click . Command ]:
207
+ def flag_option (* args , default : Optional [bool ] = False , ** kwargs ) -> Callable [[ _C ], _C ]:
206
208
r"""
207
209
Decorator to a flag option to a click command.
208
210
@@ -221,7 +223,7 @@ def flag_option(*args, default: Optional[bool] = False, **kwargs) -> Callable[..
221
223
)
222
224
223
225
224
- def auto_default_option (* param_decls , ** attrs ) -> Callable [..., click . Command ]:
226
+ def auto_default_option (* param_decls , ** attrs ) -> Callable [[ _C ], _C ]:
225
227
"""
226
228
Attaches an option to the command, with a default value determined from the decorated function's signature.
227
229
@@ -264,14 +266,14 @@ def _get_default_from_callback_and_set(command: click.Command, param: click.Para
264
266
param .default = param_default
265
267
266
268
267
- def auto_default_argument (* param_decls , ** attrs ) -> Callable [..., click . Argument ]:
269
+ def auto_default_argument (* param_decls , ** attrs ) -> Callable [[ _C ], _C ]:
268
270
"""
269
271
Attaches an argument to the command, with a default value determined from the decorated function's signature.
270
272
271
273
All positional arguments are passed as parameter declarations to :class:`click.Argument`;
272
274
all keyword arguments are forwarded unchanged (except ``cls``).
273
275
This is equivalent to creating an :class:`click.Argument` instance manually
274
- and attaching it to the :attr:`click.Argument .params` list.
276
+ and attaching it to the :attr:`click.Command .params` list.
275
277
276
278
.. versionadded:: 0.8.0
277
279
0 commit comments