pax_global_header 0000666 0000000 0000000 00000000064 14113116342 0014506 g ustar 00root root 0000000 0000000 52 comment=aab42c985d99b7e997f7e52e83863305b828e5a1 typer-0.4.0/ 0000775 0000000 0000000 00000000000 14113116342 0012652 5 ustar 00root root 0000000 0000000 typer-0.4.0/.coveragerc 0000664 0000000 0000000 00000000102 14113116342 0014764 0 ustar 00root root 0000000 0000000 [run] source = typer tests docs_src parallel = True typer-0.4.0/.github/ 0000775 0000000 0000000 00000000000 14113116342 0014212 5 ustar 00root root 0000000 0000000 typer-0.4.0/.github/FUNDING.yml 0000664 0000000 0000000 00000000023 14113116342 0016022 0 ustar 00root root 0000000 0000000 github: [tiangolo] typer-0.4.0/.github/ISSUE_TEMPLATE/ 0000775 0000000 0000000 00000000000 14113116342 0016375 5 ustar 00root root 0000000 0000000 typer-0.4.0/.github/ISSUE_TEMPLATE/config.yml 0000664 0000000 0000000 00000000221 14113116342 0020360 0 ustar 00root root 0000000 0000000 blank_issues_enabled: false contact_links: - name: Security Contact about: Please report security vulnerabilities to security@tiangolo.com typer-0.4.0/.github/ISSUE_TEMPLATE/feature-request.yml 0000664 0000000 0000000 00000014154 14113116342 0022246 0 ustar 00root root 0000000 0000000 name: Feature Request description: Suggest an idea or ask for a feature that you would like to have in Typer labels: [enhancement] body: - type: markdown attributes: value: | Thanks for your interest in Typer! π Please follow these instructions, fill every question, and do every step. π I'm asking this because answering questions and solving problems in GitHub issues is what consumes most of the time. I end up not being able to add new features, fix bugs, review pull requests, etc. as fast as I wish because I have to spend too much time handling issues. All that, on top of all the incredible help provided by a bunch of community members that give a lot of their time to come here and help others. If more Typer users came to help others like them just a little bit more, it would be much less effort for them (and you and me π ). By asking questions in a structured way (following this) it will be much easier to help you. And there's a high chance that you will find the solution along the way and you won't even have to submit it and wait for an answer. π As there are too many issues with questions, I'll have to close the incomplete ones. That will allow me (and others) to focus on helping people like you that follow the whole process and help us help you. π€ - type: checkboxes id: checks attributes: label: First Check description: Please confirm and check all the following options. options: - label: I added a very descriptive title to this issue. required: true - label: I used the GitHub search to find a similar issue and didn't find it. required: true - label: I searched the Typer documentation, with the integrated search. required: true - label: I already searched in Google "How to X in Typer" and didn't find any information. required: true - label: I already read and followed all the tutorial in the docs and didn't find an answer. required: true - label: I already checked if it is not related to Typer but to [Click](https://github.com/pallets/click). required: true - type: checkboxes id: help attributes: label: Commit to Help description: | After submitting this, I commit to one of: * Read open issues with questions until I find 2 issues where I can help someone and add a comment to help there. * I already hit the "watch" button in this repository to receive notifications and I commit to help at least 2 people that ask questions in the future. * Implement a Pull Request for a confirmed bug. options: - label: I commit to help with one of those options π required: true - type: textarea id: example attributes: label: Example Code description: | Please add a self-contained, [minimal, reproducible, example](https://stackoverflow.com/help/minimal-reproducible-example) with your use case. If I (or someone) can copy it, run it, and see it right away, there's a much higher chance I (or someone) will be able to help you. placeholder: | import typer def main(name: str): typer.echo(f"Hello {name}") if __name__ == "__main__": typer.run(main) render: python validations: required: true - type: textarea id: description attributes: label: Description description: | What is your feature request? Write a short description telling me what you are trying to solve and what you are currently doing. placeholder: | * Create a Typer CLI that says "Hello". * Run it on the command line without a name. * I would like it to use Privacy-Aware Artificial Intelligence based on Block Chain and predict my name without me typing it. validations: required: true - type: textarea id: wanted-solution attributes: label: Wanted Solution description: | Tell me what's the solution you would like. placeholder: | I would like it to say my name without me having to type it. validations: required: true - type: textarea id: wanted-code attributes: label: Wanted Code description: Show me an example of how you would want the code to look like. placeholder: | import typer def main(name: str): typer.guess_name(f"Hello {name}") if __name__ == "__main__": typer.run(main) render: python validations: required: true - type: textarea id: alternatives attributes: label: Alternatives description: | Tell me about alternatives you've considered. placeholder: | To hardcode my name, so that if I don't type it it will be the default. - type: dropdown id: os attributes: label: Operating System description: What operating system are you on? multiple: true options: - Linux - Windows - macOS - Other validations: required: true - type: textarea id: os-details attributes: label: Operating System Details description: You can add more details about your operating system here, in particular if you chose "Other". - type: input id: typer-version attributes: label: Typer Version description: | What Typer version are you using? You can find the Typer version with: ```bash python -c "import typer; print(typer.__version__)" ``` validations: required: true - type: input id: python-version attributes: label: Python Version description: | What Python version are you using? You can find the Python version with: ```bash python --version ``` validations: required: true - type: textarea id: context attributes: label: Additional Context description: Add any additional context information or screenshots you think are useful. typer-0.4.0/.github/ISSUE_TEMPLATE/question.yml 0000664 0000000 0000000 00000012312 14113116342 0020766 0 ustar 00root root 0000000 0000000 name: Question or Problem description: Ask a question or ask about a problem labels: [question] body: - type: markdown attributes: value: | Thanks for your interest in Typer! π Please follow these instructions, fill every question, and do every step. π I'm asking this because answering questions and solving problems in GitHub issues is what consumes most of the time. I end up not being able to add new features, fix bugs, review pull requests, etc. as fast as I wish because I have to spend too much time handling issues. All that, on top of all the incredible help provided by a bunch of community members that give a lot of their time to come here and help others. If more Typer users came to help others like them just a little bit more, it would be much less effort for them (and you and me π ). By asking questions in a structured way (following this) it will be much easier to help you. And there's a high chance that you will find the solution along the way and you won't even have to submit it and wait for an answer. π As there are too many issues with questions, I'll have to close the incomplete ones. That will allow me (and others) to focus on helping people like you that follow the whole process and help us help you. π€ - type: checkboxes id: checks attributes: label: First Check description: Please confirm and check all the following options. options: - label: I added a very descriptive title to this issue. required: true - label: I used the GitHub search to find a similar issue and didn't find it. required: true - label: I searched the Typer documentation, with the integrated search. required: true - label: I already searched in Google "How to X in Typer" and didn't find any information. required: true - label: I already read and followed all the tutorial in the docs and didn't find an answer. required: true - label: I already checked if it is not related to Typer but to [Click](https://github.com/pallets/click). required: true - type: checkboxes id: help attributes: label: Commit to Help description: | After submitting this, I commit to one of: * Read open issues with questions until I find 2 issues where I can help someone and add a comment to help there. * I already hit the "watch" button in this repository to receive notifications and I commit to help at least 2 people that ask questions in the future. * Implement a Pull Request for a confirmed bug. options: - label: I commit to help with one of those options π required: true - type: textarea id: example attributes: label: Example Code description: | Please add a self-contained, [minimal, reproducible, example](https://stackoverflow.com/help/minimal-reproducible-example) with your use case. If I (or someone) can copy it, run it, and see it right away, there's a much higher chance I (or someone) will be able to help you. placeholder: | import typer def main(name: str): typer.echo(f"Hello {name}") if __name__ == "__main__": typer.run(main) render: python validations: required: true - type: textarea id: description attributes: label: Description description: | What is the problem, question, or error? Write a short description telling me what you are doing, what you expect to happen, and what is currently happening. placeholder: | * Create a small Typer script. * Open a Terminal with Ninja-Turtle-Shell. * Trigger autocompletion hitting TAB. * I don't see any completion in the terminal using Ninja-Turtle-Shell. * I expected to see autocompletion there. validations: required: true - type: dropdown id: os attributes: label: Operating System description: What operating system are you on? multiple: true options: - Linux - Windows - macOS - Other validations: required: true - type: textarea id: os-details attributes: label: Operating System Details description: You can add more details about your operating system here, in particular if you chose "Other". - type: input id: typer-version attributes: label: Typer Version description: | What Typer version are you using? You can find the Typer version with: ```bash python -c "import typer; print(typer.__version__)" ``` validations: required: true - type: input id: python-version attributes: label: Python Version description: | What Python version are you using? You can find the Python version with: ```bash python --version ``` validations: required: true - type: textarea id: context attributes: label: Additional Context description: Add any additional context information or screenshots you think are useful. typer-0.4.0/.github/dependabot.yml 0000664 0000000 0000000 00000000152 14113116342 0017040 0 ustar 00root root 0000000 0000000 version: 2 updates: - package-ecosystem: "pip" directory: "/" schedule: interval: "daily" typer-0.4.0/.github/workflows/ 0000775 0000000 0000000 00000000000 14113116342 0016247 5 ustar 00root root 0000000 0000000 typer-0.4.0/.github/workflows/deploy-docs.yml 0000664 0000000 0000000 00000001541 14113116342 0021215 0 ustar 00root root 0000000 0000000 name: Build and Deploy to Netlify on: push: pull_request: types: [opened, synchronize] jobs: build-docs: runs-on: ubuntu-18.04 steps: - uses: actions/checkout@v2 - name: Set up Python uses: actions/setup-python@v1 with: python-version: "3.7" - name: Install Flit run: python3.7 -m pip install flit - name: Install docs extras run: python3.7 -m flit install --extras doc - name: Build MkDocs run: python3.7 -m mkdocs build - name: Deploy to Netlify uses: nwtgck/actions-netlify@v1.0.3 with: publish-dir: './site' production-branch: master github-token: ${{ secrets.GITHUB_TOKEN }} env: NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} typer-0.4.0/.github/workflows/issue-manager.yml 0000664 0000000 0000000 00000001100 14113116342 0021522 0 ustar 00root root 0000000 0000000 name: Issue Manager on: schedule: - cron: "0 0 * * *" issue_comment: types: - created - edited issues: types: - labeled jobs: issue-manager: runs-on: ubuntu-latest steps: - uses: tiangolo/issue-manager@0.2.0 with: token: ${{ secrets.GITHUB_TOKEN }} config: > { "answered": { "message": "Assuming the original issue was solved, it will be automatically closed now. But feel free to add more comments or create new issues." } } typer-0.4.0/.github/workflows/latest-changes.yml 0000664 0000000 0000000 00000002157 14113116342 0021701 0 ustar 00root root 0000000 0000000 name: Latest Changes on: pull_request_target: branches: - master types: - closed workflow_dispatch: inputs: number: description: PR number required: true debug_enabled: description: 'Run the build with tmate debugging enabled (https://github.com/marketplace/actions/debugging-with-tmate)' required: false default: false jobs: latest-changes: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 with: # To allow latest-changes to commit to the main branch token: ${{ secrets.ACTIONS_TOKEN }} # Allow debugging with tmate - name: Setup tmate session uses: mxschmitt/action-tmate@v3 if: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.debug_enabled }} with: limit-access-to-actor: true - uses: docker://tiangolo/latest-changes:0.0.3 with: token: ${{ secrets.GITHUB_TOKEN }} latest_changes_file: docs/release-notes.md latest_changes_header: '## Latest Changes\n\n' debug_logs: true typer-0.4.0/.github/workflows/publish.yml 0000664 0000000 0000000 00000001067 14113116342 0020444 0 ustar 00root root 0000000 0000000 name: Publish on: release: types: - created jobs: publish: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Set up Python uses: actions/setup-python@v1 with: python-version: "3.6" - name: Install Flit run: pip install flit - name: Install Dependencies run: flit install --symlink - name: Publish env: FLIT_USERNAME: ${{ secrets.FLIT_USERNAME }} FLIT_PASSWORD: ${{ secrets.FLIT_PASSWORD }} run: bash scripts/publish.sh typer-0.4.0/.github/workflows/test.yml 0000664 0000000 0000000 00000001627 14113116342 0017757 0 ustar 00root root 0000000 0000000 name: Test on: push: pull_request: types: [opened, synchronize] jobs: test: runs-on: ubuntu-latest strategy: matrix: python-version: [3.6, 3.7, 3.8, 3.9] click-7: [true, false] fail-fast: false steps: - uses: actions/checkout@v2 - name: Set up Python uses: actions/setup-python@v2 with: python-version: ${{ matrix.python-version }} - name: Install Flit run: pip install flit - name: Install Dependencies run: flit install --deps=develop --symlink - name: Install Click 7 if: matrix.click-7 run: pip install "click<8.0.0" - name: Lint if: ${{ matrix.python-version != '3.6' && matrix.click-7 == false }} run: bash scripts/lint.sh - name: Test run: bash scripts/test.sh - name: Upload coverage uses: codecov/codecov-action@v1 typer-0.4.0/.gitignore 0000664 0000000 0000000 00000000165 14113116342 0014644 0 ustar 00root root 0000000 0000000 .vscode *.pyc __pycache__ env3.7 env3.6 env dist .mypy_cache .idea site .coverage htmlcov .pytest_cache coverage.xml typer-0.4.0/CONTRIBUTING.md 0000664 0000000 0000000 00000000175 14113116342 0015106 0 ustar 00root root 0000000 0000000 Please read the [Development - Contributing](https://typer.tiangolo.com/contributing/) guidelines in the documentation site. typer-0.4.0/LICENSE 0000664 0000000 0000000 00000002076 14113116342 0013664 0 ustar 00root root 0000000 0000000 The MIT License (MIT) Copyright (c) 2019 SebastiΓ‘n RamΓrez Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. typer-0.4.0/README.md 0000664 0000000 0000000 00000023016 14113116342 0014133 0 ustar 00root root 0000000 0000000
Typer, build great CLIs. Easy to code. Based on Python type hints.
--- **Documentation**: https://typer.tiangolo.com **Source Code**: https://github.com/tiangolo/typer --- Typer is a library for building CLI applications that users will **love using** and developers will **love creating**. Based on Python 3.6+ type hints. The key features are: * **Intuitive to write**: Great editor support. Completion everywhere. Less time debugging. Designed to be easy to use and learn. Less time reading docs. * **Easy to use**: It's easy to use for the final users. Automatic help, and automatic completion for all shells. * **Short**: Minimize code duplication. Multiple features from each parameter declaration. Fewer bugs. * **Start simple**: The simplest example adds only 2 lines of code to your app: **1 import, 1 function call**. * **Grow large**: Grow in complexity as much as you want, create arbitrarily complex trees of commands and groups of subcommands, with options and arguments. ## FastAPI of CLIscolorama
: and Click will automatically use it to make sure your terminal's colors always work correctly, even in Windows.
* Then you can use any tool you want to output your terminal's colors in all the systems, including the integrated `typer.style()` and `typer.secho()` (provided by Click).
* Or any other tool, e.g. wasabi
, blessings
.
* shellingham
: and Typer will automatically detect the current shell when installing completion.
* With `shellingham` you can just use `--install-completion`.
* Without `shellingham`, you have to pass the name of the shell to install completion for, e.g. `--install-completion bash`.
You can install `typer` with `colorama` and `shellingham` with `pip install typer[all]`.
## Other tools and plug-ins
Click has many plug-ins available that you can use. And there are many tools that help with command line applications that you can use as well, even if they are not related to Typer or Click.
For example:
* click-spinner
: to show the user that you are loading data. A Click plug-in.
* There are several other Click plug-ins at click-contrib that you can explore.
* tabulate
: to automatically display tabular data nicely. Independent of Click or Typer.
* tqdm
: a fast, extensible progress bar, alternative to Typer's own `typer.progressbar()`.
* etc... you can re-use many of the great available tools for building CLIs.
## License
This project is licensed under the terms of the MIT license.
typer-0.4.0/SECURITY.md 0000664 0000000 0000000 00000002210 14113116342 0014436 0 ustar 00root root 0000000 0000000 # Security Policy
Security is very important for Typer and its community. π
Learn more about it below. π
## Versions
The latest versions of Typer are supported.
You are encouraged to [write tests](https://typer.tiangolo.com/tutorial/testing/) for your application and update your Typer version frequently after ensuring that your tests are passing. This way you will benefit from the latest features, bug fixes, and **security fixes**.
## Reporting a Vulnerability
If you think you found a vulnerability, and even if you are not sure about it, please report it right away by sending an email to: security@tiangolo.com. Please try to be as explicit as possible, describing all the steps and example code to reproduce the security issue.
I (the author, [@tiangolo](https://twitter.com/tiangolo)) will review it thoroughly and get back to you.
## Public Discussions
Please restrain from publicly discussing a potential security vulnerability. π
It's better to discuss privately and try to find a solution first, to limit the potential impact as much as possible.
---
Thanks for your help!
The Typer community and I thank you for that. π
typer-0.4.0/docs/ 0000775 0000000 0000000 00000000000 14113116342 0013602 5 ustar 00root root 0000000 0000000 typer-0.4.0/docs/alternatives.md 0000664 0000000 0000000 00000011406 14113116342 0016627 0 ustar 00root root 0000000 0000000 What inspired **Typer**, how it compares to other alternatives and what it learned from them.
## Intro
**Typer** wouldn't exist if not for the previous work of others.
There have been many tools created before that have helped inspire its creation.
## Previous tools
### `argparse`
`argparse` is the Python standard library's module to write CLIs.
It provides a better alternative than reading the *CLI Parameters* as a `list` of `str` and parsing everything by hand.
!!! check "Inspired **Typer** to"
Provide a better development experience than just reading *CLI Parameters* by hand.
### Hug
Hug is a library to create APIs and CLIs, it uses parameters in functions to declare the required data.
It inspired a lot of the ideas in **FastAPI** and **Typer**.
!!! check "Inspired **Typer** to"
Use function parameters to declare *CLI arguments* and *CLI options* as it simplifies a lot the development experience.
### Plac
Plac is another library to create CLIs using parameters in functions, similar to Hug.
!!! check "Inspired **Typer** to"
Provide a simple way to use a function as a command line app, without having to create a complete app, with `typer.run(some_function)`.
### Pydantic
Pydantic is a library to handle data validation using standard modern Python type annotations.
It powers **FastAPI** underneath.
It is not used by **Typer**, but it inspired a lot of the design (through **FastAPI**).
!!! check "Inspired **Typer** to"
Use standard Python type annotations to declare types instead of library-specific types or classes and use them for data validation and documentation.
### Click
Click is one of the most widely used libraries to create CLIs in Python.
It's a very powerful tool and there are many CLIs built with it. It is what powers **Typer** underneath.
It 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).
It 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.
It was built with some great ideas and design using the features available in the language at the time (Python 2.x).
!!! check "**Typer** uses it for"
Everything. π
**Typer** mainly adds a layer on top of Click, making the code simpler and easier to use, with autocompletion everywhere, etc, but providing all the powerful features of Click underneath.
As someone pointed out: "Nice to see it is built on Click but adds the type stuff. Me gusta!"
### `click-completion`
`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.
Previous 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`.
And 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).
!!! check "Inspired **Typer** to"
Provide auto completion for all the shells.
### FastAPI
I created **FastAPI** to provide an easy way to build APIs with autocompletion for everything in the code (and some other features).
**Typer** is the "FastAPI of CLIs".
It uses the same design and usage of FastAPI as much as possible. So, if you have used FastAPI, you know how to use Typer.
typer-0.4.0/docs/contributing.md 0000664 0000000 0000000 00000013534 14113116342 0016641 0 ustar 00root root 0000000 0000000 First, you might want to see the basic ways to [help Typer and get help](help-typer.md){.internal-link target=_blank}.
## Developing
If you already cloned the repository and you know that you need to deep dive in the code, here are some guidelines to set up your environment.
### Virtual environment with `venv`
You can create a virtual environment in a directory using Python's `venv` module: