From b0104309119b0712969e730aa914a94759e63688 Mon Sep 17 00:00:00 2001 From: Brian Kohan Date: Tue, 23 Jan 2024 23:13:50 -0800 Subject: [PATCH] run isort and black --- django_typer/__init__.py | 9 +++++++-- django_typer/management/commands/shellcompletion.py | 8 +++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/django_typer/__init__.py b/django_typer/__init__.py index 10b72ae..12ec673 100644 --- a/django_typer/__init__.py +++ b/django_typer/__init__.py @@ -61,7 +61,7 @@ "command", "group", "get_command", - "COMPLETE_VAR" + "COMPLETE_VAR", ] """ @@ -91,6 +91,7 @@ COMPLETE_VAR = "_COMPLETE_INSTRUCTION" + def traceback_config(): cfg = getattr(settings, "DT_RICH_TRACEBACK_CONFIG", {"show_locals": True}) if cfg: @@ -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 diff --git a/django_typer/management/commands/shellcompletion.py b/django_typer/management/commands/shellcompletion.py index fef08b1..a0f6907 100644 --- a/django_typer/management/commands/shellcompletion.py +++ b/django_typer/management/commands/shellcompletion.py @@ -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 @@ -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) @@ -427,7 +429,7 @@ def call_fallback(fb): except Exception: call_fallback(fallback) return - + if isinstance(cmd, TyperCommand): cmd.typer_app( args=args[1:],