Skip to content

Commit

Permalink
Merge branch 'master' into update-package-section
Browse files Browse the repository at this point in the history
  • Loading branch information
kinuax committed Apr 7, 2024
2 parents 82b21f9 + 475359f commit 237cda5
Show file tree
Hide file tree
Showing 39 changed files with 427 additions and 319 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
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/[email protected]
with:
packages-dir: ${{ env.dir }}/dist/
11 changes: 4 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,24 @@ 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
- 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
3 changes: 3 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ on:
types:
- opened
- synchronize
schedule:
# cron every week on monday
- cron: "0 0 * * 1"

jobs:
test:
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
47 changes: 47 additions & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,54 @@
## Latest Changes

### 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
6 changes: 3 additions & 3 deletions docs/tutorial/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,12 @@ The first step is to install **Typer**:
```console
$ pip install typer
---> 100%
Successfully installed typer click shellingham rich typer-cli
Successfully installed typer click shellingham rich
```

</div>

By default, `typer` comes with `rich`, `shellingham`, and `typer-cli`.
By default, `typer` comes with `rich` and `shellingham`.

!!! note
If you are an advanced user and want to opt out of these default extra dependencies, you can instead install `typer-slim`.
Expand All @@ -82,7 +82,7 @@ By default, `typer` comes with `rich`, `shellingham`, and `typer-cli`.
pip install typer
```

...is the equivalent of:
...includes the same optional dependencies as:

```bash
pip install "typer-slim[standard]"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Hello Ron
// If you pass an invalid number of arguments you will get an error
$ python main.py Draco Hagrid

Error: argument names takes 3 values
Error: Argument 'names' takes 3 values

// And if you pass the exact number of values it will work correctly
$ python main.py Draco Hagrid Dobby
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ The username Morty has 3 coins
// Try with invalid values (not enough)
$ python main.py --user Camila 50

Error: --user option requires 3 arguments
Error: Option '--user' requires 3 arguments
```

</div>
2 changes: 1 addition & 1 deletion docs/tutorial/options/prompt.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ $ python main.py
# Project name: $ Old Project
# Repeat for confirmation: $ New Spice

Error: the two entered values do not match
Error: The two entered values do not match

# Project name: $ Old Project
# Repeat for confirmation: $ Old Project
Expand Down
Loading

0 comments on commit 237cda5

Please sign in to comment.