# microsoft/pyright architecture

> Architecture diagram of the GitHub repository microsoft/pyright, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/microsoft/pyright
- Repository: https://github.com/microsoft/pyright

## Overview

Pyright is a high-performance static type checker for Python, delivered as a command-line tool and a Visual Studio Code extension. The principal workflow is a user submitting a workspace for analysis, followed by parsing, type evaluation, and diagnostics. The repository also contains editor language-service features, command handling, and a separate type-server/notebook surface. Edges are limited to relationships documented in the README or visible in the supplied source index; where implementation details were not sampled, uncertain links are omitted.

Main entry points: [`packages/pyright-internal/src/server.ts`](https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/server.ts) (Language server), [`packages/pyright-internal/src/analyzer/program.ts`](https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/analyzer/program.ts) (Analysis program), [`packages/pyright-internal/src/common/serviceProvider.ts`](https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/common/serviceProvider.ts) (Service registry), [`packages/pyright-internal/src/workspaceFactory.ts`](https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/workspaceFactory.ts) (Workspace factory)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Product entry points"]
  node_cli["CLI entry<br/>[pyright.ts]"]
  node_vscode["VS Code extension<br/>[extension.ts]"]
  node_server["Language server<br/>[server.ts]"]
end

subgraph group_analysis["Python analysis"]
  node_workspace["Workspace factory"]
  node_config["Analysis configuration<br/>[configOptions.ts]"]
  node_imports["Import resolution<br/>[importResolver.ts]"]
  node_parser["Python parser<br/>[parser.ts]"]
  node_source["Source files<br/>[sourceFile.ts]"]
  node_program["Analysis program<br/>[program.ts]"]
  node_evaluator["Type evaluation<br/>[typeEvaluator.ts]"]
  node_diagnostics["Diagnostics<br/>[diagnostic.ts]"]
end

subgraph group_editor["Editor services"]
  node_language["Language features"]
  node_commands["Server commands"]
end

subgraph group_runtime["Runtime services"]
  node_typeserver["Type server<br/>[server.ts]"]
  node_notebooks["Notebook handling"]
  node_services["Service registry<br/>[serviceProvider.ts]"]
  node_filesystem["File system interface<br/>[fileSystem.ts]"]
end

node_user(("Python developer"))

node_user -->|"runs"| node_cli
node_user -->|"uses"| node_vscode
node_cli -.->|"starts"| node_server
node_vscode -.->|"connects"| node_server
node_server -->|"creates workspace"| node_workspace
node_workspace -.->|"builds analysis"| node_program
node_program -.->|"analyzes files"| node_source
node_source -.->|"parses source"| node_parser
node_program -.->|"evaluates types"| node_evaluator
node_server -->|"configures"| node_config
node_server -->|"resolves imports"| node_imports
node_server -.->|"produces diagnostics"| node_diagnostics
node_server -->|"dispatches commands"| node_commands
node_server -.->|"serves features"| node_language
node_typeserver -.->|"handles notebooks"| node_notebooks
node_server -->|"uses services"| node_services
node_services -->|"registers services"| node_filesystem
node_services -->|"provides workspace"| node_workspace

