diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_name/test_tutorial003_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_name/test_tutorial003_an.py new file mode 100644 index 0000000000000000000000000000000000000000..eb15ad2a6be8035a5bd7c61c44bdcbc8563ec7c3 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_name/test_tutorial003_an.py @@ -0,0 +1,36 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.options.name import tutorial003_an as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_option_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "-n" in result.output + assert "TEXT" in result.output + assert "--user-name" not in result.output + assert "--name" not in result.output + + +def test_call(): + result = runner.invoke(app, ["-n", "Camila"]) + assert result.exit_code == 0 + assert "Hello Camila" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_name/test_tutorial004.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_name/test_tutorial004.py new file mode 100644 index 0000000000000000000000000000000000000000..93253ac5e5ea3c80a717634fc0768f3d6ca90812 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_name/test_tutorial004.py @@ -0,0 +1,42 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.options.name import tutorial004 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_option_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "-n" in result.output + assert "--user-name" in result.output + assert "TEXT" in result.output + assert "--name" not in result.output + + +def test_call(): + result = runner.invoke(app, ["-n", "Camila"]) + assert result.exit_code == 0 + assert "Hello Camila" in result.output + + +def test_call_long(): + result = runner.invoke(app, ["--user-name", "Camila"]) + assert result.exit_code == 0 + assert "Hello Camila" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_name/test_tutorial004_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_name/test_tutorial004_an.py new file mode 100644 index 0000000000000000000000000000000000000000..f3cc9d958d8d9cfccdf3ab0315a541c8b788e8a5 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_name/test_tutorial004_an.py @@ -0,0 +1,42 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.options.name import tutorial004_an as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_option_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "-n" in result.output + assert "--user-name" in result.output + assert "TEXT" in result.output + assert "--name" not in result.output + + +def test_call(): + result = runner.invoke(app, ["-n", "Camila"]) + assert result.exit_code == 0 + assert "Hello Camila" in result.output + + +def test_call_long(): + result = runner.invoke(app, ["--user-name", "Camila"]) + assert result.exit_code == 0 + assert "Hello Camila" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_name/test_tutorial005.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_name/test_tutorial005.py new file mode 100644 index 0000000000000000000000000000000000000000..fa70682bc894994d72b039c51be914b15e0f88c5 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_name/test_tutorial005.py @@ -0,0 +1,54 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.options.name import tutorial005 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_option_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "-n" in result.output + assert "--name" in result.output + assert "TEXT" in result.output + assert "-f" in result.output + assert "--formal" in result.output + + +def test_call(): + result = runner.invoke(app, ["-n", "Camila"]) + assert result.exit_code == 0 + assert "Hello Camila" in result.output + + +def test_call_formal(): + result = runner.invoke(app, ["-n", "Camila", "-f"]) + assert result.exit_code == 0 + assert "Good day Ms. Camila." in result.output + + +def test_call_formal_condensed(): + result = runner.invoke(app, ["-fn", "Camila"]) + assert result.exit_code == 0 + assert "Good day Ms. Camila." in result.output + + +def test_call_condensed_wrong_order(): + result = runner.invoke(app, ["-nf", "Camila"]) + assert result.exit_code != 0 + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_name/test_tutorial005_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_name/test_tutorial005_an.py new file mode 100644 index 0000000000000000000000000000000000000000..0a947f7a41902429d5cbc1321079526e7d17abc7 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_name/test_tutorial005_an.py @@ -0,0 +1,54 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.options.name import tutorial005_an as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_option_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "-n" in result.output + assert "--name" in result.output + assert "TEXT" in result.output + assert "-f" in result.output + assert "--formal" in result.output + + +def test_call(): + result = runner.invoke(app, ["-n", "Camila"]) + assert result.exit_code == 0 + assert "Hello Camila" in result.output + + +def test_call_formal(): + result = runner.invoke(app, ["-n", "Camila", "-f"]) + assert result.exit_code == 0 + assert "Good day Ms. Camila." in result.output + + +def test_call_formal_condensed(): + result = runner.invoke(app, ["-fn", "Camila"]) + assert result.exit_code == 0 + assert "Good day Ms. Camila." in result.output + + +def test_call_condensed_wrong_order(): + result = runner.invoke(app, ["-nf", "Camila"]) + assert result.exit_code != 0 + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_prompt/__init__.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_prompt/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_prompt/test_tutorial001.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_prompt/test_tutorial001.py new file mode 100644 index 0000000000000000000000000000000000000000..3ac3deff57173e46288361d582f8c237da6eaef0 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_prompt/test_tutorial001.py @@ -0,0 +1,42 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.options.prompt import tutorial001 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_option_lastname(): + result = runner.invoke(app, ["Camila", "--lastname", "Gutiérrez"]) + assert result.exit_code == 0 + assert "Hello Camila Gutiérrez" in result.output + + +def test_option_lastname_prompt(): + result = runner.invoke(app, ["Camila"], input="Gutiérrez") + assert result.exit_code == 0 + assert "Lastname: " in result.output + assert "Hello Camila Gutiérrez" in result.output + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "--lastname" in result.output + assert "TEXT" in result.output + assert "[required]" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_prompt/test_tutorial001_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_prompt/test_tutorial001_an.py new file mode 100644 index 0000000000000000000000000000000000000000..0592d34db8fd4a6728b6ebbbf4e0e47dfa7225bb --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_prompt/test_tutorial001_an.py @@ -0,0 +1,42 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.options.prompt import tutorial001_an as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_option_lastname(): + result = runner.invoke(app, ["Camila", "--lastname", "Gutiérrez"]) + assert result.exit_code == 0 + assert "Hello Camila Gutiérrez" in result.output + + +def test_option_lastname_prompt(): + result = runner.invoke(app, ["Camila"], input="Gutiérrez") + assert result.exit_code == 0 + assert "Lastname: " in result.output + assert "Hello Camila Gutiérrez" in result.output + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "--lastname" in result.output + assert "TEXT" in result.output + assert "[required]" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_prompt/test_tutorial002.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_prompt/test_tutorial002.py new file mode 100644 index 0000000000000000000000000000000000000000..b037ddb51853f29bc8c069fda10e6ec59be8f62f --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_prompt/test_tutorial002.py @@ -0,0 +1,42 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.options.prompt import tutorial002 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_option_lastname(): + result = runner.invoke(app, ["Camila", "--lastname", "Gutiérrez"]) + assert result.exit_code == 0 + assert "Hello Camila Gutiérrez" in result.output + + +def test_option_lastname_prompt(): + result = runner.invoke(app, ["Camila"], input="Gutiérrez") + assert result.exit_code == 0 + assert "Please tell me your last name: " in result.output + assert "Hello Camila Gutiérrez" in result.output + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "--lastname" in result.output + assert "TEXT" in result.output + assert "[required]" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_prompt/test_tutorial002_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_prompt/test_tutorial002_an.py new file mode 100644 index 0000000000000000000000000000000000000000..fa59426ed32f363a992412b76c57655706be0b75 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_prompt/test_tutorial002_an.py @@ -0,0 +1,42 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.options.prompt import tutorial002_an as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_option_lastname(): + result = runner.invoke(app, ["Camila", "--lastname", "Gutiérrez"]) + assert result.exit_code == 0 + assert "Hello Camila Gutiérrez" in result.output + + +def test_option_lastname_prompt(): + result = runner.invoke(app, ["Camila"], input="Gutiérrez") + assert result.exit_code == 0 + assert "Please tell me your last name: " in result.output + assert "Hello Camila Gutiérrez" in result.output + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "--lastname" in result.output + assert "TEXT" in result.output + assert "[required]" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_prompt/test_tutorial003.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_prompt/test_tutorial003.py new file mode 100644 index 0000000000000000000000000000000000000000..210e5afa5cf62e592b5b02330e0f813a06d968fe --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_prompt/test_tutorial003.py @@ -0,0 +1,51 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.options.prompt import tutorial003 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_prompt(): + result = runner.invoke(app, input="Old Project\nOld Project\n") + assert result.exit_code == 0 + assert "Deleting project Old Project" in result.output + + +def test_prompt_not_equal(): + result = runner.invoke( + app, input="Old Project\nNew Spice\nOld Project\nOld Project\n" + ) + assert result.exit_code == 0 + assert "Error: The two entered values do not match" in result.output + assert "Deleting project Old Project" in result.output + + +def test_option(): + result = runner.invoke(app, ["--project-name", "Old Project"]) + assert result.exit_code == 0 + assert "Deleting project Old Project" in result.output + assert "Project name: " not in result.output + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "--project-name" in result.output + assert "TEXT" in result.output + assert "[required]" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_prompt/test_tutorial003_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_prompt/test_tutorial003_an.py new file mode 100644 index 0000000000000000000000000000000000000000..5d1c0865dad5f80054c6c647b6e474e8894b29d0 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_prompt/test_tutorial003_an.py @@ -0,0 +1,51 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.options.prompt import tutorial003_an as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_prompt(): + result = runner.invoke(app, input="Old Project\nOld Project\n") + assert result.exit_code == 0 + assert "Deleting project Old Project" in result.output + + +def test_prompt_not_equal(): + result = runner.invoke( + app, input="Old Project\nNew Spice\nOld Project\nOld Project\n" + ) + assert result.exit_code == 0 + assert "Error: The two entered values do not match" in result.output + assert "Deleting project Old Project" in result.output + + +def test_option(): + result = runner.invoke(app, ["--project-name", "Old Project"]) + assert result.exit_code == 0 + assert "Deleting project Old Project" in result.output + assert "Project name: " not in result.output + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "--project-name" in result.output + assert "TEXT" in result.output + assert "[required]" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_required/__init__.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_required/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_required/test_tutorial001.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_required/test_tutorial001.py new file mode 100644 index 0000000000000000000000000000000000000000..d617080588160e69d74e2aa11a592bebb6009d50 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_required/test_tutorial001.py @@ -0,0 +1,52 @@ +import subprocess +import sys + +import pytest +import typer +import typer.core +from typer.testing import CliRunner + +from docs_src.options.required import tutorial001 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_1(): + result = runner.invoke(app, ["Camila"]) + assert result.exit_code != 0 + assert "Missing option '--lastname'" in result.output + + +def test_option_lastname(): + result = runner.invoke(app, ["Camila", "--lastname", "Gutiérrez"]) + assert result.exit_code == 0 + assert "Hello Camila Gutiérrez" in result.output + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "--lastname" in result.output + assert "TEXT" in result.output + assert "[required]" in result.output + + +def test_help_no_rich(monkeypatch: pytest.MonkeyPatch): + monkeypatch.setattr(typer.core, "HAS_RICH", False) + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "--lastname" in result.output + assert "TEXT" in result.output + assert "[required]" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_required/test_tutorial001_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_required/test_tutorial001_an.py new file mode 100644 index 0000000000000000000000000000000000000000..af33ad04e6f46662cc4393b8bdf577dd1aafe8a3 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_required/test_tutorial001_an.py @@ -0,0 +1,52 @@ +import subprocess +import sys + +import pytest +import typer +import typer.core +from typer.testing import CliRunner + +from docs_src.options.required import tutorial001_an as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_1(): + result = runner.invoke(app, ["Camila"]) + assert result.exit_code != 0 + assert "Missing option '--lastname'" in result.output + + +def test_option_lastname(): + result = runner.invoke(app, ["Camila", "--lastname", "Gutiérrez"]) + assert result.exit_code == 0 + assert "Hello Camila Gutiérrez" in result.output + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "--lastname" in result.output + assert "TEXT" in result.output + assert "[required]" in result.output + + +def test_help_no_rich(monkeypatch: pytest.MonkeyPatch): + monkeypatch.setattr(typer.core, "HAS_RICH", False) + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "--lastname" in result.output + assert "TEXT" in result.output + assert "[required]" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_version/__init__.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_version/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_version/test_tutorial003.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_version/test_tutorial003.py new file mode 100644 index 0000000000000000000000000000000000000000..ede4d14fe8eec2a4b1c81207d7fcc853c6a8d54d --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_version/test_tutorial003.py @@ -0,0 +1,56 @@ +import os +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.options.version import tutorial003 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_1(): + result = runner.invoke(app, ["--name", "Rick", "--version"]) + assert result.exit_code == 0 + assert "Awesome CLI Version: 0.1.0" in result.output + + +def test_2(): + result = runner.invoke(app, ["--name", "rick"]) + assert result.exit_code != 0 + assert "Invalid value for '--name'" in result.output + assert "Only Camila is allowed" in result.output + + +def test_3(): + result = runner.invoke(app, ["--name", "Camila"]) + assert result.exit_code == 0 + assert "Hello Camila" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout + + +def test_completion(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, " "], + capture_output=True, + encoding="utf-8", + env={ + **os.environ, + "_TUTORIAL003.PY_COMPLETE": "complete_bash", + "COMP_WORDS": "tutorial003.py --name Rick --v", + "COMP_CWORD": "3", + }, + ) + assert "--version" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_version/test_tutorial003_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_version/test_tutorial003_an.py new file mode 100644 index 0000000000000000000000000000000000000000..d120bdcce3259c598655d721f945bacff0ed68b3 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options/test_version/test_tutorial003_an.py @@ -0,0 +1,56 @@ +import os +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.options.version import tutorial003_an as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_1(): + result = runner.invoke(app, ["--name", "Rick", "--version"]) + assert result.exit_code == 0 + assert "Awesome CLI Version: 0.1.0" in result.output + + +def test_2(): + result = runner.invoke(app, ["--name", "rick"]) + assert result.exit_code != 0 + assert "Invalid value for '--name'" in result.output + assert "Only Camila is allowed" in result.output + + +def test_3(): + result = runner.invoke(app, ["--name", "Camila"]) + assert result.exit_code == 0 + assert "Hello Camila" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout + + +def test_completion(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, " "], + capture_output=True, + encoding="utf-8", + env={ + **os.environ, + "_TUTORIAL003_AN.PY_COMPLETE": "complete_bash", + "COMP_WORDS": "tutorial003_an.py --name Rick --v", + "COMP_CWORD": "3", + }, + ) + assert "--version" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/__init__.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial002.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial002.py new file mode 100644 index 0000000000000000000000000000000000000000..3e15fad9b6645d5f3d52366b7496d4e7e9fb7039 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial002.py @@ -0,0 +1,40 @@ +import os +import subprocess +import sys + +from typer.testing import CliRunner + +from docs_src.options_autocompletion import tutorial002 as mod + +runner = CliRunner() + + +def test_completion(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, " "], + capture_output=True, + encoding="utf-8", + env={ + **os.environ, + "_TUTORIAL002.PY_COMPLETE": "complete_zsh", + "_TYPER_COMPLETE_ARGS": "tutorial002.py --name ", + }, + ) + assert "Camila" in result.stdout + assert "Carlos" in result.stdout + assert "Sebastian" in result.stdout + + +def test_1(): + result = runner.invoke(mod.app, ["--name", "Camila"]) + assert result.exit_code == 0 + assert "Hello Camila" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial002_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial002_an.py new file mode 100644 index 0000000000000000000000000000000000000000..7db64bfa449b50d13a52a7d123a1ed58ebe303fc --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial002_an.py @@ -0,0 +1,40 @@ +import os +import subprocess +import sys + +from typer.testing import CliRunner + +from docs_src.options_autocompletion import tutorial002_an as mod + +runner = CliRunner() + + +def test_completion(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, " "], + capture_output=True, + encoding="utf-8", + env={ + **os.environ, + "_TUTORIAL002_AN.PY_COMPLETE": "complete_zsh", + "_TYPER_COMPLETE_ARGS": "tutorial002_an.py --name ", + }, + ) + assert "Camila" in result.stdout + assert "Carlos" in result.stdout + assert "Sebastian" in result.stdout + + +def test_1(): + result = runner.invoke(mod.app, ["--name", "Camila"]) + assert result.exit_code == 0 + assert "Hello Camila" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial003.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial003.py new file mode 100644 index 0000000000000000000000000000000000000000..60304e9e55d68bbd64866b29f5f4923617af9438 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial003.py @@ -0,0 +1,57 @@ +import os +import subprocess +import sys + +from typer.testing import CliRunner + +from docs_src.options_autocompletion import tutorial003 as mod + +runner = CliRunner() + + +def test_completion_zsh(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, " "], + capture_output=True, + encoding="utf-8", + env={ + **os.environ, + "_TUTORIAL003.PY_COMPLETE": "complete_zsh", + "_TYPER_COMPLETE_ARGS": "tutorial003.py --name Seb", + }, + ) + assert "Camila" not in result.stdout + assert "Carlos" not in result.stdout + assert "Sebastian" in result.stdout + + +def test_completion_powershell(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, " "], + capture_output=True, + encoding="utf-8", + env={ + **os.environ, + "_TUTORIAL003.PY_COMPLETE": "complete_powershell", + "_TYPER_COMPLETE_ARGS": "tutorial003.py --name Seb", + "_TYPER_COMPLETE_WORD_TO_COMPLETE": "Seb", + }, + ) + assert "Camila" not in result.stdout + assert "Carlos" not in result.stdout + assert "Sebastian" in result.stdout + + +def test_1(): + result = runner.invoke(mod.app, ["--name", "Camila"]) + assert result.exit_code == 0 + assert "Hello Camila" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial003_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial003_an.py new file mode 100644 index 0000000000000000000000000000000000000000..7688f108f5399f9a1aa1924c4ec7db3e4852bad4 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial003_an.py @@ -0,0 +1,57 @@ +import os +import subprocess +import sys + +from typer.testing import CliRunner + +from docs_src.options_autocompletion import tutorial003_an as mod + +runner = CliRunner() + + +def test_completion_zsh(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, " "], + capture_output=True, + encoding="utf-8", + env={ + **os.environ, + "_TUTORIAL003_AN.PY_COMPLETE": "complete_zsh", + "_TYPER_COMPLETE_ARGS": "tutorial003_an.py --name Seb", + }, + ) + assert "Camila" not in result.stdout + assert "Carlos" not in result.stdout + assert "Sebastian" in result.stdout + + +def test_completion_powershell(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, " "], + capture_output=True, + encoding="utf-8", + env={ + **os.environ, + "_TUTORIAL003_AN.PY_COMPLETE": "complete_powershell", + "_TYPER_COMPLETE_ARGS": "tutorial003.py --name Seb", + "_TYPER_COMPLETE_WORD_TO_COMPLETE": "Seb", + }, + ) + assert "Camila" not in result.stdout + assert "Carlos" not in result.stdout + assert "Sebastian" in result.stdout + + +def test_1(): + result = runner.invoke(mod.app, ["--name", "Camila"]) + assert result.exit_code == 0 + assert "Hello Camila" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial004.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial004.py new file mode 100644 index 0000000000000000000000000000000000000000..17c5f5197a6dacf6d2134f5390f8e4f789ce0ae6 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial004.py @@ -0,0 +1,40 @@ +import os +import subprocess +import sys + +from typer.testing import CliRunner + +from docs_src.options_autocompletion import tutorial004 as mod + +runner = CliRunner() + + +def test_completion(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, " "], + capture_output=True, + encoding="utf-8", + env={ + **os.environ, + "_TUTORIAL004.PY_COMPLETE": "complete_zsh", + "_TYPER_COMPLETE_ARGS": "tutorial004_aux.py --name ", + }, + ) + assert '"Camila":"The reader of books."' in result.stdout + assert '"Carlos":"The writer of scripts."' in result.stdout + assert '"Sebastian":"The type hints guy."' in result.stdout + + +def test_1(): + result = runner.invoke(mod.app, ["--name", "Camila"]) + assert result.exit_code == 0 + assert "Hello Camila" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial004_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial004_an.py new file mode 100644 index 0000000000000000000000000000000000000000..dcfce0a4a78df142a466dde8a547d3a307cfa30d --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial004_an.py @@ -0,0 +1,40 @@ +import os +import subprocess +import sys + +from typer.testing import CliRunner + +from docs_src.options_autocompletion import tutorial004_an as mod + +runner = CliRunner() + + +def test_completion(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, " "], + capture_output=True, + encoding="utf-8", + env={ + **os.environ, + "_TUTORIAL004_AN.PY_COMPLETE": "complete_zsh", + "_TYPER_COMPLETE_ARGS": "tutorial004_an_aux.py --name ", + }, + ) + assert '"Camila":"The reader of books."' in result.stdout + assert '"Carlos":"The writer of scripts."' in result.stdout + assert '"Sebastian":"The type hints guy."' in result.stdout + + +def test_1(): + result = runner.invoke(mod.app, ["--name", "Camila"]) + assert result.exit_code == 0 + assert "Hello Camila" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial007.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial007.py new file mode 100644 index 0000000000000000000000000000000000000000..b8ce1b1598c9e9b682992c3072668b7e31011bab --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial007.py @@ -0,0 +1,41 @@ +import os +import subprocess +import sys + +from typer.testing import CliRunner + +from docs_src.options_autocompletion import tutorial007 as mod + +runner = CliRunner() + + +def test_completion(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, " "], + capture_output=True, + encoding="utf-8", + env={ + **os.environ, + "_TUTORIAL007.PY_COMPLETE": "complete_zsh", + "_TYPER_COMPLETE_ARGS": "tutorial007.py --name Sebastian --name ", + }, + ) + assert '"Camila":"The reader of books."' in result.stdout + assert '"Carlos":"The writer of scripts."' in result.stdout + assert '"Sebastian":"The type hints guy."' not in result.stdout + + +def test_1(): + result = runner.invoke(mod.app, ["--name", "Camila", "--name", "Sebastian"]) + assert result.exit_code == 0 + assert "Hello Camila" in result.output + assert "Hello Sebastian" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial007_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial007_an.py new file mode 100644 index 0000000000000000000000000000000000000000..c35f23eb6108b09eaf6d50d2e951e02758c746f4 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial007_an.py @@ -0,0 +1,41 @@ +import os +import subprocess +import sys + +from typer.testing import CliRunner + +from docs_src.options_autocompletion import tutorial007_an as mod + +runner = CliRunner() + + +def test_completion(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, " "], + capture_output=True, + encoding="utf-8", + env={ + **os.environ, + "_TUTORIAL007_AN.PY_COMPLETE": "complete_zsh", + "_TYPER_COMPLETE_ARGS": "tutorial007_an.py --name Sebastian --name ", + }, + ) + assert '"Camila":"The reader of books."' in result.stdout + assert '"Carlos":"The writer of scripts."' in result.stdout + assert '"Sebastian":"The type hints guy."' not in result.stdout + + +def test_1(): + result = runner.invoke(mod.app, ["--name", "Camila", "--name", "Sebastian"]) + assert result.exit_code == 0 + assert "Hello Camila" in result.output + assert "Hello Sebastian" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial008.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial008.py new file mode 100644 index 0000000000000000000000000000000000000000..0874f23c5df8125057af1b5661e4b9039f6abc3e --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial008.py @@ -0,0 +1,42 @@ +import os +import subprocess +import sys + +from typer.testing import CliRunner + +from docs_src.options_autocompletion import tutorial008 as mod + +runner = CliRunner() + + +def test_completion(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, " "], + capture_output=True, + encoding="utf-8", + env={ + **os.environ, + "_TUTORIAL008.PY_COMPLETE": "complete_zsh", + "_TYPER_COMPLETE_ARGS": "tutorial008.py --name ", + }, + ) + assert '"Camila":"The reader of books."' in result.stdout + assert '"Carlos":"The writer of scripts."' in result.stdout + assert '"Sebastian":"The type hints guy."' in result.stdout + assert "[]" in result.stderr + + +def test_1(): + result = runner.invoke(mod.app, ["--name", "Camila", "--name", "Sebastian"]) + assert result.exit_code == 0 + assert "Hello Camila" in result.output + assert "Hello Sebastian" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial008_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial008_an.py new file mode 100644 index 0000000000000000000000000000000000000000..cb2481a67c4fdbcb3d83858924ee3ea63a27b12d --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial008_an.py @@ -0,0 +1,42 @@ +import os +import subprocess +import sys + +from typer.testing import CliRunner + +from docs_src.options_autocompletion import tutorial008_an as mod + +runner = CliRunner() + + +def test_completion(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, " "], + capture_output=True, + encoding="utf-8", + env={ + **os.environ, + "_TUTORIAL008_AN.PY_COMPLETE": "complete_zsh", + "_TYPER_COMPLETE_ARGS": "tutorial008_an.py --name ", + }, + ) + assert '"Camila":"The reader of books."' in result.stdout + assert '"Carlos":"The writer of scripts."' in result.stdout + assert '"Sebastian":"The type hints guy."' in result.stdout + assert "[]" in result.stderr + + +def test_1(): + result = runner.invoke(mod.app, ["--name", "Camila", "--name", "Sebastian"]) + assert result.exit_code == 0 + assert "Hello Camila" in result.output + assert "Hello Sebastian" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial009.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial009.py new file mode 100644 index 0000000000000000000000000000000000000000..3c7eb0cc646037a72460e4e7e4ab25baee8fe910 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial009.py @@ -0,0 +1,42 @@ +import os +import subprocess +import sys + +from typer.testing import CliRunner + +from docs_src.options_autocompletion import tutorial009 as mod + +runner = CliRunner() + + +def test_completion(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, " "], + capture_output=True, + encoding="utf-8", + env={ + **os.environ, + "_TUTORIAL009.PY_COMPLETE": "complete_zsh", + "_TYPER_COMPLETE_ARGS": "tutorial009.py --name Sebastian --name ", + }, + ) + assert '"Camila":"The reader of books."' in result.stdout + assert '"Carlos":"The writer of scripts."' in result.stdout + assert '"Sebastian":"The type hints guy."' not in result.stdout + assert "[]" in result.stderr + + +def test_1(): + result = runner.invoke(mod.app, ["--name", "Camila", "--name", "Sebastian"]) + assert result.exit_code == 0 + assert "Hello Camila" in result.output + assert "Hello Sebastian" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial009_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial009_an.py new file mode 100644 index 0000000000000000000000000000000000000000..56182ac3b9d4b3144dca4c4e99fbef6c29ff62f4 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_options_autocompletion/test_tutorial009_an.py @@ -0,0 +1,42 @@ +import os +import subprocess +import sys + +from typer.testing import CliRunner + +from docs_src.options_autocompletion import tutorial009_an as mod + +runner = CliRunner() + + +def test_completion(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, " "], + capture_output=True, + encoding="utf-8", + env={ + **os.environ, + "_TUTORIAL009_AN.PY_COMPLETE": "complete_zsh", + "_TYPER_COMPLETE_ARGS": "tutorial009_an.py --name Sebastian --name ", + }, + ) + assert '"Camila":"The reader of books."' in result.stdout + assert '"Carlos":"The writer of scripts."' in result.stdout + assert '"Sebastian":"The type hints guy."' not in result.stdout + assert "[]" in result.stderr + + +def test_1(): + result = runner.invoke(mod.app, ["--name", "Camila", "--name", "Sebastian"]) + assert result.exit_code == 0 + assert "Hello Camila" in result.output + assert "Hello Sebastian" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/__init__.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_bool/__init__.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_bool/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_bool/test_tutorial001.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_bool/test_tutorial001.py new file mode 100644 index 0000000000000000000000000000000000000000..61f0f2597c1b3cea562a644ddf7dbc8225e43cfc --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_bool/test_tutorial001.py @@ -0,0 +1,46 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.bool import tutorial001 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "--force" in result.output + assert "--no-force" not in result.output + + +def test_no_force(): + result = runner.invoke(app) + assert result.exit_code == 0 + assert "Not forcing" in result.output + + +def test_force(): + result = runner.invoke(app, ["--force"]) + assert result.exit_code == 0 + assert "Forcing operation" in result.output + + +def test_invalid_no_force(): + result = runner.invoke(app, ["--no-force"]) + assert result.exit_code != 0 + assert "No such option: --no-force" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_bool/test_tutorial001_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_bool/test_tutorial001_an.py new file mode 100644 index 0000000000000000000000000000000000000000..b549583e236586c874c7721c842a83aeb3a50df3 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_bool/test_tutorial001_an.py @@ -0,0 +1,46 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.bool import tutorial001_an as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "--force" in result.output + assert "--no-force" not in result.output + + +def test_no_force(): + result = runner.invoke(app) + assert result.exit_code == 0 + assert "Not forcing" in result.output + + +def test_force(): + result = runner.invoke(app, ["--force"]) + assert result.exit_code == 0 + assert "Forcing operation" in result.output + + +def test_invalid_no_force(): + result = runner.invoke(app, ["--no-force"]) + assert result.exit_code != 0 + assert "No such option: --no-force" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_bool/test_tutorial002.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_bool/test_tutorial002.py new file mode 100644 index 0000000000000000000000000000000000000000..eb05427fce353183fb53db48d647f118da9e1383 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_bool/test_tutorial002.py @@ -0,0 +1,64 @@ +import subprocess +import sys + +import pytest +import typer +import typer.core +from typer.testing import CliRunner + +from docs_src.parameter_types.bool import tutorial002 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "--accept" in result.output + assert "--reject" in result.output + assert "--no-accept" not in result.output + + +def test_help_no_rich(monkeypatch: pytest.MonkeyPatch): + monkeypatch.setattr(typer.core, "HAS_RICH", False) + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "--accept" in result.output + assert "--reject" in result.output + assert "--no-accept" not in result.output + + +def test_main(): + result = runner.invoke(app) + assert result.exit_code == 0 + assert "I don't know what you want yet" in result.output + + +def test_accept(): + result = runner.invoke(app, ["--accept"]) + assert result.exit_code == 0 + assert "Accepting!" in result.output + + +def test_reject(): + result = runner.invoke(app, ["--reject"]) + assert result.exit_code == 0 + assert "Rejecting!" in result.output + + +def test_invalid_no_accept(): + result = runner.invoke(app, ["--no-accept"]) + assert result.exit_code != 0 + assert "No such option: --no-accept" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_bool/test_tutorial002_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_bool/test_tutorial002_an.py new file mode 100644 index 0000000000000000000000000000000000000000..78ad94bea8223d1aa4379d3d97571a178ec36809 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_bool/test_tutorial002_an.py @@ -0,0 +1,64 @@ +import subprocess +import sys + +import pytest +import typer +import typer.core +from typer.testing import CliRunner + +from docs_src.parameter_types.bool import tutorial002_an as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "--accept" in result.output + assert "--reject" in result.output + assert "--no-accept" not in result.output + + +def test_help_no_rich(monkeypatch: pytest.MonkeyPatch): + monkeypatch.setattr(typer.core, "HAS_RICH", False) + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "--accept" in result.output + assert "--reject" in result.output + assert "--no-accept" not in result.output + + +def test_main(): + result = runner.invoke(app) + assert result.exit_code == 0 + assert "I don't know what you want yet" in result.output + + +def test_accept(): + result = runner.invoke(app, ["--accept"]) + assert result.exit_code == 0 + assert "Accepting!" in result.output + + +def test_reject(): + result = runner.invoke(app, ["--reject"]) + assert result.exit_code == 0 + assert "Rejecting!" in result.output + + +def test_invalid_no_accept(): + result = runner.invoke(app, ["--no-accept"]) + assert result.exit_code != 0 + assert "No such option: --no-accept" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_bool/test_tutorial003.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_bool/test_tutorial003.py new file mode 100644 index 0000000000000000000000000000000000000000..794efece5789498c951e7566382e86aa50b89627 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_bool/test_tutorial003.py @@ -0,0 +1,42 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.bool import tutorial003 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "-f" in result.output + assert "--force" in result.output + assert "-F" in result.output + assert "--no-force" in result.output + + +def test_force(): + result = runner.invoke(app, ["-f"]) + assert result.exit_code == 0 + assert "Forcing operation" in result.output + + +def test_no_force(): + result = runner.invoke(app, ["-F"]) + assert result.exit_code == 0 + assert "Not forcing" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_bool/test_tutorial003_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_bool/test_tutorial003_an.py new file mode 100644 index 0000000000000000000000000000000000000000..ef608dd9e8f35c82e27dd598cd27e8edfcba621a --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_bool/test_tutorial003_an.py @@ -0,0 +1,42 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.bool import tutorial003_an as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "-f" in result.output + assert "--force" in result.output + assert "-F" in result.output + assert "--no-force" in result.output + + +def test_force(): + result = runner.invoke(app, ["-f"]) + assert result.exit_code == 0 + assert "Forcing operation" in result.output + + +def test_no_force(): + result = runner.invoke(app, ["-F"]) + assert result.exit_code == 0 + assert "Not forcing" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_bool/test_tutorial004.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_bool/test_tutorial004.py new file mode 100644 index 0000000000000000000000000000000000000000..6b891544c6a3bab5669ec6ac1d0ca6bf65de70c2 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_bool/test_tutorial004.py @@ -0,0 +1,46 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.bool import tutorial004 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "-d" in result.output + assert "--demo" in result.output + + +def test_main(): + result = runner.invoke(app) + assert result.exit_code == 0 + assert "Running in production" in result.output + + +def test_demo(): + result = runner.invoke(app, ["--demo"]) + assert result.exit_code == 0 + assert "Running demo" in result.output + + +def test_short_demo(): + result = runner.invoke(app, ["-d"]) + assert result.exit_code == 0 + assert "Running demo" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_bool/test_tutorial004_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_bool/test_tutorial004_an.py new file mode 100644 index 0000000000000000000000000000000000000000..e6073100874a58470027f1698d0e9b96c0fae4ea --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_bool/test_tutorial004_an.py @@ -0,0 +1,46 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.bool import tutorial004_an as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "-d" in result.output + assert "--demo" in result.output + + +def test_main(): + result = runner.invoke(app) + assert result.exit_code == 0 + assert "Running in production" in result.output + + +def test_demo(): + result = runner.invoke(app, ["--demo"]) + assert result.exit_code == 0 + assert "Running demo" in result.output + + +def test_short_demo(): + result = runner.invoke(app, ["-d"]) + assert result.exit_code == 0 + assert "Running demo" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_custom_types/__init__.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_custom_types/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_custom_types/test_tutorial001.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_custom_types/test_tutorial001.py new file mode 100644 index 0000000000000000000000000000000000000000..047dfff14208301f20fa1306079adffac0ee4a4c --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_custom_types/test_tutorial001.py @@ -0,0 +1,38 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.custom_types import tutorial001 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + + +def test_parse_custom_type(): + result = runner.invoke(app, ["0", "--custom-opt", "1"]) + assert "custom_arg is " in result.output + assert "custom-opt is " in result.output + + +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 + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_custom_types/test_tutorial001_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_custom_types/test_tutorial001_an.py new file mode 100644 index 0000000000000000000000000000000000000000..7b52d5e1d1a273f46547f9923cb454b63f39b0e6 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_custom_types/test_tutorial001_an.py @@ -0,0 +1,38 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.custom_types import tutorial001_an as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + + +def test_parse_custom_type(): + result = runner.invoke(app, ["0", "--custom-opt", "1"]) + assert "custom_arg is " in result.output + assert "custom-opt is " in result.output + + +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 + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_custom_types/test_tutorial002.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_custom_types/test_tutorial002.py new file mode 100644 index 0000000000000000000000000000000000000000..fc72db408a4f1828159e21a89dfb048ef2d34db6 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_custom_types/test_tutorial002.py @@ -0,0 +1,38 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.custom_types import tutorial002 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + + +def test_parse_custom_type(): + result = runner.invoke(app, ["0", "--custom-opt", "1"]) + assert "custom_arg is " in result.output + assert "custom-opt is " in result.output + + +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 + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_custom_types/test_tutorial002_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_custom_types/test_tutorial002_an.py new file mode 100644 index 0000000000000000000000000000000000000000..c31d69ae74c935911e7b0aebb5d3d9a6f7c0cb19 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_custom_types/test_tutorial002_an.py @@ -0,0 +1,38 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.custom_types import tutorial002_an as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + + +def test_parse_custom_type(): + result = runner.invoke(app, ["0", "--custom-opt", "1"]) + assert "custom_arg is " in result.output + assert "custom-opt is " in result.output + + +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 + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_datetime/__init__.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_datetime/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_datetime/test_tutorial001.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_datetime/test_tutorial001.py new file mode 100644 index 0000000000000000000000000000000000000000..96cd5a9f56e43be3c5fa25f99022d3e2ab87a70c --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_datetime/test_tutorial001.py @@ -0,0 +1,47 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.datetime import tutorial001 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "[%Y-%m-%d|%Y-%m-%dT%H:%M:%S|%Y-%m-%d %H:%M:%S]" in result.output + + +def test_main(): + result = runner.invoke(app, ["1956-01-31T10:00:00"]) + assert result.exit_code == 0 + assert "Interesting day to be born: 1956-01-31 10:00:00" in result.output + assert "Birth hour: 10" in result.output + + +def test_invalid(): + result = runner.invoke(app, ["july-19-1989"]) + assert result.exit_code != 0 + assert ( + "Invalid value for 'BIRTH:[%Y-%m-%d|%Y-%m-%dT%H:%M:%S|%Y-%m-%d %H:%M:%S]':" + in result.output + ) + assert "'july-19-1989' does not match the formats" in result.output + assert "%Y-%m-%d" in result.output + assert "%Y-%m-%dT%H:%M:%S" in result.output + assert "%Y-%m-%d %H:%M:%S" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_datetime/test_tutorial002.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_datetime/test_tutorial002.py new file mode 100644 index 0000000000000000000000000000000000000000..0c08f1b046484394d2bd9b59deb2e940f742440c --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_datetime/test_tutorial002.py @@ -0,0 +1,33 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.datetime import tutorial002 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_main(): + result = runner.invoke(app, ["1969-10-29"]) + assert result.exit_code == 0 + assert "Launch will be at: 1969-10-29 00:00:00" in result.output + + +def test_usa_weird_date_format(): + result = runner.invoke(app, ["10/29/1969"]) + assert result.exit_code == 0 + assert "Launch will be at: 1969-10-29 00:00:00" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_datetime/test_tutorial002_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_datetime/test_tutorial002_an.py new file mode 100644 index 0000000000000000000000000000000000000000..d89821bf7faf5f16bf7a26fe0ec0980efbb60e0c --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_datetime/test_tutorial002_an.py @@ -0,0 +1,33 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.datetime import tutorial002_an as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_main(): + result = runner.invoke(app, ["1969-10-29"]) + assert result.exit_code == 0 + assert "Launch will be at: 1969-10-29 00:00:00" in result.output + + +def test_usa_weird_date_format(): + result = runner.invoke(app, ["10/29/1969"]) + assert result.exit_code == 0 + assert "Launch will be at: 1969-10-29 00:00:00" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_enum/__init__.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_enum/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_enum/test_tutorial001.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_enum/test_tutorial001.py new file mode 100644 index 0000000000000000000000000000000000000000..567a9d3486048314f9ebf5e3a74c14a8d96787c1 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_enum/test_tutorial001.py @@ -0,0 +1,61 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.enum import tutorial001 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "--network" in result.output + assert "[simple|conv|lstm]" in result.output + assert "default: simple" in result.output + + +def test_main(): + result = runner.invoke(app, ["--network", "conv"]) + assert result.exit_code == 0 + assert "Training neural network of type: conv" in result.output + + +def test_main_default(): + result = runner.invoke(app) + assert result.exit_code == 0 + assert "Training neural network of type: simple" in result.output + + +def test_invalid_case(): + result = runner.invoke(app, ["--network", "CONV"]) + assert result.exit_code != 0 + assert "Invalid value for '--network'" in result.output + assert "'CONV' is not one of" in result.output + assert "simple" in result.output + assert "conv" in result.output + assert "lstm" in result.output + + +def test_invalid_other(): + result = runner.invoke(app, ["--network", "capsule"]) + assert result.exit_code != 0 + assert "Invalid value for '--network'" in result.output + assert "'capsule' is not one of" in result.output + assert "simple" in result.output + assert "conv" in result.output + assert "lstm" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_enum/test_tutorial002.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_enum/test_tutorial002.py new file mode 100644 index 0000000000000000000000000000000000000000..6c712d3b6ec64c007a3b16ef8c86f6b8982e909c --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_enum/test_tutorial002.py @@ -0,0 +1,33 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.enum import tutorial002 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_upper(): + result = runner.invoke(app, ["--network", "CONV"]) + assert result.exit_code == 0 + assert "Training neural network of type: conv" in result.output + + +def test_mix(): + result = runner.invoke(app, ["--network", "LsTm"]) + assert result.exit_code == 0 + assert "Training neural network of type: lstm" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_enum/test_tutorial002_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_enum/test_tutorial002_an.py new file mode 100644 index 0000000000000000000000000000000000000000..a3c72b7eea7df20f741dd30b3153e8de3b18c1c2 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_enum/test_tutorial002_an.py @@ -0,0 +1,33 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.enum import tutorial002_an as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_upper(): + result = runner.invoke(app, ["--network", "CONV"]) + assert result.exit_code == 0 + assert "Training neural network of type: conv" in result.output + + +def test_mix(): + result = runner.invoke(app, ["--network", "LsTm"]) + assert result.exit_code == 0 + assert "Training neural network of type: lstm" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_enum/test_tutorial003.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_enum/test_tutorial003.py new file mode 100644 index 0000000000000000000000000000000000000000..98c882ebc179312e21ac841f4e86f4870c3d97d3 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_enum/test_tutorial003.py @@ -0,0 +1,47 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.enum import tutorial003 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "--groceries" in result.output + assert "[Eggs|Bacon|Cheese]" in result.output + assert "default: Eggs, Cheese" in result.output + + +def test_call_no_arg(): + result = runner.invoke(app) + assert result.exit_code == 0 + assert "Buying groceries: Eggs, Cheese" in result.output + + +def test_call_single_arg(): + result = runner.invoke(app, ["--groceries", "Bacon"]) + assert result.exit_code == 0 + assert "Buying groceries: Bacon" in result.output + + +def test_call_multiple_arg(): + result = runner.invoke(app, ["--groceries", "Eggs", "--groceries", "Bacon"]) + assert result.exit_code == 0 + assert "Buying groceries: Eggs, Bacon" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_enum/test_tutorial003_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_enum/test_tutorial003_an.py new file mode 100644 index 0000000000000000000000000000000000000000..46dd4018a5015436c88c61423a232a0351eaee83 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_enum/test_tutorial003_an.py @@ -0,0 +1,47 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.enum import tutorial003_an as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "--groceries" in result.output + assert "[Eggs|Bacon|Cheese]" in result.output + assert "default: Eggs, Cheese" in result.output + + +def test_call_no_arg(): + result = runner.invoke(app) + assert result.exit_code == 0 + assert "Buying groceries: Eggs, Cheese" in result.output + + +def test_call_single_arg(): + result = runner.invoke(app, ["--groceries", "Bacon"]) + assert result.exit_code == 0 + assert "Buying groceries: Bacon" in result.output + + +def test_call_multiple_arg(): + result = runner.invoke(app, ["--groceries", "Eggs", "--groceries", "Bacon"]) + assert result.exit_code == 0 + assert "Buying groceries: Eggs, Bacon" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_enum/test_tutorial004.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_enum/test_tutorial004.py new file mode 100644 index 0000000000000000000000000000000000000000..6cb479b1b477d69d5fc5bd35df8cc5d7e2ece409 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_enum/test_tutorial004.py @@ -0,0 +1,46 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.enum import tutorial004 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "--network [simple|conv|lstm]" in result.output.replace(" ", "") + + +def test_main(): + result = runner.invoke(app, ["--network", "conv"]) + assert result.exit_code == 0 + assert "Training neural network of type: conv" in result.output + + +def test_invalid(): + result = runner.invoke(app, ["--network", "capsule"]) + assert result.exit_code != 0 + assert "Invalid value for '--network'" in result.output + assert ( + "invalid choice: capsule. (choose from" in result.output + or "'capsule' is not one of" in result.output + ) + assert "simple" in result.output + assert "conv" in result.output + assert "lstm" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_enum/test_tutorial004_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_enum/test_tutorial004_an.py new file mode 100644 index 0000000000000000000000000000000000000000..afa061d92af7ef43b182dbcf0d42aaee84e265bb --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_enum/test_tutorial004_an.py @@ -0,0 +1,46 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.enum import tutorial004_an as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "--network [simple|conv|lstm]" in result.output.replace(" ", "") + + +def test_main(): + result = runner.invoke(app, ["--network", "conv"]) + assert result.exit_code == 0 + assert "Training neural network of type: conv" in result.output + + +def test_invalid(): + result = runner.invoke(app, ["--network", "capsule"]) + assert result.exit_code != 0 + assert "Invalid value for '--network'" in result.output + assert ( + "invalid choice: capsule. (choose from" in result.output + or "'capsule' is not one of" in result.output + ) + assert "simple" in result.output + assert "conv" in result.output + assert "lstm" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/__init__.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/test_tutorial001.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/test_tutorial001.py new file mode 100644 index 0000000000000000000000000000000000000000..24259b1e7ed7af17309d7036e145267fe26dfd9f --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/test_tutorial001.py @@ -0,0 +1,32 @@ +import subprocess +import sys +from pathlib import Path + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.file import tutorial001 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_main(tmpdir): + config_file = Path(tmpdir) / "config.txt" + config_file.write_text("some settings\nsome more settings") + result = runner.invoke(app, ["--config", f"{config_file}"]) + config_file.unlink() + assert result.exit_code == 0 + assert "Config line: some settings" in result.output + assert "Config line: some more settings" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/test_tutorial001_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/test_tutorial001_an.py new file mode 100644 index 0000000000000000000000000000000000000000..4be35a88a4b6367b450c2e17f586fee5264f6887 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/test_tutorial001_an.py @@ -0,0 +1,32 @@ +import subprocess +import sys +from pathlib import Path + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.file import tutorial001_an as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_main(tmpdir): + config_file = Path(tmpdir) / "config.txt" + config_file.write_text("some settings\nsome more settings") + result = runner.invoke(app, ["--config", f"{config_file}"]) + config_file.unlink() + assert result.exit_code == 0 + assert "Config line: some settings" in result.output + assert "Config line: some more settings" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/test_tutorial002.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/test_tutorial002.py new file mode 100644 index 0000000000000000000000000000000000000000..0f6ff642092bf5e7a34947632fba6f535380dfb1 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/test_tutorial002.py @@ -0,0 +1,34 @@ +import subprocess +import sys +from pathlib import Path + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.file import tutorial002 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_main(tmpdir): + config_file = Path(tmpdir) / "config.txt" + if config_file.exists(): # pragma: no cover + config_file.unlink() + result = runner.invoke(app, ["--config", f"{config_file}"]) + text = config_file.read_text() + config_file.unlink() + assert result.exit_code == 0 + assert "Config written" in result.output + assert "Some config written by the app" in text + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/test_tutorial002_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/test_tutorial002_an.py new file mode 100644 index 0000000000000000000000000000000000000000..c2f605d84ed9400a36fbedc62f882081e8550192 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/test_tutorial002_an.py @@ -0,0 +1,34 @@ +import subprocess +import sys +from pathlib import Path + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.file import tutorial002_an as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_main(tmpdir): + config_file = Path(tmpdir) / "config.txt" + if config_file.exists(): # pragma: no cover + config_file.unlink() + result = runner.invoke(app, ["--config", f"{config_file}"]) + text = config_file.read_text() + config_file.unlink() + assert result.exit_code == 0 + assert "Config written" in result.output + assert "Some config written by the app" in text + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/test_tutorial003.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/test_tutorial003.py new file mode 100644 index 0000000000000000000000000000000000000000..5dda6d3cb8059bbff4b81c941c1d544d75109399 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/test_tutorial003.py @@ -0,0 +1,31 @@ +import subprocess +import sys +from pathlib import Path + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.file import tutorial003 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_main(tmpdir): + binary_file = Path(tmpdir) / "config.txt" + binary_file.write_bytes(b"la cig\xc3\xbce\xc3\xb1a trae al ni\xc3\xb1o") + result = runner.invoke(app, ["--file", f"{binary_file}"]) + binary_file.unlink() + assert result.exit_code == 0 + assert "Processed bytes total:" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/test_tutorial003_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/test_tutorial003_an.py new file mode 100644 index 0000000000000000000000000000000000000000..4b48675ade65bca2acd92c56abf2e10df3fa9898 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/test_tutorial003_an.py @@ -0,0 +1,31 @@ +import subprocess +import sys +from pathlib import Path + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.file import tutorial003_an as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_main(tmpdir): + binary_file = Path(tmpdir) / "config.txt" + binary_file.write_bytes(b"la cig\xc3\xbce\xc3\xb1a trae al ni\xc3\xb1o") + result = runner.invoke(app, ["--file", f"{binary_file}"]) + binary_file.unlink() + assert result.exit_code == 0 + assert "Processed bytes total:" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/test_tutorial004.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/test_tutorial004.py new file mode 100644 index 0000000000000000000000000000000000000000..96a64779bd23425a3b7ead8db1eac7154c06718b --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/test_tutorial004.py @@ -0,0 +1,35 @@ +import subprocess +import sys +from pathlib import Path + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.file import tutorial004 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_main(tmpdir): + binary_file = Path(tmpdir) / "config.txt" + if binary_file.exists(): # pragma: no cover + binary_file.unlink() + result = runner.invoke(app, ["--file", f"{binary_file}"]) + text = binary_file.read_text(encoding="utf-8") + binary_file.unlink() + assert result.exit_code == 0 + assert "Binary file written" in result.output + assert "some settings" in text + assert "la cigüeña trae al niño" in text + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/test_tutorial004_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/test_tutorial004_an.py new file mode 100644 index 0000000000000000000000000000000000000000..7cf0ecf49829d122b863d581b03b9e6bd45cd58f --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/test_tutorial004_an.py @@ -0,0 +1,35 @@ +import subprocess +import sys +from pathlib import Path + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.file import tutorial004_an as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_main(tmpdir): + binary_file = Path(tmpdir) / "config.txt" + if binary_file.exists(): # pragma: no cover + binary_file.unlink() + result = runner.invoke(app, ["--file", f"{binary_file}"]) + text = binary_file.read_text(encoding="utf-8") + binary_file.unlink() + assert result.exit_code == 0 + assert "Binary file written" in result.output + assert "some settings" in text + assert "la cigüeña trae al niño" in text + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/test_tutorial005.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/test_tutorial005.py new file mode 100644 index 0000000000000000000000000000000000000000..bdc52c838146a80f049c1667d7ef7b85b0d8f670 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/test_tutorial005.py @@ -0,0 +1,37 @@ +import subprocess +import sys +from pathlib import Path + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.file import tutorial005 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_main(tmpdir): + config_file = Path(tmpdir) / "config.txt" + if config_file.exists(): # pragma: no cover + config_file.unlink() + config_file.write_text("") + result = runner.invoke(app, ["--config", f"{config_file}"]) + result = runner.invoke(app, ["--config", f"{config_file}"]) + result = runner.invoke(app, ["--config", f"{config_file}"]) + text = config_file.read_text() + config_file.unlink() + assert result.exit_code == 0 + assert "Config line written" + assert "This is a single line\nThis is a single line\nThis is a single line" in text + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/test_tutorial005_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/test_tutorial005_an.py new file mode 100644 index 0000000000000000000000000000000000000000..85d49e121e75672db25b32c650f274f71daca875 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_file/test_tutorial005_an.py @@ -0,0 +1,37 @@ +import subprocess +import sys +from pathlib import Path + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.file import tutorial005_an as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_main(tmpdir): + config_file = Path(tmpdir) / "config.txt" + if config_file.exists(): # pragma: no cover + config_file.unlink() + config_file.write_text("") + result = runner.invoke(app, ["--config", f"{config_file}"]) + result = runner.invoke(app, ["--config", f"{config_file}"]) + result = runner.invoke(app, ["--config", f"{config_file}"]) + text = config_file.read_text() + config_file.unlink() + assert result.exit_code == 0 + assert "Config line written" + assert "This is a single line\nThis is a single line\nThis is a single line" in text + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_index/__init__.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_index/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_index/test_tutorial001.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_index/test_tutorial001.py new file mode 100644 index 0000000000000000000000000000000000000000..a53450ba8e17145296a027db53360e3b82cb0bef --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_index/test_tutorial001.py @@ -0,0 +1,48 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.index import tutorial001 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "--age" in result.output + assert "INTEGER" in result.output + assert "--height-meters" in result.output + assert "FLOAT" in result.output + + +def test_params(): + result = runner.invoke( + app, ["Camila", "--age", "15", "--height-meters", "1.70", "--female"] + ) + assert result.exit_code == 0 + assert "NAME is Camila, of type: " in result.output + assert "--age is 15, of type: " in result.output + assert "--height-meters is 1.7, of type: " in result.output + assert "--female is True, of type: " in result.output + + +def test_invalid(): + result = runner.invoke(app, ["Camila", "--age", "15.3"]) + assert result.exit_code != 0 + assert "Invalid value for '--age'" in result.output + assert "'15.3' is not a valid integer" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_number/__init__.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_number/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_number/test_tutorial001.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_number/test_tutorial001.py new file mode 100644 index 0000000000000000000000000000000000000000..fdaf7550078c0d49c3a0d4c8f465bf914f18701d --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_number/test_tutorial001.py @@ -0,0 +1,80 @@ +import subprocess +import sys + +import pytest +import typer +import typer.core +from typer.testing import CliRunner + +from docs_src.parameter_types.number import tutorial001 as mod + +runner = CliRunner() + +app = typer.Typer(rich_markup_mode=None) +app.command()(mod.main) + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "--age" in result.output + assert "INTEGER RANGE" in result.output + assert "--score" in result.output + assert "FLOAT RANGE" in result.output + + +def test_help_no_rich(monkeypatch: pytest.MonkeyPatch): + monkeypatch.setattr(typer.core, "HAS_RICH", False) + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "--age" in result.output + assert "INTEGER RANGE" in result.output + assert "--score" in result.output + assert "FLOAT RANGE" in result.output + + +def test_params(): + result = runner.invoke(app, ["5", "--age", "20", "--score", "90"]) + assert result.exit_code == 0 + assert "ID is 5" in result.output + assert "--age is 20" in result.output + assert "--score is 90.0" in result.output + + +def test_invalid_id(): + result = runner.invoke(app, ["1002"]) + assert result.exit_code != 0 + assert ( + "Invalid value for 'ID': 1002 is not in the range 0<=x<=1000." in result.output + ) + + +def test_invalid_age(): + result = runner.invoke(app, ["5", "--age", "15"]) + assert result.exit_code != 0 + assert "Invalid value for '--age'" in result.output + assert "15 is not in the range x>=18" in result.output + + +def test_invalid_score(): + result = runner.invoke(app, ["5", "--age", "20", "--score", "100.5"]) + assert result.exit_code != 0 + assert "Invalid value for '--score'" in result.output + assert "100.5 is not in the range x<=100." in result.output + + +def test_negative_score(): + result = runner.invoke(app, ["5", "--age", "20", "--score", "-5"]) + assert result.exit_code == 0 + assert "ID is 5" in result.output + assert "--age is 20" in result.output + assert "--score is -5.0" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_number/test_tutorial001_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_number/test_tutorial001_an.py new file mode 100644 index 0000000000000000000000000000000000000000..9c9ad8be9a0ec4d02840ee66b43da23ec8b06627 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_number/test_tutorial001_an.py @@ -0,0 +1,80 @@ +import subprocess +import sys + +import pytest +import typer +import typer.core +from typer.testing import CliRunner + +from docs_src.parameter_types.number import tutorial001_an as mod + +runner = CliRunner() + +app = typer.Typer(rich_markup_mode=None) +app.command()(mod.main) + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "--age" in result.output + assert "INTEGER RANGE" in result.output + assert "--score" in result.output + assert "FLOAT RANGE" in result.output + + +def test_help_no_rich(monkeypatch: pytest.MonkeyPatch): + monkeypatch.setattr(typer.core, "HAS_RICH", False) + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "--age" in result.output + assert "INTEGER RANGE" in result.output + assert "--score" in result.output + assert "FLOAT RANGE" in result.output + + +def test_params(): + result = runner.invoke(app, ["5", "--age", "20", "--score", "90"]) + assert result.exit_code == 0 + assert "ID is 5" in result.output + assert "--age is 20" in result.output + assert "--score is 90.0" in result.output + + +def test_invalid_id(): + result = runner.invoke(app, ["1002"]) + assert result.exit_code != 0 + assert ( + "Invalid value for 'ID': 1002 is not in the range 0<=x<=1000." in result.output + ) + + +def test_invalid_age(): + result = runner.invoke(app, ["5", "--age", "15"]) + assert result.exit_code != 0 + assert "Invalid value for '--age'" in result.output + assert "15 is not in the range x>=18" in result.output + + +def test_invalid_score(): + result = runner.invoke(app, ["5", "--age", "20", "--score", "100.5"]) + assert result.exit_code != 0 + assert "Invalid value for '--score'" in result.output + assert "100.5 is not in the range x<=100." in result.output + + +def test_negative_score(): + result = runner.invoke(app, ["5", "--age", "20", "--score", "-5"]) + assert result.exit_code == 0 + assert "ID is 5" in result.output + assert "--age is 20" in result.output + assert "--score is -5.0" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_number/test_tutorial002.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_number/test_tutorial002.py new file mode 100644 index 0000000000000000000000000000000000000000..da8d1c1a6e4ea7ac1224afb2ce6c5e647bda7923 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_number/test_tutorial002.py @@ -0,0 +1,37 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.number import tutorial002 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_invalid_id(): + result = runner.invoke(app, ["1002"]) + assert result.exit_code != 0 + assert ( + "Invalid value for 'ID': 1002 is not in the range 0<=x<=1000" in result.output + ) + + +def test_clamped(): + result = runner.invoke(app, ["5", "--rank", "11", "--score", "-5"]) + assert result.exit_code == 0 + assert "ID is 5" in result.output + assert "--rank is 10" in result.output + assert "--score is 0" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_number/test_tutorial002_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_number/test_tutorial002_an.py new file mode 100644 index 0000000000000000000000000000000000000000..db1a73569f2946f68bde26005c198223fa5b71bb --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_number/test_tutorial002_an.py @@ -0,0 +1,37 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.number import tutorial002_an as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_invalid_id(): + result = runner.invoke(app, ["1002"]) + assert result.exit_code != 0 + assert ( + "Invalid value for 'ID': 1002 is not in the range 0<=x<=1000" in result.output + ) + + +def test_clamped(): + result = runner.invoke(app, ["5", "--rank", "11", "--score", "-5"]) + assert result.exit_code == 0 + assert "ID is 5" in result.output + assert "--rank is 10" in result.output + assert "--score is 0" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_number/test_tutorial003.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_number/test_tutorial003.py new file mode 100644 index 0000000000000000000000000000000000000000..a639447c988c7a691e19b2a637e024eac2763230 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_number/test_tutorial003.py @@ -0,0 +1,57 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.number import tutorial003 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_main(): + result = runner.invoke(app) + assert result.exit_code == 0 + assert "Verbose level is 0" in result.output + + +def test_verbose_1(): + result = runner.invoke(app, ["--verbose"]) + assert result.exit_code == 0 + assert "Verbose level is 1" in result.output + + +def test_verbose_3(): + result = runner.invoke(app, ["--verbose", "--verbose", "--verbose"]) + assert result.exit_code == 0 + assert "Verbose level is 3" in result.output + + +def test_verbose_short_1(): + result = runner.invoke(app, ["-v"]) + assert result.exit_code == 0 + assert "Verbose level is 1" in result.output + + +def test_verbose_short_3(): + result = runner.invoke(app, ["-v", "-v", "-v"]) + assert result.exit_code == 0 + assert "Verbose level is 3" in result.output + + +def test_verbose_short_3_condensed(): + result = runner.invoke(app, ["-vvv"]) + assert result.exit_code == 0 + assert "Verbose level is 3" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_number/test_tutorial003_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_number/test_tutorial003_an.py new file mode 100644 index 0000000000000000000000000000000000000000..71498a97310aefd1f18c8d8f588ed8a170ec036a --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_number/test_tutorial003_an.py @@ -0,0 +1,57 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.number import tutorial003_an as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_main(): + result = runner.invoke(app) + assert result.exit_code == 0 + assert "Verbose level is 0" in result.output + + +def test_verbose_1(): + result = runner.invoke(app, ["--verbose"]) + assert result.exit_code == 0 + assert "Verbose level is 1" in result.output + + +def test_verbose_3(): + result = runner.invoke(app, ["--verbose", "--verbose", "--verbose"]) + assert result.exit_code == 0 + assert "Verbose level is 3" in result.output + + +def test_verbose_short_1(): + result = runner.invoke(app, ["-v"]) + assert result.exit_code == 0 + assert "Verbose level is 1" in result.output + + +def test_verbose_short_3(): + result = runner.invoke(app, ["-v", "-v", "-v"]) + assert result.exit_code == 0 + assert "Verbose level is 3" in result.output + + +def test_verbose_short_3_condensed(): + result = runner.invoke(app, ["-vvv"]) + assert result.exit_code == 0 + assert "Verbose level is 3" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_path/__init__.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_path/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_path/test_tutorial001.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_path/test_tutorial001.py new file mode 100644 index 0000000000000000000000000000000000000000..e15121586ffca3449e731449dbd869a7141c7f27 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_path/test_tutorial001.py @@ -0,0 +1,54 @@ +import subprocess +import sys +from pathlib import Path + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.path import tutorial001 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_no_path(tmpdir): + Path(tmpdir) / "config.txt" + result = runner.invoke(app) + assert result.exit_code == 1 + assert "No config file" in result.output + assert "Aborted" in result.output + + +def test_not_exists(tmpdir): + config_file = Path(tmpdir) / "config.txt" + if config_file.exists(): # pragma: no cover + config_file.unlink() + result = runner.invoke(app, ["--config", f"{config_file}"]) + assert result.exit_code == 0 + assert "The config doesn't exist" in result.output + + +def test_exists(tmpdir): + config_file = Path(tmpdir) / "config.txt" + config_file.write_text("some settings") + result = runner.invoke(app, ["--config", f"{config_file}"]) + config_file.unlink() + assert result.exit_code == 0 + assert "Config file contents: some settings" in result.output + + +def test_dir(): + result = runner.invoke(app, ["--config", "./"]) + assert result.exit_code == 0 + assert "Config is a directory, will use all its config files" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_path/test_tutorial001_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_path/test_tutorial001_an.py new file mode 100644 index 0000000000000000000000000000000000000000..1db306f8d5e81161a8dc2866f2dcefcf529349bf --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_path/test_tutorial001_an.py @@ -0,0 +1,54 @@ +import subprocess +import sys +from pathlib import Path + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.path import tutorial001_an as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_no_path(tmpdir): + Path(tmpdir) / "config.txt" + result = runner.invoke(app) + assert result.exit_code == 1 + assert "No config file" in result.output + assert "Aborted" in result.output + + +def test_not_exists(tmpdir): + config_file = Path(tmpdir) / "config.txt" + if config_file.exists(): # pragma: no cover + config_file.unlink() + result = runner.invoke(app, ["--config", f"{config_file}"]) + assert result.exit_code == 0 + assert "The config doesn't exist" in result.output + + +def test_exists(tmpdir): + config_file = Path(tmpdir) / "config.txt" + config_file.write_text("some settings") + result = runner.invoke(app, ["--config", f"{config_file}"]) + config_file.unlink() + assert result.exit_code == 0 + assert "Config file contents: some settings" in result.output + + +def test_dir(): + result = runner.invoke(app, ["--config", "./"]) + assert result.exit_code == 0 + assert "Config is a directory, will use all its config files" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_path/test_tutorial002.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_path/test_tutorial002.py new file mode 100644 index 0000000000000000000000000000000000000000..c76596570962f759dce08ac6ce255f9e76498fea --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_path/test_tutorial002.py @@ -0,0 +1,49 @@ +import subprocess +import sys +from pathlib import Path + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.path import tutorial002 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_not_exists(tmpdir): + config_file = Path(tmpdir) / "config.txt" + if config_file.exists(): # pragma: no cover + config_file.unlink() + result = runner.invoke(app, ["--config", f"{config_file}"]) + assert result.exit_code != 0 + assert "Invalid value for '--config'" in result.output + assert "File" in result.output + assert "does not exist" in result.output + + +def test_exists(tmpdir): + config_file = Path(tmpdir) / "config.txt" + config_file.write_text("some settings") + result = runner.invoke(app, ["--config", f"{config_file}"]) + config_file.unlink() + assert result.exit_code == 0 + assert "Config file contents: some settings" in result.output + + +def test_dir(): + result = runner.invoke(app, ["--config", "./"]) + assert result.exit_code != 0 + assert "Invalid value for '--config'" in result.output + assert "File './' is a directory." in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_path/test_tutorial002_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_path/test_tutorial002_an.py new file mode 100644 index 0000000000000000000000000000000000000000..0defc6d3f43a55992ab2b0e7dea7443e318a3e0f --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_path/test_tutorial002_an.py @@ -0,0 +1,49 @@ +import subprocess +import sys +from pathlib import Path + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.path import tutorial002_an as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_not_exists(tmpdir): + config_file = Path(tmpdir) / "config.txt" + if config_file.exists(): # pragma: no cover + config_file.unlink() + result = runner.invoke(app, ["--config", f"{config_file}"]) + assert result.exit_code != 0 + assert "Invalid value for '--config'" in result.output + assert "File" in result.output + assert "does not exist" in result.output + + +def test_exists(tmpdir): + config_file = Path(tmpdir) / "config.txt" + config_file.write_text("some settings") + result = runner.invoke(app, ["--config", f"{config_file}"]) + config_file.unlink() + assert result.exit_code == 0 + assert "Config file contents: some settings" in result.output + + +def test_dir(): + result = runner.invoke(app, ["--config", "./"]) + assert result.exit_code != 0 + assert "Invalid value for '--config'" in result.output + assert "File './' is a directory." in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_uuid/__init__.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_uuid/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_uuid/test_tutorial001.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_uuid/test_tutorial001.py new file mode 100644 index 0000000000000000000000000000000000000000..aa9503e908e3bfe991488917868e2f6018992e33 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_parameter_types/test_uuid/test_tutorial001.py @@ -0,0 +1,37 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.parameter_types.uuid import tutorial001 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_main(): + result = runner.invoke(app, ["d48edaa6-871a-4082-a196-4daab372d4a1"]) + assert result.exit_code == 0 + assert "USER_ID is d48edaa6-871a-4082-a196-4daab372d4a1" in result.output + assert "UUID version is: 4" in result.output + + +def test_invalid_uuid(): + result = runner.invoke(app, ["7479706572-72756c6573"]) + assert result.exit_code != 0 + assert ( + "Invalid value for 'USER_ID': '7479706572-72756c6573' is not a valid UUID" + in result.output + ) + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_prompt/__init__.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_prompt/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_prompt/test_tutorial001.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_prompt/test_tutorial001.py new file mode 100644 index 0000000000000000000000000000000000000000..4b01d6d42d98279ba13e65edccdbf33aa54488b2 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_prompt/test_tutorial001.py @@ -0,0 +1,28 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.prompt import tutorial001 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_cli(): + result = runner.invoke(app, input="Camila\n") + assert result.exit_code == 0 + assert "What's your name?:" in result.output + assert "Hello Camila" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_prompt/test_tutorial002.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_prompt/test_tutorial002.py new file mode 100644 index 0000000000000000000000000000000000000000..9ed3c2d15275f5f87e351639a82c8e04eadd1253 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_prompt/test_tutorial002.py @@ -0,0 +1,36 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.prompt import tutorial002 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_cli(): + result = runner.invoke(app, input="y\n") + assert result.exit_code == 0 + assert "Are you sure you want to delete it? [y/N]:" in result.output + assert "Deleting it!" in result.output + + +def test_no_confirm(): + result = runner.invoke(app, input="n\n") + assert result.exit_code == 1 + assert "Are you sure you want to delete it? [y/N]:" in result.output + assert "Not deleting" in result.output + assert "Aborted" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_prompt/test_tutorial003.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_prompt/test_tutorial003.py new file mode 100644 index 0000000000000000000000000000000000000000..962ceca6ef391c8f8534d6f1341fcf32ebb069ac --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_prompt/test_tutorial003.py @@ -0,0 +1,35 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.prompt import tutorial003 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_cli(): + result = runner.invoke(app, input="y\n") + assert result.exit_code == 0 + assert "Are you sure you want to delete it? [y/N]:" in result.output + assert "Deleting it!" in result.output + + +def test_no_confirm(): + result = runner.invoke(app, input="n\n") + assert result.exit_code == 1 + assert "Are you sure you want to delete it? [y/N]:" in result.output + assert "Aborted" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/__init__.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_callback_override/__init__.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_callback_override/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_callback_override/test_tutorial001.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_callback_override/test_tutorial001.py new file mode 100644 index 0000000000000000000000000000000000000000..ec76dfebf15bba96daee29d8da53714db70fe15d --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_callback_override/test_tutorial001.py @@ -0,0 +1,26 @@ +import subprocess +import sys + +from typer.testing import CliRunner + +from docs_src.subcommands.callback_override import tutorial001 as mod + +runner = CliRunner() + +app = mod.app + + +def test_cli(): + result = runner.invoke(app, ["users", "create", "Camila"]) + assert result.exit_code == 0 + assert "Running a users command" in result.output + assert "Creating user: Camila" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_callback_override/test_tutorial002.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_callback_override/test_tutorial002.py new file mode 100644 index 0000000000000000000000000000000000000000..bfe8c35278184febab891786596faefb167fee7a --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_callback_override/test_tutorial002.py @@ -0,0 +1,26 @@ +import subprocess +import sys + +from typer.testing import CliRunner + +from docs_src.subcommands.callback_override import tutorial002 as mod + +runner = CliRunner() + +app = mod.app + + +def test_cli(): + result = runner.invoke(app, ["users", "create", "Camila"]) + assert result.exit_code == 0 + assert "Running a users command" in result.output + assert "Creating user: Camila" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_callback_override/test_tutorial003.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_callback_override/test_tutorial003.py new file mode 100644 index 0000000000000000000000000000000000000000..eb289a1443eab216a5271eb96285f5bc20a2a3bf --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_callback_override/test_tutorial003.py @@ -0,0 +1,31 @@ +import subprocess +import sys + +from typer.testing import CliRunner + +from docs_src.subcommands.callback_override import tutorial003 as mod + +runner = CliRunner() + +app = mod.app + + +def test_cli(): + result = runner.invoke(app, ["users", "create", "Camila"]) + assert result.exit_code == 0 + assert "Running a users command" not in result.output + assert "Callback override, running users command" in result.output + assert "Creating user: Camila" in result.output + + +def test_for_coverage(): + mod.default_callback() + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_callback_override/test_tutorial004.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_callback_override/test_tutorial004.py new file mode 100644 index 0000000000000000000000000000000000000000..f22b77f9168108a6fe23c8b587816473bf2303ba --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_callback_override/test_tutorial004.py @@ -0,0 +1,33 @@ +import subprocess +import sys + +from typer.testing import CliRunner + +from docs_src.subcommands.callback_override import tutorial004 as mod + +runner = CliRunner() + +app = mod.app + + +def test_cli(): + result = runner.invoke(app, ["users", "create", "Camila"]) + assert result.exit_code == 0 + assert "Running a users command" not in result.output + assert "Callback override, running users command" not in result.output + assert "I have the high land! Running users command" in result.output + assert "Creating user: Camila" in result.output + + +def test_for_coverage(): + mod.default_callback() + mod.user_callback() + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_name_help/__init__.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_name_help/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_name_help/test_tutorial001.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_name_help/test_tutorial001.py new file mode 100644 index 0000000000000000000000000000000000000000..fad028d4160e207b61a81024f27d0763bb341b62 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_name_help/test_tutorial001.py @@ -0,0 +1,39 @@ +import subprocess +import sys + +from typer.testing import CliRunner + +from docs_src.subcommands.name_help import tutorial001 as mod + +runner = CliRunner() + +app = mod.app + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "Commands" in result.output + assert "users" in result.output + assert "Manage users in the app." in result.output + + +def test_command_help(): + result = runner.invoke(app, ["users", "--help"]) + assert result.exit_code == 0 + assert "Manage users in the app." in result.output + + +def test_command(): + result = runner.invoke(app, ["users", "create", "Camila"]) + assert result.exit_code == 0 + assert "Creating user: Camila" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_name_help/test_tutorial002.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_name_help/test_tutorial002.py new file mode 100644 index 0000000000000000000000000000000000000000..d65b60a28703f6c1fe64643b39cd17c13cfa2216 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_name_help/test_tutorial002.py @@ -0,0 +1,39 @@ +import subprocess +import sys + +from typer.testing import CliRunner + +from docs_src.subcommands.name_help import tutorial002 as mod + +runner = CliRunner() + +app = mod.app + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "Commands" in result.output + assert "users" in result.output + assert "Manage users in the app." in result.output + + +def test_command_help(): + result = runner.invoke(app, ["users", "--help"]) + assert result.exit_code == 0 + assert "Manage users in the app." in result.output + + +def test_command(): + result = runner.invoke(app, ["users", "create", "Camila"]) + assert result.exit_code == 0 + assert "Creating user: Camila" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_name_help/test_tutorial003.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_name_help/test_tutorial003.py new file mode 100644 index 0000000000000000000000000000000000000000..0b64a47954714f5cc5fddd0a884bb2fa67d3f15e --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_name_help/test_tutorial003.py @@ -0,0 +1,39 @@ +import subprocess +import sys + +from typer.testing import CliRunner + +from docs_src.subcommands.name_help import tutorial003 as mod + +runner = CliRunner() + +app = mod.app + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "Commands" in result.output + assert "users" in result.output + assert "Manage users in the app." in result.output + + +def test_command_help(): + result = runner.invoke(app, ["users", "--help"]) + assert result.exit_code == 0 + assert "Manage users in the app." in result.output + + +def test_command(): + result = runner.invoke(app, ["users", "create", "Camila"]) + assert result.exit_code == 0 + assert "Creating user: Camila" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_name_help/test_tutorial004.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_name_help/test_tutorial004.py new file mode 100644 index 0000000000000000000000000000000000000000..667ce75a4ab69ff1f9b6bcbe80522c6afb8b2dd5 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_name_help/test_tutorial004.py @@ -0,0 +1,39 @@ +import subprocess +import sys + +from typer.testing import CliRunner + +from docs_src.subcommands.name_help import tutorial004 as mod + +runner = CliRunner() + +app = mod.app + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "Commands" in result.output + assert "users" in result.output + assert "Manage users in the app." in result.output + + +def test_command_help(): + result = runner.invoke(app, ["users", "--help"]) + assert result.exit_code == 0 + assert "Manage users in the app." in result.output + + +def test_command(): + result = runner.invoke(app, ["users", "create", "Camila"]) + assert result.exit_code == 0 + assert "Creating user: Camila" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_name_help/test_tutorial005.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_name_help/test_tutorial005.py new file mode 100644 index 0000000000000000000000000000000000000000..815af7c126984334df06fa08cdb097fcc6045d78 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_name_help/test_tutorial005.py @@ -0,0 +1,39 @@ +import subprocess +import sys + +from typer.testing import CliRunner + +from docs_src.subcommands.name_help import tutorial005 as mod + +runner = CliRunner() + +app = mod.app + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "Commands" in result.output + assert "new-users" in result.output + assert "I have the highland! Create some users." in result.output + + +def test_command_help(): + result = runner.invoke(app, ["new-users", "--help"]) + assert result.exit_code == 0 + assert "I have the highland! Create some users." in result.output + + +def test_command(): + result = runner.invoke(app, ["new-users", "create", "Camila"]) + assert result.exit_code == 0 + assert "Creating user: Camila" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_name_help/test_tutorial006.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_name_help/test_tutorial006.py new file mode 100644 index 0000000000000000000000000000000000000000..cf2117965ec50534aa90712b1149094249b62e7e --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_name_help/test_tutorial006.py @@ -0,0 +1,39 @@ +import subprocess +import sys + +from typer.testing import CliRunner + +from docs_src.subcommands.name_help import tutorial006 as mod + +runner = CliRunner() + +app = mod.app + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "Commands" in result.output + assert "exp-users" in result.output + assert "Explicit help." in result.output + + +def test_command_help(): + result = runner.invoke(app, ["exp-users", "--help"]) + assert result.exit_code == 0 + assert "Explicit help." in result.output + + +def test_command(): + result = runner.invoke(app, ["exp-users", "create", "Camila"]) + assert result.exit_code == 0 + assert "Creating user: Camila" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_name_help/test_tutorial007.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_name_help/test_tutorial007.py new file mode 100644 index 0000000000000000000000000000000000000000..f0632fb5eb362ff1c017ead4ebebf28f7d6ce8a0 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_name_help/test_tutorial007.py @@ -0,0 +1,39 @@ +import subprocess +import sys + +from typer.testing import CliRunner + +from docs_src.subcommands.name_help import tutorial007 as mod + +runner = CliRunner() + +app = mod.app + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "Commands" in result.output + assert "users" in result.output + assert "Help from callback for users." in result.output + + +def test_command_help(): + result = runner.invoke(app, ["users", "--help"]) + assert result.exit_code == 0 + assert "Help from callback for users." in result.output + + +def test_command(): + result = runner.invoke(app, ["users", "create", "Camila"]) + assert result.exit_code == 0 + assert "Creating user: Camila" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_name_help/test_tutorial008.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_name_help/test_tutorial008.py new file mode 100644 index 0000000000000000000000000000000000000000..17f0826ca896000f512193f3bab198f5966b2b38 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_name_help/test_tutorial008.py @@ -0,0 +1,39 @@ +import subprocess +import sys + +from typer.testing import CliRunner + +from docs_src.subcommands.name_help import tutorial008 as mod + +runner = CliRunner() + +app = mod.app + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "Commands" in result.output + assert "cake-sith-users" in result.output + assert "Unlimited powder! Eh, users." in result.output + + +def test_command_help(): + result = runner.invoke(app, ["cake-sith-users", "--help"]) + assert result.exit_code == 0 + assert "Unlimited powder! Eh, users." in result.output + + +def test_command(): + result = runner.invoke(app, ["cake-sith-users", "create", "Camila"]) + assert result.exit_code == 0 + assert "Creating user: Camila" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_tutorial001.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_tutorial001.py new file mode 100644 index 0000000000000000000000000000000000000000..6b228bd788bc54d69a3a84e8e3d20291c5371ee5 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_tutorial001.py @@ -0,0 +1,99 @@ +import os +import subprocess +import sys + +import pytest +from typer.testing import CliRunner + +from docs_src.subcommands import tutorial001 + +runner = CliRunner() + + +@pytest.fixture() +def mod(monkeypatch): + with monkeypatch.context(): + monkeypatch.syspath_prepend(list(tutorial001.__path__)[0]) + from docs_src.subcommands.tutorial001 import main + + return main + + +@pytest.fixture() +def app(mod): + return mod.app + + +def test_help(app): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "[OPTIONS] COMMAND [ARGS]..." in result.output + assert "Commands" in result.output + assert "items" in result.output + assert "users" in result.output + + +def test_help_items(app): + result = runner.invoke(app, ["items", "--help"]) + assert result.exit_code == 0 + assert "[OPTIONS] COMMAND [ARGS]..." in result.output + assert "Commands" in result.output + assert "create" in result.output + assert "delete" in result.output + assert "sell" in result.output + + +def test_items_create(app): + result = runner.invoke(app, ["items", "create", "Wand"]) + assert result.exit_code == 0 + assert "Creating item: Wand" in result.output + + +def test_items_sell(app): + result = runner.invoke(app, ["items", "sell", "Vase"]) + assert result.exit_code == 0 + assert "Selling item: Vase" in result.output + + +def test_items_delete(app): + result = runner.invoke(app, ["items", "delete", "Vase"]) + assert result.exit_code == 0 + assert "Deleting item: Vase" in result.output + + +def test_help_users(app): + result = runner.invoke(app, ["users", "--help"]) + assert result.exit_code == 0 + assert "[OPTIONS] COMMAND [ARGS]..." in result.output + assert "Commands" in result.output + assert "create" in result.output + assert "delete" in result.output + assert "sell" not in result.output + + +def test_users_create(app): + result = runner.invoke(app, ["users", "create", "Camila"]) + assert result.exit_code == 0 + assert "Creating user: Camila" in result.output + + +def test_users_delete(app): + result = runner.invoke(app, ["users", "delete", "Camila"]) + assert result.exit_code == 0 + assert "Deleting user: Camila" in result.output + + +def test_scripts(mod): + from docs_src.subcommands.tutorial001 import items, users + + env = os.environ.copy() + env["PYTHONPATH"] = ":".join(list(tutorial001.__path__)) + + for module in [mod, items, users]: + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", module.__file__, "--help"], + capture_output=True, + encoding="utf-8", + env=env, + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_tutorial002.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_tutorial002.py new file mode 100644 index 0000000000000000000000000000000000000000..2b86bb3730e6f169650785a5449f11d787f8419d --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_tutorial002.py @@ -0,0 +1,77 @@ +import subprocess +import sys + +from typer.testing import CliRunner + +from docs_src.subcommands.tutorial002 import main as mod + +app = mod.app +runner = CliRunner() + + +def test_help(): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "[OPTIONS] COMMAND [ARGS]..." in result.output + assert "Commands" in result.output + assert "items" in result.output + assert "users" in result.output + + +def test_help_items(): + result = runner.invoke(app, ["items", "--help"]) + assert result.exit_code == 0 + assert "[OPTIONS] COMMAND [ARGS]..." in result.output + assert "Commands" in result.output + assert "create" in result.output + assert "delete" in result.output + assert "sell" in result.output + + +def test_items_create(): + result = runner.invoke(app, ["items", "create", "Wand"]) + assert result.exit_code == 0 + assert "Creating item: Wand" in result.output + + +def test_items_sell(): + result = runner.invoke(app, ["items", "sell", "Vase"]) + assert result.exit_code == 0 + assert "Selling item: Vase" in result.output + + +def test_items_delete(): + result = runner.invoke(app, ["items", "delete", "Vase"]) + assert result.exit_code == 0 + assert "Deleting item: Vase" in result.output + + +def test_help_users(): + result = runner.invoke(app, ["users", "--help"]) + assert result.exit_code == 0 + assert "[OPTIONS] COMMAND [ARGS]..." in result.output + assert "Commands" in result.output + assert "create" in result.output + assert "delete" in result.output + assert "sell" not in result.output + + +def test_users_create(): + result = runner.invoke(app, ["users", "create", "Camila"]) + assert result.exit_code == 0 + assert "Creating user: Camila" in result.output + + +def test_users_delete(): + result = runner.invoke(app, ["users", "delete", "Camila"]) + assert result.exit_code == 0 + assert "Deleting user: Camila" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_tutorial003.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_tutorial003.py new file mode 100644 index 0000000000000000000000000000000000000000..ff30cde28b5e470ddf85c2edb8d9882f12ac0fcc --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_subcommands/test_tutorial003.py @@ -0,0 +1,172 @@ +import os +import subprocess +import sys + +import pytest +from typer.testing import CliRunner + +from docs_src.subcommands import tutorial003 +from docs_src.subcommands.tutorial003 import items, users + +runner = CliRunner() + + +@pytest.fixture() +def mod(monkeypatch): + with monkeypatch.context() as m: + m.syspath_prepend(list(tutorial003.__path__)[0]) + from docs_src.subcommands.tutorial003 import main + + return main + + +@pytest.fixture() +def app(mod): + return mod.app + + +def test_help(app): + result = runner.invoke(app, ["--help"]) + assert result.exit_code == 0 + assert "[OPTIONS] COMMAND [ARGS]..." in result.output + assert "Commands" in result.output + assert "items" in result.output + assert "users" in result.output + assert "lands" in result.output + + +def test_help_items(app): + result = runner.invoke(app, ["items", "--help"]) + assert result.exit_code == 0 + assert "[OPTIONS] COMMAND [ARGS]..." in result.output + assert "Commands" in result.output + assert "create" in result.output + assert "delete" in result.output + assert "sell" in result.output + + +def test_items_create(app): + result = runner.invoke(app, ["items", "create", "Wand"]) + assert result.exit_code == 0 + assert "Creating item: Wand" in result.output + # For coverage, because the monkeypatch above sometimes confuses coverage + result = runner.invoke(items.app, ["create", "Wand"]) + assert result.exit_code == 0 + assert "Creating item: Wand" in result.output + + +def test_items_sell(app): + result = runner.invoke(app, ["items", "sell", "Vase"]) + assert result.exit_code == 0 + assert "Selling item: Vase" in result.output + # For coverage, because the monkeypatch above sometimes confuses coverage + result = runner.invoke(items.app, ["sell", "Vase"]) + assert result.exit_code == 0 + assert "Selling item: Vase" in result.output + + +def test_items_delete(app): + result = runner.invoke(app, ["items", "delete", "Vase"]) + assert result.exit_code == 0 + assert "Deleting item: Vase" in result.output + # For coverage, because the monkeypatch above sometimes confuses coverage + result = runner.invoke(items.app, ["delete", "Vase"]) + assert result.exit_code == 0 + assert "Deleting item: Vase" in result.output + + +def test_help_users(app): + result = runner.invoke(app, ["users", "--help"]) + assert result.exit_code == 0 + assert "[OPTIONS] COMMAND [ARGS]..." in result.output + assert "Commands" in result.output + assert "create" in result.output + assert "delete" in result.output + assert "sell" not in result.output + + +def test_users_create(app): + result = runner.invoke(app, ["users", "create", "Camila"]) + assert result.exit_code == 0 + assert "Creating user: Camila" in result.output + # For coverage, because the monkeypatch above sometimes confuses coverage + result = runner.invoke(users.app, ["create", "Camila"]) + assert result.exit_code == 0 + assert "Creating user: Camila" in result.output + + +def test_users_delete(app): + result = runner.invoke(app, ["users", "delete", "Camila"]) + assert result.exit_code == 0 + assert "Deleting user: Camila" in result.output + # For coverage, because the monkeypatch above sometimes confuses coverage + result = runner.invoke(users.app, ["delete", "Camila"]) + assert result.exit_code == 0 + assert "Deleting user: Camila" in result.output + + +def test_help_lands(app): + result = runner.invoke(app, ["lands", "--help"]) + assert result.exit_code == 0 + assert "lands [OPTIONS] COMMAND [ARGS]..." in result.output + assert "Commands" in result.output + assert "reigns" in result.output + assert "towns" in result.output + + +def test_help_lands_reigns(app): + result = runner.invoke(app, ["lands", "reigns", "--help"]) + assert result.exit_code == 0 + assert "lands reigns [OPTIONS] COMMAND [ARGS]..." in result.output + assert "Commands" in result.output + assert "conquer" in result.output + assert "destroy" in result.output + + +def test_lands_reigns_conquer(app): + result = runner.invoke(app, ["lands", "reigns", "conquer", "Gondor"]) + assert result.exit_code == 0 + assert "Conquering reign: Gondor" in result.output + + +def test_lands_reigns_destroy(app): + result = runner.invoke(app, ["lands", "reigns", "destroy", "Mordor"]) + assert result.exit_code == 0 + assert "Destroying reign: Mordor" in result.output + + +def test_help_lands_towns(app): + result = runner.invoke(app, ["lands", "towns", "--help"]) + assert result.exit_code == 0 + assert "lands towns [OPTIONS] COMMAND [ARGS]..." in result.output + assert "Commands" in result.output + assert "burn" in result.output + assert "found" in result.output + + +def test_lands_towns_found(app): + result = runner.invoke(app, ["lands", "towns", "found", "Cartagena"]) + assert result.exit_code == 0 + assert "Founding town: Cartagena" in result.output + + +def test_lands_towns_burn(app): + result = runner.invoke(app, ["lands", "towns", "burn", "New Asgard"]) + assert result.exit_code == 0 + assert "Burning town: New Asgard" in result.output + + +def test_scripts(mod): + from docs_src.subcommands.tutorial003 import items, lands, reigns, towns, users + + env = os.environ.copy() + env["PYTHONPATH"] = ":".join(list(tutorial003.__path__)) + + for module in [mod, items, lands, reigns, towns, users]: + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", module.__file__, "--help"], + capture_output=True, + encoding="utf-8", + env=env, + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_terminating/__init__.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_terminating/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_terminating/test_tutorial001.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_terminating/test_tutorial001.py new file mode 100644 index 0000000000000000000000000000000000000000..6306fc2e15d2c44af39e97392f04578ea88cea8d --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_terminating/test_tutorial001.py @@ -0,0 +1,43 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.terminating import tutorial001 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_cli(): + result = runner.invoke(app, ["Camila"]) + assert result.exit_code == 0 + assert "User created: Camila" in result.output + assert "Notification sent for new user: Camila" in result.output + + +def test_existing(): + result = runner.invoke(app, ["rick"]) + assert result.exit_code == 0 + assert "The user already exists" in result.output + assert "Notification sent for new user" not in result.output + + +def test_existing_no_standalone(): + # Mainly for coverage + result = runner.invoke(app, ["rick"], standalone_mode=False) + assert result.exit_code == 0 + assert "The user already exists" in result.output + assert "Notification sent for new user" not in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_terminating/test_tutorial002.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_terminating/test_tutorial002.py new file mode 100644 index 0000000000000000000000000000000000000000..89f13bac8bf5388e09db3d3f2e1453925c69dd26 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_terminating/test_tutorial002.py @@ -0,0 +1,33 @@ +import subprocess +import sys + +import typer +from typer.testing import CliRunner + +from docs_src.terminating import tutorial002 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_cli(): + result = runner.invoke(app, ["Camila"]) + assert result.exit_code == 0 + assert "New user created: Camila" in result.output + + +def test_root(): + result = runner.invoke(app, ["root"]) + assert result.exit_code == 1 + assert "The root user is reserved" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_terminating/test_tutorial003.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_terminating/test_tutorial003.py new file mode 100644 index 0000000000000000000000000000000000000000..cee5ccac9433eaa425958fb4b31ffb9e81372969 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_terminating/test_tutorial003.py @@ -0,0 +1,51 @@ +import subprocess +import sys + +import pytest +import typer +import typer.core +from typer.testing import CliRunner + +from docs_src.terminating import tutorial003 as mod + +runner = CliRunner() + +app = typer.Typer() +app.command()(mod.main) + + +def test_cli(): + result = runner.invoke(app, ["Camila"]) + assert result.exit_code == 0 + assert "New user created: Camila" in result.output + + +def test_root(): + result = runner.invoke(app, ["root"]) + assert result.exit_code == 1 + assert "The root user is reserved" in result.output + assert "Aborted" in result.output + + +def test_root_no_standalone(): + # Mainly for coverage + result = runner.invoke(app, ["root"], standalone_mode=False) + assert result.exit_code == 1 + + +def test_root_no_rich(monkeypatch: pytest.MonkeyPatch): + # Mainly for coverage + monkeypatch.setattr(typer.core, "HAS_RICH", False) + result = runner.invoke(app, ["root"]) + assert result.exit_code == 1 + assert "The root user is reserved" in result.output + assert "Aborted!" in result.output + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_testing/__init__.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_testing/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_testing/test_app01.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_testing/test_app01.py new file mode 100644 index 0000000000000000000000000000000000000000..89acf56280fbf2a2358070e1deff30636572a0d1 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_testing/test_app01.py @@ -0,0 +1,18 @@ +import subprocess +import sys + +from docs_src.testing.app01 import main as mod +from docs_src.testing.app01.test_main import test_app + + +def test_app01(): + test_app() + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_testing/test_app02.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_testing/test_app02.py new file mode 100644 index 0000000000000000000000000000000000000000..e95e13ca5c014848908820db462137e2e102ed06 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_testing/test_app02.py @@ -0,0 +1,18 @@ +import subprocess +import sys + +from docs_src.testing.app02 import main as mod +from docs_src.testing.app02.test_main import test_app + + +def test_app02(): + test_app() + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_testing/test_app02_an.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_testing/test_app02_an.py new file mode 100644 index 0000000000000000000000000000000000000000..89764d63167a401420a5638df815faa03eb92cdd --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_testing/test_app02_an.py @@ -0,0 +1,18 @@ +import subprocess +import sys + +from docs_src.testing.app02_an import main as mod +from docs_src.testing.app02_an.test_main import test_app + + +def test_app02_an(): + test_app() + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_testing/test_app03.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_testing/test_app03.py new file mode 100644 index 0000000000000000000000000000000000000000..3f65d47806e17099ebf491af7b23dbbacf180b86 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_testing/test_app03.py @@ -0,0 +1,18 @@ +import subprocess +import sys + +from docs_src.testing.app03 import main as mod +from docs_src.testing.app03.test_main import test_app + + +def test_app03(): + test_app() + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_using_click/__init__.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_using_click/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_using_click/test_tutorial003.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_using_click/test_tutorial003.py new file mode 100644 index 0000000000000000000000000000000000000000..ccb481552df67f663eb5dc77349f60a852d39cee --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_using_click/test_tutorial003.py @@ -0,0 +1,40 @@ +import subprocess +import sys + +from click.testing import CliRunner + +from docs_src.using_click import tutorial003 as mod + +runner = CliRunner() + + +def test_cli(): + result = runner.invoke(mod.typer_click_object, []) + assert "Missing command" in result.output + + +def test_help(): + result = runner.invoke(mod.typer_click_object, ["--help"]) + assert result.exit_code == 0 + assert "Commands" in result.output + assert "top" in result.output + assert "hello" in result.output + + +def test_typer(): + result = runner.invoke(mod.typer_click_object, ["top"]) + assert "The Typer app is at the top level" in result.stdout + + +def test_click(): + result = runner.invoke(mod.typer_click_object, ["hello", "--name", "Camila"]) + assert "Hello Camila!" in result.stdout + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_using_click/test_tutorial004.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_using_click/test_tutorial004.py new file mode 100644 index 0000000000000000000000000000000000000000..902c7deca71042f9605cd4a510ff1bce23eb1834 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/info/test/typer/tests/test_tutorial/test_using_click/test_tutorial004.py @@ -0,0 +1,39 @@ +import subprocess +import sys + +from click.testing import CliRunner + +from docs_src.using_click import tutorial004 as mod + +runner = CliRunner() + + +def test_cli(): + result = runner.invoke(mod.cli, []) + assert "Usage" in result.output + assert "dropdb" in result.output + assert "sub" in result.output + + +def test_typer(): + result = runner.invoke(mod.cli, ["sub"]) + assert "Typer is now below Click, the Click app is the top level" in result.stdout + + +def test_click_initdb(): + result = runner.invoke(mod.cli, ["initdb"]) + assert "Initialized the database" in result.stdout + + +def test_click_dropdb(): + result = runner.invoke(mod.cli, ["dropdb"]) + assert "Dropped the database" in result.stdout + + +def test_script(): + result = subprocess.run( + [sys.executable, "-m", "coverage", "run", mod.__file__, "--help"], + capture_output=True, + encoding="utf-8", + ) + assert "Usage" in result.stdout diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer-0.20.0.dist-info/INSTALLER b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer-0.20.0.dist-info/INSTALLER new file mode 100644 index 0000000000000000000000000000000000000000..f79e4cb9aaf0b2d9e8ba78861e2071317b2384b3 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer-0.20.0.dist-info/INSTALLER @@ -0,0 +1 @@ +conda \ No newline at end of file diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer-0.20.0.dist-info/METADATA b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer-0.20.0.dist-info/METADATA new file mode 100644 index 0000000000000000000000000000000000000000..59c3ca16a1dcbea3e2cfc4bfe853428af95b4ef6 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer-0.20.0.dist-info/METADATA @@ -0,0 +1,424 @@ +Metadata-Version: 2.1 +Name: typer +Version: 0.20.0 +Summary: Typer, build great CLIs. Easy to code. Based on Python type hints. +Author-Email: =?utf-8?q?Sebasti=C3=A1n_Ram=C3=ADrez?= +Classifier: Intended Audience :: Information Technology +Classifier: Intended Audience :: System Administrators +Classifier: Operating System :: OS Independent +Classifier: Programming Language :: Python :: 3 +Classifier: Programming Language :: Python +Classifier: Topic :: Software Development :: Libraries :: Application Frameworks +Classifier: Topic :: Software Development :: Libraries :: Python Modules +Classifier: Topic :: Software Development :: Libraries +Classifier: Topic :: Software Development +Classifier: Typing :: Typed +Classifier: Development Status :: 4 - Beta +Classifier: Intended Audience :: Developers +Classifier: Programming Language :: Python :: 3 :: Only +Classifier: Programming Language :: Python :: 3.8 +Classifier: Programming Language :: Python :: 3.9 +Classifier: Programming Language :: Python :: 3.10 +Classifier: Programming Language :: Python :: 3.11 +Classifier: Programming Language :: Python :: 3.12 +Classifier: Programming Language :: Python :: 3.13 +Classifier: Programming Language :: Python :: 3.14 +Classifier: License :: OSI Approved :: MIT License +Project-URL: Homepage, https://github.com/fastapi/typer +Project-URL: Documentation, https://typer.tiangolo.com +Project-URL: Repository, https://github.com/fastapi/typer +Project-URL: Issues, https://github.com/fastapi/typer/issues +Project-URL: Changelog, https://typer.tiangolo.com/release-notes/ +Requires-Python: >=3.8 +Requires-Dist: click>=8.0.0 +Requires-Dist: typing-extensions>=3.7.4.3 +Requires-Dist: shellingham>=1.3.0 +Requires-Dist: rich>=10.11.0 +Description-Content-Type: text/markdown + +

