Commit graph

74 commits

Author SHA1 Message Date
Sebastián Ramírez
413d585f1f
📝 Remove obsolete references to --install-completion for typer.run() scripts (#595)
📝 Remove obsolete references to --install-completion for typer.run() scripts
2023-05-02 06:15:24 +00:00
Sebastián Ramírez
58522bf0fc
📝 Update docs examples for custom param types using Annotated, fix overloads for typer.Argument (#594)
* 📝 Add source examples for custom parameter types with Annotated

*  Add tests for custom parameters with Annotated

* 📝 Update docs for custom parameters with Annotated

* ♻️ Fix overloads default in Argument after Annotated

*  Fix test for custom param types
2023-05-01 22:02:57 -07:00
Ryan Miller Galamb
458a492ed9
Add support for PEP-593 Annotated for specifying options and arguments (#584)
*  Add support for PEP-593 `Annotated` for specifying options and arguments

Implements #184

* Revert things I did to get a 3.6 virtualenv 😅

A lot of the dev dependency packages weren't installable on 3.6, so I
had to remove them from the pyproject.toml.

This commit adds them back

* Fix mypy/lint errors

* Skip coverage on test lines that shouldn't execute

* Missed a spot

* ♻️ Tweak examples and tests with Annotated, add extra examples and tests

* 🔥 Remove Pydantic-specific logic from _typing.py

* 📝 Update docs to use new Annotated examples

* 📝 Add docs introducing Annotated and previous versions

* 🔧 Add commented out MkDocs config for highlighting docs examples

*  Fix tests for Click 7

---------

Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2023-05-01 21:19:19 -07:00
jmills
46154f2fc9
✏ Fix spelling (shinny -> shiny) (#586)
shinny -> shiny
2023-05-01 04:05:30 -07:00
Sebastián Ramírez
e7c3467a08
📝 Tweak docs, Custom Types path, main page and READAME colors, broken links (#588)
* 📝 Tweak name for Custom Types

* ✏️ Fix broken internal links in CLI Option autocompletion

* 📝 Update main page docs, remove colors as that renders badly in README

* 📝 Update README, sync with index.md, remove colors for GitHub and PyPI
2023-05-01 03:51:35 -07:00
John Purviance
3e37e01979
Add support for custom types and parsers (updates/builds upon PR #443) (#583)
* 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>
2023-05-01 03:03:26 -07:00
Xuan (Sean) Hu
915f89b6f8
✏️ Fix typo in datetime docs (#495) 2022-11-10 22:45:09 +01:00
Oskar Skjærvø Gjølga
9f2d7ebe05
✏️ Add quotes to package name that includes brackets in docs (#475)
Adds quotes to package name with brackets

Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2022-11-06 15:12:01 +00:00
Sebastián Ramírez
36e40806b7
Make typer.run() not add completion scripts by default, it only makes sense in installed apps (#488) 2022-11-05 16:13:37 +00:00
Taranjeet Singh
7c88b2d191
📝 Add note about how subcommands with function names using underscores are converted to dashes (#403)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2022-11-05 15:39:04 +01:00
Fernando Pérez-García
7345567538
📝 Fix typo in docs at docs/tutorial/commands/help.md (#466)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2022-11-05 14:33:39 +00:00
Jakub Jakubec
523a6501bf
✏ Fix link in docs to datetime.strptime() (#464)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2022-11-05 14:32:02 +00:00
Sean McCarthy
aac4ce175c
✏ Update first-steps.md, clarify distinction between parameter and argument (#176)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-07-17 08:15:44 +00:00
Sebastián Ramírez
c750f8206e
Refactor and document handling pretty exceptions (#422)
* ♻️ Rename pretty_errors_ to pretty_exceptions_ to avoid confusion with validation errors

*  Add source examples for pretty_exceptions

* 📝 Add docs for pretty exceptions

* 🔧 Add Exceptions docs to MkDocs

*  Add tests for tutorial about exceptions

*  Update trackeback tests, remove tests covered by tutorial

*  Fix test for module
2022-07-12 21:06:51 +02:00
Sebastián Ramírez
33dcb53129
📝 Add docs for using Rich with Typer (#421) 2022-07-12 18:38:50 +00:00
Sebastián Ramírez
6208b5b208
Richify, add integrations with Rich everywhere (#419) 2022-07-12 16:45:43 +00:00
Sebastián Ramírez
252ed30936
Add pretty error tracebacks for user errors and support for Rich (#412) 2022-07-06 13:32:19 +02:00
Nils K
e56521f7dd
✏ Fix typo, "ASCII codes" to "ANSI escape sequences" (#308)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2022-07-04 11:20:17 +02:00
Christophe Gabard
f4a5ee1bef
📝 Clarify testing documentation about checking stderr (#335)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-07-02 17:36:25 +00:00
graue70
0fe8f472f5
✏ Fix typo in docs for CLI Option autocompletion (#288)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2022-05-12 19:17:49 +00:00
Brian Cohan
7f65b64d8b
🎨 Fix header format for "Standard Input" in docs/tutorial/printing.md (#386)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2022-05-12 19:14:59 +00:00
Kian-Meng Ang
cf7ffa4792
✏ Fix typo in docs/tutorial/terminating.md (#382)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2022-05-12 19:13:47 +00:00
Ryan Streur
d5223d6de4
✏ Fix syntax typo in docs/tutorial/package.md (#333)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2022-05-12 19:13:14 +00:00
Michael Rios
808a15f942
✏ Fix typo, duplicated word in docs/tutorial/options/required.md. (#316)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2022-05-12 19:12:34 +00:00
Roald Storm
a55c9b086b
✏ Fix minor typo in index.md (#274)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2022-05-12 19:07:19 +00:00
Nicoló Lino
2fc51f2c33
✏ Fix double "and" typo in first-steps tutorial (#225)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2022-05-12 19:05:04 +00:00
Diego Piloni
e61aa15596
🎨 Fix format in docs explaining datetime parameter type (#220)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2022-05-12 19:02:22 +00:00
Sebastián Ramírez
a1ee41186f
🔧 Add pre-commit config and formatting (#392) 2022-05-11 19:59:56 -05:00
Sebastián Ramírez
b97298181b
Add support for Click 8 while keeping compatibility with Click 7 (#317) 2021-08-30 09:57:12 +02:00
JAYATI SHRIVASTAVA
39a6552808
📝 Update docs with the new --help argument (#135)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2020-08-16 14:19:40 +02:00
Rupsi Kaushik
32436f0b1a
📝 Add Optional to docs for CLI Arguments and Options with a None default (#131)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2020-08-16 14:01:19 +02:00
Cathal O'Callaghan
26ccd5f6b7
📝 Add date string formats to docs (#122) 2020-08-16 13:27:44 +02:00
Sebastián Ramírez
89ddc35372
⬆ Upgrade Isort to version 5.x.x (#137)
* 🚚 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
2020-07-09 22:09:53 +02:00
Sebastián Ramírez
15380ddc07
Add support for help for CLI arguments (#123)
*  Implement custom TyperCommand and TyperArgument

to support help in CLI Arguments

*  Update data models to store help for CLI Arguments

*  Add help to typer.Argument()

*  Use new TyperCommand and TyperArgument classes by default

to support CLI Arguments with help

*  Update failing test

*  Make showing default values default to true and support arguments hidden from help text

*  Add docs for CLI arguments with defaults, help, and new features

* 📝 Update CLI options with new show_default=True by default

* 📝 Add example of CLI arguments with tuples

* 📝 Update docs with new generated help text for CLI arguments

* 📝 Use Optional for None example in micro-intro to types

*  Add tests for new CLI argument features from docs examples

*  Update tests with new generated help text for CLI arguments

*  Add tests for CLI arguments with tuple defaults

* 🔧 Update MkDocs with new sections

*  make show_envvar default to True

*  Add docs for envvar in CLI arguments

*  Add tests for CLI arguments with env vars from docs

* 🎨 Add format to CLI usage examples in docs

* 🔧 Add section about CLI arguments with env vars to MkDocs

* 📝 Fix link in docs with new structure

* 🎨 Fix format in first-steps
2020-06-24 21:05:21 +02:00
Sebastián Ramírez
fe60816e56
📝 Add docs for __main__.py (#121) 2020-06-23 14:52:19 +02:00
Evan E. Baird
877cf18296
✏ Fix typo in docs (#98)
Co-authored-by: Sebastián Ramírez <tiangolo@gmail.com>
2020-06-22 19:19:46 +02:00
Sebastián Ramírez
57343e1402 🎨 Update format in docs 2020-06-22 19:05:58 +02:00
Evan E. Baird
a3316193be
✏ Fix typos and rewording in docs (#97) 2020-06-22 18:56:53 +02:00
Sebastián Ramírez
372efa998b
📝 Add emphasis note about using typer.echo instead of print (#89) 2020-04-18 12:46:55 +02:00
Sebastián Ramírez
a89fc4ebb7
white_check_mark: Add coverage instructions to tests (#72)
*  Add coverage instructions to tests

* 📝 Update docs note about coverage in features

* 🎨 Fix format

* 🎨 Update testing docs format
2020-03-19 14:44:43 +01:00
Sebastián Ramírez
0830c023b9
📝 Add docs section, build a package from scratch (#71)
* 📝 Add docs section, build a package from scratch

* 📝 Update Package docs

* ✏️ Fix internal links
2020-03-19 13:42:23 +01:00
Sebastián Ramírez
48698ff2ad
📝 Add docs for using Click with Typer (#70)
* 📝 Add docs for using Click with Typer

*  Add tests for integrating Click and Typer
2020-03-19 10:30:42 +01:00
Sebastián Ramírez
5a6379ffc6
Add docs for testing, password, version, context. Extra tests, include callback and autocompletion PR (#68)
*  Implement custom handling for callbacks with types

*  Implement type-based handling for completion functions

*  Add examples for custom completion

* 📝 Add docs for custom autocompletion

*  Add tests for autocompletion

*  Document using the context

*  Add tests for using the context

*  Add tests init for context

* 🔧 Update Mypy config

*  Add extra tests for completion

* ✏️ Fix format, typos, and minor texts

*  Update docs for printing, include stdout, stderr, and stdin

* ✏️ Add references to FastAPI, fix typos

* ✏️ Fix typo in Typer CLI

* 📝 Update docs for version

* 📝 Update docs for callbacks

* 📝 Update references to stdout/stderr in autocompletion

* 📝 Add docs for password in CLI option

* 📝 Add docs and tests for Testing

* 📝 Add new sections to docs

* 🎨 Fix formatting
2020-03-18 21:17:47 +01:00
Sebastián Ramírez
12eef051c8
🐛 Fix docs format with hl_lines (#65) 2020-03-12 10:46:32 +01:00
Sebastián Ramírez
96731c43be
Docs for Typer CLI (#64)
*  Add docs for Typer CLI

* 📝 Update references to Typer CLI in docs

* 🔧 Update tests to check files and linting before tests, to error out early

* 📝 Sync README.md with docs/index.md
2020-03-11 17:16:49 +01:00
Sebastián Ramírez
96b29e9639
Add support for Click 7.1.1 (#60)
* ⬆️ Upgrade required Click to 7.1.1 and pin it to patch versions

as a MINOR version broke compatibility, so I'll have to upgrade manually every time

* 📌 Fix pinning Click to MINOR version

*  Upgrade code to be compatible with latest Click changes

*  Update tests with new format for errors

* 📝 Update docs to keep them in sync with actual output
2020-03-10 18:49:29 +01:00
Sebastián Ramírez
2af83b0be5 📝 Refactor docs with internal links 2020-01-18 19:35:49 +01:00
Sebastián Ramírez
fc902304b6 🎨 Tweak external link format 2020-01-17 16:27:17 +01:00
Sebastián Ramírez
5e063d8446 📝 Update docs for First Steps 2020-01-05 22:23:55 +01:00
Sebastián Ramírez
fb8622b8bb 📝 Add docs and examples for CLI parameters with multiple values 2020-01-05 22:09:41 +01:00