click node_cli "https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/pyright.ts"
click node_vscode "https://github.com/microsoft/pyright/blob/main/packages/vscode-pyright/src/extension.ts"
click node_server "https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/server.ts"
click node_workspace "https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/workspaceFactory.ts"
click node_config "https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/common/configOptions.ts"
click node_imports "https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/analyzer/importResolver.ts"
click node_parser "https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/parser/parser.ts"
click node_source "https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/analyzer/sourceFile.ts"
click node_program "https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/analyzer/program.ts"
click node_evaluator "https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/analyzer/typeEvaluator.ts"
click node_diagnostics "https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/common/diagnostic.ts"
click node_language "https://github.com/microsoft/pyright/tree/main/packages/pyright-internal/src/languageService"
click node_commands "https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/commands/commandController.ts"
click node_typeserver "https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/typeServer/server.ts"
click node_notebooks "https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/typeServer/notebookDocumentHandler.ts"
click node_services "https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/common/serviceProvider.ts"
click node_filesystem "https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/common/fileSystem.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cli,node_vscode,node_server toneBlue
class node_workspace,node_config,node_imports,node_parser,node_source,node_program,node_evaluator,node_diagnostics toneAmber
class node_language,node_commands toneMint
class node_typeserver,node_notebooks,node_services,node_filesystem toneRose
class node_user toneIndigo
```

## Components

### Product entry points

- [CLI entry](https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/pyright.ts): `packages/pyright-internal/src/pyright.ts`
- [VS Code extension](https://github.com/microsoft/pyright/blob/main/packages/vscode-pyright/src/extension.ts): `packages/vscode-pyright/src/extension.ts`
- [Language server](https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/server.ts): `packages/pyright-internal/src/server.ts`

### Python analysis

- [Workspace factory](https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/workspaceFactory.ts): `packages/pyright-internal/src/workspaceFactory.ts`
- [Analysis configuration](https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/common/configOptions.ts): `packages/pyright-internal/src/common/configOptions.ts`
- [Import resolution](https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/analyzer/importResolver.ts): `packages/pyright-internal/src/analyzer/importResolver.ts`
- [Python parser](https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/parser/parser.ts): `packages/pyright-internal/src/parser/parser.ts`
- [Source files](https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/analyzer/sourceFile.ts): `packages/pyright-internal/src/analyzer/sourceFile.ts`
- [Analysis program](https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/analyzer/program.ts): `packages/pyright-internal/src/analyzer/program.ts`
- [Type evaluation](https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/analyzer/typeEvaluator.ts): `packages/pyright-internal/src/analyzer/typeEvaluator.ts`
- [Diagnostics](https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/common/diagnostic.ts): `packages/pyright-internal/src/common/diagnostic.ts`

### Editor services

- [Language features](https://github.com/microsoft/pyright/tree/main/packages/pyright-internal/src/languageService): `packages/pyright-internal/src/languageService`
- [Server commands](https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/commands/commandController.ts): `packages/pyright-internal/src/commands/commandController.ts`

### Runtime services

- [Type server](https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/typeServer/server.ts): `packages/pyright-internal/src/typeServer/server.ts`
- [Notebook handling](https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/typeServer/notebookDocumentHandler.ts): `packages/pyright-internal/src/typeServer/notebookDocumentHandler.ts`
- [Service registry](https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/common/serviceProvider.ts): `packages/pyright-internal/src/common/serviceProvider.ts`
- [File system interface](https://github.com/microsoft/pyright/blob/main/packages/pyright-internal/src/common/fileSystem.ts): `packages/pyright-internal/src/common/fileSystem.ts`

### Other components

- **Python developer**

## Connections

- Python developer → CLI entry: runs
- Python developer → VS Code extension: uses
- CLI entry → Language server: starts
- VS Code extension → Language server: connects
- Language server → Workspace factory: creates workspace (evidence: `packages/pyright-internal/src/server.ts`)
- Workspace factory → Analysis program: builds analysis
- Analysis program → Source files: analyzes files (evidence: `packages/pyright-internal/src/analyzer/program.ts`)
- Source files → Python parser: parses source (evidence: `packages/pyright-internal/src/analyzer/sourceFile.ts`)
- Analysis program → Type evaluation: evaluates types (evidence: `packages/pyright-internal/src/analyzer/program.ts`)
- Language server → Analysis configuration: configures (evidence: `packages/pyright-internal/src/server.ts`)
- Language server → Import resolution: resolves imports (evidence: `packages/pyright-internal/src/server.ts`)
- Language server → Diagnostics: produces diagnostics
- Language server → Server commands: dispatches commands (evidence: `packages/pyright-internal/src/server.ts`)
- Language server → Language features: serves features (evidence: `packages/pyright-internal/src/server.ts`)
- Type server → Notebook handling: handles notebooks (evidence: `packages/pyright-internal/src/typeServer/server.ts`)
- Language server → Service registry: uses services (evidence: `packages/pyright-internal/src/server.ts`)
- Service registry → File system interface: registers services (evidence: `packages/pyright-internal/src/common/serviceProviderExtensions.ts`)
- Service registry → Workspace factory: provides workspace (evidence: `packages/pyright-internal/src/common/languageServerInterface.ts`)
