pyright-lsp

TotalClaw 作者 totalclaw

Python 语言服务器 (Pyright) 为 .py 和 .pyi 文件提供静态类型检查、代码智能和 LSP 诊断。在处理需要类型检查、自动完成建议、错误检测或代码导航的 Python 代码时使用。

安装 / 下载方式

TotalClaw CLI推荐
totalclaw skills install shop:totalclaw:totalclaw~bowen31337-pyright-lsp
cURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/totalclaw%3Atotalclaw~bowen31337-pyright-lsp/file -o bowen31337-pyright-lsp.md
## 概述(中文)

Python 语言服务器 (Pyright) 为 .py 和 .pyi 文件提供静态类型检查、代码智能和 LSP 诊断。在处理需要类型检查、自动完成建议、错误检测或代码导航的 Python 代码时使用。

## 原文

# Pyright LSP

Python language server integration providing static type checking and code intelligence through Microsoft's Pyright.

## Capabilities

- **Type checking**: Static analysis of Python types
- **Code intelligence**: Autocomplete, go-to-definition, find references
- **Error detection**: Real-time diagnostics for type errors and issues
- **Supported extensions**: `.py`, `.pyi`

## Installation Check

Before using, verify Pyright is installed:

```bash
which pyright || npm install -g pyright
```

Alternative installation methods:
```bash
pip install pyright
# or
pipx install pyright  # recommended for CLI tools
```

## Usage

Run type checking on Python files:

```bash
pyright path/to/file.py
```

Run on entire project:

```bash
cd project-root && pyright
```

## Configuration

Create `pyrightconfig.json` in project root for custom settings:

```json
{
  "include": ["src"],
  "exclude": ["**/node_modules", "**/__pycache__"],
  "typeCheckingMode": "basic",
  "pythonVersion": "3.10"
}
```

## Integration Pattern

When editing Python code:
1. Run pyright after significant changes
2. Address type errors before committing
3. Use diagnostics to improve code quality

## More Information

- [Pyright on npm](https://www.npmjs.com/package/pyright)
- [Pyright on PyPI](https://pypi.org/project/pyright/)
- [GitHub Repository](https://github.com/microsoft/pyright)