Editor Integration (t-linter)¶
t-linter is a linter, formatter, and LSP server for Python template strings (PEP 750 t-strings). It uses the same Rust backends (tstring-json, tstring-toml, tstring-yaml) as this project for check and format operations.
Installation¶
Or with uv:
CLI usage¶
Check templates for errors¶
Validate t-string templates in your Python files:
Output format options:
t-linter check file.py --format human # default, human-readable
t-linter check file.py --format json # machine-readable JSON
t-linter check file.py --format github # GitHub Actions annotations
Use --error-on-issues to fail CI when problems are found:
Format templates¶
Canonical formatting for JSON, YAML, and TOML template literals:
Dry-run to see what would change without modifying files:
Read from stdin:
LSP server¶
Start the built-in LSP server for real-time editor diagnostics and formatting:
The LSP provides:
- Diagnostics — syntax and semantic errors reported inline as you type
- Formatting — format-on-save or format-on-demand via your editor's formatting command
VSCode integration¶
-
Install the binary:
-
Install the t-linter extension from the VSCode marketplace.
-
Recommended: set
"python.languageServer": "None"in VSCode settings to avoid conflicts with other Python language servers. -
Optionally configure
t-linter.serverPathin settings if the binary is not on yourPATH.
Other editors¶
Any editor that supports the Language Server Protocol can use t-linter lsp. Configure your editor to start t-linter lsp as the language server for Python files.
Configuration¶
Configure t-linter via pyproject.toml:
Language detection¶
t-linter identifies structured-data templates from PEP 593 Annotated
metadata on string.templatelib.Template:
from string.templatelib import Template
from typing import Annotated
payload: Annotated[Template, "json"] = t'{"name": {name}}'
config: Annotated[Template, "toml"] = t"name = {name}"
manifest: Annotated[Template, "yaml"] = t"name: {name}"
The wrapper packages export aliases for the same convention:
from json_tstring import JsonTemplate, render_data as render_json
from toml_tstring import TomlTemplate, render_data as render_toml
from yaml_tstring import YamlTemplate, render_data as render_yaml
payload: JsonTemplate = t'{"name": {name}}'
config: TomlTemplate = t"name = {name}"
manifest: YamlTemplate = t"name: {name}"
json_data = render_json(payload)
toml_data = render_toml(config)
yaml_data = render_yaml(manifest)
For this project, t-linter recognizes the metadata tags json, toml,
yaml, and yml. The aliases above use the canonical json, toml, and
yaml tags.
How it works with tstring-structured-data¶
t-linter and tstring-structured-data share the same Rust parsing and formatting backends:
- tstring-structured-data is the runtime library —
render_data()andrender_text()parse and render templates at runtime - t-linter is the developer tooling —
checkvalidates templates andformatcanonicalizes them at development time
For JSON, YAML, and TOML templates, t-linter uses:
- Tree-sitter for fast syntax highlighting (low-latency, no full parse)
- Rust backends (
tstring-json,tstring-yaml,tstring-toml) for strictcheckandformatoperations