typer.models

  1import inspect
  2import io
  3from typing import (
  4    TYPE_CHECKING,
  5    Any,
  6    Callable,
  7    Dict,
  8    List,
  9    Optional,
 10    Sequence,
 11    Type,
 12    TypeVar,
 13    Union,
 14)
 15
 16import click
 17import click.shell_completion
 18
 19if TYPE_CHECKING:  # pragma: no cover
 20    from .core import TyperCommand, TyperGroup
 21    from .main import Typer
 22
 23
 24NoneType = type(None)
 25
 26AnyType = Type[Any]
 27
 28Required = ...
 29
 30
 31class Context(click.Context):
 32    pass
 33
 34
 35class FileText(io.TextIOWrapper):
 36    pass
 37
 38
 39class FileTextWrite(FileText):
 40    pass
 41
 42
 43class FileBinaryRead(io.BufferedReader):
 44    pass
 45
 46
 47class FileBinaryWrite(io.BufferedWriter):
 48    pass
 49
 50
 51class CallbackParam(click.Parameter):
 52    pass
 53
 54
 55class DefaultPlaceholder:
 56    """
 57    You shouldn't use this class directly.
 58
 59    It's used internally to recognize when a default value has been overwritten, even
 60    if the new value is `None`.
 61    """
 62
 63    def __init__(self, value: Any):
 64        self.value = value
 65
 66    def __bool__(self) -> bool:
 67        return bool(self.value)
 68
 69
 70DefaultType = TypeVar("DefaultType")
 71
 72CommandFunctionType = TypeVar("CommandFunctionType", bound=Callable[..., Any])
 73
 74
 75def Default(value: DefaultType) -> DefaultType:
 76    """
 77    You shouldn't use this function directly.
 78
 79    It's used internally to recognize when a default value has been overwritten, even
 80    if the new value is `None`.
 81    """
 82    return DefaultPlaceholder(value)  # type: ignore
 83
 84
 85class CommandInfo:
 86    def __init__(
 87        self,
 88        name: Optional[str] = None,
 89        *,
 90        cls: Optional[Type["TyperCommand"]] = None,
 91        context_settings: Optional[Dict[Any, Any]] = None,
 92        callback: Optional[Callable[..., Any]] = None,
 93        help: Optional[str] = None,
 94        epilog: Optional[str] = None,
 95        short_help: Optional[str] = None,
 96        options_metavar: str = "[OPTIONS]",
 97        add_help_option: bool = True,
 98        no_args_is_help: bool = False,
 99        hidden: bool = False,
100        deprecated: bool = False,
101        # Rich settings
102        rich_help_panel: Union[str, None] = None,
103    ):
104        self.name = name
105        self.cls = cls
106        self.context_settings = context_settings
107        self.callback = callback
108        self.help = help
109        self.epilog = epilog
110        self.short_help = short_help
111        self.options_metavar = options_metavar
112        self.add_help_option = add_help_option
113        self.no_args_is_help = no_args_is_help
114        self.hidden = hidden
115        self.deprecated = deprecated
116        # Rich settings
117        self.rich_help_panel = rich_help_panel
118
119
120class TyperInfo:
121    def __init__(
122        self,
123        typer_instance: Optional["Typer"] = Default(None),
124        *,
125        name: Optional[str] = Default(None),
126        cls: Optional[Type["TyperGroup"]] = Default(None),
127        invoke_without_command: bool = Default(False),
128        no_args_is_help: bool = Default(False),
129        subcommand_metavar: Optional[str] = Default(None),
130        chain: bool = Default(False),
131        result_callback: Optional[Callable[..., Any]] = Default(None),
132        # Command
133        context_settings: Optional[Dict[Any, Any]] = Default(None),
134        callback: Optional[Callable[..., Any]] = Default(None),
135        help: Optional[str] = Default(None),
136        epilog: Optional[str] = Default(None),
137        short_help: Optional[str] = Default(None),
138        options_metavar: str = Default("[OPTIONS]"),
139        add_help_option: bool = Default(True),
140        hidden: bool = Default(False),
141        deprecated: bool = Default(False),
142        # Rich settings
143        rich_help_panel: Union[str, None] = Default(None),
144    ):
145        self.typer_instance = typer_instance
146        self.name = name
147        self.cls = cls
148        self.invoke_without_command = invoke_without_command
149        self.no_args_is_help = no_args_is_help
150        self.subcommand_metavar = subcommand_metavar
151        self.chain = chain
152        self.result_callback = result_callback
153        self.context_settings = context_settings
154        self.callback = callback
155        self.help = help
156        self.epilog = epilog
157        self.short_help = short_help
158        self.options_metavar = options_metavar
159        self.add_help_option = add_help_option
160        self.hidden = hidden
161        self.deprecated = deprecated
162        self.rich_help_panel = rich_help_panel
163
164
165class ParameterInfo:
166    def __init__(
167        self,
168        *,
169        default: Optional[Any] = None,
170        param_decls: Optional[Sequence[str]] = None,
171        callback: Optional[Callable[..., Any]] = None,
172        metavar: Optional[str] = None,
173        expose_value: bool = True,
174        is_eager: bool = False,
175        envvar: Optional[Union[str, List[str]]] = None,
176        shell_complete: Optional[
177            Callable[
178                [click.Context, click.Parameter, str],
179                Union[List["click.shell_completion.CompletionItem"], List[str]],
180            ]
181        ] = None,
182        autocompletion: Optional[Callable[..., Any]] = None,
183        default_factory: Optional[Callable[[], Any]] = None,
184        # Custom type
185        parser: Optional[Callable[[str], Any]] = None,
186        click_type: Optional[click.ParamType] = None,
187        # TyperArgument
188        show_default: Union[bool, str] = True,
189        show_choices: bool = True,
190        show_envvar: bool = True,
191        help: Optional[str] = None,
192        hidden: bool = False,
193        # Choice
194        case_sensitive: bool = True,
195        # Numbers
196        min: Optional[Union[int, float]] = None,
197        max: Optional[Union[int, float]] = None,
198        clamp: bool = False,
199        # DateTime
200        formats: Optional[List[str]] = None,
201        # File
202        mode: Optional[str] = None,
203        encoding: Optional[str] = None,
204        errors: Optional[str] = "strict",
205        lazy: Optional[bool] = None,
206        atomic: bool = False,
207        # Path
208        exists: bool = False,
209        file_okay: bool = True,
210        dir_okay: bool = True,
211        writable: bool = False,
212        readable: bool = True,
213        resolve_path: bool = False,
214        allow_dash: bool = False,
215        path_type: Union[None, Type[str], Type[bytes]] = None,
216        # Rich settings
217        rich_help_panel: Union[str, None] = None,
218    ):
219        # Check if user has provided multiple custom parsers
220        if parser and click_type:
221            raise ValueError(
222                "Multiple custom type parsers provided. "
223                "`parser` and `click_type` may not both be provided."
224            )
225
226        self.default = default
227        self.param_decls = param_decls
228        self.callback = callback
229        self.metavar = metavar
230        self.expose_value = expose_value
231        self.is_eager = is_eager
232        self.envvar = envvar
233        self.shell_complete = shell_complete
234        self.autocompletion = autocompletion
235        self.default_factory = default_factory
236        # Custom type
237        self.parser = parser
238        self.click_type = click_type
239        # TyperArgument
240        self.show_default = show_default
241        self.show_choices = show_choices
242        self.show_envvar = show_envvar
243        self.help = help
244        self.hidden = hidden
245        # Choice
246        self.case_sensitive = case_sensitive
247        # Numbers
248        self.min = min
249        self.max = max
250        self.clamp = clamp
251        # DateTime
252        self.formats = formats
253        # File
254        self.mode = mode
255        self.encoding = encoding
256        self.errors = errors
257        self.lazy = lazy
258        self.atomic = atomic
259        # Path
260        self.exists = exists
261        self.file_okay = file_okay
262        self.dir_okay = dir_okay
263        self.writable = writable
264        self.readable = readable
265        self.resolve_path = resolve_path
266        self.allow_dash = allow_dash
267        self.path_type = path_type
268        # Rich settings
269        self.rich_help_panel = rich_help_panel
270
271
272class OptionInfo(ParameterInfo):
273    def __init__(
274        self,
275        *,
276        # ParameterInfo
277        default: Optional[Any] = None,
278        param_decls: Optional[Sequence[str]] = None,
279        callback: Optional[Callable[..., Any]] = None,
280        metavar: Optional[str] = None,
281        expose_value: bool = True,
282        is_eager: bool = False,
283        envvar: Optional[Union[str, List[str]]] = None,
284        shell_complete: Optional[
285            Callable[
286                [click.Context, click.Parameter, str],
287                Union[List["click.shell_completion.CompletionItem"], List[str]],
288            ]
289        ] = None,
290        autocompletion: Optional[Callable[..., Any]] = None,
291        default_factory: Optional[Callable[[], Any]] = None,
292        # Custom type
293        parser: Optional[Callable[[str], Any]] = None,
294        click_type: Optional[click.ParamType] = None,
295        # Option
296        show_default: Union[bool, str] = True,
297        prompt: Union[bool, str] = False,
298        confirmation_prompt: bool = False,
299        prompt_required: bool = True,
300        hide_input: bool = False,
301        is_flag: Optional[bool] = None,
302        flag_value: Optional[Any] = None,
303        count: bool = False,
304        allow_from_autoenv: bool = True,
305        help: Optional[str] = None,
306        hidden: bool = False,
307        show_choices: bool = True,
308        show_envvar: bool = True,
309        # Choice
310        case_sensitive: bool = True,
311        # Numbers
312        min: Optional[Union[int, float]] = None,
313        max: Optional[Union[int, float]] = None,
314        clamp: bool = False,
315        # DateTime
316        formats: Optional[List[str]] = None,
317        # File
318        mode: Optional[str] = None,
319        encoding: Optional[str] = None,
320        errors: Optional[str] = "strict",
321        lazy: Optional[bool] = None,
322        atomic: bool = False,
323        # Path
324        exists: bool = False,
325        file_okay: bool = True,
326        dir_okay: bool = True,
327        writable: bool = False,
328        readable: bool = True,
329        resolve_path: bool = False,
330        allow_dash: bool = False,
331        path_type: Union[None, Type[str], Type[bytes]] = None,
332        # Rich settings
333        rich_help_panel: Union[str, None] = None,
334    ):
335        super().__init__(
336            default=default,
337            param_decls=param_decls,
338            callback=callback,
339            metavar=metavar,
340            expose_value=expose_value,
341            is_eager=is_eager,
342            envvar=envvar,
343            shell_complete=shell_complete,
344            autocompletion=autocompletion,
345            default_factory=default_factory,
346            # Custom type
347            parser=parser,
348            click_type=click_type,
349            # TyperArgument
350            show_default=show_default,
351            show_choices=show_choices,
352            show_envvar=show_envvar,
353            help=help,
354            hidden=hidden,
355            # Choice
356            case_sensitive=case_sensitive,
357            # Numbers
358            min=min,
359            max=max,
360            clamp=clamp,
361            # DateTime
362            formats=formats,
363            # File
364            mode=mode,
365            encoding=encoding,
366            errors=errors,
367            lazy=lazy,
368            atomic=atomic,
369            # Path
370            exists=exists,
371            file_okay=file_okay,
372            dir_okay=dir_okay,
373            writable=writable,
374            readable=readable,
375            resolve_path=resolve_path,
376            allow_dash=allow_dash,
377            path_type=path_type,
378            # Rich settings
379            rich_help_panel=rich_help_panel,
380        )
381        self.prompt = prompt
382        self.confirmation_prompt = confirmation_prompt
383        self.prompt_required = prompt_required
384        self.hide_input = hide_input
385        self.is_flag = is_flag
386        self.flag_value = flag_value
387        self.count = count
388        self.allow_from_autoenv = allow_from_autoenv
389
390
391class ArgumentInfo(ParameterInfo):
392    def __init__(
393        self,
394        *,
395        # ParameterInfo
396        default: Optional[Any] = None,
397        param_decls: Optional[Sequence[str]] = None,
398        callback: Optional[Callable[..., Any]] = None,
399        metavar: Optional[str] = None,
400        expose_value: bool = True,
401        is_eager: bool = False,
402        envvar: Optional[Union[str, List[str]]] = None,
403        shell_complete: Optional[
404            Callable[
405                [click.Context, click.Parameter, str],
406                Union[List["click.shell_completion.CompletionItem"], List[str]],
407            ]
408        ] = None,
409        autocompletion: Optional[Callable[..., Any]] = None,
410        default_factory: Optional[Callable[[], Any]] = None,
411        # Custom type
412        parser: Optional[Callable[[str], Any]] = None,
413        click_type: Optional[click.ParamType] = None,
414        # TyperArgument
415        show_default: Union[bool, str] = True,
416        show_choices: bool = True,
417        show_envvar: bool = True,
418        help: Optional[str] = None,
419        hidden: bool = False,
420        # Choice
421        case_sensitive: bool = True,
422        # Numbers
423        min: Optional[Union[int, float]] = None,
424        max: Optional[Union[int, float]] = None,
425        clamp: bool = False,
426        # DateTime
427        formats: Optional[List[str]] = None,
428        # File
429        mode: Optional[str] = None,
430        encoding: Optional[str] = None,
431        errors: Optional[str] = "strict",
432        lazy: Optional[bool] = None,
433        atomic: bool = False,
434        # Path
435        exists: bool = False,
436        file_okay: bool = True,
437        dir_okay: bool = True,
438        writable: bool = False,
439        readable: bool = True,
440        resolve_path: bool = False,
441        allow_dash: bool = False,
442        path_type: Union[None, Type[str], Type[bytes]] = None,
443        # Rich settings
444        rich_help_panel: Union[str, None] = None,
445    ):
446        super().__init__(
447            default=default,
448            param_decls=param_decls,
449            callback=callback,
450            metavar=metavar,
451            expose_value=expose_value,
452            is_eager=is_eager,
453            envvar=envvar,
454            shell_complete=shell_complete,
455            autocompletion=autocompletion,
456            default_factory=default_factory,
457            # Custom type
458            parser=parser,
459            click_type=click_type,
460            # TyperArgument
461            show_default=show_default,
462            show_choices=show_choices,
463            show_envvar=show_envvar,
464            help=help,
465            hidden=hidden,
466            # Choice
467            case_sensitive=case_sensitive,
468            # Numbers
469            min=min,
470            max=max,
471            clamp=clamp,
472            # DateTime
473            formats=formats,
474            # File
475            mode=mode,
476            encoding=encoding,
477            errors=errors,
478            lazy=lazy,
479            atomic=atomic,
480            # Path
481            exists=exists,
482            file_okay=file_okay,
483            dir_okay=dir_okay,
484            writable=writable,
485            readable=readable,
486            resolve_path=resolve_path,
487            allow_dash=allow_dash,
488            path_type=path_type,
489            # Rich settings
490            rich_help_panel=rich_help_panel,
491        )
492
493
494class ParamMeta:
495    empty = inspect.Parameter.empty
496
497    def __init__(
498        self,
499        *,
500        name: str,
501        default: Any = inspect.Parameter.empty,
502        annotation: Any = inspect.Parameter.empty,
503    ) -> None:
504        self.name = name
505        self.default = default
506        self.annotation = annotation
507
508
509class DeveloperExceptionConfig:
510    def __init__(
511        self,
512        *,
513        pretty_exceptions_enable: bool = True,
514        pretty_exceptions_show_locals: bool = True,
515        pretty_exceptions_short: bool = True,
516    ) -> None:
517        self.pretty_exceptions_enable = pretty_exceptions_enable
518        self.pretty_exceptions_show_locals = pretty_exceptions_show_locals
519        self.pretty_exceptions_short = pretty_exceptions_short
class NoneType:
AnyType = typing.Type[typing.Any]
Required = Ellipsis
class Context(click.core.Context):
32class Context(click.Context):
33    pass

