Skip to content

Commit 96a2668

Browse files
committed
fix #43
1 parent 6f53751 commit 96a2668

File tree

5 files changed

+17
-11
lines changed

5 files changed

+17
-11
lines changed

django_typer/__init__.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@
6767
import inspect
6868
import sys
6969
import typing as t
70-
from copy import deepcopy
70+
from copy import copy, deepcopy
7171
from importlib import import_module
7272
from pathlib import Path
7373
from types import MethodType, SimpleNamespace
@@ -114,7 +114,7 @@
114114
from typing import ParamSpec
115115

116116

117-
VERSION = (1, 0, 5)
117+
VERSION = (1, 0, 6)
118118

119119
__title__ = "Django Typer"
120120
__version__ = ".".join(str(i) for i in VERSION)
@@ -415,11 +415,14 @@ def get_params(self, ctx: click.Context) -> t.List[click.Parameter]:
415415
modified = []
416416
params = super().get_params(ctx)
417417
for param in params:
418-
if getattr(param, "prompt_required", None) and getattr(
419-
ctx, "supplied_params", {}
420-
).get(param.name, None):
421-
param = deepcopy(param)
418+
if (
419+
getattr(param, "prompt", None)
420+
and getattr(param, "prompt_required", False)
421+
and getattr(ctx, "supplied_params", {}).get(param.name, None)
422+
):
423+
param = copy(param)
422424
setattr(param, "prompt_required", False)
425+
param.required = False
423426
modified.append(param)
424427
return modified
425428

django_typer/tests/test_app/management/commands/prompt.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,6 @@ def group1(
6060
def cmd4(
6161
self,
6262
username: str,
63-
password: Annotated[
64-
t.Optional[str], Option("-p", hide_input=True, prompt=True)
65-
] = None,
63+
password: Annotated[str, Option("-p", hide_input=True, prompt=True)],
6664
):
6765
return f"{self.flag} {username} {password}"

django_typer/tests/tests.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2853,7 +2853,6 @@ def test_call_with_option_prompt(self):
28532853
"test_flag bckohan test_password4",
28542854
)
28552855

2856-
@pytest.mark.skip()
28572856
def test_call_group_with_prompt_value(self):
28582857
"""
28592858
This is a bug!

doc/source/changelog.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
Change Log
33
==========
44

5+
v1.0.6
6+
======
7+
8+
* Fixed `prompt options on groups still prompt when given as named parameters on call_command <https://github.com/bckohan/django-typer/issues/43>`_
9+
10+
511
v1.0.5
612
======
713

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "django-typer"
3-
version = "1.0.5"
3+
version = "1.0.6"
44
description = "Use Typer to define the CLI for your Django management commands."
55
authors = ["Brian Kohan <[email protected]>"]
66
license = "MIT"

0 commit comments

Comments
 (0)