From 05ffb24386cfa6cd23fa5f18b9eb233cd363e309 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Fri, 5 Apr 2024 04:29:30 +0400 Subject: [PATCH 01/32] =?UTF-8?q?=F0=9F=90=9B=20Fix=20broken=20installatio?= =?UTF-8?q?n=20when=20upgrading=20from=20`typer=20<0.12.0`=20to=20`typer?= =?UTF-8?q?=20>=3D0.12.0`,=20make=20`typer`=20independent=20of=20`typer-sl?= =?UTF-8?q?im`,=20include=20`typer`=20command=20in=20`typer`=20package=20(?= =?UTF-8?q?#791)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/publish.yml | 7 +-- .github/workflows/test-redistribute.yml | 11 ++--- README.md | 13 ++--- docs/index.md | 13 ++--- docs/tutorial/index.md | 6 +-- pdm_build.py | 55 ++++++++++++++++++++++ pyproject.toml | 55 ++++++++++++++++++---- {typer_cli_package => typer-cli}/README.md | 10 ++-- typer/__init__.py | 2 +- typer_cli_package/pdm_build.py | 40 ---------------- typer_cli_package/pyproject.toml | 55 ---------------------- typer_package/pdm_build.py | 49 ------------------- typer_package/pyproject.toml | 52 -------------------- 13 files changed, 128 insertions(+), 240 deletions(-) create mode 100644 pdm_build.py rename {typer_cli_package => typer-cli}/README.md (82%) delete mode 100644 typer_cli_package/pdm_build.py delete mode 100644 typer_cli_package/pyproject.toml delete mode 100644 typer_package/pdm_build.py delete mode 100644 typer_package/pyproject.toml diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1a842c4ea7..80cae43a7f 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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: @@ -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/ diff --git a/.github/workflows/test-redistribute.yml b/.github/workflows/test-redistribute.yml index c16d19d7b4..d2a33d30e2 100644 --- a/.github/workflows/test-redistribute.yml +++ b/.github/workflows/test-redistribute.yml @@ -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: @@ -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 diff --git a/README.md b/README.md index 0d4d824aa1..6bb4983a9f 100644 --- a/README.md +++ b/README.md @@ -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 @@ -355,13 +355,10 @@ By default it also comes with extra standard dependencies: * shellingham: 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: @@ -369,15 +366,15 @@ When you install with: 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 diff --git a/docs/index.md b/docs/index.md index 0d4d824aa1..6bb4983a9f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -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 @@ -355,13 +355,10 @@ By default it also comes with extra standard dependencies: * shellingham: 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: @@ -369,15 +366,15 @@ When you install with: 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 diff --git a/docs/tutorial/index.md b/docs/tutorial/index.md index 6fb8075c87..6cec65fe23 100644 --- a/docs/tutorial/index.md +++ b/docs/tutorial/index.md @@ -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 ``` -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`. @@ -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]" diff --git a/pdm_build.py b/pdm_build.py new file mode 100644 index 0000000000..4629801f0e --- /dev/null +++ b/pdm_build.py @@ -0,0 +1,55 @@ +import os +from typing import Any, Dict, List + +from pdm.backend.hooks import Context + +TIANGOLO_BUILD_PACKAGE = os.getenv("TIANGOLO_BUILD_PACKAGE", "typer") + + +def pdm_build_initialize(context: Context): + metadata = context.config.metadata + # Get main version + version = metadata["version"] + # Get package names to keep in sync with the same main version + sync_dependencies: List[str] = context.config.data["tool"]["tiangolo"][ + "_internal-slim-build" + ]["sync-dependencies"] + # Get custom config for the current package, from the env var + config: Dict[str, Any] = context.config.data["tool"]["tiangolo"][ + "_internal-slim-build" + ]["packages"][TIANGOLO_BUILD_PACKAGE] + project_config: Dict[str, Any] = config["project"] + # Get main optional dependencies, extras + optional_dependencies: Dict[str, List[str]] = metadata.get( + "optional-dependencies", {} + ) + # Get custom optional dependencies name to always include in this (non-slim) package + include_optional_dependencies: List[str] = config.get( + "include-optional-dependencies", [] + ) + # Override main [project] configs with custom configs for this package + for key, value in project_config.items(): + metadata[key] = value + # Get custom build config for the current package + build_config: Dict[str, Any] = ( + config.get("tool", {}).get("pdm", {}).get("build", {}) + ) + # Override PDM build config with custom build config for this package + for key, value in build_config.items(): + context.config.build_config[key] = value + # Get main dependencies + dependencies: List[str] = metadata.get("dependencies", []) + # Add optional dependencies to the default dependencies for this (non-slim) package + for include_optional in include_optional_dependencies: + optional_dependencies_group = optional_dependencies.get(include_optional, []) + dependencies.extend(optional_dependencies_group) + # Sync versions in dependencies + new_dependencies = [] + for dep in dependencies: + if dep in sync_dependencies: + new_dep = f"{dep}=={version}" + new_dependencies.append(new_dep) + else: + new_dependencies.append(dep) + if new_dependencies != dependencies: + metadata["dependencies"] = new_dependencies diff --git a/pyproject.toml b/pyproject.toml index f5abe95d3c..b648d38ad4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -3,15 +3,12 @@ requires = ["pdm-backend"] build-backend = "pdm.backend" [project] -# pip install typer-slim: is only the Typer library, without extras -# pip install typer: is typer-slim[standard], with extras and typer-cli -name = "typer-slim" +name = "typer" dynamic = ["version"] description = "Typer, build great CLIs. Easy to code. Based on Python type hints." authors = [ {name = "Sebastián Ramírez", email = "tiangolo@gmail.com"}, ] -readme = "README.md" requires-python = ">=3.7" classifiers = [ "Intended Audience :: Information Technology", @@ -38,16 +35,12 @@ dependencies = [ "click >= 8.0.0", "typing-extensions >= 3.7.4.3", ] - +readme = "README.md" [project.urls] Documentation = "https://typer.tiangolo.com/" homepage = "https://github.com/tiangolo/typer" [project.optional-dependencies] -all = [ - "shellingham >=1.3.0", - "rich >=10.11.0", -] standard = [ "shellingham >=1.3.0", "rich >=10.11.0", @@ -65,6 +58,50 @@ source-includes = [ "scripts/", ] +[tool.tiangolo._internal-slim-build] +sync-dependencies = [ + "typer-slim[standard]", + "typer-cli", + "typer" +] + +[tool.tiangolo._internal-slim-build.packages.typer-slim.project] +name = "typer-slim" + +[tool.tiangolo._internal-slim-build.packages.typer] +include-optional-dependencies = ["standard"] + +[tool.tiangolo._internal-slim-build.packages.typer.project] +optional-dependencies = {} + +[tool.tiangolo._internal-slim-build.packages.typer.project.scripts] +typer = "typer.cli:main" + +[tool.tiangolo._internal-slim-build.packages.typer-cli.project] +name = "typer-cli" +readme = "typer-cli/README.md" +dependencies = [ + "typer", +] +optional-dependencies = {} + +[tool.tiangolo._internal-slim-build.packages.typer-cli.tool.pdm.build] +# excludes needs to explicitly exclude the top level python packages, +# otherwise PDM includes them by default +# A "*" glob pattern can't be used here because in PDM internals, the patterns are put +# in a set (unordered, order varies) and each excluded file is assigned one of the +# glob patterns that matches, as the set is unordered, the matched pattern could be "*" +# independent of the order here. And then the internal code would give it a lower score +# than the one for a default included file. +# By not using "*" and explicitly excluding the top level packages, they get a higher +# score than the default inclusion +excludes = ["typer", "tests", "pdm_build.py"] +# source-includes needs to explicitly define some value because PDM will check the +# truthy value of the list, and if empty, will include some defaults, including "tests", +# an empty string doesn't match anything, but makes the list truthy, so that PDM +# doesn't override it during the build. +source-includes = [""] + [tool.isort] profile = "black" known_third_party = ["typer", "click"] diff --git a/typer_cli_package/README.md b/typer-cli/README.md similarity index 82% rename from typer_cli_package/README.md rename to typer-cli/README.md index dba1a0dcf7..0ebe65102c 100644 --- a/typer_cli_package/README.md +++ b/typer-cli/README.md @@ -30,9 +30,13 @@ Typer is a library for building Date: Fri, 5 Apr 2024 00:29:53 +0000 Subject: [PATCH 02/32] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/release-notes.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/release-notes.md b/docs/release-notes.md index 733c50c3e7..655a8855a9 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -4,6 +4,10 @@ * ✨ 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). + ### 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). From 3d1c32bf93214b0ac9c6b8d04a3daae2bbf2f74c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Thu, 4 Apr 2024 19:39:28 -0500 Subject: [PATCH 03/32] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/release-notes.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/release-notes.md b/docs/release-notes.md index 655a8855a9..76a0432ffc 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -1,5 +1,15 @@ ## Latest Changes +## 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). @@ -8,12 +18,26 @@ * 🐛 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). From f94b484450393f6a5cd064000ccc5b05e3bab10d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Thu, 4 Apr 2024 19:40:04 -0500 Subject: [PATCH 04/32] =?UTF-8?q?=F0=9F=94=96=20Release=20version=200.12.1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- typer/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/typer/__init__.py b/typer/__init__.py index 53a450970e..54d9c02214 100644 --- a/typer/__init__.py +++ b/typer/__init__.py @@ -1,6 +1,6 @@ """Typer, build great CLIs. Easy to code. Based on Python type hints.""" -__version__ = "0.12.1.dev2" +__version__ = "0.12.1" from shutil import get_terminal_size as get_terminal_size From 39fc51041f3ece615228114ccaf493a92efef681 Mon Sep 17 00:00:00 2001 From: "Jonas M. Miguel" <44494117+jonasmmiguel@users.noreply.github.com> Date: Sun, 7 Apr 2024 06:40:19 +0200 Subject: [PATCH 05/32] =?UTF-8?q?=F0=9F=93=9D=C2=A0Remove=20references=20t?= =?UTF-8?q?o=20a=20.rst=20README=20generated=20by=20poetry=20new=20(#632)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Jonas M. Miguel Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: svlandeg Co-authored-by: Sebastián Ramírez --- docs/tutorial/package.md | 61 ++-------------------------------------- 1 file changed, 3 insertions(+), 58 deletions(-) diff --git a/docs/tutorial/package.md b/docs/tutorial/package.md index a6901a0a94..17fe5a4149 100644 --- a/docs/tutorial/package.md +++ b/docs/tutorial/package.md @@ -97,7 +97,7 @@ You can see that you have a generated project structure that looks like: . ├── poetry.lock ├── pyproject.toml -├── README.rst +├── README.md ├── rick_portal_gun │   └── __init__.py └── tests @@ -146,13 +146,7 @@ def load(): ## Modify the README -Let's change the README. By default it's a file `README.rst`. - -Let's change it to `README.md`. So, change the extension from `.rst` to `.md`. - -So that we can use Markdown instead of reStructuredText. - -And change the file to have something like: +Let's change the README to have something like: ```Markdown # Portal Gun @@ -160,55 +154,6 @@ And change the file to have something like: The awesome Portal Gun ``` -## Modify your project metadata - -Edit your file `pyproject.toml`. - -It would look something like: - -```TOML -[tool.poetry] -name = "rick-portal-gun" -version = "0.1.0" -description = "" -authors = ["Rick Sanchez "] - -[tool.poetry.dependencies] -python = "^3.10" -typer = {extras = ["all"], version = "^0.1.0"} - -[tool.poetry.dev-dependencies] -pytest = "^5.2" - -[build-system] -requires = ["poetry>=0.12"] -build-backend = "poetry.masonry.api" -``` - -We changed the default README, so let's make it use the new `README.md`. - -Add the line: - -```TOML hl_lines="6" -[tool.poetry] -name = "rick-portal-gun" -version = "0.1.0" -description = "" -authors = ["Rick Sanchez "] -readme = "README.md" - -[tool.poetry.dependencies] -python = "^3.10" -typer = {extras = ["all"], version = "^0.1.0"} - -[tool.poetry.dev-dependencies] -pytest = "^5.2" - -[build-system] -requires = ["poetry>=0.12"] -build-backend = "poetry.masonry.api" -``` - ## Add a "script" We are creating a Python package that can be installed with `pip install`. @@ -468,7 +413,7 @@ The file would live right beside `__init__.py`: . ├── poetry.lock ├── pyproject.toml -├── README.rst +├── README.md ├── rick_portal_gun │ ├── __init__.py │ ├── __main__.py From b8ba669beac0c4215a04a150f87546b177f72ee5 Mon Sep 17 00:00:00 2001 From: github-actions Date: Sun, 7 Apr 2024 04:40:36 +0000 Subject: [PATCH 06/32] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/release-notes.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/release-notes.md b/docs/release-notes.md index 76a0432ffc..88c162ed06 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -1,5 +1,9 @@ ## Latest Changes +### Docs + +* 📝 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. From 31a15d83919f580a3a3fa77d8b57e97fec3c8012 Mon Sep 17 00:00:00 2001 From: Sofie Van Landeghem Date: Sun, 7 Apr 2024 06:41:11 +0200 Subject: [PATCH 07/32] =?UTF-8?q?=F0=9F=93=9D=20Update=20console=20output?= =?UTF-8?q?=20with=20Click=208=20messages=20(#789)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/tutorial/commands/callback.md | 2 +- docs/tutorial/commands/options.md | 8 ++++---- .../multiple-values/arguments-with-multiple-values.md | 2 +- .../multiple-values/options-with-multiple-values.md | 2 +- docs/tutorial/options/prompt.md | 2 +- docs/tutorial/parameter-types/bool.md | 2 +- docs/tutorial/parameter-types/datetime.md | 2 +- docs/tutorial/parameter-types/enum.md | 4 ++-- docs/tutorial/parameter-types/index.md | 2 +- docs/tutorial/parameter-types/number.md | 8 ++++---- docs/tutorial/parameter-types/uuid.md | 2 +- 11 files changed, 18 insertions(+), 18 deletions(-) diff --git a/docs/tutorial/commands/callback.md b/docs/tutorial/commands/callback.md index 6235ade00f..db8d18f2fd 100644 --- a/docs/tutorial/commands/callback.md +++ b/docs/tutorial/commands/callback.md @@ -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 ``` diff --git a/docs/tutorial/commands/options.md b/docs/tutorial/commands/options.md index 5d658477d8..1bb3921ef8 100644 --- a/docs/tutorial/commands/options.md +++ b/docs/tutorial/commands/options.md @@ -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 @@ -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 diff --git a/docs/tutorial/multiple-values/arguments-with-multiple-values.md b/docs/tutorial/multiple-values/arguments-with-multiple-values.md index 891ec4fbf7..07e6cd888a 100644 --- a/docs/tutorial/multiple-values/arguments-with-multiple-values.md +++ b/docs/tutorial/multiple-values/arguments-with-multiple-values.md @@ -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 diff --git a/docs/tutorial/multiple-values/options-with-multiple-values.md b/docs/tutorial/multiple-values/options-with-multiple-values.md index 78083a4e0a..feeb45eea9 100644 --- a/docs/tutorial/multiple-values/options-with-multiple-values.md +++ b/docs/tutorial/multiple-values/options-with-multiple-values.md @@ -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 ``` diff --git a/docs/tutorial/options/prompt.md b/docs/tutorial/options/prompt.md index 73a857a331..9f7472eac4 100644 --- a/docs/tutorial/options/prompt.md +++ b/docs/tutorial/options/prompt.md @@ -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 diff --git a/docs/tutorial/parameter-types/bool.md b/docs/tutorial/parameter-types/bool.md index 4d074e5d5b..68ef638062 100644 --- a/docs/tutorial/parameter-types/bool.md +++ b/docs/tutorial/parameter-types/bool.md @@ -54,7 +54,7 @@ $ python main.py --no-force Usage: main.py [OPTIONS] Try "main.py --help" for help. -Error: no such option: --no-force +Error: No such option: --no-force ``` diff --git a/docs/tutorial/parameter-types/datetime.md b/docs/tutorial/parameter-types/datetime.md index 4f59811e89..04a3eb71a8 100644 --- a/docs/tutorial/parameter-types/datetime.md +++ b/docs/tutorial/parameter-types/datetime.md @@ -38,7 +38,7 @@ $ python main.py july-19-1989 Usage: main.py [OPTIONS] [%Y-%m-%d|%Y-%m-%dT%H:%M:%S|%Y-%m-%d%H:%M:%S] -Error: Invalid value for '[%Y-%m-%d|%Y-%m-%dT%H:%M:%S|%Y-%m-%d %H:%M:%S]': invalid datetime format: july-19-1989. (choose from %Y-%m-%d, %Y-%m-%dT%H:%M:%S, %Y-%m-%d %H:%M:%S) +Error: Invalid value for 'BIRTH:[%Y-%m-%d|%Y-%m-%dT%H:%M:%S|%Y-%m-%d %H:%M:%S]': 'july-19-1989' does not match the formats '%Y-%m-%d', '%Y-%m-%dT%H:%M:%S', '%Y-%m-%d %H:%M:%S'. ``` diff --git a/docs/tutorial/parameter-types/enum.md b/docs/tutorial/parameter-types/enum.md index 0751aadb35..b3b2c149f0 100644 --- a/docs/tutorial/parameter-types/enum.md +++ b/docs/tutorial/parameter-types/enum.md @@ -34,7 +34,7 @@ $ python main.py --network capsule Usage: main.py [OPTIONS] Try "main.py --help" for help. -Error: Invalid value for '--network': invalid choice: capsule. (choose from simple, conv, lstm) +Error: Invalid value for '--network': 'capsule' is not one of 'simple', 'conv', 'lstm'. // Note that enums are case sensitive by default $ python main.py --network CONV @@ -42,7 +42,7 @@ $ python main.py --network CONV Usage: main.py [OPTIONS] Try "main.py --help" for help. -Error: Invalid value for '--network': invalid choice: CONV. (choose from simple, conv, lstm) +Error: Invalid value for '--network': 'CONV' is not one of 'simple', 'conv', 'lstm'. ``` diff --git a/docs/tutorial/parameter-types/index.md b/docs/tutorial/parameter-types/index.md index 8a0e5dfbfa..ed3b7ad186 100644 --- a/docs/tutorial/parameter-types/index.md +++ b/docs/tutorial/parameter-types/index.md @@ -50,7 +50,7 @@ $ python main.py Camila --age 15.3 Usage: main.py [OPTIONS] NAME Try "main.py --help" for help. -Error: Invalid value for '--age': 15.3 is not a valid integer +Error: Invalid value for '--age': '15.3' is not a valid integer // Because 15.3 is not an INTEGER (it's a float) ``` diff --git a/docs/tutorial/parameter-types/number.md b/docs/tutorial/parameter-types/number.md index eab91f627f..001e4fccbb 100644 --- a/docs/tutorial/parameter-types/number.md +++ b/docs/tutorial/parameter-types/number.md @@ -50,7 +50,7 @@ $ python main.py 1002 Usage: main.py [OPTIONS] ID Try "main.py --help" for help. -Error: Invalid value for 'ID': 1002 is not in the valid range of 0 to 1000. +Error: Invalid value for 'ID': 1002 is not in the range 0<=x<=1000. // Pass an invalid age $ python main.py 5 --age 15 @@ -58,7 +58,7 @@ $ python main.py 5 --age 15 Usage: main.py [OPTIONS] ID Try "main.py --help" for help. -Error: Invalid value for '--age': 15 is smaller than the minimum valid value 18. +Error: Invalid value for '--age': 15 is not in the range x>=18. // Pass an invalid score $ python main.py 5 --age 20 --score 100.5 @@ -66,7 +66,7 @@ $ python main.py 5 --age 20 --score 100.5 Usage: main.py [OPTIONS] ID Try "main.py --help" for help. -Error: Invalid value for '--score': 100.5 is bigger than the maximum valid value 100. +Error: Invalid value for '--score': 100.5 is not in the range x<=100. // But as we didn't specify a minimum score, this is accepted $ python main.py 5 --age 20 --score -5 @@ -110,7 +110,7 @@ $ python main.py 1002 Usage: main.py [OPTIONS] ID Try "main.py --help" for help. -Error: Invalid value for 'ID': 1002 is not in the valid range of 0 to 1000. +Error: Invalid value for 'ID': 1002 is not in the range 0<=x<=1000. // But --rank and --score use clamp $ python main.py 5 --rank 11 --score -5 diff --git a/docs/tutorial/parameter-types/uuid.md b/docs/tutorial/parameter-types/uuid.md index 0042f47061..8b96f6ad45 100644 --- a/docs/tutorial/parameter-types/uuid.md +++ b/docs/tutorial/parameter-types/uuid.md @@ -42,7 +42,7 @@ $ python main.py 7479706572-72756c6573 Usage: main.py [OPTIONS] USER_ID Try "main.py --help" for help. -Error: Invalid value for 'USER_ID': 7479706572-72756c6573 is not a valid UUID value +Error: Invalid value for 'USER_ID': 7479706572-72756c6573 is not a valid UUID. ``` From cc9a40799c8736b60d3237a770336ae09ed7e2bb Mon Sep 17 00:00:00 2001 From: github-actions Date: Sun, 7 Apr 2024 04:41:30 +0000 Subject: [PATCH 08/32] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/release-notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes.md b/docs/release-notes.md index 88c162ed06..a4a2070083 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -2,6 +2,7 @@ ### Docs +* 📝 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 From b2834dba0dd26e38a6f2ebe757918b822d9744cf Mon Sep 17 00:00:00 2001 From: Sofie Van Landeghem Date: Sun, 7 Apr 2024 06:42:37 +0200 Subject: [PATCH 09/32] =?UTF-8?q?=F0=9F=93=9D=20Fix=20typos=20in=20documen?= =?UTF-8?q?tation=20(#761)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sebastián Ramírez --- docs/help-typer.md | 2 +- docs/tutorial/arguments/optional.md | 2 +- docs_src/parameter_types/custom_types/tutorial001.py | 2 +- tests/test_others.py | 2 +- .../test_parameter_types/test_custom_types/test_tutorial001.py | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/help-typer.md b/docs/help-typer.md index 98cf4069e9..221492db38 100644 --- a/docs/help-typer.md +++ b/docs/help-typer.md @@ -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)via the PSF or via Tidelift +* Pallets Project (Click maintainers) via the PSF or via Tidelift --- diff --git a/docs/tutorial/arguments/optional.md b/docs/tutorial/arguments/optional.md index c52e689a38..6bda570843 100644 --- a/docs/tutorial/arguments/optional.md +++ b/docs/tutorial/arguments/optional.md @@ -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: diff --git a/docs_src/parameter_types/custom_types/tutorial001.py b/docs_src/parameter_types/custom_types/tutorial001.py index 456c46b52f..1ccf24cdfe 100644 --- a/docs_src/parameter_types/custom_types/tutorial001.py +++ b/docs_src/parameter_types/custom_types/tutorial001.py @@ -15,7 +15,7 @@ def parse_custom_class(value: str): def main( custom_arg: CustomClass = typer.Argument(parser=parse_custom_class), - custom_opt: CustomClass = typer.Option("Y", parser=parse_custom_class), + custom_opt: CustomClass = typer.Option("Foo", parser=parse_custom_class), ): print(f"custom_arg is {custom_arg}") print(f"--custom-opt is {custom_opt}") diff --git a/tests/test_others.py b/tests/test_others.py index 7986e1d7f0..8c78520029 100644 --- a/tests/test_others.py +++ b/tests/test_others.py @@ -30,7 +30,7 @@ def test_defaults_from_info(): assert value -def test_too_may_parsers(): +def test_too_many_parsers(): def custom_parser(value: str) -> int: return int(value) # pragma: no cover diff --git a/tests/test_tutorial/test_parameter_types/test_custom_types/test_tutorial001.py b/tests/test_tutorial/test_parameter_types/test_custom_types/test_tutorial001.py index 6e21535fa6..047dfff142 100644 --- a/tests/test_tutorial/test_parameter_types/test_custom_types/test_tutorial001.py +++ b/tests/test_tutorial/test_parameter_types/test_custom_types/test_tutorial001.py @@ -26,7 +26,7 @@ def test_parse_custom_type(): def test_parse_custom_type_with_default(): result = runner.invoke(app, ["0"]) assert "custom_arg is " in result.output - assert "custom-opt is " in result.output + assert "custom-opt is " in result.output def test_script(): From d9f65ba49d15d0789ad01d0411530294d085ed49 Mon Sep 17 00:00:00 2001 From: Sofie Van Landeghem Date: Sun, 7 Apr 2024 06:42:53 +0200 Subject: [PATCH 10/32] =?UTF-8?q?=F0=9F=94=A7=20Fix=20typo=20in=20Github?= =?UTF-8?q?=20template=20(#793)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/DISCUSSION_TEMPLATE/questions.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/DISCUSSION_TEMPLATE/questions.yml b/.github/DISCUSSION_TEMPLATE/questions.yml index 1d15c2f566..def5e754cf 100644 --- a/.github/DISCUSSION_TEMPLATE/questions.yml +++ b/.github/DISCUSSION_TEMPLATE/questions.yml @@ -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 @@ -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 👆 From cb7811380f03881d7690c987613c37b6890d1a69 Mon Sep 17 00:00:00 2001 From: github-actions Date: Sun, 7 Apr 2024 04:42:56 +0000 Subject: [PATCH 11/32] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/release-notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes.md b/docs/release-notes.md index a4a2070083..0a6687653e 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -2,6 +2,7 @@ ### Docs +* 📝 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). From 5cee0af07312d7077614c702ba60444eb2ea4e7c Mon Sep 17 00:00:00 2001 From: github-actions Date: Sun, 7 Apr 2024 04:43:22 +0000 Subject: [PATCH 12/32] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/release-notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes.md b/docs/release-notes.md index 0a6687653e..1ed57b54a9 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -2,6 +2,7 @@ ### 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). From a0209aa969f08b39438e04c6280dbe723782636a Mon Sep 17 00:00:00 2001 From: Asthestarsfalll <72954905+Asthestarsfalll@users.noreply.github.com> Date: Sun, 7 Apr 2024 12:45:03 +0800 Subject: [PATCH 13/32] =?UTF-8?q?=F0=9F=90=9B=20Add=20support=20for=20an?= =?UTF-8?q?=20argument=20of=20type=20`Optional[Tuple]`=20and=20default=20v?= =?UTF-8?q?alue=20`None`=20(#757)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: svlandeg --- tests/test_type_conversion.py | 19 +++++++++++++++++++ typer/main.py | 8 ++++++-- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/tests/test_type_conversion.py b/tests/test_type_conversion.py index 21ad57436c..51e83314de 100644 --- a/tests/test_type_conversion.py +++ b/tests/test_type_conversion.py @@ -29,6 +29,25 @@ def opt(user: Optional[str] = None): assert "User: Camila" in result.output +def test_optional_tuple(): + app = typer.Typer() + + @app.command() + def opt(number: Optional[Tuple[int, int]] = None): + if number: + print(f"Number: {number}") + else: + print("No number") + + result = runner.invoke(app) + assert result.exit_code == 0 + assert "No number" in result.output + + result = runner.invoke(app, ["--number", "4", "2"]) + assert result.exit_code == 0 + assert "Number: (4, 2)" in result.output + + def test_no_type(): app = typer.Typer() diff --git a/typer/main.py b/typer/main.py index ccf9f0956c..9db26975ca 100644 --- a/typer/main.py +++ b/typer/main.py @@ -645,10 +645,14 @@ def internal_convertor(value: Sequence[Any]) -> Optional[List[Any]]: def generate_tuple_convertor( types: Sequence[Any], -) -> Callable[[Tuple[Any, ...]], Tuple[Any, ...]]: +) -> Callable[[Optional[Tuple[Any, ...]]], Optional[Tuple[Any, ...]]]: convertors = [determine_type_convertor(type_) for type_ in types] - def internal_convertor(param_args: Tuple[Any, ...]) -> Tuple[Any, ...]: + def internal_convertor( + param_args: Optional[Tuple[Any, ...]], + ) -> Optional[Tuple[Any, ...]]: + if param_args is None: + return None return tuple( convertor(arg) if convertor else arg for (convertor, arg) in zip(convertors, param_args) From 475359f31a010f36c17408570048f0c9d46eb619 Mon Sep 17 00:00:00 2001 From: github-actions Date: Sun, 7 Apr 2024 04:45:24 +0000 Subject: [PATCH 14/32] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/release-notes.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/release-notes.md b/docs/release-notes.md index 1ed57b54a9..159c6ad1a5 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -1,5 +1,9 @@ ## 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). From cfae1d2ba37a84789a1d8f112dde74cbf5a00d1e Mon Sep 17 00:00:00 2001 From: Sorin Sbarnea Date: Mon, 8 Apr 2024 20:10:11 +0100 Subject: [PATCH 15/32] =?UTF-8?q?=E2=9C=A8=20Improve=20column=20help=20dis?= =?UTF-8?q?play,=20ensure=20commands=20column=20width=20is=20the=20same=20?= =?UTF-8?q?on=20all=20panels=20(#567)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: svlandeg Co-authored-by: Sebastián Ramírez --- typer/rich_utils.py | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/typer/rich_utils.py b/typer/rich_utils.py index ff91e51662..2b91f265ab 100644 --- a/typer/rich_utils.py +++ b/typer/rich_utils.py @@ -466,6 +466,7 @@ def _print_commands_panel( commands: List[click.Command], markup_mode: MarkupMode, console: Console, + cmd_len: int, ) -> None: t_styles: Dict[str, Any] = { "show_lines": STYLE_COMMANDS_TABLE_SHOW_LINES, @@ -487,7 +488,16 @@ def _print_commands_panel( ) # Define formatting in first column, as commands don't match highlighter # regex - commands_table.add_column(style="bold cyan", no_wrap=True) + commands_table.add_column( + style="bold cyan", + no_wrap=True, + width=cmd_len, + ) + + # A big ratio makes the description column be greedy and take all the space + # available instead of allowing the command column to grow and misalign with + # other panels. + commands_table.add_column("Description", justify="left", no_wrap=False, ratio=10) rows: List[List[Union[RenderableType, None]]] = [] deprecated_rows: List[Union[RenderableType, None]] = [] for command in commands: @@ -628,6 +638,15 @@ def rich_format_help( ) panel_to_commands[panel_name].append(command) + # Identify the longest command name in all panels + max_cmd_len = max( + [ + len(command.name or "") + for commands in panel_to_commands.values() + for command in commands + ] + ) + # Print each command group panel default_commands = panel_to_commands.get(COMMANDS_PANEL_TITLE, []) _print_commands_panel( @@ -635,6 +654,7 @@ def rich_format_help( commands=default_commands, markup_mode=markup_mode, console=console, + cmd_len=max_cmd_len, ) for panel_name, commands in panel_to_commands.items(): if panel_name == COMMANDS_PANEL_TITLE: @@ -645,6 +665,7 @@ def rich_format_help( commands=commands, markup_mode=markup_mode, console=console, + cmd_len=max_cmd_len, ) # Epilogue if we have it From c99a9501eea30967e82e6d77bf7ac0466b17993e Mon Sep 17 00:00:00 2001 From: github-actions Date: Mon, 8 Apr 2024 19:10:28 +0000 Subject: [PATCH 16/32] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/release-notes.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/release-notes.md b/docs/release-notes.md index 159c6ad1a5..6cea8c3884 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -1,5 +1,9 @@ ## Latest Changes +### 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). From c9bc93c2592e36e449354dea9b8d64b26cf6bdc1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Mon, 8 Apr 2024 14:16:08 -0500 Subject: [PATCH 17/32] =?UTF-8?q?=F0=9F=94=96=20Release=20version=200.12.2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/release-notes.md | 2 ++ typer/__init__.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/release-notes.md b/docs/release-notes.md index 6cea8c3884..022bb06950 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -1,5 +1,7 @@ ## Latest Changes +## 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). diff --git a/typer/__init__.py b/typer/__init__.py index 54d9c02214..5669d61b2a 100644 --- a/typer/__init__.py +++ b/typer/__init__.py @@ -1,6 +1,6 @@ """Typer, build great CLIs. Easy to code. Based on Python type hints.""" -__version__ = "0.12.1" +__version__ = "0.12.2" from shutil import get_terminal_size as get_terminal_size From 3bc7d2560f4c8f86e058c9ea1d1e682d14c5107c Mon Sep 17 00:00:00 2001 From: Sofie Van Landeghem Date: Tue, 9 Apr 2024 19:10:18 +0200 Subject: [PATCH 18/32] =?UTF-8?q?=F0=9F=90=9B=20Fix=20Rich=20formatting=20?= =?UTF-8?q?with=20no=20commands=20(#796)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_rich_utils.py | 14 ++++++++++++++ typer/rich_utils.py | 3 ++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/test_rich_utils.py b/tests/test_rich_utils.py index b6da8995f6..c62e3512aa 100644 --- a/tests/test_rich_utils.py +++ b/tests/test_rich_utils.py @@ -36,3 +36,17 @@ def secondary(): assert "Hello World" in result.stdout result = runner.invoke(app, ["secondary"]) assert "Hello Secondary World" in result.stdout + + +def test_rich_help_no_commands(): + """Ensure that the help still works for a Typer instance with no commands, but with a callback.""" + app = typer.Typer(help="My cool Typer app") + + @app.callback(invoke_without_command=True, no_args_is_help=True) + def main() -> None: + return None # pragma: no cover + + result = runner.invoke(app, ["--help"]) + + assert result.exit_code == 0 + assert "Show this message" in result.stdout diff --git a/typer/rich_utils.py b/typer/rich_utils.py index 2b91f265ab..cf0538e914 100644 --- a/typer/rich_utils.py +++ b/typer/rich_utils.py @@ -644,7 +644,8 @@ def rich_format_help( len(command.name or "") for commands in panel_to_commands.values() for command in commands - ] + ], + default=0, ) # Print each command group panel From 718a899b1895cb4abf1da8518de8f3bf6fdaac56 Mon Sep 17 00:00:00 2001 From: github-actions Date: Tue, 9 Apr 2024 17:10:38 +0000 Subject: [PATCH 19/32] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/release-notes.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/release-notes.md b/docs/release-notes.md index 022bb06950..b06b4056fc 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -1,5 +1,9 @@ ## Latest Changes +### 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 From 525c7779ba8914b3950b26ffa21decdfd3eec6ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Tue, 9 Apr 2024 12:12:16 -0500 Subject: [PATCH 20/32] =?UTF-8?q?=F0=9F=94=96=20Release=20version=200.12.3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/release-notes.md | 2 ++ typer/__init__.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/release-notes.md b/docs/release-notes.md index b06b4056fc..bef720c2d9 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -1,5 +1,7 @@ ## Latest Changes +## 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). diff --git a/typer/__init__.py b/typer/__init__.py index 5669d61b2a..d4ac56d0ba 100644 --- a/typer/__init__.py +++ b/typer/__init__.py @@ -1,6 +1,6 @@ """Typer, build great CLIs. Easy to code. Based on Python type hints.""" -__version__ = "0.12.2" +__version__ = "0.12.3" from shutil import get_terminal_size as get_terminal_size From c1aac460852dd85dfecc1636c03cec445e977c34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Wed, 10 Apr 2024 14:19:48 +0400 Subject: [PATCH 21/32] =?UTF-8?q?=F0=9F=94=A7=20Tweak=20development=20scri?= =?UTF-8?q?pts=20and=20configs=20after=20migration=20to=20PDM,=20Ruff,=20e?= =?UTF-8?q?tc.=20(#797)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pyproject.toml | 9 --------- requirements-tests.txt | 2 +- requirements.txt | 2 +- scripts/format-imports.sh | 6 ------ scripts/format.sh | 2 +- scripts/lint.sh | 2 +- scripts/publish.sh | 5 ----- scripts/zip-docs.sh | 11 ----------- 8 files changed, 4 insertions(+), 35 deletions(-) delete mode 100755 scripts/format-imports.sh delete mode 100755 scripts/publish.sh delete mode 100644 scripts/zip-docs.sh diff --git a/pyproject.toml b/pyproject.toml index b648d38ad4..c9e793e1ed 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -102,15 +102,6 @@ excludes = ["typer", "tests", "pdm_build.py"] # doesn't override it during the build. source-includes = [""] -[tool.isort] -profile = "black" -known_third_party = ["typer", "click"] -skip_glob = [ - "docs_src/subcommands/tutorial001/main.py", - "docs_src/subcommands/tutorial003/lands.py", - "docs_src/subcommands/tutorial003/main.py", - ] - [tool.pytest.ini_options] addopts = [ "--strict-config", diff --git a/requirements-tests.txt b/requirements-tests.txt index f89c88eebe..45f1904d16 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -1,4 +1,4 @@ --e .[all] +-e . pytest >=4.4.0,<8.0.0 pytest-cov >=2.10.0,<5.0.0 diff --git a/requirements.txt b/requirements.txt index d84d26a8da..1e21c5d2f3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ --e .[all] +-e . -r requirements-tests.txt -r requirements-docs.txt diff --git a/scripts/format-imports.sh b/scripts/format-imports.sh deleted file mode 100755 index fa036a9291..0000000000 --- a/scripts/format-imports.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -e -set -x - -# Sort imports one per line, so autoflake can remove unused imports -isort --force-single-line-imports typer tests docs_src -sh ./scripts/format.sh diff --git a/scripts/format.sh b/scripts/format.sh index 63b434e0b4..6131b020d0 100755 --- a/scripts/format.sh +++ b/scripts/format.sh @@ -2,5 +2,5 @@ set -x set -e -ruff typer tests docs_src scripts --fix +ruff check typer tests docs_src scripts --fix ruff format typer tests docs_src scripts diff --git a/scripts/lint.sh b/scripts/lint.sh index a32cf3afca..75761f1b6a 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -4,5 +4,5 @@ set -e set -x mypy typer -ruff typer tests docs_src +ruff check typer tests docs_src ruff format typer tests docs_src --check diff --git a/scripts/publish.sh b/scripts/publish.sh deleted file mode 100755 index 122728a604..0000000000 --- a/scripts/publish.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -set -e - -flit publish diff --git a/scripts/zip-docs.sh b/scripts/zip-docs.sh deleted file mode 100644 index 69315f5ddd..0000000000 --- a/scripts/zip-docs.sh +++ /dev/null @@ -1,11 +0,0 @@ -#! /usr/bin/env bash - -set -x -set -e - -cd ./site - -if [ -f docs.zip ]; then - rm -rf docs.zip -fi -zip -r docs.zip ./ From 8bffffd47e6b1b51adbf16700133e72f99a77c1f Mon Sep 17 00:00:00 2001 From: github-actions Date: Wed, 10 Apr 2024 10:20:09 +0000 Subject: [PATCH 22/32] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/release-notes.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/release-notes.md b/docs/release-notes.md index bef720c2d9..4c19c931ce 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -1,5 +1,9 @@ ## Latest Changes +### Internal + +* 🔧 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 From 874b2bca7c5614a55e8e947797958b9a0480d62d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Mon, 29 Apr 2024 17:06:42 -0700 Subject: [PATCH 23/32] =?UTF-8?q?=F0=9F=94=A7=20Update=20MkDocs=20Material?= =?UTF-8?q?,=20enable=20plugins=20(#813)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mkdocs.insiders.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mkdocs.insiders.yml b/mkdocs.insiders.yml index d0b5a56f6e..bb475642cd 100644 --- a/mkdocs.insiders.yml +++ b/mkdocs.insiders.yml @@ -1,4 +1,4 @@ INHERIT: mkdocs.yml -# plugins: - # TODO: Re-enable once this is fixed: https://github.com/squidfunk/mkdocs-material/issues/6983 - # - social +plugins: + social: + typeset: From f6ba077dca84dfb567a8ee7e4580b0657d80878a Mon Sep 17 00:00:00 2001 From: github-actions Date: Tue, 30 Apr 2024 00:07:09 +0000 Subject: [PATCH 24/32] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/release-notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes.md b/docs/release-notes.md index 4c19c931ce..7b53e5ff83 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -2,6 +2,7 @@ ### Internal +* 🔧 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 From b9aa1db9da41fc965d81f537674c468fb22efe24 Mon Sep 17 00:00:00 2001 From: Sofie Van Landeghem Date: Thu, 2 May 2024 23:43:47 +0200 Subject: [PATCH 25/32] =?UTF-8?q?=E2=9C=85=20Add=20`=5F=5Finit=5F=5F.py`?= =?UTF-8?q?=20files=20to=20fix=20test=20suite=20(#809)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs_src/subcommands/tutorial001/__init__.py | 0 docs_src/subcommands/tutorial003/__init__.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 docs_src/subcommands/tutorial001/__init__.py create mode 100644 docs_src/subcommands/tutorial003/__init__.py diff --git a/docs_src/subcommands/tutorial001/__init__.py b/docs_src/subcommands/tutorial001/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/docs_src/subcommands/tutorial003/__init__.py b/docs_src/subcommands/tutorial003/__init__.py new file mode 100644 index 0000000000..e69de29bb2 From 8f11d2e9537a629914ff982a7fbcc9df87e1eaff Mon Sep 17 00:00:00 2001 From: github-actions Date: Thu, 2 May 2024 21:44:08 +0000 Subject: [PATCH 26/32] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/release-notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes.md b/docs/release-notes.md index 7b53e5ff83..62152704e1 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -2,6 +2,7 @@ ### Internal +* ✅ 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). From 77adc6e2485673a7cf122f075ae0802d953155b2 Mon Sep 17 00:00:00 2001 From: Sofie Van Landeghem Date: Thu, 2 May 2024 23:44:37 +0200 Subject: [PATCH 27/32] =?UTF-8?q?=E2=9C=85=20Generalize=20test=20suite=20t?= =?UTF-8?q?o=20run=20on=20Windows=20(#810)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_completion/test_completion.py | 6 +++--- tests/test_completion/test_completion_install.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/test_completion/test_completion.py b/tests/test_completion/test_completion.py index 2af209e2dc..d9115b8e77 100644 --- a/tests/test_completion/test_completion.py +++ b/tests/test_completion/test_completion.py @@ -11,7 +11,7 @@ def test_show_completion(): [ "bash", "-c", - f"{sys.executable} -m coverage run {mod.__file__} --show-completion", + f"'{sys.executable}' -m coverage run '{mod.__file__}' --show-completion", ], capture_output=True, encoding="utf-8", @@ -29,7 +29,7 @@ def test_install_completion(): [ "bash", "-c", - f"{sys.executable} -m coverage run {mod.__file__} --install-completion", + f"'{sys.executable}' -m coverage run '{mod.__file__}' --install-completion", ], capture_output=True, encoding="utf-8", @@ -38,7 +38,7 @@ def test_install_completion(): new_text = bash_completion_path.read_text() bash_completion_path.write_text(text) assert "source" in new_text - assert ".bash_completions/tutorial001.py.sh" in new_text + assert str(Path(".bash_completions/tutorial001.py.sh")) in new_text assert "completion installed in" in result.stdout assert "Completion will take effect once you restart the terminal" in result.stdout diff --git a/tests/test_completion/test_completion_install.py b/tests/test_completion/test_completion_install.py index a6ad3c9f03..d1a4695bc8 100644 --- a/tests/test_completion/test_completion_install.py +++ b/tests/test_completion/test_completion_install.py @@ -52,9 +52,9 @@ def test_completion_install_bash(): ) new_text = bash_completion_path.read_text() bash_completion_path.write_text(text) - install_source = ".bash_completions/tutorial001.py.sh" - assert install_source not in text - assert install_source in new_text + install_source = Path(".bash_completions/tutorial001.py.sh") + assert str(install_source) not in text + assert str(install_source) in new_text assert "completion installed in" in result.stdout assert "Completion will take effect once you restart the terminal" in result.stdout install_source_path = Path.home() / install_source From 773927208fbf03d30d50fc39fe2a1a18b7bd93cb Mon Sep 17 00:00:00 2001 From: github-actions Date: Thu, 2 May 2024 21:44:59 +0000 Subject: [PATCH 28/32] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/release-notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes.md b/docs/release-notes.md index 62152704e1..47f19c56e9 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -2,6 +2,7 @@ ### Internal +* ✅ 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). From 8e06b427087a882f2cdb4301344b246423c5af4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Tue, 7 May 2024 11:37:55 -0700 Subject: [PATCH 29/32] =?UTF-8?q?=F0=9F=91=B7=20Tweak=20CI=20for=20test-re?= =?UTF-8?q?distribute,=20add=20needed=20env=20vars=20for=20slim=20(#827)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test-redistribute.yml | 2 ++ requirements-tests.txt | 3 +++ 2 files changed, 5 insertions(+) diff --git a/.github/workflows/test-redistribute.yml b/.github/workflows/test-redistribute.yml index d2a33d30e2..a2d92c788e 100644 --- a/.github/workflows/test-redistribute.yml +++ b/.github/workflows/test-redistribute.yml @@ -46,6 +46,8 @@ jobs: 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-cli' }} run: | diff --git a/requirements-tests.txt b/requirements-tests.txt index 45f1904d16..510dd17ab6 100644 --- a/requirements-tests.txt +++ b/requirements-tests.txt @@ -7,3 +7,6 @@ pytest-xdist >=1.32.0,<4.0.0 pytest-sugar >=0.9.4,<0.10.0 mypy ==1.4.1 ruff ==0.2.0 +# Needed explicitly by typer-slim +rich >=10.11.0 +shellingham >=1.3.0 From 8c05c8421f4dcb3a1cf8997b072e297334b01c4a Mon Sep 17 00:00:00 2001 From: github-actions Date: Tue, 7 May 2024 18:38:18 +0000 Subject: [PATCH 30/32] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/release-notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes.md b/docs/release-notes.md index 47f19c56e9..f472aa1764 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -2,6 +2,7 @@ ### Internal +* 👷 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). From 3f4c3069f7b1d11fe126a790d7be7042d928cb87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Fri, 10 May 2024 13:55:48 -0700 Subject: [PATCH 31/32] =?UTF-8?q?=F0=9F=91=B7=20Update=20GitHub=20Actions?= =?UTF-8?q?=20to=20upload=20and=20download=20artifacts=20(#829)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-docs.yml | 2 +- .github/workflows/deploy-docs.yml | 16 +++++++--------- .github/workflows/smokeshow.yml | 10 ++++++---- .github/workflows/test.yml | 11 ++++++----- 4 files changed, 20 insertions(+), 19 deletions(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 9e448c374c..8291f117f1 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -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/** diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index 8f526d818d..206d1199e1 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -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: diff --git a/.github/workflows/smokeshow.yml b/.github/workflows/smokeshow.yml index 7afe2c0d9f..d3a975df58 100644 --- a/.github/workflows/smokeshow.yml +++ b/.github/workflows/smokeshow.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 61d114c611..91c02b7d36 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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: @@ -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 From b4b6f25e3dd4c30dc6c535715f25d281a009f56e Mon Sep 17 00:00:00 2001 From: github-actions Date: Fri, 10 May 2024 20:56:07 +0000 Subject: [PATCH 32/32] =?UTF-8?q?=F0=9F=93=9D=20Update=20release=20notes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/release-notes.md | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/release-notes.md b/docs/release-notes.md index f472aa1764..932ab22188 100644 --- a/docs/release-notes.md +++ b/docs/release-notes.md @@ -2,6 +2,7 @@ ### 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).