The context is a special internal object that holds state relevant for the script execution at every single level. It's normally invisible to commands unless they opt-in to getting access to it.

The context is useful as it can pass internal objects around and can control special execution features such as reading data from environment variables.

A context can be used as context manager in which case it will call close() on teardown.

Parameters
  • command: the command class for this context.
  • parent: the parent context.
  • info_name: the info name for this invocation. Generally this is the most descriptive name for the script or command. For the toplevel script it is usually the name of the script, for commands below it it's the name of the script.
  • obj: an arbitrary object of user data.
  • auto_envvar_prefix: the prefix to use for automatic environment variables. If this is None then reading from environment variables is disabled. This does not affect manually set environment variables which are always read.
  • default_map: a dictionary (like object) with default values for parameters.
  • terminal_width: the width of the terminal. The default is inherit from parent context. If no context defines the terminal width then auto detection will be applied.
  • max_content_width: the maximum width for content rendered by Click (this currently only affects help pages). This defaults to 80 characters if not overridden. In other words: even if the terminal is larger than that, Click will not format things wider than 80 characters by default. In addition to that, formatters might add some safety mapping on the right.
  • resilient_parsing: if this flag is enabled then Click will parse without any interactivity or callback invocation. Default values will also be ignored. This is useful for implementing things such as completion support.
  • allow_extra_args: if this is set to True then extra arguments at the end will not raise an error and will be kept on the context. The default is to inherit from the command.
  • allow_interspersed_args: if this is set to False then options and arguments cannot be mixed. The default is to inherit from the command.
  • ignore_unknown_options: instructs click to ignore options it does not know and keeps them for later processing.
  • help_option_names: optionally a list of strings that define how the default help parameter is named. The default is ['--help'].
  • token_normalize_func: an optional function that is used to normalize tokens (options, choices, etc.). This for instance can be used to implement case insensitive behavior.
  • color: controls if the terminal supports ANSI colors or not. The default is autodetection. This is only needed if ANSI codes are used in texts that Click prints which is by default not the case. This for instance would affect help output.
  • show_default: Show the default value for commands. If this value is not set, it defaults to the value from the parent context. Command.show_default overrides this default for the specific command.

