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        # Note that shell_complete is not fully supported and will be removed in future versions
177        # TODO: Remove shell_complete in a future version (after 0.16.0)
178        shell_complete: Optional[
179            Callable[
180                [click.Context, click.Parameter, str],
181                Union[List["click.shell_completion.CompletionItem"], List[str]],
182            ]
183        ] = None,
184        autocompletion: Optional[Callable[..., Any]] = None,
185        default_factory: Optional[Callable[[], Any]] = None,
186        # Custom type
187        parser: Optional[Callable[[str], Any]] = None,
188        click_type: Optional[click.ParamType] = None,
189        # TyperArgument
190        show_default: Union[bool, str] = True,
191        show_choices: bool = True,
192        show_envvar: bool = True,
193        help: Optional[str] = None,
194        hidden: bool = False,
195        # Choice
196        case_sensitive: bool = True,
197        # Numbers
198        min: Optional[Union[int, float]] = None,
199        max: Optional[Union[int, float]] = None,
200        clamp: bool = False,
201        # DateTime
202        formats: Optional[List[str]] = None,
203        # File
204        mode: Optional[str] = None,
205        encoding: Optional[str] = None,
206        errors: Optional[str] = "strict",
207        lazy: Optional[bool] = None,
208        atomic: bool = False,
209        # Path
210        exists: bool = False,
211        file_okay: bool = True,
212        dir_okay: bool = True,
213        writable: bool = False,
214        readable: bool = True,
215        resolve_path: bool = False,
216        allow_dash: bool = False,
217        path_type: Union[None, Type[str], Type[bytes]] = None,
218        # Rich settings
219        rich_help_panel: Union[str, None] = None,
220    ):
221        # Check if user has provided multiple custom parsers
222        if parser and click_type:
223            raise ValueError(
224                "Multiple custom type parsers provided. "
225                "`parser` and `click_type` may not both be provided."
226            )
227
228        self.default = default
229        self.param_decls = param_decls
230        self.callback = callback
231        self.metavar = metavar
232        self.expose_value = expose_value
233        self.is_eager = is_eager
234        self.envvar = envvar
235        self.shell_complete = shell_complete
236        self.autocompletion = autocompletion
237        self.default_factory = default_factory
238        # Custom type
239        self.parser = parser
240        self.click_type = click_type
241        # TyperArgument
242        self.show_default = show_default
243        self.show_choices = show_choices
244        self.show_envvar = show_envvar
245        self.help = help
246        self.hidden = hidden
247        # Choice
248        self.case_sensitive = case_sensitive
249        # Numbers
250        self.min = min
251        self.max = max
252        self.clamp = clamp
253        # DateTime
254        self.formats = formats
255        # File
256        self.mode = mode
257        self.encoding = encoding
258        self.errors = errors
259        self.lazy = lazy
260        self.atomic = atomic
261        # Path
262        self.exists = exists
263        self.file_okay = file_okay
264        self.dir_okay = dir_okay
265        self.writable = writable
266        self.readable = readable
267        self.resolve_path = resolve_path
268        self.allow_dash = allow_dash
269        self.path_type = path_type
270        # Rich settings
271        self.rich_help_panel = rich_help_panel
272
273
274class OptionInfo(ParameterInfo):
275    def __init__(
276        self,
277        *,
278        # ParameterInfo
279        default: Optional[Any] = None,
280        param_decls: Optional[Sequence[str]] = None,
281        callback: Optional[Callable[..., Any]] = None,
282        metavar: Optional[str] = None,
283        expose_value: bool = True,
284        is_eager: bool = False,
285        envvar: Optional[Union[str, List[str]]] = None,
286        # Note that shell_complete is not fully supported and will be removed in future versions
287        # TODO: Remove shell_complete in a future version (after 0.16.0)
288        shell_complete: Optional[
289            Callable[
290                [click.Context, click.Parameter, str],
291                Union[List["click.shell_completion.CompletionItem"], List[str]],
292            ]
293        ] = None,
294        autocompletion: Optional[Callable[..., Any]] = None,
295        default_factory: Optional[Callable[[], Any]] = None,
296        # Custom type
297        parser: Optional[Callable[[str], Any]] = None,
298        click_type: Optional[click.ParamType] = None,
299        # Option
300        show_default: Union[bool, str] = True,
301        prompt: Union[bool, str] = False,
302        confirmation_prompt: bool = False,
303        prompt_required: bool = True,
304        hide_input: bool = False,
305        # TODO: remove is_flag and flag_value in a future release
306        is_flag: Optional[bool] = None,
307        flag_value: Optional[Any] = None,
308        count: bool = False,
309        allow_from_autoenv: bool = True,
310        help: Optional[str] = None,
311        hidden: bool = False,
312        show_choices: bool = True,
313        show_envvar: bool = True,
314        # Choice
315        case_sensitive: bool = True,
316        # Numbers
317        min: Optional[Union[int, float]] = None,
318        max: Optional[Union[int, float]] = None,
319        clamp: bool = False,
320        # DateTime
321        formats: Optional[List[str]] = None,
322        # File
323        mode: Optional[str] = None,
324        encoding: Optional[str] = None,
325        errors: Optional[str] = "strict",
326        lazy: Optional[bool] = None,
327        atomic: bool = False,
328        # Path
329        exists: bool = False,
330        file_okay: bool = True,
331        dir_okay: bool = True,
332        writable: bool = False,
333        readable: bool = True,
334        resolve_path: bool = False,
335        allow_dash: bool = False,
336        path_type: Union[None, Type[str], Type[bytes]] = None,
337        # Rich settings
338        rich_help_panel: Union[str, None] = None,
339    ):
340        super().__init__(
341            default=default,
342            param_decls=param_decls,
343            callback=callback,
344            metavar=metavar,
345            expose_value=expose_value,
346            is_eager=is_eager,
347            envvar=envvar,
348            shell_complete=shell_complete,
349            autocompletion=autocompletion,
350            default_factory=default_factory,
351            # Custom type
352            parser=parser,
353            click_type=click_type,
354            # TyperArgument
355            show_default=show_default,
356            show_choices=show_choices,
357            show_envvar=show_envvar,
358            help=help,
359            hidden=hidden,
360            # Choice
361            case_sensitive=case_sensitive,
362            # Numbers
363            min=min,
364            max=max,
365            clamp=clamp,
366            # DateTime
367            formats=formats,
368            # File
369            mode=mode,
370            encoding=encoding,
371            errors=errors,
372            lazy=lazy,
373            atomic=atomic,
374            # Path
375            exists=exists,
376            file_okay=file_okay,
377            dir_okay=dir_okay,
378            writable=writable,
379            readable=readable,
380            resolve_path=resolve_path,
381            allow_dash=allow_dash,
382            path_type=path_type,
383            # Rich settings
384            rich_help_panel=rich_help_panel,
385        )
386        if is_flag is not None or flag_value is not None:
387            import warnings
388
389            warnings.warn(
390                "The 'is_flag' and 'flag_value' parameters are not supported by Typer "
391                "and will be removed entirely in a future release.",
392                DeprecationWarning,
393                stacklevel=2,
394            )
395        self.prompt = prompt
396        self.confirmation_prompt = confirmation_prompt
397        self.prompt_required = prompt_required
398        self.hide_input = hide_input
399        self.count = count
400        self.allow_from_autoenv = allow_from_autoenv
401
402
403class ArgumentInfo(ParameterInfo):
404    def __init__(
405        self,
406        *,
407        # ParameterInfo
408        default: Optional[Any] = None,
409        param_decls: Optional[Sequence[str]] = None,
410        callback: Optional[Callable[..., Any]] = None,
411        metavar: Optional[str] = None,
412        expose_value: bool = True,
413        is_eager: bool = False,
414        envvar: Optional[Union[str, List[str]]] = None,
415        # Note that shell_complete is not fully supported and will be removed in future versions
416        # TODO: Remove shell_complete in a future version (after 0.16.0)
417        shell_complete: Optional[
418            Callable[
419                [click.Context, click.Parameter, str],
420                Union[List["click.shell_completion.CompletionItem"], List[str]],
421            ]
422        ] = None,
423        autocompletion: Optional[Callable[..., Any]] = None,
424        default_factory: Optional[Callable[[], Any]] = None,
425        # Custom type
426        parser: Optional[Callable[[str], Any]] = None,
427        click_type: Optional[click.ParamType] = None,
428        # TyperArgument
429        show_default: Union[bool, str] = True,
430        show_choices: bool = True,
431        show_envvar: bool = True,
432        help: Optional[str] = None,
433        hidden: bool = False,
434        # Choice
435        case_sensitive: bool = True,
436        # Numbers
437        min: Optional[Union[int, float]] = None,
438        max: Optional[Union[int, float]] = None,
439        clamp: bool = False,
440        # DateTime
441        formats: Optional[List[str]] = None,
442        # File
443        mode: Optional[str] = None,
444        encoding: Optional[str] = None,
445        errors: Optional[str] = "strict",
446        lazy: Optional[bool] = None,
447        atomic: bool = False,
448        # Path
449        exists: bool = False,
450        file_okay: bool = True,
451        dir_okay: bool = True,
452        writable: bool = False,
453        readable: bool = True,
454        resolve_path: bool = False,
455        allow_dash: bool = False,
456        path_type: Union[None, Type[str], Type[bytes]] = None,
457        # Rich settings
458        rich_help_panel: Union[str, None] = None,
459    ):
460        super().__init__(
461            default=default,
462            param_decls=param_decls,
463            callback=callback,
464            metavar=metavar,
465            expose_value=expose_value,
466            is_eager=is_eager,
467            envvar=envvar,
468            shell_complete=shell_complete,
469            autocompletion=autocompletion,
470            default_factory=default_factory,
471            # Custom type
472            parser=parser,
473            click_type=click_type,
474            # TyperArgument
475            show_default=show_default,
476            show_choices=show_choices,
477            show_envvar=show_envvar,
478            help=help,
479            hidden=hidden,
480            # Choice
481            case_sensitive=case_sensitive,
482            # Numbers
483            min=min,
484            max=max,
485            clamp=clamp,
486            # DateTime
487            formats=formats,
488            # File
489            mode=mode,
490            encoding=encoding,
491            errors=errors,
492            lazy=lazy,
493            atomic=atomic,
494            # Path
495            exists=exists,
496            file_okay=file_okay,
497            dir_okay=dir_okay,
498            writable=writable,
499            readable=readable,
500            resolve_path=resolve_path,
501            allow_dash=allow_dash,
502            path_type=path_type,
503            # Rich settings
504            rich_help_panel=rich_help_panel,
505        )
506
507
508class ParamMeta:
509    empty = inspect.Parameter.empty
510
511    def __init__(
512        self,
513        *,
514        name: str,
515        default: Any = inspect.Parameter.empty,
516        annotation: Any = inspect.Parameter.empty,
517    ) -> None:
518        self.name = name
519        self.default = default
520        self.annotation = annotation
521
522
523class DeveloperExceptionConfig:
524    def __init__(
525        self,
526        *,
527        pretty_exceptions_enable: bool = True,
528        pretty_exceptions_show_locals: bool = True,
529        pretty_exceptions_short: bool = True,
530    ) -> None:
531        self.pretty_exceptions_enable = pretty_exceptions_enable
532        self.pretty_exceptions_show_locals = pretty_exceptions_show_locals
533        self.pretty_exceptions_short = pretty_exceptions_short
class NoneType:

