Skip to content

Commit

Permalink
run isort and black
Browse files Browse the repository at this point in the history
  • Loading branch information
bckohan committed Jan 24, 2024
1 parent a543da8 commit b010430
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
9 changes: 7 additions & 2 deletions django_typer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"command",
"group",
"get_command",
"COMPLETE_VAR"
"COMPLETE_VAR",
]

"""
Expand Down Expand Up @@ -91,6 +91,7 @@

COMPLETE_VAR = "_COMPLETE_INSTRUCTION"


def traceback_config():
cfg = getattr(settings, "DT_RICH_TRACEBACK_CONFIG", {"show_locals": True})
if cfg:
Expand Down Expand Up @@ -244,7 +245,11 @@ def shell_complete(self, ctx: Context, incomplete: str) -> t.List[CompletionItem
for the command if there are any available.
"""
completions = super().shell_complete(ctx, incomplete)
if not completions and (incomplete.isspace() or not incomplete) and getattr(ctx, '_opt_prefixes', None):
if (
not completions
and (incomplete.isspace() or not incomplete)
and getattr(ctx, "_opt_prefixes", None)
):
completions = super().shell_complete(ctx, min(ctx._opt_prefixes))
return completions

Expand Down
8 changes: 5 additions & 3 deletions django_typer/management/commands/shellcompletion.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
from typer import Argument, Option, echo
from typer.completion import Shells, completion_init

from django_typer import TyperCommand, command, get_command, COMPLETE_VAR
from django_typer import COMPLETE_VAR, TyperCommand, command, get_command

try:
from shellingham import detect_shell
Expand Down Expand Up @@ -387,17 +387,19 @@ def get_completion_args(self) -> t.Tuple[t.List[str], str]:
pass
return (
cwords[:-1],
cwords[-1] if len(cwords) and not command[-1].isspace() else ' ',
cwords[-1] if len(cwords) and not command[-1].isspace() else " ",
)

CompletionClass.get_completion_args = get_completion_args

_get_completions = CompletionClass.get_completions

def get_completions(self, args, incomplete):
"""
need to remove the django command name from the arg completions
"""
return _get_completions(self, args[1:], incomplete)

CompletionClass.get_completions = get_completions

add_completion_class(self.shell.value, CompletionClass)
Expand Down Expand Up @@ -427,7 +429,7 @@ def call_fallback(fb):
except Exception:
call_fallback(fallback)
return

if isinstance(cmd, TyperCommand):
cmd.typer_app(
args=args[1:],
Expand Down

0 comments on commit b010430

Please sign in to comment.