* Support custom parameter types
While most CLI parameters are strings, ints, etc, we sometimes need custom
types.
Currently typer has no support for it (See #77), and while there are a few hacks, the
likely solution is to add a 'str' argument and parse it inside the main function.
This PR adds support for custom types in 3 different ways:
- Manually specifying a `click_type`
- Manually specifying a `parse` function
- Using a Callable type annotation (It is very common for types to have a string constructor, like `int("1")`)
* Document how to parse custom objects with Typer.
Typer supports parsing of cutom types with:
- A user provided parser class
- A click custom type parser
* 🎨 [pre-commit.ci] Auto format from pre-commit.com hooks
* 📝 Tweak and simplify docs
* ✅ Tweak tests to run scripts and remove pragma: nocover in examples
* 📝 Tweak examples for docs, add types and remove # pragma: nocover
* ♻️ Tweak implementation checking for parser and Click type
---------
Co-authored-by: Paulo Costa <me@paulo.costa.nom.br>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
* 🚚 Move docs src files to root docs_src
* 🚚 Update example includes from root docs_src
* 🚚 Import docs src examples for tests from docs_src
* ⬆️ Upgrade isort and configs
* 🎨 Update format in testing
* 🔧 Update configs with root docs_src
* 🔥 Remove obsolete/unecessary section in contributing guide
* 🎨 Re-format multi-file example
* ⏪ Revert format for multi-file examples
* 🔧 Add isort skips for multi-file examples