home / skills / laurigates / claude-plugins / basedpyright-type-checking

basedpyright-type-checking skill

/python-plugin/skills/basedpyright-type-checking

This skill helps you configure and compare Basedpyright type checking, enabling strict, fast Python validation with LSP support and tooling integration.

npx playbooks add skill laurigates/claude-plugins --skill basedpyright-type-checking

Review the files below or copy the command above to add this skill to your agents.

Files (2)
SKILL.md
4.2 KB
---
model: haiku
created: 2025-12-16
modified: 2026-02-14
reviewed: 2025-12-16
name: basedpyright-type-checking
description: |
  Basedpyright static type checker configuration, installation, and usage patterns.
  Use when implementing type checking, configuring LSP, comparing type checkers,
  or setting up strict type validation in Python projects.
  Triggered by: basedpyright, pyright, type checking, LSP, mypy alternative, static analysis.
allowed-tools: Bash, Read, Grep, Glob
---

# 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)
```bash
# Install globally
uv tool install basedpyright

# Install as dev dependency
uv add --dev basedpyright

# Run with uv
uv run basedpyright
```

### Via pipx
```bash
pipx install basedpyright
```

## Basic Usage

```bash
# 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)

```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

```toml
# 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

```python
# 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](REFERENCE.md).

Overview

This skill documents Basedpyright static type checker configuration, installation, and usage patterns for Python projects. It highlights strict defaults, CLI flags, LSP integration, and progressive migration patterns to adopt stricter type checking safely. Use it to configure CI, editor LSPs, or compare Basedpyright with other type checkers.

How this skill works

Basedpyright is a Pyright fork with stricter defaults and extra diagnostic rules. The skill explains installing via uv or pipx, running the CLI (watch, JSON output, verbose), and configuring pyproject.toml or CLI overrides. It describes typeCheckingMode levels (off, basic, standard, strict, all) and shows how to progressively expand coverage and escalate strictness.

When to use it

  • Setting up static type checking for a new or existing Python codebase
  • Configuring LSP support in editors to get type-aware completions and diagnostics
  • Comparing type checkers when choosing between Basedpyright, Pyright, and mypy
  • Enforcing stricter diagnostics and rules (unused results, missing super calls, uninitialized vars)
  • Integrating type checks into CI or developer workflows with uv or pipx

Best practices

  • Start with typeCheckingMode = "basic" for new modules, then expand include and increase strictness progressively
  • Use pyproject.toml to centralize configuration and set project-wide rules like reportUnusedCallResult and reportUninitializedInstanceVariable
  • Run basedpyright --watch during active development and use --outputjson for CI tooling or automation
  • Suppress diagnostics sparingly with inline ignores and prefer gradual typing over blanket disables
  • Pin pythonVersion in configuration to ensure consistent behavior across dev machines and CI

Example use cases

  • Install basedpyright as a dev dependency and run uv run basedpyright in CI to fail on type errors
  • Enable watch mode while working on a module to get immediate feedback on type regressions
  • Migrate a legacy codebase by gradually including directories and moving from basic to strict mode
  • Compare performance and rule strictness versus mypy when choosing a static analysis tool for a project
  • Output JSON diagnostics for an automation script that converts errors into GitHub annotations

FAQ

How do I install Basedpyright?

Recommended: use uv tool install basedpyright or uv add --dev basedpyright. Alternatively install via pipx: pipx install basedpyright.

How can I migrate incrementally to strict mode?

Start with typeCheckingMode = "basic" and include only new modules. Gradually add directories to include and finally set typeCheckingMode = "strict" when coverage is sufficient.