Skip to content

Accept a details tuple of any length - #16

Merged
FichteFoll merged 2 commits into
SublimeText:mainfrom
rchl:fix/details-variadic-tuple
Nov 4, 2026
Merged

FichteFoll merged 2 commits into
SublimeText:mainfrom
rchl:fix/details-variadic-tuple

Conversation

@rchl

@rchl rchl commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

The details parameter and attribute of QuickPanelItem and ListInputItem are typed str | list[str] | tuple[str], as in the reference. But tuple[str] is a tuple of exactly one string, so passing details with several lines as a tuple is rejected:

sublime.QuickPanelItem(path, details=(path, "second line"))
# Argument of type "tuple[str, str]" cannot be assigned to parameter "details"
# of type "str | list[str] | tuple[str]"

The docstrings call it "a minihtml string or list of strings", so any number of strings is meant. This changes tuple[str] to tuple[str, ...] in both constructors and on both attributes.

I kept the containers the reference names (list and tuple) rather than widening to Sequence[str], as LSP's bundled stubs do, because other sequences don't work. Window.show_quick_panel() and ListInputHandler.setup_() only join the lines when isinstance(item.details, (list, tuple)) (references/python314/sublime.py:1864, sublime_plugin.py:1359, and the same lines in the python38 references). Anything else is passed on as it is. I checked this on ST 4215 (Python 3.14 host) in the UnitTesting Docker runner, with two-line details:

details QuickPanelItem in show_quick_panel() ListInputItem in setup_()
tuple accepted sent as 'first line\x1fsecond line'
list accepted sent as 'first line\x1fsecond line'
collections.UserList TypeError: String required sent unjoined as the UserList

This came up while moving LSP to this package (sublimelsp/LSP#3129).

The fix is PARAMS and ATTRIBUTES overrides, with the regenerated stub. The new multi_line_details test in tests/typing/check_sublime.py fails on main (both constructors reject a two-element tuple, and assert_type on the attribute fails) and passes with this change. The generator's --check, all four checkers, and ruff for both the stubs and the tools pass locally.

This targets main. It will need a backport to st-4200 as well; happy to open that once this is settled.

@FichteFoll
FichteFoll merged commit 29b1ec4 into SublimeText:main Nov 4, 2026
9 checks passed
FichteFoll pushed a commit that referenced this pull request Nov 5, 2026
The `details` parameter and attribute of `QuickPanelItem` and `ListInputItem` are typed `str | list[str] | tuple[str]`, as in the reference. But `tuple[str]` is a tuple of exactly one string, so passing details with several lines as a tuple is rejected.
@rchl
rchl deleted the fix/details-variadic-tuple branch November 5, 2026 06:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants