BasedPyright

1.39.0 · active · verified Thu Apr 09

BasedPyright is a static type checker for Python, forked from Pyright. It aims to provide various type checking improvements, integrate Pylance features (previously exclusive to VS Code), and introduce new diagnostic rules. Unlike upstream Pyright, it is officially published on PyPI, removing the requirement for Node.js. It is actively maintained with frequent releases, currently at version 1.39.0.

Warnings

Install

Quickstart

To get started, create a Python file and a `pyproject.toml` configuration. Then run `basedpyright` from your terminal. BasedPyright will analyze your code based on the rules specified in the configuration.

mkdir my_project
cd my_project

# Create a Python file
echo 'def greet(name: str) -> str:
    return "Hello, " + name

# Intentional type error for demonstration
def add(a: int, b: str) -> int:
    # Pyright will flag this: Expression of type "str" cannot be added to an expression of type "int"
    return a + b' > main.py

# Create a pyproject.toml for configuration
echo '[tool.basedpyright]
include = ["main.py"]
reportMissingTypeStubs = true
reportPrivateUsage = true' > pyproject.toml

# Run basedpyright
pip install basedpyright
basedpyright main.py

view raw JSON →