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