Repository navigation
Return HtmlSheet from Window.new_html_sheet - #14
Merged
Merged
Conversation
FichteFoll
pushed a commit
that referenced
this pull request
Nov 5, 2026
`Window.new_html_sheet()` is typed to return `Sheet`, but it always returns an `HtmlSheet`. It returns `make_sheet()` of the ID that `window_new_html_sheet` hands back, and `make_sheet()` dispatches on the ID's low bits, which mark an HTML sheet. With `Sheet`, callers have to narrow before they can use `HtmlSheet.set_contents()`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Window.new_html_sheet()is typed to returnSheet, but it always returns anHtmlSheet. It returnsmake_sheet()of the ID thatwindow_new_html_sheethands back, andmake_sheet()dispatches on the ID's low bits, which mark an HTML sheet. WithSheet, callers have to narrow before they can useHtmlSheet.set_contents():The API reference also shows
→ Sheet, but it reflects the same annotation as the reference source and has no separate Returns section to say otherwise.HtmlSheetis a subclass ofSheet, so narrowing the return type doesn't break existing callers.This came up while moving LSP to this package (sublimelsp/LSP#3129). LSP's bundled stubs already return
HtmlSheet, and helper packages rely on that, so switching to this package as it is would break their type checks.The fix is a
RETURNSoverride, with the regenerated stub. The newupdate_html_sheettest intests/typing/check_sublime.pyfails onmain(expected "HtmlSheet" but received "Sheet") 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 tost-4200as well; happy to open that once this is settled.