@narumitw/pi-python-lsp
v0.1.20
Published
Pi extension that exposes ty and Ruff language-server tools for Python.
Maintainers
Readme
🐍 pi-python-lsp — ty and Ruff Language Server Tools for Pi
@narumitw/pi-python-lsp is a native Pi coding agent extension that exposes Python language-server tools from ty and Ruff.
Use it to give Pi reliable Python type diagnostics, Ruff lint diagnostics, formatting, import organization, and source fixes through Language Server Protocol (LSP) workflows.
✨ Features
- Runs
ty serveron demand for Python type diagnostics. - Runs
ruff serveron demand for lint diagnostics. - Computes or writes Ruff formatting edits.
- Computes or writes Ruff source actions such as
source.fixAll.ruffandsource.organizeImports.ruff. - Supports workspace roots, file limits, and recursive Python file discovery.
- Starts language servers only for tool calls, then shuts them down.
- Shows statusline activity only while Python LSP tools are running.
- Provides clear setup errors when ty or Ruff is missing.
📦 Install
pi install npm:@narumitw/pi-python-lspTry without installing permanently:
pi -e npm:@narumitw/pi-python-lspTry this package locally from the repository root:
pi -e ./extensions/pi-python-lsp✅ Requirements
Install ty and/or ruff somewhere on PATH, for example:
uv tool install ty
uv tool install ruffOr provide custom server commands:
PI_TY_LSP_COMMAND="uvx ty server" PI_RUFF_LSP_COMMAND="uvx ruff server" pi -e ./extensions/pi-python-lspOptional timeout overrides:
PI_TY_LSP_TIMEOUT_MS=30000 PI_RUFF_LSP_TIMEOUT_MS=30000 pi -e ./extensions/pi-python-lsp🛠️ Pi tools
ty_lsp_diagnostics— startty server, open Python files, and return type diagnostics.ruff_lsp_diagnostics— startruff server, open Python files, and return lint diagnostics.ruff_lsp_format— compute or write Ruff formatting edits for one Python file.ruff_lsp_fix— compute or write Ruff source actions such assource.fixAll.rufforsource.organizeImports.ruff.
🚀 Examples
Check a Python project with ty or Ruff diagnostics:
{
"paths": ["src", "tests"],
"limit": 100
}Format a Python file with Ruff:
{
"path": "src/app.py",
"write": true
}Organize imports with Ruff:
{
"path": "src/app.py",
"kind": "source.organizeImports.ruff",
"write": true
}If paths is omitted for diagnostics, the tool recursively discovers Python files under the workspace root, skipping common cache and virtualenv directories.
💬 Command
/python-lspShows the configured ty and Ruff LSP commands and whether each command is available on PATH.
🧠 Use cases
- Let Pi typecheck Python code with ty before completing a task.
- Ask Pi to run Ruff lint diagnostics while editing.
- Format Python files through a native Pi tool.
- Organize imports and apply safe Ruff fixes.
- Add Python quality gates to AI coding agent workflows.
🗂️ Package layout
extensions/pi-python-lsp/
├── src/
│ └── python-lsp.ts
├── README.md
├── LICENSE
├── tsconfig.json
└── package.json🔎 Keywords
Pi extension, Pi coding agent, Python LSP, ty, Ruff, Python type checking, Python linting, Python formatter, import organization, Language Server Protocol, AI coding tools.
📄 License
MIT. See LICENSE.
