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 parser (tstring-html-rs, tstring-thtml-rs) 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 HTML and T-HTML template literals:
Dry-run to see what would change without modifying files:
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:
How it works with tstring-html¶
t-linter and tstring-html share the same Rust parsing and formatting backends:
- tstring-html is the runtime library —
render_html()andhtml()parse and render templates at runtime - t-linter is the developer tooling —
checkvalidates templates andformatcanonicalizes them at development time
The integration seam is:
- Backend Rust APIs accept
tstring_syntax::TemplateInput - Diagnostics use
tstring_syntax::SourceSpan - Tooling constructs
TemplateInputfrom source text and preservesraw_source - No Python runtime object is required for lint/format
- Reserved language ids:
"html"and"thtml"