From a88f9dc96ea5b9b307c91fc2d9bc704094d40c06 Mon Sep 17 00:00:00 2001 From: remimd Date: Wed, 28 Feb 2024 19:16:49 +0100 Subject: [PATCH] =?UTF-8?q?remove:=20=F0=9F=94=A5=20Typer=20integration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- documentation/integrations.md | 20 ------------------ injection/integrations/typer.py | 15 ------------- poetry.lock | 35 +++++++------------------------ pyproject.toml | 3 +-- tests/integrations/test_typer.py | 36 -------------------------------- 5 files changed, 8 insertions(+), 101 deletions(-) delete mode 100644 injection/integrations/typer.py delete mode 100644 tests/integrations/test_typer.py diff --git a/documentation/integrations.md b/documentation/integrations.md index af7de26..57a597e 100644 --- a/documentation/integrations.md +++ b/documentation/integrations.md @@ -30,23 +30,3 @@ app = Application( services=InjectionServices(custom_module), ) ``` - -## [Typer](https://github.com/tiangolo/typer) - -Example: - -```python -from typing import Annotated - -from injection import inject -from injection.integrations.typer import ignore -from typer import Typer - -app = Typer() - - -@app.command() -@inject(force=True) -def my_command(dependency: Annotated[Dependency, ignore()]): - """ command implementation """ -``` diff --git a/injection/integrations/typer.py b/injection/integrations/typer.py deleted file mode 100644 index 8aad448..0000000 --- a/injection/integrations/typer.py +++ /dev/null @@ -1,15 +0,0 @@ -from typer import Option - -__all__ = ("ignore",) - - -def ignore(): - """ - Typer option for the CLI to ignore this option and replace it with `None`. - """ - - return Option( - default_factory=str, - parser=lambda _: None, - hidden=True, - ) diff --git a/poetry.lock b/poetry.lock index ce07a91..b53009b 100644 --- a/poetry.lock +++ b/poetry.lock @@ -601,13 +601,13 @@ files = [ [[package]] name = "pydantic" -version = "2.6.2" +version = "2.6.3" description = "Data validation using Python type hints" optional = false python-versions = ">=3.8" files = [ - {file = "pydantic-2.6.2-py3-none-any.whl", hash = "sha256:37a5432e54b12fecaa1049c5195f3d860a10e01bdfd24f1840ef14bd0d3aeab3"}, - {file = "pydantic-2.6.2.tar.gz", hash = "sha256:a09be1c3d28f3abe37f8a78af58284b236a92ce520105ddc91a6d29ea1176ba7"}, + {file = "pydantic-2.6.3-py3-none-any.whl", hash = "sha256:72c6034df47f46ccdf81869fddb81aade68056003900a8724a4f160700016a2a"}, + {file = "pydantic-2.6.3.tar.gz", hash = "sha256:e07805c4c7f5c6826e33a1d4c9d47950d7eaf34868e2690f8594d2e30241f11f"}, ] [package.dependencies] @@ -885,39 +885,18 @@ files = [ {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, ] -[[package]] -name = "typer" -version = "0.9.0" -description = "Typer, build great CLIs. Easy to code. Based on Python type hints." -optional = false -python-versions = ">=3.6" -files = [ - {file = "typer-0.9.0-py3-none-any.whl", hash = "sha256:5d96d986a21493606a358cae4461bd8cdf83cbf33a5aa950ae629ca3b51467ee"}, - {file = "typer-0.9.0.tar.gz", hash = "sha256:50922fd79aea2f4751a8e0408ff10d2662bd0c8bbfa84755a699f3bada2978b2"}, -] - -[package.dependencies] -click = ">=7.1.1,<9.0.0" -typing-extensions = ">=3.7.4.3" - -[package.extras] -all = ["colorama (>=0.4.3,<0.5.0)", "rich (>=10.11.0,<14.0.0)", "shellingham (>=1.3.0,<2.0.0)"] -dev = ["autoflake (>=1.3.1,<2.0.0)", "flake8 (>=3.8.3,<4.0.0)", "pre-commit (>=2.17.0,<3.0.0)"] -doc = ["cairosvg (>=2.5.2,<3.0.0)", "mdx-include (>=1.4.1,<2.0.0)", "mkdocs (>=1.1.2,<2.0.0)", "mkdocs-material (>=8.1.4,<9.0.0)", "pillow (>=9.3.0,<10.0.0)"] -test = ["black (>=22.3.0,<23.0.0)", "coverage (>=6.2,<7.0)", "isort (>=5.0.6,<6.0.0)", "mypy (==0.910)", "pytest (>=4.4.0,<8.0.0)", "pytest-cov (>=2.10.0,<5.0.0)", "pytest-sugar (>=0.9.4,<0.10.0)", "pytest-xdist (>=1.32.0,<4.0.0)", "rich (>=10.11.0,<14.0.0)", "shellingham (>=1.3.0,<2.0.0)"] - [[package]] name = "typing-extensions" -version = "4.9.0" +version = "4.10.0" description = "Backported and Experimental Type Hints for Python 3.8+" optional = false python-versions = ">=3.8" files = [ - {file = "typing_extensions-4.9.0-py3-none-any.whl", hash = "sha256:af72aea155e91adfc61c3ae9e0e342dbc0cba726d6cba4b6c72c1f34e47291cd"}, - {file = "typing_extensions-4.9.0.tar.gz", hash = "sha256:23478f88c37f27d76ac8aee6c905017a143b0b1b886c3c9f66bc2fd94f9f5783"}, + {file = "typing_extensions-4.10.0-py3-none-any.whl", hash = "sha256:69b1a937c3a517342112fb4c6df7e72fc39a38e7891a5730ed4985b5214b5475"}, + {file = "typing_extensions-4.10.0.tar.gz", hash = "sha256:b0abd7c89e8fb96f98db18d86106ff1d90ab692004eb746cf6eda2682f91b3cb"}, ] [metadata] lock-version = "2.0" python-versions = ">=3.10, <4" -content-hash = "59664d2d3e99b8ad2a971e999cec7786407d8c2ef16263f355b76e6da3f45a05" +content-hash = "130d63f34d187817f8d7ce4a0d4c2ef81563a4f570ade2fc65037075d51ec406" diff --git a/pyproject.toml b/pyproject.toml index 9fed6e7..c911982 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,11 +17,10 @@ black = "*" blacksheep = "^2.0.7" flake8 = "*" isort = "*" -pydantic = "^2.6.2" +pydantic = "^2.6.3" pytest = "*" pytest-asyncio = "*" pytest-cov = "*" -typer = "^0.9.0" [build-system] requires = ["poetry-core"] diff --git a/tests/integrations/test_typer.py b/tests/integrations/test_typer.py deleted file mode 100644 index 8f7cf51..0000000 --- a/tests/integrations/test_typer.py +++ /dev/null @@ -1,36 +0,0 @@ -from typing import Annotated - -import pytest -from typer import Typer -from typer.testing import CliRunner - -from injection import inject, singleton -from injection.integrations.typer import ignore - - -@singleton -class Dependency: - pass - - -app = Typer() - - -@app.command() -@inject(force=True) -def integration(dependency: Annotated[Dependency, ignore()]): - assert isinstance(dependency, Dependency) - - -class TestInjected: - @pytest.fixture(scope="class") - def runner(self) -> CliRunner: - return CliRunner() - - def test_injected_with_success(self, runner): - result = runner.invoke(app) - assert result.exit_code == 0 - - def test_injected_with_custom_input(self, runner): - result = runner.invoke(app, ["--dependency", "input"]) - assert result.exit_code == 0