Skip to content
Myr

contributing.md

This file

Path

docs/contributing.md

231 lines · 5.8 KiB · Markdown

Last changed by

⬆ Upgrade Isort to version 5.x.x (#137)Sebastián Ramírezbefore adoption89ddc35

History of this file

Take it

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

:memo: Refactor docs with internal links #38Sebastián Ramírezbefore adoption8d6b201

line 1why, one step back
1First, you might want to see the basic ways to [help Typer and get help](help-typer.md){.internal-link target=_blank}.

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 2why, one step back
2

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

line 3why, one step back
3## Developing

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

lines 4–6why, one step back
4
5If 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.6

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

line 7why, one step back
7### Virtual environment with `venv`

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 8why, one step back
8

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

line 9why, one step back
9You can create a virtual environment in a directory using Python's `venv` module:

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 10why, one step back
10

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

lines 11–12why, one step back
11<div class="termy">
12

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

lines 13–15why, one step back
13```console
14$ python -m venv env15```

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 16why, one step back
16

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

lines 17–18why, one step back
17</div>
18

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

lines 19–24why, one step back
19That will create a directory `./env/` with the Python binaries and then you will be able to install packages for that isolated environment.
2021### Activate the environment2223Activate the new environment with:24

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

line 25why, one step back
25=== "Linux, macOS"

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

line 26why, one step back
26

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

line 27why, one step back
27 <div class="termy">

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 28why, one step back
28

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

lines 29–31why, one step back
29 ```console
30 $ source ./env/bin/activate31 ```

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

line 32why, one step back
32

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

line 33why, one step back
33 </div>

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 34why, one step back
34

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

line 35why, one step back
35=== "Windows PowerShell"

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

line 36why, one step back
36

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

line 37why, one step back
37 <div class="termy">

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 38why, one step back
38

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

lines 39–41why, one step back
39 ```console
40 $ .\env\Scripts\Activate.ps141 ```

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

line 42why, one step back
42

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

line 43why, one step back
43 </div>

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 44why, one step back
44

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

line 45why, one step back
45=== "Windows Bash"

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

line 46why, one step back
46

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

line 47why, one step back
47 Or if you use Bash for Windows (e.g. <a href="https://gitforwindows.org/" class="external-link" target="_blank">Git Bash</a>):

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 48why, one step back
48

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

line 49why, one step back
49 <div class="termy">

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

line 50why, one step back
50

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

lines 51–56why, one step back
51 ```console
52 $ source ./env/Scripts/activate53 ```5455 </div>56

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

line 57why, one step back
57To check it worked, use:

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 58why, one step back
58

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

line 59why, one step back
59=== "Linux, macOS, Windows Bash"

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

line 60why, one step back
60

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

line 61why, one step back
61 <div class="termy">

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 62why, one step back
62

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

lines 63–64why, one step back
63 ```console
64 $ which pip

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 65why, one step back
65

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

lines 66–67why, one step back
66 some/directory/typer/env/bin/pip
67 ```

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

line 68why, one step back
68

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

line 69why, one step back
69 </div>

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 70why, one step back
70

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

line 71why, one step back
71=== "Windows PowerShell"

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 72why, one step back
72

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

line 73why, one step back
73 <div class="termy">

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

line 74why, one step back
74

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

lines 75–76why, one step back
75 ```console
76 $ Get-Command pip

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 77why, one step back
77

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

lines 78–79why, one step back
78 some/directory/typer/env/bin/pip
79 ```

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 80why, one step back
80

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

line 81why, one step back
81 </div>

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

line 82why, one step back
82

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

lines 83–84why, one step back
83If it shows the `pip` binary at `env/bin/pip` then it worked. 🎉
84

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

lines 85–86why, one step back
85!!! tip
86 Every time you install a new package with `pip` under that environment, activate the environment again.

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 87why, one step back
87

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

line 88why, one step back
88 This makes sure that if you use a terminal program installed by that package (like `flit`), you use the one from your local environment and not any other that could be installed globally.

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 89why, one step back
89

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

line 90why, one step back
90### Flit

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 91why, one step back
91

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

line 92why, one step back
92**Typer** uses <a href="https://flit.readthedocs.io/en/latest/index.html" class="external-link" target="_blank">Flit</a> to build, package and publish the project.

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 93why, one step back
93

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

line 94why, one step back
94After activating the environment as described above, install `flit`:

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 95why, one step back
95

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

lines 96–97why, one step back
96<div class="termy">
97

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

lines 98–99why, one step back
98```console
99$ pip install flit

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

lines 100–101why, one step back
100
101---> 100%

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

line 102why, one step back
102```

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 103why, one step back
103

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

lines 104–105why, one step back
104</div>
105

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

line 106why, one step back
106Now re-activate the environment to make sure you are using the `flit` you just installed (and not a global one).

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 107why, one step back
107

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

lines 108–109why, one step back
108And now use `flit` to install the development dependencies:
109

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

line 110why, one step back
110=== "Linux, macOS"

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

line 111why, one step back
111

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

line 112why, one step back
112 <div class="termy">

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

line 113why, one step back
113

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

lines 114–115why, one step back
114 ```console
115 $ flit install --deps develop --symlink

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

line 116why, one step back
116

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

lines 117–118why, one step back
117 ---> 100%
118 ```

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

line 119why, one step back
119

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

line 120why, one step back
120 </div>

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

line 121why, one step back
121

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

line 122why, one step back
122=== "Windows"

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

line 123why, one step back
123

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

line 124why, one step back
124 If you are on Windows, use `--pth-file` instead of `--symlink`:

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

line 125why, one step back
125

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

line 126why, one step back
126 <div class="termy">

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

line 127why, one step back
127

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

lines 128–129why, one step back
128 ```console
129 $ flit install --deps develop --pth-file

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

line 130why, one step back
130

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

lines 131–135why, one step back
131 ---> 100%
132 ```133134 </div>135

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

lines 136–141why, one step back
136It will install all the dependencies and your local Typer in your local environment.
137138#### Using your local Typer139140If you create a Python file that imports and uses Typer, and run it with the Python from your local environment, it will use your local Typer source code.141

:heavy_plus_sign: Upgrade Material-Mkdocs (#90)Sebastián Ramírezbefore adoptionce9e08d

line 142why, one step back
142And if you update that local Typer source code, as it is installed with `--symlink` (or `--pth-file` on Windows), when you run that Python file again, it will use the fresh version of Typer you just edited.

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

lines 143–145why, one step back
143
144That way, you don't have to "install" your local version to be able to test every change.145

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

lines 146–149why, one step back
146### Format
147148There is a script that you can run that will format and clean all your code:149

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

lines 150–151why, one step back
150<div class="termy">
151

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

lines 152–153why, one step back
152```console
153$ bash scripts/format.sh

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

lines 154–155why, one step back
154```
155

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

lines 156–157why, one step back
156</div>
157

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

lines 158–159why, one step back
158It will also auto-sort all your imports.
159

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

line 160why, one step back
160For it to sort them correctly, you need to have Typer installed locally in your environment, with the command in the section above using `--symlink` (or `--pth-file` on Windows).

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 161why, one step back
161

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

line 162why, one step back
162### Format imports

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 163why, one step back
163

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

line 164why, one step back
164There is another script that formats all the imports and makes sure you don't have unused imports:

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 165why, one step back
165

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

lines 166–167why, one step back
166<div class="termy">
167

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

lines 168–170why, one step back
168```console
169$ bash scripts/format-imports.sh170```

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 171why, one step back
171

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

lines 172–173why, one step back
172</div>
173

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

lines 174–179why, one step back
174As it runs one command after the other and modifies and reverts many files, it takes a bit longer to run, so it might be easier to use `scripts/format.sh` frequently and `scripts/format-imports.sh` only before committing.
175176## Docs177178The documentation uses <a href="https://www.mkdocs.org/" class="external-link" target="_blank">MkDocs</a>.179

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

lines 180–185why, one step back
180All the documentation is in Markdown format in the directory `./docs`.
181182Many of the tutorials have blocks of code.183184In most of the cases, these blocks of code are actual complete applications that can be run as is.185

⬆ Upgrade Isort to version 5.x.x (#137)Sebastián Ramírezbefore adoption89ddc35

line 186why, one step back
186In fact, those blocks of code are not written inside the Markdown, they are Python files in the `./docs_src/` directory.

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

lines 187–189why, one step back
187
188And those Python files are included/injected in the documentation when generating the site.189

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

line 190why, one step back
190### Docs for tests

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

lines 191–197why, one step back
191
192Most of the tests actually run against the example source files in the documentation.193194This helps making sure that:195196* The documentation is up to date.197* The documentation examples can be run as is.

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

line 198why, one step back
198* Most of the features are covered by the documentation, ensured by test coverage.

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

lines 199–201why, one step back
199
200During local development, there is a script that builds the site and checks for any changes, live-reloading:201

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

lines 202–203why, one step back
202<div class="termy">
203

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

lines 204–205why, one step back
204```console
205$ bash scripts/docs-live.sh

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

lines 206–210why, one step back
206
207<span style="color: green;">[INFO]</span> - Building documentation...208<span style="color: green;">[INFO]</span> - Cleaning site directory209<span style="color: green;">[INFO]</span> - Documentation built in 2.74 seconds210<span style="color: green;">[INFO]</span> - Serving on http://127.0.0.1:8008

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

lines 211–212why, one step back
211```
212

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

lines 213–214why, one step back
213</div>
214

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

line 215why, one step back
215It will serve the documentation on `http://127.0.0.1:8008`.

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

lines 216–218why, one step back
216
217That way, you can edit the documentation/source files and see the changes live.218

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

line 219why, one step back
219## Tests

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 220why, one step back
220

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

line 221why, one step back
221There is a script that you can run locally to test all the code and generate coverage reports in HTML:

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 222why, one step back
222

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

lines 223–224why, one step back
223<div class="termy">
224

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

lines 225–226why, one step back
225```console
226$ bash scripts/test-cov-html.sh

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 227why, one step back
227```

:bug: Fix Bash completion install to .bashrc (#81)Sebastián Ramírezbefore adoptiond90344d

lines 228–229why, one step back
228
229</div>

:memo: Add new issue templatesSebastián Ramírezbefore adoption95803c4

line 230why, one step back
230

:memo: Add contributing guide (#61)Sebastián Ramírezbefore adoptiondd72411

line 231why, one step back
231This command generates a directory `./htmlcov/`, if you open the file `./htmlcov/index.html` in your browser, you can explore interactively the regions of code that are covered by the tests, and notice if there is any region missing.