一键导入
pyright
Pyright static type checker — configuration, common errors, type annotation patterns for Python 3.10+ with uv projects
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
菜单
Pyright static type checker — configuration, common errors, type annotation patterns for Python 3.10+ with uv projects
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
基于 SOC 职业分类
PM2 — process manager for long-running training jobs on remote servers. ecosystem.config.js, common commands, and SSH workflow with uv.
pre-commit — git hook framework for automating ruff, pyright, pytest, and other checks before every commit
pytest — test structure, fixtures, markers, parametrize, conftest, and pytest-watch for automated testing in uv projects
Ruff — fast Python linter and formatter replacing flake8, black, isort. Configuration, rule selection, and common fixes.
uv — Python package manager, dependency management, virtual environments, and script running. Replaces pip, pip-tools, virtualenv, pyenv.
| name | pyright |
| description | Pyright static type checker — configuration, common errors, type annotation patterns for Python 3.10+ with uv projects |
uv run pyright # check all configured paths
uv run pyright src/my_module/ # check specific path
uv run pyright --version
[tool.pyright]
pythonVersion = "3.10"
pythonPlatform = "Linux"
typeCheckingMode = "basic" # off | basic | standard | strict
include = ["src", "baselines"]
exclude = [
"tests",
"baselines/tgn", # submodules with no stubs
"**/__pycache__",
]
venvPath = "."
venv = ".venv"
reportMissingImports = true
reportMissingTypeStubs = false # suppress for packages with no stubs (torch, dgl)
from __future__ import annotations # enables postponed evaluation everywhere
# Union — use X | Y (not Optional[X] or Union[X, Y])
def load(path: str | None = None) -> dict[str, float]:
...
# Generics — use lowercase built-ins (Python 3.9+)
def process(items: list[int]) -> dict[str, list[float]]:
...
# Callable
from collections.abc import Callable, Sequence
fn: Callable[[int, str], bool]
# TypeVar
from typing import TypeVar
T = TypeVar("T")
def first(items: list[T]) -> T:
return items[0]
# Self (Python 3.11+ or typing_extensions)
from typing import Self
class Builder:
def set_lr(self, lr: float) -> Self:
self.lr = lr
return self
# Type alias
type Vector = list[float] # Python 3.12+
Vector = list[float] # Python 3.10 compatible
x: int = some_dynamic_value # type: ignore[assignment]
# Whole file — put at top
# pyright: ignore[reportMissingImports]
| Error | Fix |
|---|---|
reportMissingImports for torch/dgl | set reportMissingTypeStubs = false or add stub package |
Cannot access attribute X | narrow type with isinstance check or cast |
Type X is not assignable to Y | check union types; use assert isinstance(x, T) to narrow |
reportUnknownMemberType | add # type: ignore[reportUnknownMemberType] for third-party |
reportAny | avoid Any; if needed, add comment explaining why |
uv add --dev pandas-stubs types-PyYAML types-tqdm
from __future__ import annotations must be the first import — it makes all annotations strings at runtime, fixing forward-reference issues.venvPath/venv config; if not set it may miss installed packages.typeCheckingMode = "strict" requires every function to be fully annotated — start with "basic" and tighten gradually.# type: ignore without specifying the error code — it silences all errors on that line.