{"library":"pyright","title":"Pyright for Python","description":"Pyright for Python is a command-line wrapper that simplifies the installation and execution of Microsoft's Pyright static type checker within a Python environment. Pyright itself is a fast, standards-compliant type checker written in TypeScript and executed via Node.js. This wrapper handles the complexities of downloading and managing Node.js and the Pyright npm package, allowing Python developers to use Pyright without needing a separate Node.js installation. The project is actively maintained with frequent releases, typically aligned with upstream Pyright updates.","language":"python","status":"active","last_verified":"Sun Mar 29","install":{"commands":["pip install pyright","pip install pyright[nodejs]"],"cli":{"name":"pyright","version":"* Install prebuilt node (26.1.0) ..... done."}},"imports":[],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import os\n\n# Create a dummy Python file to check\nwith open(\"my_module.py\", \"w\") as f:\n    f.write(\"def greet(name: str) -> int:\\n    return f'Hello, {name}'\\n\\nresult = greet('World')\\n\")\n\n# Run pyright via the command line (typical usage)\n# This is equivalent to `pyright my_module.py` in the terminal\nimport subprocess\n\ntry:\n    # Using python -m pyright to ensure the installed package's executable is found\n    process = subprocess.run(\n        ['python', '-m', 'pyright', 'my_module.py'],\n        capture_output=True,\n        text=True,\n        check=False  # Do not raise an exception for non-zero exit codes\n    )\n    print(\"Pyright Output:\\n\" + process.stdout)\n    if process.stderr:\n        print(\"Pyright Errors:\\n\" + process.stderr)\n    if process.returncode != 0:\n        print(f\"Pyright exited with code {process.returncode}. Errors found.\")\n    else:\n        print(\"Pyright completed with no errors.\")\nexcept FileNotFoundError:\n    print(\"Error: 'pyright' command not found. Ensure pyright is installed and in PATH.\")\nexcept Exception as e:\n    print(f\"An error occurred: {e}\")\n\n# Clean up the dummy file\nos.remove(\"my_module.py\")","lang":"python","description":"This quickstart demonstrates how to run Pyright on a simple Python file. The `pyright` Python package primarily provides a command-line executable. Programmatic invocation within Python is typically done by calling the `pyright` command via `subprocess`.","tag":null,"tag_description":null,"last_tested":"2026-04-24","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":-1},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]},"compatibility":null}