Skip to content

Commit

Permalink
fix #43
Browse files Browse the repository at this point in the history
  • Loading branch information
bckohan committed Mar 15, 2024
1 parent 6f53751 commit 96a2668
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 11 deletions.
15 changes: 9 additions & 6 deletions django_typer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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

Expand Down
4 changes: 1 addition & 3 deletions django_typer/tests/test_app/management/commands/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
1 change: 0 additions & 1 deletion django_typer/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
6 changes: 6 additions & 0 deletions doc/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
Change Log
==========

v1.0.6
======

* Fixed `prompt options on groups still prompt when given as named parameters on call_command <https://github.com/bckohan/django-typer/issues/43>`_


v1.0.5
======

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <bckohan@gmail.com>"]
license = "MIT"
Expand Down

0 comments on commit 96a2668

Please sign in to comment.