Skip to content

Commit 89ce2d1

Browse files
committed
Fix type annotations of show_selection_panel
1 parent ce92a96 commit 89ce2d1

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

sublime_lib/show_selection_panel.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from __future__ import annotations
22
from collections.abc import Sequence
3-
from typing import Callable, TypeVar
3+
from typing import Callable, Iterable, TypeVar
44

55
import sublime
66

@@ -19,7 +19,7 @@ def show_selection_panel(
1919
window: sublime.Window,
2020
items: Sequence[_ItemType],
2121
*,
22-
flags: QuickPanelOption = QuickPanelOption.NONE,
22+
flags: QuickPanelOption | Iterable[QuickPanelOption] | str = QuickPanelOption.NONE,
2323
labels: Sequence[object] | Callable[[_ItemType], object] | None = None,
2424
selected: NamedValue | _ItemType = NO_SELECTION,
2525
on_select: Callable[[_ItemType], None] | None = None,
@@ -113,16 +113,16 @@ def on_done(index: int) -> None:
113113
else:
114114
selected_index = items.index(selected)
115115

116-
on_highlight_callback: Callable[[int], None] = \
117-
lambda index: on_highlight(items[index]) if on_highlight else None
116+
def on_highlight_callback(index: int) -> None:
117+
return on_highlight(items[index]) if on_highlight else None
118118

119-
if isinstance(flags, str):
120-
flags = QuickPanelOption(flags)
119+
if isinstance(flags, QuickPanelOption):
120+
pass
121+
elif isinstance(flags, str):
122+
flags = QuickPanelOption[flags]
121123
else:
122124
flags = QuickPanelOption(*flags)
123125

124-
# The signature in the API docs is wrong.
125-
# See https://github.com/SublimeTextIssues/Core/issues/2290
126126
window.show_quick_panel(
127127
items=label_strings,
128128
on_select=on_done,

0 commit comments

Comments
 (0)