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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ their changes are listed under the release that follows them.
- `sublime.expand_variables()` is generic and returns the type of its `value` argument
instead of `Value`.

### Fixed

- `Window.new_html_sheet()` returns `HtmlSheet` instead of `Sheet`.

## 4213.0 (2026-10-25)

### Breaking
Expand Down
2 changes: 1 addition & 1 deletion stubs/sublime-stubs/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -1095,7 +1095,7 @@ class Window:
contents: str,
flags: NewFileFlags = ...,
group: int = ...,
) -> Sheet:
) -> HtmlSheet:
"""
Construct a sheet with HTML contents rendered using `minihtml`.

Expand Down
7 changes: 7 additions & 0 deletions tests/typing/check_sublime.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,13 @@ def too_large_is_not_found(error: sublime.FileTooLargeError) -> FileNotFoundErro
return error


def update_html_sheet(window: sublime.Window) -> None:
# `new_html_sheet()` always creates an `HtmlSheet`, so no narrowing is needed.
sheet = window.new_html_sheet("Preview", "<p>Loading</p>")
_ = assert_type(sheet, sublime.HtmlSheet)
sheet.set_contents("<p>Done</p>")


def rename_sheet(sheet: sublime.Sheet) -> str | None:
# Both live on `Sheet` itself, so no narrowing to `TextSheet` or `HtmlSheet`.
sheet.set_name("Scratch")
Expand Down
6 changes: 6 additions & 0 deletions tools/stub_overrides.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,12 @@
# (references/python314/sublime.py:2043-2064) names every key it may contain; see
# `WindowVariables` in `EXTRA_TYPE_ALIAS_CLASSES`.
"sublime.Window.extract_variables": "WindowVariables",
# `Sheet` in the reference (references/python314/sublime.py:1429), but it returns
# `make_sheet()` of the id `window_new_html_sheet` hands back, and `make_sheet()`
# dispatches on the id's low bits (references/python314/sublime.py:2435-2443), which
# mark an HTML sheet. So the result is always an `HtmlSheet`, and callers can use
# `HtmlSheet.set_contents()` without narrowing.
"sublime.Window.new_html_sheet": "HtmlSheet",
# Unannotated in the reference.
"sublime.Window.__eq__": "bool",
"sublime.Window.show_input_panel": "View",
Expand Down
Loading