From 1bc01980640526b3996a51bd953a79ddec8a3627 Mon Sep 17 00:00:00 2001 From: Brian Kohan Date: Fri, 16 Aug 2024 21:47:01 -0700 Subject: [PATCH] fix #66 --- django_typer/__init__.py | 2 +- django_typer/patch.py | 30 ------------------------------ doc/source/changelog.rst | 5 +++++ pyproject.toml | 4 ++-- 4 files changed, 8 insertions(+), 33 deletions(-) diff --git a/django_typer/__init__.py b/django_typer/__init__.py index 5dee56cb..087a3290 100644 --- a/django_typer/__init__.py +++ b/django_typer/__init__.py @@ -47,7 +47,7 @@ model_parser_completer, # noqa: F401 ) -VERSION = (2, 2, 0) +VERSION = (2, 2, 1) __title__ = "Django Typer" __version__ = ".".join(str(i) for i in VERSION) diff --git a/django_typer/patch.py b/django_typer/patch.py index a5a9a521..dd9b9eec 100644 --- a/django_typer/patch.py +++ b/django_typer/patch.py @@ -127,33 +127,3 @@ def get_console(stderr: bool = False) -> Console: strip_ansi = _compat.strip_ansi _compat.strip_ansi = lambda value: strip_ansi(str(value)) - - -from typer import __version__ as typer_version # noqa: E402 - -if (0, 4, 0) <= tuple(int(v) for v in typer_version.split(".")) < (0, 13, 0): - from typer import main as typer_main - from typer.models import ParamMeta - - upstream_get_click_param = typer_main.get_click_param - - def patched_get_click_param( - param: ParamMeta, - ) -> t.Tuple[t.Union[click.Argument, click.Option], t.Any]: - """ - Patch this bug: https://github.com/tiangolo/typer/issues/334 - - This gets shell completions working for arguments. As of 0.9.0 I have - an open PR to fix this problem upstream, but it is enough of an issue - that its worth patching here until it gets merged. - """ - click_param = upstream_get_click_param(param) - if isinstance(click_param[0], click.Argument) and getattr( - param.default, "shell_complete", None - ): - click_param[0]._custom_shell_complete = param.default.shell_complete - return click_param - - typer_main.get_click_param = patched_get_click_param -else: # pragma: no cover - pass diff --git a/doc/source/changelog.rst b/doc/source/changelog.rst index 996664e8..cf98f3af 100644 --- a/doc/source/changelog.rst +++ b/doc/source/changelog.rst @@ -2,6 +2,11 @@ Change Log ========== +v2.2.1 (17-AUG-2024) +==================== + +* Fixed `Remove shell_complete monkey patch when upstream PR is merged. `_ + v2.2.0 (26-JUL-2024) ==================== diff --git a/pyproject.toml b/pyproject.toml index 46cac51a..49d609f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "django-typer" -version = "2.2.0" +version = "2.2.1" description = "Use Typer to define the CLI for your Django management commands." authors = ["Brian Kohan "] license = "MIT" @@ -48,7 +48,7 @@ click = "^8.1.0" # typer's release history is full of breaking changes for minor versions # given the reliance on some of its private internals we peg the typer # version very strictly to bug fix releases for specific minor lines. -typer-slim = ">=0.12.0,<0.13.0" +typer-slim = ">=0.12.4,<0.13.0" # this should track typer's rich dependency, so long as our console # patches still work - so be sure to test on the low end of the range