Skip to content
Myr

alternatives.md

This file

Path

docs/alternatives.md

103 lines · 4.5 KiB · Markdown

Last changed by

➖ Vendor Click and streamline Typer's functionality and code base (#1774)Sofie Van Landeghembefore adoption1829d73

History of this file

Take it

The walk stopped after 200 commits: lines older than 3436fe6 point at it.

⬆ Bump ty from 0.0.23 to 0.0.24 (#1646)dependabot[bot]before adoption3436fe6

lines 1–12why, one step back
1# Alternatives, Inspiration and Comparisons
23What inspired **Typer**, how it compares to other alternatives and what it learned from them.45## Intro67**Typer** wouldn't exist if not for the previous work of others.89There have been many tools created before that have helped inspire its creation.1011## Previous tools12

📝 Update link syntax to minimal Markdown (#1623)Sebastián Ramírezbefore adoption3780a29

line 13why, one step back
13### [`argparse`](https://docs.python.org/3/library/argparse.html)

⬆ Bump ty from 0.0.23 to 0.0.24 (#1646)dependabot[bot]before adoption3436fe6

lines 14–18why, one step back
14
15`argparse` is the Python standard library's module to write CLIs.1617It provides a better alternative than reading the *CLI Parameters* as a `list` of `str` and parsing everything by hand.18

📝 Update and simplify usage of admonitions (#1755)Sebastián Ramírezbefore adoptione3f56c0

line 19why, one step back
19/// tip | Inspired **Typer** to

⬆ Bump ty from 0.0.23 to 0.0.24 (#1646)dependabot[bot]before adoption3436fe6

lines 20–24why, one step back
20
21Provide a better development experience than just reading *CLI Parameters* by hand.2223///24

📝 Update link syntax to minimal Markdown (#1623)Sebastián Ramírezbefore adoption3780a29

line 25why, one step back
25### [Hug](https://hugapi.github.io/hug/)

⬆ Bump ty from 0.0.23 to 0.0.24 (#1646)dependabot[bot]before adoption3436fe6

lines 26–30why, one step back
26
27Hug is a library to create APIs and CLIs, it uses parameters in functions to declare the required data.2829It inspired a lot of the ideas in **FastAPI** and **Typer**.30

📝 Update and simplify usage of admonitions (#1755)Sebastián Ramírezbefore adoptione3f56c0

line 31why, one step back
31/// tip | Inspired **Typer** to

⬆ Bump ty from 0.0.23 to 0.0.24 (#1646)dependabot[bot]before adoption3436fe6

lines 32–36why, one step back
32
33Use function parameters to declare *CLI arguments* and *CLI options* as it simplifies a lot the development experience.3435///36

📝 Update link syntax to minimal Markdown (#1623)Sebastián Ramírezbefore adoption3780a29

line 37why, one step back
37### [Plac](https://plac.readthedocs.io/en/latest/)

⬆ Bump ty from 0.0.23 to 0.0.24 (#1646)dependabot[bot]before adoption3436fe6

lines 38–40why, one step back
38
39Plac is another library to create CLIs using parameters in functions, similar to Hug.40

📝 Update and simplify usage of admonitions (#1755)Sebastián Ramírezbefore adoptione3f56c0

line 41why, one step back
41/// tip | Inspired **Typer** to

⬆ Bump ty from 0.0.23 to 0.0.24 (#1646)dependabot[bot]before adoption3436fe6

lines 42–46why, one step back
42
43Provide a simple way to use a function as a command line app, without having to create a complete app, with `typer.run(some_function)`.4445///46

📝 Update link syntax to minimal Markdown (#1623)Sebastián Ramírezbefore adoption3780a29

line 47why, one step back
47### [Pydantic](https://pydantic-docs.helpmanual.io/)

⬆ Bump ty from 0.0.23 to 0.0.24 (#1646)dependabot[bot]before adoption3436fe6

lines 48–54why, one step back
48
49Pydantic is a library to handle data validation using standard modern Python type annotations.5051It powers **FastAPI** underneath.5253It is not used by **Typer**, but it inspired a lot of the design (through **FastAPI**).54

📝 Update and simplify usage of admonitions (#1755)Sebastián Ramírezbefore adoptione3f56c0

line 55why, one step back
55/// tip | Inspired **Typer** to

⬆ Bump ty from 0.0.23 to 0.0.24 (#1646)dependabot[bot]before adoption3436fe6

lines 56–60why, one step back
56
57Use standard Python type annotations to declare types instead of library-specific types or classes and use them for data validation and documentation.5859///60

📝 Update link syntax to minimal Markdown (#1623)Sebastián Ramírezbefore adoption3780a29

line 61why, one step back
61### [Click](https://click.palletsprojects.com)

⬆ Bump ty from 0.0.23 to 0.0.24 (#1646)dependabot[bot]before adoption3436fe6

lines 62–72why, one step back
62
63Click is one of the most widely used libraries to create CLIs in Python.6465It's a very powerful tool and there are many CLIs built with it. It is what powers **Typer** underneath.6667It also uses functions with parameters for *CLI arguments* and *CLI options*, but the declaration of the specific *CLI arguments*, *CLI options*, types, etc, is done in decorators on top of the function. This requires some code repetition (e.g. a *CLI Option* name `--verbose` and a variable name `verbose`) and synchronization between two places related to the same information (the decorator and the parameter function).6869It uses decorators on top of functions to modify the actual value of those functions, converting them to instances of a specific class. This is a clever trick, but code editors can't provide great support for autocompletion that way.7071It was built with some great ideas and design using the features available in the language at the time (Python 2.x).72

➖ Vendor Click and streamline Typer's functionality and code base (#1774)Sofie Van Landeghembefore adoption1829d73

line 73why, one step back
73/// tip | **Typer** builds on top of Click functionality

⬆ Bump ty from 0.0.23 to 0.0.24 (#1646)dependabot[bot]before adoption3436fe6

line 74why, one step back
74

➖ Vendor Click and streamline Typer's functionality and code base (#1774)Sofie Van Landeghembefore adoption1829d73

line 75why, one step back
75It has <abbr title="included Click's source code internally, instead of installing it as a third party package">vendored</abbr> Click version 8.3.1 and adds a layer on top of it.

⬆ Bump ty from 0.0.23 to 0.0.24 (#1646)dependabot[bot]before adoption3436fe6

line 76why, one step back
76

➖ Vendor Click and streamline Typer's functionality and code base (#1774)Sofie Van Landeghembefore adoption1829d73

line 77why, one step back
77Typer aims to make the code simpler and easier to use, with autocompletion everywhere, etc, while still providing many of the powerful features of Click underneath.

⬆ Bump ty from 0.0.23 to 0.0.24 (#1646)dependabot[bot]before adoption3436fe6

line 78why, one step back
78

📝 Update link syntax to minimal Markdown (#1623)Sebastián Ramírezbefore adoption3780a29

line 79why, one step back
79As someone pointed out: <em>["Nice to see it is built on Click but adds the type stuff. Me gusta!"](https://twitter.com/fishnets88/status/1210126833745838080)</em>

⬆ Bump ty from 0.0.23 to 0.0.24 (#1646)dependabot[bot]before adoption3436fe6

lines 80–82why, one step back
80
81///82

📝 Update link syntax to minimal Markdown (#1623)Sebastián Ramírezbefore adoption3780a29

line 83why, one step back
83### [`click-completion`](https://github.com/click-contrib/click-completion)

⬆ Bump ty from 0.0.23 to 0.0.24 (#1646)dependabot[bot]before adoption3436fe6

lines 84–90why, one step back
84
85`click-completion` is a plug-in for Click. It was created to extend completion support for shells when Click only had support for Bash completion.8687Previous versions of **Typer** had deep integrations with `click-completion` and used it as an optional dependency. But now all the completion logic is implemented internally in **Typer** itself, the internal logic was heavily inspired and using some parts of `click-completion`.8889And now **Typer** improved it to have new features, tests, some bug fixes (for issues in plain `click-completion` and Click), and better support for shells, including modern versions of PowerShell (e.g. the default versions that come with Windows 10).90

📝 Update and simplify usage of admonitions (#1755)Sebastián Ramírezbefore adoptione3f56c0

line 91why, one step back
91/// tip | Inspired **Typer** to

⬆ Bump ty from 0.0.23 to 0.0.24 (#1646)dependabot[bot]before adoption3436fe6

lines 92–96why, one step back
92
93Provide auto completion for all the shells.9495///96

📝 Update link syntax to minimal Markdown (#1623)Sebastián Ramírezbefore adoption3780a29

line 97why, one step back
97### [FastAPI](https://fastapi.tiangolo.com/)

⬆ Bump ty from 0.0.23 to 0.0.24 (#1646)dependabot[bot]before adoption3436fe6

line 98why, one step back
98

📝 Update link syntax to minimal Markdown (#1623)Sebastián Ramírezbefore adoption3780a29

line 99why, one step back
99I created **FastAPI** to provide an easy way to build APIs with autocompletion for everything in the code (and some other [features](https://fastapi.tiangolo.com/features/)).

⬆ Bump ty from 0.0.23 to 0.0.24 (#1646)dependabot[bot]before adoption3436fe6

lines 100–103why, one step back
100
101**Typer** is the "FastAPI of CLIs".102103It uses the same design and usage of FastAPI as much as possible. So, if you have used FastAPI, you know how to use Typer.