Skip to content

Commit

Permalink
Merge branch 'master' into lachaib/issue181
Browse files Browse the repository at this point in the history
  • Loading branch information
lachaib committed May 12, 2024
2 parents 19319c6 + b4b6f25 commit fde3d16
Show file tree
Hide file tree
Showing 52 changed files with 315 additions and 389 deletions.
4 changes: 2 additions & 2 deletions .github/DISCUSSION_TEMPLATE/questions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ body:
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.
- label: I already read and followed all the tutorials 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
Expand All @@ -47,7 +47,7 @@ body:
* 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.
* Review one Pull Request by downloading the code and following all the review process](https://typer.tiangolo.com/help-typer/#review-pull-requests).
* Review one Pull Request by downloading the code and following all the [review process](https://typer.tiangolo.com/help-typer/#review-pull-requests).
options:
- label: I commit to help with one of those options 👆
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ jobs:
if: ( github.event_name != 'pull_request' || github.secret_source == 'Actions' )
run: python -m mkdocs build --config-file mkdocs.insiders.yml

- uses: actions/upload-artifact@v3
- uses: actions/upload-artifact@v4
with:
name: docs-site
path: ./site/**
Expand Down
16 changes: 7 additions & 9 deletions .github/workflows/deploy-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,16 @@ jobs:
run: |
rm -rf ./site
mkdir ./site
- name: Download Artifact Docs
id: download
uses: dawidd6/action-download-artifact@v3.1.4
- uses: actions/download-artifact@v4
with:
if_no_artifact_found: ignore
github_token: ${{ secrets.GITHUB_TOKEN }}
workflow: build-docs.yml
run_id: ${{ github.event.workflow_run.id }}
name: docs-site
path: ./site/
pattern: docs-site
merge-multiple: true
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Deploy to Cloudflare Pages
if: steps.download.outputs.found_artifact == 'true'
# hashFiles returns an empty string if there are no files
if: hashFiles('./site/*')
id: deploy
uses: cloudflare/pages-action@v1
with:
Expand Down
7 changes: 2 additions & 5 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ jobs:
- typer-slim
- typer
- typer-cli
env:
dir: ${{ matrix.package == 'typer-slim' && './' || matrix.package == 'typer' && 'typer_package' || matrix.package == 'typer-cli' && 'typer_cli_package' }}
permissions:
id-token: write
steps:
Expand All @@ -34,9 +32,8 @@ jobs:
- name: Install build dependencies
run: pip install build
- name: Build distribution
working-directory: ${{ env.dir }}
env:
TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }}
run: python -m build
- name: Publish
uses: pypa/gh-action-pypi-publish@v1.8.11
with:
packages-dir: ${{ env.dir }}/dist/
10 changes: 6 additions & 4 deletions .github/workflows/smokeshow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@ jobs:

- run: pip install smokeshow

- uses: dawidd6/action-download-artifact@v3.1.4
- uses: actions/download-artifact@v4
with:
workflow: test.yml
commit: ${{ github.event.workflow_run.head_sha }}
name: coverage-html
path: htmlcov
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}

- run: smokeshow upload coverage-html
- run: smokeshow upload htmlcov
env:
SMOKESHOW_GITHUB_STATUS_DESCRIPTION: Coverage {coverage-percentage}
SMOKESHOW_GITHUB_COVERAGE_THRESHOLD: 100
Expand Down
13 changes: 6 additions & 7 deletions .github/workflows/test-redistribute.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ jobs:
- typer-slim
- typer
- typer-cli
env:
dir: ${{ matrix.package == 'typer-slim' && './' || matrix.package == 'typer' && 'typer_package' || matrix.package == 'typer-cli' && 'typer_cli_package' }}
steps:
- name: Dump GitHub context
env:
Expand All @@ -36,25 +34,26 @@ jobs:
- name: Install build dependencies
run: pip install build
- name: Build source distribution
working-directory: ${{ env.dir }}
env:
TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }}
run: python -m build --sdist
- name: Decompress source distribution
working-directory: ${{ env.dir }}
run: |
cd dist
tar xvf typer*.tar.gz
- name: Install test dependencies
if: ${{ matrix.package == 'typer-slim' }}
if: ${{ matrix.package != 'typer-cli' }}
run: |
cd dist/typer*/
pip install -r requirements-tests.txt
env:
TIANGOLO_BUILD_PACKAGE: ${{ matrix.package }}
- name: Run source distribution tests
if: ${{ matrix.package == 'typer-slim' }}
if: ${{ matrix.package != 'typer-cli' }}
run: |
cd dist/typer*/
bash scripts/test.sh
- name: Build wheel distribution
working-directory: ${{ env.dir }}
run: |
cd dist
pip wheel --no-deps typer*.tar.gz
11 changes: 6 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ jobs:
COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}
CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}
- name: Store coverage files
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage
name: coverage-${{ matrix.python-version }}
path: coverage

