Skip to content

Commit a3bdc86

Browse files
committed
Merge branch 'master' of github.com:fastapi/typer
2 parents 6b0c4d6 + 7afa636 commit a3bdc86

Some content is hidden

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

42 files changed

+351
-118
lines changed

.github/workflows/deploy-docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ jobs:
4949
run: |
5050
rm -rf ./site
5151
mkdir ./site
52-
- uses: actions/download-artifact@v4
52+
- uses: actions/download-artifact@v5
5353
with:
5454
path: ./site/
5555
pattern: docs-site

.github/workflows/smokeshow.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
requirements**.txt
3636
pyproject.toml
3737
- run: uv pip install -r requirements-github-actions.txt
38-
- uses: actions/download-artifact@v4
38+
- uses: actions/download-artifact@v5
3939
with:
4040
name: coverage-html
4141
path: htmlcov

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ jobs:
9494
requirements**.txt
9595
pyproject.toml
9696
- name: Get coverage files
97-
uses: actions/download-artifact@v4
97+
uses: actions/download-artifact@v5
9898
with:
9999
pattern: coverage-*
100100
path: coverage

.pre-commit-config.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ repos:
1414
- id: end-of-file-fixer
1515
- id: trailing-whitespace
1616
- repo: https://github.com/astral-sh/ruff-pre-commit
17-
rev: v0.12.12
17+
rev: v0.13.0
1818
hooks:
1919
- id: ruff
2020
args:

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,8 @@ Goodbye Ms. Camila. Have a good day.
318318

319319
</div>
320320

