Skip to content
Myr

contributing.md

This file

Path

docs/contributing.md

148 lines · 3.3 KiB · Markdown

Last changed by

📝 Fix formatting for help link to support GitHub-specific overview edge-case (#1826)Philipp Stahlbergbefore adoptionba3dc50

History of this file

Take it

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

⬆ Bump mypy from 1.20.0 to 1.20.1 (#1689)dependabot[bot]before adoptionf6d4c10

lines 1–2why, one step back
1# Development - Contributing
2

📝 Fix formatting for help link to support GitHub-specific overview edge-case (#1826)Philipp Stahlbergbefore adoptionba3dc50

line 3why, one step back
3First, you might want to see the basic ways to [help Typer and get help](https://typer.tiangolo.com/help-typer/).

⬆ Bump mypy from 1.20.0 to 1.20.1 (#1689)dependabot[bot]before adoptionf6d4c10

lines 4–6why, one step back
4
5## Developing6

📝 Update contributing docs, reference central docs (#1777)Sebastián Ramírezbefore adoption90111e8

line 7why, one step back
7To contribute code to the project, please follow the guidelines in [tiangolo.com - Contributing](https://tiangolo.com/open-source/contributing/).

⬆ Bump mypy from 1.20.0 to 1.20.1 (#1689)dependabot[bot]before adoptionf6d4c10

lines 8–61why, one step back
8
9## Completion1011To try and test the completion for different shells and check that they are working you can use a Docker container.1213There's a `Dockerfile` and a Docker Compose file `compose.yaml` at `./scripts/docker/`.1415It has installed `bash`, `zsh`, `fish`, and `pwsh` (PowerShell for Linux).1617It also has installed `nano` and `vim`, so that you can check the modified configuration files for the shells (for example `.bashrc`, `.zshrc`, etc).1819It also has `uv` installed, so you can install the dependencies and the project quickly.2021The Docker Compose file mounts the main directory as `/code` inside the container, so you can change things and try them out.2223Go to the `./scripts/docker/` directory:2425```console26$ cd scripts/docker/27```2829Then run an interactive session with `bash` inside the container:3031```console32$ docker compose run typer bash3334root@79c4b9b70cbe:/code#35```3637Then inside the container, you can install `typer` with:3839```console40$ uv pip install -r requirements.txt41```4243Then, you can start the shell you want to use, the one where you want to try out completion:4445* `bash`46* `fish`47* `pwsh`48* `zsh`4950For example:5152```console53$ zsh54```5556Then install `typer` completion:5758```console59$ typer --install-completion60```61

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

line 62why, one step back
62/// note

⬆ Bump mypy from 1.20.0 to 1.20.1 (#1689)dependabot[bot]before adoptionf6d4c10

lines 63–148why, one step back
63
64In `pwsh` you will probably get a warning of:6566```plaintext67Set-ExecutionPolicy: Operation is not supported on this platform.68```6970this is because that configuration is only available in Windows (and needed there), not in PowerShell for Linux.7172///7374For completion to take effect, you need to restart the shell. So, exit the current shell:7576```console77$ exit78```7980and start a new shell (for the same shell you installed completion in) again. For example:8182```console83$ zsh84```8586Now you could create a demo file on the same Typer directory in your editor, for example `demo.py`:8788```python89import typer9091app = typer.Typer()929394@app.command()95def hello():96 print("Hello")979899@app.command()100def goodbye():101 print("Goodbye")102103104if __name__ == "__main__":105 app()106```107108Because the directory is mounted as a volume, you will be able to access the file from inside the container.109110So, you can try running it with the `typer` command, that will use the installed shell completion:111112```console113$ typer demo.py <TAB>114```115116And you should see the completion working:117118```console119run -- Run the provided Typer app.120utils -- Extra utility commands for Typer apps.121```122123And the same for the commands in your `demo.py` file:124125```console126$ typer demo.py run <TAB>127128hello goodbye129```130131You can also check the configuration file using `nano` or `vim`, for example:132133```bash134nano ~/.zshrc135```136137It will show some content like:138139```bash140fpath+=~/.zfunc; autoload -Uz compinit; compinit141142143zstyle ':completion:*' menu select144```145146If you exit from the container, you can start a new one, you will probably have to install the packages again and install completion again.147148Using this process, you can test all the shells, with their completions, being able to start from scratch quickly in a fresh container, and verifying that everything works as expected.