diff --git a/django_typer/__init__.py b/django_typer/__init__.py index 621cf00..3faf417 100644 --- a/django_typer/__init__.py +++ b/django_typer/__init__.py @@ -67,7 +67,7 @@ import inspect import sys import typing as t -from copy import deepcopy +from copy import copy, deepcopy from importlib import import_module from pathlib import Path from types import MethodType, SimpleNamespace @@ -114,7 +114,7 @@ from typing import ParamSpec -VERSION = (1, 0, 5) +VERSION = (1, 0, 6) __title__ = "Django Typer" __version__ = ".".join(str(i) for i in VERSION) @@ -415,11 +415,14 @@ def get_params(self, ctx: click.Context) -> t.List[click.Parameter]: modified = [] params = super().get_params(ctx) for param in params: - if getattr(param, "prompt_required", None) and getattr( - ctx, "supplied_params", {} - ).get(param.name, None): - param = deepcopy(param) + if ( + getattr(param, "prompt", None) + and getattr(param, "prompt_required", False) + and getattr(ctx, "supplied_params", {}).get(param.name, None) + ): + param = copy(param) setattr(param, "prompt_required", False) + param.required = False modified.append(param) return modified diff --git a/django_typer/tests/test_app/management/commands/prompt.py b/django_typer/tests/test_app/management/commands/prompt.py index c5a7028..ad76bc4 100644 --- a/django_typer/tests/test_app/management/commands/prompt.py +++ b/django_typer/tests/test_app/management/commands/prompt.py @@ -60,8 +60,6 @@ def group1( def cmd4( self, username: str, - password: Annotated[ - t.Optional[str], Option("-p", hide_input=True, prompt=True) - ] = None, + password: Annotated[str, Option("-p", hide_input=True, prompt=True)], ): return f"{self.flag} {username} {password}" diff --git a/django_typer/tests/tests.py b/django_typer/tests/tests.py index 02acc64..7b9fddc 100644 --- a/django_typer/tests/tests.py +++ b/django_typer/tests/tests.py @@ -2853,7 +2853,6 @@ def test_call_with_option_prompt(self): "test_flag bckohan test_password4", ) - @pytest.mark.skip() def test_call_group_with_prompt_value(self): """ This is a bug! diff --git a/doc/source/changelog.rst b/doc/source/changelog.rst index c159d33..6a8dd8d 100644 --- a/doc/source/changelog.rst +++ b/doc/source/changelog.rst @@ -2,6 +2,12 @@ Change Log ========== +v1.0.6 +====== + +* Fixed `prompt options on groups still prompt when given as named parameters on call_command `_ + + v1.0.5 ====== diff --git a/pyproject.toml b/pyproject.toml index d295901..0d9b98f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "django-typer" -version = "1.0.5" +version = "1.0.6" description = "Use Typer to define the CLI for your Django management commands." authors = ["Brian Kohan "] license = "MIT"