How microsoft/pyright works
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: server.ts Language server · program.ts Analysis program · serviceProvider.ts Service registry · workspaceFactory.ts Workspace factory
Components 18
Product entry points
- CLI entry
packages/pyright-internal/src/pyright.ts - VS Code extension
packages/vscode-pyright/src/extension.ts - Language server
packages/pyright-internal/src/server.ts
Python analysis
- Workspace factory
packages/pyright-internal/src/workspaceFactory.ts - Analysis configuration
packages/pyright-internal/src/common/configOptions.ts - Import resolution
packages/pyright-internal/src/analyzer/importResolver.ts - Python parser
packages/pyright-internal/src/parser/parser.ts - Source files
packages/pyright-internal/src/analyzer/sourceFile.ts - Analysis program
packages/pyright-internal/src/analyzer/program.ts - Type evaluation
packages/pyright-internal/src/analyzer/typeEvaluator.ts - Diagnostics
packages/pyright-internal/src/common/diagnostic.ts
Editor services
- Language features
packages/pyright-internal/src/languageService - Server commands
packages/pyright-internal/src/commands/commandController.ts
Runtime services
- Type server
packages/pyright-internal/src/typeServer/server.ts - Notebook handling
packages/pyright-internal/src/typeServer/notebookDocumentHandler.ts - Service registry
packages/pyright-internal/src/common/serviceProvider.ts - File system interface
packages/pyright-internal/src/common/fileSystem.ts
Other components
- Python developer
Connections 18
- 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
packages/pyright-internal/src/server.ts - Workspace factory → Analysis program: builds analysis
- Analysis program → Source files: analyzes files
packages/pyright-internal/src/analyzer/program.ts - Source files → Python parser: parses source
packages/pyright-internal/src/analyzer/sourceFile.ts - Analysis program → Type evaluation: evaluates types
packages/pyright-internal/src/analyzer/program.ts - Language server → Analysis configuration: configures
packages/pyright-internal/src/server.ts - Language server → Import resolution: resolves imports
packages/pyright-internal/src/server.ts - Language server → Diagnostics: produces diagnostics
- Language server → Server commands: dispatches commands
packages/pyright-internal/src/server.ts - Language server → Language features: serves features
packages/pyright-internal/src/server.ts - Type server → Notebook handling: handles notebooks
packages/pyright-internal/src/typeServer/server.ts - Language server → Service registry: uses services
packages/pyright-internal/src/server.ts - Service registry → File system interface: registers services
packages/pyright-internal/src/common/serviceProviderExtensions.ts - Service registry → Workspace factory: provides workspace
packages/pyright-internal/src/common/languageServerInterface.ts