Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

README.md

🐍 pi-python-lsp — ty and Ruff Language Server Tools for Pi

npm Pi extension License: MIT

Deprecated: use @narumitw/pi-lsp instead. This package is kept for reference under extensions/deprecated/ and is no longer part of the active workspace package set.

@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 server on demand for Python type diagnostics.
  • Runs ruff server on demand for lint diagnostics.
  • Computes or writes Ruff formatting edits.
  • Computes or writes Ruff source actions such as source.fixAll.ruff and source.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-lsp

Try without installing permanently:

pi -e npm:@narumitw/pi-python-lsp

Try this package locally from the repository root:

pi -e ./extensions/deprecated/pi-python-lsp

✅ Requirements

Install ty and/or ruff somewhere on PATH, for example:

uv tool install ty
uv tool install ruff

Or provide custom server commands:

PI_TY_LSP_COMMAND="uvx ty server" PI_RUFF_LSP_COMMAND="uvx ruff server" pi -e ./extensions/deprecated/pi-python-lsp

Optional timeout overrides:

PI_TY_LSP_TIMEOUT_MS=30000 PI_RUFF_LSP_TIMEOUT_MS=30000 pi -e ./extensions/deprecated/pi-python-lsp

🛠️ Pi tools

  • ty_lsp_diagnostics — start ty server, open Python files, and return type diagnostics.
  • ruff_lsp_diagnostics — start ruff 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 as source.fixAll.ruff or source.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-lsp

Shows 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/deprecated/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.