docs/release-notes.md
target=_blank and CSS automatically in JS and CSS. PR #1622 by @tiangolo.install.md file. PR #1606 by @Johandielangman.ty to exit with error code on warnings. PR #1657 by @svlandeg.typer-slim, nor typer-cli. PR #1569 by @tiangolo.typer-slim and typer-cli, no more versions will be released, use only typer. PR #1568 by @tiangolo.typer-slim a shallow wrapper around typer, always requiring rich and shellingham. PR #1522 by @svlandeg.--help text alignment when using typer.style() in option descriptions. PR #1356 by @mahimairaja.uv instead of poetry. PR #1474 by @svlandeg.management-tasks.md to be in line with management-tasks.md in FastAPI repo. PR #1519 by @YuriiMotov.custom.js. PR #1488 by @alejsdev.ty to the CI lint check. PR #1477 by @svlandeg.Lint step in test.yml workflow. PR #1511 by @YuriiMotov.mod fixture. PR #1506 by @svlandeg.uv.lock gets the internal label. PR #1497 by @svlandeg.prek. PR #1466 by @YuriiMotov.ruff dependency to shared requirements-docs-tests.txt to fix "Build docs" workflow in CI. PR #1458 by @YuriiMotov.TYPER_STANDARD_TRACEBACK. PR #1299 by @colin-nolan.options_metavar is passed through correctly. PR #816 by @gar1t.metavar is set. PR #1409 by @svlandeg.rich_markup_mode is interpreted correctly. PR #1304 by @svlandeg.shellingham. PR #1347 by @nathanjmcdougall.printing.md. PR #1365 by @svlandeg.master. PR #1414 by @svlandeg.Typer() more prominently. PR #1418 by @svlandeg.--showlocals to test.sh. PR #1169 by @rickwporter.mod.app . PR #1427 by @svlandeg.latest-changes GitHub Action and pin actions/checkout@v5. PR #1424 by @tiangolo.waiting label in issue-manager. PR #1378 by @YuriiMotov.Note: this is the last version to support Python 3.7, going forward Typer will require Python 3.8+. And soon Python 3.8 will also be dropped as Python 3.8 reached it's end of life almost a year ago.
Optional[list] values work correctly with callbacks. PR #1018 by @solesensei.typing.Literal to define a set of predefined choices. PR #429 by @blackary.None in CliRunner.invoke. PR #1303 by @arjenzorgdoc.rich. PR #1297 by @nathanjmcdougall.value_is_missing function. PR #1333 by @svlandeg.rich.markup is imported when rendering help text. PR #1290 by @g-arjones.default: None in the help section when using Rich. PR #1120 by @mattmess1221.environment-variables.md. PR #1277 by @neirzhei.count parameter in the documentation. PR #1201 by @PokkaKiyo.When using the CliRunner with Click < 8.2, to be able to access the stderr output, you needed to set the mix_stderr parameter to True. Since Click 8.2 (and Typer 0.160 this release supporting it) this is no longer necessary, so this parameter has been removed.
Path arguments/options. PR #1138 by @svlandeg.rich_markup_mode . PR #964 by @svlandeg.typing_extensions in newer Python versions. PR #1048 by @horta.Annotated. PR #983 by @gkeuccsr.mix_stderr when accessing the output of stderr in tests. PR #1045 by @mrchrisadams.shell_complete and continue to use autocompletion for CLI parameters. PR #974 by @svlandeg.add_typer based on the group's callback function name. PR #1052 by @patrick91.Before, it was supported to infer the name of a command group from the callback function name in the sub-app, so, in this code:
import typer
app = typer.Typer()
users_app = typer.Typer()
app.add_typer(users_app)
@users_app.callback()
def users(): # <-- This was the inferred command group name
"""
Manage users in the app.
"""
@users_app.command()
def create(name: str):
print(f"Creating user: {name}")
...the command group would be named users, based on the name of the function def users().
Now you need to set it explicitly:
import typer
app = typer.Typer()
users_app = typer.Typer()
app.add_typer(users_app, name="users") # <-- Explicitly set the command group name
@users_app.callback()
def users():
"""
Manage users in the app.
"""
@users_app.command()
def create(name: str):
print(f"Creating user: {name}")
Updated docs SubCommand Name and Help.
Note: this change will enable important features in the next release. 🤩
KeyboardInterrupt separately from other exceptions. PR #1039 by @patrick91.launch to not print anything when opening urls. PR #1035 by @patrick91.is_flag and flag_value parameters. PR #987 by @svlandeg._typing.py file. PR #805 by @ivantodorovich._make_rich_text. PR #959 by @svlandeg._TYPER_RUN_INSTALL_COMPLETION_TESTS is set. PR #995 by @svlandeg._make_rich_text method. PR #972 by @svlandeg.labeler.yml. PR #1014 by @tiangolo.issue-manager.yml. PR #978 by @tiangolo.include-hidden-files to True when using the upload-artifact GH action. PR #967 by @svlandeg.latest-changes GitHub Action. PR #955 by @tiangolo.rich_markup_mode=None disables Rich formatting. PR #859 by @svlandeg.main.py in tutorial on CLI option names. PR #868 by @fsramalho.docs/virtual-environments.md. PR #952 by @tiangolo.docs/contributing.md. PR #947 by @tiangolo.needs_bash test fixture. PR #888 by @svlandeg.UnionType (e.g. str | None) with Python 3.11. PR #548 by @jonaslb.zsh autocompletion installation. PR #237 by @alexjurkiewicz.Annotated with future annotations in Python 3.7+. PR #814 by @ivantodorovich.shell_complete not working for Arguments. PR #737 by @bckohan.pyproject.toml, show up in PyPI. PR #931 by @tiangolo.__init__.py files to fix test suite. PR #809 by @svlandeg.Optional[Tuple] and default value None. PR #757 by @Asthestarsfalll.Now you don't need to install typer[all]. When you install typer it comes with the default optional dependencies and the typer command.
If you don't want the extra optional dependencies (rich and shellingham), you can install typer-slim instead.
You can also install typer-slim[standard], which includes the default optional dependencies, but not the typer command.
Now the package typer-cli doesn't add anything on top of what typer has, it only depends on typer, and is there only for backwards compatibility, so that projects that depend on typer-cli can get the latest features of the typer command while they upgrade their dependencies to require typer directly.
typer <0.12.0 to typer >=0.12.0, make typer independent of typer-slim, include typer command in typer package. PR #791 by @tiangolo.This fixes a problem that would break the typer installation directory when upgrading from typer <0.12.0 to typer >=0.12.0, see issue #790.
By installing the latest version (0.12.1) it fixes it, for any previous version, even if the installation directory was already broken by the previous upgrade.
In version 0.12.0, the typer package depends on typer-slim[standard] which includes the default dependencies (instead of typer[all]) and typer-cli (that provides the typer command).
If you don't want the extra optional dependencies (rich and shellingham), you can install typer-slim instead.
You can also install typer-slim[standard], which includes the default optional dependencies, but not the typer command.
In version 0.12.0 the typer-cli package only provides the typer command, but the code is still in the main code, so even without installing typer-cli, it can be called with python -m typer.
This approach of having typer depend on typer-slim[standard] instead of including the whole code and dependencies itself caused an issue when upgrading from typer <0.12.0 to typer >=0.12.0, see issue #790. This is fixed in version 0.12.1.
typer-slim package without extras, make typer include typer-slim[default] and integrate Typer CLI (typer command) into Typer. PR #780 by @tiangolo.test, doc, dev. PR #764 by @tiangolo.None for CLI Parameters when the type is list | None and the default value is None. PR #664 by @theowisear.from __future__ import annotations). PR #721 by @heckad.show_default parameter and update docs for setting a "Custom default string". PR #501 by @plannigan.default_factory in Argument overloads. PR #750 by @m9810223.📝 Remove obsolete references to --install-completion for typer.run() scripts. PR #595 by @tiangolo.
📝 Update docs example for a Typer/Click group to make new subcommands explicit. PR #755 by @svlandeg.
📝 Update docs for building a package, file structure example. PR #683 by @davidbgk.
📝 Update link in docs to the newest stable version of click. PR #675 by @javier171188.
🔧 Add CITATION.cff file for academic citations. PR #681 by @tiangolo.
✏ Fix typo in docs/tutorial/exceptions.md. PR #702 by @menzenski.
✏ Fix typo in docs/tutorial/options/name.md. PR #725 by @bwagner.
✏ Fix typo in docs/tutorial/arguments/optional.md. PR #602 by @tadasgedgaudas.
Annotated for specifying options and arguments. Initial PR #584 by @ryangalamb.
... to mark a CLI Argument or CLI Option as required.Annotated for typer.Option() and typer.Argument().Annotated.Annotated, fix overloads for typer.Argument. PR #594 by @tiangolo.exclude_lines to coverage configuration. PR #585 by @dmontagu.sys.executable to run subprocesses, needed by OpenSUSE. PR #408 by @theMarix.PYTHONPATH is set properly when testing the tutorial scripts. PR #407 by @theMarix.typer.run() not add completion scripts by default, it only makes sense in installed apps. Also update docs for handling autocompletion in CLI options. PR #488 by @tiangolo.typer.run(). PR #284 by @yassu.get_group. PR #430 by @tiangolo.docs/tutorial/commands/help.md. PR #466 by @fepegar.datetime.strptime(). PR #464 by @Kobu.first-steps.md, clarify distinction between parameter and argument. PR #176 by @mccarthysean.FORCE_TERMINAL with colors 2. PR #424 by @tiangolo.FORCE_TERMINAL with colors. PR #423 by @tiangolo.This release adds deep integrations with Rich. ✨
rich is an optional dependency, you can install it directly or it will be included when you install with:
$ pip install "typer[all]"
If Rich is available, it will be used to show the content from --help options, validation errors, and even errors in your app (exception tracebacks).
There are new options to group commands, CLI arguments, and CLI options, support for Rich Console Markup, and more! 🎉
print() instead of typer.echo() in the docs, to simplify the concepts and avoid confusions. New docs: Printing and Colors - typer Echo.help, and epilog with the new parameter typer.Typer(rich_markup_mode="markdown"), new docs: Commands - Command Help - Rich Markdown and Markup.help, and epilog with the new parameter typer.Typer(rich_markup_mode="rich"), new docs: Commands - Command Help - Rich Markdown and Markup.epilog, with support for Rich Markdown and Console Markup, new docs: Commands - Command Help - Epilog.List and Tuple and their internal types. PR #143 by @hellowhistler.context_settings for a Typer app with a single command. PR #210 by @daddycocoaman.stderr. PR #335 by @cgabard.docs/tutorial/printing.md. PR #386 by @briancohan.docs/tutorial/terminating.md. PR #382 by @kianmeng.docs/tutorial/package.md. PR #333 by @ryanstreur.docs/tutorial/options/required.md.. PR #316 by @michaelriri.index.md. PR #274 by @RmStorm.datetime parameter type. PR #220 by @DiegoPiloni.get_terminal_size for Click 8.1.0 support and upgrade Black to fix CI. PR #380 by @tiangolo based on original PR #375 by @madkinsz.mypy --strict. Original PR #147 by @victorphoenix3.--help showing default values. PR #135 by @victorphoenix3.Optional to docs for CLI Arguments and Options with a default of None. PR #131 by @rkbeatss.help parameter in CLI arguments:
help in CLI arguments is not supported by Click, there are two new internal classes (Click sub-classes) to support it:
typer.core.TyperArgumenttyper.core.TyperCommandArguments for CLI arguments, showing defaults, required arguments, etc.hidden parameter.show_default is True by default.show_envvar is True by default.python -m some_package using __main__.py: Building a Package: Support python -m. PR #121.*args and **kwargs when calling the Typer app, just like in Click. PR #120 by @teymour-aldridge.typer.echo() and print() for colors in Windows. PR #89.~/.bashrc and update Windows development docs. PR #81.click-completion (with its sub-dependencies, like Jinja).shellingham to auto detect shell to install (it was used by click-completion).shellingham is not installed/added as a dependency, --install-completion and --show-completion take a value with the name of the shell.pwsh (PowerShell Core).
mypy to type check applications built with Typer. PR #58.typer.Argument() to remove invalid positional param_decls. PR #19.typer.Typer() parameters. PR #14.Exit exception. PR #11.--install-completion and --show-completion in docs. PR #9.--install-completion and --show-completion. PR #7.