321+
**Note**: If your app only has one command, by default the command name is **omitted** in usage: `python main.py Camila`. However, when there are multiple commands, you must **explicitly include the command name**: `python main.py hello Camila`. See [One or Multiple Commands](https://typer.tiangolo.com/tutorial/commands/one-or-multiple/) for more details.
322+
321323
### Recap
322324

323325
In summary, you declare **once** the types of parameters (*CLI arguments* and *CLI options*) as function parameters.

docs/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,8 @@ Goodbye Ms. Camila. Have a good day.
324324

325325
</div>
326326

327+
**Note**: If your app only has one command, by default the command name is **omitted** in usage: `python main.py Camila`. However, when there are multiple commands, you must **explicitly include the command name**: `python main.py hello Camila`. See [One or Multiple Commands](https://typer.tiangolo.com/tutorial/commands/one-or-multiple/) for more details.
328+
327329
### Recap
328330

329331
In summary, you declare **once** the types of parameters (*CLI arguments* and *CLI options*) as function parameters.

docs/release-notes.md

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,53 @@
22

33
## Latest Changes
44

5+
## 0.19.1
6+
7+
**Note**: this is the last version to support Python 3.7, going forward Typer will require Python 3.8+. And soon Python 3.8 will also be dropped as [Python 3.8 reached it's end of life](https://devguide.python.org/versions/) almost a year ago.
8+
9+
### Fixes
10+
11+
* 🐛 Ensure that `Optional[list]` values work correctly with callbacks. PR [#1018](https://github.com/fastapi/typer/pull/1018) by [@solesensei](https://github.com/solesensei).
12+
13+
## 0.19.0
14+
15+
### Features
16+
17+
* ✨ Support `typing.Literal` to define a set of predefined choices. PR [#429](https://github.com/fastapi/typer/pull/429) by [@blackary](https://github.com/blackary).
18+
* ✨ Allow setting an environment variable to `None` in `CliRunner.invoke`. PR [#1303](https://github.com/fastapi/typer/pull/1303) by [@arjenzorgdoc](https://github.com/arjenzorgdoc).
19+
20+
### Refactors
21+
22+
* ✅ Use Ruff rules to ensure safe lazy-loading of `rich`. PR [#1297](https://github.com/fastapi/typer/pull/1297) by [@nathanjmcdougall](https://github.com/nathanjmcdougall).
23+
* ✅ Avoid rich formatting in number test. PR [#1305](https://github.com/fastapi/typer/pull/1305) by [@svlandeg](https://github.com/svlandeg).
24+
25+
### Docs
26+
27+
* 📝 Clarify single-command vs multi-command behaviour in README. PR [#1268](https://github.com/fastapi/typer/pull/1268) by [@MorgenPronk](https://github.com/MorgenPronk).
28+
29+
## 0.18.0
30+
31+
### Fixes
32+
33+
* 👽️ Ensure compatibility with Click 8.3.0 by restoring the original `value_is_missing` function. PR [#1333](https://github.com/fastapi/typer/pull/1333) by [@svlandeg](https://github.com/svlandeg).
34+
35+
### Upgrades
36+
37+
* 📌 Remove pin for Click < 8.3.0 now that there's a fix for the changes. PR [#1346](https://github.com/fastapi/typer/pull/1346) by [@tiangolo](https://github.com/tiangolo).
38+
39+
## 0.17.5
40+
41+
### Fixes
42+
43+
* ⬇️ Restrict Click to below 8.3.0 to handle changes in the new version. PR [#1336](https://github.com/fastapi/typer/pull/1336) by [@svlandeg](https://github.com/svlandeg).
44+
545
### Internal
646

47+
* ⬆ Bump mkdocs-material from 9.6.14 to 9.6.20. PR [#1308](https://github.com/fastapi/typer/pull/1308) by [@dependabot[bot]](https://github.com/apps/dependabot).
48+
* ⬆ Bump mkdocs-material from 9.5.50 to 9.6.14. PR [#1223](https://github.com/fastapi/typer/pull/1223) by [@dependabot[bot]](https://github.com/apps/dependabot).
49+
* ⬆ Bump actions/download-artifact from 4 to 5. PR [#1269](https://github.com/fastapi/typer/pull/1269) by [@dependabot[bot]](https://github.com/apps/dependabot).
50+
* ⬆ Bump ruff from 0.12.12 to 0.13.0. PR [#1302](https://github.com/fastapi/typer/pull/1302) by [@dependabot[bot]](https://github.com/apps/dependabot).
51+
*[pre-commit.ci] pre-commit autoupdate. PR [#1307](https://github.com/fastapi/typer/pull/1307) by [@pre-commit-ci[bot]](https://github.com/apps/pre-commit-ci).
752
* ⬆ Update pytest-cov requirement from <7.0.0,>=2.10.0 to >=2.10.0,<8.0.0. PR [#1301](https://github.com/fastapi/typer/pull/1301) by [@dependabot[bot]](https://github.com/apps/dependabot).
853
* ⬆ Bump actions/setup-python from 5 to 6. PR [#1291](https://github.com/fastapi/typer/pull/1291) by [@dependabot[bot]](https://github.com/apps/dependabot).
954
* ⬆ Bump ruff from 0.12.11 to 0.12.12. PR [#1295](https://github.com/fastapi/typer/pull/1295) by [@dependabot[bot]](https://github.com/apps/dependabot).

docs/tutorial/parameter-types/enum.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,37 @@ Buying groceries: Eggs, Bacon
111111
```
112112

113113
</div>
114+
115+
### Literal choices
116+
117+
You can also use `Literal` to represent a set of possible predefined choices, without having to use an `Enum`:
118+
119+
{* docs_src/parameter_types/enum/tutorial004_an.py hl[6] *}
120+
121+
<div class="termy">
122+
123+
```console
124+
$ python main.py --help
125+
126+
// Notice the predefined values [simple|conv|lstm]
127+
Usage: main.py [OPTIONS]
128+
129+
Options:
130+
--network [simple|conv|lstm] [default: simple]
131+
--help Show this message and exit.
132+
133+
// Try it
134+
$ python main.py --network conv
135+
136+
Training neural network of type: conv
137+
138+
// Invalid value
139+
$ python main.py --network capsule
140+
141+
Usage: main.py [OPTIONS]
142+
Try "main.py --help" for help.
143+
144+
Error: Invalid value for '--network': 'capsule' is not one of 'simple', 'conv', 'lstm'.
145+
```
146+
147+
</div>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import typer
2+
from typing_extensions import Literal
3+
4+
5+
def main(network: Literal["simple", "conv", "lstm"] = typer.Option("simple")):
6+
print(f"Training neural network of type: {network}")
7+
8+
9+
if __name__ == "__main__":
10+
typer.run(main)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import typer
2+
from typing_extensions import Annotated, Literal
3+
4+
5+
def main(
6+
network: Annotated[Literal["simple", "conv", "lstm"], typer.Option()] = "simple",
7+
):
8+
print(f"Training neural network of type: {network}")
9+
10+
11+
if __name__ == "__main__":
12+
typer.run(main)

0 commit comments

Comments
 (0)