CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-pyright

Static type checker for Python with command-line tool and language server capabilities

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

cli-tool.mddocs/

CLI Tool

Complete command-line interface for Python static type checking with extensive configuration options and output formats.

Capabilities

Main Command

Primary interface for static type analysis of Python code.

pyright [options] files...

Analysis Options

Control the scope and behavior of type analysis.

--createstub <IMPORT>
# Create type stub file(s) for the specified import

--level <LEVEL>  
# Set minimum diagnostic level: "error" or "warning"

--skipunannotated
# Skip analysis of functions with no type annotations

--verifytypes <PACKAGE>
# Verify type completeness of a py.typed package

--ignoreexternal
# Ignore external imports for --verifytypes (only valid with --verifytypes)

Usage Examples:

# Create type stubs for a package
pyright --createstub requests

# Only show errors, hide warnings
pyright --level error src/

# Skip unannotated functions
pyright --skipunannotated

# Verify package type completeness
pyright --verifytypes mypackage

Python Environment Options

Configure the Python environment and interpreter settings.

--pythonplatform <PLATFORM>
# Analyze for specific platform: "Darwin", "Linux", or "Windows"

--pythonpath <FILE>
# Path to the Python interpreter executable

--pythonversion <VERSION>
# Analyze for specific Python version: "3.3", "3.4", "3.7", "3.8", "3.9", "3.10", "3.11", etc.

-v, --venvpath <DIRECTORY>
# Directory that contains virtual environments

-t, --typeshedpath <DIRECTORY>
# Use typeshed type stubs at this location

Usage Examples:

# Check for Linux compatibility
pyright --pythonplatform Linux

# Use specific Python version
pyright --pythonversion 3.9

# Set virtual environment path
pyright --venvpath ./venvs

# Use custom typeshed location
pyright --typeshedpath ./custom-typeshed

Project Configuration Options

Specify project files and configuration settings.

-p, --project <FILE OR DIRECTORY>
# Use configuration file at this location

files...
# Python files to analyze (default positional argument)

-
# Read file list from stdin

Usage Examples:

# Use specific config file
pyright --project ./myconfig.json

# Analyze specific files
pyright src/main.py tests/test_main.py

# Read file list from stdin
echo "src/main.py src/utils.py" | pyright -

Output Options

Control the format and verbosity of analysis output.

--outputjson
# Output results in JSON format instead of text

--verbose
# Emit verbose diagnostics and additional information

--stats
# Print detailed performance statistics

--dependencies
# Emit import dependency information

--warnings
# Use exit code of 1 if warnings are reported (in addition to errors)

Usage Examples:

# Get machine-readable JSON output
pyright --outputjson > results.json

# Show detailed performance information
pyright --stats --verbose

# Show import dependencies
pyright --dependencies

# Treat warnings as errors for CI
pyright --warnings

Runtime Options

Configure execution behavior and performance.

--threads <optional COUNT>
# Use separate threads to parallelize type checking
# If COUNT is omitted or "auto", uses CPU core count (minimum 4)

-w, --watch
# Continue to run and watch for file changes

--help, -h
# Show help message and exit

--version
# Print Pyright version and exit

Usage Examples:

# Use automatic thread count
pyright --threads

# Use specific thread count
pyright --threads 8

# Watch mode for continuous checking
pyright --watch

# Show version information
pyright --version

Deprecated Options

These options are still supported but deprecated in favor of newer alternatives:

--lib
# DEPRECATED: Pyright now defaults to using library code to infer types

--venv-path <DIRECTORY>
# DEPRECATED: Use --venvpath instead

--typeshed-path <DIRECTORY>  
# DEPRECATED: Use --typeshedpath instead

Option Compatibility

Some options are mutually exclusive:

--outputjson incompatible with:

  • --stats, --verbose, --createstub, --dependencies

--verifytypes incompatible with:

  • --watch, --stats, --createstub, --dependencies, --skipunannotated, --threads

--createstub incompatible with:

  • --watch, --stats, --verifytypes, --dependencies, --skipunannotated, --threads

--threads incompatible with:

  • --watch, --stats, --dependencies

--pythonpath incompatible with:

  • --venv-path, --venvpath

Configuration File Integration

The CLI respects configuration files in the following order:

  1. File specified by --project option
  2. pyrightconfig.json in current directory
  3. pyproject.toml with [tool.pyright] section in current directory
  4. Search parent directories for configuration files

Exit Codes

enum ExitStatus {
  NoErrors = 0,              // Successful execution with no errors
  ErrorsReported = 1,        // Type errors were found
  FatalError = 2,            // Fatal error occurred during execution  
  ConfigFileParseError = 3,  // Configuration file parsing failed
  ParameterError = 4,        // Invalid command-line parameters
}

Multi-threading Behavior

When using --threads:

  • Analysis is split across multiple worker processes
  • Each worker analyzes a subset of files
  • Results are aggregated and reported by the main process
  • Improves performance on large codebases
  • Uses file affinity to maximize type cache effectiveness

File Input Methods

# Direct file arguments
pyright file1.py file2.py

# Glob patterns (shell expansion)
pyright src/**/*.py

# Configuration-based discovery
pyright --project pyrightconfig.json

# Stdin file list
echo "file1.py file2.py" | pyright -

Environment Variables

Pyright respects these environment variables:

  • PYTHONPATH - Additional module search paths
  • Standard Node.js environment variables for the runtime

Performance Considerations

  • Use --threads for large codebases (>100 files)
  • Enable --watch mode for development workflows
  • Use --skipunannotated to focus on typed code
  • Configure appropriate include/exclude patterns in config files
  • Consider --level error to reduce noise in CI environments

Install with Tessl CLI

npx tessl i tessl/npm-pyright

docs

cli-tool.md

index.md

json-output.md

language-server.md

tile.json