This release is a pre-release and may not be stable for production use.
sublime-text-stubs
PEP 561 typing stubs
for the Sublime Text plugin API,
covering the sublime, sublime_plugin and sublime_types modules.
The stubs carry the API documentation as docstrings, so hovering a symbol in an editor shows the same prose as the official API reference.
Sublime Text exposes these modules only inside its own embedded interpreter, so they cannot be imported or introspected from a normal Python environment. Installing this package as a dev dependency gives type checkers and editors something to resolve them against.
Installation
uv add --dev sublime-text-stubs
# or
pip install --upgrade sublime-text-stubs
The package requires Python 3.13 or newer to install, and your type checker has to target Python 3.13 or newer. Python 3.14 matches the plugin host.
Versioning
Versions follow the scheme ${st_build_version}.${patch}:
| Version | Sublime Text build | Embedded Python |
|---|---|---|
4213.* |
4213 (stable) | 3.14 |
4200.* |
4200 (stable) | 3.8 |
The first segment is the Sublime Text build the stubs describe,
and the second is the patch level within that build.
This is deliberately not semantic versioning.
Releases up to 1.4200.1 and the pre-release 1.4213.0b1
were numbered 1.${st_build_version}.${patch}.
Pin the build you target:
sublime-text-stubs = "==4213.*"
Sublime Text also ships a disabled, deprecated Python 3.3 plugin host. This package does not target it.
Notes for plugin authors
-
Commands do not declare
run. Sublime Text invokes it with command-specific keyword arguments, so the stubs leave the signature to your subclass. Writedef run(self, **kwargs), ordef run(self, edit, **kwargs)for aTextCommand. -
is_enabled,is_visible,is_checkedanddescriptionreceive their command arguments the same dynamic way, but are declared without parameters.def is_enabled(self),def is_enabled(self, my_arg="")anddef is_enabled(self, **kwargs)all type-check. A required parameter is rejected, and correctly so: such an override also raisesTypeErrorat runtime when the command is invoked without that argument. -
TextChangeListener.bufferissublime.Buffer, neverNone. -
ValueLikeis what you pass in,Valueis what you get back. Parameters a plugin hands a value to are annotatedValueLike, which accepts arbitrary sequences and mappings, except where a specific shape is required:Window.set_project_data()takes a mapping, andSettings.update()takes a mapping or an iterable of key/value pairs. Alist[str]variable can be passed directly even though the invariantlist[Value]would reject it:tags: list[str] = ["fix", "feature"] settings.set("tags", tags) sublime.encode_value(tags)
Two things it does not model. A
collections.abc.Mappingthat is not adicttype-checks asValueLike, but is rejected at runtime everywhere exceptSettings.update, which genuinely accepts any mapping. And a value that makes the round trip through Sublime Text comes back as a plainlistordict, not as the type that was passed;bytesin particular is accepted and arrives back aslist[int].sublime.Regionis rejected by both the checkers and the runtime.A
TypedDictis only aValueLikewhen it is declared withclosed=True(PEP 728), because an open one may carry further keys of any type. This applies to the type parameter of the input handlers as well.typing.TypedDictacceptsclosedonly from Python 3.15 on, so importTypedDictfromtyping_extensionsinstead. Define the class inside theif TYPE_CHECKING:block unlesstyping_extensionsis available at runtime; its values are plaindictliterals either way:if TYPE_CHECKING: from typing_extensions import TypedDict class Entry(TypedDict, closed=True): name: str tags: list[str] def store_entry(settings: sublime.Settings, entry: Entry) -> None: settings.set("entry", entry)
pyright, basedpyright and ty accept this. mypy, as of version 2.4.0, does not implement PEP 728 and rejects every
TypedDictas aValueLike. -
The input handlers are generic.
ListInputHandlerandsublime.ListInputItemtake a type parameter for the value the selected row passes to the command, and that value type is whatlist_items(),description(),preview(),validate()andconfirm()traffic in. You may parameterize on anything aValueLikeallows, soListInputHandler[list[str]]type-checks, while a bare annotation resolves toValue, which is what the runtime actually delivers.TextInputHandleris aCommandInputHandler[str]. A bareCommandInputHandler, as in the return types ofCommand.input()andnext_input(), still accepts every kind of handler, sosublime_plugin.CommandInputHandler | Nonekeeps working unchanged. The real classes cannot be subscripted at runtime, so parameterize a base class through anif TYPE_CHECKING:alias:if TYPE_CHECKING: _StrListInputHandler = sublime_plugin.ListInputHandler[str] else: _StrListInputHandler = sublime_plugin.ListInputHandler class NameInputHandler(_StrListInputHandler): ...
-
Several
sublime_typesnames exist only in these stubs, not in the real module at runtime, so each must be imported inside anif TYPE_CHECKING:block:ModifierKeys, the type of themodifier_keysentry of anEvent.UIInfoand its partsUIInfoSystem,UIInfoTheme,UIInfoColorSchemeandUIInfoPalette, describing the return value ofsublime.ui_info().ScopeStyle, the return value ofView.style_for_scope().MacroStep, the entries of the listsublime.get_macro()returns.WindowLayout, used byWindow.layout(),Window.get_layout()andWindow.set_layout().WindowVariables, the return value ofWindow.extract_variables().FontOptions, the default and callback argument types ofchoose_font_dialog().ValueLike, the covariant companion toValue, accepted wherever a plugin passes a value into Sublime Text.CommandArgsLike, the same widening applied to commandargs, mirroringCommandArgs.
The stubs are not validated against the running editor, so divergences from the actual runtime API are possible. Please report any you find.
Contributing
See CONTRIBUTING.md for the project structure, how the stubs are generated and validated, and how to correct them.
License
MIT. See LICENSE. The stubs are derived from the API sources shipped with Sublime Text, (c) Sublime HQ Pty Ltd, and used with permission under the same license.
Metadata
Release files for sublime-text-stubs 4213.0b1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| sublime_text_stubs-4213.0b1.tar.gz | 81.3 kB | With provenance | Details for sublime_text_stubs-4213.0b1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| sublime_text_stubs-4213.0b1-py3-none-any.whl | Python 3 | none | any | Details for sublime_text_stubs-4213.0b1-py3-none-any.whl |
Total release size: 119.1 kB
Release files / sublime_text_stubs-4213.0b1.tar.gz
| Download URL | sublime_text_stubs-4213.0b1.tar.gz |
|---|---|
| Size | 81.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
53648666df6c352beec8a7ce7febe708ff165f3f4ff9c21b56eb31d339cd6dc5
|
|
BLAKE2b-256 checksum How to use checksums |
c68c929663a3ce64bad29e6aaf8c769db66213601e8fae3d32fe56da84e65297
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.
Transparency logRelease files / sublime_text_stubs-4213.0b1-py3-none-any.whl
| Download URL | sublime_text_stubs-4213.0b1-py3-none-any.whl |
|---|---|
| Size | 37.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
634d94eb35b78c40e001707dde3bbd7be339e69eb85afedb7ded05775fdb250a
|
|
BLAKE2b-256 checksum How to use checksums |
b80287a9992af5ec1b21a41ae71a3a769e3d3eca3c8eccca27a7467cd2605018
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.
Transparency logSecurity for sublime-text-stubs 4213.0b1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for sublime_text_stubs-4213.0b1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 17, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.