Skip to content

Commit

Permalink
fix #66
Browse files Browse the repository at this point in the history
  • Loading branch information
bckohan committed Aug 17, 2024
1 parent b8e69bb commit 1bc0198
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 33 deletions.
2 changes: 1 addition & 1 deletion django_typer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
30 changes: 0 additions & 30 deletions django_typer/patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions doc/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Change Log
==========

v2.2.1 (17-AUG-2024)
====================

* Fixed `Remove shell_complete monkey patch when upstream PR is merged. <https://github.com/bckohan/django-typer/issues/66>`_

v2.2.0 (26-JUL-2024)
====================

Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
license = "MIT"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1bc0198

Please sign in to comment.