typer API Reference
Full documentation for typer (0.27.0)
typer.Abort
Python Library Documentation: class Abort in module typer._click.exceptions class Abort(builtins.RuntimeError) | An internal signalling exception that signals Click to abort. | | Method resolution order: | Abort | builtins.RuntimeError | builtins.Exception | builtins.BaseException | builtins.object | | Data descriptors defined here: | | __weakref__ | list of weak references to the object | | ---------------------------------------------------------------------- | Methods inherited from builtins.RuntimeError: | | __init__(self, /, *args, **kwargs) | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Static methods inherited from builtins.RuntimeError: | | __new__(*args, **kwargs) class method of builtins.RuntimeError | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
typer.Argument
Python Library Documentation: function Argument in module typer.params
Argument(default: Annotated[Any | None, Doc('\n By default, CLI arguments are required. However, by giving them a default value they become [optional](https://typer.tiangolo.com/tutorial/arguments/optional):\n\n **Example**\n\n ```python\n @app.command()\n def main(name: str = typer.Argument("World")):\n print(f"Hello {name}!")\n ```\n\n Note that this usage is deprecated, and we recommend to use `Annotated` instead:\n ```python\n @app.command()\n def main(name: Annotated[str, typer.Argument()] = "World"):\n print(f"Hello {name}!")\n ```\n ')] = Ellipsis, *, callback: Annotated[collections.abc.Callable[..., Any] | None, Doc('\n Add a callback to this CLI Argument, to execute additional logic with the value received from the terminal.\n See [the tutorial about callbacks](https://typer.tiangolo.com/tutorial/options/callback-and-context/) for more details.\n\n **Example**\n\n ```python\n def name_callback(value: str):\n if value != "Deadpool":\n raise typer.BadParameter("Only Deadpool is allowed")\n return value\n\n @app.command()\n def main(name: Annotated[str, typer.Argument(callback=name_callback)]):\n print(f"Hello {name}")\n ```\n ')] = None, metavar: Annotated[str | None, Doc('\n Customize the name displayed in the help text to represent this CLI Argument.\n By default, it will be the same name you declared, in uppercase.\n See [the tutorial about CLI Arguments with Help](https://typer.tiangolo.com/tutorial/arguments/help/#custom-help-name-metavar) for more details.\n\n **Example**\n\n ```python\n @app.command()\n def main(name: Annotated[str, typer.Argument(metavar="✨username✨")]):\n print(f"Hello {name}")\n ```\n ')] = None, expose_value: Annotated[bool, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.\n\n ---\n\n If this is `True` then the value is passed onwards to the command callback and stored on the context, otherwise it’s skipped.\n ")] = True, is_eager: Annotated[bool, Doc('\n Set an argument to "eager" to ensure it gets processed before other CLI parameters. This could be relevant when there are other parameters with callbacks that could exit the program early.\n For more information and an extended example, see the documentation [here](https://typer.tiangolo.com/tutorial/options/version/#fix-with-is_eager).\n ')] = False, envvar: Annotated[str | list[str] | None, Doc('\n Configure an argument to read a value from an environment variable if it is not provided in the command line as a CLI argument.\n For more information, see the [documentation on Environment Variables](https://typer.tiangolo.com/tutorial/arguments/envvar/).\n\n **Example**\n\n ```python\n @app.command()\n def main(name: Annotated[str, typer.Argument(envvar="ME")]):\n print(f"Hello Mr. {name}")\n ```\n ')] = None, shell_complete: Annotated[collections.abc.Callable[[typer._click.core.Context, typer._click.core.Parameter, str], list['CompletionItem'] | list[str]] | None, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.\n It is however not fully functional, and will likely be removed in future versions.\n ")] = None, autocompletion: Annotated[collections.abc.Callable[..., Any] | None, Doc('\n Provide a custom function that helps to autocomplete the values of this CLI Argument.\n See [the tutorial on parameter autocompletion](https://typer.tiangolo.com/tutorial/options-autocompletion) for more details.\n\n **Example**\n\n ```python\n def complete():\n return ["Me", "Myself", "I"]\n\n @app.command()\n def main(name: Annotated[str, typer.Argument(autocompletion=complete)]):\n print(f"Hello {name}")\n ```\n ')] = None, default_factory: Annotated[collections.abc.Callable[[], Any] | None, Doc('\n Provide a custom function that dynamically generates a [default](https://typer.tiangolo.com/tutorial/arguments/default) for this CLI Argument.\n\n **Example**\n\n ```python\n def get_name():\n return random.choice(["Me", "Myself", "I"])\n\n @app.command()\n def main(name: Annotated[str, typer.Argument(default_factory=get_name)]):\n print(f"Hello {name}")\n ```\n ')] = None, parser: Annotated[collections.abc.Callable[[str], Any] | None, Doc('\n Use your own custom types in Typer applications by defining a `parser` function that parses input into your own types:\n\n **Example**\n\n ```python\n class CustomClass:\n def __init__(self, value: str):\n self.value = value\n\n def __str__(self):\n return f"<CustomClass: value={self.value}>"\n\n def my_parser(value: str):\n return CustomClass(value * 2)\n\n @app.command()\n def main(arg: Annotated[CustomClass, typer.Argument(parser=my_parser):\n print(f"arg is {arg}")\n ```\n ')] = None, click_type: Annotated[typer._click.types.ParamType | None, Doc('\n Define this parameter to use a [custom Click type](https://click.palletsprojects.com/en/stable/parameters/#implementing-custom-types) in your Typer applications.\n\n **Example**\n\n ```python\n class MyClass:\n def __init__(self, value: str):\n self.value = value\n\n def __str__(self):\n return f"<MyClass: value={self.value}>"\n\n class MyParser(click.ParamType):\n name = "MyClass"\n\n def convert(self, value, param, ctx):\n return MyClass(value * 3)\n\n @app.command()\n def main(arg: Annotated[MyClass, typer.Argument(click_type=MyParser())]):\n print(f"arg is {arg}")\n ```\n ')] = None, show_default: Annotated[bool | str, Doc('\n When set to `False`, don\'t show the default value of this CLI Argument in the [help text](https://typer.tiangolo.com/tutorial/arguments/help/).\n\n **Example**\n\n ```python\n @app.command()\n def main(name: Annotated[str, typer.Argument(show_default=False)] = "Rick"):\n print(f"Hello {name}")\n ```\n ')] = True, show_choices: Annotated[bool, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.\n\n ---\n\n When set to `False`, this suppresses choices from being displayed inline when `prompt` is used.\n ")] = True, show_envvar: Annotated[bool, Doc('\n When an ["envvar"](https://typer.tiangolo.com/tutorial/arguments/envvar) is defined, prevent it from showing up in the help text:\n\n **Example**\n\n ```python\n @app.command()\n def main(name: Annotated[str, typer.Argument(envvar="ME", show_envvar=False)]):\n print(f"Hello Mr. {name}")\n ```\n ')] = True, help: Annotated[str | None, Doc('\n Help text for this CLI Argument.\n See [the tutorial about CLI Arguments with help](https://typer.tiangolo.com/tutorial/arguments/help/) for more dedails.\n\n **Example**\n\n ```python\n @app.command()\n def greet(name: Annotated[str, typer.Argument(help="Person to greet")]):\n print(f"Hello {name}")\n ```\n ')] = None, hidden: Annotated[bool, Doc('\n Hide this CLI Argument from [help outputs](https://typer.tiangolo.com/tutorial/arguments/help). `False` by default.\n\n **Example**\n\n ```python\n @app.command()\n def main(name: Annotated[str, typer.Argument(hidden=True)] = "World"):\n print(f"Hello {name}")\n ```\n ')] = False, case_sensitive: Annotated[bool, Doc('\n For a CLI Argument representing an [Enum (choice)](https://typer.tiangolo.com/tutorial/parameter-types/enum),\n you can allow case-insensitive matching with this parameter:\n\n **Example**\n\n ```python\n from enum import Enum\n\n class NeuralNetwork(str, Enum):\n simple = "simple"\n conv = "conv"\n lstm = "lstm"\n\n @app.command()\n def main(\n network: Annotated[NeuralNetwork, typer.Argument(case_sensitive=False)]):\n print(f"Training neural network of type: {network.value}")\n ```\n\n With this setting, "LSTM" or "lstm" will both be valid values that will be resolved to `NeuralNetwork.lstm`.\n ')] = True, min: Annotated[int | float | None, Doc('\n For a CLI Argument representing a [number](https://typer.tiangolo.com/tutorial/parameter-types/number/) (`int` or `float`),\n you can define numeric validations with `min` and `max` values:\n\n **Example**\n\n ```python\n @app.command()\n def main(\n user: Annotated[str, typer.Argument()],\n user_id: Annotated[int, typer.Argument(min=1, max=1000)],\n ):\n print(f"ID for {user} is {user_id}")\n ```\n\n If the user attempts to input an invalid number, an error will be shown, explaining why the value is invalid.\n ')] = None, max: Annotated[int | float | None, Doc('\n For a CLI Argument representing a [number](https://typer.tiangolo.com/tutorial/parameter-types/number/) (`int` or `float`),\n you can define numeric validations with `min` and `max` values:\n\n **Example**\n\n ```python\n @app.command()\n def main(\n user: Annotated[str, typer.Argument()],\n user_id: Annotated[int, typer.Argument(min=1, max=1000)],\n ):\n print(f"ID for {user} is {user_id}")\n ```\n\n If the user attempts to input an invalid number, an error will be shown, explaining why the value is invalid.\n ')] = None, clamp: Annotated[bool, Doc('\n For a CLI Argument representing a [number](https://typer.tiangolo.com/tutorial/parameter-types/number/) and that is bounded by using `min` and/or `max`,\n you can opt to use the closest minimum or maximum value instead of raising an error. This is done by setting `clamp` to `True`.\n\n **Example**\n\n ```python\n @app.command()\n def main(\n user: Annotated[str, typer.Argument()],\n user_id: Annotated[int, typer.Argument(min=1, max=1000, clamp=True)],\n ):\n print(f"ID for {user} is {user_id}")\n ```\n\n If the user attempts to input 3420 for `user_id`, this will internally be converted to `1000`.\n ')] = False, formats: Annotated[list[str] | None, Doc('\n For a CLI Argument representing a [DateTime object](https://typer.tiangolo.com/tutorial/parameter-types/datetime),\n you can customize the formats that can be parsed automatically:\n\n **Example**\n\n ```python\n from datetime import datetime\n\n @app.command()\n def main(\n birthday: Annotated[\n datetime,\n typer.Argument(\n formats=["%Y-%m-%d", "%Y-%m-%d %H:%M:%S", "%m/%d/%Y"]\n ),\n ],\n ):\n print(f"Birthday defined at: {birthday}")\n ```\n ')] = None, mode: Annotated[str | None, Doc('\n For a CLI Argument representing a [File object](https://typer.tiangolo.com/tutorial/parameter-types/file/),\n you can customize the mode to open the file with. If unset, Typer will set a [sensible value by default](https://typer.tiangolo.com/tutorial/parameter-types/file/#advanced-mode).\n\n **Example**\n\n ```python\n @app.command()\n def main(config: Annotated[typer.FileText, typer.Argument(mode="a")]):\n config.write("This is a single line\\n")\n print("Config line written")\n ```\n ')] = None, encoding: Annotated[str | None, Doc('\n Customize the encoding of this CLI Argument represented by a [File object](https://typer.tiangolo.com/tutorial/parameter-types/file/).\n\n **Example**\n\n ```python\n @app.command()\n def main(config: Annotated[typer.FileText, typer.Argument(encoding="utf-8")]):\n config.write("All the text gets written\\n")\n ```\n ')] = None, errors: Annotated[str | None, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.\n\n ---\n\n The error handling mode.\n ")] = 'strict', lazy: Annotated[bool | None, Doc('\n For a CLI Argument representing a [File object](https://typer.tiangolo.com/tutorial/parameter-types/file/),\n by default the file will not be created until you actually start writing to it.\n You can change this behaviour by setting this parameter.\n By default, it\'s set to `True` for writing and to `False` for reading.\n\n **Example**\n\n ```python\n @app.command()\n def main(config: Annotated[typer.FileText, typer.Argument(mode="a", lazy=False)]):\n config.write("This is a single line\\n")\n print("Config line written")\n ```\n ')] = None, atomic: Annotated[bool, Doc('\n For a CLI Argument representing a [File object](https://typer.tiangolo.com/tutorial/parameter-types/file/),\n you can ensure that all write instructions first go into a temporal file, and are only moved to the final destination after completing\n by setting `atomic` to `True`. This can be useful for files with potential concurrent access.\n\n **Example**\n\n ```python\n @app.command()\n def main(config: Annotated[typer.FileText, typer.Argument(mode="a", atomic=True)]):\n config.write("All the text")\n ```\n ')] = False, exists: Annotated[bool, Doc('\n When set to `True` for a [`Path` argument](https://typer.tiangolo.com/tutorial/parameter-types/path/),\n additional validation is performed to check that the file or directory exists. If not, the value will be invalid.\n\n **Example**\n\n ```python\n from pathlib import Path\n\n @app.command()\n def main(config: Annotated[Path, typer.Argument(exists=True)]):\n text = config.read_text()\n print(f"Config file contents: {text}")\n ```\n ')] = False, file_okay: Annotated[bool, Doc('\n Determine whether or not a [`Path` argument](https://typer.tiangolo.com/tutorial/parameter-types/path/)\n is allowed to refer to a file. When this is set to `False`, the application will raise a validation error when a path to a file is given.\n\n **Example**\n\n ```python\n from pathlib import Path\n\n @app.command()\n def main(config: Annotated[Path, typer.Argument(exists=True, file_okay=False)]):\n print(f"Directory listing: {[x.name for x in config.iterdir()]}")\n ```\n ')] = True, dir_okay: Annotated[bool, Doc('\n Determine whether or not a [`Path` argument](https://typer.tiangolo.com/tutorial/parameter-types/path/)\n is allowed to refer to a directory. When this is set to `False`, the application will raise a validation error when a path to a directory is given.\n\n **Example**\n\n ```python\n from pathlib import Path\n\n @app.command()\n def main(config: Annotated[Path, typer.Argument(exists=True, dir_okay=False)]):\n text = config.read_text()\n print(f"Config file contents: {text}")\n ```\n ')] = True, writable: Annotated[bool, Doc('\n Whether or not to perform a writable check for this [`Path` argument](https://typer.tiangolo.com/tutorial/parameter-types/path/).\n\n **Example**\n\n ```python\n from pathlib import Path\n\n @app.command()\n def main(config: Annotated[Path, typer.Argument(writable=True)]):\n config.write_text("All the text")\n ```\n ')] = False, readable: Annotated[bool, Doc('\n Whether or not to perform a readable check for this [`Path` argument](https://typer.tiangolo.com/tutorial/parameter-types/path/).\n\n **Example**\n\n ```python\n from pathlib import Path\n\n @app.command()\n def main(config: Annotated[Path, typer.Argument(readable=True)]):\n config.read_text("All the text")\n ```\n ')] = True, resolve_path: Annotated[bool, Doc('\n Whether or not to fully resolve the path of this [`Path` argument](https://typer.tiangolo.com/tutorial/parameter-types/path/),\n meaning that the path becomes absolute and symlinks are resolved.\n\n **Example**\n\n ```python\n from pathlib import Path\n\n @app.command()\n def main(config: Annotated[Path, typer.Argument(resolve_path=True)]):\n config.read_text("All the text")\n ```\n ')] = False, allow_dash: Annotated[bool, Doc('\n When set to `True`, a single dash for this [`Path` argument](https://typer.tiangolo.com/tutorial/parameter-types/path/)\n would be a valid value, indicating standard streams. This is a more advanced use-case.\n ')] = False, path_type: Annotated[None | type[str] | type[bytes], Doc('\n A string type that will be used to represent this [`Path` argument](https://typer.tiangolo.com/tutorial/parameter-types/path/).\n The default is `None` which means the return value will be either bytes or unicode, depending on what makes most sense given the input data.\n This is a more advanced use-case.\n ')] = None, rich_help_panel: Annotated[str | None, Doc('\n Set the panel name where you want this CLI Argument to be shown in the [help text](https://typer.tiangolo.com/tutorial/arguments/help).\n\n **Example**\n\n ```python\n @app.command()\n def main(\n name: Annotated[str, typer.Argument(help="Who to greet")],\n age: Annotated[str, typer.Option(help="Their age", rich_help_panel="Data")],\n ):\n print(f"Hello {name} of age {age}")\n ```\n ')] = None) -> Any
A [CLI Argument](https://typer.tiangolo.com/tutorial/arguments) is a positional parameter to your command line application.
Often, CLI Arguments are required, meaning that users have to specify them. However, you can set them to be optional by defining a default value:
## Example
```python
@app.command()
def main(name: Annotated[str, typer.Argument()] = "World"):
print(f"Hello {name}!")
```
Note how in this example, if `name` is not specified on the command line, the application will still execute normally and print "Hello World!".
typer.BadParameter
Python Library Documentation: class BadParameter in module typer._click.exceptions
class BadParameter(UsageError)
| BadParameter(message: str, ctx: Optional[ForwardRef('Context')] = None, param: Optional[ForwardRef('Parameter')] = None, param_hint: collections.abc.Sequence[str] | str | None = None) -> None
|
| An exception that formats out a standardized error message for a
| bad parameter. This is useful when thrown from a callback or type as
| Click will attach contextual information to it (for instance, which
| parameter it is).
|
| Method resolution order:
| BadParameter
| UsageError
| ClickException
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, message: str, ctx: Optional[ForwardRef('Context')] = None, param: Optional[ForwardRef('Parameter')] = None, param_hint: collections.abc.Sequence[str] | str | None = None) -> None
| Initialize self. See help(type(self)) for accurate signature.
|
| format_message(self) -> str
|
| ----------------------------------------------------------------------
| Methods inherited from UsageError:
|
| show(self, file: Optional[IO[Any]] = None) -> None
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from UsageError:
|
| exit_code = 2
|
| ----------------------------------------------------------------------
| Methods inherited from ClickException:
|
| __str__(self) -> str
| Return str(self).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from ClickException:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
typer.CallbackParam
Python Library Documentation: class CallbackParam in module typer.models
class CallbackParam(typer._click.core.Parameter)
| CallbackParam(param_decls: collections.abc.Sequence[str] | None = None, type: typer._click.types.ParamType | typing.Any | None = None, required: bool = False, default: typing.Any | collections.abc.Callable[[], typing.Any] | None = None, callback: collections.abc.Callable[[typer._click.core.Context, 'Parameter', typing.Any], typing.Any] | None = None, nargs: int | None = None, multiple: bool = False, metavar: str | None = None, expose_value: bool = True, is_eager: bool = False, envvar: str | collections.abc.Sequence[str] | None = None, shell_complete: collections.abc.Callable[[typer._click.core.Context, 'Parameter', str], list['CompletionItem'] | list[str]] | None = None) -> None
|
| In a callback function, you can declare a function parameter with type `CallbackParam`
| to access the specific Click [`Parameter`](https://click.palletsprojects.com/en/stable/api/#click.Parameter) object.
|
| Method resolution order:
| CallbackParam
| typer._click.core.Parameter
| abc.ABC
| builtins.object
|
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset({'_parse_decls', 'add_to_parser', 'get...
|
| ----------------------------------------------------------------------
| Methods inherited from typer._click.core.Parameter:
|
| __init__(self, param_decls: collections.abc.Sequence[str] | None = None, type: typer._click.types.ParamType | typing.Any | None = None, required: bool = False, default: typing.Any | collections.abc.Callable[[], typing.Any] | None = None, callback: collections.abc.Callable[[typer._click.core.Context, 'Parameter', typing.Any], typing.Any] | None = None, nargs: int | None = None, multiple: bool = False, metavar: str | None = None, expose_value: bool = True, is_eager: bool = False, envvar: str | collections.abc.Sequence[str] | None = None, shell_complete: collections.abc.Callable[[typer._click.core.Context, 'Parameter', str], list['CompletionItem'] | list[str]] | None = None) -> None
| Initialize self. See help(type(self)) for accurate signature.
|
| __repr__(self) -> str
| Return repr(self).
|
| add_to_parser(self, parser: typer._click.parser._OptionParser, ctx: typer._click.core.Context) -> None
|
| consume_value(self, ctx: typer._click.core.Context, opts: collections.abc.Mapping[str, typing.Any]) -> tuple[typing.Any, typer._click.core.ParameterSource]
|
| get_default(self, ctx: typer._click.core.Context, call: bool = True) -> typing.Any | collections.abc.Callable[[], typing.Any] | None
| Get the default for the parameter
|
| get_error_hint(self, ctx: typer._click.core.Context) -> str
| Get a stringified version of the param for use in error messages to
| indicate which param caused the error.
|
| get_help_record(self, ctx: typer._click.core.Context) -> tuple[str, str] | None
|
| get_usage_pieces(self, ctx: typer._click.core.Context) -> list[str]
|
| handle_parse_result(self, ctx: typer._click.core.Context, opts: collections.abc.Mapping[str, typing.Any], args: list[str]) -> tuple[typing.Any, list[str]]
| Process the value produced by the parser from user input.
|
| Always process the value through the Parameter's `type`, wherever it
| comes from.
|
| If the parameter is deprecated, this method warn the user about it. But only if
| the value has been explicitly set by the user (and as such, is not coming from
| a default).
|
| make_metavar(self, ctx: typer._click.core.Context) -> str
|
| process_value(self, ctx: typer._click.core.Context, value: Any) -> Any
| Process the value of this parameter
|
| resolve_envvar_value(self, ctx: typer._click.core.Context) -> str | None
| Returns the value found in the environment variable(s) attached to this
| parameter.
|
| Environment variables values are `always returned as strings
| <https://docs.python.org/3/library/os.html#os.environ>`_.
|
| This method returns ``None`` if:
|
| - the `envvar` property is not set on `Parameter`,
| - the environment variable is not found in the environment,
| - the variable is found in the environment but its value is empty (i.e. the
| environment variable is present but has an empty string).
|
| If `envvar` is setup with multiple environment variables,
| then only the first non-empty value is returned.
|
| shell_complete(self, ctx: typer._click.core.Context, incomplete: str) -> list['CompletionItem']
| Return a list of completions for the incomplete value. If a
| ``shell_complete`` function was given during init, it is used.
| Otherwise, the `type` `ParamType.shell_complete` function is used.
|
| type_cast_value(self, ctx: typer._click.core.Context, value: Any) -> Any
| Convert and validate a value against the parameter's
| `type`, `multiple`, and `nargs`.
|
| value_from_envvar(self, ctx: typer._click.core.Context) -> str | collections.abc.Sequence[str] | None
| Process the raw environment variable string for this parameter.
|
| Returns the string as-is or splits it into a sequence of strings if the
| parameter is expecting multiple values (i.e. its `nargs` property is set
| to a value other than ``1``).
|
| value_is_missing(self, value: Any) -> bool
|
| ----------------------------------------------------------------------
| Readonly properties inherited from typer._click.core.Parameter:
|
| human_readable_name
| Returns the human readable name of this parameter. This is the
| same as the name for options, but the metavar for arguments.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from typer._click.core.Parameter:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from typer._click.core.Parameter:
|
| param_type_name = 'parameter'
typer.Context
Python Library Documentation: class Context in module typer.models
class Context(typer._click.core.Context)
| Context(command: 'Command', parent: Optional[ForwardRef('Context')] = None, info_name: str | None = None, obj: typing.Any | None = None, auto_envvar_prefix: str | None = None, default_map: collections.abc.MutableMapping[str, typing.Any] | None = None, terminal_width: int | None = None, max_content_width: int | None = None, resilient_parsing: bool = False, allow_extra_args: bool | None = None, allow_interspersed_args: bool | None = None, ignore_unknown_options: bool | None = None, help_option_names: list[str] | None = None, token_normalize_func: collections.abc.Callable[[str], str] | None = None, color: bool | None = None, show_default: bool | None = None) -> None
|
| The [`Context`](https://click.palletsprojects.com/en/stable/api/#click.Context) has some additional data about the current execution of your program.
| When declaring it in a [callback](https://typer.tiangolo.com/tutorial/options/callback-and-context/) function,
| you can access this additional information.
|
| Method resolution order:
| Context
| typer._click.core.Context
| builtins.object
|
| Data and other attributes defined here:
|
| __annotations__ = {}
|
| ----------------------------------------------------------------------
| Methods inherited from typer._click.core.Context:
|
| __enter__(self) -> 'Context'
|
| __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, tb: traceback | None) -> bool | None
|
| __init__(self, command: 'Command', parent: Optional[ForwardRef('Context')] = None, info_name: str | None = None, obj: typing.Any | None = None, auto_envvar_prefix: str | None = None, default_map: collections.abc.MutableMapping[str, typing.Any] | None = None, terminal_width: int | None = None, max_content_width: int | None = None, resilient_parsing: bool = False, allow_extra_args: bool | None = None, allow_interspersed_args: bool | None = None, ignore_unknown_options: bool | None = None, help_option_names: list[str] | None = None, token_normalize_func: collections.abc.Callable[[str], str] | None = None, color: bool | None = None, show_default: bool | None = None) -> None
| Initialize self. See help(type(self)) for accurate signature.
|
| abort(self) -> NoReturn
| Aborts the script.
|
| call_on_close(self, f: collections.abc.Callable[..., typing.Any]) -> collections.abc.Callable[..., typing.Any]
| Register a function to be called when the context tears down.
|
| This can be used to close resources opened during the script
| execution. Resources that support Python's context manager
| protocol which would be used in a ``with`` statement should be
| registered with `with_resource` instead.
|
| close(self) -> None
| Invoke all close callbacks registered with `call_on_close`,
| and exit all context managers entered with `with_resource`.
|
| ensure_object(self, object_type: type[~V]) -> ~V
| Like `find_object` but sets the innermost object to a
| new instance of `object_type` if it does not exist.
|
| exit(self, code: int = 0) -> NoReturn
| Exits the application with a given exit code.
|
| fail(self, message: str) -> NoReturn
| Aborts the execution of the program with a specific error
| message.
|
| find_object(self, object_type: type[~V]) -> Optional[~V]
| Finds the closest object of a given type.
|
| find_root(self) -> 'Context'
| Finds the outermost context.
|
| get_help(self) -> str
| Helper method to get formatted help page for the current
| context and command.
|
| get_parameter_source(self, name: str) -> typer._click.core.ParameterSource | None
| Get the source of a parameter. This indicates the location
| from which the value of the parameter was obtained.
|
| This can be useful for determining when a user specified a value
| on the command line that is the same as the default value. It
| will be `ParameterSource.DEFAULT` only if the
| value was actually taken from the default.
|
| get_usage(self) -> str
| Helper method to get formatted usage string for the current
| context and command.
|
| invoke(self, callback: collections.abc.Callable[..., ~V], /, *args: Any, **kwargs: Any) -> ~V
| Invokes a command callback in exactly the way it expects. There
| are two ways to invoke this method:
|
| 1. the first argument can be a callback and all other arguments and
| keyword arguments are forwarded directly to the function.
| 2. the first argument is a click command object. In that case all
| arguments are forwarded as well but proper click parameters
| (options and click arguments) must be keyword arguments and Click
| will fill in defaults.
|
| lookup_default(self, name: str, call: bool = True) -> typing.Any | None
| Get the default for a parameter from `default_map`.
|
| make_formatter(self) -> typer._click.formatting.HelpFormatter
| Creates the HelpFormatter for the help and
| usage output.
|
| scope(self, cleanup: bool = True) -> collections.abc.Iterator['Context']
| This helper method can be used with the context object to promote
| it to the current thread local (see `get_current_context`).
| The default behavior of this is to invoke the cleanup functions which
| can be disabled by setting `cleanup` to `False`. The cleanup
| functions are typically used for things such as closing file handles.
|
| If the cleanup is intended the context object can also be directly
| used as a context manager.
|
| set_parameter_source(self, name: str, source: typer._click.core.ParameterSource) -> None
| Set the source of a parameter. This indicates the location
| from which the value of the parameter was obtained.
|
| with_resource(self, context_manager: contextlib.AbstractContextManager[~V]) -> ~V
| Register a resource as if it were used in a ``with``
| statement. The resource will be cleaned up when the context is
| popped.
|
| Uses `contextlib.ExitStack.enter_context`. It calls the
| resource's ``__enter__()`` method and returns the result. When
| the context is popped, it closes the stack, which calls the
| resource's ``__exit__()`` method.
|
| To register a cleanup function for something that isn't a
| context manager, use `call_on_close`. Or use something
| from `contextlib` to turn it into a context manager first.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from typer._click.core.Context:
|
| command_path
| The computed command path. This is used for the ``usage``
| information on the help page. It's automatically created by
| combining the info names of the chain of contexts to the root.
|
| meta
| This is a dictionary which is shared with all the contexts
| that are nested. It exists so that click utilities can store some
| state here if they need to. It is however the responsibility of
| that code to manage this dictionary well.
|
| The keys are supposed to be unique dotted strings. For instance
| module paths are a good choice for it. What is stored in there is
| irrelevant for the operation of click. However what is important is
| that code that places data here adheres to the general semantics of
| the system.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from typer._click.core.Context:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from typer._click.core.Context:
|
| formatter_class = <class 'typer._click.formatting.HelpFormatter'>
| This class helps with formatting text-based help pages. It's
| usually just needed for very special internal cases, but it's also
| exposed so that developers can write their own fancy outputs.
|
| At present, it always writes into memory.
typer.Exit
Python Library Documentation: class Exit in module typer._click.exceptions class Exit(builtins.RuntimeError) | Exit(code: int = 0) -> None | | An exception that indicates that the application should exit with some | status code. | | Method resolution order: | Exit | builtins.RuntimeError | builtins.Exception | builtins.BaseException | builtins.object | | Methods defined here: | | __init__(self, code: int = 0) -> None | Initialize self. See help(type(self)) for accurate signature. | | ---------------------------------------------------------------------- | Data descriptors defined here: | | exit_code | | ---------------------------------------------------------------------- | Static methods inherited from builtins.RuntimeError: | | __new__(*args, **kwargs) class method of builtins.RuntimeError | Create and return a new object. See help(type) for accurate signature. | | ---------------------------------------------------------------------- | Methods inherited from builtins.BaseException: | | __getattribute__(self, name, /) | Return getattr(self, name). | | __reduce__(...) | Helper for pickle. | | __repr__(self, /) | Return repr(self). | | __setstate__(...) | | __str__(self, /) | Return str(self). | | add_note(...) | Exception.add_note(note) -- | add a note to the exception | | with_traceback(...) | Exception.with_traceback(tb) -- | set self.__traceback__ to tb and return self. | | ---------------------------------------------------------------------- | Data descriptors inherited from builtins.BaseException: | | __cause__ | exception cause | | __context__ | exception context | | __dict__ | | __suppress_context__ | | __traceback__ | | args
typer.FileBinaryRead
Python Library Documentation: class FileBinaryRead in module typer.models
class FileBinaryRead(_io.BufferedReader)
| FileBinaryRead(raw, buffer_size=8192)
|
| You can use this class to read binary data, receiving `bytes`.
| The default mode of this class is `mode="rb"`.
| It is useful for reading binary files like images:
|
| **Example**
|
| ```python
| from typing import Annotated
|
| import typer
|
| app = typer.Typer()
|
| @app.command()
| def main(file: Annotated[typer.FileBinaryRead, typer.Option()]):
| processed_total = 0
| for bytes_chunk in file:
| # Process the bytes in bytes_chunk
| processed_total += len(bytes_chunk)
| print(f"Processed bytes total: {processed_total}")
|
| if __name__ == "__main__":
| app()
| ```
|
| Method resolution order:
| FileBinaryRead
| _io.BufferedReader
| _io._BufferedIOBase
| _io._IOBase
| builtins.object
|
| Methods inherited from _io.BufferedReader:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Helper for pickle.
|
| __reduce_ex__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __sizeof__(self, /)
| Size of object in memory, in bytes.
|
| close(self, /)
| Flush and close the IO object.
|
| This method has no effect if the file is already closed.
|
| detach(self, /)
| Disconnect this buffer from its underlying raw stream and return it.
|
| After the raw stream has been detached, the buffer is in an unusable
| state.
|
| fileno(self, /)
| Return underlying file descriptor if one exists.
|
| Raise OSError if the IO object does not use a file descriptor.
|
| flush(self, /)
| Flush write buffers, if applicable.
|
| This is not implemented for read-only and non-blocking streams.
|
| isatty(self, /)
| Return whether this is an 'interactive' stream.
|
| Return False if it can't be determined.
|
| peek(self, size=0, /)
|
| read(self, size=-1, /)
| Read and return up to n bytes.
|
| If the size argument is omitted, None, or negative, read and
| return all data until EOF.
|
| If the size argument is positive, and the underlying raw stream is
| not 'interactive', multiple raw reads may be issued to satisfy
| the byte count (unless EOF is reached first).
| However, for interactive raw streams (as well as sockets and pipes),
| at most one raw read will be issued, and a short result does not
| imply that EOF is imminent.
|
| Return an empty bytes object on EOF.
|
| Return None if the underlying raw stream was open in non-blocking
| mode and no data is available at the moment.
|
| read1(self, size=-1, /)
| Read and return up to size bytes, with at most one read() call to the underlying raw stream.
|
| Return an empty bytes object on EOF.
| A short result does not imply that EOF is imminent.
|
| readable(self, /)
| Return whether object was opened for reading.
|
| If False, read() will raise OSError.
|
| readinto(self, buffer, /)
|
| readinto1(self, buffer, /)
|
| readline(self, size=-1, /)
| Read and return a line from the stream.
|
| If size is specified, at most size bytes will be read.
|
| The line terminator is always b'\n' for binary files; for text
| files, the newlines argument to open can be used to select the line
| terminator(s) recognized.
|
| seek(self, target, whence=0, /)
| Change the stream position to the given byte offset.
|
| offset
| The stream position, relative to 'whence'.
| whence
| The relative position to seek from.
|
| The offset is interpreted relative to the position indicated by whence.
| Values for whence are:
|
| * os.SEEK_SET or 0 -- start of stream (the default); offset should be zero or positive
| * os.SEEK_CUR or 1 -- current stream position; offset may be negative
| * os.SEEK_END or 2 -- end of stream; offset is usually negative
|
| Return the new absolute position.
|
| seekable(self, /)
| Return whether object supports random access.
|
| If False, seek(), tell() and truncate() will raise OSError.
| This method may need to do a test seek().
|
| tell(self, /)
| Return current stream position.
|
| truncate(self, pos=None, /)
| Truncate file to size bytes.
|
| File pointer is left unchanged. Size defaults to the current IO position
| as reported by tell(). Return the new size.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from _io.BufferedReader:
|
| closed
|
| mode
|
| name
|
| raw
|
| ----------------------------------------------------------------------
| Methods inherited from _io._BufferedIOBase:
|
| write(self, b, /)
| Write buffer b to the IO stream.
|
| Return the number of bytes written, which is always
| the length of b in bytes.
|
| Raise BlockingIOError if the buffer is full and the
| underlying raw stream cannot accept more data at the moment.
|
| ----------------------------------------------------------------------
| Methods inherited from _io._IOBase:
|
| __del__(...)
|
| __enter__(...)
|
| __exit__(...)
|
| __iter__(self, /)
| Implement iter(self).
|
| readlines(self, hint=-1, /)
| Return a list of lines from the stream.
|
| hint can be specified to control the number of lines read: no more
| lines will be read if the total size (in bytes/characters) of all
| lines so far exceeds hint.
|
| writable(self, /)
| Return whether object was opened for writing.
|
| If False, write() will raise OSError.
|
| writelines(self, lines, /)
| Write a list of lines to stream.
|
| Line separators are not added, so it is usual for each of the
| lines provided to have a line separator at the end.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from _io._IOBase:
|
| __dict__
typer.FileBinaryWrite
Python Library Documentation: class FileBinaryWrite in module typer.models
class FileBinaryWrite(_io.BufferedWriter)
| FileBinaryWrite(raw, buffer_size=8192)
|
| You can use this class to write binary data: you pass `bytes` to it instead of strings.
| The default mode of this class is `mode="wb"`.
| It is useful for writing binary files like images:
|
| **Example**
|
| ```python
| from typing import Annotated
|
| import typer
|
| app = typer.Typer()
|
| @app.command()
| def main(file: Annotated[typer.FileBinaryWrite, typer.Option()]):
| first_line_str = "some settings\n"
| # You cannot write str directly to a binary file; encode it first
| first_line_bytes = first_line_str.encode("utf-8")
| # Then you can write the bytes
| file.write(first_line_bytes)
| # This is already bytes, it starts with b"
| second_line = b"la cigüeña trae al niño"
| file.write(second_line)
| print("Binary file written")
|
| if __name__ == "__main__":
| app()
| ```
|
| Method resolution order:
| FileBinaryWrite
| _io.BufferedWriter
| _io._BufferedIOBase
| _io._IOBase
| builtins.object
|
| Methods inherited from _io.BufferedWriter:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __reduce__(...)
| Helper for pickle.
|
| __reduce_ex__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __sizeof__(self, /)
| Size of object in memory, in bytes.
|
| close(self, /)
| Flush and close the IO object.
|
| This method has no effect if the file is already closed.
|
| detach(self, /)
| Disconnect this buffer from its underlying raw stream and return it.
|
| After the raw stream has been detached, the buffer is in an unusable
| state.
|
| fileno(self, /)
| Return underlying file descriptor if one exists.
|
| Raise OSError if the IO object does not use a file descriptor.
|
| flush(self, /)
| Flush write buffers, if applicable.
|
| This is not implemented for read-only and non-blocking streams.
|
| isatty(self, /)
| Return whether this is an 'interactive' stream.
|
| Return False if it can't be determined.
|
| seek(self, target, whence=0, /)
| Change the stream position to the given byte offset.
|
| offset
| The stream position, relative to 'whence'.
| whence
| The relative position to seek from.
|
| The offset is interpreted relative to the position indicated by whence.
| Values for whence are:
|
| * os.SEEK_SET or 0 -- start of stream (the default); offset should be zero or positive
| * os.SEEK_CUR or 1 -- current stream position; offset may be negative
| * os.SEEK_END or 2 -- end of stream; offset is usually negative
|
| Return the new absolute position.
|
| seekable(self, /)
| Return whether object supports random access.
|
| If False, seek(), tell() and truncate() will raise OSError.
| This method may need to do a test seek().
|
| tell(self, /)
| Return current stream position.
|
| truncate(self, pos=None, /)
| Truncate file to size bytes.
|
| File pointer is left unchanged. Size defaults to the current IO position
| as reported by tell(). Return the new size.
|
| writable(self, /)
| Return whether object was opened for writing.
|
| If False, write() will raise OSError.
|
| write(self, buffer, /)
| Write buffer b to the IO stream.
|
| Return the number of bytes written, which is always
| the length of b in bytes.
|
| Raise BlockingIOError if the buffer is full and the
| underlying raw stream cannot accept more data at the moment.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from _io.BufferedWriter:
|
| closed
|
| mode
|
| name
|
| raw
|
| ----------------------------------------------------------------------
| Methods inherited from _io._BufferedIOBase:
|
| read(self, size=-1, /)
| Read and return up to n bytes.
|
| If the size argument is omitted, None, or negative, read and
| return all data until EOF.
|
| If the size argument is positive, and the underlying raw stream is
| not 'interactive', multiple raw reads may be issued to satisfy
| the byte count (unless EOF is reached first).
| However, for interactive raw streams (as well as sockets and pipes),
| at most one raw read will be issued, and a short result does not
| imply that EOF is imminent.
|
| Return an empty bytes object on EOF.
|
| Return None if the underlying raw stream was open in non-blocking
| mode and no data is available at the moment.
|
| read1(self, size=-1, /)
| Read and return up to size bytes, with at most one read() call to the underlying raw stream.
|
| Return an empty bytes object on EOF.
| A short result does not imply that EOF is imminent.
|
| readinto(self, buffer, /)
|
| readinto1(self, buffer, /)
|
| ----------------------------------------------------------------------
| Methods inherited from _io._IOBase:
|
| __del__(...)
|
| __enter__(...)
|
| __exit__(...)
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| readable(self, /)
| Return whether object was opened for reading.
|
| If False, read() will raise OSError.
|
| readline(self, size=-1, /)
| Read and return a line from the stream.
|
| If size is specified, at most size bytes will be read.
|
| The line terminator is always b'\n' for binary files; for text
| files, the newlines argument to open can be used to select the line
| terminator(s) recognized.
|
| readlines(self, hint=-1, /)
| Return a list of lines from the stream.
|
| hint can be specified to control the number of lines read: no more
| lines will be read if the total size (in bytes/characters) of all
| lines so far exceeds hint.
|
| writelines(self, lines, /)
| Write a list of lines to stream.
|
| Line separators are not added, so it is usual for each of the
| lines provided to have a line separator at the end.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from _io._IOBase:
|
| __dict__
typer.FileText
Python Library Documentation: class FileText in module typer.models
class FileText(_io.TextIOWrapper)
| FileText(buffer, encoding=None, errors=None, newline=None, line_buffering=False, write_through=False)
|
| Gives you a file-like object for reading text, and you will get a `str` data from it.
| The default mode of this class is `mode="r"`.
|
| **Example**
|
| ```python
| from typing import Annotated
|
| import typer
|
| app = typer.Typer()
|
| @app.command()
| def main(config: Annotated[typer.FileText, typer.Option()]):
| for line in config:
| print(f"Config line: {line}")
|
| if __name__ == "__main__":
| app()
| ```
|
| Method resolution order:
| FileText
| _io.TextIOWrapper
| _io._TextIOBase
| _io._IOBase
| builtins.object
|
| Methods inherited from _io.TextIOWrapper:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Helper for pickle.
|
| __reduce_ex__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| close(self, /)
| Flush and close the IO object.
|
| This method has no effect if the file is already closed.
|
| detach(self, /)
| Separate the underlying buffer from the TextIOBase and return it.
|
| After the underlying buffer has been detached, the TextIO is in an unusable state.
|
| fileno(self, /)
| Return underlying file descriptor if one exists.
|
| Raise OSError if the IO object does not use a file descriptor.
|
| flush(self, /)
| Flush write buffers, if applicable.
|
| This is not implemented for read-only and non-blocking streams.
|
| isatty(self, /)
| Return whether this is an 'interactive' stream.
|
| Return False if it can't be determined.
|
| read(self, size=-1, /)
| Read at most size characters from stream.
|
| Read from underlying buffer until we have size characters or we hit EOF.
| If size is negative or omitted, read until EOF.
|
| readable(self, /)
| Return whether object was opened for reading.
|
| If False, read() will raise OSError.
|
| readline(self, size=-1, /)
| Read until newline or EOF.
|
| Return an empty string if EOF is hit immediately.
| If size is specified, at most size characters will be read.
|
| reconfigure(self, /, *, encoding=None, errors=None, newline=None, line_buffering=None, write_through=None)
| Reconfigure the text stream with new parameters.
|
| This also does an implicit stream flush.
|
| seek(self, cookie, whence=0, /)
| Set the stream position, and return the new stream position.
|
| cookie
| Zero or an opaque number returned by tell().
| whence
| The relative position to seek from.
|
| Four operations are supported, given by the following argument
| combinations:
|
| - seek(0, SEEK_SET): Rewind to the start of the stream.
| - seek(cookie, SEEK_SET): Restore a previous position;
| 'cookie' must be a number returned by tell().
| - seek(0, SEEK_END): Fast-forward to the end of the stream.
| - seek(0, SEEK_CUR): Leave the current stream position unchanged.
|
| Any other argument combinations are invalid,
| and may raise exceptions.
|
| seekable(self, /)
| Return whether object supports random access.
|
| If False, seek(), tell() and truncate() will raise OSError.
| This method may need to do a test seek().
|
| tell(self, /)
| Return the stream position as an opaque number.
|
| The return value of tell() can be given as input to seek(), to restore a
| previous stream position.
|
| truncate(self, pos=None, /)
| Truncate file to size bytes.
|
| File pointer is left unchanged. Size defaults to the current IO position
| as reported by tell(). Return the new size.
|
| writable(self, /)
| Return whether object was opened for writing.
|
| If False, write() will raise OSError.
|
| write(self, text, /)
| Write string s to stream.
|
| Return the number of characters written
| (which is always equal to the length of the string).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from _io.TextIOWrapper:
|
| buffer
|
| closed
|
| encoding
| Encoding of the text stream.
|
| Subclasses should override.
|
| errors
| The error setting of the decoder or encoder.
|
| Subclasses should override.
|
| line_buffering
|
| name
|
| newlines
| Line endings translated so far.
|
| Only line endings translated during reading are considered.
|
| Subclasses should override.
|
| write_through
|
| ----------------------------------------------------------------------
| Methods inherited from _io._IOBase:
|
| __del__(...)
|
| __enter__(...)
|
| __exit__(...)
|
| __iter__(self, /)
| Implement iter(self).
|
| readlines(self, hint=-1, /)
| Return a list of lines from the stream.
|
| hint can be specified to control the number of lines read: no more
| lines will be read if the total size (in bytes/characters) of all
| lines so far exceeds hint.
|
| writelines(self, lines, /)
| Write a list of lines to stream.
|
| Line separators are not added, so it is usual for each of the
| lines provided to have a line separator at the end.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from _io._IOBase:
|
| __dict__
typer.FileTextWrite
Python Library Documentation: class FileTextWrite in module typer.models
class FileTextWrite(FileText)
| FileTextWrite(buffer, encoding=None, errors=None, newline=None, line_buffering=False, write_through=False)
|
| You can use this class for writing text. Alternatively, you can use `FileText` with `mode="w"`.
| The default mode of this class is `mode="w"`.
|
| **Example**
|
| ```python
| from typing import Annotated
|
| import typer
|
| app = typer.Typer()
|
| @app.command()
| def main(config: Annotated[typer.FileTextWrite, typer.Option()]):
| config.write("Some config written by the app")
| print("Config written")
|
| if __name__ == "__main__":
| app()
| ```
|
| Method resolution order:
| FileTextWrite
| FileText
| _io.TextIOWrapper
| _io._TextIOBase
| _io._IOBase
| builtins.object
|
| Methods inherited from _io.TextIOWrapper:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Helper for pickle.
|
| __reduce_ex__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| close(self, /)
| Flush and close the IO object.
|
| This method has no effect if the file is already closed.
|
| detach(self, /)
| Separate the underlying buffer from the TextIOBase and return it.
|
| After the underlying buffer has been detached, the TextIO is in an unusable state.
|
| fileno(self, /)
| Return underlying file descriptor if one exists.
|
| Raise OSError if the IO object does not use a file descriptor.
|
| flush(self, /)
| Flush write buffers, if applicable.
|
| This is not implemented for read-only and non-blocking streams.
|
| isatty(self, /)
| Return whether this is an 'interactive' stream.
|
| Return False if it can't be determined.
|
| read(self, size=-1, /)
| Read at most size characters from stream.
|
| Read from underlying buffer until we have size characters or we hit EOF.
| If size is negative or omitted, read until EOF.
|
| readable(self, /)
| Return whether object was opened for reading.
|
| If False, read() will raise OSError.
|
| readline(self, size=-1, /)
| Read until newline or EOF.
|
| Return an empty string if EOF is hit immediately.
| If size is specified, at most size characters will be read.
|
| reconfigure(self, /, *, encoding=None, errors=None, newline=None, line_buffering=None, write_through=None)
| Reconfigure the text stream with new parameters.
|
| This also does an implicit stream flush.
|
| seek(self, cookie, whence=0, /)
| Set the stream position, and return the new stream position.
|
| cookie
| Zero or an opaque number returned by tell().
| whence
| The relative position to seek from.
|
| Four operations are supported, given by the following argument
| combinations:
|
| - seek(0, SEEK_SET): Rewind to the start of the stream.
| - seek(cookie, SEEK_SET): Restore a previous position;
| 'cookie' must be a number returned by tell().
| - seek(0, SEEK_END): Fast-forward to the end of the stream.
| - seek(0, SEEK_CUR): Leave the current stream position unchanged.
|
| Any other argument combinations are invalid,
| and may raise exceptions.
|
| seekable(self, /)
| Return whether object supports random access.
|
| If False, seek(), tell() and truncate() will raise OSError.
| This method may need to do a test seek().
|
| tell(self, /)
| Return the stream position as an opaque number.
|
| The return value of tell() can be given as input to seek(), to restore a
| previous stream position.
|
| truncate(self, pos=None, /)
| Truncate file to size bytes.
|
| File pointer is left unchanged. Size defaults to the current IO position
| as reported by tell(). Return the new size.
|
| writable(self, /)
| Return whether object was opened for writing.
|
| If False, write() will raise OSError.
|
| write(self, text, /)
| Write string s to stream.
|
| Return the number of characters written
| (which is always equal to the length of the string).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from _io.TextIOWrapper:
|
| buffer
|
| closed
|
| encoding
| Encoding of the text stream.
|
| Subclasses should override.
|
| errors
| The error setting of the decoder or encoder.
|
| Subclasses should override.
|
| line_buffering
|
| name
|
| newlines
| Line endings translated so far.
|
| Only line endings translated during reading are considered.
|
| Subclasses should override.
|
| write_through
|
| ----------------------------------------------------------------------
| Methods inherited from _io._IOBase:
|
| __del__(...)
|
| __enter__(...)
|
| __exit__(...)
|
| __iter__(self, /)
| Implement iter(self).
|
| readlines(self, hint=-1, /)
| Return a list of lines from the stream.
|
| hint can be specified to control the number of lines read: no more
| lines will be read if the total size (in bytes/characters) of all
| lines so far exceeds hint.
|
| writelines(self, lines, /)
| Write a list of lines to stream.
|
| Line separators are not added, so it is usual for each of the
| lines provided to have a line separator at the end.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from _io._IOBase:
|
| __dict__
typer.Option
Python Library Documentation: function Option in module typer.params
Option(default: Annotated[Any | None, Doc('\n Usually, [CLI options](https://typer.tiangolo.com/tutorial/options/) are optional and have a default value, passed on like this:\n\n **Example**\n\n ```python\n @app.command()\n def main(network: str = typer.Option("CNN")):\n print(f"Training neural network of type: {network}")\n ```\n\n Note that this usage is deprecated, and we recommend to use `Annotated` instead:\n ```\n @app.command()\n def main(network: Annotated[str, typer.Option()] = "CNN"):\n print(f"Hello {name}!")\n ```\n\n You can also use `...` ([Ellipsis](https://docs.python.org/3/library/constants.html#Ellipsis)) as the "default" value to clarify that this is a required CLI option.\n ')] = Ellipsis, *param_decls: Annotated[str, Doc('\n Positional argument that defines how users can call this option on the command line. This may be one or multiple aliases, all strings.\n If not defined, Typer will automatically use the function parameter as default name.\n See [the tutorial about CLI Option Names](https://typer.tiangolo.com/tutorial/options/name/) for more details.\n\n **Example**\n\n ```python\n @app.command()\n def main(user_name: Annotated[str, typer.Option("--user", "-u", "-x")]):\n print(f"Hello {user_name}")\n ```\n ')], callback: Annotated[collections.abc.Callable[..., Any] | None, Doc('\n Add a callback to this CLI Option, to execute additional logic after its value was received from the terminal.\n See [the tutorial about callbacks](https://typer.tiangolo.com/tutorial/options/callback-and-context/) for more details.\n\n **Example**\n\n ```python\n def name_callback(value: str):\n if value != "Deadpool":\n raise typer.BadParameter("Only Deadpool is allowed")\n return value\n\n @app.command()\n def main(name: Annotated[str, typer.Option(callback=name_callback)]):\n print(f"Hello {name}")\n ```\n ')] = None, metavar: Annotated[str | None, Doc('\n Customize the name displayed in the [help text](https://typer.tiangolo.com/tutorial/options/help/) to represent this CLI option.\n Note that this doesn\'t influence the way the option must be called.\n\n **Example**\n\n ```python\n @app.command()\n def main(user: Annotated[str, typer.Option(metavar="User name")]):\n print(f"Hello {user}")\n ```\n ')] = None, expose_value: Annotated[bool, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.\n\n ---\n\n If this is `True` then the value is passed onwards to the command callback and stored on the context, otherwise it’s skipped.\n ")] = True, is_eager: Annotated[bool, Doc('\n Mark a CLI Option to be "eager", ensuring it gets processed before other CLI parameters. This could be relevant when there are other parameters with callbacks that could exit the program early.\n For more information and an extended example, see the documentation [here](https://typer.tiangolo.com/tutorial/options/version/#fix-with-is_eager).\n ')] = False, envvar: Annotated[str | list[str] | None, Doc('\n Configure a CLI Option to read its value from an environment variable if it is not provided in the command line.\n For more information, see the [documentation on Environment Variables](https://typer.tiangolo.com/tutorial/arguments/envvar/).\n\n **Example**\n\n ```python\n @app.command()\n def main(user: Annotated[str, typer.Option(envvar="ME")]):\n print(f"Hello {user}")\n ```\n ')] = None, shell_complete: Annotated[collections.abc.Callable[[typer._click.core.Context, typer._click.core.Parameter, str], list['CompletionItem'] | list[str]] | None, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.\n It is however not fully functional, and will likely be removed in future versions.\n ")] = None, autocompletion: Annotated[collections.abc.Callable[..., Any] | None, Doc('\n Provide a custom function that helps to autocomplete the values of this CLI Option.\n See [the tutorial on parameter autocompletion](https://typer.tiangolo.com/tutorial/options-autocompletion) for more details.\n\n **Example**\n\n ```python\n def complete():\n return ["Me", "Myself", "I"]\n\n @app.command()\n def main(name: Annotated[str, typer.Option(autocompletion=complete)]):\n print(f"Hello {name}")\n ```\n ')] = None, default_factory: Annotated[collections.abc.Callable[[], Any] | None, Doc('\n Provide a custom function that dynamically generates a [default](https://typer.tiangolo.com/tutorial/arguments/default) for this CLI Option.\n\n **Example**\n\n ```python\n def get_name():\n return random.choice(["Me", "Myself", "I"])\n\n @app.command()\n def main(name: Annotated[str, typer.Option(default_factory=get_name)]):\n print(f"Hello {name}")\n ```\n ')] = None, parser: Annotated[collections.abc.Callable[[str], Any] | None, Doc('\n Use your own custom types in Typer applications by defining a `parser` function that parses input into your own types:\n\n **Example**\n\n ```python\n class CustomClass:\n def __init__(self, value: str):\n self.value = value\n\n def __str__(self):\n return f"<CustomClass: value={self.value}>"\n\n def my_parser(value: str):\n return CustomClass(value * 2)\n\n @app.command()\n def main(opt: Annotated[CustomClass, typer.Option(parser=my_parser)] = "Foo"):\n print(f"--opt is {opt}")\n ```\n ')] = None, click_type: Annotated[typer._click.types.ParamType | None, Doc('\n Define this parameter to use a [custom Click type](https://click.palletsprojects.com/en/stable/parameters/#implementing-custom-types) in your Typer applications.\n\n **Example**\n\n ```python\n class MyClass:\n def __init__(self, value: str):\n self.value = value\n\n def __str__(self):\n return f"<MyClass: value={self.value}>"\n\n class MyParser(click.ParamType):\n name = "MyClass"\n\n def convert(self, value, param, ctx):\n return MyClass(value * 3)\n\n @app.command()\n def main(opt: Annotated[MyClass, typer.Option(click_type=MyParser())] = "Foo"):\n print(f"--opt is {opt}")\n ```\n ')] = None, show_default: Annotated[bool | str, Doc('\n When set to `False`, don\'t show the default value of this CLI Option in the [help text](https://typer.tiangolo.com/tutorial/options/help/).\n\n **Example**\n\n ```python\n @app.command()\n def main(name: Annotated[str, typer.Option(show_default=False)] = "Rick"):\n print(f"Hello {name}")\n ```\n ')] = True, prompt: Annotated[bool | str, Doc('\n When set to `True`, a prompt will appear to ask for the value of this CLI Option if it was not provided:\n\n **Example**\n\n ```python\n @app.command()\n def main(name: str, lastname: Annotated[str, typer.Option(prompt=True)]):\n print(f"Hello {name} {lastname}")\n ```\n ')] = False, confirmation_prompt: Annotated[bool, Doc('\n When set to `True`, a user will need to type a prompted value twice (may be useful for passwords etc.).\n\n **Example**\n\n ```python\n @app.command()\n def main(project: Annotated[str, typer.Option(prompt=True, confirmation_prompt=True)]):\n print(f"Deleting project {project}")\n ```\n ')] = False, prompt_required: Annotated[bool, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.\n\n ---\n\n If this is `False` then a prompt is only shown if the option's flag is given without a value.\n ")] = True, hide_input: Annotated[bool, Doc('\n When you\'ve configured a prompt, for instance for [querying a password](https://typer.tiangolo.com/tutorial/options/password/),\n don\'t show anything on the screen while the user is typing the value.\n\n **Example**\n\n ```python\n @app.command()\n def login(\n name: str,\n password: Annotated[str, typer.Option(prompt=True, hide_input=True)],\n ):\n print(f"Hello {name}. Doing something very secure with password.")\n ```\n ')] = False, is_flag: Annotated[bool | None, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.\n It is however not fully functional, and will likely be removed in future versions.\n ")] = None, flag_value: Annotated[Any | None, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.\n It is however not fully functional, and will likely be removed in future versions.\n ")] = None, count: Annotated[bool, Doc('\n Make a CLI Option work as a [counter](https://typer.tiangolo.com/tutorial/parameter-types/number/#counter-cli-options).\n The CLI option will have the `int` value representing the number of times the option was used on the command line.\n\n **Example**\n\n ```python\n @app.command()\n def main(verbose: Annotated[int, typer.Option("--verbose", "-v", count=True)] = 0):\n print(f"Verbose level is {verbose}")\n ```\n ')] = False, allow_from_autoenv: Annotated[bool, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.\n\n ---\n\n If this is enabled then the value of this parameter will be pulled from an environment variable in case a prefix is defined on the context.\n ")] = True, help: Annotated[str | None, Doc('\n Help text for this CLI Option.\n See [the tutorial about CLI Options with help](https://typer.tiangolo.com/tutorial/options/help/) for more dedails.\n\n **Example**\n\n ```python\n @app.command()\n def greet(name: Annotated[str, typer.Option(help="Person to greet")] = "Deadpool"):\n print(f"Hello {name}")\n ```\n ')] = None, hidden: Annotated[bool, Doc('\n Hide this CLI Option from [help outputs](https://typer.tiangolo.com/tutorial/options/help). `False` by default.\n\n **Example**\n\n ```python\n @app.command()\n def greet(name: Annotated[str, typer.Option(hidden=True)] = "Deadpool"):\n print(f"Hello {name}")\n ```\n ')] = False, show_choices: Annotated[bool, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.\n\n ---\n\n When set to `False`, this suppresses choices from being displayed inline when `prompt` is used.\n ")] = True, show_envvar: Annotated[bool, Doc('\n When an ["envvar"](https://typer.tiangolo.com/tutorial/arguments/envvar) is defined, prevent it from showing up in the help text:\n\n **Example**\n\n ```python\n @app.command()\n def main(user: Annotated[str, typer.Option(envvar="ME", show_envvar=False)]):\n print(f"Hello {user}")\n ```\n ')] = True, case_sensitive: Annotated[bool, Doc('\n For a CLI Option representing an [Enum (choice)](https://typer.tiangolo.com/tutorial/parameter-types/enum),\n you can allow case-insensitive matching with this parameter:\n\n **Example**\n\n ```python\n from enum import Enum\n\n class NeuralNetwork(str, Enum):\n simple = "simple"\n conv = "conv"\n lstm = "lstm"\n\n @app.command()\n def main(\n network: Annotated[NeuralNetwork, typer.Option(case_sensitive=False)]):\n print(f"Training neural network of type: {network.value}")\n ```\n\n With this setting, "LSTM" or "lstm" will both be valid values that will be resolved to `NeuralNetwork.lstm`.\n ')] = True, min: Annotated[int | float | None, Doc('\n For a CLI Option representing a [number](https://typer.tiangolo.com/tutorial/parameter-types/number/) (`int` or `float`),\n you can define numeric validations with `min` and `max` values:\n\n **Example**\n\n ```python\n @app.command()\n def main(\n user: Annotated[str, typer.Argument()],\n user_id: Annotated[int, typer.Option(min=1, max=1000)],\n ):\n print(f"ID for {user} is {user_id}")\n ```\n\n If the user attempts to input an invalid number, an error will be shown, explaining why the value is invalid.\n ')] = None, max: Annotated[int | float | None, Doc('\n For a CLI Option representing a [number](https://typer.tiangolo.com/tutorial/parameter-types/number/) (`int` or `float`),\n you can define numeric validations with `min` and `max` values:\n\n **Example**\n\n ```python\n @app.command()\n def main(\n user: Annotated[str, typer.Argument()],\n user_id: Annotated[int, typer.Option(min=1, max=1000)],\n ):\n print(f"ID for {user} is {user_id}")\n ```\n\n If the user attempts to input an invalid number, an error will be shown, explaining why the value is invalid.\n ')] = None, clamp: Annotated[bool, Doc('\n For a CLI Option representing a [number](https://typer.tiangolo.com/tutorial/parameter-types/number/) and that is bounded by using `min` and/or `max`,\n you can opt to use the closest minimum or maximum value instead of raising an error when the value is out of bounds. This is done by setting `clamp` to `True`.\n\n **Example**\n\n ```python\n @app.command()\n def main(\n user: Annotated[str, typer.Argument()],\n user_id: Annotated[int, typer.Option(min=1, max=1000, clamp=True)],\n ):\n print(f"ID for {user} is {user_id}")\n ```\n\n If the user attempts to input 3420 for `user_id`, this will internally be converted to `1000`.\n ')] = False, formats: Annotated[list[str] | None, Doc('\n For a CLI Option representing a [DateTime object](https://typer.tiangolo.com/tutorial/parameter-types/datetime),\n you can customize the formats that can be parsed automatically:\n\n **Example**\n\n ```python\n from datetime import datetime\n\n @app.command()\n def main(\n birthday: Annotated[\n datetime,\n typer.Option(\n formats=["%Y-%m-%d", "%Y-%m-%d %H:%M:%S", "%m/%d/%Y"]\n ),\n ],\n ):\n print(f"Birthday defined at: {birthday}")\n ```\n ')] = None, mode: Annotated[str | None, Doc('\n For a CLI Option representing a [File object](https://typer.tiangolo.com/tutorial/parameter-types/file/),\n you can customize the mode to open the file with. If unset, Typer will set a [sensible value by default](https://typer.tiangolo.com/tutorial/parameter-types/file/#advanced-mode).\n\n **Example**\n\n ```python\n @app.command()\n def main(config: Annotated[typer.FileText, typer.Option(mode="a")]):\n config.write("This is a single line\\n")\n print("Config line written")\n ```\n ')] = None, encoding: Annotated[str | None, Doc('\n Customize the encoding of this CLI Option represented by a [File object](https://typer.tiangolo.com/tutorial/parameter-types/file/).\n\n **Example**\n\n ```python\n @app.command()\n def main(config: Annotated[typer.FileText, typer.Option(encoding="utf-8")]):\n config.write("All the text gets written\\n")\n ```\n ')] = None, errors: Annotated[str | None, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.\n\n ---\n\n The error handling mode.\n ")] = 'strict', lazy: Annotated[bool | None, Doc('\n For a CLI Option representing a [File object](https://typer.tiangolo.com/tutorial/parameter-types/file/),\n by default the file will not be created until you actually start writing to it.\n You can change this behaviour by setting this parameter.\n By default, it\'s set to `True` for writing and to `False` for reading.\n\n **Example**\n\n ```python\n @app.command()\n def main(config: Annotated[typer.FileText, typer.Option(mode="a", lazy=False)]):\n config.write("This is a single line\\n")\n print("Config line written")\n ```\n ')] = None, atomic: Annotated[bool, Doc('\n For a CLI Option representing a [File object](https://typer.tiangolo.com/tutorial/parameter-types/file/),\n you can ensure that all write instructions first go into a temporal file, and are only moved to the final destination after completing\n by setting `atomic` to `True`. This can be useful for files with potential concurrent access.\n\n **Example**\n\n ```python\n @app.command()\n def main(config: Annotated[typer.FileText, typer.Option(mode="a", atomic=True)]):\n config.write("All the text")\n ```\n ')] = False, exists: Annotated[bool, Doc('\n When set to `True` for a [`Path` CLI Option](https://typer.tiangolo.com/tutorial/parameter-types/path/),\n additional validation is performed to check that the file or directory exists. If not, the value will be invalid.\n\n **Example**\n\n ```python\n from pathlib import Path\n\n @app.command()\n def main(config: Annotated[Path, typer.Option(exists=True)]):\n text = config.read_text()\n print(f"Config file contents: {text}")\n ```\n ')] = False, file_okay: Annotated[bool, Doc('\n Determine whether or not a [`Path` CLI Option](https://typer.tiangolo.com/tutorial/parameter-types/path/)\n is allowed to refer to a file. When this is set to `False`, the application will raise a validation error when a path to a file is given.\n\n **Example**\n\n ```python\n from pathlib import Path\n\n @app.command()\n def main(config: Annotated[Path, typer.Option(exists=True, file_okay=False)]):\n print(f"Directory listing: {[x.name for x in config.iterdir()]}")\n ```\n ')] = True, dir_okay: Annotated[bool, Doc('\n Determine whether or not a [`Path` CLI Option](https://typer.tiangolo.com/tutorial/parameter-types/path/)\n is allowed to refer to a directory. When this is set to `False`, the application will raise a validation error when a path to a directory is given.\n\n **Example**\n\n ```python\n from pathlib import Path\n\n @app.command()\n def main(config: Annotated[Path, typer.Argument(exists=True, dir_okay=False)]):\n text = config.read_text()\n print(f"Config file contents: {text}")\n ```\n ')] = True, writable: Annotated[bool, Doc('\n Whether or not to perform a writable check for this [`Path` CLI Option](https://typer.tiangolo.com/tutorial/parameter-types/path/).\n\n **Example**\n\n ```python\n from pathlib import Path\n\n @app.command()\n def main(config: Annotated[Path, typer.Option(writable=True)]):\n config.write_text("All the text")\n ```\n ')] = False, readable: Annotated[bool, Doc('\n Whether or not to perform a readable check for this [`Path` CLI Option](https://typer.tiangolo.com/tutorial/parameter-types/path/).\n\n **Example**\n\n ```python\n from pathlib import Path\n\n @app.command()\n def main(config: Annotated[Path, typer.Option(readable=True)]):\n config.read_text("All the text")\n ```\n ')] = True, resolve_path: Annotated[bool, Doc('\n Whether or not to fully resolve the path of this [`Path` CLI Option](https://typer.tiangolo.com/tutorial/parameter-types/path/),\n meaning that the path becomes absolute and symlinks are resolved.\n\n **Example**\n\n ```python\n from pathlib import Path\n\n @app.command()\n def main(config: Annotated[Path, typer.Option(resolve_path=True)]):\n config.read_text("All the text")\n ```\n ')] = False, allow_dash: Annotated[bool, Doc('\n When set to `True`, a single dash for this [`Path` CLI Option](https://typer.tiangolo.com/tutorial/parameter-types/path/)\n would be a valid value, indicating standard streams. This is a more advanced use-case.\n ')] = False, path_type: Annotated[None | type[str] | type[bytes], Doc('\n A string type that will be used to represent this [`Path` argument](https://typer.tiangolo.com/tutorial/parameter-types/path/).\n The default is `None` which means the return value will be either bytes or unicode, depending on what makes most sense given the input data.\n This is a more advanced use-case.\n ')] = None, rich_help_panel: Annotated[str | None, Doc('\n Set the panel name where you want this CLI Option to be shown in the [help text](https://typer.tiangolo.com/tutorial/arguments/help).\n\n **Example**\n\n ```python\n @app.command()\n def main(\n name: Annotated[str, typer.Argument(help="Who to greet")],\n age: Annotated[str, typer.Option(help="Their age", rich_help_panel="Data")],\n ):\n print(f"Hello {name} of age {age}")\n ```\n ')] = None) -> Any
A [CLI Option](https://typer.tiangolo.com/tutorial/options) is a parameter to your command line application that is called with a single or double dash, something like `--verbose` or `-v`.
Often, CLI Options are optional, meaning that users can omit them from the command. However, you can set them to be required by using `Annotated`
and omitting a default value.
## Example
```python
@app.command()
def register(
user: Annotated[str, typer.Argument()],
age: Annotated[int, typer.Option(min=18)],
):
print(f"User is {user}")
print(f"--age is {age}")
```
Note how in this example, `--age` is a required CLI Option.
typer.Typer
Python Library Documentation: class Typer in module typer.main
class Typer(builtins.object)
| Typer(*, name: Annotated[str | None, Doc('\n The name of this application.\n Mostly used to set the name for [subcommands](https://typer.tiangolo.com/tutorial/subcommands/), in which case it can be overridden by `add_typer(name=...)`.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(name="users")\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D4370A810>, cls: Annotated[type[typer.core.TyperGroup] | None, Doc('\n The class of this app. Mainly used when [using the Click library underneath](https://typer.tiangolo.com/tutorial/using-click/). Can usually be left at the default value `None`.\n Otherwise, should be a subtype of `TyperGroup`.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(cls=TyperGroup)\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D4370A840>, invoke_without_command: Annotated[bool, Doc('\n By setting this to `True`, you can make sure a callback is executed even when no subcommand is provided.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(invoke_without_command=True)\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D4370AA20>, no_args_is_help: Annotated[bool, Doc('\n If this is set to `True`, running a command without any arguments will automatically show the help page.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(no_args_is_help=True)\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F4C890>, subcommand_metavar: Annotated[str | None, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n How to represent the subcommand argument in help.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F4D2B0>, chain: Annotated[bool, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n Allow passing more than one subcommand argument.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F4D7C0>, result_callback: Annotated[collections.abc.Callable[..., Any] | None, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n A function to call after the group's and subcommand's callbacks.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F4DA30>, context_settings: Annotated[dict[Any, Any] | None, Doc('\n Pass configurations for the [context](https://typer.tiangolo.com/tutorial/commands/context/).\n Available configurations can be found in the docs for Click\'s `Context` [here](https://click.palletsprojects.com/en/stable/api/#context).\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(context_settings={"help_option_names": ["-h", "--help"]})\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77D10>, callback: Annotated[collections.abc.Callable[..., Any] | None, Doc('\n Add a callback to the main Typer app. Can be overridden with `@app.callback()`.\n See [the tutorial about callbacks](https://typer.tiangolo.com/tutorial/commands/callback/) for more details.\n\n **Example**\n\n ```python\n import typer\n\n def callback():\n print("Running a command")\n\n app = typer.Typer(callback=callback)\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77D70>, help: Annotated[str | None, Doc('\n Help text for the main Typer app.\n See [the tutorial about name and help](https://typer.tiangolo.com/tutorial/subcommands/name-and-help) for different ways of setting a command\'s help,\n and which one takes priority.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(help="Some help.")\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77DA0>, epilog: Annotated[str | None, Doc('\n Text that will be printed right after the help text.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(epilog="May the force be with you")\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77DD0>, short_help: Annotated[str | None, Doc('\n A shortened version of the help text that can be used e.g. in the help table listing subcommands.\n When not defined, the normal `help` text will be used instead.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(help="A lot of explanation about user management", short_help="user management")\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77E00>, options_metavar: Annotated[str, Doc('\n In the example usage string of the help text for a command, the default placeholder for various arguments is `[OPTIONS]`.\n Set `options_metavar` to change this into a different string.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(options_metavar="[OPTS]")\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77E30>, add_help_option: Annotated[bool, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n By default each command registers a `--help` option. This can be disabled by this parameter.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77E60>, hidden: Annotated[bool, Doc('\n Hide this command from help outputs. `False` by default.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(hidden=True)\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77E90>, deprecated: Annotated[bool, Doc('\n Mark this command as being deprecated in the help text. `False` by default.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(deprecated=True)\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77EC0>, add_completion: Annotated[bool, Doc('\n Toggle whether or not to add the `--install-completion` and `--show-completion` options to the app.\n Set to `True` by default.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(add_completion=False)\n ```\n ')] = True, rich_markup_mode: Annotated[Literal['markdown', 'rich', None], Doc('\n Enable markup text if you have Rich installed. This can be set to `"markdown"`, `"rich"`, or `None`.\n By default, `rich_markup_mode` is `None` if Rich is not installed, and `"rich"` if it is installed.\n See [the tutorial on help formatting](https://typer.tiangolo.com/tutorial/commands/help/#rich-markdown-and-markup) for more information.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(rich_markup_mode="rich")\n ```\n ')] = 'rich', rich_help_panel: Annotated[str | None, Doc('\n Set the panel name of the command when the help is printed with Rich.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(rich_help_panel="Utils and Configs")\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77EF0>, suggest_commands: Annotated[bool, Doc('\n As of version 0.20.0, Typer provides [support for mistyped command names](https://typer.tiangolo.com/tutorial/commands/help/#suggest-commands) by printing helpful suggestions.\n You can turn this setting off with `suggest_commands`:\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(suggest_commands=False)\n ```\n ')] = True, pretty_exceptions_enable: Annotated[bool, Doc('\n If you want to disable [pretty exceptions with Rich](https://typer.tiangolo.com/tutorial/exceptions/#exceptions-with-rich),\n you can set `pretty_exceptions_enable` to `False`. When doing so, you will see the usual standard exception trace.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(pretty_exceptions_enable=False)\n ```\n ')] = True, pretty_exceptions_show_locals: Annotated[bool, Doc('\n If Rich is installed, [error messages](https://typer.tiangolo.com/tutorial/exceptions/#exceptions-and-errors)\n will be nicely printed.\n\n If you set `pretty_exceptions_show_locals=True` it will also include the values of local variables for easy debugging.\n\n However, if such a variable contains delicate information, you should consider leaving `pretty_exceptions_show_locals=False`\n (the default) to `False` to enhance security.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(pretty_exceptions_show_locals=True)\n ```\n ')] = False, pretty_exceptions_short: Annotated[bool, Doc('\n By default, [pretty exceptions formatted with Rich](https://typer.tiangolo.com/tutorial/exceptions/#exceptions-with-rich) hide the long stack trace.\n If you want to show the full trace instead, you can set the parameter `pretty_exceptions_short` to `False`:\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(pretty_exceptions_short=False)\n ```\n ')] = True)
|
| `Typer` main class, the main entrypoint to use Typer.
|
| Read more in the
| [Typer docs for First Steps](https://typer.tiangolo.com/tutorial/typer-app/).
|
| ## Example
|
| ```python
| import typer
|
| app = typer.Typer()
| ```
|
| Methods defined here:
|
| __call__(self, *args: Any, **kwargs: Any) -> Any
| Call self as a function.
|
| __init__(self, *, name: Annotated[str | None, Doc('\n The name of this application.\n Mostly used to set the name for [subcommands](https://typer.tiangolo.com/tutorial/subcommands/), in which case it can be overridden by `add_typer(name=...)`.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(name="users")\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D4370A810>, cls: Annotated[type[typer.core.TyperGroup] | None, Doc('\n The class of this app. Mainly used when [using the Click library underneath](https://typer.tiangolo.com/tutorial/using-click/). Can usually be left at the default value `None`.\n Otherwise, should be a subtype of `TyperGroup`.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(cls=TyperGroup)\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D4370A840>, invoke_without_command: Annotated[bool, Doc('\n By setting this to `True`, you can make sure a callback is executed even when no subcommand is provided.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(invoke_without_command=True)\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D4370AA20>, no_args_is_help: Annotated[bool, Doc('\n If this is set to `True`, running a command without any arguments will automatically show the help page.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(no_args_is_help=True)\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F4C890>, subcommand_metavar: Annotated[str | None, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n How to represent the subcommand argument in help.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F4D2B0>, chain: Annotated[bool, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n Allow passing more than one subcommand argument.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F4D7C0>, result_callback: Annotated[collections.abc.Callable[..., Any] | None, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n A function to call after the group's and subcommand's callbacks.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F4DA30>, context_settings: Annotated[dict[Any, Any] | None, Doc('\n Pass configurations for the [context](https://typer.tiangolo.com/tutorial/commands/context/).\n Available configurations can be found in the docs for Click\'s `Context` [here](https://click.palletsprojects.com/en/stable/api/#context).\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(context_settings={"help_option_names": ["-h", "--help"]})\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77D10>, callback: Annotated[collections.abc.Callable[..., Any] | None, Doc('\n Add a callback to the main Typer app. Can be overridden with `@app.callback()`.\n See [the tutorial about callbacks](https://typer.tiangolo.com/tutorial/commands/callback/) for more details.\n\n **Example**\n\n ```python\n import typer\n\n def callback():\n print("Running a command")\n\n app = typer.Typer(callback=callback)\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77D70>, help: Annotated[str | None, Doc('\n Help text for the main Typer app.\n See [the tutorial about name and help](https://typer.tiangolo.com/tutorial/subcommands/name-and-help) for different ways of setting a command\'s help,\n and which one takes priority.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(help="Some help.")\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77DA0>, epilog: Annotated[str | None, Doc('\n Text that will be printed right after the help text.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(epilog="May the force be with you")\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77DD0>, short_help: Annotated[str | None, Doc('\n A shortened version of the help text that can be used e.g. in the help table listing subcommands.\n When not defined, the normal `help` text will be used instead.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(help="A lot of explanation about user management", short_help="user management")\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77E00>, options_metavar: Annotated[str, Doc('\n In the example usage string of the help text for a command, the default placeholder for various arguments is `[OPTIONS]`.\n Set `options_metavar` to change this into a different string.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(options_metavar="[OPTS]")\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77E30>, add_help_option: Annotated[bool, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n By default each command registers a `--help` option. This can be disabled by this parameter.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77E60>, hidden: Annotated[bool, Doc('\n Hide this command from help outputs. `False` by default.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(hidden=True)\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77E90>, deprecated: Annotated[bool, Doc('\n Mark this command as being deprecated in the help text. `False` by default.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(deprecated=True)\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77EC0>, add_completion: Annotated[bool, Doc('\n Toggle whether or not to add the `--install-completion` and `--show-completion` options to the app.\n Set to `True` by default.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(add_completion=False)\n ```\n ')] = True, rich_markup_mode: Annotated[Literal['markdown', 'rich', None], Doc('\n Enable markup text if you have Rich installed. This can be set to `"markdown"`, `"rich"`, or `None`.\n By default, `rich_markup_mode` is `None` if Rich is not installed, and `"rich"` if it is installed.\n See [the tutorial on help formatting](https://typer.tiangolo.com/tutorial/commands/help/#rich-markdown-and-markup) for more information.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(rich_markup_mode="rich")\n ```\n ')] = 'rich', rich_help_panel: Annotated[str | None, Doc('\n Set the panel name of the command when the help is printed with Rich.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(rich_help_panel="Utils and Configs")\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77EF0>, suggest_commands: Annotated[bool, Doc('\n As of version 0.20.0, Typer provides [support for mistyped command names](https://typer.tiangolo.com/tutorial/commands/help/#suggest-commands) by printing helpful suggestions.\n You can turn this setting off with `suggest_commands`:\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(suggest_commands=False)\n ```\n ')] = True, pretty_exceptions_enable: Annotated[bool, Doc('\n If you want to disable [pretty exceptions with Rich](https://typer.tiangolo.com/tutorial/exceptions/#exceptions-with-rich),\n you can set `pretty_exceptions_enable` to `False`. When doing so, you will see the usual standard exception trace.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(pretty_exceptions_enable=False)\n ```\n ')] = True, pretty_exceptions_show_locals: Annotated[bool, Doc('\n If Rich is installed, [error messages](https://typer.tiangolo.com/tutorial/exceptions/#exceptions-and-errors)\n will be nicely printed.\n\n If you set `pretty_exceptions_show_locals=True` it will also include the values of local variables for easy debugging.\n\n However, if such a variable contains delicate information, you should consider leaving `pretty_exceptions_show_locals=False`\n (the default) to `False` to enhance security.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(pretty_exceptions_show_locals=True)\n ```\n ')] = False, pretty_exceptions_short: Annotated[bool, Doc('\n By default, [pretty exceptions formatted with Rich](https://typer.tiangolo.com/tutorial/exceptions/#exceptions-with-rich) hide the long stack trace.\n If you want to show the full trace instead, you can set the parameter `pretty_exceptions_short` to `False`:\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(pretty_exceptions_short=False)\n ```\n ')] = True)
| Initialize self. See help(type(self)) for accurate signature.
|
| add_typer(self, typer_instance: 'Typer', *, name: Annotated[str | None, Doc("\n The name of this subcommand.\n See [the tutorial about name and help](https://typer.tiangolo.com/tutorial/subcommands/name-and-help) for different ways of setting a command's name,\n and which one takes priority.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F960C0>, cls: Annotated[type[typer.core.TyperGroup] | None, Doc('\n The class of this subcommand. Mainly used when [using the Click library underneath](https://typer.tiangolo.com/tutorial/using-click/). Can usually be left at the default value `None`.\n Otherwise, should be a subtype of `TyperGroup`.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F960F0>, invoke_without_command: Annotated[bool, Doc('\n By setting this to `True`, you can make sure a callback is executed even when no subcommand is provided.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F96120>, no_args_is_help: Annotated[bool, Doc('\n If this is set to `True`, running a command without any arguments will automatically show the help page.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F96150>, subcommand_metavar: Annotated[str | None, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n How to represent the subcommand argument in help.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F96180>, chain: Annotated[bool, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n Allow passing more than one subcommand argument.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F961B0>, result_callback: Annotated[collections.abc.Callable[..., Any] | None, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n A function to call after the group's and subcommand's callbacks.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F961E0>, context_settings: Annotated[dict[Any, Any] | None, Doc("\n Pass configurations for the [context](https://typer.tiangolo.com/tutorial/commands/context/).\n Available configurations can be found in the docs for Click's `Context` [here](https://click.palletsprojects.com/en/stable/api/#context).\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F96210>, callback: Annotated[collections.abc.Callable[..., Any] | None, Doc('\n Add a callback to this app.\n See [the tutorial about callbacks](https://typer.tiangolo.com/tutorial/commands/callback/) for more details.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F96240>, help: Annotated[str | None, Doc("\n Help text for the subcommand.\n See [the tutorial about name and help](https://typer.tiangolo.com/tutorial/subcommands/name-and-help) for different ways of setting a command's help,\n and which one takes priority.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F96270>, epilog: Annotated[str | None, Doc('\n Text that will be printed right after the help text.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F962A0>, short_help: Annotated[str | None, Doc('\n A shortened version of the help text that can be used e.g. in the help table listing subcommands.\n When not defined, the normal `help` text will be used instead.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F962D0>, options_metavar: Annotated[str | None, Doc('\n In the example usage string of the help text for a command, the default placeholder for various arguments is `[OPTIONS]`.\n Set `options_metavar` to change this into a different string. When `None`, the default value will be used.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F96300>, add_help_option: Annotated[bool, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n By default each command registers a `--help` option. This can be disabled by this parameter.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F96330>, hidden: Annotated[bool, Doc('\n Hide this command from help outputs. `False` by default.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F96360>, deprecated: Annotated[bool, Doc('\n Mark this command as deprecated in the help outputs. `False` by default.\n ')] = False, rich_help_panel: Annotated[str | None, Doc('\n Set the panel name of the command when the help is printed with Rich.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F96390>) -> None
| Add subcommands to the main app using `app.add_typer()`.
| Subcommands may be defined in separate modules, ensuring clean separation of code by functionality.
|
| Read more in the
| [Typer docs for SubCommands](https://typer.tiangolo.com/tutorial/subcommands/add-typer/).
|
| ## Example
|
| ```python
| import typer
|
| from .add import app as add_app
| from .delete import app as delete_app
|
| app = typer.Typer()
|
| app.add_typer(add_app)
| app.add_typer(delete_app)
| ```
|
| callback(self, *, cls: Annotated[type[typer.core.TyperGroup] | None, Doc('\n The class of this app. Mainly used when [using the Click library underneath](https://typer.tiangolo.com/tutorial/using-click/). Can usually be left at the default value `None`.\n Otherwise, should be a subtype of `TyperGroup`.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F95100>, invoke_without_command: Annotated[bool, Doc('\n By setting this to `True`, you can make sure a callback is executed even when no subcommand is provided.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F95130>, no_args_is_help: Annotated[bool, Doc('\n If this is set to `True`, running a command without any arguments will automatically show the help page.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F95160>, subcommand_metavar: Annotated[str | None, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n How to represent the subcommand argument in help.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F95190>, chain: Annotated[bool, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n Allow passing more than one subcommand argument.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F951C0>, result_callback: Annotated[collections.abc.Callable[..., Any] | None, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n A function to call after the group's and subcommand's callbacks.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F951F0>, context_settings: Annotated[dict[Any, Any] | None, Doc("\n Pass configurations for the [context](https://typer.tiangolo.com/tutorial/commands/context/).\n Available configurations can be found in the docs for Click's `Context` [here](https://click.palletsprojects.com/en/stable/api/#context).\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F95220>, help: Annotated[str | None, Doc("\n Help text for the command.\n See [the tutorial about name and help](https://typer.tiangolo.com/tutorial/subcommands/name-and-help) for different ways of setting a command's help,\n and which one takes priority.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F95250>, epilog: Annotated[str | None, Doc('\n Text that will be printed right after the help text.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F95280>, short_help: Annotated[str | None, Doc('\n A shortened version of the help text that can be used e.g. in the help table listing subcommands.\n When not defined, the normal `help` text will be used instead.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F952B0>, options_metavar: Annotated[str | None, Doc('\n In the example usage string of the help text for a command, the default placeholder for various arguments is `[OPTIONS]`.\n Set `options_metavar` to change this into a different string. When `None`, the default value will be used.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F952E0>, add_help_option: Annotated[bool, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n By default each command registers a `--help` option. This can be disabled by this parameter.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F95310>, hidden: Annotated[bool, Doc('\n Hide this command from help outputs. `False` by default.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F95340>, deprecated: Annotated[bool, Doc('\n Mark this command as deprecated in the help text. `False` by default.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F95370>, rich_help_panel: Annotated[str | None, Doc('\n Set the panel name of the command when the help is printed with Rich.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F953A0>) -> collections.abc.Callable[[~CommandFunctionType], ~CommandFunctionType]
| Using the decorator `@app.callback`, you can declare the CLI parameters for the main CLI application.
|
| Read more in the
| [Typer docs for Callbacks](https://typer.tiangolo.com/tutorial/commands/callback/).
|
| ## Example
|
| ```python
| import typer
|
| app = typer.Typer()
| state = {"verbose": False}
|
| @app.callback()
| def main(verbose: bool = False):
| if verbose:
| print("Will write verbose output")
| state["verbose"] = True
|
| @app.command()
| def delete(username: str):
| # define subcommand
| ...
| ```
|
| command(self, name: Annotated[str | None, Doc('\n The name of this command.\n ')] = None, *, cls: Annotated[type[typer.core.TyperCommand] | None, Doc('\n The class of this command. Mainly used when [using the Click library underneath](https://typer.tiangolo.com/tutorial/using-click/). Can usually be left at the default value `None`.\n Otherwise, should be a subtype of `TyperCommand`.\n ')] = None, context_settings: Annotated[dict[Any, Any] | None, Doc("\n Pass configurations for the [context](https://typer.tiangolo.com/tutorial/commands/context/).\n Available configurations can be found in the docs for Click's `Context` [here](https://click.palletsprojects.com/en/stable/api/#context).\n ")] = None, help: Annotated[str | None, Doc("\n Help text for the command.\n See [the tutorial about name and help](https://typer.tiangolo.com/tutorial/subcommands/name-and-help) for different ways of setting a command's help,\n and which one takes priority.\n ")] = None, epilog: Annotated[str | None, Doc('\n Text that will be printed right after the help text.\n ')] = None, short_help: Annotated[str | None, Doc('\n A shortened version of the help text that can be used e.g. in the help table listing subcommands.\n When not defined, the normal `help` text will be used instead.\n ')] = None, options_metavar: Annotated[str | None, Doc('\n In the example usage string of the help text for a command, the default placeholder for various arguments is `[OPTIONS]`.\n Set `options_metavar` to change this into a different string. When `None`, the default value will be used.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F95D90>, add_help_option: Annotated[bool, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n By default each command registers a `--help` option. This can be disabled by this parameter.\n ")] = True, no_args_is_help: Annotated[bool, Doc('\n If this is set to `True`, running a command without any arguments will automatically show the help page.\n ')] = False, hidden: Annotated[bool, Doc('\n Hide this command from help outputs. `False` by default.\n ')] = False, deprecated: Annotated[bool, Doc('\n Mark this command as deprecated in the help outputs. `False` by default.\n ')] = False, rich_help_panel: Annotated[str | None, Doc('\n Set the panel name of the command when the help is printed with Rich.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F95DC0>) -> collections.abc.Callable[[~CommandFunctionType], ~CommandFunctionType]
| Using the decorator `@app.command`, you can define a subcommand of the previously defined Typer app.
|
| Read more in the
| [Typer docs for Commands](https://typer.tiangolo.com/tutorial/commands/).
|
| ## Example
|
| ```python
| import typer
|
| app = typer.Typer()
|
| @app.command()
| def create():
| print("Creating user: Hiro Hamada")
|
| @app.command()
| def delete():
| print("Deleting user: Hiro Hamada")
| ```
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
typer.colors
Python Library Documentation: module typer.colors in typer
NAME
typer.colors - # Variable names to colors, just for completion
DATA
BLACK = 'black'
BLUE = 'blue'
BRIGHT_BLACK = 'bright_black'
BRIGHT_BLUE = 'bright_blue'
BRIGHT_CYAN = 'bright_cyan'
BRIGHT_GREEN = 'bright_green'
BRIGHT_MAGENTA = 'bright_magenta'
BRIGHT_RED = 'bright_red'
BRIGHT_WHITE = 'bright_white'
BRIGHT_YELLOW = 'bright_yellow'
CYAN = 'cyan'
GREEN = 'green'
MAGENTA = 'magenta'
RED = 'red'
RESET = 'reset'
WHITE = 'white'
YELLOW = 'yellow'
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\typer\colors.py
typer.completion
Python Library Documentation: module typer.completion in typer
NAME
typer.completion
FUNCTIONS
get_completion_inspect_parameters() -> tuple[typer.models.ParamMeta, typer.models.ParamMeta]
install_callback(ctx: typer._click.core.Context, param: typer._click.core.Parameter, value: Any) -> Any
shell_complete(cli: typer._click.core.Command, ctx_args: collections.abc.MutableMapping[str, typing.Any], prog_name: str, complete_var: str, instruction: str) -> int
# Re-implement Click's shell_complete to add error message with:
# Invalid completion instruction
# To use 7.x instruction style for compatibility
# And to add extra error messages, for compatibility with Typer in previous versions
# This is only called in new Command method, only used by Click 8.x+
show_callback(ctx: typer._click.core.Context, param: typer._click.core.Parameter, value: Any) -> Any
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\typer\completion.py
typer.confirm
Python Library Documentation: function confirm in module typer._click.termui
confirm(text: str, default: bool | None = False, abort: bool = False, prompt_suffix: str = ': ', show_default: bool = True, err: bool = False) -> bool
Prompts for confirmation (yes/no question).
If the user aborts the input by sending a interrupt signal this
function will catch it and raise an `Abort` exception.
typer.core
Python Library Documentation: module typer.core in typer
NAME
typer.core
CLASSES
typer._click.core.Command(abc.ABC)
TyperCommand
TyperGroup
typer._click.core.Parameter(abc.ABC)
TyperArgument
TyperOption
class TyperArgument(typer._click.core.Parameter)
| TyperArgument(*, param_decls: list[str], type: typing.Any | None = None, required: bool = False, default: typing.Any | None = None, callback: collections.abc.Callable[..., typing.Any] | None = None, nargs: int | None = None, metavar: str | None = None, expose_value: bool = True, is_eager: bool = False, envvar: str | list[str] | None = None, shell_complete: collections.abc.Callable[[typer._click.core.Context, typer._click.core.Parameter, str], list[typer._click.shell_completion.CompletionItem] | list[str]] | None = None, autocompletion: collections.abc.Callable[..., typing.Any] | None = None, show_default: bool | str = True, show_choices: bool = True, show_envvar: bool = True, help: str | None = None, hidden: bool = False, rich_help_panel: str | None = None)
|
| Method resolution order:
| TyperArgument
| typer._click.core.Parameter
| abc.ABC
| builtins.object
|
| Methods defined here:
|
| __init__(self, *, param_decls: list[str], type: typing.Any | None = None, required: bool = False, default: typing.Any | None = None, callback: collections.abc.Callable[..., typing.Any] | None = None, nargs: int | None = None, metavar: str | None = None, expose_value: bool = True, is_eager: bool = False, envvar: str | list[str] | None = None, shell_complete: collections.abc.Callable[[typer._click.core.Context, typer._click.core.Parameter, str], list[typer._click.shell_completion.CompletionItem] | list[str]] | None = None, autocompletion: collections.abc.Callable[..., typing.Any] | None = None, show_default: bool | str = True, show_choices: bool = True, show_envvar: bool = True, help: str | None = None, hidden: bool = False, rich_help_panel: str | None = None)
| Initialize self. See help(type(self)) for accurate signature.
|
| add_to_parser(self, parser: typer._click.parser._OptionParser, ctx: typer._click.core.Context) -> None
|
| get_error_hint(self, ctx: typer._click.core.Context) -> str
| Get a stringified version of the param for use in error messages to
| indicate which param caused the error.
|
| get_help_record(self, ctx: typer._click.core.Context) -> tuple[str, str] | None
|
| get_usage_pieces(self, ctx: typer._click.core.Context) -> list[str]
|
| make_metavar(self, ctx: typer._click.core.Context, *, usage: bool = False) -> str
|
| value_is_missing(self, value: Any) -> bool
|
| ----------------------------------------------------------------------
| Readonly properties defined here:
|
| human_readable_name
| Returns the human readable name of this parameter. This is the
| same as the name for options, but the metavar for arguments.
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| param_type_name = 'argument'
|
| ----------------------------------------------------------------------
| Methods inherited from typer._click.core.Parameter:
|
| __repr__(self) -> str
| Return repr(self).
|
| consume_value(self, ctx: typer._click.core.Context, opts: collections.abc.Mapping[str, typing.Any]) -> tuple[typing.Any, typer._click.core.ParameterSource]
|
| get_default(self, ctx: typer._click.core.Context, call: bool = True) -> typing.Any | collections.abc.Callable[[], typing.Any] | None
| Get the default for the parameter
|
| handle_parse_result(self, ctx: typer._click.core.Context, opts: collections.abc.Mapping[str, typing.Any], args: list[str]) -> tuple[typing.Any, list[str]]
| Process the value produced by the parser from user input.
|
| Always process the value through the Parameter's `type`, wherever it
| comes from.
|
| If the parameter is deprecated, this method warn the user about it. But only if
| the value has been explicitly set by the user (and as such, is not coming from
| a default).
|
| process_value(self, ctx: typer._click.core.Context, value: Any) -> Any
| Process the value of this parameter
|
| resolve_envvar_value(self, ctx: typer._click.core.Context) -> str | None
| Returns the value found in the environment variable(s) attached to this
| parameter.
|
| Environment variables values are `always returned as strings
| <https://docs.python.org/3/library/os.html#os.environ>`_.
|
| This method returns ``None`` if:
|
| - the `envvar` property is not set on `Parameter`,
| - the environment variable is not found in the environment,
| - the variable is found in the environment but its value is empty (i.e. the
| environment variable is present but has an empty string).
|
| If `envvar` is setup with multiple environment variables,
| then only the first non-empty value is returned.
|
| shell_complete(self, ctx: typer._click.core.Context, incomplete: str) -> list['CompletionItem']
| Return a list of completions for the incomplete value. If a
| ``shell_complete`` function was given during init, it is used.
| Otherwise, the `type` `ParamType.shell_complete` function is used.
|
| type_cast_value(self, ctx: typer._click.core.Context, value: Any) -> Any
| Convert and validate a value against the parameter's
| `type`, `multiple`, and `nargs`.
|
| value_from_envvar(self, ctx: typer._click.core.Context) -> str | collections.abc.Sequence[str] | None
| Process the raw environment variable string for this parameter.
|
| Returns the string as-is or splits it into a sequence of strings if the
| parameter is expecting multiple values (i.e. its `nargs` property is set
| to a value other than ``1``).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from typer._click.core.Parameter:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
class TyperCommand(typer._click.core.Command)
| TyperCommand(name: str | None, *, context_settings: dict[str, typing.Any] | None = None, callback: collections.abc.Callable[..., typing.Any] | None = None, params: list[typer._click.core.Parameter] | None = None, help: str | None = None, epilog: str | None = None, short_help: str | None = None, options_metavar: str | None = '[OPTIONS]', add_help_option: bool = True, no_args_is_help: bool = False, hidden: bool = False, deprecated: bool = False, rich_markup_mode: Literal['markdown', 'rich', None] = 'rich', rich_help_panel: str | None = None) -> None
|
| Method resolution order:
| TyperCommand
| typer._click.core.Command
| abc.ABC
| builtins.object
|
| Methods defined here:
|
| __init__(self, name: str | None, *, context_settings: dict[str, typing.Any] | None = None, callback: collections.abc.Callable[..., typing.Any] | None = None, params: list[typer._click.core.Parameter] | None = None, help: str | None = None, epilog: str | None = None, short_help: str | None = None, options_metavar: str | None = '[OPTIONS]', add_help_option: bool = True, no_args_is_help: bool = False, hidden: bool = False, deprecated: bool = False, rich_markup_mode: Literal['markdown', 'rich', None] = 'rich', rich_help_panel: str | None = None) -> None
| Initialize self. See help(type(self)) for accurate signature.
|
| format_help(self, ctx: typer._click.core.Context, formatter: typer._click.formatting.HelpFormatter) -> None
| Writes the help into the formatter if it exists.
|
| format_options(self, ctx: typer._click.core.Context, formatter: typer._click.formatting.HelpFormatter) -> None
|
| main(self, args: collections.abc.Sequence[str] | None = None, prog_name: str | None = None, complete_var: str | None = None, standalone_mode: bool = True, windows_expand_args: bool = True, **extra: Any) -> Any
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| __annotations__ = {}
|
| ----------------------------------------------------------------------
| Methods inherited from typer._click.core.Command:
|
| __call__(self, *args: Any, **kwargs: Any) -> Any
| Alias for self.main
|
| __repr__(self) -> str
| Return repr(self).
|
| collect_usage_pieces(self, ctx: typer._click.core.Context) -> list[str]
| Returns all the pieces that go into the usage line and returns
| it as a list of strings.
|
| format_epilog(self, ctx: typer._click.core.Context, formatter: typer._click.formatting.HelpFormatter) -> None
| Writes the epilog into the formatter if it exists.
|
| format_help_text(self, ctx: typer._click.core.Context, formatter: typer._click.formatting.HelpFormatter) -> None
| Writes the help text to the formatter if it exists.
|
| format_usage(self, ctx: typer._click.core.Context, formatter: typer._click.formatting.HelpFormatter) -> None
| Writes the usage line into the formatter.
|
| get_help(self, ctx: typer._click.core.Context) -> str
| Formats the help into a string and returns it.
|
| get_help_option(self, ctx: typer._click.core.Context) -> Optional[ForwardRef('TyperOption')]
| Returns the help option object.
|
| get_help_option_names(self, ctx: typer._click.core.Context) -> list[str]
| Returns the names for the help option.
|
| get_params(self, ctx: typer._click.core.Context) -> list['Parameter']
|
| get_short_help_str(self, limit: int = 45) -> str
| Gets short help for the command or makes it by shortening the
| long help string.
|
| get_usage(self, ctx: typer._click.core.Context) -> str
| Formats the usage line into a string and returns it.
|
| invoke(self, ctx: typer._click.core.Context) -> Any
| Given a context, this invokes the attached callback (if it exists)
| in the right way.
|
| make_context(self, info_name: str | None, args: list[str], parent: typer._click.core.Context | None = None, **extra: Any) -> typer._click.core.Context
| This function when given an info name and arguments will kick
| off the parsing and create a new `Context`. It does not
| invoke the actual command callback though.
|
| To quickly customize the context class used without overriding
| this method, set the `context_class` attribute.
|
| make_parser(self, ctx: typer._click.core.Context) -> typer._click.parser._OptionParser
| Creates the underlying option parser for this command.
|
| parse_args(self, ctx: typer._click.core.Context, args: list[str]) -> list[str]
|
| shell_complete(self, ctx: typer._click.core.Context, incomplete: str) -> list['CompletionItem']
| Return a list of completions for the incomplete value. Looks
| at the names of options and chained multi-commands.
|
| Any command could be part of a chained multi-command, so sibling
| commands are valid at any point during command completion.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from typer._click.core.Command:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from typer._click.core.Command:
|
| allow_extra_args = False
|
| allow_interspersed_args = True
|
| context_class = <class 'typer._click.core.Context'>
| 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.
|
|
| ignore_unknown_options = False
class TyperGroup(typer._click.core.Command)
| TyperGroup(*, name: str | None = None, commands: dict[str, typer._click.core.Command] | collections.abc.Sequence[typer._click.core.Command] | None = None, rich_markup_mode: Literal['markdown', 'rich', None] = 'rich', rich_help_panel: str | None = None, suggest_commands: bool = True, invoke_without_command: bool = False, no_args_is_help: bool = False, subcommand_metavar: str | None = None, result_callback: collections.abc.Callable[..., typing.Any] | None = None, **attrs: Any) -> None
|
| Method resolution order:
| TyperGroup
| typer._click.core.Command
| abc.ABC
| builtins.object
|
| Methods defined here:
|
| __init__(self, *, name: str | None = None, commands: dict[str, typer._click.core.Command] | collections.abc.Sequence[typer._click.core.Command] | None = None, rich_markup_mode: Literal['markdown', 'rich', None] = 'rich', rich_help_panel: str | None = None, suggest_commands: bool = True, invoke_without_command: bool = False, no_args_is_help: bool = False, subcommand_metavar: str | None = None, result_callback: collections.abc.Callable[..., typing.Any] | None = None, **attrs: Any) -> None
| Initialize self. See help(type(self)) for accurate signature.
|
| add_command(self, cmd: typer._click.core.Command, name: str | None = None) -> None
|
| collect_usage_pieces(self, ctx: typer._click.core.Context) -> list[str]
| Returns all the pieces that go into the usage line and returns
| it as a list of strings.
|
| format_commands(self, ctx: typer._click.core.Context, formatter: typer._click.formatting.HelpFormatter) -> None
|
| format_help(self, ctx: typer._click.core.Context, formatter: typer._click.formatting.HelpFormatter) -> None
| Writes the help into the formatter if it exists.
|
| format_options(self, ctx: typer._click.core.Context, formatter: typer._click.formatting.HelpFormatter) -> None
|
| get_command(self, ctx: typer._click.core.Context, cmd_name: str) -> typer._click.core.Command | None
|
| invoke(self, ctx: typer._click.core.Context) -> Any
| Given a context, this invokes the attached callback (if it exists)
| in the right way.
|
| list_commands(self, ctx: typer._click.core.Context) -> list[str]
| Returns a list of subcommand names, maintaining the original order of creation (cf Issue #933)
|
| main(self, args: collections.abc.Sequence[str] | None = None, prog_name: str | None = None, complete_var: str | None = None, standalone_mode: bool = True, windows_expand_args: bool = True, **extra: Any) -> Any
|
| parse_args(self, ctx: typer._click.core.Context, args: list[str]) -> list[str]
|
| resolve_command(self, ctx: typer._click.core.Context, args: list[str]) -> tuple[str | None, typer._click.core.Command | None, list[str]]
|
| shell_complete(self, ctx: typer._click.core.Context, incomplete: str) -> list[typer._click.shell_completion.CompletionItem]
| Return a list of completions for the incomplete value. Looks
| at the names of options, subcommands, and chained
| multi-commands.
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| __annotations__ = {'command_class': type[typer._click.core.Command] | ...
|
| allow_extra_args = True
|
| allow_interspersed_args = False
|
| command_class = None
|
| group_class = None
|
| ----------------------------------------------------------------------
| Methods inherited from typer._click.core.Command:
|
| __call__(self, *args: Any, **kwargs: Any) -> Any
| Alias for self.main
|
| __repr__(self) -> str
| Return repr(self).
|
| format_epilog(self, ctx: typer._click.core.Context, formatter: typer._click.formatting.HelpFormatter) -> None
| Writes the epilog into the formatter if it exists.
|
| format_help_text(self, ctx: typer._click.core.Context, formatter: typer._click.formatting.HelpFormatter) -> None
| Writes the help text to the formatter if it exists.
|
| format_usage(self, ctx: typer._click.core.Context, formatter: typer._click.formatting.HelpFormatter) -> None
| Writes the usage line into the formatter.
|
| get_help(self, ctx: typer._click.core.Context) -> str
| Formats the help into a string and returns it.
|
| get_help_option(self, ctx: typer._click.core.Context) -> Optional[ForwardRef('TyperOption')]
| Returns the help option object.
|
| get_help_option_names(self, ctx: typer._click.core.Context) -> list[str]
| Returns the names for the help option.
|
| get_params(self, ctx: typer._click.core.Context) -> list['Parameter']
|
| get_short_help_str(self, limit: int = 45) -> str
| Gets short help for the command or makes it by shortening the
| long help string.
|
| get_usage(self, ctx: typer._click.core.Context) -> str
| Formats the usage line into a string and returns it.
|
| make_context(self, info_name: str | None, args: list[str], parent: typer._click.core.Context | None = None, **extra: Any) -> typer._click.core.Context
| This function when given an info name and arguments will kick
| off the parsing and create a new `Context`. It does not
| invoke the actual command callback though.
|
| To quickly customize the context class used without overriding
| this method, set the `context_class` attribute.
|
| make_parser(self, ctx: typer._click.core.Context) -> typer._click.parser._OptionParser
| Creates the underlying option parser for this command.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from typer._click.core.Command:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from typer._click.core.Command:
|
| context_class = <class 'typer._click.core.Context'>
| 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.
|
|
| ignore_unknown_options = False
class TyperOption(typer._click.core.Parameter)
| TyperOption(*, param_decls: list[str], type: typer._click.types.ParamType | typing.Any | None = None, required: bool = False, default: typing.Any | None = None, callback: collections.abc.Callable[..., typing.Any] | None = None, nargs: int | None = None, metavar: str | None = None, expose_value: bool = True, is_eager: bool = False, envvar: str | list[str] | None = None, shell_complete: collections.abc.Callable[[typer._click.core.Context, typer._click.core.Parameter, str], list[typer._click.shell_completion.CompletionItem] | list[str]] | None = None, autocompletion: collections.abc.Callable[..., typing.Any] | None = None, show_default: bool | str = False, prompt: bool | str = False, confirmation_prompt: bool | str = False, prompt_required: bool = True, hide_input: bool = False, is_flag: bool | None = None, multiple: bool = False, count: bool = False, allow_from_autoenv: bool = True, help: str | None = None, hidden: bool = False, show_choices: bool = True, show_envvar: bool = False, rich_help_panel: str | None = None)
|
| Method resolution order:
| TyperOption
| typer._click.core.Parameter
| abc.ABC
| builtins.object
|
| Methods defined here:
|
| __init__(self, *, param_decls: list[str], type: typer._click.types.ParamType | typing.Any | None = None, required: bool = False, default: typing.Any | None = None, callback: collections.abc.Callable[..., typing.Any] | None = None, nargs: int | None = None, metavar: str | None = None, expose_value: bool = True, is_eager: bool = False, envvar: str | list[str] | None = None, shell_complete: collections.abc.Callable[[typer._click.core.Context, typer._click.core.Parameter, str], list[typer._click.shell_completion.CompletionItem] | list[str]] | None = None, autocompletion: collections.abc.Callable[..., typing.Any] | None = None, show_default: bool | str = False, prompt: bool | str = False, confirmation_prompt: bool | str = False, prompt_required: bool = True, hide_input: bool = False, is_flag: bool | None = None, multiple: bool = False, count: bool = False, allow_from_autoenv: bool = True, help: str | None = None, hidden: bool = False, show_choices: bool = True, show_envvar: bool = False, rich_help_panel: str | None = None)
| Initialize self. See help(type(self)) for accurate signature.
|
| add_to_parser(self, parser: typer._click.parser._OptionParser, ctx: typer._click.core.Context) -> None
|
| consume_value(self, ctx: typer._click.core.Context, opts: collections.abc.Mapping[str, typer._click.core.Parameter]) -> tuple[typing.Any, typer._click.core.ParameterSource]
| For `Option`, the value can be collected from an interactive prompt
| if the option is a flag that needs a value (and the `prompt` property is
| set).
|
| Additionally, this method handles flag option that are activated without a
| value, in which case the `flag_value` is returned.
|
| get_error_hint(self, ctx: typer._click.core.Context) -> str
| Get a stringified version of the param for use in error messages to
| indicate which param caused the error.
|
| get_help_record(self, ctx: typer._click.core.Context) -> tuple[str, str] | None
|
| make_metavar(self, ctx: typer._click.core.Context) -> str
|
| prompt_for_value(self, ctx: typer._click.core.Context) -> Any
| This is an alternative flow that can be activated in the full
| value processing if a value does not exist. It will prompt the
| user until a valid value exists and then returns the processed
| value as result.
|
| resolve_envvar_value(self, ctx: typer._click.core.Context) -> str | None
| Returns the value found in the environment variable(s) attached to this
| parameter.
|
| Environment variables values are `always returned as strings
| <https://docs.python.org/3/library/os.html#os.environ>`_.
|
| This method returns ``None`` if:
|
| - the `envvar` property is not set on `Parameter`,
| - the environment variable is not found in the environment,
| - the variable is found in the environment but its value is empty (i.e. the
| environment variable is present but has an empty string).
|
| If `envvar` is setup with multiple environment variables,
| then only the first non-empty value is returned.
|
| value_from_envvar(self, ctx: typer._click.core.Context) -> Any
| Process the raw environment variable string for this parameter.
|
| Returns the string as-is or splits it into a sequence of strings if the
| parameter is expecting multiple values (i.e. its `nargs` property is set
| to a value other than ``1``).
|
| value_is_missing(self, value: Any) -> bool
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset()
|
| __annotations__ = {'_depr_flag_value': bool | None}
|
| param_type_name = 'option'
|
| ----------------------------------------------------------------------
| Methods inherited from typer._click.core.Parameter:
|
| __repr__(self) -> str
| Return repr(self).
|
| get_default(self, ctx: typer._click.core.Context, call: bool = True) -> typing.Any | collections.abc.Callable[[], typing.Any] | None
| Get the default for the parameter
|
| get_usage_pieces(self, ctx: typer._click.core.Context) -> list[str]
|
| handle_parse_result(self, ctx: typer._click.core.Context, opts: collections.abc.Mapping[str, typing.Any], args: list[str]) -> tuple[typing.Any, list[str]]
| Process the value produced by the parser from user input.
|
| Always process the value through the Parameter's `type`, wherever it
| comes from.
|
| If the parameter is deprecated, this method warn the user about it. But only if
| the value has been explicitly set by the user (and as such, is not coming from
| a default).
|
| process_value(self, ctx: typer._click.core.Context, value: Any) -> Any
| Process the value of this parameter
|
| shell_complete(self, ctx: typer._click.core.Context, incomplete: str) -> list['CompletionItem']
| Return a list of completions for the incomplete value. If a
| ``shell_complete`` function was given during init, it is used.
| Otherwise, the `type` `ParamType.shell_complete` function is used.
|
| type_cast_value(self, ctx: typer._click.core.Context, value: Any) -> Any
| Convert and validate a value against the parameter's
| `type`, `multiple`, and `nargs`.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from typer._click.core.Parameter:
|
| human_readable_name
| Returns the human readable name of this parameter. This is the
| same as the name for options, but the metavar for arguments.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from typer._click.core.Parameter:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
DATA
DEFAULT_MARKUP_MODE = 'rich'
HAS_RICH = True
Literal = typing.Literal
Special typing form to define literal types (a.k.a. value types).
This form can be used to indicate to type checkers that the corresponding
variable or function parameter has a value equivalent to the provided
literal (or one of several literals)::
def validate_simple(data: Any) -> Literal[True]: # always returns True
...
MODE = Literal['r', 'rb', 'w', 'wb']
def open_helper(file: str, mode: MODE) -> str:
...
open_helper('/some/path', 'r') # Passes type check
open_helper('/other/path', 'typo') # Error in type checker
Literal[...] cannot be subclassed. At runtime, an arbitrary value
is allowed as type argument to Literal[...], but type checkers may
impose restrictions.
MARKUP_MODE_KEY = 'TYPER_RICH_MARKUP_MODE'
MarkupMode = typing.Literal['markdown', 'rich', None]
Union = typing.Union
Union type; Union[X, Y] means either X or Y.
On Python 3.10 and higher, the | operator
can also be used to denote unions;
X | Y means the same thing to the type checker as Union[X, Y].
To define a union, use e.g. Union[int, str]. Details:
- The arguments must be types and there must be at least one.
- None as an argument is a special case and is replaced by
type(None).
- Unions of unions are flattened, e.g.::
assert Union[Union[int, str], float] == Union[int, str, float]
- Unions of a single argument vanish, e.g.::
assert Union[int] == int # The constructor actually returns int
- Redundant arguments are skipped, e.g.::
assert Union[int, str, int] == Union[int, str]
- When comparing unions, the argument order is ignored, e.g.::
assert Union[int, str] == Union[str, int]
- You cannot subclass or instantiate a union.
- You can use Optional[X] as a shorthand for Union[X, None].
__annotations__ = {'DEFAULT_MARKUP_MODE': typing.Literal['markdown', '...
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\typer\core.py
typer.echo
Python Library Documentation: function echo in module typer._click.utils
echo(message: typing.Any | None = None, file: Optional[IO[Any]] = None, nl: bool = True, err: bool = False, color: bool | None = None) -> None
Print a message and newline to stdout or a file. This should be
used instead of `print` because it provides better support
for different data, files, and environments.
Compared to `print`, this does the following:
- Ensures that the output encoding is not misconfigured on Linux.
- Supports Unicode in the Windows console.
- Supports writing to binary outputs, and supports writing bytes
to text outputs.
- Supports colors and styles on Windows.
- Removes ANSI color and style codes if the output does not look
like an interactive terminal.
- Always flushes the output.
typer.format_filename
Python Library Documentation: function format_filename in module typer._click.utils
format_filename(filename: str | bytes | os.PathLike[str] | os.PathLike[bytes], shorten: bool = False) -> str
Format a filename as a string for display. Ensures the filename can be
displayed by replacing any invalid bytes or surrogate escapes in the name
with the replacement character ``�``.
Invalid bytes or surrogate escapes will raise an error when written to a
stream with ``errors="strict"``. This will typically happen with ``stdout``
when the locale is something like ``en_GB.UTF-8``.
Many scenarios *are* safe to write surrogates though, due to PEP 538 and
PEP 540, including:
- Writing to ``stderr``, which uses ``errors="backslashreplace"``.
- The system has ``LANG=C.UTF-8``, ``C``, or ``POSIX``. Python opens
stdout and stderr with ``errors="surrogateescape"``.
- None of ``LANG/LC_*`` are set. Python assumes ``LANG=C.UTF-8``.
- Python is started in UTF-8 mode with ``PYTHONUTF8=1`` or ``-X utf8``.
Python opens stdout and stderr with ``errors="surrogateescape"``.
typer.get_app_dir
Python Library Documentation: function get_app_dir in module typer._click.utils
get_app_dir(app_name: str, roaming: bool = True, force_posix: bool = False) -> str
Returns the config folder for the application. The default behavior
is to return whatever is most appropriate for the operating system.
To give you an idea, for an app called ``"Foo Bar"``, something like
the following folders could be returned:
Mac OS X:
``~/Library/Application Support/Foo Bar``
Mac OS X (POSIX):
``~/.foo-bar``
Unix:
``~/.config/foo-bar``
Unix (POSIX):
``~/.foo-bar``
Windows (roaming):
``C:\Users\<user>\AppData\Roaming\Foo Bar``
Windows (not roaming):
``C:\Users\<user>\AppData\Local\Foo Bar``
typer.get_binary_stream
Python Library Documentation: function get_binary_stream in module typer._click.utils
get_binary_stream(name: Literal['stdin', 'stdout', 'stderr']) -> <class 'BinaryIO'>
Returns a system stream for byte processing.
typer.get_terminal_size
Python Library Documentation: function get_terminal_size in module shutil
get_terminal_size(fallback=(80, 24))
Get the size of the terminal window.
For each of the two dimensions, the environment variable, COLUMNS
and LINES respectively, is checked. If the variable is defined and
the value is a positive integer, it is used.
When COLUMNS or LINES is not defined, which is the common case,
the terminal connected to sys.__stdout__ is queried
by invoking os.get_terminal_size.
If the terminal size cannot be successfully queried, either because
the system doesn't support querying, or because we are not
connected to a terminal, the value given in fallback parameter
is used. Fallback defaults to (80, 24) which is the default
size used by many terminal emulators.
The value returned is a named tuple of type os.terminal_size.
typer.get_text_stream
Python Library Documentation: function get_text_stream in module typer._click.utils
get_text_stream(name: Literal['stdin', 'stdout', 'stderr'], encoding: str | None = None, errors: str | None = 'strict') -> <class 'TextIO'>
Returns a system stream for text processing. This usually returns
a wrapped stream around a binary stream returned from
`get_binary_stream` but it also can take shortcuts for already
correctly configured streams.
typer.getchar
Python Library Documentation: function getchar in module typer._click.termui
getchar(echo: bool = False) -> str
Fetches a single character from the terminal and returns it. This
will always return a unicode character and under certain rare
circumstances this might return more than one character. The
situations which more than one character is returned is when for
whatever reason multiple characters end up in the terminal buffer or
standard input was not actually a terminal.
Note that this will always read from the terminal, even if something
is piped into the standard input.
Note for Windows: in rare cases when typing non-ASCII characters, this
function might wait for a second character and then return both at once.
This is because certain Unicode characters look like special-key markers.
typer.launch
Python Library Documentation: function launch in module typer.main
launch(url: Annotated[str, Doc('\n URL or filename of the thing to launch.\n ')], wait: Annotated[bool, Doc('\n Wait for the program to exit before returning. This only works if the launched program blocks.\n ')] = False, locate: Annotated[bool, Doc('\n If this is set to `True`, then instead of launching the application associated with the URL, it will attempt to\n launch a file manager with the file located. This might have weird effects if the URL does not point to the filesystem.\n ')] = False) -> int
This function launches the given URL (or filename) in the default
viewer application for this file type. If this is an executable, it
might launch the executable in a new session. The return value is
the exit code of the launched application. Usually, `0` indicates
success.
This function handles url in different operating systems separately:
- On macOS (Darwin), it uses the `open` command.
- On Linux and BSD, it uses `xdg-open` if available.
- On Windows (and other OSes), it uses the standard webbrowser module.
The function avoids, when possible, using the webbrowser module on Linux and macOS
to prevent spammy terminal messages from some browsers (e.g., Chrome).
## Examples
```python
import typer
typer.launch("https://typer.tiangolo.com/")
```
```python
import typer
typer.launch("/my/downloaded/file", locate=True)
```
typer.main
Python Library Documentation: module typer.main in typer
NAME
typer.main
CLASSES
builtins.object
Typer
class Typer(builtins.object)
| Typer(*, name: Annotated[str | None, Doc('\n The name of this application.\n Mostly used to set the name for [subcommands](https://typer.tiangolo.com/tutorial/subcommands/), in which case it can be overridden by `add_typer(name=...)`.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(name="users")\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D4370A810>, cls: Annotated[type[typer.core.TyperGroup] | None, Doc('\n The class of this app. Mainly used when [using the Click library underneath](https://typer.tiangolo.com/tutorial/using-click/). Can usually be left at the default value `None`.\n Otherwise, should be a subtype of `TyperGroup`.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(cls=TyperGroup)\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D4370A840>, invoke_without_command: Annotated[bool, Doc('\n By setting this to `True`, you can make sure a callback is executed even when no subcommand is provided.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(invoke_without_command=True)\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D4370AA20>, no_args_is_help: Annotated[bool, Doc('\n If this is set to `True`, running a command without any arguments will automatically show the help page.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(no_args_is_help=True)\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F4C890>, subcommand_metavar: Annotated[str | None, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n How to represent the subcommand argument in help.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F4D2B0>, chain: Annotated[bool, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n Allow passing more than one subcommand argument.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F4D7C0>, result_callback: Annotated[collections.abc.Callable[..., Any] | None, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n A function to call after the group's and subcommand's callbacks.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F4DA30>, context_settings: Annotated[dict[Any, Any] | None, Doc('\n Pass configurations for the [context](https://typer.tiangolo.com/tutorial/commands/context/).\n Available configurations can be found in the docs for Click\'s `Context` [here](https://click.palletsprojects.com/en/stable/api/#context).\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(context_settings={"help_option_names": ["-h", "--help"]})\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77D10>, callback: Annotated[collections.abc.Callable[..., Any] | None, Doc('\n Add a callback to the main Typer app. Can be overridden with `@app.callback()`.\n See [the tutorial about callbacks](https://typer.tiangolo.com/tutorial/commands/callback/) for more details.\n\n **Example**\n\n ```python\n import typer\n\n def callback():\n print("Running a command")\n\n app = typer.Typer(callback=callback)\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77D70>, help: Annotated[str | None, Doc('\n Help text for the main Typer app.\n See [the tutorial about name and help](https://typer.tiangolo.com/tutorial/subcommands/name-and-help) for different ways of setting a command\'s help,\n and which one takes priority.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(help="Some help.")\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77DA0>, epilog: Annotated[str | None, Doc('\n Text that will be printed right after the help text.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(epilog="May the force be with you")\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77DD0>, short_help: Annotated[str | None, Doc('\n A shortened version of the help text that can be used e.g. in the help table listing subcommands.\n When not defined, the normal `help` text will be used instead.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(help="A lot of explanation about user management", short_help="user management")\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77E00>, options_metavar: Annotated[str, Doc('\n In the example usage string of the help text for a command, the default placeholder for various arguments is `[OPTIONS]`.\n Set `options_metavar` to change this into a different string.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(options_metavar="[OPTS]")\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77E30>, add_help_option: Annotated[bool, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n By default each command registers a `--help` option. This can be disabled by this parameter.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77E60>, hidden: Annotated[bool, Doc('\n Hide this command from help outputs. `False` by default.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(hidden=True)\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77E90>, deprecated: Annotated[bool, Doc('\n Mark this command as being deprecated in the help text. `False` by default.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(deprecated=True)\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77EC0>, add_completion: Annotated[bool, Doc('\n Toggle whether or not to add the `--install-completion` and `--show-completion` options to the app.\n Set to `True` by default.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(add_completion=False)\n ```\n ')] = True, rich_markup_mode: Annotated[Literal['markdown', 'rich', None], Doc('\n Enable markup text if you have Rich installed. This can be set to `"markdown"`, `"rich"`, or `None`.\n By default, `rich_markup_mode` is `None` if Rich is not installed, and `"rich"` if it is installed.\n See [the tutorial on help formatting](https://typer.tiangolo.com/tutorial/commands/help/#rich-markdown-and-markup) for more information.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(rich_markup_mode="rich")\n ```\n ')] = 'rich', rich_help_panel: Annotated[str | None, Doc('\n Set the panel name of the command when the help is printed with Rich.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(rich_help_panel="Utils and Configs")\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77EF0>, suggest_commands: Annotated[bool, Doc('\n As of version 0.20.0, Typer provides [support for mistyped command names](https://typer.tiangolo.com/tutorial/commands/help/#suggest-commands) by printing helpful suggestions.\n You can turn this setting off with `suggest_commands`:\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(suggest_commands=False)\n ```\n ')] = True, pretty_exceptions_enable: Annotated[bool, Doc('\n If you want to disable [pretty exceptions with Rich](https://typer.tiangolo.com/tutorial/exceptions/#exceptions-with-rich),\n you can set `pretty_exceptions_enable` to `False`. When doing so, you will see the usual standard exception trace.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(pretty_exceptions_enable=False)\n ```\n ')] = True, pretty_exceptions_show_locals: Annotated[bool, Doc('\n If Rich is installed, [error messages](https://typer.tiangolo.com/tutorial/exceptions/#exceptions-and-errors)\n will be nicely printed.\n\n If you set `pretty_exceptions_show_locals=True` it will also include the values of local variables for easy debugging.\n\n However, if such a variable contains delicate information, you should consider leaving `pretty_exceptions_show_locals=False`\n (the default) to `False` to enhance security.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(pretty_exceptions_show_locals=True)\n ```\n ')] = False, pretty_exceptions_short: Annotated[bool, Doc('\n By default, [pretty exceptions formatted with Rich](https://typer.tiangolo.com/tutorial/exceptions/#exceptions-with-rich) hide the long stack trace.\n If you want to show the full trace instead, you can set the parameter `pretty_exceptions_short` to `False`:\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(pretty_exceptions_short=False)\n ```\n ')] = True)
|
| `Typer` main class, the main entrypoint to use Typer.
|
| Read more in the
| [Typer docs for First Steps](https://typer.tiangolo.com/tutorial/typer-app/).
|
| ## Example
|
| ```python
| import typer
|
| app = typer.Typer()
| ```
|
| Methods defined here:
|
| __call__(self, *args: Any, **kwargs: Any) -> Any
| Call self as a function.
|
| __init__(self, *, name: Annotated[str | None, Doc('\n The name of this application.\n Mostly used to set the name for [subcommands](https://typer.tiangolo.com/tutorial/subcommands/), in which case it can be overridden by `add_typer(name=...)`.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(name="users")\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D4370A810>, cls: Annotated[type[typer.core.TyperGroup] | None, Doc('\n The class of this app. Mainly used when [using the Click library underneath](https://typer.tiangolo.com/tutorial/using-click/). Can usually be left at the default value `None`.\n Otherwise, should be a subtype of `TyperGroup`.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(cls=TyperGroup)\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D4370A840>, invoke_without_command: Annotated[bool, Doc('\n By setting this to `True`, you can make sure a callback is executed even when no subcommand is provided.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(invoke_without_command=True)\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D4370AA20>, no_args_is_help: Annotated[bool, Doc('\n If this is set to `True`, running a command without any arguments will automatically show the help page.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(no_args_is_help=True)\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F4C890>, subcommand_metavar: Annotated[str | None, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n How to represent the subcommand argument in help.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F4D2B0>, chain: Annotated[bool, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n Allow passing more than one subcommand argument.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F4D7C0>, result_callback: Annotated[collections.abc.Callable[..., Any] | None, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n A function to call after the group's and subcommand's callbacks.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F4DA30>, context_settings: Annotated[dict[Any, Any] | None, Doc('\n Pass configurations for the [context](https://typer.tiangolo.com/tutorial/commands/context/).\n Available configurations can be found in the docs for Click\'s `Context` [here](https://click.palletsprojects.com/en/stable/api/#context).\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(context_settings={"help_option_names": ["-h", "--help"]})\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77D10>, callback: Annotated[collections.abc.Callable[..., Any] | None, Doc('\n Add a callback to the main Typer app. Can be overridden with `@app.callback()`.\n See [the tutorial about callbacks](https://typer.tiangolo.com/tutorial/commands/callback/) for more details.\n\n **Example**\n\n ```python\n import typer\n\n def callback():\n print("Running a command")\n\n app = typer.Typer(callback=callback)\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77D70>, help: Annotated[str | None, Doc('\n Help text for the main Typer app.\n See [the tutorial about name and help](https://typer.tiangolo.com/tutorial/subcommands/name-and-help) for different ways of setting a command\'s help,\n and which one takes priority.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(help="Some help.")\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77DA0>, epilog: Annotated[str | None, Doc('\n Text that will be printed right after the help text.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(epilog="May the force be with you")\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77DD0>, short_help: Annotated[str | None, Doc('\n A shortened version of the help text that can be used e.g. in the help table listing subcommands.\n When not defined, the normal `help` text will be used instead.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(help="A lot of explanation about user management", short_help="user management")\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77E00>, options_metavar: Annotated[str, Doc('\n In the example usage string of the help text for a command, the default placeholder for various arguments is `[OPTIONS]`.\n Set `options_metavar` to change this into a different string.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(options_metavar="[OPTS]")\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77E30>, add_help_option: Annotated[bool, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n By default each command registers a `--help` option. This can be disabled by this parameter.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77E60>, hidden: Annotated[bool, Doc('\n Hide this command from help outputs. `False` by default.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(hidden=True)\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77E90>, deprecated: Annotated[bool, Doc('\n Mark this command as being deprecated in the help text. `False` by default.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(deprecated=True)\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77EC0>, add_completion: Annotated[bool, Doc('\n Toggle whether or not to add the `--install-completion` and `--show-completion` options to the app.\n Set to `True` by default.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(add_completion=False)\n ```\n ')] = True, rich_markup_mode: Annotated[Literal['markdown', 'rich', None], Doc('\n Enable markup text if you have Rich installed. This can be set to `"markdown"`, `"rich"`, or `None`.\n By default, `rich_markup_mode` is `None` if Rich is not installed, and `"rich"` if it is installed.\n See [the tutorial on help formatting](https://typer.tiangolo.com/tutorial/commands/help/#rich-markdown-and-markup) for more information.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(rich_markup_mode="rich")\n ```\n ')] = 'rich', rich_help_panel: Annotated[str | None, Doc('\n Set the panel name of the command when the help is printed with Rich.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(rich_help_panel="Utils and Configs")\n ```\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F77EF0>, suggest_commands: Annotated[bool, Doc('\n As of version 0.20.0, Typer provides [support for mistyped command names](https://typer.tiangolo.com/tutorial/commands/help/#suggest-commands) by printing helpful suggestions.\n You can turn this setting off with `suggest_commands`:\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(suggest_commands=False)\n ```\n ')] = True, pretty_exceptions_enable: Annotated[bool, Doc('\n If you want to disable [pretty exceptions with Rich](https://typer.tiangolo.com/tutorial/exceptions/#exceptions-with-rich),\n you can set `pretty_exceptions_enable` to `False`. When doing so, you will see the usual standard exception trace.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(pretty_exceptions_enable=False)\n ```\n ')] = True, pretty_exceptions_show_locals: Annotated[bool, Doc('\n If Rich is installed, [error messages](https://typer.tiangolo.com/tutorial/exceptions/#exceptions-and-errors)\n will be nicely printed.\n\n If you set `pretty_exceptions_show_locals=True` it will also include the values of local variables for easy debugging.\n\n However, if such a variable contains delicate information, you should consider leaving `pretty_exceptions_show_locals=False`\n (the default) to `False` to enhance security.\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(pretty_exceptions_show_locals=True)\n ```\n ')] = False, pretty_exceptions_short: Annotated[bool, Doc('\n By default, [pretty exceptions formatted with Rich](https://typer.tiangolo.com/tutorial/exceptions/#exceptions-with-rich) hide the long stack trace.\n If you want to show the full trace instead, you can set the parameter `pretty_exceptions_short` to `False`:\n\n **Example**\n\n ```python\n import typer\n\n app = typer.Typer(pretty_exceptions_short=False)\n ```\n ')] = True)
| Initialize self. See help(type(self)) for accurate signature.
|
| add_typer(self, typer_instance: 'Typer', *, name: Annotated[str | None, Doc("\n The name of this subcommand.\n See [the tutorial about name and help](https://typer.tiangolo.com/tutorial/subcommands/name-and-help) for different ways of setting a command's name,\n and which one takes priority.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F960C0>, cls: Annotated[type[typer.core.TyperGroup] | None, Doc('\n The class of this subcommand. Mainly used when [using the Click library underneath](https://typer.tiangolo.com/tutorial/using-click/). Can usually be left at the default value `None`.\n Otherwise, should be a subtype of `TyperGroup`.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F960F0>, invoke_without_command: Annotated[bool, Doc('\n By setting this to `True`, you can make sure a callback is executed even when no subcommand is provided.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F96120>, no_args_is_help: Annotated[bool, Doc('\n If this is set to `True`, running a command without any arguments will automatically show the help page.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F96150>, subcommand_metavar: Annotated[str | None, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n How to represent the subcommand argument in help.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F96180>, chain: Annotated[bool, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n Allow passing more than one subcommand argument.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F961B0>, result_callback: Annotated[collections.abc.Callable[..., Any] | None, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n A function to call after the group's and subcommand's callbacks.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F961E0>, context_settings: Annotated[dict[Any, Any] | None, Doc("\n Pass configurations for the [context](https://typer.tiangolo.com/tutorial/commands/context/).\n Available configurations can be found in the docs for Click's `Context` [here](https://click.palletsprojects.com/en/stable/api/#context).\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F96210>, callback: Annotated[collections.abc.Callable[..., Any] | None, Doc('\n Add a callback to this app.\n See [the tutorial about callbacks](https://typer.tiangolo.com/tutorial/commands/callback/) for more details.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F96240>, help: Annotated[str | None, Doc("\n Help text for the subcommand.\n See [the tutorial about name and help](https://typer.tiangolo.com/tutorial/subcommands/name-and-help) for different ways of setting a command's help,\n and which one takes priority.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F96270>, epilog: Annotated[str | None, Doc('\n Text that will be printed right after the help text.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F962A0>, short_help: Annotated[str | None, Doc('\n A shortened version of the help text that can be used e.g. in the help table listing subcommands.\n When not defined, the normal `help` text will be used instead.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F962D0>, options_metavar: Annotated[str | None, Doc('\n In the example usage string of the help text for a command, the default placeholder for various arguments is `[OPTIONS]`.\n Set `options_metavar` to change this into a different string. When `None`, the default value will be used.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F96300>, add_help_option: Annotated[bool, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n By default each command registers a `--help` option. This can be disabled by this parameter.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F96330>, hidden: Annotated[bool, Doc('\n Hide this command from help outputs. `False` by default.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F96360>, deprecated: Annotated[bool, Doc('\n Mark this command as deprecated in the help outputs. `False` by default.\n ')] = False, rich_help_panel: Annotated[str | None, Doc('\n Set the panel name of the command when the help is printed with Rich.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F96390>) -> None
| Add subcommands to the main app using `app.add_typer()`.
| Subcommands may be defined in separate modules, ensuring clean separation of code by functionality.
|
| Read more in the
| [Typer docs for SubCommands](https://typer.tiangolo.com/tutorial/subcommands/add-typer/).
|
| ## Example
|
| ```python
| import typer
|
| from .add import app as add_app
| from .delete import app as delete_app
|
| app = typer.Typer()
|
| app.add_typer(add_app)
| app.add_typer(delete_app)
| ```
|
| callback(self, *, cls: Annotated[type[typer.core.TyperGroup] | None, Doc('\n The class of this app. Mainly used when [using the Click library underneath](https://typer.tiangolo.com/tutorial/using-click/). Can usually be left at the default value `None`.\n Otherwise, should be a subtype of `TyperGroup`.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F95100>, invoke_without_command: Annotated[bool, Doc('\n By setting this to `True`, you can make sure a callback is executed even when no subcommand is provided.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F95130>, no_args_is_help: Annotated[bool, Doc('\n If this is set to `True`, running a command without any arguments will automatically show the help page.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F95160>, subcommand_metavar: Annotated[str | None, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n How to represent the subcommand argument in help.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F95190>, chain: Annotated[bool, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n Allow passing more than one subcommand argument.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F951C0>, result_callback: Annotated[collections.abc.Callable[..., Any] | None, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n A function to call after the group's and subcommand's callbacks.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F951F0>, context_settings: Annotated[dict[Any, Any] | None, Doc("\n Pass configurations for the [context](https://typer.tiangolo.com/tutorial/commands/context/).\n Available configurations can be found in the docs for Click's `Context` [here](https://click.palletsprojects.com/en/stable/api/#context).\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F95220>, help: Annotated[str | None, Doc("\n Help text for the command.\n See [the tutorial about name and help](https://typer.tiangolo.com/tutorial/subcommands/name-and-help) for different ways of setting a command's help,\n and which one takes priority.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F95250>, epilog: Annotated[str | None, Doc('\n Text that will be printed right after the help text.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F95280>, short_help: Annotated[str | None, Doc('\n A shortened version of the help text that can be used e.g. in the help table listing subcommands.\n When not defined, the normal `help` text will be used instead.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F952B0>, options_metavar: Annotated[str | None, Doc('\n In the example usage string of the help text for a command, the default placeholder for various arguments is `[OPTIONS]`.\n Set `options_metavar` to change this into a different string. When `None`, the default value will be used.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F952E0>, add_help_option: Annotated[bool, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n By default each command registers a `--help` option. This can be disabled by this parameter.\n ")] = <typer.models.DefaultPlaceholder object at 0x0000021D44F95310>, hidden: Annotated[bool, Doc('\n Hide this command from help outputs. `False` by default.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F95340>, deprecated: Annotated[bool, Doc('\n Mark this command as deprecated in the help text. `False` by default.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F95370>, rich_help_panel: Annotated[str | None, Doc('\n Set the panel name of the command when the help is printed with Rich.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F953A0>) -> collections.abc.Callable[[~CommandFunctionType], ~CommandFunctionType]
| Using the decorator `@app.callback`, you can declare the CLI parameters for the main CLI application.
|
| Read more in the
| [Typer docs for Callbacks](https://typer.tiangolo.com/tutorial/commands/callback/).
|
| ## Example
|
| ```python
| import typer
|
| app = typer.Typer()
| state = {"verbose": False}
|
| @app.callback()
| def main(verbose: bool = False):
| if verbose:
| print("Will write verbose output")
| state["verbose"] = True
|
| @app.command()
| def delete(username: str):
| # define subcommand
| ...
| ```
|
| command(self, name: Annotated[str | None, Doc('\n The name of this command.\n ')] = None, *, cls: Annotated[type[typer.core.TyperCommand] | None, Doc('\n The class of this command. Mainly used when [using the Click library underneath](https://typer.tiangolo.com/tutorial/using-click/). Can usually be left at the default value `None`.\n Otherwise, should be a subtype of `TyperCommand`.\n ')] = None, context_settings: Annotated[dict[Any, Any] | None, Doc("\n Pass configurations for the [context](https://typer.tiangolo.com/tutorial/commands/context/).\n Available configurations can be found in the docs for Click's `Context` [here](https://click.palletsprojects.com/en/stable/api/#context).\n ")] = None, help: Annotated[str | None, Doc("\n Help text for the command.\n See [the tutorial about name and help](https://typer.tiangolo.com/tutorial/subcommands/name-and-help) for different ways of setting a command's help,\n and which one takes priority.\n ")] = None, epilog: Annotated[str | None, Doc('\n Text that will be printed right after the help text.\n ')] = None, short_help: Annotated[str | None, Doc('\n A shortened version of the help text that can be used e.g. in the help table listing subcommands.\n When not defined, the normal `help` text will be used instead.\n ')] = None, options_metavar: Annotated[str | None, Doc('\n In the example usage string of the help text for a command, the default placeholder for various arguments is `[OPTIONS]`.\n Set `options_metavar` to change this into a different string. When `None`, the default value will be used.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F95D90>, add_help_option: Annotated[bool, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited\n from Click and supported for compatibility.\n\n ---\n\n By default each command registers a `--help` option. This can be disabled by this parameter.\n ")] = True, no_args_is_help: Annotated[bool, Doc('\n If this is set to `True`, running a command without any arguments will automatically show the help page.\n ')] = False, hidden: Annotated[bool, Doc('\n Hide this command from help outputs. `False` by default.\n ')] = False, deprecated: Annotated[bool, Doc('\n Mark this command as deprecated in the help outputs. `False` by default.\n ')] = False, rich_help_panel: Annotated[str | None, Doc('\n Set the panel name of the command when the help is printed with Rich.\n ')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F95DC0>) -> collections.abc.Callable[[~CommandFunctionType], ~CommandFunctionType]
| Using the decorator `@app.command`, you can define a subcommand of the previously defined Typer app.
|
| Read more in the
| [Typer docs for Commands](https://typer.tiangolo.com/tutorial/commands/).
|
| ## Example
|
| ```python
| import typer
|
| app = typer.Typer()
|
| @app.command()
| def create():
| print("Creating user: Hiro Hamada")
|
| @app.command()
| def delete():
| print("Deleting user: Hiro Hamada")
| ```
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
FUNCTIONS
determine_type_convertor(type_: Any) -> collections.abc.Callable[[typing.Any], typing.Any] | None
except_hook(exc_type: type[BaseException], exc_value: BaseException, tb: traceback | None) -> None
generate_enum_convertor(enum: type[enum.Enum]) -> collections.abc.Callable[[typing.Any], typing.Any]
generate_list_convertor(convertor: collections.abc.Callable[[typing.Any], typing.Any] | None, default_value: typing.Any | None) -> collections.abc.Callable[[collections.abc.Sequence[typing.Any] | None], list[typing.Any] | None]
generate_tuple_convertor(types: collections.abc.Sequence[typing.Any]) -> collections.abc.Callable[[tuple[typing.Any, ...] | None], tuple[typing.Any, ...] | None]
get_callback(*, callback: collections.abc.Callable[..., typing.Any] | None = None, params: collections.abc.Sequence[typer._click.core.Parameter] = [], convertors: dict[str, collections.abc.Callable[[str], typing.Any]] | None = None, context_param_name: str | None = None, pretty_exceptions_short: bool) -> collections.abc.Callable[..., typing.Any] | None
get_click_param(param: typer.models.ParamMeta) -> tuple[typer.core.TyperArgument | typer.core.TyperOption, typing.Any]
get_click_type(*, annotation: Any, parameter_info: typer.models.ParameterInfo) -> typer._click.types.ParamType
get_command(typer_instance: typer.main.Typer) -> typer._click.core.Command
get_command_from_info(command_info: typer.models.CommandInfo, *, pretty_exceptions_short: bool, rich_markup_mode: Literal['markdown', 'rich', None]) -> typer._click.core.Command
get_command_name(name: str) -> str
get_default_option_flag_name(name: str, metavar: str | None) -> str
get_group(typer_instance: typer.main.Typer) -> typer.core.TyperGroup
get_group_from_info(group_info: typer.models.TyperInfo, *, pretty_exceptions_short: bool, suggest_commands: bool, rich_markup_mode: Literal['markdown', 'rich', None]) -> typer.core.TyperGroup
get_install_completion_arguments() -> tuple[typer._click.core.Parameter, typer._click.core.Parameter]
get_param_callback(*, callback: collections.abc.Callable[..., typing.Any] | None = None, convertor: collections.abc.Callable[..., typing.Any] | None = None) -> collections.abc.Callable[..., typing.Any] | None
get_param_completion(callback: collections.abc.Callable[..., typing.Any] | None = None) -> collections.abc.Callable[..., typing.Any] | None
get_params_convertors_ctx_param_name_from_function(callback: collections.abc.Callable[..., typing.Any] | None) -> tuple[list[typer.core.TyperArgument | typer.core.TyperOption], dict[str, typing.Any], str | None]
launch(url: Annotated[str, Doc('\n URL or filename of the thing to launch.\n ')], wait: Annotated[bool, Doc('\n Wait for the program to exit before returning. This only works if the launched program blocks.\n ')] = False, locate: Annotated[bool, Doc('\n If this is set to `True`, then instead of launching the application associated with the URL, it will attempt to\n launch a file manager with the file located. This might have weird effects if the URL does not point to the filesystem.\n ')] = False) -> int
This function launches the given URL (or filename) in the default
viewer application for this file type. If this is an executable, it
might launch the executable in a new session. The return value is
the exit code of the launched application. Usually, `0` indicates
success.
This function handles url in different operating systems separately:
- On macOS (Darwin), it uses the `open` command.
- On Linux and BSD, it uses `xdg-open` if available.
- On Windows (and other OSes), it uses the standard webbrowser module.
The function avoids, when possible, using the webbrowser module on Linux and macOS
to prevent spammy terminal messages from some browsers (e.g., Chrome).
## Examples
```python
import typer
typer.launch("https://typer.tiangolo.com/")
```
```python
import typer
typer.launch("/my/downloaded/file", locate=True)
```
lenient_issubclass(cls: Any, class_or_tuple: type[typing.Any] | tuple[type[typing.Any], ...]) -> bool
param_path_convertor(value: str | None = None) -> pathlib.Path | None
run(function: Annotated[collections.abc.Callable[..., Any], Doc('\n The function that should power this CLI application.\n ')]) -> None
This function converts a given function to a CLI application with `Typer()` and executes it.
## Example
```python
import typer
def main(name: str):
print(f"Hello {name}")
if __name__ == "__main__":
typer.run(main)
```
solve_typer_info_defaults(typer_info: typer.models.TyperInfo) -> typer.models.TyperInfo
solve_typer_info_help(typer_info: typer.models.TyperInfo) -> str
DATA
AnyType = type[typing.Any]
CommandFunctionType = ~CommandFunctionType
DEFAULT_MARKUP_MODE = 'rich'
HAS_RICH = True
MarkupMode = typing.Literal['markdown', 'rich', None]
Required = Ellipsis
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\typer\main.py
typer.models
Python Library Documentation: module typer.models in typer
NAME
typer.models
CLASSES
_io.BufferedReader(_io._BufferedIOBase)
FileBinaryRead
_io.BufferedWriter(_io._BufferedIOBase)
FileBinaryWrite
_io.TextIOWrapper(_io._TextIOBase)
FileText
FileTextWrite
builtins.object
CommandInfo
DefaultPlaceholder
DeveloperExceptionConfig
ParamMeta
ParameterInfo
ArgumentInfo
OptionInfo
TyperInfo
typer._click.core.Context(builtins.object)
Context
typer._click.core.Parameter(abc.ABC)
CallbackParam
typer._click.types.ParamType(builtins.object)
TyperPath
class ArgumentInfo(ParameterInfo)
| ArgumentInfo(*, default: typing.Any | None = None, param_decls: collections.abc.Sequence[str] | None = None, callback: collections.abc.Callable[..., typing.Any] | None = None, metavar: str | None = None, expose_value: bool = True, is_eager: bool = False, envvar: str | list[str] | None = None, shell_complete: collections.abc.Callable[[typer._click.core.Context, typer._click.core.Parameter, str], list['CompletionItem'] | list[str]] | None = None, autocompletion: collections.abc.Callable[..., typing.Any] | None = None, default_factory: collections.abc.Callable[[], typing.Any] | None = None, parser: collections.abc.Callable[[str], typing.Any] | None = None, click_type: typer._click.types.ParamType | None = None, show_default: bool | str = True, show_choices: bool = True, show_envvar: bool = True, help: str | None = None, hidden: bool = False, case_sensitive: bool = True, min: int | float | None = None, max: int | float | None = None, clamp: bool = False, formats: list[str] | None = None, mode: str | None = None, encoding: str | None = None, errors: str | None = 'strict', lazy: bool | None = 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: None | type[str] | type[bytes] = None, rich_help_panel: str | None = None)
|
| Method resolution order:
| ArgumentInfo
| ParameterInfo
| builtins.object
|
| Methods defined here:
|
| __init__(self, *, default: typing.Any | None = None, param_decls: collections.abc.Sequence[str] | None = None, callback: collections.abc.Callable[..., typing.Any] | None = None, metavar: str | None = None, expose_value: bool = True, is_eager: bool = False, envvar: str | list[str] | None = None, shell_complete: collections.abc.Callable[[typer._click.core.Context, typer._click.core.Parameter, str], list['CompletionItem'] | list[str]] | None = None, autocompletion: collections.abc.Callable[..., typing.Any] | None = None, default_factory: collections.abc.Callable[[], typing.Any] | None = None, parser: collections.abc.Callable[[str], typing.Any] | None = None, click_type: typer._click.types.ParamType | None = None, show_default: bool | str = True, show_choices: bool = True, show_envvar: bool = True, help: str | None = None, hidden: bool = False, case_sensitive: bool = True, min: int | float | None = None, max: int | float | None = None, clamp: bool = False, formats: list[str] | None = None, mode: str | None = None, encoding: str | None = None, errors: str | None = 'strict', lazy: bool | None = 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: None | type[str] | type[bytes] = None, rich_help_panel: str | None = None)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from ParameterInfo:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
class CallbackParam(typer._click.core.Parameter)
| CallbackParam(param_decls: collections.abc.Sequence[str] | None = None, type: typer._click.types.ParamType | typing.Any | None = None, required: bool = False, default: typing.Any | collections.abc.Callable[[], typing.Any] | None = None, callback: collections.abc.Callable[[typer._click.core.Context, 'Parameter', typing.Any], typing.Any] | None = None, nargs: int | None = None, multiple: bool = False, metavar: str | None = None, expose_value: bool = True, is_eager: bool = False, envvar: str | collections.abc.Sequence[str] | None = None, shell_complete: collections.abc.Callable[[typer._click.core.Context, 'Parameter', str], list['CompletionItem'] | list[str]] | None = None) -> None
|
| In a callback function, you can declare a function parameter with type `CallbackParam`
| to access the specific Click [`Parameter`](https://click.palletsprojects.com/en/stable/api/#click.Parameter) object.
|
| Method resolution order:
| CallbackParam
| typer._click.core.Parameter
| abc.ABC
| builtins.object
|
| Data and other attributes defined here:
|
| __abstractmethods__ = frozenset({'_parse_decls', 'add_to_parser', 'get...
|
| __annotations__ = {}
|
| ----------------------------------------------------------------------
| Methods inherited from typer._click.core.Parameter:
|
| __init__(self, param_decls: collections.abc.Sequence[str] | None = None, type: typer._click.types.ParamType | typing.Any | None = None, required: bool = False, default: typing.Any | collections.abc.Callable[[], typing.Any] | None = None, callback: collections.abc.Callable[[typer._click.core.Context, 'Parameter', typing.Any], typing.Any] | None = None, nargs: int | None = None, multiple: bool = False, metavar: str | None = None, expose_value: bool = True, is_eager: bool = False, envvar: str | collections.abc.Sequence[str] | None = None, shell_complete: collections.abc.Callable[[typer._click.core.Context, 'Parameter', str], list['CompletionItem'] | list[str]] | None = None) -> None
| Initialize self. See help(type(self)) for accurate signature.
|
| __repr__(self) -> str
| Return repr(self).
|
| add_to_parser(self, parser: typer._click.parser._OptionParser, ctx: typer._click.core.Context) -> None
|
| consume_value(self, ctx: typer._click.core.Context, opts: collections.abc.Mapping[str, typing.Any]) -> tuple[typing.Any, typer._click.core.ParameterSource]
|
| get_default(self, ctx: typer._click.core.Context, call: bool = True) -> typing.Any | collections.abc.Callable[[], typing.Any] | None
| Get the default for the parameter
|
| get_error_hint(self, ctx: typer._click.core.Context) -> str
| Get a stringified version of the param for use in error messages to
| indicate which param caused the error.
|
| get_help_record(self, ctx: typer._click.core.Context) -> tuple[str, str] | None
|
| get_usage_pieces(self, ctx: typer._click.core.Context) -> list[str]
|
| handle_parse_result(self, ctx: typer._click.core.Context, opts: collections.abc.Mapping[str, typing.Any], args: list[str]) -> tuple[typing.Any, list[str]]
| Process the value produced by the parser from user input.
|
| Always process the value through the Parameter's `type`, wherever it
| comes from.
|
| If the parameter is deprecated, this method warn the user about it. But only if
| the value has been explicitly set by the user (and as such, is not coming from
| a default).
|
| make_metavar(self, ctx: typer._click.core.Context) -> str
|
| process_value(self, ctx: typer._click.core.Context, value: Any) -> Any
| Process the value of this parameter
|
| resolve_envvar_value(self, ctx: typer._click.core.Context) -> str | None
| Returns the value found in the environment variable(s) attached to this
| parameter.
|
| Environment variables values are `always returned as strings
| <https://docs.python.org/3/library/os.html#os.environ>`_.
|
| This method returns ``None`` if:
|
| - the `envvar` property is not set on `Parameter`,
| - the environment variable is not found in the environment,
| - the variable is found in the environment but its value is empty (i.e. the
| environment variable is present but has an empty string).
|
| If `envvar` is setup with multiple environment variables,
| then only the first non-empty value is returned.
|
| shell_complete(self, ctx: typer._click.core.Context, incomplete: str) -> list['CompletionItem']
| Return a list of completions for the incomplete value. If a
| ``shell_complete`` function was given during init, it is used.
| Otherwise, the `type` `ParamType.shell_complete` function is used.
|
| type_cast_value(self, ctx: typer._click.core.Context, value: Any) -> Any
| Convert and validate a value against the parameter's
| `type`, `multiple`, and `nargs`.
|
| value_from_envvar(self, ctx: typer._click.core.Context) -> str | collections.abc.Sequence[str] | None
| Process the raw environment variable string for this parameter.
|
| Returns the string as-is or splits it into a sequence of strings if the
| parameter is expecting multiple values (i.e. its `nargs` property is set
| to a value other than ``1``).
|
| value_is_missing(self, value: Any) -> bool
|
| ----------------------------------------------------------------------
| Readonly properties inherited from typer._click.core.Parameter:
|
| human_readable_name
| Returns the human readable name of this parameter. This is the
| same as the name for options, but the metavar for arguments.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from typer._click.core.Parameter:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from typer._click.core.Parameter:
|
| param_type_name = 'parameter'
class CommandInfo(builtins.object)
| CommandInfo(name: str | None = None, *, cls: type['TyperCommand'] | None = None, context_settings: dict[typing.Any, typing.Any] | None = None, callback: collections.abc.Callable[..., typing.Any] | None = None, help: str | None = None, epilog: str | None = None, short_help: str | None = 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: str | None = None)
|
| Methods defined here:
|
| __init__(self, name: str | None = None, *, cls: type['TyperCommand'] | None = None, context_settings: dict[typing.Any, typing.Any] | None = None, callback: collections.abc.Callable[..., typing.Any] | None = None, help: str | None = None, epilog: str | None = None, short_help: str | None = 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: str | None = None)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
class Context(typer._click.core.Context)
| Context(command: 'Command', parent: Optional[ForwardRef('Context')] = None, info_name: str | None = None, obj: typing.Any | None = None, auto_envvar_prefix: str | None = None, default_map: collections.abc.MutableMapping[str, typing.Any] | None = None, terminal_width: int | None = None, max_content_width: int | None = None, resilient_parsing: bool = False, allow_extra_args: bool | None = None, allow_interspersed_args: bool | None = None, ignore_unknown_options: bool | None = None, help_option_names: list[str] | None = None, token_normalize_func: collections.abc.Callable[[str], str] | None = None, color: bool | None = None, show_default: bool | None = None) -> None
|
| The [`Context`](https://click.palletsprojects.com/en/stable/api/#click.Context) has some additional data about the current execution of your program.
| When declaring it in a [callback](https://typer.tiangolo.com/tutorial/options/callback-and-context/) function,
| you can access this additional information.
|
| Method resolution order:
| Context
| typer._click.core.Context
| builtins.object
|
| Data and other attributes defined here:
|
| __annotations__ = {}
|
| ----------------------------------------------------------------------
| Methods inherited from typer._click.core.Context:
|
| __enter__(self) -> 'Context'
|
| __exit__(self, exc_type: type[BaseException] | None, exc_value: BaseException | None, tb: traceback | None) -> bool | None
|
| __init__(self, command: 'Command', parent: Optional[ForwardRef('Context')] = None, info_name: str | None = None, obj: typing.Any | None = None, auto_envvar_prefix: str | None = None, default_map: collections.abc.MutableMapping[str, typing.Any] | None = None, terminal_width: int | None = None, max_content_width: int | None = None, resilient_parsing: bool = False, allow_extra_args: bool | None = None, allow_interspersed_args: bool | None = None, ignore_unknown_options: bool | None = None, help_option_names: list[str] | None = None, token_normalize_func: collections.abc.Callable[[str], str] | None = None, color: bool | None = None, show_default: bool | None = None) -> None
| Initialize self. See help(type(self)) for accurate signature.
|
| abort(self) -> NoReturn
| Aborts the script.
|
| call_on_close(self, f: collections.abc.Callable[..., typing.Any]) -> collections.abc.Callable[..., typing.Any]
| Register a function to be called when the context tears down.
|
| This can be used to close resources opened during the script
| execution. Resources that support Python's context manager
| protocol which would be used in a ``with`` statement should be
| registered with `with_resource` instead.
|
| close(self) -> None
| Invoke all close callbacks registered with `call_on_close`,
| and exit all context managers entered with `with_resource`.
|
| ensure_object(self, object_type: type[~V]) -> ~V
| Like `find_object` but sets the innermost object to a
| new instance of `object_type` if it does not exist.
|
| exit(self, code: int = 0) -> NoReturn
| Exits the application with a given exit code.
|
| fail(self, message: str) -> NoReturn
| Aborts the execution of the program with a specific error
| message.
|
| find_object(self, object_type: type[~V]) -> Optional[~V]
| Finds the closest object of a given type.
|
| find_root(self) -> 'Context'
| Finds the outermost context.
|
| get_help(self) -> str
| Helper method to get formatted help page for the current
| context and command.
|
| get_parameter_source(self, name: str) -> typer._click.core.ParameterSource | None
| Get the source of a parameter. This indicates the location
| from which the value of the parameter was obtained.
|
| This can be useful for determining when a user specified a value
| on the command line that is the same as the default value. It
| will be `ParameterSource.DEFAULT` only if the
| value was actually taken from the default.
|
| get_usage(self) -> str
| Helper method to get formatted usage string for the current
| context and command.
|
| invoke(self, callback: collections.abc.Callable[..., ~V], /, *args: Any, **kwargs: Any) -> ~V
| Invokes a command callback in exactly the way it expects. There
| are two ways to invoke this method:
|
| 1. the first argument can be a callback and all other arguments and
| keyword arguments are forwarded directly to the function.
| 2. the first argument is a click command object. In that case all
| arguments are forwarded as well but proper click parameters
| (options and click arguments) must be keyword arguments and Click
| will fill in defaults.
|
| lookup_default(self, name: str, call: bool = True) -> typing.Any | None
| Get the default for a parameter from `default_map`.
|
| make_formatter(self) -> typer._click.formatting.HelpFormatter
| Creates the HelpFormatter for the help and
| usage output.
|
| scope(self, cleanup: bool = True) -> collections.abc.Iterator['Context']
| This helper method can be used with the context object to promote
| it to the current thread local (see `get_current_context`).
| The default behavior of this is to invoke the cleanup functions which
| can be disabled by setting `cleanup` to `False`. The cleanup
| functions are typically used for things such as closing file handles.
|
| If the cleanup is intended the context object can also be directly
| used as a context manager.
|
| set_parameter_source(self, name: str, source: typer._click.core.ParameterSource) -> None
| Set the source of a parameter. This indicates the location
| from which the value of the parameter was obtained.
|
| with_resource(self, context_manager: contextlib.AbstractContextManager[~V]) -> ~V
| Register a resource as if it were used in a ``with``
| statement. The resource will be cleaned up when the context is
| popped.
|
| Uses `contextlib.ExitStack.enter_context`. It calls the
| resource's ``__enter__()`` method and returns the result. When
| the context is popped, it closes the stack, which calls the
| resource's ``__exit__()`` method.
|
| To register a cleanup function for something that isn't a
| context manager, use `call_on_close`. Or use something
| from `contextlib` to turn it into a context manager first.
|
| ----------------------------------------------------------------------
| Readonly properties inherited from typer._click.core.Context:
|
| command_path
| The computed command path. This is used for the ``usage``
| information on the help page. It's automatically created by
| combining the info names of the chain of contexts to the root.
|
| meta
| This is a dictionary which is shared with all the contexts
| that are nested. It exists so that click utilities can store some
| state here if they need to. It is however the responsibility of
| that code to manage this dictionary well.
|
| The keys are supposed to be unique dotted strings. For instance
| module paths are a good choice for it. What is stored in there is
| irrelevant for the operation of click. However what is important is
| that code that places data here adheres to the general semantics of
| the system.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from typer._click.core.Context:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from typer._click.core.Context:
|
| formatter_class = <class 'typer._click.formatting.HelpFormatter'>
| This class helps with formatting text-based help pages. It's
| usually just needed for very special internal cases, but it's also
| exposed so that developers can write their own fancy outputs.
|
| At present, it always writes into memory.
class DefaultPlaceholder(builtins.object)
| DefaultPlaceholder(value: Any)
|
| 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`.
|
| Methods defined here:
|
| __bool__(self) -> bool
|
| __init__(self, value: Any)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
class DeveloperExceptionConfig(builtins.object)
| DeveloperExceptionConfig(*, pretty_exceptions_enable: bool = True, pretty_exceptions_show_locals: bool = True, pretty_exceptions_short: bool = True) -> None
|
| Methods defined here:
|
| __init__(self, *, pretty_exceptions_enable: bool = True, pretty_exceptions_show_locals: bool = True, pretty_exceptions_short: bool = True) -> None
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
class FileBinaryRead(_io.BufferedReader)
| FileBinaryRead(raw, buffer_size=8192)
|
| You can use this class to read binary data, receiving `bytes`.
| The default mode of this class is `mode="rb"`.
| It is useful for reading binary files like images:
|
| **Example**
|
| ```python
| from typing import Annotated
|
| import typer
|
| app = typer.Typer()
|
| @app.command()
| def main(file: Annotated[typer.FileBinaryRead, typer.Option()]):
| processed_total = 0
| for bytes_chunk in file:
| # Process the bytes in bytes_chunk
| processed_total += len(bytes_chunk)
| print(f"Processed bytes total: {processed_total}")
|
| if __name__ == "__main__":
| app()
| ```
|
| Method resolution order:
| FileBinaryRead
| _io.BufferedReader
| _io._BufferedIOBase
| _io._IOBase
| builtins.object
|
| Methods inherited from _io.BufferedReader:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Helper for pickle.
|
| __reduce_ex__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __sizeof__(self, /)
| Size of object in memory, in bytes.
|
| close(self, /)
| Flush and close the IO object.
|
| This method has no effect if the file is already closed.
|
| detach(self, /)
| Disconnect this buffer from its underlying raw stream and return it.
|
| After the raw stream has been detached, the buffer is in an unusable
| state.
|
| fileno(self, /)
| Return underlying file descriptor if one exists.
|
| Raise OSError if the IO object does not use a file descriptor.
|
| flush(self, /)
| Flush write buffers, if applicable.
|
| This is not implemented for read-only and non-blocking streams.
|
| isatty(self, /)
| Return whether this is an 'interactive' stream.
|
| Return False if it can't be determined.
|
| peek(self, size=0, /)
|
| read(self, size=-1, /)
| Read and return up to n bytes.
|
| If the size argument is omitted, None, or negative, read and
| return all data until EOF.
|
| If the size argument is positive, and the underlying raw stream is
| not 'interactive', multiple raw reads may be issued to satisfy
| the byte count (unless EOF is reached first).
| However, for interactive raw streams (as well as sockets and pipes),
| at most one raw read will be issued, and a short result does not
| imply that EOF is imminent.
|
| Return an empty bytes object on EOF.
|
| Return None if the underlying raw stream was open in non-blocking
| mode and no data is available at the moment.
|
| read1(self, size=-1, /)
| Read and return up to size bytes, with at most one read() call to the underlying raw stream.
|
| Return an empty bytes object on EOF.
| A short result does not imply that EOF is imminent.
|
| readable(self, /)
| Return whether object was opened for reading.
|
| If False, read() will raise OSError.
|
| readinto(self, buffer, /)
|
| readinto1(self, buffer, /)
|
| readline(self, size=-1, /)
| Read and return a line from the stream.
|
| If size is specified, at most size bytes will be read.
|
| The line terminator is always b'\n' for binary files; for text
| files, the newlines argument to open can be used to select the line
| terminator(s) recognized.
|
| seek(self, target, whence=0, /)
| Change the stream position to the given byte offset.
|
| offset
| The stream position, relative to 'whence'.
| whence
| The relative position to seek from.
|
| The offset is interpreted relative to the position indicated by whence.
| Values for whence are:
|
| * os.SEEK_SET or 0 -- start of stream (the default); offset should be zero or positive
| * os.SEEK_CUR or 1 -- current stream position; offset may be negative
| * os.SEEK_END or 2 -- end of stream; offset is usually negative
|
| Return the new absolute position.
|
| seekable(self, /)
| Return whether object supports random access.
|
| If False, seek(), tell() and truncate() will raise OSError.
| This method may need to do a test seek().
|
| tell(self, /)
| Return current stream position.
|
| truncate(self, pos=None, /)
| Truncate file to size bytes.
|
| File pointer is left unchanged. Size defaults to the current IO position
| as reported by tell(). Return the new size.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from _io.BufferedReader:
|
| closed
|
| mode
|
| name
|
| raw
|
| ----------------------------------------------------------------------
| Methods inherited from _io._BufferedIOBase:
|
| write(self, b, /)
| Write buffer b to the IO stream.
|
| Return the number of bytes written, which is always
| the length of b in bytes.
|
| Raise BlockingIOError if the buffer is full and the
| underlying raw stream cannot accept more data at the moment.
|
| ----------------------------------------------------------------------
| Methods inherited from _io._IOBase:
|
| __del__(...)
|
| __enter__(...)
|
| __exit__(...)
|
| __iter__(self, /)
| Implement iter(self).
|
| readlines(self, hint=-1, /)
| Return a list of lines from the stream.
|
| hint can be specified to control the number of lines read: no more
| lines will be read if the total size (in bytes/characters) of all
| lines so far exceeds hint.
|
| writable(self, /)
| Return whether object was opened for writing.
|
| If False, write() will raise OSError.
|
| writelines(self, lines, /)
| Write a list of lines to stream.
|
| Line separators are not added, so it is usual for each of the
| lines provided to have a line separator at the end.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from _io._IOBase:
|
| __dict__
class FileBinaryWrite(_io.BufferedWriter)
| FileBinaryWrite(raw, buffer_size=8192)
|
| You can use this class to write binary data: you pass `bytes` to it instead of strings.
| The default mode of this class is `mode="wb"`.
| It is useful for writing binary files like images:
|
| **Example**
|
| ```python
| from typing import Annotated
|
| import typer
|
| app = typer.Typer()
|
| @app.command()
| def main(file: Annotated[typer.FileBinaryWrite, typer.Option()]):
| first_line_str = "some settings\n"
| # You cannot write str directly to a binary file; encode it first
| first_line_bytes = first_line_str.encode("utf-8")
| # Then you can write the bytes
| file.write(first_line_bytes)
| # This is already bytes, it starts with b"
| second_line = b"la cigüeña trae al niño"
| file.write(second_line)
| print("Binary file written")
|
| if __name__ == "__main__":
| app()
| ```
|
| Method resolution order:
| FileBinaryWrite
| _io.BufferedWriter
| _io._BufferedIOBase
| _io._IOBase
| builtins.object
|
| Methods inherited from _io.BufferedWriter:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __reduce__(...)
| Helper for pickle.
|
| __reduce_ex__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __sizeof__(self, /)
| Size of object in memory, in bytes.
|
| close(self, /)
| Flush and close the IO object.
|
| This method has no effect if the file is already closed.
|
| detach(self, /)
| Disconnect this buffer from its underlying raw stream and return it.
|
| After the raw stream has been detached, the buffer is in an unusable
| state.
|
| fileno(self, /)
| Return underlying file descriptor if one exists.
|
| Raise OSError if the IO object does not use a file descriptor.
|
| flush(self, /)
| Flush write buffers, if applicable.
|
| This is not implemented for read-only and non-blocking streams.
|
| isatty(self, /)
| Return whether this is an 'interactive' stream.
|
| Return False if it can't be determined.
|
| seek(self, target, whence=0, /)
| Change the stream position to the given byte offset.
|
| offset
| The stream position, relative to 'whence'.
| whence
| The relative position to seek from.
|
| The offset is interpreted relative to the position indicated by whence.
| Values for whence are:
|
| * os.SEEK_SET or 0 -- start of stream (the default); offset should be zero or positive
| * os.SEEK_CUR or 1 -- current stream position; offset may be negative
| * os.SEEK_END or 2 -- end of stream; offset is usually negative
|
| Return the new absolute position.
|
| seekable(self, /)
| Return whether object supports random access.
|
| If False, seek(), tell() and truncate() will raise OSError.
| This method may need to do a test seek().
|
| tell(self, /)
| Return current stream position.
|
| truncate(self, pos=None, /)
| Truncate file to size bytes.
|
| File pointer is left unchanged. Size defaults to the current IO position
| as reported by tell(). Return the new size.
|
| writable(self, /)
| Return whether object was opened for writing.
|
| If False, write() will raise OSError.
|
| write(self, buffer, /)
| Write buffer b to the IO stream.
|
| Return the number of bytes written, which is always
| the length of b in bytes.
|
| Raise BlockingIOError if the buffer is full and the
| underlying raw stream cannot accept more data at the moment.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from _io.BufferedWriter:
|
| closed
|
| mode
|
| name
|
| raw
|
| ----------------------------------------------------------------------
| Methods inherited from _io._BufferedIOBase:
|
| read(self, size=-1, /)
| Read and return up to n bytes.
|
| If the size argument is omitted, None, or negative, read and
| return all data until EOF.
|
| If the size argument is positive, and the underlying raw stream is
| not 'interactive', multiple raw reads may be issued to satisfy
| the byte count (unless EOF is reached first).
| However, for interactive raw streams (as well as sockets and pipes),
| at most one raw read will be issued, and a short result does not
| imply that EOF is imminent.
|
| Return an empty bytes object on EOF.
|
| Return None if the underlying raw stream was open in non-blocking
| mode and no data is available at the moment.
|
| read1(self, size=-1, /)
| Read and return up to size bytes, with at most one read() call to the underlying raw stream.
|
| Return an empty bytes object on EOF.
| A short result does not imply that EOF is imminent.
|
| readinto(self, buffer, /)
|
| readinto1(self, buffer, /)
|
| ----------------------------------------------------------------------
| Methods inherited from _io._IOBase:
|
| __del__(...)
|
| __enter__(...)
|
| __exit__(...)
|
| __iter__(self, /)
| Implement iter(self).
|
| __next__(self, /)
| Implement next(self).
|
| readable(self, /)
| Return whether object was opened for reading.
|
| If False, read() will raise OSError.
|
| readline(self, size=-1, /)
| Read and return a line from the stream.
|
| If size is specified, at most size bytes will be read.
|
| The line terminator is always b'\n' for binary files; for text
| files, the newlines argument to open can be used to select the line
| terminator(s) recognized.
|
| readlines(self, hint=-1, /)
| Return a list of lines from the stream.
|
| hint can be specified to control the number of lines read: no more
| lines will be read if the total size (in bytes/characters) of all
| lines so far exceeds hint.
|
| writelines(self, lines, /)
| Write a list of lines to stream.
|
| Line separators are not added, so it is usual for each of the
| lines provided to have a line separator at the end.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from _io._IOBase:
|
| __dict__
class FileText(_io.TextIOWrapper)
| FileText(buffer, encoding=None, errors=None, newline=None, line_buffering=False, write_through=False)
|
| Gives you a file-like object for reading text, and you will get a `str` data from it.
| The default mode of this class is `mode="r"`.
|
| **Example**
|
| ```python
| from typing import Annotated
|
| import typer
|
| app = typer.Typer()
|
| @app.command()
| def main(config: Annotated[typer.FileText, typer.Option()]):
| for line in config:
| print(f"Config line: {line}")
|
| if __name__ == "__main__":
| app()
| ```
|
| Method resolution order:
| FileText
| _io.TextIOWrapper
| _io._TextIOBase
| _io._IOBase
| builtins.object
|
| Methods inherited from _io.TextIOWrapper:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Helper for pickle.
|
| __reduce_ex__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| close(self, /)
| Flush and close the IO object.
|
| This method has no effect if the file is already closed.
|
| detach(self, /)
| Separate the underlying buffer from the TextIOBase and return it.
|
| After the underlying buffer has been detached, the TextIO is in an unusable state.
|
| fileno(self, /)
| Return underlying file descriptor if one exists.
|
| Raise OSError if the IO object does not use a file descriptor.
|
| flush(self, /)
| Flush write buffers, if applicable.
|
| This is not implemented for read-only and non-blocking streams.
|
| isatty(self, /)
| Return whether this is an 'interactive' stream.
|
| Return False if it can't be determined.
|
| read(self, size=-1, /)
| Read at most size characters from stream.
|
| Read from underlying buffer until we have size characters or we hit EOF.
| If size is negative or omitted, read until EOF.
|
| readable(self, /)
| Return whether object was opened for reading.
|
| If False, read() will raise OSError.
|
| readline(self, size=-1, /)
| Read until newline or EOF.
|
| Return an empty string if EOF is hit immediately.
| If size is specified, at most size characters will be read.
|
| reconfigure(self, /, *, encoding=None, errors=None, newline=None, line_buffering=None, write_through=None)
| Reconfigure the text stream with new parameters.
|
| This also does an implicit stream flush.
|
| seek(self, cookie, whence=0, /)
| Set the stream position, and return the new stream position.
|
| cookie
| Zero or an opaque number returned by tell().
| whence
| The relative position to seek from.
|
| Four operations are supported, given by the following argument
| combinations:
|
| - seek(0, SEEK_SET): Rewind to the start of the stream.
| - seek(cookie, SEEK_SET): Restore a previous position;
| 'cookie' must be a number returned by tell().
| - seek(0, SEEK_END): Fast-forward to the end of the stream.
| - seek(0, SEEK_CUR): Leave the current stream position unchanged.
|
| Any other argument combinations are invalid,
| and may raise exceptions.
|
| seekable(self, /)
| Return whether object supports random access.
|
| If False, seek(), tell() and truncate() will raise OSError.
| This method may need to do a test seek().
|
| tell(self, /)
| Return the stream position as an opaque number.
|
| The return value of tell() can be given as input to seek(), to restore a
| previous stream position.
|
| truncate(self, pos=None, /)
| Truncate file to size bytes.
|
| File pointer is left unchanged. Size defaults to the current IO position
| as reported by tell(). Return the new size.
|
| writable(self, /)
| Return whether object was opened for writing.
|
| If False, write() will raise OSError.
|
| write(self, text, /)
| Write string s to stream.
|
| Return the number of characters written
| (which is always equal to the length of the string).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from _io.TextIOWrapper:
|
| buffer
|
| closed
|
| encoding
| Encoding of the text stream.
|
| Subclasses should override.
|
| errors
| The error setting of the decoder or encoder.
|
| Subclasses should override.
|
| line_buffering
|
| name
|
| newlines
| Line endings translated so far.
|
| Only line endings translated during reading are considered.
|
| Subclasses should override.
|
| write_through
|
| ----------------------------------------------------------------------
| Methods inherited from _io._IOBase:
|
| __del__(...)
|
| __enter__(...)
|
| __exit__(...)
|
| __iter__(self, /)
| Implement iter(self).
|
| readlines(self, hint=-1, /)
| Return a list of lines from the stream.
|
| hint can be specified to control the number of lines read: no more
| lines will be read if the total size (in bytes/characters) of all
| lines so far exceeds hint.
|
| writelines(self, lines, /)
| Write a list of lines to stream.
|
| Line separators are not added, so it is usual for each of the
| lines provided to have a line separator at the end.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from _io._IOBase:
|
| __dict__
class FileTextWrite(FileText)
| FileTextWrite(buffer, encoding=None, errors=None, newline=None, line_buffering=False, write_through=False)
|
| You can use this class for writing text. Alternatively, you can use `FileText` with `mode="w"`.
| The default mode of this class is `mode="w"`.
|
| **Example**
|
| ```python
| from typing import Annotated
|
| import typer
|
| app = typer.Typer()
|
| @app.command()
| def main(config: Annotated[typer.FileTextWrite, typer.Option()]):
| config.write("Some config written by the app")
| print("Config written")
|
| if __name__ == "__main__":
| app()
| ```
|
| Method resolution order:
| FileTextWrite
| FileText
| _io.TextIOWrapper
| _io._TextIOBase
| _io._IOBase
| builtins.object
|
| Methods inherited from _io.TextIOWrapper:
|
| __init__(self, /, *args, **kwargs)
| Initialize self. See help(type(self)) for accurate signature.
|
| __next__(self, /)
| Implement next(self).
|
| __reduce__(...)
| Helper for pickle.
|
| __reduce_ex__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| close(self, /)
| Flush and close the IO object.
|
| This method has no effect if the file is already closed.
|
| detach(self, /)
| Separate the underlying buffer from the TextIOBase and return it.
|
| After the underlying buffer has been detached, the TextIO is in an unusable state.
|
| fileno(self, /)
| Return underlying file descriptor if one exists.
|
| Raise OSError if the IO object does not use a file descriptor.
|
| flush(self, /)
| Flush write buffers, if applicable.
|
| This is not implemented for read-only and non-blocking streams.
|
| isatty(self, /)
| Return whether this is an 'interactive' stream.
|
| Return False if it can't be determined.
|
| read(self, size=-1, /)
| Read at most size characters from stream.
|
| Read from underlying buffer until we have size characters or we hit EOF.
| If size is negative or omitted, read until EOF.
|
| readable(self, /)
| Return whether object was opened for reading.
|
| If False, read() will raise OSError.
|
| readline(self, size=-1, /)
| Read until newline or EOF.
|
| Return an empty string if EOF is hit immediately.
| If size is specified, at most size characters will be read.
|
| reconfigure(self, /, *, encoding=None, errors=None, newline=None, line_buffering=None, write_through=None)
| Reconfigure the text stream with new parameters.
|
| This also does an implicit stream flush.
|
| seek(self, cookie, whence=0, /)
| Set the stream position, and return the new stream position.
|
| cookie
| Zero or an opaque number returned by tell().
| whence
| The relative position to seek from.
|
| Four operations are supported, given by the following argument
| combinations:
|
| - seek(0, SEEK_SET): Rewind to the start of the stream.
| - seek(cookie, SEEK_SET): Restore a previous position;
| 'cookie' must be a number returned by tell().
| - seek(0, SEEK_END): Fast-forward to the end of the stream.
| - seek(0, SEEK_CUR): Leave the current stream position unchanged.
|
| Any other argument combinations are invalid,
| and may raise exceptions.
|
| seekable(self, /)
| Return whether object supports random access.
|
| If False, seek(), tell() and truncate() will raise OSError.
| This method may need to do a test seek().
|
| tell(self, /)
| Return the stream position as an opaque number.
|
| The return value of tell() can be given as input to seek(), to restore a
| previous stream position.
|
| truncate(self, pos=None, /)
| Truncate file to size bytes.
|
| File pointer is left unchanged. Size defaults to the current IO position
| as reported by tell(). Return the new size.
|
| writable(self, /)
| Return whether object was opened for writing.
|
| If False, write() will raise OSError.
|
| write(self, text, /)
| Write string s to stream.
|
| Return the number of characters written
| (which is always equal to the length of the string).
|
| ----------------------------------------------------------------------
| Data descriptors inherited from _io.TextIOWrapper:
|
| buffer
|
| closed
|
| encoding
| Encoding of the text stream.
|
| Subclasses should override.
|
| errors
| The error setting of the decoder or encoder.
|
| Subclasses should override.
|
| line_buffering
|
| name
|
| newlines
| Line endings translated so far.
|
| Only line endings translated during reading are considered.
|
| Subclasses should override.
|
| write_through
|
| ----------------------------------------------------------------------
| Methods inherited from _io._IOBase:
|
| __del__(...)
|
| __enter__(...)
|
| __exit__(...)
|
| __iter__(self, /)
| Implement iter(self).
|
| readlines(self, hint=-1, /)
| Return a list of lines from the stream.
|
| hint can be specified to control the number of lines read: no more
| lines will be read if the total size (in bytes/characters) of all
| lines so far exceeds hint.
|
| writelines(self, lines, /)
| Write a list of lines to stream.
|
| Line separators are not added, so it is usual for each of the
| lines provided to have a line separator at the end.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from _io._IOBase:
|
| __dict__
class OptionInfo(ParameterInfo)
| OptionInfo(*, default: typing.Any | None = None, param_decls: collections.abc.Sequence[str] | None = None, callback: collections.abc.Callable[..., typing.Any] | None = None, metavar: str | None = None, expose_value: bool = True, is_eager: bool = False, envvar: str | list[str] | None = None, shell_complete: collections.abc.Callable[[typer._click.core.Context, typer._click.core.Parameter, str], list['CompletionItem'] | list[str]] | None = None, autocompletion: collections.abc.Callable[..., typing.Any] | None = None, default_factory: collections.abc.Callable[[], typing.Any] | None = None, parser: collections.abc.Callable[[str], typing.Any] | None = None, click_type: typer._click.types.ParamType | None = None, show_default: bool | str = True, prompt: bool | str = False, confirmation_prompt: bool = False, prompt_required: bool = True, hide_input: bool = False, is_flag: bool | None = None, flag_value: typing.Any | None = None, count: bool = False, allow_from_autoenv: bool = True, help: str | None = None, hidden: bool = False, show_choices: bool = True, show_envvar: bool = True, case_sensitive: bool = True, min: int | float | None = None, max: int | float | None = None, clamp: bool = False, formats: list[str] | None = None, mode: str | None = None, encoding: str | None = None, errors: str | None = 'strict', lazy: bool | None = 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: None | type[str] | type[bytes] = None, rich_help_panel: str | None = None)
|
| Method resolution order:
| OptionInfo
| ParameterInfo
| builtins.object
|
| Methods defined here:
|
| __init__(self, *, default: typing.Any | None = None, param_decls: collections.abc.Sequence[str] | None = None, callback: collections.abc.Callable[..., typing.Any] | None = None, metavar: str | None = None, expose_value: bool = True, is_eager: bool = False, envvar: str | list[str] | None = None, shell_complete: collections.abc.Callable[[typer._click.core.Context, typer._click.core.Parameter, str], list['CompletionItem'] | list[str]] | None = None, autocompletion: collections.abc.Callable[..., typing.Any] | None = None, default_factory: collections.abc.Callable[[], typing.Any] | None = None, parser: collections.abc.Callable[[str], typing.Any] | None = None, click_type: typer._click.types.ParamType | None = None, show_default: bool | str = True, prompt: bool | str = False, confirmation_prompt: bool = False, prompt_required: bool = True, hide_input: bool = False, is_flag: bool | None = None, flag_value: typing.Any | None = None, count: bool = False, allow_from_autoenv: bool = True, help: str | None = None, hidden: bool = False, show_choices: bool = True, show_envvar: bool = True, case_sensitive: bool = True, min: int | float | None = None, max: int | float | None = None, clamp: bool = False, formats: list[str] | None = None, mode: str | None = None, encoding: str | None = None, errors: str | None = 'strict', lazy: bool | None = 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: None | type[str] | type[bytes] = None, rich_help_panel: str | None = None)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from ParameterInfo:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
class ParamMeta(builtins.object)
| ParamMeta(*, name: str, default: Any, annotation: Any) -> None
|
| Methods defined here:
|
| __init__(self, *, name: str, default: Any, annotation: Any) -> None
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| empty = <class 'inspect._empty'>
| Marker object for Signature.empty and Parameter.empty.
class ParameterInfo(builtins.object)
| ParameterInfo(*, default: typing.Any | None = None, param_decls: collections.abc.Sequence[str] | None = None, callback: collections.abc.Callable[..., typing.Any] | None = None, metavar: str | None = None, expose_value: bool = True, is_eager: bool = False, envvar: str | list[str] | None = None, shell_complete: collections.abc.Callable[[typer._click.core.Context, typer._click.core.Parameter, str], list['CompletionItem'] | list[str]] | None = None, autocompletion: collections.abc.Callable[..., typing.Any] | None = None, default_factory: collections.abc.Callable[[], typing.Any] | None = None, parser: collections.abc.Callable[[str], typing.Any] | None = None, click_type: typer._click.types.ParamType | None = None, show_default: bool | str = True, show_choices: bool = True, show_envvar: bool = True, help: str | None = None, hidden: bool = False, case_sensitive: bool = True, min: int | float | None = None, max: int | float | None = None, clamp: bool = False, formats: list[str] | None = None, mode: str | None = None, encoding: str | None = None, errors: str | None = 'strict', lazy: bool | None = 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: None | type[str] | type[bytes] = None, rich_help_panel: str | None = None)
|
| Methods defined here:
|
| __init__(self, *, default: typing.Any | None = None, param_decls: collections.abc.Sequence[str] | None = None, callback: collections.abc.Callable[..., typing.Any] | None = None, metavar: str | None = None, expose_value: bool = True, is_eager: bool = False, envvar: str | list[str] | None = None, shell_complete: collections.abc.Callable[[typer._click.core.Context, typer._click.core.Parameter, str], list['CompletionItem'] | list[str]] | None = None, autocompletion: collections.abc.Callable[..., typing.Any] | None = None, default_factory: collections.abc.Callable[[], typing.Any] | None = None, parser: collections.abc.Callable[[str], typing.Any] | None = None, click_type: typer._click.types.ParamType | None = None, show_default: bool | str = True, show_choices: bool = True, show_envvar: bool = True, help: str | None = None, hidden: bool = False, case_sensitive: bool = True, min: int | float | None = None, max: int | float | None = None, clamp: bool = False, formats: list[str] | None = None, mode: str | None = None, encoding: str | None = None, errors: str | None = 'strict', lazy: bool | None = 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: None | type[str] | type[bytes] = None, rich_help_panel: str | None = None)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
class TyperInfo(builtins.object)
| TyperInfo(typer_instance: Optional[ForwardRef('Typer')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F309E0>, *, name: str | None = <typer.models.DefaultPlaceholder object at 0x0000021D44F30A40>, cls: type['TyperGroup'] | None = <typer.models.DefaultPlaceholder object at 0x0000021D44F30A70>, invoke_without_command: bool = <typer.models.DefaultPlaceholder object at 0x0000021D44F30AA0>, no_args_is_help: bool = <typer.models.DefaultPlaceholder object at 0x0000021D44F30AD0>, subcommand_metavar: str | None = <typer.models.DefaultPlaceholder object at 0x0000021D44F30B00>, chain: bool = <typer.models.DefaultPlaceholder object at 0x0000021D44F30B30>, result_callback: collections.abc.Callable[..., typing.Any] | None = <typer.models.DefaultPlaceholder object at 0x0000021D44F30B60>, context_settings: dict[typing.Any, typing.Any] | None = <typer.models.DefaultPlaceholder object at 0x0000021D44F30B90>, callback: collections.abc.Callable[..., typing.Any] | None = <typer.models.DefaultPlaceholder object at 0x0000021D44F30BC0>, help: str | None = <typer.models.DefaultPlaceholder object at 0x0000021D44F30BF0>, epilog: str | None = <typer.models.DefaultPlaceholder object at 0x0000021D44F30C20>, short_help: str | None = <typer.models.DefaultPlaceholder object at 0x0000021D44F30C50>, options_metavar: str = <typer.models.DefaultPlaceholder object at 0x0000021D44F30C80>, add_help_option: bool = <typer.models.DefaultPlaceholder object at 0x0000021D44F30CB0>, hidden: bool = <typer.models.DefaultPlaceholder object at 0x0000021D44F30CE0>, deprecated: bool = <typer.models.DefaultPlaceholder object at 0x0000021D44F30D10>, rich_help_panel: str | None = <typer.models.DefaultPlaceholder object at 0x0000021D44F30D40>)
|
| Methods defined here:
|
| __init__(self, typer_instance: Optional[ForwardRef('Typer')] = <typer.models.DefaultPlaceholder object at 0x0000021D44F309E0>, *, name: str | None = <typer.models.DefaultPlaceholder object at 0x0000021D44F30A40>, cls: type['TyperGroup'] | None = <typer.models.DefaultPlaceholder object at 0x0000021D44F30A70>, invoke_without_command: bool = <typer.models.DefaultPlaceholder object at 0x0000021D44F30AA0>, no_args_is_help: bool = <typer.models.DefaultPlaceholder object at 0x0000021D44F30AD0>, subcommand_metavar: str | None = <typer.models.DefaultPlaceholder object at 0x0000021D44F30B00>, chain: bool = <typer.models.DefaultPlaceholder object at 0x0000021D44F30B30>, result_callback: collections.abc.Callable[..., typing.Any] | None = <typer.models.DefaultPlaceholder object at 0x0000021D44F30B60>, context_settings: dict[typing.Any, typing.Any] | None = <typer.models.DefaultPlaceholder object at 0x0000021D44F30B90>, callback: collections.abc.Callable[..., typing.Any] | None = <typer.models.DefaultPlaceholder object at 0x0000021D44F30BC0>, help: str | None = <typer.models.DefaultPlaceholder object at 0x0000021D44F30BF0>, epilog: str | None = <typer.models.DefaultPlaceholder object at 0x0000021D44F30C20>, short_help: str | None = <typer.models.DefaultPlaceholder object at 0x0000021D44F30C50>, options_metavar: str = <typer.models.DefaultPlaceholder object at 0x0000021D44F30C80>, add_help_option: bool = <typer.models.DefaultPlaceholder object at 0x0000021D44F30CB0>, hidden: bool = <typer.models.DefaultPlaceholder object at 0x0000021D44F30CE0>, deprecated: bool = <typer.models.DefaultPlaceholder object at 0x0000021D44F30D10>, rich_help_panel: str | None = <typer.models.DefaultPlaceholder object at 0x0000021D44F30D40>)
| Initialize self. See help(type(self)) for accurate signature.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
class TyperPath(typer._click.types.ParamType)
| TyperPath(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: type[typing.Any] | None = None)
|
| Method resolution order:
| TyperPath
| typer._click.types.ParamType
| builtins.object
|
| Methods defined here:
|
| __init__(self, 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: type[typing.Any] | None = None)
| Initialize self. See help(type(self)) for accurate signature.
|
| coerce_path_result(self, value: str | os.PathLike[str]) -> str | bytes | os.PathLike[str]
|
| convert(self, value: str | os.PathLike[str], param: typer._click.core.Parameter | None, ctx: typer.models.Context | None) -> str | bytes | os.PathLike[str]
|
| shell_complete(self, ctx: typer._click.core.Context, param: typer._click.core.Parameter, incomplete: str) -> list[typer._click.shell_completion.CompletionItem]
| Return an empty list so that the autocompletion functionality
| will work properly from the commandline.
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {'envvar_list_splitter': typing.ClassVar[str]}
|
| envvar_list_splitter = ';'
|
| ----------------------------------------------------------------------
| Methods inherited from typer._click.types.ParamType:
|
| __call__(self, value: Any, param: Optional[ForwardRef('Parameter')] = None, ctx: Optional[ForwardRef('Context')] = None) -> Any
| Call self as a function.
|
| fail(self, message: str, param: Optional[ForwardRef('Parameter')] = None, ctx: Optional[ForwardRef('Context')] = None) -> NoReturn
| Helper method to fail with an invalid value message.
|
| get_metavar(self, param: 'Parameter', ctx: 'Context') -> str | None
| Returns the metavar default for this param if it provides one.
|
| get_missing_message(self, param: 'Parameter', ctx: Optional[ForwardRef('Context')]) -> str | None
| Optionally might return extra information about a missing
| parameter.
|
| split_envvar_value(self, rv: str) -> collections.abc.Sequence[str]
| Given a value from an environment variable this splits it up
| into small chunks depending on the defined envvar list splitter.
|
| If the splitter is set to `None`, which means that whitespace splits,
| then leading and trailing whitespace is ignored. Otherwise, leading
| and trailing splitters usually lead to empty items being included.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from typer._click.types.ParamType:
|
| __dict__
| dictionary for instance variables
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from typer._click.types.ParamType:
|
| arity = 1
|
| is_composite = False
FUNCTIONS
Default(value: ~DefaultType) -> ~DefaultType
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`.
DATA
AnyType = type[typing.Any]
ClassVar = typing.ClassVar
Special type construct to mark class variables.
An annotation wrapped in ClassVar indicates that a given
attribute is intended to be used as a class variable and
should not be set on instances of that class.
Usage::
class Starship:
stats: ClassVar[dict[str, int]] = {} # class variable
damage: int = 10 # instance variable
ClassVar accepts only types and cannot be further subscribed.
Note that ClassVar is not a class itself, and should not
be used with isinstance() or issubclass().
CommandFunctionType = ~CommandFunctionType
DefaultType = ~DefaultType
Optional = typing.Optional
Optional[X] is equivalent to Union[X, None].
Required = Ellipsis
TYPE_CHECKING = False
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\typer\models.py
typer.params
Python Library Documentation: module typer.params in typer
NAME
typer.params
FUNCTIONS
Argument(default: Annotated[Any | None, Doc('\n By default, CLI arguments are required. However, by giving them a default value they become [optional](https://typer.tiangolo.com/tutorial/arguments/optional):\n\n **Example**\n\n ```python\n @app.command()\n def main(name: str = typer.Argument("World")):\n print(f"Hello {name}!")\n ```\n\n Note that this usage is deprecated, and we recommend to use `Annotated` instead:\n ```python\n @app.command()\n def main(name: Annotated[str, typer.Argument()] = "World"):\n print(f"Hello {name}!")\n ```\n ')] = Ellipsis, *, callback: Annotated[collections.abc.Callable[..., Any] | None, Doc('\n Add a callback to this CLI Argument, to execute additional logic with the value received from the terminal.\n See [the tutorial about callbacks](https://typer.tiangolo.com/tutorial/options/callback-and-context/) for more details.\n\n **Example**\n\n ```python\n def name_callback(value: str):\n if value != "Deadpool":\n raise typer.BadParameter("Only Deadpool is allowed")\n return value\n\n @app.command()\n def main(name: Annotated[str, typer.Argument(callback=name_callback)]):\n print(f"Hello {name}")\n ```\n ')] = None, metavar: Annotated[str | None, Doc('\n Customize the name displayed in the help text to represent this CLI Argument.\n By default, it will be the same name you declared, in uppercase.\n See [the tutorial about CLI Arguments with Help](https://typer.tiangolo.com/tutorial/arguments/help/#custom-help-name-metavar) for more details.\n\n **Example**\n\n ```python\n @app.command()\n def main(name: Annotated[str, typer.Argument(metavar="✨username✨")]):\n print(f"Hello {name}")\n ```\n ')] = None, expose_value: Annotated[bool, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.\n\n ---\n\n If this is `True` then the value is passed onwards to the command callback and stored on the context, otherwise it’s skipped.\n ")] = True, is_eager: Annotated[bool, Doc('\n Set an argument to "eager" to ensure it gets processed before other CLI parameters. This could be relevant when there are other parameters with callbacks that could exit the program early.\n For more information and an extended example, see the documentation [here](https://typer.tiangolo.com/tutorial/options/version/#fix-with-is_eager).\n ')] = False, envvar: Annotated[str | list[str] | None, Doc('\n Configure an argument to read a value from an environment variable if it is not provided in the command line as a CLI argument.\n For more information, see the [documentation on Environment Variables](https://typer.tiangolo.com/tutorial/arguments/envvar/).\n\n **Example**\n\n ```python\n @app.command()\n def main(name: Annotated[str, typer.Argument(envvar="ME")]):\n print(f"Hello Mr. {name}")\n ```\n ')] = None, shell_complete: Annotated[collections.abc.Callable[[typer._click.core.Context, typer._click.core.Parameter, str], list['CompletionItem'] | list[str]] | None, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.\n It is however not fully functional, and will likely be removed in future versions.\n ")] = None, autocompletion: Annotated[collections.abc.Callable[..., Any] | None, Doc('\n Provide a custom function that helps to autocomplete the values of this CLI Argument.\n See [the tutorial on parameter autocompletion](https://typer.tiangolo.com/tutorial/options-autocompletion) for more details.\n\n **Example**\n\n ```python\n def complete():\n return ["Me", "Myself", "I"]\n\n @app.command()\n def main(name: Annotated[str, typer.Argument(autocompletion=complete)]):\n print(f"Hello {name}")\n ```\n ')] = None, default_factory: Annotated[collections.abc.Callable[[], Any] | None, Doc('\n Provide a custom function that dynamically generates a [default](https://typer.tiangolo.com/tutorial/arguments/default) for this CLI Argument.\n\n **Example**\n\n ```python\n def get_name():\n return random.choice(["Me", "Myself", "I"])\n\n @app.command()\n def main(name: Annotated[str, typer.Argument(default_factory=get_name)]):\n print(f"Hello {name}")\n ```\n ')] = None, parser: Annotated[collections.abc.Callable[[str], Any] | None, Doc('\n Use your own custom types in Typer applications by defining a `parser` function that parses input into your own types:\n\n **Example**\n\n ```python\n class CustomClass:\n def __init__(self, value: str):\n self.value = value\n\n def __str__(self):\n return f"<CustomClass: value={self.value}>"\n\n def my_parser(value: str):\n return CustomClass(value * 2)\n\n @app.command()\n def main(arg: Annotated[CustomClass, typer.Argument(parser=my_parser):\n print(f"arg is {arg}")\n ```\n ')] = None, click_type: Annotated[typer._click.types.ParamType | None, Doc('\n Define this parameter to use a [custom Click type](https://click.palletsprojects.com/en/stable/parameters/#implementing-custom-types) in your Typer applications.\n\n **Example**\n\n ```python\n class MyClass:\n def __init__(self, value: str):\n self.value = value\n\n def __str__(self):\n return f"<MyClass: value={self.value}>"\n\n class MyParser(click.ParamType):\n name = "MyClass"\n\n def convert(self, value, param, ctx):\n return MyClass(value * 3)\n\n @app.command()\n def main(arg: Annotated[MyClass, typer.Argument(click_type=MyParser())]):\n print(f"arg is {arg}")\n ```\n ')] = None, show_default: Annotated[bool | str, Doc('\n When set to `False`, don\'t show the default value of this CLI Argument in the [help text](https://typer.tiangolo.com/tutorial/arguments/help/).\n\n **Example**\n\n ```python\n @app.command()\n def main(name: Annotated[str, typer.Argument(show_default=False)] = "Rick"):\n print(f"Hello {name}")\n ```\n ')] = True, show_choices: Annotated[bool, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.\n\n ---\n\n When set to `False`, this suppresses choices from being displayed inline when `prompt` is used.\n ")] = True, show_envvar: Annotated[bool, Doc('\n When an ["envvar"](https://typer.tiangolo.com/tutorial/arguments/envvar) is defined, prevent it from showing up in the help text:\n\n **Example**\n\n ```python\n @app.command()\n def main(name: Annotated[str, typer.Argument(envvar="ME", show_envvar=False)]):\n print(f"Hello Mr. {name}")\n ```\n ')] = True, help: Annotated[str | None, Doc('\n Help text for this CLI Argument.\n See [the tutorial about CLI Arguments with help](https://typer.tiangolo.com/tutorial/arguments/help/) for more dedails.\n\n **Example**\n\n ```python\n @app.command()\n def greet(name: Annotated[str, typer.Argument(help="Person to greet")]):\n print(f"Hello {name}")\n ```\n ')] = None, hidden: Annotated[bool, Doc('\n Hide this CLI Argument from [help outputs](https://typer.tiangolo.com/tutorial/arguments/help). `False` by default.\n\n **Example**\n\n ```python\n @app.command()\n def main(name: Annotated[str, typer.Argument(hidden=True)] = "World"):\n print(f"Hello {name}")\n ```\n ')] = False, case_sensitive: Annotated[bool, Doc('\n For a CLI Argument representing an [Enum (choice)](https://typer.tiangolo.com/tutorial/parameter-types/enum),\n you can allow case-insensitive matching with this parameter:\n\n **Example**\n\n ```python\n from enum import Enum\n\n class NeuralNetwork(str, Enum):\n simple = "simple"\n conv = "conv"\n lstm = "lstm"\n\n @app.command()\n def main(\n network: Annotated[NeuralNetwork, typer.Argument(case_sensitive=False)]):\n print(f"Training neural network of type: {network.value}")\n ```\n\n With this setting, "LSTM" or "lstm" will both be valid values that will be resolved to `NeuralNetwork.lstm`.\n ')] = True, min: Annotated[int | float | None, Doc('\n For a CLI Argument representing a [number](https://typer.tiangolo.com/tutorial/parameter-types/number/) (`int` or `float`),\n you can define numeric validations with `min` and `max` values:\n\n **Example**\n\n ```python\n @app.command()\n def main(\n user: Annotated[str, typer.Argument()],\n user_id: Annotated[int, typer.Argument(min=1, max=1000)],\n ):\n print(f"ID for {user} is {user_id}")\n ```\n\n If the user attempts to input an invalid number, an error will be shown, explaining why the value is invalid.\n ')] = None, max: Annotated[int | float | None, Doc('\n For a CLI Argument representing a [number](https://typer.tiangolo.com/tutorial/parameter-types/number/) (`int` or `float`),\n you can define numeric validations with `min` and `max` values:\n\n **Example**\n\n ```python\n @app.command()\n def main(\n user: Annotated[str, typer.Argument()],\n user_id: Annotated[int, typer.Argument(min=1, max=1000)],\n ):\n print(f"ID for {user} is {user_id}")\n ```\n\n If the user attempts to input an invalid number, an error will be shown, explaining why the value is invalid.\n ')] = None, clamp: Annotated[bool, Doc('\n For a CLI Argument representing a [number](https://typer.tiangolo.com/tutorial/parameter-types/number/) and that is bounded by using `min` and/or `max`,\n you can opt to use the closest minimum or maximum value instead of raising an error. This is done by setting `clamp` to `True`.\n\n **Example**\n\n ```python\n @app.command()\n def main(\n user: Annotated[str, typer.Argument()],\n user_id: Annotated[int, typer.Argument(min=1, max=1000, clamp=True)],\n ):\n print(f"ID for {user} is {user_id}")\n ```\n\n If the user attempts to input 3420 for `user_id`, this will internally be converted to `1000`.\n ')] = False, formats: Annotated[list[str] | None, Doc('\n For a CLI Argument representing a [DateTime object](https://typer.tiangolo.com/tutorial/parameter-types/datetime),\n you can customize the formats that can be parsed automatically:\n\n **Example**\n\n ```python\n from datetime import datetime\n\n @app.command()\n def main(\n birthday: Annotated[\n datetime,\n typer.Argument(\n formats=["%Y-%m-%d", "%Y-%m-%d %H:%M:%S", "%m/%d/%Y"]\n ),\n ],\n ):\n print(f"Birthday defined at: {birthday}")\n ```\n ')] = None, mode: Annotated[str | None, Doc('\n For a CLI Argument representing a [File object](https://typer.tiangolo.com/tutorial/parameter-types/file/),\n you can customize the mode to open the file with. If unset, Typer will set a [sensible value by default](https://typer.tiangolo.com/tutorial/parameter-types/file/#advanced-mode).\n\n **Example**\n\n ```python\n @app.command()\n def main(config: Annotated[typer.FileText, typer.Argument(mode="a")]):\n config.write("This is a single line\\n")\n print("Config line written")\n ```\n ')] = None, encoding: Annotated[str | None, Doc('\n Customize the encoding of this CLI Argument represented by a [File object](https://typer.tiangolo.com/tutorial/parameter-types/file/).\n\n **Example**\n\n ```python\n @app.command()\n def main(config: Annotated[typer.FileText, typer.Argument(encoding="utf-8")]):\n config.write("All the text gets written\\n")\n ```\n ')] = None, errors: Annotated[str | None, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.\n\n ---\n\n The error handling mode.\n ")] = 'strict', lazy: Annotated[bool | None, Doc('\n For a CLI Argument representing a [File object](https://typer.tiangolo.com/tutorial/parameter-types/file/),\n by default the file will not be created until you actually start writing to it.\n You can change this behaviour by setting this parameter.\n By default, it\'s set to `True` for writing and to `False` for reading.\n\n **Example**\n\n ```python\n @app.command()\n def main(config: Annotated[typer.FileText, typer.Argument(mode="a", lazy=False)]):\n config.write("This is a single line\\n")\n print("Config line written")\n ```\n ')] = None, atomic: Annotated[bool, Doc('\n For a CLI Argument representing a [File object](https://typer.tiangolo.com/tutorial/parameter-types/file/),\n you can ensure that all write instructions first go into a temporal file, and are only moved to the final destination after completing\n by setting `atomic` to `True`. This can be useful for files with potential concurrent access.\n\n **Example**\n\n ```python\n @app.command()\n def main(config: Annotated[typer.FileText, typer.Argument(mode="a", atomic=True)]):\n config.write("All the text")\n ```\n ')] = False, exists: Annotated[bool, Doc('\n When set to `True` for a [`Path` argument](https://typer.tiangolo.com/tutorial/parameter-types/path/),\n additional validation is performed to check that the file or directory exists. If not, the value will be invalid.\n\n **Example**\n\n ```python\n from pathlib import Path\n\n @app.command()\n def main(config: Annotated[Path, typer.Argument(exists=True)]):\n text = config.read_text()\n print(f"Config file contents: {text}")\n ```\n ')] = False, file_okay: Annotated[bool, Doc('\n Determine whether or not a [`Path` argument](https://typer.tiangolo.com/tutorial/parameter-types/path/)\n is allowed to refer to a file. When this is set to `False`, the application will raise a validation error when a path to a file is given.\n\n **Example**\n\n ```python\n from pathlib import Path\n\n @app.command()\n def main(config: Annotated[Path, typer.Argument(exists=True, file_okay=False)]):\n print(f"Directory listing: {[x.name for x in config.iterdir()]}")\n ```\n ')] = True, dir_okay: Annotated[bool, Doc('\n Determine whether or not a [`Path` argument](https://typer.tiangolo.com/tutorial/parameter-types/path/)\n is allowed to refer to a directory. When this is set to `False`, the application will raise a validation error when a path to a directory is given.\n\n **Example**\n\n ```python\n from pathlib import Path\n\n @app.command()\n def main(config: Annotated[Path, typer.Argument(exists=True, dir_okay=False)]):\n text = config.read_text()\n print(f"Config file contents: {text}")\n ```\n ')] = True, writable: Annotated[bool, Doc('\n Whether or not to perform a writable check for this [`Path` argument](https://typer.tiangolo.com/tutorial/parameter-types/path/).\n\n **Example**\n\n ```python\n from pathlib import Path\n\n @app.command()\n def main(config: Annotated[Path, typer.Argument(writable=True)]):\n config.write_text("All the text")\n ```\n ')] = False, readable: Annotated[bool, Doc('\n Whether or not to perform a readable check for this [`Path` argument](https://typer.tiangolo.com/tutorial/parameter-types/path/).\n\n **Example**\n\n ```python\n from pathlib import Path\n\n @app.command()\n def main(config: Annotated[Path, typer.Argument(readable=True)]):\n config.read_text("All the text")\n ```\n ')] = True, resolve_path: Annotated[bool, Doc('\n Whether or not to fully resolve the path of this [`Path` argument](https://typer.tiangolo.com/tutorial/parameter-types/path/),\n meaning that the path becomes absolute and symlinks are resolved.\n\n **Example**\n\n ```python\n from pathlib import Path\n\n @app.command()\n def main(config: Annotated[Path, typer.Argument(resolve_path=True)]):\n config.read_text("All the text")\n ```\n ')] = False, allow_dash: Annotated[bool, Doc('\n When set to `True`, a single dash for this [`Path` argument](https://typer.tiangolo.com/tutorial/parameter-types/path/)\n would be a valid value, indicating standard streams. This is a more advanced use-case.\n ')] = False, path_type: Annotated[None | type[str] | type[bytes], Doc('\n A string type that will be used to represent this [`Path` argument](https://typer.tiangolo.com/tutorial/parameter-types/path/).\n The default is `None` which means the return value will be either bytes or unicode, depending on what makes most sense given the input data.\n This is a more advanced use-case.\n ')] = None, rich_help_panel: Annotated[str | None, Doc('\n Set the panel name where you want this CLI Argument to be shown in the [help text](https://typer.tiangolo.com/tutorial/arguments/help).\n\n **Example**\n\n ```python\n @app.command()\n def main(\n name: Annotated[str, typer.Argument(help="Who to greet")],\n age: Annotated[str, typer.Option(help="Their age", rich_help_panel="Data")],\n ):\n print(f"Hello {name} of age {age}")\n ```\n ')] = None) -> Any
A [CLI Argument](https://typer.tiangolo.com/tutorial/arguments) is a positional parameter to your command line application.
Often, CLI Arguments are required, meaning that users have to specify them. However, you can set them to be optional by defining a default value:
## Example
```python
@app.command()
def main(name: Annotated[str, typer.Argument()] = "World"):
print(f"Hello {name}!")
```
Note how in this example, if `name` is not specified on the command line, the application will still execute normally and print "Hello World!".
Option(default: Annotated[Any | None, Doc('\n Usually, [CLI options](https://typer.tiangolo.com/tutorial/options/) are optional and have a default value, passed on like this:\n\n **Example**\n\n ```python\n @app.command()\n def main(network: str = typer.Option("CNN")):\n print(f"Training neural network of type: {network}")\n ```\n\n Note that this usage is deprecated, and we recommend to use `Annotated` instead:\n ```\n @app.command()\n def main(network: Annotated[str, typer.Option()] = "CNN"):\n print(f"Hello {name}!")\n ```\n\n You can also use `...` ([Ellipsis](https://docs.python.org/3/library/constants.html#Ellipsis)) as the "default" value to clarify that this is a required CLI option.\n ')] = Ellipsis, *param_decls: Annotated[str, Doc('\n Positional argument that defines how users can call this option on the command line. This may be one or multiple aliases, all strings.\n If not defined, Typer will automatically use the function parameter as default name.\n See [the tutorial about CLI Option Names](https://typer.tiangolo.com/tutorial/options/name/) for more details.\n\n **Example**\n\n ```python\n @app.command()\n def main(user_name: Annotated[str, typer.Option("--user", "-u", "-x")]):\n print(f"Hello {user_name}")\n ```\n ')], callback: Annotated[collections.abc.Callable[..., Any] | None, Doc('\n Add a callback to this CLI Option, to execute additional logic after its value was received from the terminal.\n See [the tutorial about callbacks](https://typer.tiangolo.com/tutorial/options/callback-and-context/) for more details.\n\n **Example**\n\n ```python\n def name_callback(value: str):\n if value != "Deadpool":\n raise typer.BadParameter("Only Deadpool is allowed")\n return value\n\n @app.command()\n def main(name: Annotated[str, typer.Option(callback=name_callback)]):\n print(f"Hello {name}")\n ```\n ')] = None, metavar: Annotated[str | None, Doc('\n Customize the name displayed in the [help text](https://typer.tiangolo.com/tutorial/options/help/) to represent this CLI option.\n Note that this doesn\'t influence the way the option must be called.\n\n **Example**\n\n ```python\n @app.command()\n def main(user: Annotated[str, typer.Option(metavar="User name")]):\n print(f"Hello {user}")\n ```\n ')] = None, expose_value: Annotated[bool, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.\n\n ---\n\n If this is `True` then the value is passed onwards to the command callback and stored on the context, otherwise it’s skipped.\n ")] = True, is_eager: Annotated[bool, Doc('\n Mark a CLI Option to be "eager", ensuring it gets processed before other CLI parameters. This could be relevant when there are other parameters with callbacks that could exit the program early.\n For more information and an extended example, see the documentation [here](https://typer.tiangolo.com/tutorial/options/version/#fix-with-is_eager).\n ')] = False, envvar: Annotated[str | list[str] | None, Doc('\n Configure a CLI Option to read its value from an environment variable if it is not provided in the command line.\n For more information, see the [documentation on Environment Variables](https://typer.tiangolo.com/tutorial/arguments/envvar/).\n\n **Example**\n\n ```python\n @app.command()\n def main(user: Annotated[str, typer.Option(envvar="ME")]):\n print(f"Hello {user}")\n ```\n ')] = None, shell_complete: Annotated[collections.abc.Callable[[typer._click.core.Context, typer._click.core.Parameter, str], list['CompletionItem'] | list[str]] | None, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.\n It is however not fully functional, and will likely be removed in future versions.\n ")] = None, autocompletion: Annotated[collections.abc.Callable[..., Any] | None, Doc('\n Provide a custom function that helps to autocomplete the values of this CLI Option.\n See [the tutorial on parameter autocompletion](https://typer.tiangolo.com/tutorial/options-autocompletion) for more details.\n\n **Example**\n\n ```python\n def complete():\n return ["Me", "Myself", "I"]\n\n @app.command()\n def main(name: Annotated[str, typer.Option(autocompletion=complete)]):\n print(f"Hello {name}")\n ```\n ')] = None, default_factory: Annotated[collections.abc.Callable[[], Any] | None, Doc('\n Provide a custom function that dynamically generates a [default](https://typer.tiangolo.com/tutorial/arguments/default) for this CLI Option.\n\n **Example**\n\n ```python\n def get_name():\n return random.choice(["Me", "Myself", "I"])\n\n @app.command()\n def main(name: Annotated[str, typer.Option(default_factory=get_name)]):\n print(f"Hello {name}")\n ```\n ')] = None, parser: Annotated[collections.abc.Callable[[str], Any] | None, Doc('\n Use your own custom types in Typer applications by defining a `parser` function that parses input into your own types:\n\n **Example**\n\n ```python\n class CustomClass:\n def __init__(self, value: str):\n self.value = value\n\n def __str__(self):\n return f"<CustomClass: value={self.value}>"\n\n def my_parser(value: str):\n return CustomClass(value * 2)\n\n @app.command()\n def main(opt: Annotated[CustomClass, typer.Option(parser=my_parser)] = "Foo"):\n print(f"--opt is {opt}")\n ```\n ')] = None, click_type: Annotated[typer._click.types.ParamType | None, Doc('\n Define this parameter to use a [custom Click type](https://click.palletsprojects.com/en/stable/parameters/#implementing-custom-types) in your Typer applications.\n\n **Example**\n\n ```python\n class MyClass:\n def __init__(self, value: str):\n self.value = value\n\n def __str__(self):\n return f"<MyClass: value={self.value}>"\n\n class MyParser(click.ParamType):\n name = "MyClass"\n\n def convert(self, value, param, ctx):\n return MyClass(value * 3)\n\n @app.command()\n def main(opt: Annotated[MyClass, typer.Option(click_type=MyParser())] = "Foo"):\n print(f"--opt is {opt}")\n ```\n ')] = None, show_default: Annotated[bool | str, Doc('\n When set to `False`, don\'t show the default value of this CLI Option in the [help text](https://typer.tiangolo.com/tutorial/options/help/).\n\n **Example**\n\n ```python\n @app.command()\n def main(name: Annotated[str, typer.Option(show_default=False)] = "Rick"):\n print(f"Hello {name}")\n ```\n ')] = True, prompt: Annotated[bool | str, Doc('\n When set to `True`, a prompt will appear to ask for the value of this CLI Option if it was not provided:\n\n **Example**\n\n ```python\n @app.command()\n def main(name: str, lastname: Annotated[str, typer.Option(prompt=True)]):\n print(f"Hello {name} {lastname}")\n ```\n ')] = False, confirmation_prompt: Annotated[bool, Doc('\n When set to `True`, a user will need to type a prompted value twice (may be useful for passwords etc.).\n\n **Example**\n\n ```python\n @app.command()\n def main(project: Annotated[str, typer.Option(prompt=True, confirmation_prompt=True)]):\n print(f"Deleting project {project}")\n ```\n ')] = False, prompt_required: Annotated[bool, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.\n\n ---\n\n If this is `False` then a prompt is only shown if the option's flag is given without a value.\n ")] = True, hide_input: Annotated[bool, Doc('\n When you\'ve configured a prompt, for instance for [querying a password](https://typer.tiangolo.com/tutorial/options/password/),\n don\'t show anything on the screen while the user is typing the value.\n\n **Example**\n\n ```python\n @app.command()\n def login(\n name: str,\n password: Annotated[str, typer.Option(prompt=True, hide_input=True)],\n ):\n print(f"Hello {name}. Doing something very secure with password.")\n ```\n ')] = False, is_flag: Annotated[bool | None, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.\n It is however not fully functional, and will likely be removed in future versions.\n ")] = None, flag_value: Annotated[Any | None, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.\n It is however not fully functional, and will likely be removed in future versions.\n ")] = None, count: Annotated[bool, Doc('\n Make a CLI Option work as a [counter](https://typer.tiangolo.com/tutorial/parameter-types/number/#counter-cli-options).\n The CLI option will have the `int` value representing the number of times the option was used on the command line.\n\n **Example**\n\n ```python\n @app.command()\n def main(verbose: Annotated[int, typer.Option("--verbose", "-v", count=True)] = 0):\n print(f"Verbose level is {verbose}")\n ```\n ')] = False, allow_from_autoenv: Annotated[bool, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.\n\n ---\n\n If this is enabled then the value of this parameter will be pulled from an environment variable in case a prefix is defined on the context.\n ")] = True, help: Annotated[str | None, Doc('\n Help text for this CLI Option.\n See [the tutorial about CLI Options with help](https://typer.tiangolo.com/tutorial/options/help/) for more dedails.\n\n **Example**\n\n ```python\n @app.command()\n def greet(name: Annotated[str, typer.Option(help="Person to greet")] = "Deadpool"):\n print(f"Hello {name}")\n ```\n ')] = None, hidden: Annotated[bool, Doc('\n Hide this CLI Option from [help outputs](https://typer.tiangolo.com/tutorial/options/help). `False` by default.\n\n **Example**\n\n ```python\n @app.command()\n def greet(name: Annotated[str, typer.Option(hidden=True)] = "Deadpool"):\n print(f"Hello {name}")\n ```\n ')] = False, show_choices: Annotated[bool, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.\n\n ---\n\n When set to `False`, this suppresses choices from being displayed inline when `prompt` is used.\n ")] = True, show_envvar: Annotated[bool, Doc('\n When an ["envvar"](https://typer.tiangolo.com/tutorial/arguments/envvar) is defined, prevent it from showing up in the help text:\n\n **Example**\n\n ```python\n @app.command()\n def main(user: Annotated[str, typer.Option(envvar="ME", show_envvar=False)]):\n print(f"Hello {user}")\n ```\n ')] = True, case_sensitive: Annotated[bool, Doc('\n For a CLI Option representing an [Enum (choice)](https://typer.tiangolo.com/tutorial/parameter-types/enum),\n you can allow case-insensitive matching with this parameter:\n\n **Example**\n\n ```python\n from enum import Enum\n\n class NeuralNetwork(str, Enum):\n simple = "simple"\n conv = "conv"\n lstm = "lstm"\n\n @app.command()\n def main(\n network: Annotated[NeuralNetwork, typer.Option(case_sensitive=False)]):\n print(f"Training neural network of type: {network.value}")\n ```\n\n With this setting, "LSTM" or "lstm" will both be valid values that will be resolved to `NeuralNetwork.lstm`.\n ')] = True, min: Annotated[int | float | None, Doc('\n For a CLI Option representing a [number](https://typer.tiangolo.com/tutorial/parameter-types/number/) (`int` or `float`),\n you can define numeric validations with `min` and `max` values:\n\n **Example**\n\n ```python\n @app.command()\n def main(\n user: Annotated[str, typer.Argument()],\n user_id: Annotated[int, typer.Option(min=1, max=1000)],\n ):\n print(f"ID for {user} is {user_id}")\n ```\n\n If the user attempts to input an invalid number, an error will be shown, explaining why the value is invalid.\n ')] = None, max: Annotated[int | float | None, Doc('\n For a CLI Option representing a [number](https://typer.tiangolo.com/tutorial/parameter-types/number/) (`int` or `float`),\n you can define numeric validations with `min` and `max` values:\n\n **Example**\n\n ```python\n @app.command()\n def main(\n user: Annotated[str, typer.Argument()],\n user_id: Annotated[int, typer.Option(min=1, max=1000)],\n ):\n print(f"ID for {user} is {user_id}")\n ```\n\n If the user attempts to input an invalid number, an error will be shown, explaining why the value is invalid.\n ')] = None, clamp: Annotated[bool, Doc('\n For a CLI Option representing a [number](https://typer.tiangolo.com/tutorial/parameter-types/number/) and that is bounded by using `min` and/or `max`,\n you can opt to use the closest minimum or maximum value instead of raising an error when the value is out of bounds. This is done by setting `clamp` to `True`.\n\n **Example**\n\n ```python\n @app.command()\n def main(\n user: Annotated[str, typer.Argument()],\n user_id: Annotated[int, typer.Option(min=1, max=1000, clamp=True)],\n ):\n print(f"ID for {user} is {user_id}")\n ```\n\n If the user attempts to input 3420 for `user_id`, this will internally be converted to `1000`.\n ')] = False, formats: Annotated[list[str] | None, Doc('\n For a CLI Option representing a [DateTime object](https://typer.tiangolo.com/tutorial/parameter-types/datetime),\n you can customize the formats that can be parsed automatically:\n\n **Example**\n\n ```python\n from datetime import datetime\n\n @app.command()\n def main(\n birthday: Annotated[\n datetime,\n typer.Option(\n formats=["%Y-%m-%d", "%Y-%m-%d %H:%M:%S", "%m/%d/%Y"]\n ),\n ],\n ):\n print(f"Birthday defined at: {birthday}")\n ```\n ')] = None, mode: Annotated[str | None, Doc('\n For a CLI Option representing a [File object](https://typer.tiangolo.com/tutorial/parameter-types/file/),\n you can customize the mode to open the file with. If unset, Typer will set a [sensible value by default](https://typer.tiangolo.com/tutorial/parameter-types/file/#advanced-mode).\n\n **Example**\n\n ```python\n @app.command()\n def main(config: Annotated[typer.FileText, typer.Option(mode="a")]):\n config.write("This is a single line\\n")\n print("Config line written")\n ```\n ')] = None, encoding: Annotated[str | None, Doc('\n Customize the encoding of this CLI Option represented by a [File object](https://typer.tiangolo.com/tutorial/parameter-types/file/).\n\n **Example**\n\n ```python\n @app.command()\n def main(config: Annotated[typer.FileText, typer.Option(encoding="utf-8")]):\n config.write("All the text gets written\\n")\n ```\n ')] = None, errors: Annotated[str | None, Doc("\n **Note**: you probably shouldn't use this parameter, it is inherited from Click and supported for compatibility.\n\n ---\n\n The error handling mode.\n ")] = 'strict', lazy: Annotated[bool | None, Doc('\n For a CLI Option representing a [File object](https://typer.tiangolo.com/tutorial/parameter-types/file/),\n by default the file will not be created until you actually start writing to it.\n You can change this behaviour by setting this parameter.\n By default, it\'s set to `True` for writing and to `False` for reading.\n\n **Example**\n\n ```python\n @app.command()\n def main(config: Annotated[typer.FileText, typer.Option(mode="a", lazy=False)]):\n config.write("This is a single line\\n")\n print("Config line written")\n ```\n ')] = None, atomic: Annotated[bool, Doc('\n For a CLI Option representing a [File object](https://typer.tiangolo.com/tutorial/parameter-types/file/),\n you can ensure that all write instructions first go into a temporal file, and are only moved to the final destination after completing\n by setting `atomic` to `True`. This can be useful for files with potential concurrent access.\n\n **Example**\n\n ```python\n @app.command()\n def main(config: Annotated[typer.FileText, typer.Option(mode="a", atomic=True)]):\n config.write("All the text")\n ```\n ')] = False, exists: Annotated[bool, Doc('\n When set to `True` for a [`Path` CLI Option](https://typer.tiangolo.com/tutorial/parameter-types/path/),\n additional validation is performed to check that the file or directory exists. If not, the value will be invalid.\n\n **Example**\n\n ```python\n from pathlib import Path\n\n @app.command()\n def main(config: Annotated[Path, typer.Option(exists=True)]):\n text = config.read_text()\n print(f"Config file contents: {text}")\n ```\n ')] = False, file_okay: Annotated[bool, Doc('\n Determine whether or not a [`Path` CLI Option](https://typer.tiangolo.com/tutorial/parameter-types/path/)\n is allowed to refer to a file. When this is set to `False`, the application will raise a validation error when a path to a file is given.\n\n **Example**\n\n ```python\n from pathlib import Path\n\n @app.command()\n def main(config: Annotated[Path, typer.Option(exists=True, file_okay=False)]):\n print(f"Directory listing: {[x.name for x in config.iterdir()]}")\n ```\n ')] = True, dir_okay: Annotated[bool, Doc('\n Determine whether or not a [`Path` CLI Option](https://typer.tiangolo.com/tutorial/parameter-types/path/)\n is allowed to refer to a directory. When this is set to `False`, the application will raise a validation error when a path to a directory is given.\n\n **Example**\n\n ```python\n from pathlib import Path\n\n @app.command()\n def main(config: Annotated[Path, typer.Argument(exists=True, dir_okay=False)]):\n text = config.read_text()\n print(f"Config file contents: {text}")\n ```\n ')] = True, writable: Annotated[bool, Doc('\n Whether or not to perform a writable check for this [`Path` CLI Option](https://typer.tiangolo.com/tutorial/parameter-types/path/).\n\n **Example**\n\n ```python\n from pathlib import Path\n\n @app.command()\n def main(config: Annotated[Path, typer.Option(writable=True)]):\n config.write_text("All the text")\n ```\n ')] = False, readable: Annotated[bool, Doc('\n Whether or not to perform a readable check for this [`Path` CLI Option](https://typer.tiangolo.com/tutorial/parameter-types/path/).\n\n **Example**\n\n ```python\n from pathlib import Path\n\n @app.command()\n def main(config: Annotated[Path, typer.Option(readable=True)]):\n config.read_text("All the text")\n ```\n ')] = True, resolve_path: Annotated[bool, Doc('\n Whether or not to fully resolve the path of this [`Path` CLI Option](https://typer.tiangolo.com/tutorial/parameter-types/path/),\n meaning that the path becomes absolute and symlinks are resolved.\n\n **Example**\n\n ```python\n from pathlib import Path\n\n @app.command()\n def main(config: Annotated[Path, typer.Option(resolve_path=True)]):\n config.read_text("All the text")\n ```\n ')] = False, allow_dash: Annotated[bool, Doc('\n When set to `True`, a single dash for this [`Path` CLI Option](https://typer.tiangolo.com/tutorial/parameter-types/path/)\n would be a valid value, indicating standard streams. This is a more advanced use-case.\n ')] = False, path_type: Annotated[None | type[str] | type[bytes], Doc('\n A string type that will be used to represent this [`Path` argument](https://typer.tiangolo.com/tutorial/parameter-types/path/).\n The default is `None` which means the return value will be either bytes or unicode, depending on what makes most sense given the input data.\n This is a more advanced use-case.\n ')] = None, rich_help_panel: Annotated[str | None, Doc('\n Set the panel name where you want this CLI Option to be shown in the [help text](https://typer.tiangolo.com/tutorial/arguments/help).\n\n **Example**\n\n ```python\n @app.command()\n def main(\n name: Annotated[str, typer.Argument(help="Who to greet")],\n age: Annotated[str, typer.Option(help="Their age", rich_help_panel="Data")],\n ):\n print(f"Hello {name} of age {age}")\n ```\n ')] = None) -> Any
A [CLI Option](https://typer.tiangolo.com/tutorial/options) is a parameter to your command line application that is called with a single or double dash, something like `--verbose` or `-v`.
Often, CLI Options are optional, meaning that users can omit them from the command. However, you can set them to be required by using `Annotated`
and omitting a default value.
## Example
```python
@app.command()
def register(
user: Annotated[str, typer.Argument()],
age: Annotated[int, typer.Option(min=18)],
):
print(f"User is {user}")
print(f"--age is {age}")
```
Note how in this example, `--age` is a required CLI Option.
DATA
TYPE_CHECKING = False
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\typer\params.py
typer.progressbar
Python Library Documentation: function progressbar in module typer._click.termui
progressbar(iterable: collections.abc.Iterable[~V] | None = None, length: int | None = None, label: str | None = None, hidden: bool = False, show_eta: bool = True, show_percent: bool | None = None, show_pos: bool = False, item_show_func: collections.abc.Callable[[typing.Optional[~V]], str | None] | None = None, fill_char: str = '#', empty_char: str = '-', bar_template: str = '%(label)s [%(bar)s] %(info)s', info_sep: str = ' ', width: int = 36, file: typing.TextIO | None = None, color: bool | None = None, update_min_steps: int = 1) -> 'ProgressBar[V]'
This function creates an iterable context manager that can be used
to iterate over something while showing a progress bar. It will
either iterate over the `iterable` or `length` items (that are counted
up). While iteration happens, this function will print a rendered
progress bar to the given `file` (defaults to stdout) and will attempt
to calculate remaining time and more. By default, this progress bar
will not be rendered if the file is not a terminal.
The context manager creates the progress bar. When the context
manager is entered the progress bar is already created. With every
iteration over the progress bar, the iterable passed to the bar is
advanced and the bar is updated. When the context manager exits,
a newline is printed and the progress bar is finalized on screen.
Note: The progress bar is currently designed for use cases where the
total progress can be expected to take at least several seconds.
Because of this, the ProgressBar class object won't display
progress that is considered too fast, and progress where the time
between steps is less than a second.
No printing must happen or the progress bar will be unintentionally
destroyed.
typer.prompt
Python Library Documentation: function prompt in module typer._click.termui
prompt(text: str, default: typing.Any | None = None, hide_input: bool = False, confirmation_prompt: bool | str = False, type: typer._click.types.ParamType | typing.Any | None = None, value_proc: collections.abc.Callable[[str], typing.Any] | None = None, prompt_suffix: str = ': ', show_default: bool = True, err: bool = False, show_choices: bool = True) -> Any
Prompts a user for input. This is a convenience function that can
be used to prompt a user for input later.
If the user aborts the input by sending an interrupt signal, this
function will catch it and raise an `Abort` exception.
typer.run
Python Library Documentation: function run in module typer.main
run(function: Annotated[collections.abc.Callable[..., Any], Doc('\n The function that should power this CLI application.\n ')]) -> None
This function converts a given function to a CLI application with `Typer()` and executes it.
## Example
```python
import typer
def main(name: str):
print(f"Hello {name}")
if __name__ == "__main__":
typer.run(main)
```
typer.secho
Python Library Documentation: function secho in module typer._click.termui
secho(message: typing.Any | None = None, file: Optional[IO[~AnyStr]] = None, nl: bool = True, err: bool = False, color: bool | None = None, **styles: Any) -> None
This function combines `echo` and `style` into one call.
typer.style
Python Library Documentation: function style in module typer._click.termui
style(text: Any, fg: int | tuple[int, int, int] | str | None = None, bg: int | tuple[int, int, int] | str | None = None, bold: bool | None = None, dim: bool | None = None, underline: bool | None = None, overline: bool | None = None, italic: bool | None = None, blink: bool | None = None, reverse: bool | None = None, strikethrough: bool | None = None, reset: bool = True) -> str
Styles a text with ANSI styles and returns the new string. By
default the styling is self contained which means that at the end
of the string a reset code is issued. This can be prevented by
passing ``reset=False``.
typer.utils
Python Library Documentation: module typer.utils in typer
NAME
typer.utils
CLASSES
builtins.Exception(builtins.BaseException)
AnnotatedParamWithDefaultValueError
DefaultFactoryAndDefaultValueError
MixedAnnotatedAndDefaultStyleError
MultipleTyperAnnotationsError
class AnnotatedParamWithDefaultValueError(builtins.Exception)
| AnnotatedParamWithDefaultValueError(argument_name: str, param_type: type[typer.models.ParameterInfo])
|
| Method resolution order:
| AnnotatedParamWithDefaultValueError
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, argument_name: str, param_type: type[typer.models.ParameterInfo])
| Initialize self. See help(type(self)) for accurate signature.
|
| __str__(self) -> str
| Return str(self).
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {'argument_name': <class 'str'>, 'param_type': type[...
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class DefaultFactoryAndDefaultValueError(builtins.Exception)
| DefaultFactoryAndDefaultValueError(argument_name: str, param_type: type[typer.models.ParameterInfo])
|
| Method resolution order:
| DefaultFactoryAndDefaultValueError
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, argument_name: str, param_type: type[typer.models.ParameterInfo])
| Initialize self. See help(type(self)) for accurate signature.
|
| __str__(self) -> str
| Return str(self).
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {'argument_name': <class 'str'>, 'param_type': type[...
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class MixedAnnotatedAndDefaultStyleError(builtins.Exception)
| MixedAnnotatedAndDefaultStyleError(argument_name: str, annotated_param_type: type[typer.models.ParameterInfo], default_param_type: type[typer.models.ParameterInfo])
|
| Method resolution order:
| MixedAnnotatedAndDefaultStyleError
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, argument_name: str, annotated_param_type: type[typer.models.ParameterInfo], default_param_type: type[typer.models.ParameterInfo])
| Initialize self. See help(type(self)) for accurate signature.
|
| __str__(self) -> str
| Return str(self).
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {'annotated_param_type': type[typer.models.Parameter...
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
class MultipleTyperAnnotationsError(builtins.Exception)
| MultipleTyperAnnotationsError(argument_name: str)
|
| Method resolution order:
| MultipleTyperAnnotationsError
| builtins.Exception
| builtins.BaseException
| builtins.object
|
| Methods defined here:
|
| __init__(self, argument_name: str)
| Initialize self. See help(type(self)) for accurate signature.
|
| __str__(self) -> str
| Return str(self).
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __weakref__
| list of weak references to the object
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| __annotations__ = {'argument_name': <class 'str'>}
|
| ----------------------------------------------------------------------
| Static methods inherited from builtins.Exception:
|
| __new__(*args, **kwargs) class method of builtins.Exception
| Create and return a new object. See help(type) for accurate signature.
|
| ----------------------------------------------------------------------
| Methods inherited from builtins.BaseException:
|
| __getattribute__(self, name, /)
| Return getattr(self, name).
|
| __reduce__(...)
| Helper for pickle.
|
| __repr__(self, /)
| Return repr(self).
|
| __setstate__(...)
|
| add_note(...)
| Exception.add_note(note) --
| add a note to the exception
|
| with_traceback(...)
| Exception.with_traceback(tb) --
| set self.__traceback__ to tb and return self.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from builtins.BaseException:
|
| __cause__
| exception cause
|
| __context__
| exception context
|
| __dict__
|
| __suppress_context__
|
| __traceback__
|
| args
FUNCTIONS
get_params_from_function(func: collections.abc.Callable[..., typing.Any]) -> dict[str, typer.models.ParamMeta]
parse_boolean_env_var(env_var_value: str | None, default: bool) -> bool
FILE
c:\users\youse\appdata\local\programs\python\python312\lib\site-packages\typer\utils.py