Skip to content

Commit 28035df

Browse files
authored
➖ Drop support for Python 3.9 (#1546)
1 parent 2bf1e4d commit 28035df

467 files changed

Lines changed: 631 additions & 1766 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@ jobs:
2424
uv-resolution:
2525
- highest
2626
include:
27-
- os: windows-latest
28-
python-version: "3.9"
29-
uv-resolution: highest
3027
- os: ubuntu-latest
3128
python-version: "3.10"
3229
uv-resolution: lowest-direct

docs/tutorial/app-dir.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
You can get the application directory where you can, for example, save configuration files with `typer.get_app_dir()`:
44

5-
{* docs_src/app_dir/tutorial001_py39.py hl[12] *}
5+
{* docs_src/app_dir/tutorial001_py310.py hl[12] *}
66

77
It will give you a directory for storing configurations appropriate for your CLI program for the current user in each operating system.
88

docs/tutorial/arguments/default.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ That way the *CLI argument* will be optional *and also* have a default value.
88

99
We can also use `typer.Argument()` to make a *CLI argument* have a default value other than `None`:
1010

11-
{* docs_src/arguments/default/tutorial001_an_py39.py hl[9] *}
11+
{* docs_src/arguments/default/tutorial001_an_py310.py hl[9] *}
1212

1313
/// tip
1414

@@ -52,7 +52,7 @@ Hello Camila
5252

5353
And we can even make the default value be dynamically generated by passing a function as the `default_factory` argument:
5454

55-
{* docs_src/arguments/default/tutorial002_an_py39.py hl[9:10,14] *}
55+
{* docs_src/arguments/default/tutorial002_an_py310.py hl[9:10,14] *}
5656

5757
In this case, we created the function `get_name` that will just return a random `str` each time.
5858

docs/tutorial/arguments/envvar.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ You can learn more about environment variables in the [Environment Variables](..
1010

1111
To do that, use the `envvar` parameter for `typer.Argument()`:
1212

13-
{* docs_src/arguments/envvar/tutorial001_an_py39.py hl[9] *}
13+
{* docs_src/arguments/envvar/tutorial001_an_py310.py hl[9] *}
1414

1515
In this case, the *CLI argument* `name` will have a default value of `"World"`, but will also read any value passed to the environment variable `AWESOME_NAME` if no value is provided in the command line:
1616

@@ -55,7 +55,7 @@ Hello Mr. Czernobog
5555

5656
You are not restricted to a single environment variable, you can declare a list of environment variables that could be used to get a value if it was not passed in the command line:
5757

58-
{* docs_src/arguments/envvar/tutorial002_an_py39.py hl[10] *}
58+
{* docs_src/arguments/envvar/tutorial002_an_py310.py hl[10] *}
5959

6060
Check it:
6161

@@ -90,7 +90,7 @@ Hello Mr. Anubis
9090

9191
By default, environment variables used will be shown in the help text, but you can disable them with `show_envvar=False`:
9292

93-
{* docs_src/arguments/envvar/tutorial003_an_py39.py hl[11] *}
93+
{* docs_src/arguments/envvar/tutorial003_an_py310.py hl[11] *}
9494

9595
Check it:
9696

docs/tutorial/arguments/help.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ In the *First Steps* section you saw how to add help for a CLI app/command by ad
44

55
Here's how that last example looked like:
66

7-
{* docs_src/first_steps/tutorial006_py39.py *}
7+
{* docs_src/first_steps/tutorial006_py310.py *}
88

99
Now that you also know how to use `typer.Argument()`, let's use it to add documentation specific for a *CLI argument*.
1010

1111
## Add a `help` text for a *CLI argument*
1212

1313
You can use the `help` parameter to add a help text for a *CLI argument*:
1414

15-
{* docs_src/arguments/help/tutorial001_an_py39.py hl[9] *}
15+
{* docs_src/arguments/help/tutorial001_an_py310.py hl[9] *}
1616

1717
And it will be used in the automatic `--help` option:
1818

@@ -37,7 +37,7 @@ Options:
3737

3838
And of course, you can also combine that `help` with the <abbr title="a multi-line string as the first expression inside a function (not assigned to any variable) used for documentation">docstring</abbr>:
3939

40-
{* docs_src/arguments/help/tutorial002_an_py39.py hl[9:12] *}
40+
{* docs_src/arguments/help/tutorial002_an_py310.py hl[9:12] *}
4141

4242
And the `--help` option will combine all the information:
4343

@@ -64,7 +64,7 @@ Options:
6464

6565
If you have a *CLI argument* with a default value, like `"World"`:
6666

67-
{* docs_src/arguments/help/tutorial003_an_py39.py hl[9] *}
67+
{* docs_src/arguments/help/tutorial003_an_py310.py hl[9] *}
6868

6969
It will show that default value in the help text:
7070

@@ -89,7 +89,7 @@ Options:
8989

9090
But you can disable that if you want to, with `show_default=False`:
9191

92-
{* docs_src/arguments/help/tutorial004_an_py39.py hl[11] *}
92+
{* docs_src/arguments/help/tutorial004_an_py310.py hl[11] *}
9393

9494
And then it won't show the default value:
9595

@@ -116,7 +116,7 @@ Options:
116116

117117
You can use the same `show_default` to pass a custom string (instead of a `bool`) to customize the default value to be shown in the help text:
118118

119-
{* docs_src/arguments/help/tutorial005_an_py39.py hl[13] *}
119+
{* docs_src/arguments/help/tutorial005_an_py310.py hl[13] *}
120120

121121
And it will be used in the help text:
122122

@@ -161,7 +161,7 @@ But you can customize it with the `metavar` parameter for `typer.Argument()`.
161161

162162
For example, let's say you don't want to have the default of `NAME`, you want to have `username`, in lowercase, and you really want ✨ emojis ✨ everywhere:
163163

164-
{* docs_src/arguments/help/tutorial006_an_py39.py hl[9] *}
164+
{* docs_src/arguments/help/tutorial006_an_py310.py hl[9] *}
165165

166166
Now the generated help text will have `✨username✨` instead of `NAME`:
167167

@@ -187,7 +187,7 @@ You might want to show the help information for *CLI arguments* in different pan
187187

188188
If you have installed Rich as described in the docs for [Printing and Colors](../printing.md){.internal-link target=_blank}, you can set the `rich_help_panel` parameter to the name of the panel where you want this *CLI argument* to be shown:
189189

190-
{* docs_src/arguments/help/tutorial007_an_py39.py hl[12,16] *}
190+
{* docs_src/arguments/help/tutorial007_an_py310.py hl[12,16] *}
191191

192192
Then, if you check the `--help` option, you will see a default panel named "`Arguments`" for the *CLI arguments* that don't have a custom `rich_help_panel`.
193193

@@ -230,7 +230,7 @@ If you want, you can make a *CLI argument* **not** show up in the `Arguments` se
230230

231231
You will probably not want to do this normally, but it's possible:
232232

233-
{* docs_src/arguments/help/tutorial008_an_py39.py hl[9] *}
233+
{* docs_src/arguments/help/tutorial008_an_py310.py hl[9] *}
234234

235235
Check it:
236236

docs/tutorial/arguments/optional.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ __init__.py test_tutorial
3535

3636
In the [First Steps](../first-steps.md#add-a-cli-argument){.internal-link target=_blank} you saw how to add a *CLI argument*:
3737

38-
{* docs_src/first_steps/tutorial002_py39.py hl[4] *}
38+
{* docs_src/first_steps/tutorial002_py310.py hl[4] *}
3939

4040
Now let's see an alternative way to create the same *CLI argument*:
4141

42-
{* docs_src/arguments/optional/tutorial000_an_py39.py hl[6] *}
42+
{* docs_src/arguments/optional/tutorial000_an_py310.py hl[6] *}
4343

4444
Or, using an explicit `Typer()` instance creation:
4545

46-
{* docs_src/arguments/optional/tutorial001_an_py39.py hl[9] *}
46+
{* docs_src/arguments/optional/tutorial001_an_py310.py hl[9] *}
4747

4848
/// info
4949

@@ -114,7 +114,7 @@ Now, finally what we came for, an optional *CLI argument*.
114114

115115
To make a *CLI argument* optional, use `typer.Argument()` and make sure to provide a "default" value, for example `"World"`:
116116

117-
{* docs_src/arguments/optional/tutorial002_an_py39.py hl[9] *}
117+
{* docs_src/arguments/optional/tutorial002_an_py310.py hl[9] *}
118118

119119
Now we have:
120120

@@ -181,7 +181,7 @@ Notice that "`Camila`" here is an optional *CLI argument*, not a *CLI option*, b
181181

182182
Instead of using `Annotated`, you can use `typer.Argument()` as the default value:
183183

184-
{* docs_src/arguments/optional/tutorial001_py39.py hl[7] *}
184+
{* docs_src/arguments/optional/tutorial001_py310.py hl[7] *}
185185

186186
/// tip
187187

@@ -215,11 +215,11 @@ If you hadn't seen that `...` before: it is a special single value, it is <a hre
215215

216216
///
217217

218-
{* docs_src/arguments/optional/tutorial003_py39.py hl[7] *}
218+
{* docs_src/arguments/optional/tutorial003_py310.py hl[7] *}
219219

220220
And the same way, you can make it optional by passing a different `default` value, for example `"World"`:
221221

222-
{* docs_src/arguments/optional/tutorial002_py39.py hl[7] *}
222+
{* docs_src/arguments/optional/tutorial002_py310.py hl[7] *}
223223

224224
Because the first parameter passed to `typer.Argument(default="World")` (the new "default" value) is `"World"`, **Typer** knows that this is an **optional** *CLI argument*, if no value is provided when calling it in the command line, it will have that default value of `"World"`.
225225

docs/tutorial/commands/arguments.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
The same way as with a CLI application with a single command, subcommands (or just "commands") can also have their own *CLI arguments*:
44

5-
{* docs_src/commands/arguments/tutorial001_py39.py hl[7,12] *}
5+
{* docs_src/commands/arguments/tutorial001_py310.py hl[7,12] *}
66

77
<div class="termy">
88

docs/tutorial/commands/callback.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ But we can use `@app.callback()` for that.
1212

1313
It's very similar to `@app.command()`, but it declares the *CLI parameters* for the main CLI application (before the commands):
1414

15-
{* docs_src/commands/callback/tutorial001_py39.py hl[25,26,27,28,29,30,31,32] *}
15+
{* docs_src/commands/callback/tutorial001_py310.py hl[25,26,27,28,29,30,31,32] *}
1616

1717
Here we create a `callback` with a `--verbose` *CLI option*.
1818

@@ -79,7 +79,7 @@ Error: No such option: --verbose
7979

8080
It's also possible to add a callback when creating the `typer.Typer()` app:
8181

82-
{* docs_src/commands/callback/tutorial002_py39.py hl[4,5,8] *}
82+
{* docs_src/commands/callback/tutorial002_py310.py hl[4,5,8] *}
8383

8484
That achieves the same as with `@app.callback()`.
8585

@@ -100,7 +100,7 @@ Creating user: Camila
100100

101101
If you added a callback when creating the `typer.Typer()` app, it's possible to override it with `@app.callback()`:
102102

103-
{* docs_src/commands/callback/tutorial003_py39.py hl[11,12,13] *}
103+
{* docs_src/commands/callback/tutorial003_py310.py hl[11,12,13] *}
104104

105105
Now `new_callback()` will be the one used.
106106

@@ -124,7 +124,7 @@ You can also add a callback just to add the documentation in the docstring.
124124

125125
It can be convenient especially if you have several lines of text, as the indentation will be automatically handled for you:
126126

127-
{* docs_src/commands/callback/tutorial004_py39.py hl[8,9,10,11,12,13,14,15,16] *}
127+
{* docs_src/commands/callback/tutorial004_py310.py hl[8,9,10,11,12,13,14,15,16] *}
128128

129129
Now the callback will be used mainly to extract the docstring for the help text.
130130

docs/tutorial/commands/context.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ For example, let's say that you want to execute some logic in a `Typer` callback
1414

1515
You can get the name of the subcommand from the context:
1616

17-
{* docs_src/commands/context/tutorial001_py39.py hl[17,21] *}
17+
{* docs_src/commands/context/tutorial001_py310.py hl[17,21] *}
1818

1919
Check it:
2020

@@ -44,7 +44,7 @@ And if no command is provided, the help message is shown.
4444

4545
But we could make it run even without a subcommand with `invoke_without_command=True`:
4646

47-
{* docs_src/commands/context/tutorial002_py39.py hl[16] *}
47+
{* docs_src/commands/context/tutorial002_py310.py hl[16] *}
4848

4949
Check it:
5050

@@ -74,7 +74,7 @@ For that, we can get the `typer.Context` and check if there's an invoked command
7474

7575
If it's `None`, it means that we are not calling a subcommand but the main program (the callback) directly:
7676

77-
{* docs_src/commands/context/tutorial003_py39.py hl[17,21] *}
77+
{* docs_src/commands/context/tutorial003_py310.py hl[17,21] *}
7878

7979
Check it:
8080

@@ -103,7 +103,7 @@ For example, you could keep additional *CLI parameters* not declared in your CLI
103103

104104
Then you can access those extra raw *CLI parameters* as a `list` of `str` in `ctx.args`:
105105

106-
{* docs_src/commands/context/tutorial004_py39.py hl[7,9,10] *}
106+
{* docs_src/commands/context/tutorial004_py310.py hl[7,9,10] *}
107107

108108
<div class="termy">
109109

docs/tutorial/commands/help.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ The same as before, you can add help for the commands in the docstrings and the
44

55
And the `typer.Typer()` application receives a parameter `help` that you can pass with the main help text for your CLI program:
66

7-
{* docs_src/commands/help/tutorial001_an_py39.py hl[5,10:12,23,27:31,44,48:52,61:63] *}
7+
{* docs_src/commands/help/tutorial001_an_py310.py hl[5,10:12,23,27:31,44,48:52,61:63] *}
88

99
Check it:
1010

@@ -92,7 +92,7 @@ You will also see how to use "Callbacks" later, and those include a way to add t
9292

9393
You will probably be better adding the help text as a docstring to your functions, but if for some reason you wanted to overwrite it, you can use the `help` function argument passed to `@app.command()`:
9494

95-
{* docs_src/commands/help/tutorial002_py39.py hl[6,14] *}
95+
{* docs_src/commands/help/tutorial002_py310.py hl[6,14] *}
9696

9797
Check it:
9898

@@ -126,7 +126,7 @@ There could be cases where you have a command in your app that you need to depre
126126

127127
You can mark it with the parameter `deprecated=True`:
128128

129-
{* docs_src/commands/help/tutorial003_py39.py hl[14] *}
129+
{* docs_src/commands/help/tutorial003_py310.py hl[14] *}
130130

131131
And when you show the `--help` option you will see it's marked as "`deprecated`":
132132

@@ -180,7 +180,7 @@ $ python main.py delete --help
180180

181181
As of version 0.20.0, Typer added support for suggesting mistyped command names. This feature is **enabled by default**, but you can disable it with the parameter `suggest_commands=False`:
182182

183-
{* docs_src/commands/index/tutorial005_py39.py hl[3] *}
183+
{* docs_src/commands/index/tutorial005_py310.py hl[3] *}
184184

185185
If a user mistypes a command, they'll see a helpful suggestion:
186186

@@ -215,7 +215,7 @@ Alternatively, you can disable it globally using an environmental variable `TYPE
215215

216216
If you set `rich_markup_mode="rich"` when creating the `typer.Typer()` app (which is the default), you will be able to use <a href="https://rich.readthedocs.io/en/stable/markup.html" class="external-link" target="_blank">Rich Console Markup</a> in the docstring, and even in the help for the *CLI arguments* and options:
217217

218-
{* docs_src/commands/help/tutorial004_an_py39.py hl[5,11,15:17,22,25,28] *}
218+
{* docs_src/commands/help/tutorial004_an_py310.py hl[5,11,15:17,22,25,28] *}
219219

220220
With that, you can use <a href="https://rich.readthedocs.io/en/stable/markup.html" class="external-link" target="_blank">Rich Console Markup</a> to format the text in the docstring for the command `create`, make the word "`create`" bold and green, and even use an <a href="https://rich.readthedocs.io/en/stable/markup.html#emoji" class="external-link" target="_blank">emoji</a>.
221221

@@ -278,7 +278,7 @@ $ python main.py delete --help
278278

279279
If you set `rich_markup_mode="markdown"` when creating the `typer.Typer()` app, you will be able to use Markdown in the docstring:
280280

281-
{* docs_src/commands/help/tutorial005_an_py39.py hl[5,10,13:21,26,28:29] *}
281+
{* docs_src/commands/help/tutorial005_an_py310.py hl[5,10,13:21,26,28:29] *}
282282

283283
With that, you can use Markdown to format the text in the docstring for the command `create`, make the word "`create`" bold, show a list of items, and even use an <a href="https://rich.readthedocs.io/en/stable/markup.html#emoji" class="external-link" target="_blank">emoji</a>.
284284

@@ -354,7 +354,7 @@ If you installed <a href="https://rich.readthedocs.io/" class="external-link" ta
354354

355355
To set the panel for a command you can pass the argument `rich_help_panel` with the name of the panel you want to use:
356356

357-
{* docs_src/commands/help/tutorial006_py39.py hl[22,30,38,46] *}
357+
{* docs_src/commands/help/tutorial006_py310.py hl[22,30,38,46] *}
358358

359359
Commands without a panel will be shown in the default panel `Commands`, and the rest will be shown in the next panels:
360360

@@ -473,7 +473,7 @@ You can see the custom panel for the commands for "`Utils and Configs`".
473473

474474
If you need, you can also add an epilog section to the help of your commands:
475475

476-
{* docs_src/commands/help/tutorial008_py39.py hl[6] *}
476+
{* docs_src/commands/help/tutorial008_py310.py hl[6] *}
477477

478478
And when you check the `--help` option it will look like:
479479

0 commit comments

Comments
 (0)