Changed in version 8.1: The show_default parameter is overridden by Command.show_default, instead of the other way around.

Changed in version 8.0: The show_default parameter defaults to the value from the parent context.

Changed in version 7.1: Added the show_default parameter.

Changed in version 4.0: Added the color, ignore_unknown_options, and max_content_width parameters.

Changed in version 3.0: Added the allow_extra_args and allow_interspersed_args parameters.

Changed in version 2.0: Added the resilient_parsing, help_option_names, and token_normalize_func parameters.

Inherited Members
click.core.Context
Context
formatter_class
parent
command
info_name
params
args
protected_args
obj
default_map
invoked_subcommand
terminal_width
max_content_width
allow_extra_args
allow_interspersed_args
ignore_unknown_options
help_option_names
token_normalize_func
resilient_parsing
auto_envvar_prefix
color
show_default
to_info_dict
scope
meta
make_formatter
with_resource
call_on_close
close
command_path
find_root
find_object
ensure_object
lookup_default
fail
abort
exit
get_usage
get_help
invoke
forward
set_parameter_source
get_parameter_source
class FileText(_io.TextIOWrapper):
36class FileText(io.TextIOWrapper):
37    pass

Character and line based layer over a BufferedIOBase object, buffer.

encoding gives the name of the encoding that the stream will be decoded or encoded with. It defaults to locale.getencoding().

errors determines the strictness of encoding and decoding (see help(codecs.Codec) or the documentation for codecs.register) and defaults to "strict".

newline controls how line endings are handled. It can be None, '', '\n', '\r', and '\r\n'. It works as follows:

  • On input, if newline is None, universal newlines mode is enabled. Lines in the input can end in '\n', '\r', or '\r\n', and these are translated into '\n' before being returned to the caller. If it is '', universal newline mode is enabled, but line endings are returned to the caller untranslated. If it has any of the other legal values, input lines are only terminated by the given string, and the line ending is returned to the caller untranslated.

  • On output, if newline is None, any '\n' characters written are translated to the system default line separator, os.linesep. If newline is '' or '\n', no translation takes place. If newline is any of the other legal values, any '\n' characters written are translated to the given string.

If line_buffering is True, a call to flush is implied when a call to write contains a newline character.

Inherited Members
_io.TextIOWrapper
TextIOWrapper
detach
reconfigure
write
read
readline
flush
close
fileno
seekable
readable
writable
isatty
seek
tell
truncate
encoding
buffer
line_buffering
write_through
name
closed
newlines
errors
_io._IOBase
readlines
writelines
class FileTextWrite(FileText):
40class FileTextWrite(FileText):
41    pass

Character and line based layer over a BufferedIOBase object, buffer.

encoding gives the name of the encoding that the stream will be decoded or encoded with. It defaults to locale.getencoding().

errors determines the strictness of encoding and decoding (see help(codecs.Codec) or the documentation for codecs.register) and defaults to "strict".

newline controls how line endings are handled. It can be None, '', '\n', '\r', and '\r\n'. It works as follows:

  • On input, if newline is None, universal newlines mode is enabled. Lines in the input can end in '\n', '\r', or '\r\n', and these are translated into '\n' before being returned to the caller. If it is '', universal newline mode is enabled, but line endings are returned to the caller untranslated. If it has any of the other legal values, input lines are only terminated by the given string, and the line ending is returned to the caller untranslated.

  • On output, if newline is None, any '\n' characters written are translated to the system default line separator, os.linesep. If newline is '' or '\n', no translation takes place. If newline is any of the other legal values, any '\n' characters written are translated to the given string.

If line_buffering is True, a call to flush is implied when a call to write contains a newline character.