+ Typer + +

+

+ Typer, build great CLIs. Easy to code. Based on Python type hints. +

+

+ + Test + + + Publish + + + Coverage + + Package version + +

+ +--- + +**Documentation**: https://typer.tiangolo.com + +**Source Code**: https://github.com/fastapi/typer + +--- + +Typer is a library for building CLI applications that users will **love using** and developers will **love creating**. Based on Python type hints. + +It's also a command line tool to run scripts, automatically converting them to CLI applications. + +The key features are: + +* **Intuitive to write**: Great editor support. Completion everywhere. Less time debugging. Designed to be easy to use and learn. Less time reading docs. +* **Easy to use**: It's easy to use for the final users. Automatic help, and automatic completion for all shells. +* **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/program that you can use to run scripts, automatically converting them to CLIs, even if they don't use Typer internally. + +## FastAPI of CLIs + +**Typer** is FastAPI's little sibling, it's the FastAPI of CLIs. + +## Installation + +Create and activate a virtual environment and then install **Typer**: + +
+ +```console +$ pip install typer +---> 100% +Successfully installed typer rich shellingham +``` + +
+ +## Example + +### The absolute minimum + +* Create a file `main.py` with: + +```Python +def main(name: str): + print(f"Hello {name}") +``` + +This script doesn't even use Typer internally. But you can use the `typer` command to run it as a CLI application. + +### Run it + +Run your application with the `typer` command: + +
+ +```console +// Run your application +$ typer main.py run + +// You get a nice error, you are missing NAME +Usage: typer [PATH_OR_MODULE] run [OPTIONS] NAME +Try 'typer [PATH_OR_MODULE] run --help' for help. +╭─ Error ───────────────────────────────────────────╮ +│ Missing argument 'NAME'. │ +╰───────────────────────────────────────────────────╯ + + +// You get a --help for free +$ typer main.py run --help + +Usage: typer [PATH_OR_MODULE] run [OPTIONS] NAME + +Run the provided Typer app. + +╭─ Arguments ───────────────────────────────────────╮ +│ * name TEXT [default: None] [required] | +╰───────────────────────────────────────────────────╯ +╭─ Options ─────────────────────────────────────────╮ +│ --help Show this message and exit. │ +╰───────────────────────────────────────────────────╯ + +// Now pass the NAME argument +$ typer main.py run Camila + +Hello Camila + +// It works! 🎉 +``` + +
+ +This is the simplest use case, not even using Typer internally, but it can already be quite useful for simple scripts. + +**Note**: auto-completion works when you create a Python package and run it with `--install-completion` or when you use the `typer` command. + +## Use Typer in your code + +Now let's start using Typer in your own code, update `main.py` with: + +```Python +import typer + + +def main(name: str): + print(f"Hello {name}") + + +if __name__ == "__main__": + typer.run(main) +``` + +Now you could run it with Python directly: + +
+ +```console +// Run your application +$ python main.py + +// You get a nice error, you are missing NAME +Usage: main.py [OPTIONS] NAME +Try 'main.py --help' for help. +╭─ Error ───────────────────────────────────────────╮ +│ Missing argument 'NAME'. │ +╰───────────────────────────────────────────────────╯ + + +// You get a --help for free +$ python main.py --help + +Usage: main.py [OPTIONS] NAME + +╭─ Arguments ───────────────────────────────────────╮ +│ * name TEXT [default: None] [required] | +╰───────────────────────────────────────────────────╯ +╭─ Options ─────────────────────────────────────────╮ +│ --help Show this message and exit. │ +╰───────────────────────────────────────────────────╯ + +// Now pass the NAME argument +$ python main.py Camila + +Hello Camila + +// It works! 🎉 +``` + +
+ +**Note**: you can also call this same script with the `typer` command, but you don't need to. + +## Example upgrade + +This was the simplest example possible. + +Now let's see one a bit more complex. + +### An example with two subcommands + +Modify the file `main.py`. + +Create a `typer.Typer()` app, and create two subcommands with their parameters. + +```Python hl_lines="3 6 11 20" +import typer + +app = typer.Typer() + + +@app.command() +def hello(name: str): + print(f"Hello {name}") + + +@app.command() +def goodbye(name: str, formal: bool = False): + if formal: + print(f"Goodbye Ms. {name}. Have a good day.") + else: + print(f"Bye {name}!") + + +if __name__ == "__main__": + app() +``` + +And that will: + +* Explicitly create a `typer.Typer` app. + * The previous `typer.run` actually creates one implicitly for you. +* Add two subcommands with `@app.command()`. +* Execute the `app()` itself, as if it was a function (instead of `typer.run`). + +### Run the upgraded example + +Check the new help: + +
+ +```console +$ python main.py --help + + Usage: main.py [OPTIONS] COMMAND [ARGS]... + +╭─ Options ─────────────────────────────────────────╮ +│ --install-completion Install completion │ +│ for the current │ +│ shell. │ +│ --show-completion Show completion for │ +│ the current shell, │ +│ to copy it or │ +│ customize the │ +│ installation. │ +│ --help Show this message │ +│ and exit. │ +╰───────────────────────────────────────────────────╯ +╭─ Commands ────────────────────────────────────────╮ +│ goodbye │ +│ hello │ +╰───────────────────────────────────────────────────╯ + +// When you create a package you get ✨ auto-completion ✨ for free, installed with --install-completion + +// You have 2 subcommands (the 2 functions): goodbye and hello +``` + +
+ +Now check the help for the `hello` command: + +
+ +```console +$ python main.py hello --help + + Usage: main.py hello [OPTIONS] NAME + +╭─ Arguments ───────────────────────────────────────╮ +│ * name TEXT [default: None] [required] │ +╰───────────────────────────────────────────────────╯ +╭─ Options ─────────────────────────────────────────╮ +│ --help Show this message and exit. │ +╰───────────────────────────────────────────────────╯ +``` + +
+ +And now check the help for the `goodbye` command: + +
+ +```console +$ python main.py goodbye --help + + Usage: main.py goodbye [OPTIONS] NAME + +╭─ Arguments ───────────────────────────────────────╮ +│ * name TEXT [default: None] [required] │ +╰───────────────────────────────────────────────────╯ +╭─ Options ─────────────────────────────────────────╮ +│ --formal --no-formal [default: no-formal] │ +│ --help Show this message │ +│ and exit. │ +╰───────────────────────────────────────────────────╯ + +// Automatic --formal and --no-formal for the bool option 🎉 +``` + +
+ +Now you can try out the new command line application: + +
+ +```console +// Use it with the hello command + +$ python main.py hello Camila + +Hello Camila + +// And with the goodbye command + +$ python main.py goodbye Camila + +Bye Camila! + +// And with --formal + +$ python main.py goodbye --formal Camila + +Goodbye Ms. Camila. Have a good day. +``` + +
+ +**Note**: If your app only has one command, by default the command name is **omitted** in usage: `python main.py Camila`. However, when there are multiple commands, you must **explicitly include the command name**: `python main.py hello Camila`. See [One or Multiple Commands](https://typer.tiangolo.com/tutorial/commands/one-or-multiple/) for more details. + +### Recap + +In summary, you declare **once** the types of parameters (*CLI arguments* and *CLI options*) as function parameters. + +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**. + +For example, for an `int`: + +```Python +total: int +``` + +or for a `bool` flag: + +```Python +force: bool +``` + +And similarly for **files**, **paths**, **enums** (choices), etc. And there are tools to create **groups of subcommands**, add metadata, extra **validation**, etc. + +**You get**: great editor support, including **completion** and **type checks** everywhere. + +**Your users get**: automatic **`--help`**, **auto-completion** in their terminal (Bash, Zsh, Fish, PowerShell) when they install your package or when using the `typer` command. + +For a more complete example including more features, see the Tutorial - User Guide. + +## Dependencies + +**Typer** stands on the shoulders of a giant. Its only internal required dependency is Click. + +By default it also comes with extra standard dependencies: + +* rich: to show nicely formatted errors automatically. +* 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-slim` + +If you don't want the extra standard optional dependencies, install `typer-slim` instead. + +When you install with: + +```bash +pip install typer +``` + +...it includes the same code and dependencies as: + +```bash +pip install "typer-slim[standard]" +``` + +The `standard` extra dependencies are `rich` and `shellingham`. + +**Note**: The `typer` command is only included in the `typer` package. + +## License + +This project is licensed under the terms of the MIT license. diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer-0.20.0.dist-info/RECORD b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer-0.20.0.dist-info/RECORD new file mode 100644 index 0000000000000000000000000000000000000000..9f681e0f63857dc1e2401a2e33612cfd4a17f01e --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer-0.20.0.dist-info/RECORD @@ -0,0 +1,41 @@ +../../../bin/typer,sha256=iynu2VE2b2VHMvhWVfseeeWTh6uM9mtRuM18NScXMXw,439 +typer-0.20.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4 +typer-0.20.0.dist-info/METADATA,sha256=M4u-og4EB34dfvLDyIF9gu2pW6pJF3xp1s8di2p7Mz4,16081 +typer-0.20.0.dist-info/RECORD,, +typer-0.20.0.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +typer-0.20.0.dist-info/WHEEL,sha256=tsUv_t7BDeJeRHaSrczbGeuK-TtDpGsWi_JfpzD255I,90 +typer-0.20.0.dist-info/entry_points.txt,sha256=YO13ByiqWeuas9V0JADLUARZFUe_cwU_7wmTNvxBYQ8,57 +typer-0.20.0.dist-info/licenses/LICENSE,sha256=WJks68-N-25AxOIRLtEhJsJDZm3KORKj14t-ysSFnUk,1086 +typer/__init__.py,sha256=jWmVfUPJA3hPwoylWh1Q7_QbMFvHAc2gFwnJK46hN_A,1596 +typer/__main__.py,sha256=bYt9eEaoRQWdejEHFD8REx9jxVEdZptECFsV7F49Ink,30 +typer/__pycache__/__init__.cpython-313.pyc,, +typer/__pycache__/__main__.cpython-313.pyc,, +typer/__pycache__/_completion_classes.cpython-313.pyc,, +typer/__pycache__/_completion_shared.cpython-313.pyc,, +typer/__pycache__/_types.cpython-313.pyc,, +typer/__pycache__/_typing.cpython-313.pyc,, +typer/__pycache__/cli.cpython-313.pyc,, +typer/__pycache__/colors.cpython-313.pyc,, +typer/__pycache__/completion.cpython-313.pyc,, +typer/__pycache__/core.cpython-313.pyc,, +typer/__pycache__/main.cpython-313.pyc,, +typer/__pycache__/models.cpython-313.pyc,, +typer/__pycache__/params.cpython-313.pyc,, +typer/__pycache__/rich_utils.cpython-313.pyc,, +typer/__pycache__/testing.cpython-313.pyc,, +typer/__pycache__/utils.cpython-313.pyc,, +typer/_completion_classes.py,sha256=Px9bV56Y4J_F9S_sUI2iPpUh_i--Chocxrk4HAut2HE,7385 +typer/_completion_shared.py,sha256=4lFOUhXSry2bIZR9al7Uq33itpgSzg6eagquAysNmOE,8758 +typer/_types.py,sha256=kSLxhKmX37YzizQjqYUAWmr_JFcCW5vhEc4YshDTC9Q,1031 +typer/_typing.py,sha256=uP-V8WjvAuF-FLWUEfVmuhVA9San5tgeN5CJqQkIjeI,2605 +typer/cli.py,sha256=Yc-A5w2CAyqE-LWgpS-3KZVJvlcw6flfyIQ6CmEaXlw,9670 +typer/colors.py,sha256=e42j8uB520hLpX5C_0fiR3OOoIFMbhO3ADZvv6hlAV8,430 +typer/completion.py,sha256=d1AiptrsEwUeSPQaIA5oiv4T3Xy3MDq5o3VIjK39Qeg,4810 +typer/core.py,sha256=D75-HYAsh9UYvP-IFzgek_Sgu029cJeMfgl9A5qXzGo,28151 +typer/main.py,sha256=0IicpEE7INQXCofCOVp0pXyw720jiBe3xUIWA7M1cs0,42360 +typer/models.py,sha256=Q6v9BQYutNlH44i7fn0YbZ-OeRXsgib1o_tR4gTmqow,17188 +typer/params.py,sha256=MRVCwRPzNMkOdYU6VNVGkawX_gAoYzbiCfL_tYcR6x8,14929 +typer/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0 +typer/rich_utils.py,sha256=ONTQLCg8WD6ngMS5hkFq-gjCVfUVOY9NrvydYtWzulI,26260 +typer/testing.py,sha256=UAU8sywhunldA9yG5QLVBEMCuU_8B4OC0buryz58PR4,884 +typer/utils.py,sha256=G0qddDX06YtHuMJNCmj-frLJYkYxfUa7iwO6KOTX2FI,7368 diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer-0.20.0.dist-info/REQUESTED b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer-0.20.0.dist-info/REQUESTED new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer-0.20.0.dist-info/WHEEL b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer-0.20.0.dist-info/WHEEL new file mode 100644 index 0000000000000000000000000000000000000000..2efd4ed297d0997e50fe9367d3d9024fa072dd4a --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer-0.20.0.dist-info/WHEEL @@ -0,0 +1,4 @@ +Wheel-Version: 1.0 +Generator: pdm-backend (2.4.6) +Root-Is-Purelib: true +Tag: py3-none-any diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer-0.20.0.dist-info/entry_points.txt b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer-0.20.0.dist-info/entry_points.txt new file mode 100644 index 0000000000000000000000000000000000000000..ca44c05a071b87fe02a3724bd895838305fe4e5d --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer-0.20.0.dist-info/entry_points.txt @@ -0,0 +1,5 @@ +[console_scripts] +typer = typer.cli:main + +[gui_scripts] + diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer-0.20.0.dist-info/licenses/LICENSE b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer-0.20.0.dist-info/licenses/LICENSE new file mode 100644 index 0000000000000000000000000000000000000000..a7694736cf37716aafec14b24aa8d6316ebe07a3 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer-0.20.0.dist-info/licenses/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2019 Sebastián Ramírez + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/__init__.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/__init__.py new file mode 100644 index 0000000000000000000000000000000000000000..a2e897cdd711f5bec3f4c62112fbf9a80e62015a --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/__init__.py @@ -0,0 +1,39 @@ +"""Typer, build great CLIs. Easy to code. Based on Python type hints.""" + +__version__ = "0.20.0" + +from shutil import get_terminal_size as get_terminal_size + +from click.exceptions import Abort as Abort +from click.exceptions import BadParameter as BadParameter +from click.exceptions import Exit as Exit +from click.termui import clear as clear +from click.termui import confirm as confirm +from click.termui import echo_via_pager as echo_via_pager +from click.termui import edit as edit +from click.termui import getchar as getchar +from click.termui import pause as pause +from click.termui import progressbar as progressbar +from click.termui import prompt as prompt +from click.termui import secho as secho +from click.termui import style as style +from click.termui import unstyle as unstyle +from click.utils import echo as echo +from click.utils import format_filename as format_filename +from click.utils import get_app_dir as get_app_dir +from click.utils import get_binary_stream as get_binary_stream +from click.utils import get_text_stream as get_text_stream +from click.utils import open_file as open_file + +from . import colors as colors +from .main import Typer as Typer +from .main import launch as launch +from .main import run as run +from .models import CallbackParam as CallbackParam +from .models import Context as Context +from .models import FileBinaryRead as FileBinaryRead +from .models import FileBinaryWrite as FileBinaryWrite +from .models import FileText as FileText +from .models import FileTextWrite as FileTextWrite +from .params import Argument as Argument +from .params import Option as Option diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/__main__.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/__main__.py new file mode 100644 index 0000000000000000000000000000000000000000..4e28416e104515e90fca4b69cc60d0c61fd15d61 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/__main__.py @@ -0,0 +1,3 @@ +from .cli import main + +main() diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/_completion_classes.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/_completion_classes.py new file mode 100644 index 0000000000000000000000000000000000000000..5980248afe4863048ecdc42e6b83281f2f870622 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/_completion_classes.py @@ -0,0 +1,211 @@ +import importlib.util +import os +import re +import sys +from typing import Any, Dict, List, Tuple + +import click +import click.parser +import click.shell_completion + +from ._completion_shared import ( + COMPLETION_SCRIPT_BASH, + COMPLETION_SCRIPT_FISH, + COMPLETION_SCRIPT_POWER_SHELL, + COMPLETION_SCRIPT_ZSH, + Shells, +) + +try: + from click.shell_completion import split_arg_string as click_split_arg_string +except ImportError: # pragma: no cover + # TODO: when removing support for Click < 8.2, remove this import + from click.parser import ( # type: ignore[no-redef] + split_arg_string as click_split_arg_string, + ) + +try: + import shellingham +except ImportError: # pragma: no cover + shellingham = None + + +def _sanitize_help_text(text: str) -> str: + """Sanitizes the help text by removing rich tags""" + if not importlib.util.find_spec("rich"): + return text + from . import rich_utils + + return rich_utils.rich_render_text(text) + + +class BashComplete(click.shell_completion.BashComplete): + name = Shells.bash.value + source_template = COMPLETION_SCRIPT_BASH + + def source_vars(self) -> Dict[str, Any]: + return { + "complete_func": self.func_name, + "autocomplete_var": self.complete_var, + "prog_name": self.prog_name, + } + + def get_completion_args(self) -> Tuple[List[str], str]: + cwords = click_split_arg_string(os.environ["COMP_WORDS"]) + cword = int(os.environ["COMP_CWORD"]) + args = cwords[1:cword] + + try: + incomplete = cwords[cword] + except IndexError: + incomplete = "" + + return args, incomplete + + def format_completion(self, item: click.shell_completion.CompletionItem) -> str: + # TODO: Explore replicating the new behavior from Click, with item types and + # triggering completion for files and directories + # return f"{item.type},{item.value}" + return f"{item.value}" + + def complete(self) -> str: + args, incomplete = self.get_completion_args() + completions = self.get_completions(args, incomplete) + out = [self.format_completion(item) for item in completions] + return "\n".join(out) + + +class ZshComplete(click.shell_completion.ZshComplete): + name = Shells.zsh.value + source_template = COMPLETION_SCRIPT_ZSH + + def source_vars(self) -> Dict[str, Any]: + return { + "complete_func": self.func_name, + "autocomplete_var": self.complete_var, + "prog_name": self.prog_name, + } + + def get_completion_args(self) -> Tuple[List[str], str]: + completion_args = os.getenv("_TYPER_COMPLETE_ARGS", "") + cwords = click_split_arg_string(completion_args) + args = cwords[1:] + if args and not completion_args.endswith(" "): + incomplete = args[-1] + args = args[:-1] + else: + incomplete = "" + return args, incomplete + + def format_completion(self, item: click.shell_completion.CompletionItem) -> str: + def escape(s: str) -> str: + return ( + s.replace('"', '""') + .replace("'", "''") + .replace("$", "\\$") + .replace("`", "\\`") + .replace(":", r"\\:") + ) + + # TODO: Explore replicating the new behavior from Click, pay attention to + # the difference with and without escape + # return f"{item.type}\n{item.value}\n{item.help if item.help else '_'}" + if item.help: + return f'"{escape(item.value)}":"{_sanitize_help_text(escape(item.help))}"' + else: + return f'"{escape(item.value)}"' + + def complete(self) -> str: + args, incomplete = self.get_completion_args() + completions = self.get_completions(args, incomplete) + res = [self.format_completion(item) for item in completions] + if res: + args_str = "\n".join(res) + return f"_arguments '*: :(({args_str}))'" + else: + return "_files" + + +class FishComplete(click.shell_completion.FishComplete): + name = Shells.fish.value + source_template = COMPLETION_SCRIPT_FISH + + def source_vars(self) -> Dict[str, Any]: + return { + "complete_func": self.func_name, + "autocomplete_var": self.complete_var, + "prog_name": self.prog_name, + } + + def get_completion_args(self) -> Tuple[List[str], str]: + completion_args = os.getenv("_TYPER_COMPLETE_ARGS", "") + cwords = click_split_arg_string(completion_args) + args = cwords[1:] + if args and not completion_args.endswith(" "): + incomplete = args[-1] + args = args[:-1] + else: + incomplete = "" + return args, incomplete + + def format_completion(self, item: click.shell_completion.CompletionItem) -> str: + # TODO: Explore replicating the new behavior from Click, pay attention to + # the difference with and without formatted help + # if item.help: + # return f"{item.type},{item.value}\t{item.help}" + + # return f"{item.type},{item.value} + if item.help: + formatted_help = re.sub(r"\s", " ", item.help) + return f"{item.value}\t{_sanitize_help_text(formatted_help)}" + else: + return f"{item.value}" + + def complete(self) -> str: + complete_action = os.getenv("_TYPER_COMPLETE_FISH_ACTION", "") + args, incomplete = self.get_completion_args() + completions = self.get_completions(args, incomplete) + show_args = [self.format_completion(item) for item in completions] + if complete_action == "get-args": + if show_args: + return "\n".join(show_args) + elif complete_action == "is-args": + if show_args: + # Activate complete args (no files) + sys.exit(0) + else: + # Deactivate complete args (allow files) + sys.exit(1) + return "" # pragma: no cover + + +class PowerShellComplete(click.shell_completion.ShellComplete): + name = Shells.powershell.value + source_template = COMPLETION_SCRIPT_POWER_SHELL + + def source_vars(self) -> Dict[str, Any]: + return { + "complete_func": self.func_name, + "autocomplete_var": self.complete_var, + "prog_name": self.prog_name, + } + + def get_completion_args(self) -> Tuple[List[str], str]: + completion_args = os.getenv("_TYPER_COMPLETE_ARGS", "") + incomplete = os.getenv("_TYPER_COMPLETE_WORD_TO_COMPLETE", "") + cwords = click_split_arg_string(completion_args) + args = cwords[1:-1] if incomplete else cwords[1:] + return args, incomplete + + def format_completion(self, item: click.shell_completion.CompletionItem) -> str: + return f"{item.value}:::{_sanitize_help_text(item.help) if item.help else ' '}" + + +def completion_init() -> None: + click.shell_completion.add_completion_class(BashComplete, Shells.bash.value) + click.shell_completion.add_completion_class(ZshComplete, Shells.zsh.value) + click.shell_completion.add_completion_class(FishComplete, Shells.fish.value) + click.shell_completion.add_completion_class( + PowerShellComplete, Shells.powershell.value + ) + click.shell_completion.add_completion_class(PowerShellComplete, Shells.pwsh.value) diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/_completion_shared.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/_completion_shared.py new file mode 100644 index 0000000000000000000000000000000000000000..cc0add992c722c6044342d912f2772aedca86538 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/_completion_shared.py @@ -0,0 +1,240 @@ +import os +import re +import subprocess +from enum import Enum +from pathlib import Path +from typing import Optional, Tuple + +import click + +try: + import shellingham +except ImportError: # pragma: no cover + shellingham = None + + +class Shells(str, Enum): + bash = "bash" + zsh = "zsh" + fish = "fish" + powershell = "powershell" + pwsh = "pwsh" + + +COMPLETION_SCRIPT_BASH = """ +%(complete_func)s() { + local IFS=$'\n' + COMPREPLY=( $( env COMP_WORDS="${COMP_WORDS[*]}" \\ + COMP_CWORD=$COMP_CWORD \\ + %(autocomplete_var)s=complete_bash $1 ) ) + return 0 +} + +complete -o default -F %(complete_func)s %(prog_name)s +""" + +COMPLETION_SCRIPT_ZSH = """ +#compdef %(prog_name)s + +%(complete_func)s() { + eval $(env _TYPER_COMPLETE_ARGS="${words[1,$CURRENT]}" %(autocomplete_var)s=complete_zsh %(prog_name)s) +} + +compdef %(complete_func)s %(prog_name)s +""" + +COMPLETION_SCRIPT_FISH = 'complete --command %(prog_name)s --no-files --arguments "(env %(autocomplete_var)s=complete_fish _TYPER_COMPLETE_FISH_ACTION=get-args _TYPER_COMPLETE_ARGS=(commandline -cp) %(prog_name)s)" --condition "env %(autocomplete_var)s=complete_fish _TYPER_COMPLETE_FISH_ACTION=is-args _TYPER_COMPLETE_ARGS=(commandline -cp) %(prog_name)s"' + +COMPLETION_SCRIPT_POWER_SHELL = """ +Import-Module PSReadLine +Set-PSReadLineKeyHandler -Chord Tab -Function MenuComplete +$scriptblock = { + param($wordToComplete, $commandAst, $cursorPosition) + $Env:%(autocomplete_var)s = "complete_powershell" + $Env:_TYPER_COMPLETE_ARGS = $commandAst.ToString() + $Env:_TYPER_COMPLETE_WORD_TO_COMPLETE = $wordToComplete + %(prog_name)s | ForEach-Object { + $commandArray = $_ -Split ":::" + $command = $commandArray[0] + $helpString = $commandArray[1] + [System.Management.Automation.CompletionResult]::new( + $command, $command, 'ParameterValue', $helpString) + } + $Env:%(autocomplete_var)s = "" + $Env:_TYPER_COMPLETE_ARGS = "" + $Env:_TYPER_COMPLETE_WORD_TO_COMPLETE = "" +} +Register-ArgumentCompleter -Native -CommandName %(prog_name)s -ScriptBlock $scriptblock +""" + +_completion_scripts = { + "bash": COMPLETION_SCRIPT_BASH, + "zsh": COMPLETION_SCRIPT_ZSH, + "fish": COMPLETION_SCRIPT_FISH, + "powershell": COMPLETION_SCRIPT_POWER_SHELL, + "pwsh": COMPLETION_SCRIPT_POWER_SHELL, +} + +# TODO: Probably refactor this, copied from Click 7.x +_invalid_ident_char_re = re.compile(r"[^a-zA-Z0-9_]") + + +def get_completion_script(*, prog_name: str, complete_var: str, shell: str) -> str: + cf_name = _invalid_ident_char_re.sub("", prog_name.replace("-", "_")) + script = _completion_scripts.get(shell) + if script is None: + click.echo(f"Shell {shell} not supported.", err=True) + raise click.exceptions.Exit(1) + return ( + script + % { + "complete_func": f"_{cf_name}_completion", + "prog_name": prog_name, + "autocomplete_var": complete_var, + } + ).strip() + + +def install_bash(*, prog_name: str, complete_var: str, shell: str) -> Path: + # Ref: https://github.com/scop/bash-completion#faq + # It seems bash-completion is the official completion system for bash: + # Ref: https://www.gnu.org/software/bash/manual/html_node/A-Programmable-Completion-Example.html + # But installing in the locations from the docs doesn't seem to have effect + completion_path = Path.home() / ".bash_completions" / f"{prog_name}.sh" + rc_path = Path.home() / ".bashrc" + rc_path.parent.mkdir(parents=True, exist_ok=True) + rc_content = "" + if rc_path.is_file(): + rc_content = rc_path.read_text() + completion_init_lines = [f"source '{completion_path}'"] + for line in completion_init_lines: + if line not in rc_content: # pragma: no cover + rc_content += f"\n{line}" + rc_content += "\n" + rc_path.write_text(rc_content) + # Install completion + completion_path.parent.mkdir(parents=True, exist_ok=True) + script_content = get_completion_script( + prog_name=prog_name, complete_var=complete_var, shell=shell + ) + completion_path.write_text(script_content) + return completion_path + + +def install_zsh(*, prog_name: str, complete_var: str, shell: str) -> Path: + # Setup Zsh and load ~/.zfunc + zshrc_path = Path.home() / ".zshrc" + zshrc_path.parent.mkdir(parents=True, exist_ok=True) + zshrc_content = "" + if zshrc_path.is_file(): + zshrc_content = zshrc_path.read_text() + completion_line = "fpath+=~/.zfunc; autoload -Uz compinit; compinit" + if completion_line not in zshrc_content: + zshrc_content += f"\n{completion_line}\n" + style_line = "zstyle ':completion:*' menu select" + # TODO: consider setting the style only for the current program + # style_line = f"zstyle ':completion:*:*:{prog_name}:*' menu select" + # Install zstyle completion config only if the user doesn't have a customization + if "zstyle" not in zshrc_content: + zshrc_content += f"\n{style_line}\n" + zshrc_content = f"{zshrc_content.strip()}\n" + zshrc_path.write_text(zshrc_content) + # Install completion under ~/.zfunc/ + path_obj = Path.home() / f".zfunc/_{prog_name}" + path_obj.parent.mkdir(parents=True, exist_ok=True) + script_content = get_completion_script( + prog_name=prog_name, complete_var=complete_var, shell=shell + ) + path_obj.write_text(script_content) + return path_obj + + +def install_fish(*, prog_name: str, complete_var: str, shell: str) -> Path: + path_obj = Path.home() / f".config/fish/completions/{prog_name}.fish" + parent_dir: Path = path_obj.parent + parent_dir.mkdir(parents=True, exist_ok=True) + script_content = get_completion_script( + prog_name=prog_name, complete_var=complete_var, shell=shell + ) + path_obj.write_text(f"{script_content}\n") + return path_obj + + +def install_powershell(*, prog_name: str, complete_var: str, shell: str) -> Path: + subprocess.run( + [ + shell, + "-Command", + "Set-ExecutionPolicy", + "Unrestricted", + "-Scope", + "CurrentUser", + ] + ) + result = subprocess.run( + [shell, "-NoProfile", "-Command", "echo", "$profile"], + check=True, + stdout=subprocess.PIPE, + ) + if result.returncode != 0: # pragma: no cover + click.echo("Couldn't get PowerShell user profile", err=True) + raise click.exceptions.Exit(result.returncode) + path_str = "" + if isinstance(result.stdout, str): # pragma: no cover + path_str = result.stdout + if isinstance(result.stdout, bytes): + for encoding in ["windows-1252", "utf8", "cp850"]: + try: + path_str = result.stdout.decode(encoding) + break + except UnicodeDecodeError: # pragma: no cover + pass + if not path_str: # pragma: no cover + click.echo("Couldn't decode the path automatically", err=True) + raise click.exceptions.Exit(1) + path_obj = Path(path_str.strip()) + parent_dir: Path = path_obj.parent + parent_dir.mkdir(parents=True, exist_ok=True) + script_content = get_completion_script( + prog_name=prog_name, complete_var=complete_var, shell=shell + ) + with path_obj.open(mode="a") as f: + f.write(f"{script_content}\n") + return path_obj + + +def install( + shell: Optional[str] = None, + prog_name: Optional[str] = None, + complete_var: Optional[str] = None, +) -> Tuple[str, Path]: + prog_name = prog_name or click.get_current_context().find_root().info_name + assert prog_name + if complete_var is None: + complete_var = "_{}_COMPLETE".format(prog_name.replace("-", "_").upper()) + test_disable_detection = os.getenv("_TYPER_COMPLETE_TEST_DISABLE_SHELL_DETECTION") + if shell is None and shellingham is not None and not test_disable_detection: + shell, _ = shellingham.detect_shell() + if shell == "bash": + installed_path = install_bash( + prog_name=prog_name, complete_var=complete_var, shell=shell + ) + return shell, installed_path + elif shell == "zsh": + installed_path = install_zsh( + prog_name=prog_name, complete_var=complete_var, shell=shell + ) + return shell, installed_path + elif shell == "fish": + installed_path = install_fish( + prog_name=prog_name, complete_var=complete_var, shell=shell + ) + return shell, installed_path + elif shell in {"powershell", "pwsh"}: + installed_path = install_powershell( + prog_name=prog_name, complete_var=complete_var, shell=shell + ) + return shell, installed_path + else: + click.echo(f"Shell {shell} is not supported.") + raise click.exceptions.Exit(1) diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/_types.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/_types.py new file mode 100644 index 0000000000000000000000000000000000000000..045e36b815652debaeea1804b1e334218422dcb4 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/_types.py @@ -0,0 +1,27 @@ +from enum import Enum +from typing import Generic, TypeVar, Union + +import click + +ParamTypeValue = TypeVar("ParamTypeValue") + + +class TyperChoice(click.Choice, Generic[ParamTypeValue]): # type: ignore[type-arg] + def normalize_choice( + self, choice: ParamTypeValue, ctx: Union[click.Context, None] + ) -> str: + # Click 8.2.0 added a new method `normalize_choice` to the `Choice` class + # to support enums, but it uses the enum names, while Typer has always used the + # enum values. + # This class overrides that method to maintain the previous behavior. + # In Click: + # normed_value = choice.name if isinstance(choice, Enum) else str(choice) + normed_value = str(choice.value) if isinstance(choice, Enum) else str(choice) + + if ctx is not None and ctx.token_normalize_func is not None: + normed_value = ctx.token_normalize_func(normed_value) + + if not self.case_sensitive: + normed_value = normed_value.casefold() + + return normed_value diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/_typing.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/_typing.py new file mode 100644 index 0000000000000000000000000000000000000000..093388cd8d5c4c8c6a159e68f9f8fb9fc61947db --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/_typing.py @@ -0,0 +1,105 @@ +# Copied from pydantic 1.9.2 (the latest version to support python 3.6.) +# https://github.com/pydantic/pydantic/blob/v1.9.2/pydantic/typing.py +# Reduced drastically to only include Typer-specific 3.8+ functionality +# mypy: ignore-errors + +import sys +from typing import ( + Any, + Callable, + Optional, + Tuple, + Type, + Union, +) + +if sys.version_info >= (3, 9): + from typing import Annotated, Literal, get_args, get_origin, get_type_hints +else: + from typing_extensions import ( + Annotated, + Literal, + get_args, + get_origin, + get_type_hints, + ) + +if sys.version_info < (3, 10): + + def is_union(tp: Optional[Type[Any]]) -> bool: + return tp is Union + +else: + import types + + def is_union(tp: Optional[Type[Any]]) -> bool: + return tp is Union or tp is types.UnionType # noqa: E721 + + +__all__ = ( + "NoneType", + "is_none_type", + "is_callable_type", + "is_literal_type", + "all_literal_values", + "is_union", + "Annotated", + "Literal", + "get_args", + "get_origin", + "get_type_hints", +) + + +NoneType = None.__class__ + + +NONE_TYPES: Tuple[Any, Any, Any] = (None, NoneType, Literal[None]) + + +if sys.version_info[:2] == (3, 8): + # We can use the fast implementation for 3.8 but there is a very weird bug + # where it can fail for `Literal[None]`. + # We just need to redefine a useless `Literal[None]` inside the function body to fix this + + def is_none_type(type_: Any) -> bool: + Literal[None] # fix edge case + for none_type in NONE_TYPES: + if type_ is none_type: + return True + return False + +else: + + def is_none_type(type_: Any) -> bool: + for none_type in NONE_TYPES: + if type_ is none_type: + return True + return False + + +def is_callable_type(type_: Type[Any]) -> bool: + return type_ is Callable or get_origin(type_) is Callable + + +def is_literal_type(type_: Type[Any]) -> bool: + import typing_extensions + + return get_origin(type_) in (Literal, typing_extensions.Literal) + + +def literal_values(type_: Type[Any]) -> Tuple[Any, ...]: + return get_args(type_) + + +def all_literal_values(type_: Type[Any]) -> Tuple[Any, ...]: + """ + This method is used to retrieve all Literal values as + Literal can be used recursively (see https://www.python.org/dev/peps/pep-0586) + e.g. `Literal[Literal[Literal[1, 2, 3], "foo"], 5, None]` + """ + if not is_literal_type(type_): + return (type_,) + + values = literal_values(type_) + return tuple(x for value in values for x in all_literal_values(value)) diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/cli.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/cli.py new file mode 100644 index 0000000000000000000000000000000000000000..16b37c515d97254be49f68033fe01e8d0373ecdd --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/cli.py @@ -0,0 +1,308 @@ +import importlib.util +import re +import sys +from pathlib import Path +from typing import Any, List, Optional + +import click +import typer +import typer.core +from click import Command, Group, Option + +from . import __version__ +from .core import HAS_RICH + +default_app_names = ("app", "cli", "main") +default_func_names = ("main", "cli", "app") + +app = typer.Typer() +utils_app = typer.Typer(help="Extra utility commands for Typer apps.") +app.add_typer(utils_app, name="utils") + + +class State: + def __init__(self) -> None: + self.app: Optional[str] = None + self.func: Optional[str] = None + self.file: Optional[Path] = None + self.module: Optional[str] = None + + +state = State() + + +def maybe_update_state(ctx: click.Context) -> None: + path_or_module = ctx.params.get("path_or_module") + if path_or_module: + file_path = Path(path_or_module) + if file_path.exists() and file_path.is_file(): + state.file = file_path + else: + if not re.fullmatch(r"[a-zA-Z_]\w*(\.[a-zA-Z_]\w*)*", path_or_module): + typer.echo( + f"Not a valid file or Python module: {path_or_module}", err=True + ) + sys.exit(1) + state.module = path_or_module + app_name = ctx.params.get("app") + if app_name: + state.app = app_name + func_name = ctx.params.get("func") + if func_name: + state.func = func_name + + +class TyperCLIGroup(typer.core.TyperGroup): + def list_commands(self, ctx: click.Context) -> List[str]: + self.maybe_add_run(ctx) + return super().list_commands(ctx) + + def get_command(self, ctx: click.Context, name: str) -> Optional[Command]: + self.maybe_add_run(ctx) + return super().get_command(ctx, name) + + def invoke(self, ctx: click.Context) -> Any: + self.maybe_add_run(ctx) + return super().invoke(ctx) + + def maybe_add_run(self, ctx: click.Context) -> None: + maybe_update_state(ctx) + maybe_add_run_to_cli(self) + + +def get_typer_from_module(module: Any) -> Optional[typer.Typer]: + # Try to get defined app + if state.app: + obj = getattr(module, state.app, None) + if not isinstance(obj, typer.Typer): + typer.echo(f"Not a Typer object: --app {state.app}", err=True) + sys.exit(1) + return obj + # Try to get defined function + if state.func: + func_obj = getattr(module, state.func, None) + if not callable(func_obj): + typer.echo(f"Not a function: --func {state.func}", err=True) + sys.exit(1) + sub_app = typer.Typer() + sub_app.command()(func_obj) + return sub_app + # Iterate and get a default object to use as CLI + local_names = dir(module) + local_names_set = set(local_names) + # Try to get a default Typer app + for name in default_app_names: + if name in local_names_set: + obj = getattr(module, name, None) + if isinstance(obj, typer.Typer): + return obj + # Try to get any Typer app + for name in local_names_set - set(default_app_names): + obj = getattr(module, name) + if isinstance(obj, typer.Typer): + return obj + # Try to get a default function + for func_name in default_func_names: + func_obj = getattr(module, func_name, None) + if callable(func_obj): + sub_app = typer.Typer() + sub_app.command()(func_obj) + return sub_app + # Try to get any func app + for func_name in local_names_set - set(default_func_names): + func_obj = getattr(module, func_name) + if callable(func_obj): + sub_app = typer.Typer() + sub_app.command()(func_obj) + return sub_app + return None + + +def get_typer_from_state() -> Optional[typer.Typer]: + spec = None + if state.file: + module_name = state.file.name + spec = importlib.util.spec_from_file_location(module_name, str(state.file)) + elif state.module: + spec = importlib.util.find_spec(state.module) + if spec is None: + if state.file: + typer.echo(f"Could not import as Python file: {state.file}", err=True) + else: + typer.echo(f"Could not import as Python module: {state.module}", err=True) + sys.exit(1) + module = importlib.util.module_from_spec(spec) + spec.loader.exec_module(module) # type: ignore + obj = get_typer_from_module(module) + return obj + + +def maybe_add_run_to_cli(cli: click.Group) -> None: + if "run" not in cli.commands: + if state.file or state.module: + obj = get_typer_from_state() + if obj: + obj._add_completion = False + click_obj = typer.main.get_command(obj) + click_obj.name = "run" + if not click_obj.help: + click_obj.help = "Run the provided Typer app." + cli.add_command(click_obj) + + +def print_version(ctx: click.Context, param: Option, value: bool) -> None: + if not value or ctx.resilient_parsing: + return + typer.echo(f"Typer version: {__version__}") + raise typer.Exit() + + +@app.callback(cls=TyperCLIGroup, no_args_is_help=True) +def callback( + ctx: typer.Context, + *, + path_or_module: str = typer.Argument(None), + app: str = typer.Option(None, help="The typer app object/variable to use."), + func: str = typer.Option(None, help="The function to convert to Typer."), + version: bool = typer.Option( + False, + "--version", + help="Print version and exit.", + callback=print_version, + ), +) -> None: + """ + Run Typer scripts with completion, without having to create a package. + + You probably want to install completion for the typer command: + + $ typer --install-completion + + https://typer.tiangolo.com/ + """ + maybe_update_state(ctx) + + +def get_docs_for_click( + *, + obj: Command, + ctx: typer.Context, + indent: int = 0, + name: str = "", + call_prefix: str = "", + title: Optional[str] = None, +) -> str: + docs = "#" * (1 + indent) + command_name = name or obj.name + if call_prefix: + command_name = f"{call_prefix} {command_name}" + if not title: + title = f"`{command_name}`" if command_name else "CLI" + docs += f" {title}\n\n" + if obj.help: + docs += f"{_parse_html(obj.help)}\n\n" + usage_pieces = obj.collect_usage_pieces(ctx) + if usage_pieces: + docs += "**Usage**:\n\n" + docs += "```console\n" + docs += "$ " + if command_name: + docs += f"{command_name} " + docs += f"{' '.join(usage_pieces)}\n" + docs += "```\n\n" + args = [] + opts = [] + for param in obj.get_params(ctx): + rv = param.get_help_record(ctx) + if rv is not None: + if param.param_type_name == "argument": + args.append(rv) + elif param.param_type_name == "option": + opts.append(rv) + if args: + docs += "**Arguments**:\n\n" + for arg_name, arg_help in args: + docs += f"* `{arg_name}`" + if arg_help: + docs += f": {_parse_html(arg_help)}" + docs += "\n" + docs += "\n" + if opts: + docs += "**Options**:\n\n" + for opt_name, opt_help in opts: + docs += f"* `{opt_name}`" + if opt_help: + docs += f": {_parse_html(opt_help)}" + docs += "\n" + docs += "\n" + if obj.epilog: + docs += f"{obj.epilog}\n\n" + if isinstance(obj, Group): + group = obj + commands = group.list_commands(ctx) + if commands: + docs += "**Commands**:\n\n" + for command in commands: + command_obj = group.get_command(ctx, command) + assert command_obj + docs += f"* `{command_obj.name}`" + command_help = command_obj.get_short_help_str() + if command_help: + docs += f": {_parse_html(command_help)}" + docs += "\n" + docs += "\n" + for command in commands: + command_obj = group.get_command(ctx, command) + assert command_obj + use_prefix = "" + if command_name: + use_prefix += f"{command_name}" + docs += get_docs_for_click( + obj=command_obj, ctx=ctx, indent=indent + 1, call_prefix=use_prefix + ) + return docs + + +def _parse_html(input_text: str) -> str: + if not HAS_RICH: # pragma: no cover + return input_text + from . import rich_utils + + return rich_utils.rich_to_html(input_text) + + +@utils_app.command() +def docs( + ctx: typer.Context, + name: str = typer.Option("", help="The name of the CLI program to use in docs."), + output: Optional[Path] = typer.Option( + None, + help="An output file to write docs to, like README.md.", + file_okay=True, + dir_okay=False, + ), + title: Optional[str] = typer.Option( + None, + help="The title for the documentation page. If not provided, the name of " + "the program is used.", + ), +) -> None: + """ + Generate Markdown docs for a Typer app. + """ + typer_obj = get_typer_from_state() + if not typer_obj: + typer.echo("No Typer app found", err=True) + raise typer.Abort() + click_obj = typer.main.get_command(typer_obj) + docs = get_docs_for_click(obj=click_obj, ctx=ctx, name=name, title=title) + clean_docs = f"{docs.strip()}\n" + if output: + output.write_text(clean_docs) + typer.echo(f"Docs saved to: {output}") + else: + typer.echo(clean_docs) + + +def main() -> Any: + return app() diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/colors.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/colors.py new file mode 100644 index 0000000000000000000000000000000000000000..54e7b166cb1de83321a4965cc4915824b47a7f4f --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/colors.py @@ -0,0 +1,20 @@ +# Variable names to colors, just for completion +BLACK = "black" +RED = "red" +GREEN = "green" +YELLOW = "yellow" +BLUE = "blue" +MAGENTA = "magenta" +CYAN = "cyan" +WHITE = "white" + +RESET = "reset" + +BRIGHT_BLACK = "bright_black" +BRIGHT_RED = "bright_red" +BRIGHT_GREEN = "bright_green" +BRIGHT_YELLOW = "bright_yellow" +BRIGHT_BLUE = "bright_blue" +BRIGHT_MAGENTA = "bright_magenta" +BRIGHT_CYAN = "bright_cyan" +BRIGHT_WHITE = "bright_white" diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/completion.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/completion.py new file mode 100644 index 0000000000000000000000000000000000000000..c355baa78182a6e7a6ba692db660fca162ef79f9 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/completion.py @@ -0,0 +1,149 @@ +import os +import sys +from typing import Any, MutableMapping, Tuple + +import click + +from ._completion_classes import completion_init +from ._completion_shared import Shells, get_completion_script, install +from .models import ParamMeta +from .params import Option +from .utils import get_params_from_function + +try: + import shellingham +except ImportError: # pragma: no cover + shellingham = None + + +_click_patched = False + + +def get_completion_inspect_parameters() -> Tuple[ParamMeta, ParamMeta]: + completion_init() + test_disable_detection = os.getenv("_TYPER_COMPLETE_TEST_DISABLE_SHELL_DETECTION") + if shellingham and not test_disable_detection: + parameters = get_params_from_function(_install_completion_placeholder_function) + else: + parameters = get_params_from_function( + _install_completion_no_auto_placeholder_function + ) + install_param, show_param = parameters.values() + return install_param, show_param + + +def install_callback(ctx: click.Context, param: click.Parameter, value: Any) -> Any: + if not value or ctx.resilient_parsing: + return value # pragma: no cover + if isinstance(value, str): + shell, path = install(shell=value) + else: + shell, path = install() + click.secho(f"{shell} completion installed in {path}", fg="green") + click.echo("Completion will take effect once you restart the terminal") + sys.exit(0) + + +def show_callback(ctx: click.Context, param: click.Parameter, value: Any) -> Any: + if not value or ctx.resilient_parsing: + return value # pragma: no cover + prog_name = ctx.find_root().info_name + assert prog_name + complete_var = "_{}_COMPLETE".format(prog_name.replace("-", "_").upper()) + shell = "" + test_disable_detection = os.getenv("_TYPER_COMPLETE_TEST_DISABLE_SHELL_DETECTION") + if isinstance(value, str): + shell = value + elif shellingham and not test_disable_detection: + shell, _ = shellingham.detect_shell() + script_content = get_completion_script( + prog_name=prog_name, complete_var=complete_var, shell=shell + ) + click.echo(script_content) + sys.exit(0) + + +# Create a fake command function to extract the completion parameters +def _install_completion_placeholder_function( + install_completion: bool = Option( + None, + "--install-completion", + callback=install_callback, + expose_value=False, + help="Install completion for the current shell.", + ), + show_completion: bool = Option( + None, + "--show-completion", + callback=show_callback, + expose_value=False, + help="Show completion for the current shell, to copy it or customize the installation.", + ), +) -> Any: + pass # pragma: no cover + + +def _install_completion_no_auto_placeholder_function( + install_completion: Shells = Option( + None, + callback=install_callback, + expose_value=False, + help="Install completion for the specified shell.", + ), + show_completion: Shells = Option( + None, + callback=show_callback, + expose_value=False, + help="Show completion for the specified shell, to copy it or customize the installation.", + ), +) -> Any: + pass # pragma: no cover + + +# Re-implement Click's shell_complete to add error message with: +# Invalid completion instruction +# To use 7.x instruction style for compatibility +# And to add extra error messages, for compatibility with Typer in previous versions +# This is only called in new Command method, only used by Click 8.x+ +def shell_complete( + cli: click.Command, + ctx_args: MutableMapping[str, Any], + prog_name: str, + complete_var: str, + instruction: str, +) -> int: + import click + import click.shell_completion + + if "_" not in instruction: + click.echo("Invalid completion instruction.", err=True) + return 1 + + # Click 8 changed the order/style of shell instructions from e.g. + # source_bash to bash_source + # Typer override to preserve the old style for compatibility + # Original in Click 8.x commented: + # shell, _, instruction = instruction.partition("_") + instruction, _, shell = instruction.partition("_") + # Typer override end + + comp_cls = click.shell_completion.get_completion_class(shell) + + if comp_cls is None: + click.echo(f"Shell {shell} not supported.", err=True) + return 1 + + comp = comp_cls(cli, ctx_args, prog_name, complete_var) + + if instruction == "source": + click.echo(comp.source()) + return 0 + + # Typer override to print the completion help msg with Rich + if instruction == "complete": + click.echo(comp.complete()) + return 0 + # Typer override end + + click.echo(f'Completion instruction "{instruction}" not supported.', err=True) + return 1 diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/core.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/core.py new file mode 100644 index 0000000000000000000000000000000000000000..e9631e56cf6101c9aa0a9582c177803ce86bb36b --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/core.py @@ -0,0 +1,829 @@ +import errno +import importlib.util +import inspect +import os +import sys +from difflib import get_close_matches +from enum import Enum +from gettext import gettext as _ +from typing import ( + Any, + Callable, + Dict, + List, + MutableMapping, + Optional, + Sequence, + TextIO, + Tuple, + Union, + cast, +) + +import click +import click.core +import click.formatting +import click.shell_completion +import click.types +import click.utils + +from ._typing import Literal + +MarkupMode = Literal["markdown", "rich", None] + +HAS_RICH = importlib.util.find_spec("rich") is not None + +if HAS_RICH: + DEFAULT_MARKUP_MODE: MarkupMode = "rich" +else: # pragma: no cover + DEFAULT_MARKUP_MODE = None + + +# Copy from click.parser._split_opt +def _split_opt(opt: str) -> Tuple[str, str]: + first = opt[:1] + if first.isalnum(): + return "", opt + if opt[1:2] == first: + return opt[:2], opt[2:] + return first, opt[1:] + + +def _typer_param_setup_autocompletion_compat( + self: click.Parameter, + *, + autocompletion: Optional[ + Callable[[click.Context, List[str], str], List[Union[Tuple[str, str], str]]] + ] = None, +) -> None: + if self._custom_shell_complete is not None: + import warnings + + warnings.warn( + "In Typer, only the parameter 'autocompletion' is supported. " + "The support for 'shell_complete' is deprecated and will be removed in upcoming versions. ", + DeprecationWarning, + stacklevel=2, + ) + + if autocompletion is not None: + + def compat_autocompletion( + ctx: click.Context, param: click.core.Parameter, incomplete: str + ) -> List["click.shell_completion.CompletionItem"]: + from click.shell_completion import CompletionItem + + out = [] + + for c in autocompletion(ctx, [], incomplete): + if isinstance(c, tuple): + use_completion = CompletionItem(c[0], help=c[1]) + else: + assert isinstance(c, str) + use_completion = CompletionItem(c) + + if use_completion.value.startswith(incomplete): + out.append(use_completion) + + return out + + self._custom_shell_complete = compat_autocompletion + + +def _get_default_string( + obj: Union["TyperArgument", "TyperOption"], + *, + ctx: click.Context, + show_default_is_str: bool, + default_value: Union[List[Any], Tuple[Any, ...], str, Callable[..., Any], Any], +) -> str: + # Extracted from click.core.Option.get_help_record() to be reused by + # rich_utils avoiding RegEx hacks + if show_default_is_str: + default_string = f"({obj.show_default})" + elif isinstance(default_value, (list, tuple)): + default_string = ", ".join( + _get_default_string( + obj, ctx=ctx, show_default_is_str=show_default_is_str, default_value=d + ) + for d in default_value + ) + elif isinstance(default_value, Enum): + default_string = str(default_value.value) + elif inspect.isfunction(default_value): + default_string = _("(dynamic)") + elif isinstance(obj, TyperOption) and obj.is_bool_flag and obj.secondary_opts: + # For boolean flags that have distinct True/False opts, + # use the opt without prefix instead of the value. + # Typer override, original commented + # default_string = click.parser.split_opt( + # (self.opts if self.default else self.secondary_opts)[0] + # )[1] + if obj.default: + if obj.opts: + default_string = _split_opt(obj.opts[0])[1] + else: + default_string = str(default_value) + else: + default_string = _split_opt(obj.secondary_opts[0])[1] + # Typer override end + elif ( + isinstance(obj, TyperOption) + and obj.is_bool_flag + and not obj.secondary_opts + and not default_value + ): + default_string = "" + else: + default_string = str(default_value) + return default_string + + +def _extract_default_help_str( + obj: Union["TyperArgument", "TyperOption"], *, ctx: click.Context +) -> Optional[Union[Any, Callable[[], Any]]]: + # Extracted from click.core.Option.get_help_record() to be reused by + # rich_utils avoiding RegEx hacks + # Temporarily enable resilient parsing to avoid type casting + # failing for the default. Might be possible to extend this to + # help formatting in general. + resilient = ctx.resilient_parsing + ctx.resilient_parsing = True + + try: + default_value = obj.get_default(ctx, call=False) + finally: + ctx.resilient_parsing = resilient + return default_value + + +def _main( + self: click.Command, + *, + args: Optional[Sequence[str]] = None, + prog_name: Optional[str] = None, + complete_var: Optional[str] = None, + standalone_mode: bool = True, + windows_expand_args: bool = True, + rich_markup_mode: MarkupMode = DEFAULT_MARKUP_MODE, + **extra: Any, +) -> Any: + # Typer override, duplicated from click.main() to handle custom rich exceptions + # Verify that the environment is configured correctly, or reject + # further execution to avoid a broken script. + if args is None: + args = sys.argv[1:] + + # Covered in Click tests + if os.name == "nt" and windows_expand_args: # pragma: no cover + args = click.utils._expand_args(args) + else: + args = list(args) + + if prog_name is None: + prog_name = click.utils._detect_program_name() + + # Process shell completion requests and exit early. + self._main_shell_completion(extra, prog_name, complete_var) + + try: + try: + with self.make_context(prog_name, args, **extra) as ctx: + rv = self.invoke(ctx) + if not standalone_mode: + return rv + # it's not safe to `ctx.exit(rv)` here! + # note that `rv` may actually contain data like "1" which + # has obvious effects + # more subtle case: `rv=[None, None]` can come out of + # chained commands which all returned `None` -- so it's not + # even always obvious that `rv` indicates success/failure + # by its truthiness/falsiness + ctx.exit() + except EOFError as e: + click.echo(file=sys.stderr) + raise click.Abort() from e + except KeyboardInterrupt as e: + raise click.exceptions.Exit(130) from e + except click.ClickException as e: + if not standalone_mode: + raise + # Typer override + if HAS_RICH and rich_markup_mode is not None: + from . import rich_utils + + rich_utils.rich_format_error(e) + else: + e.show() + # Typer override end + sys.exit(e.exit_code) + except OSError as e: + if e.errno == errno.EPIPE: + sys.stdout = cast(TextIO, click.utils.PacifyFlushWrapper(sys.stdout)) + sys.stderr = cast(TextIO, click.utils.PacifyFlushWrapper(sys.stderr)) + sys.exit(1) + else: + raise + except click.exceptions.Exit as e: + if standalone_mode: + sys.exit(e.exit_code) + else: + # in non-standalone mode, return the exit code + # note that this is only reached if `self.invoke` above raises + # an Exit explicitly -- thus bypassing the check there which + # would return its result + # the results of non-standalone execution may therefore be + # somewhat ambiguous: if there are codepaths which lead to + # `ctx.exit(1)` and to `return 1`, the caller won't be able to + # tell the difference between the two + return e.exit_code + except click.Abort: + if not standalone_mode: + raise + # Typer override + if HAS_RICH and rich_markup_mode is not None: + from . import rich_utils + + rich_utils.rich_abort_error() + else: + click.echo(_("Aborted!"), file=sys.stderr) + # Typer override end + sys.exit(1) + + +class TyperArgument(click.core.Argument): + def __init__( + self, + *, + # Parameter + param_decls: List[str], + type: Optional[Any] = None, + required: Optional[bool] = None, + default: Optional[Any] = None, + callback: Optional[Callable[..., Any]] = None, + nargs: Optional[int] = None, + metavar: Optional[str] = None, + expose_value: bool = True, + is_eager: bool = False, + envvar: Optional[Union[str, List[str]]] = None, + # Note that shell_complete is not fully supported and will be removed in future versions + # TODO: Remove shell_complete in a future version (after 0.16.0) + shell_complete: Optional[ + Callable[ + [click.Context, click.Parameter, str], + Union[List["click.shell_completion.CompletionItem"], List[str]], + ] + ] = None, + autocompletion: Optional[Callable[..., Any]] = None, + # TyperArgument + show_default: Union[bool, str] = True, + show_choices: bool = True, + show_envvar: bool = True, + help: Optional[str] = None, + hidden: bool = False, + # Rich settings + rich_help_panel: Union[str, None] = None, + ): + self.help = help + self.show_default = show_default + self.show_choices = show_choices + self.show_envvar = show_envvar + self.hidden = hidden + self.rich_help_panel = rich_help_panel + + super().__init__( + param_decls=param_decls, + type=type, + required=required, + default=default, + callback=callback, + nargs=nargs, + metavar=metavar, + expose_value=expose_value, + is_eager=is_eager, + envvar=envvar, + shell_complete=shell_complete, + ) + _typer_param_setup_autocompletion_compat(self, autocompletion=autocompletion) + + def _get_default_string( + self, + *, + ctx: click.Context, + show_default_is_str: bool, + default_value: Union[List[Any], Tuple[Any, ...], str, Callable[..., Any], Any], + ) -> str: + return _get_default_string( + self, + ctx=ctx, + show_default_is_str=show_default_is_str, + default_value=default_value, + ) + + def _extract_default_help_str( + self, *, ctx: click.Context + ) -> Optional[Union[Any, Callable[[], Any]]]: + return _extract_default_help_str(self, ctx=ctx) + + def get_help_record(self, ctx: click.Context) -> Optional[Tuple[str, str]]: + # Modified version of click.core.Option.get_help_record() + # to support Arguments + if self.hidden: + return None + name = self.make_metavar(ctx=ctx) + help = self.help or "" + extra = [] + if self.show_envvar: + envvar = self.envvar + # allow_from_autoenv is currently not supported in Typer for CLI Arguments + if envvar is not None: + var_str = ( + ", ".join(str(d) for d in envvar) + if isinstance(envvar, (list, tuple)) + else envvar + ) + extra.append(f"env var: {var_str}") + + # Typer override: + # Extracted to _extract_default_help_str() to allow re-using it in rich_utils + default_value = self._extract_default_help_str(ctx=ctx) + # Typer override end + + show_default_is_str = isinstance(self.show_default, str) + + if show_default_is_str or ( + default_value is not None and (self.show_default or ctx.show_default) + ): + # Typer override: + # Extracted to _get_default_string() to allow re-using it in rich_utils + default_string = self._get_default_string( + ctx=ctx, + show_default_is_str=show_default_is_str, + default_value=default_value, + ) + # Typer override end + if default_string: + extra.append(_("default: {default}").format(default=default_string)) + if self.required: + extra.append(_("required")) + if extra: + extra_str = "; ".join(extra) + extra_str = f"[{extra_str}]" + if HAS_RICH: + # This is needed for when we want to export to HTML + from . import rich_utils + + extra_str = rich_utils.escape_before_html_export(extra_str) + + help = f"{help} {extra_str}" if help else f"{extra_str}" + return name, help + + def make_metavar(self, ctx: Union[click.Context, None] = None) -> str: + # Modified version of click.core.Argument.make_metavar() + # to include Argument name + if self.metavar is not None: + return self.metavar + var = (self.name or "").upper() + if not self.required: + var = f"[{var}]" + # TODO: When deprecating Click < 8.2, remove this + signature = inspect.signature(self.type.get_metavar) + if "ctx" in signature.parameters: + # Click >= 8.2 + type_var = self.type.get_metavar(self, ctx=ctx) # type: ignore[arg-type] + else: + # Click < 8.2 + type_var = self.type.get_metavar(self) # type: ignore[call-arg] + # TODO: /When deprecating Click < 8.2, remove this, uncomment the line below + # type_var = self.type.get_metavar(self, ctx=ctx) + if type_var: + var += f":{type_var}" + if self.nargs != 1: + var += "..." + return var + + def value_is_missing(self, value: Any) -> bool: + return _value_is_missing(self, value) + + +class TyperOption(click.core.Option): + def __init__( + self, + *, + # Parameter + param_decls: List[str], + type: Optional[Union[click.types.ParamType, Any]] = None, + required: Optional[bool] = None, + default: Optional[Any] = None, + callback: Optional[Callable[..., Any]] = None, + nargs: Optional[int] = None, + metavar: Optional[str] = None, + expose_value: bool = True, + is_eager: bool = False, + envvar: Optional[Union[str, List[str]]] = None, + # Note that shell_complete is not fully supported and will be removed in future versions + # TODO: Remove shell_complete in a future version (after 0.16.0) + shell_complete: Optional[ + Callable[ + [click.Context, click.Parameter, str], + Union[List["click.shell_completion.CompletionItem"], List[str]], + ] + ] = None, + autocompletion: Optional[Callable[..., Any]] = None, + # Option + show_default: Union[bool, str] = False, + prompt: Union[bool, str] = False, + confirmation_prompt: Union[bool, str] = False, + prompt_required: bool = True, + hide_input: bool = False, + is_flag: Optional[bool] = None, + multiple: bool = False, + count: bool = False, + allow_from_autoenv: bool = True, + help: Optional[str] = None, + hidden: bool = False, + show_choices: bool = True, + show_envvar: bool = False, + # Rich settings + rich_help_panel: Union[str, None] = None, + ): + super().__init__( + param_decls=param_decls, + type=type, + required=required, + default=default, + callback=callback, + nargs=nargs, + metavar=metavar, + expose_value=expose_value, + is_eager=is_eager, + envvar=envvar, + show_default=show_default, + prompt=prompt, + confirmation_prompt=confirmation_prompt, + hide_input=hide_input, + is_flag=is_flag, + multiple=multiple, + count=count, + allow_from_autoenv=allow_from_autoenv, + help=help, + hidden=hidden, + show_choices=show_choices, + show_envvar=show_envvar, + prompt_required=prompt_required, + shell_complete=shell_complete, + ) + _typer_param_setup_autocompletion_compat(self, autocompletion=autocompletion) + self.rich_help_panel = rich_help_panel + + def _get_default_string( + self, + *, + ctx: click.Context, + show_default_is_str: bool, + default_value: Union[List[Any], Tuple[Any, ...], str, Callable[..., Any], Any], + ) -> str: + return _get_default_string( + self, + ctx=ctx, + show_default_is_str=show_default_is_str, + default_value=default_value, + ) + + def _extract_default_help_str( + self, *, ctx: click.Context + ) -> Optional[Union[Any, Callable[[], Any]]]: + return _extract_default_help_str(self, ctx=ctx) + + def make_metavar(self, ctx: Union[click.Context, None] = None) -> str: + signature = inspect.signature(super().make_metavar) + if "ctx" in signature.parameters: + # Click >= 8.2 + return super().make_metavar(ctx=ctx) # type: ignore[arg-type] + # Click < 8.2 + return super().make_metavar() # type: ignore[call-arg] + + def get_help_record(self, ctx: click.Context) -> Optional[Tuple[str, str]]: + # Duplicate all of Click's logic only to modify a single line, to allow boolean + # flags with only names for False values as it's currently supported by Typer + # Ref: https://typer.tiangolo.com/tutorial/parameter-types/bool/#only-names-for-false + if self.hidden: + return None + + any_prefix_is_slash = False + + def _write_opts(opts: Sequence[str]) -> str: + nonlocal any_prefix_is_slash + + rv, any_slashes = click.formatting.join_options(opts) + + if any_slashes: + any_prefix_is_slash = True + + if not self.is_flag and not self.count: + rv += f" {self.make_metavar(ctx=ctx)}" + + return rv + + rv = [_write_opts(self.opts)] + + if self.secondary_opts: + rv.append(_write_opts(self.secondary_opts)) + + help = self.help or "" + extra = [] + + if self.show_envvar: + envvar = self.envvar + + if envvar is None: + if ( + self.allow_from_autoenv + and ctx.auto_envvar_prefix is not None + and self.name is not None + ): + envvar = f"{ctx.auto_envvar_prefix}_{self.name.upper()}" + + if envvar is not None: + var_str = ( + envvar + if isinstance(envvar, str) + else ", ".join(str(d) for d in envvar) + ) + extra.append(_("env var: {var}").format(var=var_str)) + + # Typer override: + # Extracted to _extract_default() to allow re-using it in rich_utils + default_value = self._extract_default_help_str(ctx=ctx) + # Typer override end + + show_default_is_str = isinstance(self.show_default, str) + + if show_default_is_str or ( + default_value is not None and (self.show_default or ctx.show_default) + ): + # Typer override: + # Extracted to _get_default_string() to allow re-using it in rich_utils + default_string = self._get_default_string( + ctx=ctx, + show_default_is_str=show_default_is_str, + default_value=default_value, + ) + # Typer override end + if default_string: + extra.append(_("default: {default}").format(default=default_string)) + + if isinstance(self.type, click.types._NumberRangeBase): + range_str = self.type._describe_range() + + if range_str: + extra.append(range_str) + + if self.required: + extra.append(_("required")) + + if extra: + extra_str = "; ".join(extra) + extra_str = f"[{extra_str}]" + if HAS_RICH: + # This is needed for when we want to export to HTML + from . import rich_utils + + extra_str = rich_utils.escape_before_html_export(extra_str) + + help = f"{help} {extra_str}" if help else f"{extra_str}" + + return ("; " if any_prefix_is_slash else " / ").join(rv), help + + def value_is_missing(self, value: Any) -> bool: + return _value_is_missing(self, value) + + +def _value_is_missing(param: click.Parameter, value: Any) -> bool: + if value is None: + return True + + # Click 8.3 and beyond + # if value is UNSET: + # return True + + if (param.nargs != 1 or param.multiple) and value == (): + return True # pragma: no cover + + return False + + +def _typer_format_options( + self: click.core.Command, *, ctx: click.Context, formatter: click.HelpFormatter +) -> None: + args = [] + opts = [] + for param in self.get_params(ctx): + rv = param.get_help_record(ctx) + if rv is not None: + if param.param_type_name == "argument": + args.append(rv) + elif param.param_type_name == "option": + opts.append(rv) + + if args: + with formatter.section(_("Arguments")): + formatter.write_dl(args) + if opts: + with formatter.section(_("Options")): + formatter.write_dl(opts) + + +def _typer_main_shell_completion( + self: click.core.Command, + *, + ctx_args: MutableMapping[str, Any], + prog_name: str, + complete_var: Optional[str] = None, +) -> None: + if complete_var is None: + complete_var = f"_{prog_name}_COMPLETE".replace("-", "_").upper() + + instruction = os.environ.get(complete_var) + + if not instruction: + return + + from .completion import shell_complete + + rv = shell_complete(self, ctx_args, prog_name, complete_var, instruction) + sys.exit(rv) + + +class TyperCommand(click.core.Command): + def __init__( + self, + name: Optional[str], + *, + context_settings: Optional[Dict[str, Any]] = None, + callback: Optional[Callable[..., Any]] = None, + params: Optional[List[click.Parameter]] = None, + help: Optional[str] = None, + epilog: Optional[str] = None, + short_help: Optional[str] = None, + options_metavar: Optional[str] = "[OPTIONS]", + add_help_option: bool = True, + no_args_is_help: bool = False, + hidden: bool = False, + deprecated: bool = False, + # Rich settings + rich_markup_mode: MarkupMode = DEFAULT_MARKUP_MODE, + rich_help_panel: Union[str, None] = None, + ) -> None: + super().__init__( + name=name, + context_settings=context_settings, + callback=callback, + params=params, + help=help, + epilog=epilog, + short_help=short_help, + options_metavar=options_metavar, + add_help_option=add_help_option, + no_args_is_help=no_args_is_help, + hidden=hidden, + deprecated=deprecated, + ) + self.rich_markup_mode: MarkupMode = rich_markup_mode + self.rich_help_panel = rich_help_panel + + def format_options( + self, ctx: click.Context, formatter: click.HelpFormatter + ) -> None: + _typer_format_options(self, ctx=ctx, formatter=formatter) + + def _main_shell_completion( + self, + ctx_args: MutableMapping[str, Any], + prog_name: str, + complete_var: Optional[str] = None, + ) -> None: + _typer_main_shell_completion( + self, ctx_args=ctx_args, prog_name=prog_name, complete_var=complete_var + ) + + def main( + self, + args: Optional[Sequence[str]] = None, + prog_name: Optional[str] = None, + complete_var: Optional[str] = None, + standalone_mode: bool = True, + windows_expand_args: bool = True, + **extra: Any, + ) -> Any: + return _main( + self, + args=args, + prog_name=prog_name, + complete_var=complete_var, + standalone_mode=standalone_mode, + windows_expand_args=windows_expand_args, + rich_markup_mode=self.rich_markup_mode, + **extra, + ) + + def format_help(self, ctx: click.Context, formatter: click.HelpFormatter) -> None: + if not HAS_RICH or self.rich_markup_mode is None: + return super().format_help(ctx, formatter) + from . import rich_utils + + return rich_utils.rich_format_help( + obj=self, + ctx=ctx, + markup_mode=self.rich_markup_mode, + ) + + +class TyperGroup(click.core.Group): + def __init__( + self, + *, + name: Optional[str] = None, + commands: Optional[ + Union[Dict[str, click.Command], Sequence[click.Command]] + ] = None, + # Rich settings + rich_markup_mode: MarkupMode = DEFAULT_MARKUP_MODE, + rich_help_panel: Union[str, None] = None, + suggest_commands: bool = True, + **attrs: Any, + ) -> None: + super().__init__(name=name, commands=commands, **attrs) + self.rich_markup_mode: MarkupMode = rich_markup_mode + self.rich_help_panel = rich_help_panel + self.suggest_commands = suggest_commands + + def format_options( + self, ctx: click.Context, formatter: click.HelpFormatter + ) -> None: + _typer_format_options(self, ctx=ctx, formatter=formatter) + self.format_commands(ctx, formatter) + + def _main_shell_completion( + self, + ctx_args: MutableMapping[str, Any], + prog_name: str, + complete_var: Optional[str] = None, + ) -> None: + _typer_main_shell_completion( + self, ctx_args=ctx_args, prog_name=prog_name, complete_var=complete_var + ) + + def resolve_command( + self, ctx: click.Context, args: List[str] + ) -> Tuple[Optional[str], Optional[click.Command], List[str]]: + try: + return super().resolve_command(ctx, args) + except click.UsageError as e: + if self.suggest_commands: + available_commands = list(self.commands.keys()) + if available_commands and args: + typo = args[0] + matches = get_close_matches(typo, available_commands) + if matches: + suggestions = ", ".join(f"{m!r}" for m in matches) + message = e.message.rstrip(".") + e.message = f"{message}. Did you mean {suggestions}?" + raise + + def main( + self, + args: Optional[Sequence[str]] = None, + prog_name: Optional[str] = None, + complete_var: Optional[str] = None, + standalone_mode: bool = True, + windows_expand_args: bool = True, + **extra: Any, + ) -> Any: + return _main( + self, + args=args, + prog_name=prog_name, + complete_var=complete_var, + standalone_mode=standalone_mode, + windows_expand_args=windows_expand_args, + rich_markup_mode=self.rich_markup_mode, + **extra, + ) + + def format_help(self, ctx: click.Context, formatter: click.HelpFormatter) -> None: + if not HAS_RICH or self.rich_markup_mode is None: + return super().format_help(ctx, formatter) + from . import rich_utils + + return rich_utils.rich_format_help( + obj=self, + ctx=ctx, + markup_mode=self.rich_markup_mode, + ) + + def list_commands(self, ctx: click.Context) -> List[str]: + """Returns a list of subcommand names. + Note that in Click's Group class, these are sorted. + In Typer, we wish to maintain the original order of creation (cf Issue #933)""" + return [n for n, c in self.commands.items()] diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/main.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/main.py new file mode 100644 index 0000000000000000000000000000000000000000..71a25e6c4b7df34375b8a4a8c91e9ae035a029fa --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/main.py @@ -0,0 +1,1142 @@ +import inspect +import os +import platform +import shutil +import subprocess +import sys +import traceback +from datetime import datetime +from enum import Enum +from functools import update_wrapper +from pathlib import Path +from traceback import FrameSummary, StackSummary +from types import TracebackType +from typing import Any, Callable, Dict, List, Optional, Sequence, Tuple, Type, Union +from uuid import UUID + +import click +from typer._types import TyperChoice + +from ._typing import get_args, get_origin, is_literal_type, is_union, literal_values +from .completion import get_completion_inspect_parameters +from .core import ( + DEFAULT_MARKUP_MODE, + HAS_RICH, + MarkupMode, + TyperArgument, + TyperCommand, + TyperGroup, + TyperOption, +) +from .models import ( + AnyType, + ArgumentInfo, + CommandFunctionType, + CommandInfo, + Default, + DefaultPlaceholder, + DeveloperExceptionConfig, + FileBinaryRead, + FileBinaryWrite, + FileText, + FileTextWrite, + NoneType, + OptionInfo, + ParameterInfo, + ParamMeta, + Required, + TyperInfo, + TyperPath, +) +from .utils import get_params_from_function + +_original_except_hook = sys.excepthook +_typer_developer_exception_attr_name = "__typer_developer_exception__" + + +def except_hook( + exc_type: Type[BaseException], exc_value: BaseException, tb: Optional[TracebackType] +) -> None: + exception_config: Union[DeveloperExceptionConfig, None] = getattr( + exc_value, _typer_developer_exception_attr_name, None + ) + standard_traceback = os.getenv("_TYPER_STANDARD_TRACEBACK") + if ( + standard_traceback + or not exception_config + or not exception_config.pretty_exceptions_enable + ): + _original_except_hook(exc_type, exc_value, tb) + return + typer_path = os.path.dirname(__file__) + click_path = os.path.dirname(click.__file__) + internal_dir_names = [typer_path, click_path] + exc = exc_value + if HAS_RICH: + from . import rich_utils + + rich_tb = rich_utils.get_traceback(exc, exception_config, internal_dir_names) + console_stderr = rich_utils._get_rich_console(stderr=True) + console_stderr.print(rich_tb) + return + tb_exc = traceback.TracebackException.from_exception(exc) + stack: List[FrameSummary] = [] + for frame in tb_exc.stack: + if any(frame.filename.startswith(path) for path in internal_dir_names): + if not exception_config.pretty_exceptions_short: + # Hide the line for internal libraries, Typer and Click + stack.append( + traceback.FrameSummary( + filename=frame.filename, + lineno=frame.lineno, + name=frame.name, + line="", + ) + ) + else: + stack.append(frame) + # Type ignore ref: https://github.com/python/typeshed/pull/8244 + final_stack_summary = StackSummary.from_list(stack) + tb_exc.stack = final_stack_summary + for line in tb_exc.format(): + print(line, file=sys.stderr) + return + + +def get_install_completion_arguments() -> Tuple[click.Parameter, click.Parameter]: + install_param, show_param = get_completion_inspect_parameters() + click_install_param, _ = get_click_param(install_param) + click_show_param, _ = get_click_param(show_param) + return click_install_param, click_show_param + + +class Typer: + def __init__( + self, + *, + name: Optional[str] = Default(None), + cls: Optional[Type[TyperGroup]] = Default(None), + invoke_without_command: bool = Default(False), + no_args_is_help: bool = Default(False), + subcommand_metavar: Optional[str] = Default(None), + chain: bool = Default(False), + result_callback: Optional[Callable[..., Any]] = Default(None), + # Command + context_settings: Optional[Dict[Any, Any]] = Default(None), + callback: Optional[Callable[..., Any]] = Default(None), + help: Optional[str] = Default(None), + epilog: Optional[str] = Default(None), + short_help: Optional[str] = Default(None), + options_metavar: str = Default("[OPTIONS]"), + add_help_option: bool = Default(True), + hidden: bool = Default(False), + deprecated: bool = Default(False), + add_completion: bool = True, + # Rich settings + rich_markup_mode: MarkupMode = Default(DEFAULT_MARKUP_MODE), + rich_help_panel: Union[str, None] = Default(None), + suggest_commands: bool = True, + pretty_exceptions_enable: bool = True, + pretty_exceptions_show_locals: bool = True, + pretty_exceptions_short: bool = True, + ): + self._add_completion = add_completion + self.rich_markup_mode: MarkupMode = rich_markup_mode + self.rich_help_panel = rich_help_panel + self.suggest_commands = suggest_commands + self.pretty_exceptions_enable = pretty_exceptions_enable + self.pretty_exceptions_show_locals = pretty_exceptions_show_locals + self.pretty_exceptions_short = pretty_exceptions_short + self.info = TyperInfo( + name=name, + cls=cls, + invoke_without_command=invoke_without_command, + no_args_is_help=no_args_is_help, + subcommand_metavar=subcommand_metavar, + chain=chain, + result_callback=result_callback, + context_settings=context_settings, + callback=callback, + help=help, + epilog=epilog, + short_help=short_help, + options_metavar=options_metavar, + add_help_option=add_help_option, + hidden=hidden, + deprecated=deprecated, + ) + self.registered_groups: List[TyperInfo] = [] + self.registered_commands: List[CommandInfo] = [] + self.registered_callback: Optional[TyperInfo] = None + + def callback( + self, + *, + cls: Optional[Type[TyperGroup]] = Default(None), + invoke_without_command: bool = Default(False), + no_args_is_help: bool = Default(False), + subcommand_metavar: Optional[str] = Default(None), + chain: bool = Default(False), + result_callback: Optional[Callable[..., Any]] = Default(None), + # Command + context_settings: Optional[Dict[Any, Any]] = Default(None), + help: Optional[str] = Default(None), + epilog: Optional[str] = Default(None), + short_help: Optional[str] = Default(None), + options_metavar: str = Default("[OPTIONS]"), + add_help_option: bool = Default(True), + hidden: bool = Default(False), + deprecated: bool = Default(False), + # Rich settings + rich_help_panel: Union[str, None] = Default(None), + ) -> Callable[[CommandFunctionType], CommandFunctionType]: + def decorator(f: CommandFunctionType) -> CommandFunctionType: + self.registered_callback = TyperInfo( + cls=cls, + invoke_without_command=invoke_without_command, + no_args_is_help=no_args_is_help, + subcommand_metavar=subcommand_metavar, + chain=chain, + result_callback=result_callback, + context_settings=context_settings, + callback=f, + help=help, + epilog=epilog, + short_help=short_help, + options_metavar=options_metavar, + add_help_option=add_help_option, + hidden=hidden, + deprecated=deprecated, + rich_help_panel=rich_help_panel, + ) + return f + + return decorator + + def command( + self, + name: Optional[str] = None, + *, + cls: Optional[Type[TyperCommand]] = None, + context_settings: Optional[Dict[Any, Any]] = None, + help: Optional[str] = None, + epilog: Optional[str] = None, + short_help: Optional[str] = None, + options_metavar: str = "[OPTIONS]", + add_help_option: bool = True, + no_args_is_help: bool = False, + hidden: bool = False, + deprecated: bool = False, + # Rich settings + rich_help_panel: Union[str, None] = Default(None), + ) -> Callable[[CommandFunctionType], CommandFunctionType]: + if cls is None: + cls = TyperCommand + + def decorator(f: CommandFunctionType) -> CommandFunctionType: + self.registered_commands.append( + CommandInfo( + name=name, + cls=cls, + context_settings=context_settings, + callback=f, + help=help, + epilog=epilog, + short_help=short_help, + options_metavar=options_metavar, + add_help_option=add_help_option, + no_args_is_help=no_args_is_help, + hidden=hidden, + deprecated=deprecated, + # Rich settings + rich_help_panel=rich_help_panel, + ) + ) + return f + + return decorator + + def add_typer( + self, + typer_instance: "Typer", + *, + name: Optional[str] = Default(None), + cls: Optional[Type[TyperGroup]] = Default(None), + invoke_without_command: bool = Default(False), + no_args_is_help: bool = Default(False), + subcommand_metavar: Optional[str] = Default(None), + chain: bool = Default(False), + result_callback: Optional[Callable[..., Any]] = Default(None), + # Command + context_settings: Optional[Dict[Any, Any]] = Default(None), + callback: Optional[Callable[..., Any]] = Default(None), + help: Optional[str] = Default(None), + epilog: Optional[str] = Default(None), + short_help: Optional[str] = Default(None), + options_metavar: str = Default("[OPTIONS]"), + add_help_option: bool = Default(True), + hidden: bool = Default(False), + deprecated: bool = Default(False), + # Rich settings + rich_help_panel: Union[str, None] = Default(None), + ) -> None: + self.registered_groups.append( + TyperInfo( + typer_instance, + name=name, + cls=cls, + invoke_without_command=invoke_without_command, + no_args_is_help=no_args_is_help, + subcommand_metavar=subcommand_metavar, + chain=chain, + result_callback=result_callback, + context_settings=context_settings, + callback=callback, + help=help, + epilog=epilog, + short_help=short_help, + options_metavar=options_metavar, + add_help_option=add_help_option, + hidden=hidden, + deprecated=deprecated, + rich_help_panel=rich_help_panel, + ) + ) + + def __call__(self, *args: Any, **kwargs: Any) -> Any: + if sys.excepthook != except_hook: + sys.excepthook = except_hook + try: + return get_command(self)(*args, **kwargs) + except Exception as e: + # Set a custom attribute to tell the hook to show nice exceptions for user + # code. An alternative/first implementation was a custom exception with + # raise custom_exc from e + # but that means the last error shown is the custom exception, not the + # actual error. This trick improves developer experience by showing the + # actual error last. + setattr( + e, + _typer_developer_exception_attr_name, + DeveloperExceptionConfig( + pretty_exceptions_enable=self.pretty_exceptions_enable, + pretty_exceptions_show_locals=self.pretty_exceptions_show_locals, + pretty_exceptions_short=self.pretty_exceptions_short, + ), + ) + raise e + + +def get_group(typer_instance: Typer) -> TyperGroup: + group = get_group_from_info( + TyperInfo(typer_instance), + pretty_exceptions_short=typer_instance.pretty_exceptions_short, + rich_markup_mode=typer_instance.rich_markup_mode, + suggest_commands=typer_instance.suggest_commands, + ) + return group + + +def get_command(typer_instance: Typer) -> click.Command: + if typer_instance._add_completion: + click_install_param, click_show_param = get_install_completion_arguments() + if ( + typer_instance.registered_callback + or typer_instance.info.callback + or typer_instance.registered_groups + or len(typer_instance.registered_commands) > 1 + ): + # Create a Group + click_command: click.Command = get_group(typer_instance) + if typer_instance._add_completion: + click_command.params.append(click_install_param) + click_command.params.append(click_show_param) + return click_command + elif len(typer_instance.registered_commands) == 1: + # Create a single Command + single_command = typer_instance.registered_commands[0] + + if not single_command.context_settings and not isinstance( + typer_instance.info.context_settings, DefaultPlaceholder + ): + single_command.context_settings = typer_instance.info.context_settings + + click_command = get_command_from_info( + single_command, + pretty_exceptions_short=typer_instance.pretty_exceptions_short, + rich_markup_mode=typer_instance.rich_markup_mode, + ) + if typer_instance._add_completion: + click_command.params.append(click_install_param) + click_command.params.append(click_show_param) + return click_command + raise RuntimeError( + "Could not get a command for this Typer instance" + ) # pragma: no cover + + +def solve_typer_info_help(typer_info: TyperInfo) -> str: + # Priority 1: Explicit value was set in app.add_typer() + if not isinstance(typer_info.help, DefaultPlaceholder): + return inspect.cleandoc(typer_info.help or "") + # Priority 2: Explicit value was set in sub_app.callback() + try: + callback_help = typer_info.typer_instance.registered_callback.help + if not isinstance(callback_help, DefaultPlaceholder): + return inspect.cleandoc(callback_help or "") + except AttributeError: + pass + # Priority 3: Explicit value was set in sub_app = typer.Typer() + try: + instance_help = typer_info.typer_instance.info.help + if not isinstance(instance_help, DefaultPlaceholder): + return inspect.cleandoc(instance_help or "") + except AttributeError: + pass + # Priority 4: Implicit inference from callback docstring in app.add_typer() + if typer_info.callback: + doc = inspect.getdoc(typer_info.callback) + if doc: + return doc + # Priority 5: Implicit inference from callback docstring in @app.callback() + try: + callback = typer_info.typer_instance.registered_callback.callback + if not isinstance(callback, DefaultPlaceholder): + doc = inspect.getdoc(callback or "") + if doc: + return doc + except AttributeError: + pass + # Priority 6: Implicit inference from callback docstring in typer.Typer() + try: + instance_callback = typer_info.typer_instance.info.callback + if not isinstance(instance_callback, DefaultPlaceholder): + doc = inspect.getdoc(instance_callback) + if doc: + return doc + except AttributeError: + pass + # Value not set, use the default + return typer_info.help.value + + +def solve_typer_info_defaults(typer_info: TyperInfo) -> TyperInfo: + values: Dict[str, Any] = {} + for name, value in typer_info.__dict__.items(): + # Priority 1: Value was set in app.add_typer() + if not isinstance(value, DefaultPlaceholder): + values[name] = value + continue + # Priority 2: Value was set in @subapp.callback() + try: + callback_value = getattr( + typer_info.typer_instance.registered_callback, # type: ignore + name, + ) + if not isinstance(callback_value, DefaultPlaceholder): + values[name] = callback_value + continue + except AttributeError: + pass + # Priority 3: Value set in subapp = typer.Typer() + try: + instance_value = getattr( + typer_info.typer_instance.info, # type: ignore + name, + ) + if not isinstance(instance_value, DefaultPlaceholder): + values[name] = instance_value + continue + except AttributeError: + pass + # Value not set, use the default + values[name] = value.value + values["help"] = solve_typer_info_help(typer_info) + return TyperInfo(**values) + + +def get_group_from_info( + group_info: TyperInfo, + *, + pretty_exceptions_short: bool, + suggest_commands: bool, + rich_markup_mode: MarkupMode, +) -> TyperGroup: + assert group_info.typer_instance, ( + "A Typer instance is needed to generate a Click Group" + ) + commands: Dict[str, click.Command] = {} + for command_info in group_info.typer_instance.registered_commands: + command = get_command_from_info( + command_info=command_info, + pretty_exceptions_short=pretty_exceptions_short, + rich_markup_mode=rich_markup_mode, + ) + if command.name: + commands[command.name] = command + for sub_group_info in group_info.typer_instance.registered_groups: + sub_group = get_group_from_info( + sub_group_info, + pretty_exceptions_short=pretty_exceptions_short, + rich_markup_mode=rich_markup_mode, + suggest_commands=suggest_commands, + ) + if sub_group.name: + commands[sub_group.name] = sub_group + else: + if sub_group.callback: + import warnings + + warnings.warn( + "The 'callback' parameter is not supported by Typer when using `add_typer` without a name", + stacklevel=5, + ) + for sub_command_name, sub_command in sub_group.commands.items(): + commands[sub_command_name] = sub_command + solved_info = solve_typer_info_defaults(group_info) + ( + params, + convertors, + context_param_name, + ) = get_params_convertors_ctx_param_name_from_function(solved_info.callback) + cls = solved_info.cls or TyperGroup + assert issubclass(cls, TyperGroup), f"{cls} should be a subclass of {TyperGroup}" + group = cls( + name=solved_info.name or "", + commands=commands, + invoke_without_command=solved_info.invoke_without_command, + no_args_is_help=solved_info.no_args_is_help, + subcommand_metavar=solved_info.subcommand_metavar, + chain=solved_info.chain, + result_callback=solved_info.result_callback, + context_settings=solved_info.context_settings, + callback=get_callback( + callback=solved_info.callback, + params=params, + convertors=convertors, + context_param_name=context_param_name, + pretty_exceptions_short=pretty_exceptions_short, + ), + params=params, + help=solved_info.help, + epilog=solved_info.epilog, + short_help=solved_info.short_help, + options_metavar=solved_info.options_metavar, + add_help_option=solved_info.add_help_option, + hidden=solved_info.hidden, + deprecated=solved_info.deprecated, + rich_markup_mode=rich_markup_mode, + # Rich settings + rich_help_panel=solved_info.rich_help_panel, + suggest_commands=suggest_commands, + ) + return group + + +def get_command_name(name: str) -> str: + return name.lower().replace("_", "-") + + +def get_params_convertors_ctx_param_name_from_function( + callback: Optional[Callable[..., Any]], +) -> Tuple[List[Union[click.Argument, click.Option]], Dict[str, Any], Optional[str]]: + params = [] + convertors = {} + context_param_name = None + if callback: + parameters = get_params_from_function(callback) + for param_name, param in parameters.items(): + if lenient_issubclass(param.annotation, click.Context): + context_param_name = param_name + continue + click_param, convertor = get_click_param(param) + if convertor: + convertors[param_name] = convertor + params.append(click_param) + return params, convertors, context_param_name + + +def get_command_from_info( + command_info: CommandInfo, + *, + pretty_exceptions_short: bool, + rich_markup_mode: MarkupMode, +) -> click.Command: + assert command_info.callback, "A command must have a callback function" + name = command_info.name or get_command_name(command_info.callback.__name__) + use_help = command_info.help + if use_help is None: + use_help = inspect.getdoc(command_info.callback) + else: + use_help = inspect.cleandoc(use_help) + ( + params, + convertors, + context_param_name, + ) = get_params_convertors_ctx_param_name_from_function(command_info.callback) + cls = command_info.cls or TyperCommand + command = cls( + name=name, + context_settings=command_info.context_settings, + callback=get_callback( + callback=command_info.callback, + params=params, + convertors=convertors, + context_param_name=context_param_name, + pretty_exceptions_short=pretty_exceptions_short, + ), + params=params, # type: ignore + help=use_help, + epilog=command_info.epilog, + short_help=command_info.short_help, + options_metavar=command_info.options_metavar, + add_help_option=command_info.add_help_option, + no_args_is_help=command_info.no_args_is_help, + hidden=command_info.hidden, + deprecated=command_info.deprecated, + rich_markup_mode=rich_markup_mode, + # Rich settings + rich_help_panel=command_info.rich_help_panel, + ) + return command + + +def determine_type_convertor(type_: Any) -> Optional[Callable[[Any], Any]]: + convertor: Optional[Callable[[Any], Any]] = None + if lenient_issubclass(type_, Path): + convertor = param_path_convertor + if lenient_issubclass(type_, Enum): + convertor = generate_enum_convertor(type_) + return convertor + + +def param_path_convertor(value: Optional[str] = None) -> Optional[Path]: + if value is not None: + # allow returning any subclass of Path created by an annotated parser without converting + # it back to a Path + return value if isinstance(value, Path) else Path(value) + return None + + +def generate_enum_convertor(enum: Type[Enum]) -> Callable[[Any], Any]: + val_map = {str(val.value): val for val in enum} + + def convertor(value: Any) -> Any: + if value is not None: + val = str(value) + if val in val_map: + key = val_map[val] + return enum(key) + + return convertor + + +def generate_list_convertor( + convertor: Optional[Callable[[Any], Any]], default_value: Optional[Any] +) -> Callable[[Optional[Sequence[Any]]], Optional[List[Any]]]: + def internal_convertor(value: Optional[Sequence[Any]]) -> Optional[List[Any]]: + if (value is None) or (default_value is None and len(value) == 0): + return None + return [convertor(v) if convertor else v for v in value] + + return internal_convertor + + +def generate_tuple_convertor( + types: Sequence[Any], +) -> Callable[[Optional[Tuple[Any, ...]]], Optional[Tuple[Any, ...]]]: + convertors = [determine_type_convertor(type_) for type_ in types] + + 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) + ) + + return internal_convertor + + +def get_callback( + *, + callback: Optional[Callable[..., Any]] = None, + params: Sequence[click.Parameter] = [], + convertors: Optional[Dict[str, Callable[[str], Any]]] = None, + context_param_name: Optional[str] = None, + pretty_exceptions_short: bool, +) -> Optional[Callable[..., Any]]: + use_convertors = convertors or {} + if not callback: + return None + parameters = get_params_from_function(callback) + use_params: Dict[str, Any] = {} + for param_name in parameters: + use_params[param_name] = None + for param in params: + if param.name: + use_params[param.name] = param.default + + def wrapper(**kwargs: Any) -> Any: + _rich_traceback_guard = pretty_exceptions_short # noqa: F841 + for k, v in kwargs.items(): + if k in use_convertors: + use_params[k] = use_convertors[k](v) + else: + use_params[k] = v + if context_param_name: + use_params[context_param_name] = click.get_current_context() + return callback(**use_params) + + update_wrapper(wrapper, callback) + return wrapper + + +def get_click_type( + *, annotation: Any, parameter_info: ParameterInfo +) -> click.ParamType: + if parameter_info.click_type is not None: + return parameter_info.click_type + + elif parameter_info.parser is not None: + return click.types.FuncParamType(parameter_info.parser) + + elif annotation is str: + return click.STRING + elif annotation is int: + if parameter_info.min is not None or parameter_info.max is not None: + min_ = None + max_ = None + if parameter_info.min is not None: + min_ = int(parameter_info.min) + if parameter_info.max is not None: + max_ = int(parameter_info.max) + return click.IntRange(min=min_, max=max_, clamp=parameter_info.clamp) + else: + return click.INT + elif annotation is float: + if parameter_info.min is not None or parameter_info.max is not None: + return click.FloatRange( + min=parameter_info.min, + max=parameter_info.max, + clamp=parameter_info.clamp, + ) + else: + return click.FLOAT + elif annotation is bool: + return click.BOOL + elif annotation == UUID: + return click.UUID + elif annotation == datetime: + return click.DateTime(formats=parameter_info.formats) + elif ( + annotation == Path + or parameter_info.allow_dash + or parameter_info.path_type + or parameter_info.resolve_path + ): + return TyperPath( + exists=parameter_info.exists, + file_okay=parameter_info.file_okay, + dir_okay=parameter_info.dir_okay, + writable=parameter_info.writable, + readable=parameter_info.readable, + resolve_path=parameter_info.resolve_path, + allow_dash=parameter_info.allow_dash, + path_type=parameter_info.path_type, + ) + elif lenient_issubclass(annotation, FileTextWrite): + return click.File( + mode=parameter_info.mode or "w", + encoding=parameter_info.encoding, + errors=parameter_info.errors, + lazy=parameter_info.lazy, + atomic=parameter_info.atomic, + ) + elif lenient_issubclass(annotation, FileText): + return click.File( + mode=parameter_info.mode or "r", + encoding=parameter_info.encoding, + errors=parameter_info.errors, + lazy=parameter_info.lazy, + atomic=parameter_info.atomic, + ) + elif lenient_issubclass(annotation, FileBinaryRead): + return click.File( + mode=parameter_info.mode or "rb", + encoding=parameter_info.encoding, + errors=parameter_info.errors, + lazy=parameter_info.lazy, + atomic=parameter_info.atomic, + ) + elif lenient_issubclass(annotation, FileBinaryWrite): + return click.File( + mode=parameter_info.mode or "wb", + encoding=parameter_info.encoding, + errors=parameter_info.errors, + lazy=parameter_info.lazy, + atomic=parameter_info.atomic, + ) + elif lenient_issubclass(annotation, Enum): + # The custom TyperChoice is only needed for Click < 8.2.0, to parse the + # command line values matching them to the enum values. Click 8.2.0 added + # support for enum values but reading enum names. + # Passing here the list of enum values (instead of just the enum) accounts for + # Click < 8.2.0. + return TyperChoice( + [item.value for item in annotation], + case_sensitive=parameter_info.case_sensitive, + ) + elif is_literal_type(annotation): + return click.Choice( + literal_values(annotation), + case_sensitive=parameter_info.case_sensitive, + ) + raise RuntimeError(f"Type not yet supported: {annotation}") # pragma: no cover + + +def lenient_issubclass( + cls: Any, class_or_tuple: Union[AnyType, Tuple[AnyType, ...]] +) -> bool: + return isinstance(cls, type) and issubclass(cls, class_or_tuple) + + +def get_click_param( + param: ParamMeta, +) -> Tuple[Union[click.Argument, click.Option], Any]: + # First, find out what will be: + # * ParamInfo (ArgumentInfo or OptionInfo) + # * default_value + # * required + default_value = None + required = False + if isinstance(param.default, ParameterInfo): + parameter_info = param.default + if parameter_info.default == Required: + required = True + else: + default_value = parameter_info.default + elif param.default == Required or param.default is param.empty: + required = True + parameter_info = ArgumentInfo() + else: + default_value = param.default + parameter_info = OptionInfo() + annotation: Any + if param.annotation is not param.empty: + annotation = param.annotation + else: + annotation = str + main_type = annotation + is_list = False + is_tuple = False + parameter_type: Any = None + is_flag = None + origin = get_origin(main_type) + + if origin is not None: + # Handle SomeType | None and Optional[SomeType] + if is_union(origin): + types = [] + for type_ in get_args(main_type): + if type_ is NoneType: + continue + types.append(type_) + assert len(types) == 1, "Typer Currently doesn't support Union types" + main_type = types[0] + origin = get_origin(main_type) + # Handle Tuples and Lists + if lenient_issubclass(origin, List): + main_type = get_args(main_type)[0] + assert not get_origin(main_type), ( + "List types with complex sub-types are not currently supported" + ) + is_list = True + elif lenient_issubclass(origin, Tuple): # type: ignore + types = [] + for type_ in get_args(main_type): + assert not get_origin(type_), ( + "Tuple types with complex sub-types are not currently supported" + ) + types.append( + get_click_type(annotation=type_, parameter_info=parameter_info) + ) + parameter_type = tuple(types) + is_tuple = True + if parameter_type is None: + parameter_type = get_click_type( + annotation=main_type, parameter_info=parameter_info + ) + convertor = determine_type_convertor(main_type) + if is_list: + convertor = generate_list_convertor( + convertor=convertor, default_value=default_value + ) + if is_tuple: + convertor = generate_tuple_convertor(get_args(main_type)) + if isinstance(parameter_info, OptionInfo): + if main_type is bool: + is_flag = True + # Click doesn't accept a flag of type bool, only None, and then it sets it + # to bool internally + parameter_type = None + default_option_name = get_command_name(param.name) + if is_flag: + default_option_declaration = ( + f"--{default_option_name}/--no-{default_option_name}" + ) + else: + default_option_declaration = f"--{default_option_name}" + param_decls = [param.name] + if parameter_info.param_decls: + param_decls.extend(parameter_info.param_decls) + else: + param_decls.append(default_option_declaration) + return ( + TyperOption( + # Option + param_decls=param_decls, + show_default=parameter_info.show_default, + prompt=parameter_info.prompt, + confirmation_prompt=parameter_info.confirmation_prompt, + prompt_required=parameter_info.prompt_required, + hide_input=parameter_info.hide_input, + is_flag=is_flag, + multiple=is_list, + count=parameter_info.count, + allow_from_autoenv=parameter_info.allow_from_autoenv, + type=parameter_type, + help=parameter_info.help, + hidden=parameter_info.hidden, + show_choices=parameter_info.show_choices, + show_envvar=parameter_info.show_envvar, + # Parameter + required=required, + default=default_value, + callback=get_param_callback( + callback=parameter_info.callback, convertor=convertor + ), + metavar=parameter_info.metavar, + expose_value=parameter_info.expose_value, + is_eager=parameter_info.is_eager, + envvar=parameter_info.envvar, + shell_complete=parameter_info.shell_complete, + autocompletion=get_param_completion(parameter_info.autocompletion), + # Rich settings + rich_help_panel=parameter_info.rich_help_panel, + ), + convertor, + ) + elif isinstance(parameter_info, ArgumentInfo): + param_decls = [param.name] + nargs = None + if is_list: + nargs = -1 + return ( + TyperArgument( + # Argument + param_decls=param_decls, + type=parameter_type, + required=required, + nargs=nargs, + # TyperArgument + show_default=parameter_info.show_default, + show_choices=parameter_info.show_choices, + show_envvar=parameter_info.show_envvar, + help=parameter_info.help, + hidden=parameter_info.hidden, + # Parameter + default=default_value, + callback=get_param_callback( + callback=parameter_info.callback, convertor=convertor + ), + metavar=parameter_info.metavar, + expose_value=parameter_info.expose_value, + is_eager=parameter_info.is_eager, + envvar=parameter_info.envvar, + shell_complete=parameter_info.shell_complete, + autocompletion=get_param_completion(parameter_info.autocompletion), + # Rich settings + rich_help_panel=parameter_info.rich_help_panel, + ), + convertor, + ) + raise AssertionError("A click.Parameter should be returned") # pragma: no cover + + +def get_param_callback( + *, + callback: Optional[Callable[..., Any]] = None, + convertor: Optional[Callable[..., Any]] = None, +) -> Optional[Callable[..., Any]]: + if not callback: + return None + parameters = get_params_from_function(callback) + ctx_name = None + click_param_name = None + value_name = None + untyped_names: List[str] = [] + for param_name, param_sig in parameters.items(): + if lenient_issubclass(param_sig.annotation, click.Context): + ctx_name = param_name + elif lenient_issubclass(param_sig.annotation, click.Parameter): + click_param_name = param_name + else: + untyped_names.append(param_name) + # Extract value param name first + if untyped_names: + value_name = untyped_names.pop() + # If context and Click param were not typed (old/Click callback style) extract them + if untyped_names: + if ctx_name is None: + ctx_name = untyped_names.pop(0) + if click_param_name is None: + if untyped_names: + click_param_name = untyped_names.pop(0) + if untyped_names: + raise click.ClickException( + "Too many CLI parameter callback function parameters" + ) + + def wrapper(ctx: click.Context, param: click.Parameter, value: Any) -> Any: + use_params: Dict[str, Any] = {} + if ctx_name: + use_params[ctx_name] = ctx + if click_param_name: + use_params[click_param_name] = param + if value_name: + if convertor: + use_value = convertor(value) + else: + use_value = value + use_params[value_name] = use_value + return callback(**use_params) + + update_wrapper(wrapper, callback) + return wrapper + + +def get_param_completion( + callback: Optional[Callable[..., Any]] = None, +) -> Optional[Callable[..., Any]]: + if not callback: + return None + parameters = get_params_from_function(callback) + ctx_name = None + args_name = None + incomplete_name = None + unassigned_params = list(parameters.values()) + for param_sig in unassigned_params[:]: + origin = get_origin(param_sig.annotation) + if lenient_issubclass(param_sig.annotation, click.Context): + ctx_name = param_sig.name + unassigned_params.remove(param_sig) + elif lenient_issubclass(origin, List): + args_name = param_sig.name + unassigned_params.remove(param_sig) + elif lenient_issubclass(param_sig.annotation, str): + incomplete_name = param_sig.name + unassigned_params.remove(param_sig) + # If there are still unassigned parameters (not typed), extract by name + for param_sig in unassigned_params[:]: + if ctx_name is None and param_sig.name == "ctx": + ctx_name = param_sig.name + unassigned_params.remove(param_sig) + elif args_name is None and param_sig.name == "args": + args_name = param_sig.name + unassigned_params.remove(param_sig) + elif incomplete_name is None and param_sig.name == "incomplete": + incomplete_name = param_sig.name + unassigned_params.remove(param_sig) + # Extract value param name first + if unassigned_params: + show_params = " ".join([param.name for param in unassigned_params]) + raise click.ClickException( + f"Invalid autocompletion callback parameters: {show_params}" + ) + + def wrapper(ctx: click.Context, args: List[str], incomplete: Optional[str]) -> Any: + use_params: Dict[str, Any] = {} + if ctx_name: + use_params[ctx_name] = ctx + if args_name: + use_params[args_name] = args + if incomplete_name: + use_params[incomplete_name] = incomplete + return callback(**use_params) + + update_wrapper(wrapper, callback) + return wrapper + + +def run(function: Callable[..., Any]) -> None: + app = Typer(add_completion=False) + app.command()(function) + app() + + +def _is_macos() -> bool: + return platform.system() == "Darwin" + + +def _is_linux_or_bsd() -> bool: + if platform.system() == "Linux": + return True + + return "BSD" in platform.system() + + +def launch(url: str, wait: bool = False, locate: bool = False) -> int: + """This function launches the given URL (or filename) in the default + viewer application for this file type. If this is an executable, it + might launch the executable in a new session. The return value is + the exit code of the launched application. Usually, ``0`` indicates + success. + + This function handles url in different operating systems separately: + - On macOS (Darwin), it uses the 'open' command. + - On Linux and BSD, it uses 'xdg-open' if available. + - On Windows (and other OSes), it uses the standard webbrowser module. + + The function avoids, when possible, using the webbrowser module on Linux and macOS + to prevent spammy terminal messages from some browsers (e.g., Chrome). + + Examples:: + + typer.launch("https://typer.tiangolo.com/") + typer.launch("/my/downloaded/file", locate=True) + + :param url: URL or filename of the thing to launch. + :param wait: Wait for the program to exit before returning. This + only works if the launched program blocks. In particular, + ``xdg-open`` on Linux does not block. + :param locate: if this is set to `True` then instead of launching the + application associated with the URL it will attempt to + launch a file manager with the file located. This + might have weird effects if the URL does not point to + the filesystem. + """ + + if url.startswith("http://") or url.startswith("https://"): + if _is_macos(): + return subprocess.Popen( + ["open", url], stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT + ).wait() + + has_xdg_open = _is_linux_or_bsd() and shutil.which("xdg-open") is not None + + if has_xdg_open: + return subprocess.Popen( + ["xdg-open", url], stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT + ).wait() + + import webbrowser + + webbrowser.open(url) + + return 0 + + else: + return click.launch(url) diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/models.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/models.py new file mode 100644 index 0000000000000000000000000000000000000000..e0bddb965be67ec2e8fd7c045a9e53baa887a915 --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/models.py @@ -0,0 +1,544 @@ +import inspect +import io +from typing import ( + TYPE_CHECKING, + Any, + Callable, + Dict, + List, + Optional, + Sequence, + Type, + TypeVar, + Union, +) + +import click +import click.shell_completion + +if TYPE_CHECKING: # pragma: no cover + from .core import TyperCommand, TyperGroup + from .main import Typer + + +NoneType = type(None) + +AnyType = Type[Any] + +Required = ... + + +class Context(click.Context): + pass + + +class FileText(io.TextIOWrapper): + pass + + +class FileTextWrite(FileText): + pass + + +class FileBinaryRead(io.BufferedReader): + pass + + +class FileBinaryWrite(io.BufferedWriter): + pass + + +class CallbackParam(click.Parameter): + pass + + +class DefaultPlaceholder: + """ + You shouldn't use this class directly. + + It's used internally to recognize when a default value has been overwritten, even + if the new value is `None`. + """ + + def __init__(self, value: Any): + self.value = value + + def __bool__(self) -> bool: + return bool(self.value) + + +DefaultType = TypeVar("DefaultType") + +CommandFunctionType = TypeVar("CommandFunctionType", bound=Callable[..., Any]) + + +def Default(value: DefaultType) -> DefaultType: + """ + You shouldn't use this function directly. + + It's used internally to recognize when a default value has been overwritten, even + if the new value is `None`. + """ + return DefaultPlaceholder(value) # type: ignore + + +class CommandInfo: + def __init__( + self, + name: Optional[str] = None, + *, + cls: Optional[Type["TyperCommand"]] = None, + context_settings: Optional[Dict[Any, Any]] = None, + callback: Optional[Callable[..., Any]] = None, + help: Optional[str] = None, + epilog: Optional[str] = None, + short_help: Optional[str] = None, + options_metavar: str = "[OPTIONS]", + add_help_option: bool = True, + no_args_is_help: bool = False, + hidden: bool = False, + deprecated: bool = False, + # Rich settings + rich_help_panel: Union[str, None] = None, + ): + self.name = name + self.cls = cls + self.context_settings = context_settings + self.callback = callback + self.help = help + self.epilog = epilog + self.short_help = short_help + self.options_metavar = options_metavar + self.add_help_option = add_help_option + self.no_args_is_help = no_args_is_help + self.hidden = hidden + self.deprecated = deprecated + # Rich settings + self.rich_help_panel = rich_help_panel + + +class TyperInfo: + def __init__( + self, + typer_instance: Optional["Typer"] = Default(None), + *, + name: Optional[str] = Default(None), + cls: Optional[Type["TyperGroup"]] = Default(None), + invoke_without_command: bool = Default(False), + no_args_is_help: bool = Default(False), + subcommand_metavar: Optional[str] = Default(None), + chain: bool = Default(False), + result_callback: Optional[Callable[..., Any]] = Default(None), + # Command + context_settings: Optional[Dict[Any, Any]] = Default(None), + callback: Optional[Callable[..., Any]] = Default(None), + help: Optional[str] = Default(None), + epilog: Optional[str] = Default(None), + short_help: Optional[str] = Default(None), + options_metavar: str = Default("[OPTIONS]"), + add_help_option: bool = Default(True), + hidden: bool = Default(False), + deprecated: bool = Default(False), + # Rich settings + rich_help_panel: Union[str, None] = Default(None), + ): + self.typer_instance = typer_instance + self.name = name + self.cls = cls + self.invoke_without_command = invoke_without_command + self.no_args_is_help = no_args_is_help + self.subcommand_metavar = subcommand_metavar + self.chain = chain + self.result_callback = result_callback + self.context_settings = context_settings + self.callback = callback + self.help = help + self.epilog = epilog + self.short_help = short_help + self.options_metavar = options_metavar + self.add_help_option = add_help_option + self.hidden = hidden + self.deprecated = deprecated + self.rich_help_panel = rich_help_panel + + +class ParameterInfo: + def __init__( + self, + *, + default: Optional[Any] = None, + param_decls: Optional[Sequence[str]] = None, + callback: Optional[Callable[..., Any]] = None, + metavar: Optional[str] = None, + expose_value: bool = True, + is_eager: bool = False, + envvar: Optional[Union[str, List[str]]] = None, + # Note that shell_complete is not fully supported and will be removed in future versions + # TODO: Remove shell_complete in a future version (after 0.16.0) + shell_complete: Optional[ + Callable[ + [click.Context, click.Parameter, str], + Union[List["click.shell_completion.CompletionItem"], List[str]], + ] + ] = None, + autocompletion: Optional[Callable[..., Any]] = None, + default_factory: Optional[Callable[[], Any]] = None, + # Custom type + parser: Optional[Callable[[str], Any]] = None, + click_type: Optional[click.ParamType] = None, + # TyperArgument + show_default: Union[bool, str] = True, + show_choices: bool = True, + show_envvar: bool = True, + help: Optional[str] = None, + hidden: bool = False, + # Choice + case_sensitive: bool = True, + # Numbers + min: Optional[Union[int, float]] = None, + max: Optional[Union[int, float]] = None, + clamp: bool = False, + # DateTime + formats: Optional[List[str]] = None, + # File + mode: Optional[str] = None, + encoding: Optional[str] = None, + errors: Optional[str] = "strict", + lazy: Optional[bool] = None, + atomic: bool = False, + # Path + exists: bool = False, + file_okay: bool = True, + dir_okay: bool = True, + writable: bool = False, + readable: bool = True, + resolve_path: bool = False, + allow_dash: bool = False, + path_type: Union[None, Type[str], Type[bytes]] = None, + # Rich settings + rich_help_panel: Union[str, None] = None, + ): + # Check if user has provided multiple custom parsers + if parser and click_type: + raise ValueError( + "Multiple custom type parsers provided. " + "`parser` and `click_type` may not both be provided." + ) + + self.default = default + self.param_decls = param_decls + self.callback = callback + self.metavar = metavar + self.expose_value = expose_value + self.is_eager = is_eager + self.envvar = envvar + self.shell_complete = shell_complete + self.autocompletion = autocompletion + self.default_factory = default_factory + # Custom type + self.parser = parser + self.click_type = click_type + # TyperArgument + self.show_default = show_default + self.show_choices = show_choices + self.show_envvar = show_envvar + self.help = help + self.hidden = hidden + # Choice + self.case_sensitive = case_sensitive + # Numbers + self.min = min + self.max = max + self.clamp = clamp + # DateTime + self.formats = formats + # File + self.mode = mode + self.encoding = encoding + self.errors = errors + self.lazy = lazy + self.atomic = atomic + # Path + self.exists = exists + self.file_okay = file_okay + self.dir_okay = dir_okay + self.writable = writable + self.readable = readable + self.resolve_path = resolve_path + self.allow_dash = allow_dash + self.path_type = path_type + # Rich settings + self.rich_help_panel = rich_help_panel + + +class OptionInfo(ParameterInfo): + def __init__( + self, + *, + # ParameterInfo + default: Optional[Any] = None, + param_decls: Optional[Sequence[str]] = None, + callback: Optional[Callable[..., Any]] = None, + metavar: Optional[str] = None, + expose_value: bool = True, + is_eager: bool = False, + envvar: Optional[Union[str, List[str]]] = None, + # Note that shell_complete is not fully supported and will be removed in future versions + # TODO: Remove shell_complete in a future version (after 0.16.0) + shell_complete: Optional[ + Callable[ + [click.Context, click.Parameter, str], + Union[List["click.shell_completion.CompletionItem"], List[str]], + ] + ] = None, + autocompletion: Optional[Callable[..., Any]] = None, + default_factory: Optional[Callable[[], Any]] = None, + # Custom type + parser: Optional[Callable[[str], Any]] = None, + click_type: Optional[click.ParamType] = None, + # Option + show_default: Union[bool, str] = True, + prompt: Union[bool, str] = False, + confirmation_prompt: bool = False, + prompt_required: bool = True, + hide_input: bool = False, + # TODO: remove is_flag and flag_value in a future release + is_flag: Optional[bool] = None, + flag_value: Optional[Any] = None, + count: bool = False, + allow_from_autoenv: bool = True, + help: Optional[str] = None, + hidden: bool = False, + show_choices: bool = True, + show_envvar: bool = True, + # Choice + case_sensitive: bool = True, + # Numbers + min: Optional[Union[int, float]] = None, + max: Optional[Union[int, float]] = None, + clamp: bool = False, + # DateTime + formats: Optional[List[str]] = None, + # File + mode: Optional[str] = None, + encoding: Optional[str] = None, + errors: Optional[str] = "strict", + lazy: Optional[bool] = None, + atomic: bool = False, + # Path + exists: bool = False, + file_okay: bool = True, + dir_okay: bool = True, + writable: bool = False, + readable: bool = True, + resolve_path: bool = False, + allow_dash: bool = False, + path_type: Union[None, Type[str], Type[bytes]] = None, + # Rich settings + rich_help_panel: Union[str, None] = None, + ): + super().__init__( + default=default, + param_decls=param_decls, + callback=callback, + metavar=metavar, + expose_value=expose_value, + is_eager=is_eager, + envvar=envvar, + shell_complete=shell_complete, + autocompletion=autocompletion, + default_factory=default_factory, + # Custom type + parser=parser, + click_type=click_type, + # TyperArgument + show_default=show_default, + show_choices=show_choices, + show_envvar=show_envvar, + help=help, + hidden=hidden, + # Choice + case_sensitive=case_sensitive, + # Numbers + min=min, + max=max, + clamp=clamp, + # DateTime + formats=formats, + # File + mode=mode, + encoding=encoding, + errors=errors, + lazy=lazy, + atomic=atomic, + # Path + exists=exists, + file_okay=file_okay, + dir_okay=dir_okay, + writable=writable, + readable=readable, + resolve_path=resolve_path, + allow_dash=allow_dash, + path_type=path_type, + # Rich settings + rich_help_panel=rich_help_panel, + ) + if is_flag is not None or flag_value is not None: + import warnings + + warnings.warn( + "The 'is_flag' and 'flag_value' parameters are not supported by Typer " + "and will be removed entirely in a future release.", + DeprecationWarning, + stacklevel=2, + ) + self.prompt = prompt + self.confirmation_prompt = confirmation_prompt + self.prompt_required = prompt_required + self.hide_input = hide_input + self.count = count + self.allow_from_autoenv = allow_from_autoenv + + +class ArgumentInfo(ParameterInfo): + def __init__( + self, + *, + # ParameterInfo + default: Optional[Any] = None, + param_decls: Optional[Sequence[str]] = None, + callback: Optional[Callable[..., Any]] = None, + metavar: Optional[str] = None, + expose_value: bool = True, + is_eager: bool = False, + envvar: Optional[Union[str, List[str]]] = None, + # Note that shell_complete is not fully supported and will be removed in future versions + # TODO: Remove shell_complete in a future version (after 0.16.0) + shell_complete: Optional[ + Callable[ + [click.Context, click.Parameter, str], + Union[List["click.shell_completion.CompletionItem"], List[str]], + ] + ] = None, + autocompletion: Optional[Callable[..., Any]] = None, + default_factory: Optional[Callable[[], Any]] = None, + # Custom type + parser: Optional[Callable[[str], Any]] = None, + click_type: Optional[click.ParamType] = None, + # TyperArgument + show_default: Union[bool, str] = True, + show_choices: bool = True, + show_envvar: bool = True, + help: Optional[str] = None, + hidden: bool = False, + # Choice + case_sensitive: bool = True, + # Numbers + min: Optional[Union[int, float]] = None, + max: Optional[Union[int, float]] = None, + clamp: bool = False, + # DateTime + formats: Optional[List[str]] = None, + # File + mode: Optional[str] = None, + encoding: Optional[str] = None, + errors: Optional[str] = "strict", + lazy: Optional[bool] = None, + atomic: bool = False, + # Path + exists: bool = False, + file_okay: bool = True, + dir_okay: bool = True, + writable: bool = False, + readable: bool = True, + resolve_path: bool = False, + allow_dash: bool = False, + path_type: Union[None, Type[str], Type[bytes]] = None, + # Rich settings + rich_help_panel: Union[str, None] = None, + ): + super().__init__( + default=default, + param_decls=param_decls, + callback=callback, + metavar=metavar, + expose_value=expose_value, + is_eager=is_eager, + envvar=envvar, + shell_complete=shell_complete, + autocompletion=autocompletion, + default_factory=default_factory, + # Custom type + parser=parser, + click_type=click_type, + # TyperArgument + show_default=show_default, + show_choices=show_choices, + show_envvar=show_envvar, + help=help, + hidden=hidden, + # Choice + case_sensitive=case_sensitive, + # Numbers + min=min, + max=max, + clamp=clamp, + # DateTime + formats=formats, + # File + mode=mode, + encoding=encoding, + errors=errors, + lazy=lazy, + atomic=atomic, + # Path + exists=exists, + file_okay=file_okay, + dir_okay=dir_okay, + writable=writable, + readable=readable, + resolve_path=resolve_path, + allow_dash=allow_dash, + path_type=path_type, + # Rich settings + rich_help_panel=rich_help_panel, + ) + + +class ParamMeta: + empty = inspect.Parameter.empty + + def __init__( + self, + *, + name: str, + default: Any = inspect.Parameter.empty, + annotation: Any = inspect.Parameter.empty, + ) -> None: + self.name = name + self.default = default + self.annotation = annotation + + +class DeveloperExceptionConfig: + def __init__( + self, + *, + pretty_exceptions_enable: bool = True, + pretty_exceptions_show_locals: bool = True, + pretty_exceptions_short: bool = True, + ) -> None: + self.pretty_exceptions_enable = pretty_exceptions_enable + self.pretty_exceptions_show_locals = pretty_exceptions_show_locals + self.pretty_exceptions_short = pretty_exceptions_short + + +class TyperPath(click.Path): + # Overwrite Click's behaviour to be compatible with Typer's autocompletion system + def shell_complete( + self, ctx: click.Context, param: click.Parameter, incomplete: str + ) -> List[click.shell_completion.CompletionItem]: + """Return an empty list so that the autocompletion functionality + will work properly from the commandline. + """ + return [] diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/params.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/params.py new file mode 100644 index 0000000000000000000000000000000000000000..66c2b32d3e35e313454ed3dcbaac8ac9bf71d14d --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/params.py @@ -0,0 +1,479 @@ +from typing import TYPE_CHECKING, Any, Callable, List, Optional, Type, Union, overload + +import click + +from .models import ArgumentInfo, OptionInfo + +if TYPE_CHECKING: # pragma: no cover + import click.shell_completion + + +# Overload for Option created with custom type 'parser' +@overload +def Option( + # Parameter + default: Optional[Any] = ..., + *param_decls: str, + callback: Optional[Callable[..., Any]] = None, + metavar: Optional[str] = None, + expose_value: bool = True, + is_eager: bool = False, + envvar: Optional[Union[str, List[str]]] = None, + # Note that shell_complete is not fully supported and will be removed in future versions + # TODO: Remove shell_complete in a future version (after 0.16.0) + shell_complete: Optional[ + Callable[ + [click.Context, click.Parameter, str], + Union[List["click.shell_completion.CompletionItem"], List[str]], + ] + ] = None, + autocompletion: Optional[Callable[..., Any]] = None, + default_factory: Optional[Callable[[], Any]] = None, + # Custom type + parser: Optional[Callable[[str], Any]] = None, + # Option + show_default: Union[bool, str] = True, + prompt: Union[bool, str] = False, + confirmation_prompt: bool = False, + prompt_required: bool = True, + hide_input: bool = False, + # TODO: remove is_flag and flag_value in a future release + is_flag: Optional[bool] = None, + flag_value: Optional[Any] = None, + count: bool = False, + allow_from_autoenv: bool = True, + help: Optional[str] = None, + hidden: bool = False, + show_choices: bool = True, + show_envvar: bool = True, + # Choice + case_sensitive: bool = True, + # Numbers + min: Optional[Union[int, float]] = None, + max: Optional[Union[int, float]] = None, + clamp: bool = False, + # DateTime + formats: Optional[List[str]] = None, + # File + mode: Optional[str] = None, + encoding: Optional[str] = None, + errors: Optional[str] = "strict", + lazy: Optional[bool] = None, + atomic: bool = False, + # Path + exists: bool = False, + file_okay: bool = True, + dir_okay: bool = True, + writable: bool = False, + readable: bool = True, + resolve_path: bool = False, + allow_dash: bool = False, + path_type: Union[None, Type[str], Type[bytes]] = None, + # Rich settings + rich_help_panel: Union[str, None] = None, +) -> Any: ... + + +# Overload for Option created with custom type 'click_type' +@overload +def Option( + # Parameter + default: Optional[Any] = ..., + *param_decls: str, + callback: Optional[Callable[..., Any]] = None, + metavar: Optional[str] = None, + expose_value: bool = True, + is_eager: bool = False, + envvar: Optional[Union[str, List[str]]] = None, + # Note that shell_complete is not fully supported and will be removed in future versions + # TODO: Remove shell_complete in a future version (after 0.16.0) + shell_complete: Optional[ + Callable[ + [click.Context, click.Parameter, str], + Union[List["click.shell_completion.CompletionItem"], List[str]], + ] + ] = None, + autocompletion: Optional[Callable[..., Any]] = None, + default_factory: Optional[Callable[[], Any]] = None, + # Custom type + click_type: Optional[click.ParamType] = None, + # Option + show_default: Union[bool, str] = True, + prompt: Union[bool, str] = False, + confirmation_prompt: bool = False, + prompt_required: bool = True, + hide_input: bool = False, + # TODO: remove is_flag and flag_value in a future release + is_flag: Optional[bool] = None, + flag_value: Optional[Any] = None, + count: bool = False, + allow_from_autoenv: bool = True, + help: Optional[str] = None, + hidden: bool = False, + show_choices: bool = True, + show_envvar: bool = True, + # Choice + case_sensitive: bool = True, + # Numbers + min: Optional[Union[int, float]] = None, + max: Optional[Union[int, float]] = None, + clamp: bool = False, + # DateTime + formats: Optional[List[str]] = None, + # File + mode: Optional[str] = None, + encoding: Optional[str] = None, + errors: Optional[str] = "strict", + lazy: Optional[bool] = None, + atomic: bool = False, + # Path + exists: bool = False, + file_okay: bool = True, + dir_okay: bool = True, + writable: bool = False, + readable: bool = True, + resolve_path: bool = False, + allow_dash: bool = False, + path_type: Union[None, Type[str], Type[bytes]] = None, + # Rich settings + rich_help_panel: Union[str, None] = None, +) -> Any: ... + + +def Option( + # Parameter + default: Optional[Any] = ..., + *param_decls: str, + callback: Optional[Callable[..., Any]] = None, + metavar: Optional[str] = None, + expose_value: bool = True, + is_eager: bool = False, + envvar: Optional[Union[str, List[str]]] = None, + # Note that shell_complete is not fully supported and will be removed in future versions + # TODO: Remove shell_complete in a future version (after 0.16.0) + shell_complete: Optional[ + Callable[ + [click.Context, click.Parameter, str], + Union[List["click.shell_completion.CompletionItem"], List[str]], + ] + ] = None, + autocompletion: Optional[Callable[..., Any]] = None, + default_factory: Optional[Callable[[], Any]] = None, + # Custom type + parser: Optional[Callable[[str], Any]] = None, + click_type: Optional[click.ParamType] = None, + # Option + show_default: Union[bool, str] = True, + prompt: Union[bool, str] = False, + confirmation_prompt: bool = False, + prompt_required: bool = True, + hide_input: bool = False, + # TODO: remove is_flag and flag_value in a future release + is_flag: Optional[bool] = None, + flag_value: Optional[Any] = None, + count: bool = False, + allow_from_autoenv: bool = True, + help: Optional[str] = None, + hidden: bool = False, + show_choices: bool = True, + show_envvar: bool = True, + # Choice + case_sensitive: bool = True, + # Numbers + min: Optional[Union[int, float]] = None, + max: Optional[Union[int, float]] = None, + clamp: bool = False, + # DateTime + formats: Optional[List[str]] = None, + # File + mode: Optional[str] = None, + encoding: Optional[str] = None, + errors: Optional[str] = "strict", + lazy: Optional[bool] = None, + atomic: bool = False, + # Path + exists: bool = False, + file_okay: bool = True, + dir_okay: bool = True, + writable: bool = False, + readable: bool = True, + resolve_path: bool = False, + allow_dash: bool = False, + path_type: Union[None, Type[str], Type[bytes]] = None, + # Rich settings + rich_help_panel: Union[str, None] = None, +) -> Any: + return OptionInfo( + # Parameter + default=default, + param_decls=param_decls, + callback=callback, + metavar=metavar, + expose_value=expose_value, + is_eager=is_eager, + envvar=envvar, + shell_complete=shell_complete, + autocompletion=autocompletion, + default_factory=default_factory, + # Custom type + parser=parser, + click_type=click_type, + # Option + show_default=show_default, + prompt=prompt, + confirmation_prompt=confirmation_prompt, + prompt_required=prompt_required, + hide_input=hide_input, + is_flag=is_flag, + flag_value=flag_value, + count=count, + allow_from_autoenv=allow_from_autoenv, + help=help, + hidden=hidden, + show_choices=show_choices, + show_envvar=show_envvar, + # Choice + case_sensitive=case_sensitive, + # Numbers + min=min, + max=max, + clamp=clamp, + # DateTime + formats=formats, + # File + mode=mode, + encoding=encoding, + errors=errors, + lazy=lazy, + atomic=atomic, + # Path + exists=exists, + file_okay=file_okay, + dir_okay=dir_okay, + writable=writable, + readable=readable, + resolve_path=resolve_path, + allow_dash=allow_dash, + path_type=path_type, + # Rich settings + rich_help_panel=rich_help_panel, + ) + + +# Overload for Argument created with custom type 'parser' +@overload +def Argument( + # Parameter + default: Optional[Any] = ..., + *, + callback: Optional[Callable[..., Any]] = None, + metavar: Optional[str] = None, + expose_value: bool = True, + is_eager: bool = False, + envvar: Optional[Union[str, List[str]]] = None, + # Note that shell_complete is not fully supported and will be removed in future versions + # TODO: Remove shell_complete in a future version (after 0.16.0) + shell_complete: Optional[ + Callable[ + [click.Context, click.Parameter, str], + Union[List["click.shell_completion.CompletionItem"], List[str]], + ] + ] = None, + autocompletion: Optional[Callable[..., Any]] = None, + default_factory: Optional[Callable[[], Any]] = None, + # Custom type + parser: Optional[Callable[[str], Any]] = None, + # TyperArgument + show_default: Union[bool, str] = True, + show_choices: bool = True, + show_envvar: bool = True, + help: Optional[str] = None, + hidden: bool = False, + # Choice + case_sensitive: bool = True, + # Numbers + min: Optional[Union[int, float]] = None, + max: Optional[Union[int, float]] = None, + clamp: bool = False, + # DateTime + formats: Optional[List[str]] = None, + # File + mode: Optional[str] = None, + encoding: Optional[str] = None, + errors: Optional[str] = "strict", + lazy: Optional[bool] = None, + atomic: bool = False, + # Path + exists: bool = False, + file_okay: bool = True, + dir_okay: bool = True, + writable: bool = False, + readable: bool = True, + resolve_path: bool = False, + allow_dash: bool = False, + path_type: Union[None, Type[str], Type[bytes]] = None, + # Rich settings + rich_help_panel: Union[str, None] = None, +) -> Any: ... + + +# Overload for Argument created with custom type 'click_type' +@overload +def Argument( + # Parameter + default: Optional[Any] = ..., + *, + callback: Optional[Callable[..., Any]] = None, + metavar: Optional[str] = None, + expose_value: bool = True, + is_eager: bool = False, + envvar: Optional[Union[str, List[str]]] = None, + # Note that shell_complete is not fully supported and will be removed in future versions + # TODO: Remove shell_complete in a future version (after 0.16.0) + shell_complete: Optional[ + Callable[ + [click.Context, click.Parameter, str], + Union[List["click.shell_completion.CompletionItem"], List[str]], + ] + ] = None, + autocompletion: Optional[Callable[..., Any]] = None, + default_factory: Optional[Callable[[], Any]] = None, + # Custom type + click_type: Optional[click.ParamType] = None, + # TyperArgument + show_default: Union[bool, str] = True, + show_choices: bool = True, + show_envvar: bool = True, + help: Optional[str] = None, + hidden: bool = False, + # Choice + case_sensitive: bool = True, + # Numbers + min: Optional[Union[int, float]] = None, + max: Optional[Union[int, float]] = None, + clamp: bool = False, + # DateTime + formats: Optional[List[str]] = None, + # File + mode: Optional[str] = None, + encoding: Optional[str] = None, + errors: Optional[str] = "strict", + lazy: Optional[bool] = None, + atomic: bool = False, + # Path + exists: bool = False, + file_okay: bool = True, + dir_okay: bool = True, + writable: bool = False, + readable: bool = True, + resolve_path: bool = False, + allow_dash: bool = False, + path_type: Union[None, Type[str], Type[bytes]] = None, + # Rich settings + rich_help_panel: Union[str, None] = None, +) -> Any: ... + + +def Argument( + # Parameter + default: Optional[Any] = ..., + *, + callback: Optional[Callable[..., Any]] = None, + metavar: Optional[str] = None, + expose_value: bool = True, + is_eager: bool = False, + envvar: Optional[Union[str, List[str]]] = None, + # Note that shell_complete is not fully supported and will be removed in future versions + # TODO: Remove shell_complete in a future version (after 0.16.0) + shell_complete: Optional[ + Callable[ + [click.Context, click.Parameter, str], + Union[List["click.shell_completion.CompletionItem"], List[str]], + ] + ] = None, + autocompletion: Optional[Callable[..., Any]] = None, + default_factory: Optional[Callable[[], Any]] = None, + # Custom type + parser: Optional[Callable[[str], Any]] = None, + click_type: Optional[click.ParamType] = None, + # TyperArgument + show_default: Union[bool, str] = True, + show_choices: bool = True, + show_envvar: bool = True, + help: Optional[str] = None, + hidden: bool = False, + # Choice + case_sensitive: bool = True, + # Numbers + min: Optional[Union[int, float]] = None, + max: Optional[Union[int, float]] = None, + clamp: bool = False, + # DateTime + formats: Optional[List[str]] = None, + # File + mode: Optional[str] = None, + encoding: Optional[str] = None, + errors: Optional[str] = "strict", + lazy: Optional[bool] = None, + atomic: bool = False, + # Path + exists: bool = False, + file_okay: bool = True, + dir_okay: bool = True, + writable: bool = False, + readable: bool = True, + resolve_path: bool = False, + allow_dash: bool = False, + path_type: Union[None, Type[str], Type[bytes]] = None, + # Rich settings + rich_help_panel: Union[str, None] = None, +) -> Any: + return ArgumentInfo( + # Parameter + default=default, + # Arguments can only have one param declaration + # it will be generated from the param name + param_decls=None, + callback=callback, + metavar=metavar, + expose_value=expose_value, + is_eager=is_eager, + envvar=envvar, + shell_complete=shell_complete, + autocompletion=autocompletion, + default_factory=default_factory, + # Custom type + parser=parser, + click_type=click_type, + # TyperArgument + show_default=show_default, + show_choices=show_choices, + show_envvar=show_envvar, + help=help, + hidden=hidden, + # Choice + case_sensitive=case_sensitive, + # Numbers + min=min, + max=max, + clamp=clamp, + # DateTime + formats=formats, + # File + mode=mode, + encoding=encoding, + errors=errors, + lazy=lazy, + atomic=atomic, + # Path + exists=exists, + file_okay=file_okay, + dir_okay=dir_okay, + writable=writable, + readable=readable, + resolve_path=resolve_path, + allow_dash=allow_dash, + path_type=path_type, + # Rich settings + rich_help_panel=rich_help_panel, + ) diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/py.typed b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/py.typed new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/rich_utils.py b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/rich_utils.py new file mode 100644 index 0000000000000000000000000000000000000000..d4c3676aeaef7c57ec20e37ab12f00932566e81e --- /dev/null +++ b/miniconda3/pkgs/typer-0.20.0-py313h06a4308_1/lib/python3.13/site-packages/typer/rich_utils.py @@ -0,0 +1,770 @@ +# Extracted and modified from https://github.com/ewels/rich-click + +import inspect +import io +import sys +from collections import defaultdict +from gettext import gettext as _ +from os import getenv +from typing import Any, DefaultDict, Dict, Iterable, List, Optional, Union + +import click +from rich import box +from rich.align import Align +from rich.columns import Columns +from rich.console import Console, RenderableType, group +from rich.emoji import Emoji +from rich.highlighter import RegexHighlighter +from rich.markdown import Markdown +from rich.markup import escape +from rich.padding import Padding +from rich.panel import Panel +from rich.table import Table +from rich.text import Text +from rich.theme import Theme +from rich.traceback import Traceback +from typer.models import DeveloperExceptionConfig + +if sys.version_info >= (3, 9): + from typing import Literal +else: + from typing_extensions import Literal + +# Default styles +STYLE_OPTION = "bold cyan" +STYLE_SWITCH = "bold green" +STYLE_NEGATIVE_OPTION = "bold magenta" +STYLE_NEGATIVE_SWITCH = "bold red" +STYLE_METAVAR = "bold yellow" +STYLE_METAVAR_SEPARATOR = "dim" +STYLE_USAGE = "yellow" +STYLE_USAGE_COMMAND = "bold" +STYLE_DEPRECATED = "red" +STYLE_DEPRECATED_COMMAND = "dim" +STYLE_HELPTEXT_FIRST_LINE = "" +STYLE_HELPTEXT = "dim" +STYLE_OPTION_HELP = "" +STYLE_OPTION_DEFAULT = "dim" +STYLE_OPTION_ENVVAR = "dim yellow" +STYLE_REQUIRED_SHORT = "red" +STYLE_REQUIRED_LONG = "dim red" +STYLE_OPTIONS_PANEL_BORDER = "dim" +ALIGN_OPTIONS_PANEL: Literal["left", "center", "right"] = "left" +STYLE_OPTIONS_TABLE_SHOW_LINES = False +STYLE_OPTIONS_TABLE_LEADING = 0 +STYLE_OPTIONS_TABLE_PAD_EDGE = False +STYLE_OPTIONS_TABLE_PADDING = (0, 1) +STYLE_OPTIONS_TABLE_BOX = "" +STYLE_OPTIONS_TABLE_ROW_STYLES = None +STYLE_OPTIONS_TABLE_BORDER_STYLE = None +STYLE_COMMANDS_PANEL_BORDER = "dim" +ALIGN_COMMANDS_PANEL: Literal["left", "center", "right"] = "left" +STYLE_COMMANDS_TABLE_SHOW_LINES = False +STYLE_COMMANDS_TABLE_LEADING = 0 +STYLE_COMMANDS_TABLE_PAD_EDGE = False +STYLE_COMMANDS_TABLE_PADDING = (0, 1) +STYLE_COMMANDS_TABLE_BOX = "" +STYLE_COMMANDS_TABLE_ROW_STYLES = None +STYLE_COMMANDS_TABLE_BORDER_STYLE = None +STYLE_COMMANDS_TABLE_FIRST_COLUMN = "bold cyan" +STYLE_ERRORS_PANEL_BORDER = "red" +ALIGN_ERRORS_PANEL: Literal["left", "center", "right"] = "left" +STYLE_ERRORS_SUGGESTION = "dim" +STYLE_ABORTED = "red" +_TERMINAL_WIDTH = getenv("TERMINAL_WIDTH") +MAX_WIDTH = int(_TERMINAL_WIDTH) if _TERMINAL_WIDTH else None +COLOR_SYSTEM: Optional[Literal["auto", "standard", "256", "truecolor", "windows"]] = ( + "auto" # Set to None to disable colors +) +_TYPER_FORCE_DISABLE_TERMINAL = getenv("_TYPER_FORCE_DISABLE_TERMINAL") +FORCE_TERMINAL = ( + True + if getenv("GITHUB_ACTIONS") or getenv("FORCE_COLOR") or getenv("PY_COLORS") + else None +) +if _TYPER_FORCE_DISABLE_TERMINAL: + FORCE_TERMINAL = False + +# Fixed strings +DEPRECATED_STRING = _("(deprecated) ") +DEFAULT_STRING = _("[default: {}]") +ENVVAR_STRING = _("[env var: {}]") +REQUIRED_SHORT_STRING = "*" +REQUIRED_LONG_STRING = _("[required]") +RANGE_STRING = " [{}]" +ARGUMENTS_PANEL_TITLE = _("Arguments") +OPTIONS_PANEL_TITLE = _("Options") +COMMANDS_PANEL_TITLE = _("Commands") +ERRORS_PANEL_TITLE = _("Error") +ABORTED_TEXT = _("Aborted.") +RICH_HELP = _("Try [blue]'{command_path} {help_option}'[/] for help.") + +MARKUP_MODE_MARKDOWN = "markdown" +MARKUP_MODE_RICH = "rich" +_RICH_HELP_PANEL_NAME = "rich_help_panel" + +MarkupMode = Literal["markdown", "rich", None] + + +# Rich regex highlighter +class OptionHighlighter(RegexHighlighter): + """Highlights our special options.""" + + highlights = [ + r"(^|\W)(?P\-\w+)(?![a-zA-Z0-9])", + r"(^|\W)(?P