Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ their changes are listed under the release that follows them.
- `Window.new_html_sheet()` returns `HtmlSheet` instead of `Sheet`.
- The docstring of `View.command_history()` says that `("", None, 0)` is returned
when the undo/redo history doesn't extend far enough, instead of `(None, None, 0)`.
- `QuickPanelItem()` and `ListInputItem()` accept a `details` tuple of any length,
not only a tuple of exactly one string.
Their `details` attributes are typed the same way.

## 4213.0 (2026-10-25)

Expand Down
8 changes: 4 additions & 4 deletions stubs/sublime-stubs/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -3238,7 +3238,7 @@ class QuickPanelItem:
"""
trigger: str
""" Text to match against user's input. """
details: str | list[str] | tuple[str]
details: str | list[str] | tuple[str, ...]
""" A `minihtml` string or list of strings displayed below the trigger. """
annotation: str
""" Hint to draw to the right-hand side of the row. """
Expand All @@ -3248,7 +3248,7 @@ class QuickPanelItem:
def __init__(
self,
trigger: str,
details: str | list[str] | tuple[str] = ...,
details: str | list[str] | tuple[str, ...] = ...,
annotation: str = ...,
kind: Kind = ...,
) -> None:
Expand All @@ -3264,7 +3264,7 @@ class ListInputItem[T: ValueLike = Value]:
""" Text to match against the user's input. """
value: T
""" A `Value` passed to the command if the row is selected. """
details: str | list[str] | tuple[str]
details: str | list[str] | tuple[str, ...]
""" A `minihtml` string or list of strings displayed below the trigger. """
annotation: str
""" Hint to draw to the right-hand side of the row. """
Expand All @@ -3275,7 +3275,7 @@ class ListInputItem[T: ValueLike = Value]:
self,
text: str,
value: T,
details: str | list[str] | tuple[str] = ...,
details: str | list[str] | tuple[str, ...] = ...,
annotation: str = ...,
kind: Kind = ...,
) -> None:
Expand Down
9 changes: 9 additions & 0 deletions tests/typing/check_sublime.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,15 @@ def quick_panel(window: sublime.Window) -> None:
window.show_quick_panel(items, lambda _index: None, placeholder="Pick a folder")


def multi_line_details(path: str) -> list[sublime.QuickPanelItem]:
# A tuple of any length is accepted, not only a tuple of exactly one string.
details = (path, "second line")
_ = sublime.ListInputItem("label", path, details=details)
item = sublime.QuickPanelItem(path, details=details)
_ = assert_type(item.details, str | list[str] | tuple[str, ...])
return [item]


def list_input_item_value() -> int:
# `assert_type` rather than an annotated assignment: `Any` satisfies the latter,
# so it would not catch a regression to the pre-generic stubs.
Expand Down
9 changes: 9 additions & 0 deletions tools/stub_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,12 @@
# (sublime.py:4122-4126), which duck-types sequences; see `ValueLike`.
"sublime.CompletionList.__init__.completions": "Sequence[CompletionValue]",
"sublime.CompletionList.set_completions.completions": "Sequence[CompletionValue]",
# `str | list[str] | tuple[str]` in the reference (references/python314/sublime.py:4338
# and :4372), but `tuple[str]` is a tuple of exactly one string, so a tuple with more
# lines is rejected. The docstrings (sublime.py:4344-4346 and :4380-4382) call it a
# "list of strings", so any number of strings is meant.
"sublime.QuickPanelItem.__init__.details": "str | list[str] | tuple[str, ...]",
"sublime.ListInputItem.__init__.details": "str | list[str] | tuple[str, ...]",
# `Any` in the reference (references/python314/sublime.py:4371); the class is generic
# over it instead, so the constructor argument is what fixes the item's value type.
"sublime.ListInputItem.__init__.value": "T",
Expand Down Expand Up @@ -283,6 +289,9 @@
# docstring one line below calls it "A `Value` passed to the command"; see
# `TYPE_PARAMS`.
"sublime.ListInputItem.value": "T",
# Holds the `details` passed to `__init__`; see `PARAMS`.
"sublime.QuickPanelItem.details": "str | list[str] | tuple[str, ...]",
"sublime.ListInputItem.details": "str | list[str] | tuple[str, ...]",
# The reference initializes it as `self.buffer: sublime.Buffer | None = None`
# (references/python314/sublime_plugin.py:2259). Both hand-written third-party stub
# sets (sublimelsp/LSP, SublimeText/sublime_lib) spell it `Buffer | None` too, but
Expand Down
Loading