Inherited Members
_io.TextIOWrapper
TextIOWrapper
detach
reconfigure
write
read
readline
flush
close
fileno
seekable
readable
writable
isatty
seek
tell
truncate
encoding
buffer
line_buffering
write_through
name
closed
newlines
errors
_io._IOBase
readlines
writelines
class FileBinaryRead(_io.BufferedReader):
44class FileBinaryRead(io.BufferedReader):
45    pass

Create a new buffered reader using the given readable raw IO object.

Inherited Members
_io.BufferedReader
BufferedReader
detach
flush
close
seekable
readable
fileno
isatty
read
peek
read1
readinto
readinto1
readline
seek
tell
truncate
raw
closed
name
mode
_io._BufferedIOBase
write
_io._IOBase
writable
readlines
writelines
class FileBinaryWrite(_io.BufferedWriter):
48class FileBinaryWrite(io.BufferedWriter):
49    pass

A buffer for a writeable sequential RawIO object.

The constructor creates a BufferedWriter for the given writeable raw stream. If the buffer_size is not given, it defaults to DEFAULT_BUFFER_SIZE.

Inherited Members
_io.BufferedWriter
BufferedWriter
close
detach
seekable
writable
fileno
isatty
write
truncate
flush
seek
tell
raw
closed
name
mode
_io._BufferedIOBase
read
read1
readinto
readinto1
_io._IOBase
readable
readline
readlines
writelines
class CallbackParam(click.core.Parameter):
52class CallbackParam(click.Parameter):
53    pass

A parameter to a command comes in two versions: they are either Option\s or Argument\s. Other subclasses are currently not supported by design as some of the internals for parsing are intentionally not finalized.

Some settings are supported by both options and arguments.

