basedpyright静态类型检查
basedpyright-type-checking
用于 Python 的 Basedpyright 静态类型检查器。适用于搭建类型检查、配置 LSP,或比较各类类型检查器(basedpyright、pyright、mypy 等替代方案)。
- License 许可
- MIT
- 最近更新
- 2026-11-15
- Stars
- ★ 60
- Forks
- 6
01 前言 Front Matter
- name
- basedpyright-type-checking
- created
- 1765843200000
- modified
- 1778284800000
- reviewed
- 1765843200000
- description
- Basedpyright static type checker for Python. Use when setting up type checking, configuring LSP, or comparing type checkers (basedpyright, pyright, mypy alternative).
- allowed-tools
- Bash, Read, Grep, Glob
- user-invocable
- false
02 资源文件 1
- 参考文档REFERENCE.md11.1 KB
03 SKILL.md 正文
Basedpyright Type Checking
Basedpyright is a fork of Pyright with additional features and stricter defaults, designed for maximum type safety and performance.
When to Use This Skill
| Use this skill when... | Use another tool instead when... |
|---|---|
| Setting up type checking for Python | Formatting code (use ruff format) |
| Configuring strict type validation | Linting for style issues (use ruff check) |
| Comparing type checkers (basedpyright vs mypy) | Detecting unused code (use vulture/deadcode) |
| Setting up LSP for type-aware editor support | Running tests (use pytest) |
Installation
Via uv (Recommended)
# Install globally
uv tool install basedpyright
# Install as dev dependency
uv add --dev basedpyright
# Run with uv
uv run basedpyright
Via pipx
pipx install basedpyright
Basic Usage
# Check entire project
basedpyright
# Check specific files/directories
basedpyright src/ tests/
# Watch mode for development
basedpyright --watch
# Output JSON for tooling integration
basedpyright --outputjson
# Verbose diagnostics
basedpyright --verbose
Configuration
Minimal Strict Configuration (pyproject.toml)
[tool.basedpyright]
typeCheckingMode = "strict"
pythonVersion = "3.12"
include = ["src"]
exclude = ["**/__pycache__", "**/.venv"]
# Basedpyright-specific strict rules
reportUnusedCallResult = "error"
reportImplicitStringConcatenation = "error"
reportMissingSuperCall = "error"
reportUninitializedInstanceVariable = "error"
Type Checking Modes
| Mode | Description | Use Case |
|---|---|---|
off |
No type checking | Legacy code, migration start |
basic |
Basic type checking | Gradual typing adoption |
standard |
Standard strictness | Most projects (default Pyright) |
strict |
Strict type checking | Type-safe codebases |
all |
Maximum strictness | High-assurance systems |
Progressive Type Checking
# Start with basic mode
[tool.basedpyright]
typeCheckingMode = "basic"
include = ["src/new_module"] # Type check new code only
# Gradually expand
include = ["src/new_module", "src/api"]
# Eventually enable strict mode
typeCheckingMode = "strict"
include = ["src"]
Choosing a Type Checker
| Factor | Basedpyright | Pyright | mypy |
|---|---|---|---|
| Speed | Fastest | Fastest | Slower |
| Strictness | Strictest defaults | Configurable | Configurable |
| LSP Support | Built-in | Built-in | Via dmypy |
| Plugin System | Limited | Limited | Extensive |
Choose Basedpyright for maximum type safety with stricter defaults and fastest speed. Choose Pyright for Microsoft's official support and VS Code Pylance compatibility. Choose mypy for extensive plugin ecosystem (django-stubs, pydantic-mypy).
Inline Error Suppression
# Inline type ignore
result = unsafe_operation() # type: ignore[reportUnknownVariableType]
# Function-level ignore
def legacy_function(): # basedpyright: ignore
pass
Agentic Optimizations
| Context | Command |
|---|---|
| Quick check | basedpyright |
| JSON output | basedpyright --outputjson |
| Watch mode | basedpyright --watch |
| CI check | uv run basedpyright |
| Verbose | basedpyright --verbose |
Quick Reference
| Flag | Description |
|---|---|
--watch |
Watch mode for development |
--outputjson |
JSON output for tooling |
--verbose |
Verbose diagnostics |
--pythonversion X.Y |
Override Python version |
--level <mode> |
Override type checking mode |
For detailed configuration options, LSP integration, migration guides, CI setup, and best practices, see REFERENCE.md.
04 同仓库更多 Skills
session-workflow-capture
Workflow-tool scripts and workflow friction from this session, filed as issues here or in the plugins repo. Use when a session ran Workflow scripts.
kitty-show-image
Show the user an image with a note on what to judge, via a file send or a labelled kitty tab. Use when the user must see an image, or icat fails with no /dev/tty.
kitty-session-persistence
Snapshot and restore kitty terminal sessions on macOS. Use when surviving WindowServer hangs without losing tabs, configuring snapshots, or restoring after a force-reboot.
kitty-remote-control
Safe kitty remote control from an agent — read panes with kitty @ ls/get-text, notify, and never mutate the live terminal unasked. Use when running inside kitty.
docs-reference-check
Dangling doc-reference gate: flag markdown naming repo paths or relative links that no longer exist. Use when docs cite moved/deleted files, or wiring a doc-drift lint.
YouTube 视频上传与编辑
youtube-upload
通过 Data API v3 将视频上传到 YouTube,并在之后编辑其标题、描述、标签或缩略图。适用于发布 YouTube 视频或修改其标题。