coverage-combine:
Expand All @@ -71,17 +71,18 @@ jobs:
# cache: "pip"
# cache-dependency-path: pyproject.toml
- name: Get coverage files
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: coverage
pattern: coverage-*
path: coverage
merge-multiple: true
- run: pip install coverage[toml]
- run: ls -la coverage
- run: coverage combine coverage
- run: coverage report
- run: coverage html --show-contexts --title "Coverage for ${{ github.sha }}"
- name: Store coverage HTML
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: coverage-html
path: htmlcov
Expand Down
13 changes: 5 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ The key features are:
* **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.
* **Run scripts**: Typer includes a `typer` command that you can use to run scripts, automatically converting them to CLIs, even if they don't use Typer internally.
* **Run scripts**: Typer includes a `typer` command/program that you can use to run scripts, automatically converting them to CLIs, even if they don't use Typer internally.

## FastAPI of CLIs

Expand Down Expand Up @@ -355,29 +355,26 @@ By default it also comes with extra standard dependencies:
* <a href="https://github.com/sarugaku/shellingham" class="external-link" target="_blank"><code>shellingham</code></a>: to 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`.
* `typer-cli`: adds the `typer` command to your shell:
* Quickly run scripts (that don't have to use Typer) with shell completion.
* Generate docs for your Typer applications.

### `typer-slim`

If you don't want the extra dependencies, install `typer-slim` instead.
If you don't want the extra standard optional dependencies, install `typer-slim` instead.

When you install with:

```bash
pip install typer
```

...it's the equivalent of:
...it includes the same code and dependencies as:

```bash
pip install "typer-slim[standard]"
```

The `standard` extra dependencies are `rich`, `shellingham`, `typer-cli`.
The `standard` extra dependencies are `rich` and `shellingham`.

**Note**: even if you don't install `typer-cli` you can still use it's functionality by calling `typer` as a module, e.g. `python -m typer`.
**Note**: The `typer` command is only included in the `typer` package.

## License

Expand Down
2 changes: 1 addition & 1 deletion docs/help-typer.md
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ As you have seen in the documentation, Typer is built on top of Click.

You can also sponsor:

* Pallets Project (Click maintainers)<a href="https://palletsprojects.com/donate" class="external-link" target="_blank">via the PSF</a> or <a href="https://tidelift.com/subscription/pkg/pypi-click" class="external-link" target="_blank">via Tidelift</a>
* Pallets Project (Click maintainers) <a href="https://palletsprojects.com/donate" class="external-link" target="_blank">via the PSF</a> or <a href="https://tidelift.com/subscription/pkg/pypi-click" class="external-link" target="_blank">via Tidelift</a>

---

Expand Down
13 changes: 5 additions & 8 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ The key features are:
* **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.
* **Run scripts**: Typer includes a `typer` command that you can use to run scripts, automatically converting them to CLIs, even if they don't use Typer internally.
* **Run scripts**: Typer includes a `typer` command/program that you can use to run scripts, automatically converting them to CLIs, even if they don't use Typer internally.

## FastAPI of CLIs

Expand Down Expand Up @@ -355,29 +355,26 @@ By default it also comes with extra standard dependencies:
* <a href="https://github.com/sarugaku/shellingham" class="external-link" target="_blank"><code>shellingham</code></a>: to 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`.
* `typer-cli`: adds the `typer` command to your shell:
* Quickly run scripts (that don't have to use Typer) with shell completion.
* Generate docs for your Typer applications.

### `typer-slim`

If you don't want the extra dependencies, install `typer-slim` instead.
If you don't want the extra standard optional dependencies, install `typer-slim` instead.

When you install with:

```bash
pip install typer
```

...it's the equivalent of:
...it includes the same code and dependencies as:

```bash
pip install "typer-slim[standard]"
```

The `standard` extra dependencies are `rich`, `shellingham`, `typer-cli`.
The `standard` extra dependencies are `rich` and `shellingham`.

**Note**: even if you don't install `typer-cli` you can still use it's functionality by calling `typer` as a module, e.g. `python -m typer`.
**Note**: The `typer` command is only included in the `typer` package.

## License

Expand Down
60 changes: 60 additions & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,75 @@
## Latest Changes

### Internal

* 👷 Update GitHub Actions to upload and download artifacts. PR [#829](https://github.com/tiangolo/typer/pull/829) by [@tiangolo](https://github.com/tiangolo).
* 👷 Tweak CI for test-redistribute, add needed env vars for slim. PR [#827](https://github.com/tiangolo/typer/pull/827) by [@tiangolo](https://github.com/tiangolo).
* ✅ Generalize test suite to run on Windows. PR [#810](https://github.com/tiangolo/typer/pull/810) by [@svlandeg](https://github.com/svlandeg).
* ✅ Add `__init__.py` files to fix test suite. PR [#809](https://github.com/tiangolo/typer/pull/809) by [@svlandeg](https://github.com/svlandeg).
* 🔧 Update MkDocs Material, enable plugins. PR [#813](https://github.com/tiangolo/typer/pull/813) by [@tiangolo](https://github.com/tiangolo).
* 🔧 Tweak development scripts and configs after migration to PDM, Ruff, etc.. PR [#797](https://github.com/tiangolo/typer/pull/797) by [@tiangolo](https://github.com/tiangolo).

## 0.12.3

### Fixes

* 🐛 Fix Rich formatting with no commands. PR [#796](https://github.com/tiangolo/typer/pull/796) by [@svlandeg](https://github.com/svlandeg).

## 0.12.2

### Features

* ✨ Improve column help display, ensure commands column width is the same on all panels. PR [#567](https://github.com/tiangolo/typer/pull/567) by [@ssbarnea](https://github.com/ssbarnea).

### Fixes

* 🐛 Add support for an argument of type `Optional[Tuple]` and default value `None`. PR [#757](https://github.com/tiangolo/typer/pull/757) by [@Asthestarsfalll](https://github.com/Asthestarsfalll).

### Docs

* 🔧 Fix typo in Github template. PR [#793](https://github.com/tiangolo/typer/pull/793) by [@svlandeg](https://github.com/svlandeg).
* 📝 Fix typos in documentation. PR [#761](https://github.com/tiangolo/typer/pull/761) by [@svlandeg](https://github.com/svlandeg).
* 📝 Update console output with Click 8 messages. PR [#789](https://github.com/tiangolo/typer/pull/789) by [@svlandeg](https://github.com/svlandeg).
* 📝 Remove references to a .rst README generated by poetry new. PR [#632](https://github.com/tiangolo/typer/pull/632) by [@jonasmmiguel](https://github.com/jonasmmiguel).

## 0.12.1

Now you don't need to install `typer[all]`. When you install `typer` it comes with the default optional dependencies and the `typer` command.

If you don't want the extra optional dependencies (`rich` and `shellingham`), you can install `typer-slim` instead.

You can also install `typer-slim[standard]`, which includes the default optional dependencies, but not the `typer` command.

Now the package `typer-cli` doesn't add anything on top of what `typer` has, it only depends on `typer`, and is there only for backwards compatibility, so that projects that depend on `typer-cli` can get the latest features of the `typer` command while they upgrade their dependencies to require `typer` directly.

### Features

* ✨ Add support for `typer ./someprogram.py utils docs --title`. PR [#782](https://github.com/tiangolo/typer/pull/782) by [@tiangolo](https://github.com/tiangolo).

### Fixes

* 🐛 Fix broken installation when upgrading from `typer <0.12.0` to `typer >=0.12.0`, make `typer` independent of `typer-slim`, include `typer` command in `typer` package. PR [#791](https://github.com/tiangolo/typer/pull/791) by [@tiangolo](https://github.com/tiangolo).

This fixes a problem that would break the `typer` installation directory when upgrading from `typer <0.12.0` to `typer >=0.12.0`, see issue [#790](https://github.com/tiangolo/typer/issues/790).

By installing the latest version (`0.12.1`) it fixes it, for any previous version, even if the installation directory was already broken by the previous upgrade.

### Internal

* 👷 Add cron to run test once a week on monday. PR [#783](https://github.com/tiangolo/typer/pull/783) by [@estebanx64](https://github.com/estebanx64).

## 0.12.0

In version `0.12.0`, the `typer` package depends on `typer-slim[standard]` which includes the default dependencies (instead of `typer[all]`) and `typer-cli` (that provides the `typer` command).

If you don't want the extra optional dependencies (`rich` and `shellingham`), you can install `typer-slim` instead.

You can also install `typer-slim[standard]`, which includes the default optional dependencies, but not the `typer` command.

In version `0.12.0` the `typer-cli` package only provides the `typer` command, but the code is still in the main code, so even without installing `typer-cli`, it can be called with `python -m typer`.

This approach of having `typer` depend on `typer-slim[standard]` instead of including the whole code and dependencies itself caused an issue when upgrading from `typer <0.12.0` to `typer >=0.12.0`, see issue [#790](https://github.com/tiangolo/typer/issues/790). This is fixed in version `0.12.1`.

### Features

* ✨ Add `typer-slim` package without extras, make `typer` include `typer-slim[default]` and integrate Typer CLI (`typer` command) into Typer. PR [#780](https://github.com/tiangolo/typer/pull/780) by [@tiangolo](https://github.com/tiangolo).
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial/arguments/optional.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Now let's see an alternative way to create the same *CLI argument*:

If you have an older version, you would get errors when trying to use `Annotated`.

Make sure you Upgrade the Typer version to at least 0.9.0 before using `Annotated`.
Make sure you upgrade the Typer version to at least 0.9.0 before using `Annotated`.

Before, you had this function parameter:

Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial/commands/callback.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ $ python main.py create --verbose Camila
Usage: main.py create [OPTIONS] USERNAME
Try "main.py create --help" for help.

Error: no such option: --verbose
Error: No such option: --verbose
```

</div>
Expand Down
8 changes: 4 additions & 4 deletions docs/tutorial/commands/options.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ Creating user: Camila
// Now test the command delete
$ python main.py delete Camila

# Are you sure you want to delete the user? [y/N]: $ y
# Are you sure you want to delete the user? [y/n]: $ y

Deleting user: Camila

$ python main.py delete Wade

# Are you sure you want to delete the user? [y/N]: $ n
# Are you sure you want to delete the user? [y/n]: $ n

Operation cancelled

Expand All @@ -82,13 +82,13 @@ Operation cancelled

$ python main.py delete-all

# Are you sure you want to delete ALL users? [y/N]: $ y
# Are you sure you want to delete ALL users? [y/n]: $ y

Deleting all users

$ python main.py delete-all

# Are you sure you want to delete ALL users? [y/N]: $ n
# Are you sure you want to delete ALL users? [y/n]: $ n

Operation cancelled

Expand Down
Loading

0 comments on commit fde3d16

Please sign in to comment.