Parameters
  • param_decls: the parameter declarations for this option or argument. This is a list of flags or argument names.
  • type: the type that should be used. Either a ParamType or a Python type. The latter is converted into the former automatically if supported.
  • required: controls if this is optional or not.
  • default: the default value if omitted. This can also be a callable, in which case it's invoked when the default is needed without any arguments.
  • callback: A function to further process or validate the value after type conversion. It is called as f(ctx, param, value) and must return the value. It is called for all sources, including prompts.
  • nargs: the number of arguments to match. If not 1 the return value is a tuple instead of single value. The default for nargs is 1 (except if the type is a tuple, then it's the arity of the tuple). If nargs=-1, all remaining parameters are collected.
  • metavar: how the value is represented in the help page.
  • expose_value: if this is True then the value is passed onwards to the command callback and stored on the context, otherwise it's skipped.
  • is_eager: eager values are processed before non eager ones. This should not be set for arguments or it will inverse the order of processing.
  • envvar: a string or list of strings that are environment variables that should be checked.
  • shell_complete: A function that returns custom shell completions. Used instead of the param's type completion if given. Takes ctx, param, incomplete and must return a list of ~click.shell_completion.CompletionItem or a list of strings.

Changed in version 8.0: process_value validates required parameters and bounded nargs, and invokes the parameter callback before returning the value. This allows the callback to validate prompts. full_process_value is removed.

Changed in version 8.0: autocompletion is renamed to shell_complete and has new semantics described above. The old name is deprecated and will be removed in 8.1, until then it will be wrapped to match the new requirements.

Changed in version 8.0: For multiple=True, nargs>1, the default must be a list of tuples.

Changed in version 8.0: Setting a default is no longer required for nargs>1, it will default to None. multiple=True or nargs=-1 will default to ().

Changed in version 7.1: Empty environment variables are ignored rather than taking the empty string value. This makes it possible for scripts to clear variables if they can't unset them.

Changed in version 2.0: Changed signature for parameter callback to also be passed the parameter. The old callback format will still work, but it will raise a warning to give you a chance to migrate the code easier.

Inherited Members
click.core.Parameter
Parameter
param_type_name
name
opts
secondary_opts
type
required
callback
nargs
multiple
expose_value
default
is_eager
metavar
envvar
to_info_dict
human_readable_name
make_metavar
get_default
add_to_parser
consume_value
type_cast_value
value_is_missing
process_value
resolve_envvar_value
value_from_envvar
handle_parse_result
get_help_record
get_usage_pieces
get_error_hint
shell_complete
class DefaultPlaceholder:
56class DefaultPlaceholder:
57    """
58    You shouldn't use this class directly.
59
60    It's used internally to recognize when a default value has been overwritten, even
61    if the new value is `None`.
62    """
63
64    def __init__(self, value: Any):
65        self.value = value
66
67    def __bool__(self) -> bool:
68        return bool(self.value)

You shouldn't use this class directly.

It's used internally to recognize when a default value has been overwritten, even if the new value is None.

DefaultPlaceholder(value: Any)
64    def __init__(self, value: Any):
65        self.value = value
value
def Default(value: ~DefaultType) -> ~DefaultType:
76def Default(value: DefaultType) -> DefaultType:
77    """
78    You shouldn't use this function directly.
79
80    It's used internally to recognize when a default value has been overwritten, even
81    if the new value is `None`.
82    """
83    return DefaultPlaceholder(value)  # type: ignore

You shouldn't use this function directly.

It's used internally to recognize when a default value has been overwritten, even if the new value is None.

class CommandInfo:
 86class CommandInfo:
 87    def __init__(
 88        self,
 89        name: Optional[str] = None,
 90        *,
 91        cls: Optional[Type["TyperCommand"]] = None,
 92        context_settings: Optional[Dict[Any, Any]] = None,
 93        callback: Optional[Callable[..., Any]] = None,
 94        help: Optional[str] = None,
 95        epilog: Optional[str] = None,
 96        short_help: Optional[str] = None,
 97        options_metavar: str = "[OPTIONS]",
 98        add_help_option: bool = True,
 99        no_args_is_help: bool = False,
100        hidden: bool = False,
101        deprecated: bool = False,
102        # Rich settings
103        rich_help_panel: Union[str, None] = None,
104    ):
105        self.name = name
106        self.cls = cls
107        self.context_settings = context_settings
108        self.callback = callback
109        self.help = help
110        self.epilog = epilog
111        self.short_help = short_help
112        self.options_metavar = options_metavar
113        self.add_help_option = add_help_option
114        self.no_args_is_help = no_args_is_help
115        self.hidden = hidden
116        self.deprecated = deprecated
117        # Rich settings
118        self.rich_help_panel = rich_help_panel
CommandInfo( name: Optional[str] = None, *, cls: Optional[Type[typer.core.TyperCommand]] = None, context_settings: Optional[Dict[Any, Any]] = None, callback: Optional[Callable[..., Any]] = None, help: Optional[str] = None, epilog: Optional[str] = None, short_help: Optional[str] = None, options_metavar: str = '[OPTIONS]', add_help_option: bool = True, no_args_is_help: bool = False, hidden: bool = False, deprecated: bool = False, rich_help_panel: Optional[str] = None)
 87    def __init__(
 88        self,
 89        name: Optional[str] = None,
 90        *,
 91        cls: Optional[Type["TyperCommand"]] = None,
 92        context_settings: Optional[Dict[Any, Any]] = None,
 93        callback: Optional[Callable[..., Any]] = None,
 94        help: Optional[str] = None,
 95        epilog: Optional[str] = None,
 96        short_help: Optional[str] = None,
 97        options_metavar: str = "[OPTIONS]",
 98        add_help_option: bool = True,
 99        no_args_is_help: bool = False,
100        hidden: bool = False,
101        deprecated: bool = False,
102        # Rich settings
103        rich_help_panel: Union[str, None] = None,
104    ):
105        self.name = name
106        self.cls = cls
107        self.context_settings = context_settings
108        self.callback = callback
109        self.help = help
110        self.epilog = epilog
111        self.short_help = short_help
112        self.options_metavar = options_metavar
113        self.add_help_option = add_help_option
114        self.no_args_is_help = no_args_is_help
115        self.hidden = hidden
116        self.deprecated = deprecated
117        # Rich settings
118        self.rich_help_panel = rich_help_panel
name
cls
context_settings
callback
help
epilog
short_help
options_metavar
add_help_option
no_args_is_help
hidden
deprecated
rich_help_panel
class TyperInfo:
121class TyperInfo:
122    def __init__(
123        self,
124        typer_instance: Optional["Typer"] = Default(None),
125        *,
126        name: Optional[str] = Default(None),
127        cls: Optional[Type["TyperGroup"]] = Default(None),
128        invoke_without_command: bool = Default(False),
129        no_args_is_help: bool = Default(False),
130        subcommand_metavar: Optional[str] = Default(None),
131        chain: bool = Default(False),
132        result_callback: Optional[Callable[..., Any]] = Default(None),
133        # Command
134        context_settings: Optional[Dict[Any, Any]] = Default(None),
135        callback: Optional[Callable[..., Any]] = Default(None),
136        help: Optional[str] = Default(None),
137        epilog: Optional[str] = Default(None),
138        short_help: Optional[str] = Default(None),
139        options_metavar: str = Default("[OPTIONS]"),
140        add_help_option: bool = Default(True),
141        hidden: bool = Default(False),
142        deprecated: bool = Default(False),
143        # Rich settings
144        rich_help_panel: Union[str, None] = Default(None),
145    ):
146        self.typer_instance = typer_instance
147        self.name = name
148        self.cls = cls
149        self.invoke_without_command = invoke_without_command
150        self.no_args_is_help = no_args_is_help
151        self.subcommand_metavar = subcommand_metavar
152        self.chain = chain
153        self.result_callback = result_callback
154        self.context_settings = context_settings
155        self.callback = callback
156        self.help = help
157        self.epilog = epilog
158        self.short_help = short_help
159        self.options_metavar = options_metavar
160        self.add_help_option = add_help_option
161        self.hidden = hidden
162        self.deprecated = deprecated
163        self.rich_help_panel = rich_help_panel
TyperInfo( typer_instance: Optional[typer.main.Typer] = <DefaultPlaceholder object>, *, name: Optional[str] = <DefaultPlaceholder object>, cls: Optional[Type[typer.core.TyperGroup]] = <DefaultPlaceholder object>, invoke_without_command: bool = <DefaultPlaceholder object>, no_args_is_help: bool = <DefaultPlaceholder object>, subcommand_metavar: Optional[str] = <DefaultPlaceholder object>, chain: bool = <DefaultPlaceholder object>, result_callback: Optional[Callable[..., Any]] = <DefaultPlaceholder object>, context_settings: Optional[Dict[Any, Any]] = <DefaultPlaceholder object>, callback: Optional[Callable[..., Any]] = <DefaultPlaceholder object>, help: Optional[str] = <DefaultPlaceholder object>, epilog: Optional[str] = <DefaultPlaceholder object>, short_help: Optional[str] = <DefaultPlaceholder object>, options_metavar: str = <DefaultPlaceholder object>, add_help_option: bool = <DefaultPlaceholder object>, hidden: bool = <DefaultPlaceholder object>, deprecated: bool = <DefaultPlaceholder object>, rich_help_panel: Optional[str] = <DefaultPlaceholder object>)
122    def __init__(
123        self,
124        typer_instance: Optional["Typer"] = Default(None),
125        *,
126        name: Optional[str] = Default(None),
127        cls: Optional[Type["TyperGroup"]] = Default(None),
128        invoke_without_command: bool = Default(False),
129        no_args_is_help: bool = Default(False),
130        subcommand_metavar: Optional[str] = Default(None),
131        chain: bool = Default(False),
132        result_callback: Optional[Callable[..., Any]] = Default(None),
133        # Command
134        context_settings: Optional[Dict[Any, Any]] = Default(None),
135        callback: Optional[Callable[..., Any]] = Default(None),
136        help: Optional[str] = Default(None),
137        epilog: Optional[str] = Default(None),
138        short_help: Optional[str] = Default(None),
139        options_metavar: str = Default("[OPTIONS]"),
140        add_help_option: bool = Default(True),
141        hidden: bool = Default(False),
142        deprecated: bool = Default(False),
143        # Rich settings
144        rich_help_panel: Union[str, None] = Default(None),
145    ):
146        self.typer_instance = typer_instance
147        self.name = name
148        self.cls = cls
149        self.invoke_without_command = invoke_without_command
150        self.no_args_is_help = no_args_is_help
151        self.subcommand_metavar = subcommand_metavar
152        self.chain = chain
153        self.result_callback = result_callback
154        self.context_settings = context_settings
155        self.callback = callback
156        self.help = help
157        self.epilog = epilog
158        self.short_help = short_help
159        self.options_metavar = options_metavar
160        self.add_help_option = add_help_option
161        self.hidden = hidden
162        self.deprecated = deprecated
163        self.rich_help_panel = rich_help_panel
typer_instance
name
cls
invoke_without_command
no_args_is_help
subcommand_metavar
chain
result_callback
context_settings
callback
help
epilog
short_help
options_metavar
add_help_option
hidden
deprecated
rich_help_panel
class ParameterInfo:
166class ParameterInfo:
167    def __init__(
168        self,
169        *,
170        default: Optional[Any] = None,
171        param_decls: Optional[Sequence[str]] = None,
172        callback: Optional[Callable[..., Any]] = None,
173        metavar: Optional[str] = None,
174        expose_value: bool = True,
175        is_eager: bool = False,
176        envvar: Optional[Union[str, List[str]]] = None,
177        shell_complete: Optional[
178            Callable[
179                [click.Context, click.Parameter, str],
180                Union[List["click.shell_completion.CompletionItem"], List[str]],
181            ]
182        ] = None,
183        autocompletion: Optional[Callable[..., Any]] = None,
184        default_factory: Optional[Callable[[], Any]] = None,
185        # Custom type
186        parser: Optional[Callable[[str], Any]] = None,
187        click_type: Optional[click.ParamType] = None,
188        # TyperArgument
189        show_default: Union[bool, str] = True,
190        show_choices: bool = True,
191        show_envvar: bool = True,
192        help: Optional[str] = None,
193        hidden: bool = False,
194        # Choice
195        case_sensitive: bool = True,
196        # Numbers
197        min: Optional[Union[int, float]] = None,
198        max: Optional[Union[int, float]] = None,
199        clamp: bool = False,
200        # DateTime
201        formats: Optional[List[str]] = None,
202        # File
203        mode: Optional[str] = None,
204        encoding: Optional[str] = None,
205        errors: Optional[str] = "strict",
206        lazy: Optional[bool] = None,
207        atomic: bool = False,
208        # Path
209        exists: bool = False,
210        file_okay: bool = True,
211        dir_okay: bool = True,
212        writable: bool = False,
213        readable: bool = True,
214        resolve_path: bool = False,
215        allow_dash: bool = False,
216        path_type: Union[None, Type[str], Type[bytes]] = None,
217        # Rich settings
218        rich_help_panel: Union[str, None] = None,
219    ):
220        # Check if user has provided multiple custom parsers
221        if parser and click_type:
222            raise ValueError(
223                "Multiple custom type parsers provided. "
224                "`parser` and `click_type` may not both be provided."
225            )
226
227        self.default = default
228        self.param_decls = param_decls
229        self.callback = callback
230        self.metavar = metavar
231        self.expose_value = expose_value
232        self.is_eager = is_eager
233        self.envvar = envvar
234        self.shell_complete = shell_complete
235        self.autocompletion = autocompletion
236        self.default_factory = default_factory
237        # Custom type
238        self.parser = parser
239        self.click_type = click_type
240        # TyperArgument
241        self.show_default = show_default
242        self.show_choices = show_choices
243        self.show_envvar = show_envvar
244        self.help = help
245        self.hidden = hidden
246        # Choice
247        self.case_sensitive = case_sensitive
248        # Numbers
249        self.min = min
250        self.max = max
251        self.clamp = clamp
252        # DateTime
253        self.formats = formats
254        # File
255        self.mode = mode
256        self.encoding = encoding
257        self.errors = errors
258        self.lazy = lazy
259        self.atomic = atomic
260        # Path
261        self.exists = exists
262        self.file_okay = file_okay
263        self.dir_okay = dir_okay
264        self.writable = writable
265        self.readable = readable
266        self.resolve_path = resolve_path
267        self.allow_dash = allow_dash
268        self.path_type = path_type
269        # Rich settings
270        self.rich_help_panel = rich_help_panel
ParameterInfo( *, default: Optional[Any] = None, param_decls: Optional[Sequence[str]] = None, 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)
167    def __init__(
168        self,
169        *,
170        default: Optional[Any] = None,
171        param_decls: Optional[Sequence[str]] = None,
172        callback: Optional[Callable[..., Any]] = None,
173        metavar: Optional[str] = None,
174        expose_value: bool = True,
175        is_eager: bool = False,
176        envvar: Optional[Union[str, List[str]]] = None,
177        shell_complete: Optional[
178            Callable[
179                [click.Context, click.Parameter, str],
180                Union[List["click.shell_completion.CompletionItem"], List[str]],
181            ]
182        ] = None,
183        autocompletion: Optional[Callable[..., Any]] = None,
184        default_factory: Optional[Callable[[], Any]] = None,
185        # Custom type
186        parser: Optional[Callable[[str], Any]] = None,
187        click_type: Optional[click.ParamType] = None,
188        # TyperArgument
189        show_default: Union[bool, str] = True,
190        show_choices: bool = True,
191        show_envvar: bool = True,
192        help: Optional[str] = None,
193        hidden: bool = False,
194        # Choice
195        case_sensitive: bool = True,
196        # Numbers
197        min: Optional[Union[int, float]] = None,
198        max: Optional[Union[int, float]] = None,
199        clamp: bool = False,
200        # DateTime
201        formats: Optional[List[str]] = None,
202        # File
203        mode: Optional[str] = None,
204        encoding: Optional[str] = None,
205        errors: Optional[str] = "strict",
206        lazy: Optional[bool] = None,
207        atomic: bool = False,
208        # Path
209        exists: bool = False,
210        file_okay: bool = True,
211        dir_okay: bool = True,
212        writable: bool = False,
213        readable: bool = True,
214        resolve_path: bool = False,
215        allow_dash: bool = False,
216        path_type: Union[None, Type[str], Type[bytes]] = None,
217        # Rich settings
218        rich_help_panel: Union[str, None] = None,
219    ):
220        # Check if user has provided multiple custom parsers
221        if parser and click_type:
222            raise ValueError(
223                "Multiple custom type parsers provided. "
224                "`parser` and `click_type` may not both be provided."
225            )
226
227        self.default = default
228        self.param_decls = param_decls
229        self.callback = callback
230        self.metavar = metavar
231        self.expose_value = expose_value
232        self.is_eager = is_eager
233        self.envvar = envvar
234        self.shell_complete = shell_complete
235        self.autocompletion = autocompletion
236        self.default_factory = default_factory
237        # Custom type
238        self.parser = parser
239        self.click_type = click_type
240        # TyperArgument
241        self.show_default = show_default
242        self.show_choices = show_choices
243        self.show_envvar = show_envvar
244        self.help = help
245        self.hidden = hidden
246        # Choice
247        self.case_sensitive = case_sensitive
248        # Numbers
249        self.min = min
250        self.max = max
251        self.clamp = clamp
252        # DateTime
253        self.formats = formats
254        # File
255        self.mode = mode
256        self.encoding = encoding
257        self.errors = errors
258        self.lazy = lazy
259        self.atomic = atomic
260        # Path
261        self.exists = exists
262        self.file_okay = file_okay
263        self.dir_okay = dir_okay
264        self.writable = writable
265        self.readable = readable
266        self.resolve_path = resolve_path
267        self.allow_dash = allow_dash
268        self.path_type = path_type
269        # Rich settings
270        self.rich_help_panel = rich_help_panel
default
param_decls
callback
metavar
expose_value
is_eager
envvar
shell_complete
autocompletion
default_factory
parser
click_type
show_default
show_choices
show_envvar
help
hidden
case_sensitive
min
max
clamp
formats
mode
encoding
errors
lazy
atomic
exists
file_okay
dir_okay
writable
readable
resolve_path
allow_dash
path_type
rich_help_panel
class OptionInfo(ParameterInfo):
273class OptionInfo(ParameterInfo):
274    def __init__(
275        self,
276        *,
277        # ParameterInfo
278        default: Optional[Any] = None,
279        param_decls: Optional[Sequence[str]] = None,
280        callback: Optional[Callable[..., Any]] = None,
281        metavar: Optional[str] = None,
282        expose_value: bool = True,
283        is_eager: bool = False,
284        envvar: Optional[Union[str, List[str]]] = None,
285        shell_complete: Optional[
286            Callable[
287                [click.Context, click.Parameter, str],
288                Union[List["click.shell_completion.CompletionItem"], List[str]],
289            ]
290        ] = None,
291        autocompletion: Optional[Callable[..., Any]] = None,
292        default_factory: Optional[Callable[[], Any]] = None,
293        # Custom type
294        parser: Optional[Callable[[str], Any]] = None,
295        click_type: Optional[click.ParamType] = None,
296        # Option
297        show_default: Union[bool, str] = True,
298        prompt: Union[bool, str] = False,
299        confirmation_prompt: bool = False,
300        prompt_required: bool = True,
301        hide_input: bool = False,
302        is_flag: Optional[bool] = None,
303        flag_value: Optional[Any] = None,
304        count: bool = False,
305        allow_from_autoenv: bool = True,
306        help: Optional[str] = None,
307        hidden: bool = False,
308        show_choices: bool = True,
309        show_envvar: bool = True,
310        # Choice
311        case_sensitive: bool = True,
312        # Numbers
313        min: Optional[Union[int, float]] = None,
314        max: Optional[Union[int, float]] = None,
315        clamp: bool = False,
316        # DateTime
317        formats: Optional[List[str]] = None,
318        # File
319        mode: Optional[str] = None,
320        encoding: Optional[str] = None,
321        errors: Optional[str] = "strict",
322        lazy: Optional[bool] = None,
323        atomic: bool = False,
324        # Path
325        exists: bool = False,
326        file_okay: bool = True,
327        dir_okay: bool = True,
328        writable: bool = False,
329        readable: bool = True,
330        resolve_path: bool = False,
331        allow_dash: bool = False,
332        path_type: Union[None, Type[str], Type[bytes]] = None,
333        # Rich settings
334        rich_help_panel: Union[str, None] = None,
335    ):
336        super().__init__(
337            default=default,
338            param_decls=param_decls,
339            callback=callback,
340            metavar=metavar,
341            expose_value=expose_value,
342            is_eager=is_eager,
343            envvar=envvar,
344            shell_complete=shell_complete,
345            autocompletion=autocompletion,
346            default_factory=default_factory,
347            # Custom type
348            parser=parser,
349            click_type=click_type,
350            # TyperArgument
351            show_default=show_default,
352            show_choices=show_choices,
353            show_envvar=show_envvar,
354            help=help,
355            hidden=hidden,
356            # Choice
357            case_sensitive=case_sensitive,
358            # Numbers
359            min=min,
360            max=max,
361            clamp=clamp,
362            # DateTime
363            formats=formats,
364            # File
365            mode=mode,
366            encoding=encoding,
367            errors=errors,
368            lazy=lazy,
369            atomic=atomic,
370            # Path
371            exists=exists,
372            file_okay=file_okay,
373            dir_okay=dir_okay,
374            writable=writable,
375            readable=readable,
376            resolve_path=resolve_path,
377            allow_dash=allow_dash,
378            path_type=path_type,
379            # Rich settings
380            rich_help_panel=rich_help_panel,
381        )
382        self.prompt = prompt
383        self.confirmation_prompt = confirmation_prompt
384        self.prompt_required = prompt_required
385        self.hide_input = hide_input
386        self.is_flag = is_flag
387        self.flag_value = flag_value
388        self.count = count
389        self.allow_from_autoenv = allow_from_autoenv
OptionInfo( *, default: Optional[Any] = None, param_decls: Optional[Sequence[str]] = None, 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)
274    def __init__(
275        self,
276        *,
277        # ParameterInfo
278        default: Optional[Any] = None,
279        param_decls: Optional[Sequence[str]] = None,
280        callback: Optional[Callable[..., Any]] = None,
281        metavar: Optional[str] = None,
282        expose_value: bool = True,
283        is_eager: bool = False,
284        envvar: Optional[Union[str, List[str]]] = None,
285        shell_complete: Optional[
286            Callable[
287                [click.Context, click.Parameter, str],
288                Union[List["click.shell_completion.CompletionItem"], List[str]],
289            ]
290        ] = None,
291        autocompletion: Optional[Callable[..., Any]] = None,
292        default_factory: Optional[Callable[[], Any]] = None,
293        # Custom type
294        parser: Optional[Callable[[str], Any]] = None,
295        click_type: Optional[click.ParamType] = None,
296        # Option
297        show_default: Union[bool, str] = True,
298        prompt: Union[bool, str] = False,
299        confirmation_prompt: bool = False,
300        prompt_required: bool = True,
301        hide_input: bool = False,
302        is_flag: Optional[bool] = None,
303        flag_value: Optional[Any] = None,
304        count: bool = False,
305        allow_from_autoenv: bool = True,
306        help: Optional[str] = None,
307        hidden: bool = False,
308        show_choices: bool = True,
309        show_envvar: bool = True,
310        # Choice
311        case_sensitive: bool = True,
312        # Numbers
313        min: Optional[Union[int, float]] = None,
314        max: Optional[Union[int, float]] = None,
315        clamp: bool = False,
316        # DateTime
317        formats: Optional[List[str]] = None,
318        # File
319        mode: Optional[str] = None,
320        encoding: Optional[str] = None,
321        errors: Optional[str] = "strict",
322        lazy: Optional[bool] = None,
323        atomic: bool = False,
324        # Path
325        exists: bool = False,
326        file_okay: bool = True,
327        dir_okay: bool = True,
328        writable: bool = False,
329        readable: bool = True,
330        resolve_path: bool = False,
331        allow_dash: bool = False,
332        path_type: Union[None, Type[str], Type[bytes]] = None,
333        # Rich settings
334        rich_help_panel: Union[str, None] = None,
335    ):
336        super().__init__(
337            default=default,
338            param_decls=param_decls,
339            callback=callback,
340            metavar=metavar,
341            expose_value=expose_value,
342            is_eager=is_eager,
343            envvar=envvar,
344            shell_complete=shell_complete,
345            autocompletion=autocompletion,
346            default_factory=default_factory,
347            # Custom type
348            parser=parser,
349            click_type=click_type,
350            # TyperArgument
351            show_default=show_default,
352            show_choices=show_choices,
353            show_envvar=show_envvar,
354            help=help,
355            hidden=hidden,
356            # Choice
357            case_sensitive=case_sensitive,
358            # Numbers
359            min=min,
360            max=max,
361            clamp=clamp,
362            # DateTime
363            formats=formats,
364            # File
365            mode=mode,
366            encoding=encoding,
367            errors=errors,
368            lazy=lazy,
369            atomic=atomic,
370            # Path
371            exists=exists,
372            file_okay=file_okay,
373            dir_okay=dir_okay,
374            writable=writable,
375            readable=readable,
376            resolve_path=resolve_path,
377            allow_dash=allow_dash,
378            path_type=path_type,
379            # Rich settings
380            rich_help_panel=rich_help_panel,
381        )
382        self.prompt = prompt
383        self.confirmation_prompt = confirmation_prompt
384        self.prompt_required = prompt_required
385        self.hide_input = hide_input
386        self.is_flag = is_flag
387        self.flag_value = flag_value
388        self.count = count
389        self.allow_from_autoenv = allow_from_autoenv
prompt
confirmation_prompt
prompt_required
hide_input
is_flag
flag_value
count
allow_from_autoenv
class ArgumentInfo(ParameterInfo):
392class ArgumentInfo(ParameterInfo):
393    def __init__(
394        self,
395        *,
396        # ParameterInfo
397        default: Optional[Any] = None,
398        param_decls: Optional[Sequence[str]] = None,
399        callback: Optional[Callable[..., Any]] = None,
400        metavar: Optional[str] = None,
401        expose_value: bool = True,
402        is_eager: bool = False,
403        envvar: Optional[Union[str, List[str]]] = None,
404        shell_complete: Optional[
405            Callable[
406                [click.Context, click.Parameter, str],
407                Union[List["click.shell_completion.CompletionItem"], List[str]],
408            ]
409        ] = None,
410        autocompletion: Optional[Callable[..., Any]] = None,
411        default_factory: Optional[Callable[[], Any]] = None,
412        # Custom type
413        parser: Optional[Callable[[str], Any]] = None,
414        click_type: Optional[click.ParamType] = None,
415        # TyperArgument
416        show_default: Union[bool, str] = True,
417        show_choices: bool = True,
418        show_envvar: bool = True,
419        help: Optional[str] = None,
420        hidden: bool = False,
421        # Choice
422        case_sensitive: bool = True,
423        # Numbers
424        min: Optional[Union[int, float]] = None,
425        max: Optional[Union[int, float]] = None,
426        clamp: bool = False,
427        # DateTime
428        formats: Optional[List[str]] = None,
429        # File
430        mode: Optional[str] = None,
431        encoding: Optional[str] = None,
432        errors: Optional[str] = "strict",
433        lazy: Optional[bool] = None,
434        atomic: bool = False,
435        # Path
436        exists: bool = False,
437        file_okay: bool = True,
438        dir_okay: bool = True,
439        writable: bool = False,
440        readable: bool = True,
441        resolve_path: bool = False,
442        allow_dash: bool = False,
443        path_type: Union[None, Type[str], Type[bytes]] = None,
444        # Rich settings
445        rich_help_panel: Union[str, None] = None,
446    ):
447        super().__init__(
448            default=default,
449            param_decls=param_decls,
450            callback=callback,
451            metavar=metavar,
452            expose_value=expose_value,
453            is_eager=is_eager,
454            envvar=envvar,
455            shell_complete=shell_complete,
456            autocompletion=autocompletion,
457            default_factory=default_factory,
458            # Custom type
459            parser=parser,
460            click_type=click_type,
461            # TyperArgument
462            show_default=show_default,
463            show_choices=show_choices,
464            show_envvar=show_envvar,
465            help=help,
466            hidden=hidden,
467            # Choice
468            case_sensitive=case_sensitive,
469            # Numbers
470            min=min,
471            max=max,
472            clamp=clamp,
473            # DateTime
474            formats=formats,
475            # File
476            mode=mode,
477            encoding=encoding,
478            errors=errors,
479            lazy=lazy,
480            atomic=atomic,
481            # Path
482            exists=exists,
483            file_okay=file_okay,
484            dir_okay=dir_okay,
485            writable=writable,
486            readable=readable,
487            resolve_path=resolve_path,
488            allow_dash=allow_dash,
489            path_type=path_type,
490            # Rich settings
491            rich_help_panel=rich_help_panel,
492        )
ArgumentInfo( *, default: Optional[Any] = None, param_decls: Optional[Sequence[str]] = None, 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)
393    def __init__(
394        self,
395        *,
396        # ParameterInfo
397        default: Optional[Any] = None,
398        param_decls: Optional[Sequence[str]] = None,
399        callback: Optional[Callable[..., Any]] = None,
400        metavar: Optional[str] = None,
401        expose_value: bool = True,
402        is_eager: bool = False,
403        envvar: Optional[Union[str, List[str]]] = None,
404        shell_complete: Optional[
405            Callable[
406                [click.Context, click.Parameter, str],
407                Union[List["click.shell_completion.CompletionItem"], List[str]],
408            ]
409        ] = None,
410        autocompletion: Optional[Callable[..., Any]] = None,
411        default_factory: Optional[Callable[[], Any]] = None,
412        # Custom type
413        parser: Optional[Callable[[str], Any]] = None,
414        click_type: Optional[click.ParamType] = None,
415        # TyperArgument
416        show_default: Union[bool, str] = True,
417        show_choices: bool = True,
418        show_envvar: bool = True,
419        help: Optional[str] = None,
420        hidden: bool = False,
421        # Choice
422        case_sensitive: bool = True,
423        # Numbers
424        min: Optional[Union[int, float]] = None,
425        max: Optional[Union[int, float]] = None,
426        clamp: bool = False,
427        # DateTime
428        formats: Optional[List[str]] = None,
429        # File
430        mode: Optional[str] = None,
431        encoding: Optional[str] = None,
432        errors: Optional[str] = "strict",
433        lazy: Optional[bool] = None,
434        atomic: bool = False,
435        # Path
436        exists: bool = False,
437        file_okay: bool = True,
438        dir_okay: bool = True,
439        writable: bool = False,
440        readable: bool = True,
441        resolve_path: bool = False,
442        allow_dash: bool = False,
443        path_type: Union[None, Type[str], Type[bytes]] = None,
444        # Rich settings
445        rich_help_panel: Union[str, None] = None,
446    ):
447        super().__init__(
448            default=default,
449            param_decls=param_decls,
450            callback=callback,
451            metavar=metavar,
452            expose_value=expose_value,
453            is_eager=is_eager,
454            envvar=envvar,
455            shell_complete=shell_complete,
456            autocompletion=autocompletion,
457            default_factory=default_factory,
458            # Custom type
459            parser=parser,
460            click_type=click_type,
461            # TyperArgument
462            show_default=show_default,
463            show_choices=show_choices,
464            show_envvar=show_envvar,
465            help=help,
466            hidden=hidden,
467            # Choice
468            case_sensitive=case_sensitive,
469            # Numbers
470            min=min,
471            max=max,
472            clamp=clamp,
473            # DateTime
474            formats=formats,
475            # File
476            mode=mode,
477            encoding=encoding,
478            errors=errors,
479            lazy=lazy,
480            atomic=atomic,
481            # Path
482            exists=exists,
483            file_okay=file_okay,
484            dir_okay=dir_okay,
485            writable=writable,
486            readable=readable,
487            resolve_path=resolve_path,
488            allow_dash=allow_dash,
489            path_type=path_type,
490            # Rich settings
491            rich_help_panel=rich_help_panel,
492        )
class ParamMeta:
495class ParamMeta:
496    empty = inspect.Parameter.empty
497
498    def __init__(
499        self,
500        *,
501        name: str,
502        default: Any = inspect.Parameter.empty,
503        annotation: Any = inspect.Parameter.empty,
504    ) -> None:
505        self.name = name
506        self.default = default
507        self.annotation = annotation
ParamMeta(*, name: str, default: Any, annotation: Any)
498    def __init__(
499        self,
500        *,
501        name: str,
502        default: Any = inspect.Parameter.empty,
503        annotation: Any = inspect.Parameter.empty,
504    ) -> None:
505        self.name = name
506        self.default = default
507        self.annotation = annotation
empty
name
default
annotation
class DeveloperExceptionConfig:
510class DeveloperExceptionConfig:
511    def __init__(
512        self,
513        *,
514        pretty_exceptions_enable: bool = True,
515        pretty_exceptions_show_locals: bool = True,
516        pretty_exceptions_short: bool = True,
517    ) -> None:
518        self.pretty_exceptions_enable = pretty_exceptions_enable
519        self.pretty_exceptions_show_locals = pretty_exceptions_show_locals
520        self.pretty_exceptions_short = pretty_exceptions_short
DeveloperExceptionConfig( *, pretty_exceptions_enable: bool = True, pretty_exceptions_show_locals: bool = True, pretty_exceptions_short: bool = True)
511    def __init__(
512        self,
513        *,
514        pretty_exceptions_enable: bool = True,
515        pretty_exceptions_show_locals: bool = True,
516        pretty_exceptions_short: bool = True,
517    ) -> None:
518        self.pretty_exceptions_enable = pretty_exceptions_enable
519        self.pretty_exceptions_show_locals = pretty_exceptions_show_locals
520        self.pretty_exceptions_short = pretty_exceptions_short
pretty_exceptions_enable
pretty_exceptions_show_locals
pretty_exceptions_short