Skip to content

Commit a82472a

Browse files
fixing mypy issues
1 parent 9465f96 commit a82472a

File tree

1 file changed

+35
-25
lines changed

1 file changed

+35
-25
lines changed

typer/rich_utils.py

Lines changed: 35 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from collections import defaultdict
77
from gettext import gettext as _
88
from os import getenv
9-
from typing import Any, Callable, DefaultDict, Dict, Iterable, List, Optional, Union
9+
from typing import Any, DefaultDict, Dict, Iterable, List, Optional, Protocol, Union
1010

1111
import click
1212
from rich import box
@@ -549,30 +549,40 @@ def _print_commands_panel(
549549
)
550550

551551

552-
# Define acceptable function to pass as print_options_panel_func
553-
PrintOptionsPanelFunc = Callable[
554-
[
555-
str,
556-
Union[List[click.Option], List[click.Argument]],
557-
click.Context,
558-
MarkupMode,
559-
Console
560-
],
561-
None
562-
]
563-
564-
565-
# Define acceptable function to pass as print_options_panel_func
566-
PrintCommandsPanelFunc = Callable[
567-
[
568-
str,
569-
List[click.Command],
570-
MarkupMode,
571-
Console,
572-
int
573-
],
574-
None
575-
]
552+
class PrintOptionsPanelFunc(Protocol):
553+
"""
554+
Define acceptable function to pass as print_options_panel_func
555+
556+
TODO: switch to using NamedArg once minimum supported python is 3.12
557+
"""
558+
559+
def __call__(
560+
self,
561+
*,
562+
name: str,
563+
params: Union[List[click.Option], List[click.Argument]],
564+
ctx: click.Context,
565+
markup_mode: MarkupMode,
566+
console: Console,
567+
) -> None: ...
568+
569+
570+
class PrintCommandsPanelFunc(Protocol):
571+
"""
572+
Define acceptable function to pass as print_options_panel_func
573+
574+
TODO: switch to using NamedArg once minimum supported python is 3.12
575+
"""
576+
577+
def __call__(
578+
self,
579+
*,
580+
name: str,
581+
commands: List[click.Command],
582+
markup_mode: MarkupMode,
583+
console: Console,
584+
cmd_len: int,
585+
) -> None: ...
576586

577587

578588
def rich_format_help(

0 commit comments

Comments
 (0)