Coverage for typer/params.py: 100%
7 statements
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-09 18:26 +0000
« prev ^ index » next coverage.py v7.6.1, created at 2024-09-09 18:26 +0000
1from typing import TYPE_CHECKING, Any, Callable, List, Optional, Type, Union, overload 1habcdefg
3import click 1habcdefg
5from .models import ArgumentInfo, OptionInfo 1habcdefg
7if TYPE_CHECKING: # pragma: no cover 1habcdefg
8 import click.shell_completion
11# Overload for Option created with custom type 'parser'
12@overload 1habcdefg
13def Option( 1abcdefg
14 # Parameter
15 default: Optional[Any] = ..., 1habcdefg
16 *param_decls: str, 1abcdefg
17 callback: Optional[Callable[..., Any]] = None, 1habcdefg
18 metavar: Optional[str] = None, 1habcdefg
19 expose_value: bool = True, 1habcdefg
20 is_eager: bool = False, 1habcdefg
21 envvar: Optional[Union[str, List[str]]] = None, 1habcdefg
22 shell_complete: Optional[ 1abcdefg
23 Callable[ 1abcdefg
24 [click.Context, click.Parameter, str], 1abcdefg
25 Union[List["click.shell_completion.CompletionItem"], List[str]], 1abcdefg
26 ]
27 ] = None, 1habcdefg
28 autocompletion: Optional[Callable[..., Any]] = None, 1habcdefg
29 default_factory: Optional[Callable[[], Any]] = None, 1habcdefg
30 # Custom type
31 parser: Optional[Callable[[str], Any]] = None, 1habcdefg
32 # Option
33 show_default: Union[bool, str] = True, 1habcdefg
34 prompt: Union[bool, str] = False, 1habcdefg
35 confirmation_prompt: bool = False, 1habcdefg
36 prompt_required: bool = True, 1habcdefg
37 hide_input: bool = False, 1habcdefg
38 is_flag: Optional[bool] = None, 1habcdefg
39 flag_value: Optional[Any] = None, 1habcdefg
40 count: bool = False, 1habcdefg
41 allow_from_autoenv: bool = True, 1habcdefg
42 help: Optional[str] = None, 1habcdefg
43 hidden: bool = False, 1habcdefg
44 show_choices: bool = True, 1habcdefg
45 show_envvar: bool = True, 1habcdefg
46 # Choice
47 case_sensitive: bool = True, 1habcdefg
48 # Numbers
49 min: Optional[Union[int, float]] = None, 1habcdefg
50 max: Optional[Union[int, float]] = None, 1habcdefg
51 clamp: bool = False, 1habcdefg
52 # DateTime
53 formats: Optional[List[str]] = None, 1habcdefg
54 # File
55 mode: Optional[str] = None, 1habcdefg
56 encoding: Optional[str] = None, 1habcdefg
57 errors: Optional[str] = "strict", 1habcdefg
58 lazy: Optional[bool] = None, 1habcdefg
59 atomic: bool = False, 1habcdefg
60 # Path
61 exists: bool = False, 1habcdefg
62 file_okay: bool = True, 1habcdefg
63 dir_okay: bool = True, 1habcdefg
64 writable: bool = False, 1habcdefg
65 readable: bool = True, 1habcdefg
66 resolve_path: bool = False, 1habcdefg
67 allow_dash: bool = False, 1habcdefg
68 path_type: Union[None, Type[str], Type[bytes]] = None, 1habcdefg
69 # Rich settings
70 rich_help_panel: Union[str, None] = None, 1habcdefg
71) -> Any: ... 1habcdefg
74# Overload for Option created with custom type 'click_type'
75@overload 1habcdefg
76def Option( 1abcdefg
77 # Parameter
78 default: Optional[Any] = ..., 1habcdefg
79 *param_decls: str, 1abcdefg
80 callback: Optional[Callable[..., Any]] = None, 1habcdefg
81 metavar: Optional[str] = None, 1habcdefg
82 expose_value: bool = True, 1habcdefg
83 is_eager: bool = False, 1habcdefg
84 envvar: Optional[Union[str, List[str]]] = None, 1habcdefg
85 shell_complete: Optional[ 1abcdefg
86 Callable[ 1abcdefg
87 [click.Context, click.Parameter, str], 1abcdefg
88 Union[List["click.shell_completion.CompletionItem"], List[str]], 1abcdefg
89 ]
90 ] = None, 1habcdefg
91 autocompletion: Optional[Callable[..., Any]] = None, 1habcdefg
92 default_factory: Optional[Callable[[], Any]] = None, 1habcdefg
93 # Custom type
94 click_type: Optional[click.ParamType] = None, 1habcdefg
95 # Option
96 show_default: Union[bool, str] = True, 1habcdefg
97 prompt: Union[bool, str] = False, 1habcdefg
98 confirmation_prompt: bool = False, 1habcdefg
99 prompt_required: bool = True, 1habcdefg
100 hide_input: bool = False, 1habcdefg
101 is_flag: Optional[bool] = None, 1habcdefg
102 flag_value: Optional[Any] = None, 1habcdefg
103 count: bool = False, 1habcdefg
104 allow_from_autoenv: bool = True, 1habcdefg
105 help: Optional[str] = None, 1habcdefg
106 hidden: bool = False, 1habcdefg
107 show_choices: bool = True, 1habcdefg
108 show_envvar: bool = True, 1habcdefg
109 # Choice
110 case_sensitive: bool = True, 1habcdefg
111 # Numbers
112 min: Optional[Union[int, float]] = None, 1habcdefg
113 max: Optional[Union[int, float]] = None, 1habcdefg
114 clamp: bool = False, 1habcdefg
115 # DateTime
116 formats: Optional[List[str]] = None, 1habcdefg
117 # File
118 mode: Optional[str] = None, 1habcdefg
119 encoding: Optional[str] = None, 1habcdefg
120 errors: Optional[str] = "strict", 1habcdefg
121 lazy: Optional[bool] = None, 1habcdefg
122 atomic: bool = False, 1habcdefg
123 # Path
124 exists: bool = False, 1habcdefg
125 file_okay: bool = True, 1habcdefg
126 dir_okay: bool = True, 1habcdefg
127 writable: bool = False, 1habcdefg
128 readable: bool = True, 1habcdefg
129 resolve_path: bool = False, 1habcdefg
130 allow_dash: bool = False, 1habcdefg
131 path_type: Union[None, Type[str], Type[bytes]] = None, 1habcdefg
132 # Rich settings
133 rich_help_panel: Union[str, None] = None, 1habcdefg
134) -> Any: ... 1habcdefg
137def Option( 1abcdefg
138 # Parameter
139 default: Optional[Any] = ...,
140 *param_decls: str,
141 callback: Optional[Callable[..., Any]] = None,
142 metavar: Optional[str] = None,
143 expose_value: bool = True,
144 is_eager: bool = False,
145 envvar: Optional[Union[str, List[str]]] = None,
146 shell_complete: Optional[
147 Callable[
148 [click.Context, click.Parameter, str],
149 Union[List["click.shell_completion.CompletionItem"], List[str]],
150 ]
151 ] = None,
152 autocompletion: Optional[Callable[..., Any]] = None,
153 default_factory: Optional[Callable[[], Any]] = None,
154 # Custom type
155 parser: Optional[Callable[[str], Any]] = None,
156 click_type: Optional[click.ParamType] = None,
157 # Option
158 show_default: Union[bool, str] = True,
159 prompt: Union[bool, str] = False,
160 confirmation_prompt: bool = False,
161 prompt_required: bool = True,
162 hide_input: bool = False,
163 is_flag: Optional[bool] = None,
164 flag_value: Optional[Any] = None,
165 count: bool = False,
166 allow_from_autoenv: bool = True,
167 help: Optional[str] = None,
168 hidden: bool = False,
169 show_choices: bool = True,
170 show_envvar: bool = True,
171 # Choice
172 case_sensitive: bool = True,
173 # Numbers
174 min: Optional[Union[int, float]] = None,
175 max: Optional[Union[int, float]] = None,
176 clamp: bool = False,
177 # DateTime
178 formats: Optional[List[str]] = None,
179 # File
180 mode: Optional[str] = None,
181 encoding: Optional[str] = None,
182 errors: Optional[str] = "strict",
183 lazy: Optional[bool] = None,
184 atomic: bool = False,
185 # Path
186 exists: bool = False,
187 file_okay: bool = True,
188 dir_okay: bool = True,
189 writable: bool = False,
190 readable: bool = True,
191 resolve_path: bool = False,
192 allow_dash: bool = False,
193 path_type: Union[None, Type[str], Type[bytes]] = None,
194 # Rich settings
195 rich_help_panel: Union[str, None] = None,
196) -> Any:
197 return OptionInfo( 1habcdefg
198 # Parameter
199 default=default,
200 param_decls=param_decls,
201 callback=callback,
202 metavar=metavar,
203 expose_value=expose_value,
204 is_eager=is_eager,
205 envvar=envvar,
206 shell_complete=shell_complete,
207 autocompletion=autocompletion,
208 default_factory=default_factory,
209 # Custom type
210 parser=parser,
211 click_type=click_type,
212 # Option
213 show_default=show_default,
214 prompt=prompt,
215 confirmation_prompt=confirmation_prompt,
216 prompt_required=prompt_required,
217 hide_input=hide_input,
218 is_flag=is_flag,
219 flag_value=flag_value,
220 count=count,
221 allow_from_autoenv=allow_from_autoenv,
222 help=help,
223 hidden=hidden,
224 show_choices=show_choices,
225 show_envvar=show_envvar,
226 # Choice
227 case_sensitive=case_sensitive,
228 # Numbers
229 min=min,
230 max=max,
231 clamp=clamp,
232 # DateTime
233 formats=formats,
234 # File
235 mode=mode,
236 encoding=encoding,
237 errors=errors,
238 lazy=lazy,
239 atomic=atomic,
240 # Path
241 exists=exists,
242 file_okay=file_okay,
243 dir_okay=dir_okay,
244 writable=writable,
245 readable=readable,
246 resolve_path=resolve_path,
247 allow_dash=allow_dash,
248 path_type=path_type,
249 # Rich settings
250 rich_help_panel=rich_help_panel,
251 )
254# Overload for Argument created with custom type 'parser'
255@overload 1habcdefg
256def Argument( 1abcdefg
257 # Parameter
258 default: Optional[Any] = ..., 1habcdefg
259 *,
260 callback: Optional[Callable[..., Any]] = None, 1habcdefg
261 metavar: Optional[str] = None, 1habcdefg
262 expose_value: bool = True, 1habcdefg
263 is_eager: bool = False, 1habcdefg
264 envvar: Optional[Union[str, List[str]]] = None, 1habcdefg
265 shell_complete: Optional[ 1abcdefg
266 Callable[ 1abcdefg
267 [click.Context, click.Parameter, str], 1abcdefg
268 Union[List["click.shell_completion.CompletionItem"], List[str]], 1abcdefg
269 ]
270 ] = None, 1habcdefg
271 autocompletion: Optional[Callable[..., Any]] = None, 1habcdefg
272 default_factory: Optional[Callable[[], Any]] = None, 1habcdefg
273 # Custom type
274 parser: Optional[Callable[[str], Any]] = None, 1habcdefg
275 # TyperArgument
276 show_default: Union[bool, str] = True, 1habcdefg
277 show_choices: bool = True, 1habcdefg
278 show_envvar: bool = True, 1habcdefg
279 help: Optional[str] = None, 1habcdefg
280 hidden: bool = False, 1habcdefg
281 # Choice
282 case_sensitive: bool = True, 1habcdefg
283 # Numbers
284 min: Optional[Union[int, float]] = None, 1habcdefg
285 max: Optional[Union[int, float]] = None, 1habcdefg
286 clamp: bool = False, 1habcdefg
287 # DateTime
288 formats: Optional[List[str]] = None, 1habcdefg
289 # File
290 mode: Optional[str] = None, 1habcdefg
291 encoding: Optional[str] = None, 1habcdefg
292 errors: Optional[str] = "strict", 1habcdefg
293 lazy: Optional[bool] = None, 1habcdefg
294 atomic: bool = False, 1habcdefg
295 # Path
296 exists: bool = False, 1habcdefg
297 file_okay: bool = True, 1habcdefg
298 dir_okay: bool = True, 1habcdefg
299 writable: bool = False, 1habcdefg
300 readable: bool = True, 1habcdefg
301 resolve_path: bool = False, 1habcdefg
302 allow_dash: bool = False, 1habcdefg
303 path_type: Union[None, Type[str], Type[bytes]] = None, 1habcdefg
304 # Rich settings
305 rich_help_panel: Union[str, None] = None, 1habcdefg
306) -> Any: ... 1habcdefg
309# Overload for Argument created with custom type 'click_type'
310@overload 1habcdefg
311def Argument( 1abcdefg
312 # Parameter
313 default: Optional[Any] = ..., 1habcdefg
314 *,
315 callback: Optional[Callable[..., Any]] = None, 1habcdefg
316 metavar: Optional[str] = None, 1habcdefg
317 expose_value: bool = True, 1habcdefg
318 is_eager: bool = False, 1habcdefg
319 envvar: Optional[Union[str, List[str]]] = None, 1habcdefg
320 shell_complete: Optional[ 1abcdefg
321 Callable[ 1abcdefg
322 [click.Context, click.Parameter, str], 1abcdefg
323 Union[List["click.shell_completion.CompletionItem"], List[str]], 1abcdefg
324 ]
325 ] = None, 1habcdefg
326 autocompletion: Optional[Callable[..., Any]] = None, 1habcdefg
327 default_factory: Optional[Callable[[], Any]] = None, 1habcdefg
328 # Custom type
329 click_type: Optional[click.ParamType] = None, 1habcdefg
330 # TyperArgument
331 show_default: Union[bool, str] = True, 1habcdefg
332 show_choices: bool = True, 1habcdefg
333 show_envvar: bool = True, 1habcdefg
334 help: Optional[str] = None, 1habcdefg
335 hidden: bool = False, 1habcdefg
336 # Choice
337 case_sensitive: bool = True, 1habcdefg
338 # Numbers
339 min: Optional[Union[int, float]] = None, 1habcdefg
340 max: Optional[Union[int, float]] = None, 1habcdefg
341 clamp: bool = False, 1habcdefg
342 # DateTime
343 formats: Optional[List[str]] = None, 1habcdefg
344 # File
345 mode: Optional[str] = None, 1habcdefg
346 encoding: Optional[str] = None, 1habcdefg
347 errors: Optional[str] = "strict", 1habcdefg
348 lazy: Optional[bool] = None, 1habcdefg
349 atomic: bool = False, 1habcdefg
350 # Path
351 exists: bool = False, 1habcdefg
352 file_okay: bool = True, 1habcdefg
353 dir_okay: bool = True, 1habcdefg
354 writable: bool = False, 1habcdefg
355 readable: bool = True, 1habcdefg
356 resolve_path: bool = False, 1habcdefg
357 allow_dash: bool = False, 1habcdefg
358 path_type: Union[None, Type[str], Type[bytes]] = None, 1habcdefg
359 # Rich settings
360 rich_help_panel: Union[str, None] = None, 1habcdefg
361) -> Any: ... 1habcdefg
364def Argument( 1abcdefg
365 # Parameter
366 default: Optional[Any] = ...,
367 *,
368 callback: Optional[Callable[..., Any]] = None,
369 metavar: Optional[str] = None,
370 expose_value: bool = True,
371 is_eager: bool = False,
372 envvar: Optional[Union[str, List[str]]] = None,
373 shell_complete: Optional[
374 Callable[
375 [click.Context, click.Parameter, str],
376 Union[List["click.shell_completion.CompletionItem"], List[str]],
377 ]
378 ] = None,
379 autocompletion: Optional[Callable[..., Any]] = None,
380 default_factory: Optional[Callable[[], Any]] = None,
381 # Custom type
382 parser: Optional[Callable[[str], Any]] = None,
383 click_type: Optional[click.ParamType] = None,
384 # TyperArgument
385 show_default: Union[bool, str] = True,
386 show_choices: bool = True,
387 show_envvar: bool = True,
388 help: Optional[str] = None,
389 hidden: bool = False,
390 # Choice
391 case_sensitive: bool = True,
392 # Numbers
393 min: Optional[Union[int, float]] = None,
394 max: Optional[Union[int, float]] = None,
395 clamp: bool = False,
396 # DateTime
397 formats: Optional[List[str]] = None,
398 # File
399 mode: Optional[str] = None,
400 encoding: Optional[str] = None,
401 errors: Optional[str] = "strict",
402 lazy: Optional[bool] = None,
403 atomic: bool = False,
404 # Path
405 exists: bool = False,
406 file_okay: bool = True,
407 dir_okay: bool = True,
408 writable: bool = False,
409 readable: bool = True,
410 resolve_path: bool = False,
411 allow_dash: bool = False,
412 path_type: Union[None, Type[str], Type[bytes]] = None,
413 # Rich settings
414 rich_help_panel: Union[str, None] = None,
415) -> Any:
416 return ArgumentInfo( 1habcdefg
417 # Parameter
418 default=default,
419 # Arguments can only have one param declaration
420 # it will be generated from the param name
421 param_decls=None,
422 callback=callback,
423 metavar=metavar,
424 expose_value=expose_value,
425 is_eager=is_eager,
426 envvar=envvar,
427 shell_complete=shell_complete,
428 autocompletion=autocompletion,
429 default_factory=default_factory,
430 # Custom type
431 parser=parser,
432 click_type=click_type,
433 # TyperArgument
434 show_default=show_default,
435 show_choices=show_choices,
436 show_envvar=show_envvar,
437 help=help,
438 hidden=hidden,
439 # Choice
440 case_sensitive=case_sensitive,
441 # Numbers
442 min=min,
443 max=max,
444 clamp=clamp,
445 # DateTime
446 formats=formats,
447 # File
448 mode=mode,
449 encoding=encoding,
450 errors=errors,
451 lazy=lazy,
452 atomic=atomic,
453 # Path
454 exists=exists,
455 file_okay=file_okay,
456 dir_okay=dir_okay,
457 writable=writable,
458 readable=readable,
459 resolve_path=resolve_path,
460 allow_dash=allow_dash,
461 path_type=path_type,
462 # Rich settings
463 rich_help_panel=rich_help_panel,
464 )