From 0e4a4f32127e5d57b3b5f1aadc1e767851e5fe3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Sat, 23 Mar 2024 14:54:57 -0500 Subject: [PATCH 1/6] =?UTF-8?q?=F0=9F=94=A5=20Remove=20support=20for=20Pyt?= =?UTF-8?q?hon=203.6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test.yml | 9 ++------- pyproject.toml | 3 +-- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 875263fe73..cb207b60e2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-20.04 strategy: matrix: - python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", "3.11"] + python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"] click-7: [true, false] fail-fast: false @@ -25,17 +25,12 @@ jobs: - name: Install Flit run: pip install flit - name: Install Dependencies - if: ${{ matrix.python-version != '3.6' }} run: python -m flit install --symlink - - name: Install Dependencies - if: ${{ matrix.python-version == '3.6' }} - # This doesn't install the editable install, so coverage doesn't get subprocesses - run: python -m pip install ".[test]" - name: Install Click 7 if: matrix.click-7 run: pip install "click<8.0.0" - name: Lint - if: ${{ matrix.python-version != '3.6' && matrix.click-7 == false }} + if: ${{ matrix.click-7 == false }} run: bash scripts/lint.sh - run: mkdir coverage - name: Test diff --git a/pyproject.toml b/pyproject.toml index d3c6d940ae..1d96c62021 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -21,7 +21,6 @@ classifiers = [ "Development Status :: 4 - Beta", "Intended Audience :: Developers", "Programming Language :: Python :: 3 :: Only", - "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", @@ -34,7 +33,7 @@ requires = [ "typing-extensions >= 3.7.4.3", ] description-file = "README.md" -requires-python = ">=3.6" +requires-python = ">=3.7" [tool.flit.metadata.urls] Documentation = "https://typer.tiangolo.com/" From f8ff085690b2dd233536f44ce17ae9f7a5177c9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Sat, 23 Mar 2024 14:55:17 -0500 Subject: [PATCH 2/6] =?UTF-8?q?=F0=9F=99=88=20Update=20.gitignore?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 8ab16b46cb..c4f1d90825 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,7 @@ .vscode *.pyc __pycache__ -env3.7 -env3.6 +.venv* env dist .mypy_cache From 8d679160ee525024e9d59c267f23a6916797ed17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Sat, 23 Mar 2024 14:55:43 -0500 Subject: [PATCH 3/6] =?UTF-8?q?=E2=9C=85=20Update=20tests,=20remove=20supp?= =?UTF-8?q?ort=20for=20Python=203.6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tests/test_tracebacks.py | 18 +++--------------- .../test_exceptions/test_tutorial001.py | 14 ++------------ .../test_exceptions/test_tutorial002.py | 14 ++------------ .../test_exceptions/test_tutorial003.py | 7 +------ .../test_exceptions/test_tutorial004.py | 6 +----- 5 files changed, 9 insertions(+), 50 deletions(-) diff --git a/tests/test_tracebacks.py b/tests/test_tracebacks.py index 0289e9c942..639f36e53f 100644 --- a/tests/test_tracebacks.py +++ b/tests/test_tracebacks.py @@ -17,11 +17,7 @@ def test_traceback_no_rich(): assert "typer.run(main)" in result.stderr assert "print(name + 3)" in result.stderr - # TODO: when deprecating Python 3.6, remove second option - assert ( - 'TypeError: can only concatenate str (not "int") to str' in result.stderr - or "TypeError: must be str, not int" in result.stderr - ) + assert 'TypeError: can only concatenate str (not "int") to str' in result.stderr def test_traceback_no_rich_short_disable(): @@ -37,11 +33,7 @@ def test_traceback_no_rich_short_disable(): assert "app()" in result.stderr assert "print(name + 3)" in result.stderr - # TODO: when deprecating Python 3.6, remove second option - assert ( - 'TypeError: can only concatenate str (not "int") to str' in result.stderr - or "TypeError: must be str, not int" in result.stderr - ) + assert 'TypeError: can only concatenate str (not "int") to str' in result.stderr def test_unmodified_traceback(): @@ -60,8 +52,4 @@ def test_unmodified_traceback(): ) assert "typer.main.get_command(broken_app)()" in result.stderr assert "print(name + 3)" in result.stderr - # TODO: when deprecating Python 3.6, remove second option - assert ( - 'TypeError: can only concatenate str (not "int") to str' in result.stderr - or "TypeError: must be str, not int" in result.stderr - ) + assert 'TypeError: can only concatenate str (not "int") to str' in result.stderr diff --git a/tests/test_tutorial/test_exceptions/test_tutorial001.py b/tests/test_tutorial/test_exceptions/test_tutorial001.py index 0a4590bbf5..483f4340bb 100644 --- a/tests/test_tutorial/test_exceptions/test_tutorial001.py +++ b/tests/test_tutorial/test_exceptions/test_tutorial001.py @@ -23,12 +23,7 @@ def test_traceback_rich(): assert "typer.run(main)" not in result.stderr assert "print(name + 3)" in result.stderr - - # TODO: when deprecating Python 3.6, remove second option - assert ( - 'TypeError: can only concatenate str (not "int") to str' in result.stderr - or "TypeError: must be str, not int" in result.stderr - ) + assert 'TypeError: can only concatenate str (not "int") to str' in result.stderr assert "name = 'morty'" in result.stderr @@ -45,12 +40,7 @@ def test_standard_traceback_env_var(): assert "typer.run(main)" in result.stderr assert "print(name + 3)" in result.stderr - - # TODO: when deprecating Python 3.6, remove second option - assert ( - 'TypeError: can only concatenate str (not "int") to str' in result.stderr - or "TypeError: must be str, not int" in result.stderr - ) + assert 'TypeError: can only concatenate str (not "int") to str' in result.stderr assert "name = 'morty'" not in result.stderr diff --git a/tests/test_tutorial/test_exceptions/test_tutorial002.py b/tests/test_tutorial/test_exceptions/test_tutorial002.py index 66286e064d..f65cfd6f58 100644 --- a/tests/test_tutorial/test_exceptions/test_tutorial002.py +++ b/tests/test_tutorial/test_exceptions/test_tutorial002.py @@ -23,12 +23,7 @@ def test_traceback_rich(): assert "app()" not in result.stderr assert "print(password + 3)" in result.stderr - - # TODO: when deprecating Python 3.6, remove second option - assert ( - 'TypeError: can only concatenate str (not "int") to str' in result.stderr - or "TypeError: must be str, not int" in result.stderr - ) + assert 'TypeError: can only concatenate str (not "int") to str' in result.stderr assert "name = 'morty'" not in result.stderr @@ -45,12 +40,7 @@ def test_standard_traceback_env_var(): assert "app()" in result.stderr assert "print(password + 3)" in result.stderr - - # TODO: when deprecating Python 3.6, remove second option - assert ( - 'TypeError: can only concatenate str (not "int") to str' in result.stderr - or "TypeError: must be str, not int" in result.stderr - ) + assert 'TypeError: can only concatenate str (not "int") to str' in result.stderr assert "name = 'morty'" not in result.stderr diff --git a/tests/test_tutorial/test_exceptions/test_tutorial003.py b/tests/test_tutorial/test_exceptions/test_tutorial003.py index 51cb170eba..3da786d24d 100644 --- a/tests/test_tutorial/test_exceptions/test_tutorial003.py +++ b/tests/test_tutorial/test_exceptions/test_tutorial003.py @@ -23,12 +23,7 @@ def test_traceback_rich_pretty_short_disable(): assert "app()" in result.stderr assert "print(name + 3)" in result.stderr - - # TODO: when deprecating Python 3.6, remove second option - assert ( - 'TypeError: can only concatenate str (not "int") to str' in result.stderr - or "TypeError: must be str, not int" in result.stderr - ) + assert 'TypeError: can only concatenate str (not "int") to str' in result.stderr assert "name = 'morty'" in result.stderr diff --git a/tests/test_tutorial/test_exceptions/test_tutorial004.py b/tests/test_tutorial/test_exceptions/test_tutorial004.py index bb575e4eb2..417e0d4608 100644 --- a/tests/test_tutorial/test_exceptions/test_tutorial004.py +++ b/tests/test_tutorial/test_exceptions/test_tutorial004.py @@ -23,11 +23,7 @@ def test_rich_pretty_exceptions_disable(): assert "app()" in result.stderr assert "print(name + 3)" in result.stderr - # TODO: when deprecating Python 3.6, remove second option - assert ( - 'TypeError: can only concatenate str (not "int") to str' in result.stderr - or "TypeError: must be str, not int" in result.stderr - ) + assert 'TypeError: can only concatenate str (not "int") to str' in result.stderr def test_script(): From 6a6e1b76ee8e173f75087945a68e482760068b04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Sat, 23 Mar 2024 14:55:59 -0500 Subject: [PATCH 4/6] =?UTF-8?q?=F0=9F=94=A5=20Remove=20old=20unused=20scri?= =?UTF-8?q?pt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/netlify-docs.sh | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100755 scripts/netlify-docs.sh diff --git a/scripts/netlify-docs.sh b/scripts/netlify-docs.sh deleted file mode 100755 index e77fbc39ff..0000000000 --- a/scripts/netlify-docs.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env bash -set -x -set -e -# Install pip -cd /tmp -curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py -python3.6 get-pip.py --user -cd - -# Install Flit to be able to install all -python3.6 -m pip install --user flit -# Install with Flit -python3.6 -m flit install --user --deps develop -# Finally, run mkdocs -python3.6 -m mkdocs build From 00a4a872b9a8fe09dd52636662b11687913b0ef5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Sat, 23 Mar 2024 14:56:21 -0500 Subject: [PATCH 5/6] =?UTF-8?q?=F0=9F=93=9D=20Update=20mentions=20of=20Pyt?= =?UTF-8?q?hon=203.6=20in=20docs=20to=20be=20Python=203.7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 6 ++-- docs/features.md | 2 +- docs/index.md | 6 ++-- docs/tutorial/arguments/default.md | 8 ++--- docs/tutorial/arguments/envvar.md | 12 +++---- docs/tutorial/arguments/help.md | 32 ++++++++--------- docs/tutorial/commands/help.md | 18 +++++----- docs/tutorial/commands/options.md | 4 +-- .../arguments-with-multiple-values.md | 4 +-- .../multiple-values/multiple-options.md | 8 ++--- .../options-with-multiple-values.md | 4 +-- docs/tutorial/options-autocompletion.md | 36 +++++++++---------- docs/tutorial/options/callback-and-context.md | 16 ++++----- docs/tutorial/options/help.md | 16 ++++----- docs/tutorial/options/name.md | 20 +++++------ docs/tutorial/options/password.md | 8 ++--- docs/tutorial/options/prompt.md | 12 +++---- docs/tutorial/options/required.md | 6 ++-- docs/tutorial/options/version.md | 12 +++---- docs/tutorial/package.md | 26 +++++++------- docs/tutorial/parameter-types/bool.md | 16 ++++----- docs/tutorial/parameter-types/custom-types.md | 8 ++--- docs/tutorial/parameter-types/datetime.md | 4 +-- docs/tutorial/parameter-types/enum.md | 8 ++--- docs/tutorial/parameter-types/file.md | 20 +++++------ docs/tutorial/parameter-types/number.md | 12 +++---- docs/tutorial/parameter-types/path.md | 8 ++--- docs/tutorial/testing.md | 6 ++-- 28 files changed, 167 insertions(+), 171 deletions(-) diff --git a/README.md b/README.md index e5673a9a87..303774709f 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ --- -Typer is a library for building CLI applications that users will **love using** and developers will **love creating**. Based on Python 3.6+ type hints. +Typer is a library for building CLI applications that users will **love using** and developers will **love creating**. Based on Python type hints. The key features are: @@ -46,8 +46,6 @@ And it's intended to be the FastAPI of CLIs. ## Requirements -Python 3.6+ - **Typer** stands on the shoulders of a giant. Its only internal dependency is Click. ## Installation @@ -277,7 +275,7 @@ You do that with standard modern Python types. You don't have to learn a new syntax, the methods or classes of a specific library, etc. -Just standard **Python 3.6+**. +Just standard **Python**. For example, for an `int`: diff --git a/docs/features.md b/docs/features.md index 6b2bbb2b51..dc41191173 100644 --- a/docs/features.md +++ b/docs/features.md @@ -8,7 +8,7 @@ It follows the same design and ideas. If you know **FastAPI**, you already know ## Just Modern Python -It's all based on standard **Python 3.6 type** declarations. No new syntax to learn. Just standard modern Python. +It's all based on standard **Python type** declarations. No new syntax to learn. Just standard modern Python. If you need a 2 minute refresher of how to use Python types (even if you don't use FastAPI or Typer), check the FastAPI tutorial section: Python types intro. diff --git a/docs/index.md b/docs/index.md index e5673a9a87..303774709f 100644 --- a/docs/index.md +++ b/docs/index.md @@ -26,7 +26,7 @@ --- -Typer is a library for building CLI applications that users will **love using** and developers will **love creating**. Based on Python 3.6+ type hints. +Typer is a library for building CLI applications that users will **love using** and developers will **love creating**. Based on Python type hints. The key features are: @@ -46,8 +46,6 @@ And it's intended to be the FastAPI of CLIs. ## Requirements -Python 3.6+ - **Typer** stands on the shoulders of a giant. Its only internal dependency is Click. ## Installation @@ -277,7 +275,7 @@ You do that with standard modern Python types. You don't have to learn a new syntax, the methods or classes of a specific library, etc. -Just standard **Python 3.6+**. +Just standard **Python**. For example, for an `int`: diff --git a/docs/tutorial/arguments/default.md b/docs/tutorial/arguments/default.md index c85bac0c56..8a8f98017f 100644 --- a/docs/tutorial/arguments/default.md +++ b/docs/tutorial/arguments/default.md @@ -6,13 +6,13 @@ That way the *CLI argument* will be optional *and also* have a default value. We can also use `typer.Argument()` to make a *CLI argument* have a default value other than `None`: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="5" {!> ../docs_src/arguments/default/tutorial001_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -60,13 +60,13 @@ Hello Camila And we can even make the default value be dynamically generated by passing a function as the `default_factory` argument: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="7-8 11" {!> ../docs_src/arguments/default/tutorial002_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. diff --git a/docs/tutorial/arguments/envvar.md b/docs/tutorial/arguments/envvar.md index 18e8f08124..57d49e84bf 100644 --- a/docs/tutorial/arguments/envvar.md +++ b/docs/tutorial/arguments/envvar.md @@ -2,13 +2,13 @@ You can also configure a *CLI argument* to read a value from an environment vari To do that, use the `envvar` parameter for `typer.Argument()`: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="5" {!> ../docs_src/arguments/envvar/tutorial001_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -60,13 +60,13 @@ Hello Mr. Czernobog You are not restricted to a single environment variable, you can declare a list of environment variables that could be used to get a value if it was not passed in the command line: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="6" {!> ../docs_src/arguments/envvar/tutorial002_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -108,13 +108,13 @@ Hello Mr. Anubis By default, environment variables used will be shown in the help text, but you can disable them with `show_envvar=False`: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="7" {!> ../docs_src/arguments/envvar/tutorial003_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. diff --git a/docs/tutorial/arguments/help.md b/docs/tutorial/arguments/help.md index 34ec101100..bbbb5e0eff 100644 --- a/docs/tutorial/arguments/help.md +++ b/docs/tutorial/arguments/help.md @@ -12,13 +12,13 @@ Now that you also know how to use `typer.Argument()`, let's use it to add docume You can use the `help` parameter to add a help text for a *CLI argument*: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="5" {!> ../docs_src/arguments/help/tutorial001_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -50,13 +50,13 @@ Options: And of course, you can also combine that `help` with the docstring: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="5-8" {!> ../docs_src/arguments/help/tutorial002_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -90,13 +90,13 @@ Options: If you have a *CLI argument* with a default value, like `"World"`: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="5" {!> ../docs_src/arguments/help/tutorial003_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -128,13 +128,13 @@ Options: But you can disable that if you want to, with `show_default=False`: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="7" {!> ../docs_src/arguments/help/tutorial004_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -173,13 +173,13 @@ Options: You can use the same `show_default` to pass a custom string (instead of a `bool`) to customize the default value to be shown in the help text: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="9" {!> ../docs_src/arguments/help/tutorial005_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -231,13 +231,13 @@ But you can customize it with the `metavar` parameter for `typer.Argument()`. For example, let's say you don't want to have the default of `NAME`, you want to have `username`, in lowercase, and you really want ✨ emojis ✨ everywhere: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="5" {!> ../docs_src/arguments/help/tutorial006_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -270,13 +270,13 @@ You might want to show the help information for *CLI arguments* in different pan If you have installed Rich as described in the docs for [Printing and Colors](../printing.md){.internal-link target=_blank}, you can set the `rich_help_panel` parameter to the name of the panel where you want this *CLI argument* to be shown: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="8 12" {!> ../docs_src/arguments/help/tutorial007_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -326,13 +326,13 @@ If you want, you can make a *CLI argument* **not** show up in the `Arguments` se You will probably not want to do this normally, but it's possible: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="5" {!> ../docs_src/arguments/help/tutorial008_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. diff --git a/docs/tutorial/commands/help.md b/docs/tutorial/commands/help.md index 15784fadfd..0310b36d41 100644 --- a/docs/tutorial/commands/help.md +++ b/docs/tutorial/commands/help.md @@ -2,13 +2,13 @@ The same as before, you can add help for the commands in the docstrings and the And the `typer.Typer()` application receives a parameter `help` that you can pass with the main help text for your CLI program: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="4 9-11 22 26-30 43 47-51 60-62" {!> ../docs_src/commands/help/tutorial001_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -201,13 +201,13 @@ Then you can use more formatting in the docstrings and the `help` parameter for If you set `rich_markup_mode="rich"` when creating the `typer.Typer()` app, you will be able to use Rich Console Markup in the docstring, and even in the help for the *CLI arguments* and options: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="4 10 14-16 21 24 27" {!> ../docs_src/commands/help/tutorial004_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -277,13 +277,13 @@ $ python main.py delete --help If you set `rich_markup_mode="markdown"` when creating the `typer.Typer()` app, you will be able to use Markdown in the docstring: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="4 9 12-20 25 27-28" {!> ../docs_src/commands/help/tutorial005_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -363,7 +363,7 @@ If you installed ../docs_src/commands/help/tutorial006.py!} @@ -408,13 +408,13 @@ The same way, you can configure the panels for *CLI arguments* and *CLI options* And of course, in the same application you can also set the `rich_help_panel` for commands. -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="15 21 27 37" {!> ../docs_src/commands/help/tutorial007_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. diff --git a/docs/tutorial/commands/options.md b/docs/tutorial/commands/options.md index 872e81be37..5d658477d8 100644 --- a/docs/tutorial/commands/options.md +++ b/docs/tutorial/commands/options.md @@ -2,13 +2,13 @@ Commands can also have their own *CLI options*. In fact, each command can have different *CLI arguments* and *CLI options*: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="8 14-17 27-29 38" {!> ../docs_src/commands/options/tutorial001_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. diff --git a/docs/tutorial/multiple-values/arguments-with-multiple-values.md b/docs/tutorial/multiple-values/arguments-with-multiple-values.md index d55abfde52..891ec4fbf7 100644 --- a/docs/tutorial/multiple-values/arguments-with-multiple-values.md +++ b/docs/tutorial/multiple-values/arguments-with-multiple-values.md @@ -31,13 +31,13 @@ woohoo! If you want a specific number of values and types, you can use a tuple, and it can even have default values: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="8-10" {!> ../docs_src/multiple_values/arguments_with_multiple_values/tutorial002_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. diff --git a/docs/tutorial/multiple-values/multiple-options.md b/docs/tutorial/multiple-values/multiple-options.md index d61bee1588..a7c5c88fb6 100644 --- a/docs/tutorial/multiple-values/multiple-options.md +++ b/docs/tutorial/multiple-values/multiple-options.md @@ -4,13 +4,13 @@ For example, let's say you want to accept several users in a single execution. For this, use the standard Python `typing.List` to declare it as a `list` of `str`: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="1 7" {!> ../docs_src/multiple_values/multiple_options/tutorial001_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -51,13 +51,13 @@ Processing user: Morty The same way, you can use other types and they will be converted by **Typer** to their declared type: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="7" {!> ../docs_src/multiple_values/multiple_options/tutorial002_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. diff --git a/docs/tutorial/multiple-values/options-with-multiple-values.md b/docs/tutorial/multiple-values/options-with-multiple-values.md index d710966a99..78083a4e0a 100644 --- a/docs/tutorial/multiple-values/options-with-multiple-values.md +++ b/docs/tutorial/multiple-values/options-with-multiple-values.md @@ -4,13 +4,13 @@ You can set the number of values and types to anything you want, but it has to b For this, use the standard Python `typing.Tuple`: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="1 7" {!> ../docs_src/multiple_values/options_with_multiple_values/tutorial001_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. diff --git a/docs/tutorial/options-autocompletion.md b/docs/tutorial/options-autocompletion.md index b76d09545b..a46c713172 100644 --- a/docs/tutorial/options-autocompletion.md +++ b/docs/tutorial/options-autocompletion.md @@ -14,13 +14,13 @@ To check it quickly without creating a new Python package, install [Typer CLI](. Then let's create small example program: -=== "Python 3.6+" +=== "Python 3.7+" ```Python {!> ../docs_src/options_autocompletion/tutorial001_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -61,13 +61,13 @@ Right now we get completion for the *CLI option* names, but not for the values. We can provide completion for the values creating an `autocompletion` function, similar to the `callback` functions from [CLI Option Callback and Context](./options/callback-and-context.md){.internal-link target=_blank}: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="5-6 15" {!> ../docs_src/options_autocompletion/tutorial002_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -103,13 +103,13 @@ Modify the `complete_name()` function to receive a parameter of type `str`, it w Then we can check and return only the values that start with the incomplete value from the command line: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="7-12" {!> ../docs_src/options_autocompletion/tutorial003_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -152,13 +152,13 @@ In the `complete_name()` function, instead of providing one `str` per completion So, in the end, we return a `list` of `tuples` of `str`: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="4-8 11-17" {!> ../docs_src/options_autocompletion/tutorial004_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -200,13 +200,13 @@ Instead of creating and returning a list with values (`str` or `tuple`), we can That way our function will be a generator that **Typer** (actually Click) can iterate: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="11-14" {!> ../docs_src/options_autocompletion/tutorial005_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -240,13 +240,13 @@ So, we will allow multiple `--name` *CLI options*. For this we use a `List` of `str`: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="9-14" {!> ../docs_src/options_autocompletion/tutorial006_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -278,13 +278,13 @@ But you can access the context by declaring a function parameter of type `typer. And from that context you can get the current values for each parameter. -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="13-14 16" {!> ../docs_src/options_autocompletion/tutorial007_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -358,13 +358,13 @@ You can print to "standard error" with a **Rich** `Console(stderr=True)`. Using `stderr=True` tells **Rich** that the output should be shown in "standard error". -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="13 16-17" {!> ../docs_src/options_autocompletion/tutorial008_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -410,13 +410,13 @@ Sebastian -- The type hints guy. Of course, you can declare everything if you need it, the context, the raw *CLI parameters*, and the incomplete `str`: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="16" {!> ../docs_src/options_autocompletion/tutorial009_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. diff --git a/docs/tutorial/options/callback-and-context.md b/docs/tutorial/options/callback-and-context.md index 11969f2aa2..c6c80114c7 100644 --- a/docs/tutorial/options/callback-and-context.md +++ b/docs/tutorial/options/callback-and-context.md @@ -6,13 +6,13 @@ In those cases you can use a *CLI parameter* callback function. For example, you could do some validation before the rest of the code is executed. -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="5-8 11" {!> ../docs_src/options/callback/tutorial001_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -105,13 +105,13 @@ But the main **important point** is that it is all based on values printed by yo Let's say that when the callback is running, we want to show a message saying that it's validating the name: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="6" {!> ../docs_src/options/callback/tutorial002_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -153,13 +153,13 @@ But you can access the context by declaring a function parameter of type `typer. The "context" has some additional data about the current execution of your program: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="5-7" {!> ../docs_src/options/callback/tutorial003_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -198,13 +198,13 @@ Hello Camila The same way you can access the `typer.Context` by declaring a function parameter with its value, you can declare another function parameter with type `typer.CallbackParam` to get the specific Click `Parameter` object. -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="5 8" {!> ../docs_src/options/callback/tutorial004_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. diff --git a/docs/tutorial/options/help.md b/docs/tutorial/options/help.md index 13267e7fe6..772daaf1bb 100644 --- a/docs/tutorial/options/help.md +++ b/docs/tutorial/options/help.md @@ -2,13 +2,13 @@ You already saw how to add a help text for *CLI arguments* with the `help` param Let's now do the same for *CLI options*: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="7-8" {!> ../docs_src/options/help/tutorial001_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -67,13 +67,13 @@ The same as with *CLI arguments*, you can put the help for some *CLI options* in If you have installed Rich as described in the docs for [Printing and Colors](../printing.md){.internal-link target=_blank}, you can set the `rich_help_panel` parameter to the name of the panel you want for each *CLI option*: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="11 17" {!> ../docs_src/options/help/tutorial002_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -126,13 +126,13 @@ If you are in a hurry you can jump there, but otherwise, it would be better to c You can tell Typer to not show the default value in the help text with `show_default=False`: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="5" {!> ../docs_src/options/help/tutorial003_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -173,13 +173,13 @@ Options: You can use the same `show_default` to pass a custom string (instead of a `bool`) to customize the default value to be shown in the help text: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="7" {!> ../docs_src/options/help/tutorial004_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. diff --git a/docs/tutorial/options/name.md b/docs/tutorial/options/name.md index 1791f468a8..2392edcaa5 100644 --- a/docs/tutorial/options/name.md +++ b/docs/tutorial/options/name.md @@ -26,7 +26,7 @@ Let's say the function parameter name is `user_name` as above, but you want the You can pass the *CLI option* name that you want to have in the following positional argument passed to `typer.Option()`: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="5" {!> ../docs_src/options/name/tutorial001_an.py!} @@ -34,7 +34,7 @@ You can pass the *CLI option* name that you want to have in the following positi Here you are passing the string `"--name"` as the first positional argument to `typer.Option()`. -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -194,13 +194,13 @@ You can overwrite the *CLI option* name to use as in the previous example, but y For example, extending the previous example, let's add a *CLI option* short name `-n`: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="5" {!> ../docs_src/options/name/tutorial002_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -238,13 +238,13 @@ Hello Camila If you only declare a short name like `-n` then that will be the only *CLI option* name. And neither `--name` nor `--user-name` will be available. -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="5" {!> ../docs_src/options/name/tutorial003_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -279,13 +279,13 @@ Hello Camila Continuing with the example above, as **Typer** allows you to declare a *CLI option* as having only a short name, if you want to have the default long name plus a short name, you have to declare both explicitly: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="5" {!> ../docs_src/options/name/tutorial004_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -326,13 +326,13 @@ You can create multiple short names and use them together. You don't have to do anything special for it to work (apart from declaring those short versions): -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="6-7" {!> ../docs_src/options/name/tutorial005_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. diff --git a/docs/tutorial/options/password.md b/docs/tutorial/options/password.md index 96c2a51cb8..abe33e5411 100644 --- a/docs/tutorial/options/password.md +++ b/docs/tutorial/options/password.md @@ -1,12 +1,12 @@ Apart from having a prompt, you can make a *CLI option* have a `confirmation_prompt=True`: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="7" {!> ../docs_src/options/password/tutorial001_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -41,13 +41,13 @@ You can achieve the same using `hide_input=True`. And if you combine it with `confirmation_prompt=True` you can easily receive a password with double confirmation: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="8" {!> ../docs_src/options/password/tutorial002_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. diff --git a/docs/tutorial/options/prompt.md b/docs/tutorial/options/prompt.md index f77e4db491..73a857a331 100644 --- a/docs/tutorial/options/prompt.md +++ b/docs/tutorial/options/prompt.md @@ -1,12 +1,12 @@ It's also possible to, instead of just showing an error, ask for the missing value with `prompt=True`: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="5" {!> ../docs_src/options/prompt/tutorial001_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -35,13 +35,13 @@ Hello Camila Gutiérrez You can also set a custom prompt, passing the string that you want to use instead of just `True`: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="7" {!> ../docs_src/options/prompt/tutorial002_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -74,13 +74,13 @@ You can do it passing the parameter `confirmation_prompt=True`. Let's say it's a CLI app to delete a project: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="6" {!> ../docs_src/options/prompt/tutorial003_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. diff --git a/docs/tutorial/options/required.md b/docs/tutorial/options/required.md index 489bf3b9cd..311fbd93ae 100644 --- a/docs/tutorial/options/required.md +++ b/docs/tutorial/options/required.md @@ -11,7 +11,7 @@ To make a *CLI option* required, you can put `typer.Option()` inside of `Annotat Let's make `--lastname` a required *CLI option*: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="5" {!> ../docs_src/options/required/tutorial001_an.py!} @@ -19,7 +19,7 @@ Let's make `--lastname` a required *CLI option*: The same way as with `typer.Argument()`, the old style of using the function parameter default value is also supported, in that case you would just not pass anything to the `default` parameter. -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" ```Python hl_lines="4" {!> ../docs_src/options/required/tutorial001.py!} @@ -27,7 +27,7 @@ The same way as with `typer.Argument()`, the old style of using the function par Or you can explictily pass `...` to `typer.Option(default=...)`: -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" ```Python hl_lines="4" {!> ../docs_src/options/required/tutorial002.py!} diff --git a/docs/tutorial/options/version.md b/docs/tutorial/options/version.md index 0e5ff716c7..497a30262c 100644 --- a/docs/tutorial/options/version.md +++ b/docs/tutorial/options/version.md @@ -6,13 +6,13 @@ It would show the version of your CLI program and then it would terminate it. Ev Let's see a first version of how it could look like: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="9-12 17-19" {!> ../docs_src/options/version/tutorial001_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -65,13 +65,13 @@ Awesome CLI Version: 0.1.0 But now let's say that the `--name` *CLI option* that we declared before `--version` is required, and it has a callback that could exit the program: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="15-17 22-24" {!> ../docs_src/options/version/tutorial002_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -108,13 +108,13 @@ For those cases, we can mark a *CLI parameter* (a *CLI option* or *CLI argument* That will tell **Typer** (actually Click) that it should process this *CLI parameter* before the others: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="23-26" {!> ../docs_src/options/version/tutorial003_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. diff --git a/docs/tutorial/package.md b/docs/tutorial/package.md index e5a63312d1..c26ff0087c 100644 --- a/docs/tutorial/package.md +++ b/docs/tutorial/package.md @@ -52,7 +52,7 @@ Add `typer[all]` to your dependencies: $ poetry add "typer[all]" // It creates a virtual environment for your project -Creating virtualenv rick-portal-gun-w31dJa0b-py3.6 in /home/rick/.cache/pypoetry/virtualenvs +Creating virtualenv rick-portal-gun-w31dJa0b-py3.10 in /home/rick/.cache/pypoetry/virtualenvs Using version ^0.1.0 for typer Updating dependencies @@ -83,7 +83,7 @@ Package operations: 15 installs, 0 updates, 0 removals // Activate that new virtual environment $ poetry shell -Spawning shell within /home/rick/.cache/pypoetry/virtualenvs/rick-portal-gun-w31dJa0b-py3.6 +Spawning shell within /home/rick/.cache/pypoetry/virtualenvs/rick-portal-gun-w31dJa0b-py3.10 // Open an editor using this new environment, for example VS Code $ code ./ @@ -174,7 +174,7 @@ description = "" authors = ["Rick Sanchez "] [tool.poetry.dependencies] -python = "^3.6" +python = "^3.10" typer = {extras = ["all"], version = "^0.1.0"} [tool.poetry.dev-dependencies] @@ -198,7 +198,7 @@ authors = ["Rick Sanchez "] readme = "README.md" [tool.poetry.dependencies] -python = "^3.6" +python = "^3.10" typer = {extras = ["all"], version = "^0.1.0"} [tool.poetry.dev-dependencies] @@ -229,7 +229,7 @@ readme = "README.md" rick-portal-gun = "rick_portal_gun.main:app" [tool.poetry.dependencies] -python = "^3.6" +python = "^3.10" typer = {extras = ["all"], version = "^0.1.0"} [tool.poetry.dev-dependencies] @@ -302,7 +302,7 @@ Your package is installed in the environment created by Poetry, but you can alre $ which rick-portal-gun // You get the one from your environment -/home/rick/.cache/pypoetry/virtualenvs/rick-portal-gun-w31dJa0b-py3.6/bin/rick-portal-gun +/home/rick/.cache/pypoetry/virtualenvs/rick-portal-gun-w31dJa0b-py3.10/bin/rick-portal-gun // Try it $ rick-portal-gun @@ -660,8 +660,8 @@ Found existing installation: rick-portal-gun 0.1.0 Uninstalling rick-portal-gun-0.1.0: Would remove: /home/user/.local/bin/rick-portal-gun - /home/user/.local/lib/python3.6/site-packages/rick_portal_gun-0.1.0.dist-info/* - /home/user/.local/lib/python3.6/site-packages/rick_portal_gun/* + /home/user/.local/lib/python3.10/site-packages/rick_portal_gun-0.1.0.dist-info/* + /home/user/.local/lib/python3.10/site-packages/rick_portal_gun/* # Proceed (y/n)? $ y Successfully uninstalled rick-portal-gun-0.1.0 ``` @@ -678,10 +678,10 @@ $ pip install --user rick-portal-gun // Notice that it says "Downloading" 🚀 Collecting rick-portal-gun Downloading rick_portal_gun-0.1.0-py3-none-any.whl (1.8 kB) -Requirement already satisfied: typer[all]<0.0.12,>=0.0.11 in ./.local/lib/python3.6/site-packages (from rick-portal-gun) (0.0.11) -Requirement already satisfied: click<7.2.0,>=7.1.1 in ./anaconda3/lib/python3.6/site-packages (from typer[all]<0.0.12,>=0.0.11->rick-portal-gun) (7.1.1) -Requirement already satisfied: colorama; extra == "all" in ./anaconda3/lib/python3.6/site-packages (from typer[all]<0.0.12,>=0.0.11->rick-portal-gun) (0.4.3) -Requirement already satisfied: shellingham; extra == "all" in ./anaconda3/lib/python3.6/site-packages (from typer[all]<0.0.12,>=0.0.11->rick-portal-gun) (1.3.1) +Requirement already satisfied: typer[all]<0.0.12,>=0.0.11 in ./.local/lib/python3.10/site-packages (from rick-portal-gun) (0.0.11) +Requirement already satisfied: click<7.2.0,>=7.1.1 in ./anaconda3/lib/python3.10/site-packages (from typer[all]<0.0.12,>=0.0.11->rick-portal-gun) (7.1.1) +Requirement already satisfied: colorama; extra == "all" in ./anaconda3/lib/python3.10/site-packages (from typer[all]<0.0.12,>=0.0.11->rick-portal-gun) (0.4.3) +Requirement already satisfied: shellingham; extra == "all" in ./anaconda3/lib/python3.10/site-packages (from typer[all]<0.0.12,>=0.0.11->rick-portal-gun) (1.3.1) Installing collected packages: rick-portal-gun Successfully installed rick-portal-gun-0.1.0 ``` @@ -739,7 +739,7 @@ readme = "README.md" rick-portal-gun = "rick_portal_gun.main:app" [tool.poetry.dependencies] -python = "^3.6" +python = "^3.10" typer = {extras = ["all"], version = "^0.1.0"} [tool.poetry.dev-dependencies] diff --git a/docs/tutorial/parameter-types/bool.md b/docs/tutorial/parameter-types/bool.md index f89772db4b..4d074e5d5b 100644 --- a/docs/tutorial/parameter-types/bool.md +++ b/docs/tutorial/parameter-types/bool.md @@ -8,13 +8,13 @@ Let's say that we want a `--force` *CLI option* only, we want to discard `--no-f We can do that by specifying the exact name we want: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="5" {!> ../docs_src/parameter_types/bool/tutorial001_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -69,13 +69,13 @@ We might want to instead have `--accept` and `--reject`. We can do that by passing a single `str` with the 2 names for the `bool` *CLI option* separated by `/`: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="7" {!> ../docs_src/parameter_types/bool/tutorial002_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -123,13 +123,13 @@ The same way, you can declare short versions of the names for these *CLI options For example, let's say we want `-f` for `--force` and `-F` for `--no-force`: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="5" {!> ../docs_src/parameter_types/bool/tutorial003_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -172,13 +172,13 @@ If you want to (although it might not be a good idea), you can declare only *CLI To do that, use a space and a single `/` and pass the negative name after: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="5" {!> ../docs_src/parameter_types/bool/tutorial004_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. diff --git a/docs/tutorial/parameter-types/custom-types.md b/docs/tutorial/parameter-types/custom-types.md index 56acbe4a5b..fd0d395832 100644 --- a/docs/tutorial/parameter-types/custom-types.md +++ b/docs/tutorial/parameter-types/custom-types.md @@ -11,13 +11,13 @@ There are two ways to achieve this: `typer.Argument` and `typer.Option` can create custom parameter types with a `parser` callable. -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="13-14 18-19" {!> ../docs_src/parameter_types/custom_types/tutorial001_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -32,13 +32,13 @@ The function (or callable) that you pass to the parameter `parser` will receive If you already have a Click Custom Type, you can use it in `typer.Argument()` and `typer.Option()` with the `click_type` parameter. -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="14-18 22-25" {!> ../docs_src/parameter_types/custom_types/tutorial002_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. diff --git a/docs/tutorial/parameter-types/datetime.md b/docs/tutorial/parameter-types/datetime.md index fe1f18dbf5..4f59811e89 100644 --- a/docs/tutorial/parameter-types/datetime.md +++ b/docs/tutorial/parameter-types/datetime.md @@ -58,13 +58,13 @@ For example, let's imagine that you want to accept an ISO formatted datetime, bu ...It's a crazy example, but let's say you also needed that strange format: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="11" {!> ../docs_src/parameter_types/datetime/tutorial002_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. diff --git a/docs/tutorial/parameter-types/enum.md b/docs/tutorial/parameter-types/enum.md index 1f5c2fe734..0751aadb35 100644 --- a/docs/tutorial/parameter-types/enum.md +++ b/docs/tutorial/parameter-types/enum.md @@ -51,13 +51,13 @@ Error: Invalid value for '--network': invalid choice: CONV. (choose from simple, You can make an `Enum` (choice) *CLI parameter* be case-insensitive with the `case_sensitive` parameter: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="15" {!> ../docs_src/parameter_types/enum/tutorial002_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -88,13 +88,13 @@ Training neural network of type: lstm A *CLI parameter* can also take a list of `Enum` values: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="14" {!> ../docs_src/parameter_types/enum/tutorial003_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. diff --git a/docs/tutorial/parameter-types/file.md b/docs/tutorial/parameter-types/file.md index d7dadeba42..3bb1cf51ce 100644 --- a/docs/tutorial/parameter-types/file.md +++ b/docs/tutorial/parameter-types/file.md @@ -42,13 +42,13 @@ content = b"la cig\xc3\xbce\xc3\xb1a trae al ni\xc3\xb1o" You will get all the correct editor support, attributes, methods, etc for the file-like object:` -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="5" {!> ../docs_src/parameter_types/file/tutorial001_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -82,13 +82,13 @@ Config line: some more settings For writing text, you can use `typer.FileTextWrite`: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="5-6" {!> ../docs_src/parameter_types/file/tutorial002_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -136,13 +136,13 @@ You will receive `bytes` from it. It's useful for reading binary files like images: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="5" {!> ../docs_src/parameter_types/file/tutorial003_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -178,13 +178,13 @@ Have in mind that you have to pass `bytes` to its `.write()` method, not `str`. If you have a `str`, you have to encode it first to get `bytes`. -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="5" {!> ../docs_src/parameter_types/file/tutorial004_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -241,13 +241,13 @@ You can override the `mode` from the defaults above. For example, you could use `mode="a"` to write "appending" to the same file: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="5" {!> ../docs_src/parameter_types/file/tutorial005_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. diff --git a/docs/tutorial/parameter-types/number.md b/docs/tutorial/parameter-types/number.md index 2bf6b423ca..eab91f627f 100644 --- a/docs/tutorial/parameter-types/number.md +++ b/docs/tutorial/parameter-types/number.md @@ -1,12 +1,12 @@ You can define numeric validations with `max` and `min` values for `int` and `float` *CLI parameters*: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="6-8" {!> ../docs_src/parameter_types/number/tutorial001_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -84,13 +84,13 @@ You might want to, instead of showing an error, use the closest minimum or maxim You can do it with the `clamp` parameter: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="6-8" {!> ../docs_src/parameter_types/number/tutorial002_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -126,13 +126,13 @@ ID is 5 You can make a *CLI option* work as a counter with the `counter` parameter: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="5" {!> ../docs_src/parameter_types/number/tutorial003_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. diff --git a/docs/tutorial/parameter-types/path.md b/docs/tutorial/parameter-types/path.md index 44ca292c6a..f6617db4d8 100644 --- a/docs/tutorial/parameter-types/path.md +++ b/docs/tutorial/parameter-types/path.md @@ -2,13 +2,13 @@ You can declare a *CLI parameter* to be a standard Python ../docs_src/parameter_types/path/tutorial001_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. @@ -70,13 +70,13 @@ You can perform several validations for `Path` *CLI parameters*: For example: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="11-16" {!> ../docs_src/parameter_types/path/tutorial002_an.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. diff --git a/docs/tutorial/testing.md b/docs/tutorial/testing.md index 6c14ab22d9..2df3460ba4 100644 --- a/docs/tutorial/testing.md +++ b/docs/tutorial/testing.md @@ -85,7 +85,7 @@ Then you can call `pytest` in your directory and it will run your tests: $ pytest ================ test session starts ================ -platform linux -- Python 3.6.9, pytest-5.3.5, py-1.8.1, pluggy-0.13.1 +platform linux -- Python 3.10, pytest-5.3.5, py-1.8.1, pluggy-0.13.1 rootdir: /home/user/code/superawesome-cli/app plugins: forked-1.1.3, xdist-1.31.0, cov-2.8.1 collected 1 item @@ -103,13 +103,13 @@ test_main.py . If you have a CLI with prompts, like: -=== "Python 3.6+" +=== "Python 3.7+" ```Python hl_lines="8" {!> ../docs_src/testing/app02_an/main.py!} ``` -=== "Python 3.6+ non-Annotated" +=== "Python 3.7+ non-Annotated" !!! tip Prefer to use the `Annotated` version if possible. From acfc565e18c71906023665d635b4fee637f00e4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebasti=C3=A1n=20Ram=C3=ADrez?= Date: Sat, 23 Mar 2024 15:26:22 -0500 Subject: [PATCH 6/6] =?UTF-8?q?=E2=8F=AA=EF=B8=8F=20Revert=20removing=20co?= =?UTF-8?q?nfigs=20from=20master=20merge?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/test.yml | 60 +++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9a868f1530..5dd3c73170 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -32,4 +32,62 @@ jobs: if: matrix.click-version == 'click-7' run: pip install "click<8.0.0" - name: Lint - if: ${{ matrix.click-version == 'click-8' }} + if: ${{ matrix.click-version == 'click-8' }} + run: bash scripts/lint.sh + - run: mkdir coverage + - name: Test + run: bash scripts/test.sh + env: + COVERAGE_FILE: coverage/.coverage.${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.click-version }} + CONTEXT: ${{ runner.os }}-py${{ matrix.python-version }}-${{ matrix.click-version }} + - name: Store coverage files + uses: actions/upload-artifact@v3 + with: + name: coverage + path: coverage + + coverage-combine: + needs: [test] + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + with: + python-version: '3.8' + + - name: Get coverage files + uses: actions/download-artifact@v3 + with: + name: coverage + path: coverage + + - 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 + with: + name: coverage-html + path: htmlcov + + # https://github.com/marketplace/actions/alls-green#why + check: # This job does nothing and is only used for the branch protection + if: always() + needs: + - coverage-combine + runs-on: ubuntu-latest + steps: + - name: Dump GitHub context + env: + GITHUB_CONTEXT: ${{ toJson(github) }} + run: echo "$GITHUB_CONTEXT" + - name: Decide whether the needed jobs succeeded or failed + uses: re-actors/alls-green@release/v1 + with: + jobs: ${{ toJSON(needs) }}