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
Versioning
Versions follow the scheme 1.${st_build_version}.${patch}:
| Version | Sublime Text build | Embedded Python |
|---|---|---|
1.4200.* |
4200 (stable) | 3.8 |
1.4206.* |
4206 (dev) | 3.14 |
The leading 1 is the schema version of this package itself,
the middle segment is the Sublime Text build the stubs describe,
and the trailing segment is the patch level within that build.
This is deliberately not semantic versioning.
Pin the build you target:
sublime-text-stubs = "==1.4200.*"
Sublime Text 4 also still ships a legacy Python 3.3 runtime. It is scheduled for removal and is not targeted by this package.
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. Every parameter a plugin hands a value to is annotatedValueLike, which accepts arbitrary sequences and mappings, so 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. -
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, soOptional[sublime_plugin.CommandInputHandler]keeps working unchanged. The real classes cannot be subscripted on the Python 3.8 plugin host, so parameterize a base class through anif TYPE_CHECKING:alias and quote subscripted annotations: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
Not yet chosen. See LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sublime_text_stubs-1.4200.0b2.tar.gz.
File metadata
- Download URL: sublime_text_stubs-1.4200.0b2.tar.gz
- Upload date:
- Size: 72.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e5742bd3eee20140c2b609f5f02544c67e445d0f09ea657c2404436b1fca5f0
|
|
| MD5 |
81dc19d718efa2cc903e54ad01172472
|
|
| BLAKE2b-256 |
f77c895f90ef23ac3bc784b88e805d4e8fc26bfe3538f1dc7b0b661bde4b79d6
|
Provenance
The following attestation bundles were made for sublime_text_stubs-1.4200.0b2.tar.gz:
Publisher:
release.yml on SublimeText/sublime-text-stubs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sublime_text_stubs-1.4200.0b2.tar.gz -
Subject digest:
1e5742bd3eee20140c2b609f5f02544c67e445d0f09ea657c2404436b1fca5f0 - Sigstore transparency entry: 2486928138
- Sigstore integration time:
-
Permalink:
SublimeText/sublime-text-stubs@925a981c4cfbe50f3e9fd46417f18172218b25a9 -
Branch / Tag:
refs/tags/v1.4200.0b2 - Owner: https://github.com/SublimeText
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@925a981c4cfbe50f3e9fd46417f18172218b25a9 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sublime_text_stubs-1.4200.0b2-py3-none-any.whl.
File metadata
- Download URL: sublime_text_stubs-1.4200.0b2-py3-none-any.whl
- Upload date:
- Size: 36.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84ab71657d716533e4e269e242b6d3c5989e843f5ffe5fc1267be9e6d868e2e3
|
|
| MD5 |
c735acc8d521225573cb6b64adc7289b
|
|
| BLAKE2b-256 |
6bec590cd176f8088128ce954d85260f02516a78a27fc93fed9c14e468b34734
|
Provenance
The following attestation bundles were made for sublime_text_stubs-1.4200.0b2-py3-none-any.whl:
Publisher:
release.yml on SublimeText/sublime-text-stubs
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sublime_text_stubs-1.4200.0b2-py3-none-any.whl -
Subject digest:
84ab71657d716533e4e269e242b6d3c5989e843f5ffe5fc1267be9e6d868e2e3 - Sigstore transparency entry: 2486928614
- Sigstore integration time:
-
Permalink:
SublimeText/sublime-text-stubs@925a981c4cfbe50f3e9fd46417f18172218b25a9 -
Branch / Tag:
refs/tags/v1.4200.0b2 - Owner: https://github.com/SublimeText
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@925a981c4cfbe50f3e9fd46417f18172218b25a9 -
Trigger Event:
push
-
Statement type: