Language server | ty (original) (raw)

You can generally expect ty to be a fully-featured language server for Python. This page describes some of the key features provided by ty's IDE integration and includes a reference table of supported LSP features at the end. See the editor integration guide for instructions on how to set up ty with your editor.

Diagnostics

Example of an inline diagnostic with code-span annotations

ty reports type errors and other diagnostics directly in your editor. Diagnostics are updated as you type. You can use thediagnosticMode setting to control if you want to see diagnostics for open files only, or for your entire workspace.

Info

ty supports both the "pull" and "push" diagnostic models. Most modern editors will use the "pull" model for better performance, where diagnostics are fetched on demand rather than pushed after every change.

Code navigation

"Find references" shows usages across the entire workspace

ty powers several language server features that allow you to navigate a Python codebase:

Code completions

Code completion example

Accepting this completion will automatically add a subprocess import at the top of the file.

ty provides intelligent code completions as you type, offering suggestions for variables, functions, classes, and modules that are in scope. For symbols that are not yet imported, ty suggests auto-import actions to add the necessary import statements.

Code actions and refactorings

Code action example

ty offers to remove the unused suppression comment

ty offers quick fixes and other code actions to help you resolve issues:

Contextual information

Inlay hints

Gray inlay hints and on-hover information (signature, docstring)

ty surfaces useful contextual information as you code:

Code folding

ty provides Python specific code folding ranges to LSP clients upon request. This includes tagging docstrings as comments, which supports editor actions like "fold all comment blocks."

Notebook support

ty supports Jupyter notebooks (.ipynb files) with language server features. Each cell is analyzed in context, with diagnostics, completions, and other features working across cells.

Fine-grained incrementality

ty's architecture is designed for low-latency updates of diagnostics and other language server features. When you make a change in your editor, ty incrementally updates only the affected parts of the codebase, rather than re-analyzing everything from scratch. This happens at a fine-grained level, down to individual definitions. This incrementality means that you get instant feedback as you type, i.e., within a few milliseconds, even on large projects.

Info

Fine-grained dependencies also allow ty to skip large parts of 3rd-party dependencies when they are not relevant to your codebase.

Feature reference

Feature Status Notes
callHierarchy/* ✅ Supported
notebookDocument/* ✅ Supported
textDocument/codeAction ✅ Supported Quick fixes
textDocument/codeLens ❌ Not supported
textDocument/completion ✅ Supported
textDocument/declaration ✅ Supported
textDocument/definition ✅ Supported
textDocument/diagnostic ✅ Supported
textDocument/documentColor ❌ Not supported
textDocument/documentHighlight ✅ Supported
textDocument/documentLink ❌ Not supported
textDocument/documentSymbol ✅ Supported
textDocument/foldingRange ✅ Supported
textDocument/formatting Use Ruff for formatting
textDocument/hover ✅ Supported
textDocument/implementation ❌ Not supported #3514
textDocument/inlayHint ✅ Supported
textDocument/onTypeFormatting Ruff #16829
textDocument/prepareRename ✅ Supported
textDocument/rangeFormatting Use Ruff for formatting
textDocument/references ✅ Supported
textDocument/rename ✅ Supported
textDocument/selectionRange ✅ Supported
textDocument/semanticTokens ✅ Supported
textDocument/signatureHelp ✅ Supported
textDocument/typeDefinition ✅ Supported
typeHierarchy/* ✅ Supported
workspace/diagnostic ✅ Supported
workspace/symbol ✅ Supported
workspace/willRenameFiles ❌ Not supported #1560