The type of the None singleton.

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        # Note that shell_complete is not fully supported and will be removed in future versions
178        # TODO: Remove shell_complete in a future version (after 0.16.0)
179        shell_complete: Optional[
180            Callable[
181                [click.Context, click.Parameter, str],
182                Union[List["click.shell_completion.CompletionItem"], List[str]],
183            ]
184        ] = None,
185        autocompletion: Optional[Callable[..., Any]] = None,
186        default_factory: Optional[Callable[[], Any]] = None,
187        # Custom type
188        parser: Optional[Callable[[str], Any]] = None,
189        click_type: Optional[click.ParamType] = None,
190        # TyperArgument
191        show_default: Union[bool, str] = True,
192        show_choices: bool = True,
193        show_envvar: bool = True,
194        help: Optional[str] = None,
195        hidden: bool = False,
196        # Choice
197        case_sensitive: bool = True,
198        # Numbers
199        min: Optional[Union[int, float]] = None,
200        max: Optional[Union[int, float]] = None,
201        clamp: bool = False,
202        # DateTime
203        formats: Optional[List[str]] = None,
204        # File
205        mode: Optional[str] = None,
206        encoding: Optional[str] = None,
207        errors: Optional[str] = "strict",
208        lazy: Optional[bool] = None,
209        atomic: bool = False,
210        # Path
211        exists: bool = False,
212        file_okay: bool = True,
213        dir_okay: bool = True,
214        writable: bool = False,
215        readable: bool = True,
216        resolve_path: bool = False,
217        allow_dash: bool = False,
218        path_type: Union[None, Type[str], Type[bytes]] = None,
219        # Rich settings
220        rich_help_panel: Union[str, None] = None,
221    ):
222        # Check if user has provided multiple custom parsers
223        if parser and click_type:
224            raise ValueError(
225                "Multiple custom type parsers provided. "
226                "`parser` and `click_type` may not both be provided."
227            )
228
229        self.default = default
230        self.param_decls = param_decls
231        self.callback = callback
232        self.metavar = metavar
233        self.expose_value = expose_value
234        self.is_eager = is_eager
235        self.envvar = envvar
236        self.shell_complete = shell_complete
237        self.autocompletion = autocompletion
238        self.default_factory = default_factory
239        # Custom type
240        self.parser = parser
241        self.click_type = click_type
242        # TyperArgument
243        self.show_default = show_default
244        self.show_choices = show_choices
245        self.show_envvar = show_envvar
246        self.help = help
247        self.hidden = hidden
248        # Choice
249        self.case_sensitive = case_sensitive
250        # Numbers
251        self.min = min
252        self.max = max
253        self.clamp = clamp
254        # DateTime
255        self.formats = formats
256        # File
257        self.mode = mode
258        self.encoding = encoding
259        self.errors = errors
260        self.lazy = lazy
261        self.atomic = atomic
262        # Path
263        self.exists = exists
264        self.file_okay = file_okay
265        self.dir_okay = dir_okay
266        self.writable = writable
267        self.readable = readable
268        self.resolve_path = resolve_path
269        self.allow_dash = allow_dash
270        self.path_type = path_type
271        # Rich settings
272        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        # Note that shell_complete is not fully supported and will be removed in future versions
178        # TODO: Remove shell_complete in a future version (after 0.16.0)
179        shell_complete: Optional[
180            Callable[
181                [click.Context, click.Parameter, str],
182                Union[List["click.shell_completion.CompletionItem"], List[str]],
183            ]
184        ] = None,
185        autocompletion: Optional[Callable[..., Any]] = None,
186        default_factory: Optional[Callable[[], Any]] = None,
187        # Custom type
188        parser: Optional[Callable[[str], Any]] = None,
189        click_type: Optional[click.ParamType] = None,
190        # TyperArgument
191        show_default: Union[bool, str] = True,
192        show_choices: bool = True,
193        show_envvar: bool = True,
194        help: Optional[str] = None,
195        hidden: bool = False,
196        # Choice
197        case_sensitive: bool = True,
198        # Numbers
199        min: Optional[Union[int, float]] = None,
200        max: Optional[Union[int, float]] = None,
201        clamp: bool = False,
202        # DateTime
203        formats: Optional[List[str]] = None,
204        # File
205        mode: Optional[str] = None,
206        encoding: Optional[str] = None,
207        errors: Optional[str] = "strict",
208        lazy: Optional[bool] = None,
209        atomic: bool = False,
210        # Path
211        exists: bool = False,
212        file_okay: bool = True,
213        dir_okay: bool = True,
214        writable: bool = False,
215        readable: bool = True,
216        resolve_path: bool = False,
217        allow_dash: bool = False,
218        path_type: Union[None, Type[str], Type[bytes]] = None,
219        # Rich settings
220        rich_help_panel: Union[str, None] = None,
221    ):
222        # Check if user has provided multiple custom parsers
223        if parser and click_type:
224            raise ValueError(
225                "Multiple custom type parsers provided. "
226                "`parser` and `click_type` may not both be provided."
227            )
228
229        self.default = default
230        self.param_decls = param_decls
231        self.callback = callback
232        self.metavar = metavar
233        self.expose_value = expose_value
234        self.is_eager = is_eager
235        self.envvar = envvar
236        self.shell_complete = shell_complete
237        self.autocompletion = autocompletion
238        self.default_factory = default_factory
239        # Custom type
240        self.parser = parser
241        self.click_type = click_type
242        # TyperArgument
243        self.show_default = show_default
244        self.show_choices = show_choices
245        self.show_envvar = show_envvar
246        self.help = help
247        self.hidden = hidden
248        # Choice
249        self.case_sensitive = case_sensitive
250        # Numbers
251        self.min = min
252        self.max = max
253        self.clamp = clamp
254        # DateTime
255        self.formats = formats
256        # File
257        self.mode = mode
258        self.encoding = encoding
259        self.errors = errors
260        self.lazy = lazy
261        self.atomic = atomic
262        # Path
263        self.exists = exists
264        self.file_okay = file_okay
265        self.dir_okay = dir_okay
266        self.writable = writable
267        self.readable = readable
268        self.resolve_path = resolve_path
269        self.allow_dash = allow_dash
270        self.path_type = path_type
271        # Rich settings
272        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):
275class OptionInfo(ParameterInfo):
276    def __init__(
277        self,
278        *,
279        # ParameterInfo
280        default: Optional[Any] = None,
281        param_decls: Optional[Sequence[str]] = None,
282        callback: Optional[Callable[..., Any]] = None,
283        metavar: Optional[str] = None,
284        expose_value: bool = True,
285        is_eager: bool = False,
286        envvar: Optional[Union[str, List[str]]] = None,
287        # Note that shell_complete is not fully supported and will be removed in future versions
288        # TODO: Remove shell_complete in a future version (after 0.16.0)
289        shell_complete: Optional[
290            Callable[
291                [click.Context, click.Parameter, str],
292                Union[List["click.shell_completion.CompletionItem"], List[str]],
293            ]
294        ] = None,
295        autocompletion: Optional[Callable[..., Any]] = None,
296        default_factory: Optional[Callable[[], Any]] = None,
297        # Custom type
298        parser: Optional[Callable[[str], Any]] = None,
299        click_type: Optional[click.ParamType] = None,
300        # Option
301        show_default: Union[bool, str] = True,
302        prompt: Union[bool, str] = False,
303        confirmation_prompt: bool = False,
304        prompt_required: bool = True,
305        hide_input: bool = False,
306        # TODO: remove is_flag and flag_value in a future release
307        is_flag: Optional[bool] = None,
308        flag_value: Optional[Any] = None,
309        count: bool = False,
310        allow_from_autoenv: bool = True,
311        help: Optional[str] = None,
312        hidden: bool = False,
313        show_choices: bool = True,
314        show_envvar: bool = True,
315        # Choice
316        case_sensitive: bool = True,
317        # Numbers
318        min: Optional[Union[int, float]] = None,
319        max: Optional[Union[int, float]] = None,
320        clamp: bool = False,
321        # DateTime
322        formats: Optional[List[str]] = None,
323        # File
324        mode: Optional[str] = None,
325        encoding: Optional[str] = None,
326        errors: Optional[str] = "strict",
327        lazy: Optional[bool] = None,
328        atomic: bool = False,
329        # Path
330        exists: bool = False,
331        file_okay: bool = True,
332        dir_okay: bool = True,
333        writable: bool = False,
334        readable: bool = True,
335        resolve_path: bool = False,
336        allow_dash: bool = False,
337        path_type: Union[None, Type[str], Type[bytes]] = None,
338        # Rich settings
339        rich_help_panel: Union[str, None] = None,
340    ):
341        super().__init__(
342            default=default,
343            param_decls=param_decls,
344            callback=callback,
345            metavar=metavar,
346            expose_value=expose_value,
347            is_eager=is_eager,
348            envvar=envvar,
349            shell_complete=shell_complete,
350            autocompletion=autocompletion,
351            default_factory=default_factory,
352            # Custom type
353            parser=parser,
354            click_type=click_type,
355            # TyperArgument
356            show_default=show_default,
357            show_choices=show_choices,
358            show_envvar=show_envvar,
359            help=help,
360            hidden=hidden,
361            # Choice
362            case_sensitive=case_sensitive,
363            # Numbers
364            min=min,
365            max=max,
366            clamp=clamp,
367            # DateTime
368            formats=formats,
369            # File
370            mode=mode,
371            encoding=encoding,
372            errors=errors,
373            lazy=lazy,
374            atomic=atomic,
375            # Path
376            exists=exists,
377            file_okay=file_okay,
378            dir_okay=dir_okay,
379            writable=writable,
380            readable=readable,
381            resolve_path=resolve_path,
382            allow_dash=allow_dash,
383            path_type=path_type,
384            # Rich settings
385            rich_help_panel=rich_help_panel,
386        )
387        if is_flag is not None or flag_value is not None:
388            import warnings
389
390            warnings.warn(
391                "The 'is_flag' and 'flag_value' parameters are not supported by Typer "
392                "and will be removed entirely in a future release.",
393                DeprecationWarning,
394                stacklevel=2,
395            )
396        self.prompt = prompt
397        self.confirmation_prompt = confirmation_prompt
398        self.prompt_required = prompt_required
399        self.hide_input = hide_input
400        self.count = count
401        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)
276    def __init__(
277        self,
278        *,
279        # ParameterInfo
280        default: Optional[Any] = None,
281        param_decls: Optional[Sequence[str]] = None,
282        callback: Optional[Callable[..., Any]] = None,
283        metavar: Optional[str] = None,
284        expose_value: bool = True,
285        is_eager: bool = False,
286        envvar: Optional[Union[str, List[str]]] = None,
287        # Note that shell_complete is not fully supported and will be removed in future versions
288        # TODO: Remove shell_complete in a future version (after 0.16.0)
289        shell_complete: Optional[
290            Callable[
291                [click.Context, click.Parameter, str],
292                Union[List["click.shell_completion.CompletionItem"], List[str]],
293            ]
294        ] = None,
295        autocompletion: Optional[Callable[..., Any]] = None,
296        default_factory: Optional[Callable[[], Any]] = None,
297        # Custom type
298        parser: Optional[Callable[[str], Any]] = None,
299        click_type: Optional[click.ParamType] = None,
300        # Option
301        show_default: Union[bool, str] = True,
302        prompt: Union[bool, str] = False,
303        confirmation_prompt: bool = False,
304        prompt_required: bool = True,
305        hide_input: bool = False,
306        # TODO: remove is_flag and flag_value in a future release
307        is_flag: Optional[bool] = None,
308        flag_value: Optional[Any] = None,
309        count: bool = False,
310        allow_from_autoenv: bool = True,
311        help: Optional[str] = None,
312        hidden: bool = False,
313        show_choices: bool = True,
314        show_envvar: bool = True,
315        # Choice
316        case_sensitive: bool = True,
317        # Numbers
318        min: Optional[Union[int, float]] = None,
319        max: Optional[Union[int, float]] = None,
320        clamp: bool = False,
321        # DateTime
322        formats: Optional[List[str]] = None,
323        # File
324        mode: Optional[str] = None,
325        encoding: Optional[str] = None,
326        errors: Optional[str] = "strict",
327        lazy: Optional[bool] = None,
328        atomic: bool = False,
329        # Path
330        exists: bool = False,
331        file_okay: bool = True,
332        dir_okay: bool = True,
333        writable: bool = False,
334        readable: bool = True,
335        resolve_path: bool = False,
336        allow_dash: bool = False,
337        path_type: Union[None, Type[str], Type[bytes]] = None,
338        # Rich settings
339        rich_help_panel: Union[str, None] = None,
340    ):
341        super().__init__(
342            default=default,
343            param_decls=param_decls,
344            callback=callback,
345            metavar=metavar,
346            expose_value=expose_value,
347            is_eager=is_eager,
348            envvar=envvar,
349            shell_complete=shell_complete,
350            autocompletion=autocompletion,
351            default_factory=default_factory,
352            # Custom type
353            parser=parser,
354            click_type=click_type,
355            # TyperArgument
356            show_default=show_default,
357            show_choices=show_choices,
358            show_envvar=show_envvar,
359            help=help,
360            hidden=hidden,
361            # Choice
362            case_sensitive=case_sensitive,
363            # Numbers
364            min=min,
365            max=max,
366            clamp=clamp,
367            # DateTime
368            formats=formats,
369            # File
370            mode=mode,
371            encoding=encoding,
372            errors=errors,
373            lazy=lazy,
374            atomic=atomic,
375            # Path
376            exists=exists,
377            file_okay=file_okay,
378            dir_okay=dir_okay,
379            writable=writable,
380            readable=readable,
381            resolve_path=resolve_path,
382            allow_dash=allow_dash,
383            path_type=path_type,
384            # Rich settings
385            rich_help_panel=rich_help_panel,
386        )
387        if is_flag is not None or flag_value is not None:
388            import warnings
389
390            warnings.warn(
391                "The 'is_flag' and 'flag_value' parameters are not supported by Typer "
392                "and will be removed entirely in a future release.",
393                DeprecationWarning,
394                stacklevel=2,
395            )
396        self.prompt = prompt
397        self.confirmation_prompt = confirmation_prompt
398        self.prompt_required = prompt_required
399        self.hide_input = hide_input
400        self.count = count
401        self.allow_from_autoenv = allow_from_autoenv
prompt
confirmation_prompt
prompt_required
hide_input
count
allow_from_autoenv
class ArgumentInfo(ParameterInfo):
404class ArgumentInfo(ParameterInfo):
405    def __init__(
406        self,
407        *,
408        # ParameterInfo
409        default: Optional[Any] = None,
410        param_decls: Optional[Sequence[str]] = None,
411        callback: Optional[Callable[..., Any]] = None,
412        metavar: Optional[str] = None,
413        expose_value: bool = True,
414        is_eager: bool = False,
415        envvar: Optional[Union[str, List[str]]] = None,
416        # Note that shell_complete is not fully supported and will be removed in future versions
417        # TODO: Remove shell_complete in a future version (after 0.16.0)
418        shell_complete: Optional[
419            Callable[
420                [click.Context, click.Parameter, str],
421                Union[List["click.shell_completion.CompletionItem"], List[str]],
422            ]
423        ] = None,
424        autocompletion: Optional[Callable[..., Any]] = None,
425        default_factory: Optional[Callable[[], Any]] = None,
426        # Custom type
427        parser: Optional[Callable[[str], Any]] = None,
428        click_type: Optional[click.ParamType] = None,
429        # TyperArgument
430        show_default: Union[bool, str] = True,
431        show_choices: bool = True,
432        show_envvar: bool = True,
433        help: Optional[str] = None,
434        hidden: bool = False,
435        # Choice
436        case_sensitive: bool = True,
437        # Numbers
438        min: Optional[Union[int, float]] = None,
439        max: Optional[Union[int, float]] = None,
440        clamp: bool = False,
441        # DateTime
442        formats: Optional[List[str]] = None,
443        # File
444        mode: Optional[str] = None,
445        encoding: Optional[str] = None,
446        errors: Optional[str] = "strict",
447        lazy: Optional[bool] = None,
448        atomic: bool = False,
449        # Path
450        exists: bool = False,
451        file_okay: bool = True,
452        dir_okay: bool = True,
453        writable: bool = False,
454        readable: bool = True,
455        resolve_path: bool = False,
456        allow_dash: bool = False,
457        path_type: Union[None, Type[str], Type[bytes]] = None,
458        # Rich settings
459        rich_help_panel: Union[str, None] = None,
460    ):
461        super().__init__(
462            default=default,
463            param_decls=param_decls,
464            callback=callback,
465            metavar=metavar,
466            expose_value=expose_value,
467            is_eager=is_eager,
468            envvar=envvar,
469            shell_complete=shell_complete,
470            autocompletion=autocompletion,
471            default_factory=default_factory,
472            # Custom type
473            parser=parser,
474            click_type=click_type,
475            # TyperArgument
476            show_default=show_default,
477            show_choices=show_choices,
478            show_envvar=show_envvar,
479            help=help,
480            hidden=hidden,
481            # Choice
482            case_sensitive=case_sensitive,
483            # Numbers
484            min=min,
485            max=max,
486            clamp=clamp,
487            # DateTime
488            formats=formats,
489            # File
490            mode=mode,
491            encoding=encoding,
492            errors=errors,
493            lazy=lazy,
494            atomic=atomic,
495            # Path
496            exists=exists,
497            file_okay=file_okay,
498            dir_okay=dir_okay,
499            writable=writable,
500            readable=readable,
501            resolve_path=resolve_path,
502            allow_dash=allow_dash,
503            path_type=path_type,
504            # Rich settings
505            rich_help_panel=rich_help_panel,
506        )
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)
405    def __init__(
406        self,
407        *,
408        # ParameterInfo
409        default: Optional[Any] = None,
410        param_decls: Optional[Sequence[str]] = None,
411        callback: Optional[Callable[..., Any]] = None,
412        metavar: Optional[str] = None,
413        expose_value: bool = True,
414        is_eager: bool = False,
415        envvar: Optional[Union[str, List[str]]] = None,
416        # Note that shell_complete is not fully supported and will be removed in future versions
417        # TODO: Remove shell_complete in a future version (after 0.16.0)
418        shell_complete: Optional[
419            Callable[
420                [click.Context, click.Parameter, str],
421                Union[List["click.shell_completion.CompletionItem"], List[str]],
422            ]
423        ] = None,
424        autocompletion: Optional[Callable[..., Any]] = None,
425        default_factory: Optional[Callable[[], Any]] = None,
426        # Custom type
427        parser: Optional[Callable[[str], Any]] = None,
428        click_type: Optional[click.ParamType] = None,
429        # TyperArgument
430        show_default: Union[bool, str] = True,
431        show_choices: bool = True,
432        show_envvar: bool = True,
433        help: Optional[str] = None,
434        hidden: bool = False,
435        # Choice
436        case_sensitive: bool = True,
437        # Numbers
438        min: Optional[Union[int, float]] = None,
439        max: Optional[Union[int, float]] = None,
440        clamp: bool = False,
441        # DateTime
442        formats: Optional[List[str]] = None,
443        # File
444        mode: Optional[str] = None,
445        encoding: Optional[str] = None,
446        errors: Optional[str] = "strict",
447        lazy: Optional[bool] = None,
448        atomic: bool = False,
449        # Path
450        exists: bool = False,
451        file_okay: bool = True,
452        dir_okay: bool = True,
453        writable: bool = False,
454        readable: bool = True,
455        resolve_path: bool = False,
456        allow_dash: bool = False,
457        path_type: Union[None, Type[str], Type[bytes]] = None,
458        # Rich settings
459        rich_help_panel: Union[str, None] = None,
460    ):
461        super().__init__(
462            default=default,
463            param_decls=param_decls,
464            callback=callback,
465            metavar=metavar,
466            expose_value=expose_value,
467            is_eager=is_eager,
468            envvar=envvar,
469            shell_complete=shell_complete,
470            autocompletion=autocompletion,
471            default_factory=default_factory,
472            # Custom type
473            parser=parser,
474            click_type=click_type,
475            # TyperArgument
476            show_default=show_default,
477            show_choices=show_choices,
478            show_envvar=show_envvar,
479            help=help,
480            hidden=hidden,
481            # Choice
482            case_sensitive=case_sensitive,
483            # Numbers
484            min=min,
485            max=max,
486            clamp=clamp,
487            # DateTime
488            formats=formats,
489            # File
490            mode=mode,
491            encoding=encoding,
492            errors=errors,
493            lazy=lazy,
494            atomic=atomic,
495            # Path
496            exists=exists,
497            file_okay=file_okay,
498            dir_okay=dir_okay,
499            writable=writable,
500            readable=readable,
501            resolve_path=resolve_path,
502            allow_dash=allow_dash,
503            path_type=path_type,
504            # Rich settings
505            rich_help_panel=rich_help_panel,
506        )
class ParamMeta:
509class ParamMeta:
510    empty = inspect.Parameter.empty
511
512    def __init__(
513        self,
514        *,
515        name: str,
516        default: Any = inspect.Parameter.empty,
517        annotation: Any = inspect.Parameter.empty,
518    ) -> None:
519        self.name = name
520        self.default = default
521        self.annotation = annotation
ParamMeta(*, name: str, default: Any, annotation: Any)
512    def __init__(
513        self,
514        *,
515        name: str,
516        default: Any = inspect.Parameter.empty,
517        annotation: Any = inspect.Parameter.empty,
518    ) -> None:
519        self.name = name
520        self.default = default
521        self.annotation = annotation
empty
name
default
annotation
class DeveloperExceptionConfig:
524class DeveloperExceptionConfig:
525    def __init__(
526        self,
527        *,
528        pretty_exceptions_enable: bool = True,
529        pretty_exceptions_show_locals: bool = True,
530        pretty_exceptions_short: bool = True,
531    ) -> None:
532        self.pretty_exceptions_enable = pretty_exceptions_enable
533        self.pretty_exceptions_show_locals = pretty_exceptions_show_locals
534        self.pretty_exceptions_short = pretty_exceptions_short
DeveloperExceptionConfig( *, pretty_exceptions_enable: bool = True, pretty_exceptions_show_locals: bool = True, pretty_exceptions_short: bool = True)
525    def __init__(
526        self,
527        *,
528        pretty_exceptions_enable: bool = True,
529        pretty_exceptions_show_locals: bool = True,
530        pretty_exceptions_short: bool = True,
531    ) -> None:
532        self.pretty_exceptions_enable = pretty_exceptions_enable
533        self.pretty_exceptions_show_locals = pretty_exceptions_show_locals
534        self.pretty_exceptions_short = pretty_exceptions_short
pretty_exceptions_enable
pretty_exceptions_show_locals
pretty_exceptions_short