初始化上传
Some checks failed
Run mypy_primer on push / Run mypy_primer on push (push) Has been cancelled
Validation / Typecheck (push) Has been cancelled
Validation / Style (push) Has been cancelled
Validation / Test macos-latest (push) Has been cancelled
Validation / Test ubuntu-latest (push) Has been cancelled
Validation / Test windows-latest (push) Has been cancelled
Validation / Build (push) Has been cancelled
Validation / Required (push) Has been cancelled

This commit is contained in:
2026-07-24 17:08:39 +08:00
commit e9e4693333
7516 changed files with 768821 additions and 0 deletions

28
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@@ -0,0 +1,28 @@
---
name: Bug report
about: Report incorrect or unintended behaviors
title: ''
labels: bug
assignees: ''
---
Note: if you are reporting a wrong signature of a function or a class in the standard library, then the typeshed tracker is better suited for this report: https://github.com/python/typeshed/issues.
If you have a question about typing or a behavior that youre seeing in Pyright (as opposed to a bug report or enhancement request), consider posting to the [Pyright discussion forum](https://github.com/microsoft/pyright/discussions).
**Describe the bug**
A clear and concise description of the behavior you are seeing and the expected behavior along with steps to reproduce it.
**Code or Screenshots**
If possible, provide a minimal, self-contained code sample (surrounded by triple back ticks) to demonstrate the issue. The code should define or import all referenced symbols.
```python
def foo(self) -> str:
return 3
```
If your code relies on symbols that are imported from a third-party library, include the associated import statements and specify which versions of those libraries you have installed.
**VS Code extension or command-line**
Are you running pyright as a VS Code extension, a language server in another editor, integrated into Pylance, or the command-line tool? Which version?

View File

@@ -0,0 +1,17 @@
---
name: Feature request
about: Suggest an idea or improvement
title: ''
labels: enhancement request
assignees: ''
---
If you have a question about a behavior that youre seeing in pyright, consider posting to the [Pyright discussion forum](https://github.com/microsoft/pyright/discussions).
**Is your feature request related to a problem? Please describe.**
A clear and concise description of the problem.
**Describe the solution youd like**
A clear and concise description of the solution you would like to see.

View File

@@ -0,0 +1,33 @@
name: Add auth token to .npmrc
on:
workflow_call:
inputs:
working-directory:
description: The directory whose .npmrc file should be modified
required: true
type: string
token:
description: The auth token to add to the .npmrc file
required: true
type: string
feed-url:
description: The URL of the Azure Artifacts feed to authenticate with
required: false
default: //devdiv.pkgs.visualstudio.com/DevDiv/_packaging/Pylance_PublicPackages
runs:
using: composite
steps:
- name: Generate .npmrc
shell: bash
run: |
echo "registry=https:${{ inputs.feed-url }}/npm/registry/" > ${{ inputs.working-directory }}/.npmrc
echo "" >> ${{ inputs.working-directory }}/.npmrc
echo "${{ inputs.feed-url }}/npm/registry/:username=github-actions" >> ${{ inputs.working-directory }}/.npmrc
echo "${{ inputs.feed-url }}/npm/registry/:_authToken=${{ inputs.token }}" >> ${{ inputs.working-directory }}/.npmrc
echo "${{ inputs.feed-url }}/npm/registry/:email=actions@github.com" >> ${{ inputs.working-directory }}/.npmrc
echo "${{ inputs.feed-url }}/npm:username=github-actions" >> ${{ inputs.working-directory }}/.npmrc
echo "${{ inputs.feed-url }}/npm:_authToken=${{ inputs.token }}" >> ${{ inputs.working-directory }}/.npmrc
echo "${{ inputs.feed-url }}/npm:email=actions@github.com" >> ${{ inputs.working-directory }}/.npmrc

View File

@@ -0,0 +1,11 @@
name: Setup npm cache caching
on:
workflow_call:
runs:
using: composite
steps:
- uses: ./.github/actions/npm-cache-dir
with:
include-npmrc-hash: 'true'

View File

@@ -0,0 +1,56 @@
# Does an npm install using our private Azure Artifacts registry which requires OIDC authentication.
# Workflows that use this action must add the id-token: write permission.
name: npm install (CFS)
on:
workflow_call:
runs:
using: composite
steps:
- name: Azure OIDC Login
uses: azure/login@v2
with:
# These are not secret values and are safe to commit to the repository
client-id: 92c669e8-02ad-4ce6-ad73-f222fc7177e2
tenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47
allow-no-subscriptions: true
- name: Setup CFS Credentials
shell: bash
id: npm-auth
# The resource guid is the app id of Azure DevOps
run: |
echo "token=$(az account get-access-token --resource 499b84ac-1321-427f-aa17-267ca6975798 | jq -r .accessToken)" >> $GITHUB_OUTPUT
- uses: ./.github/actions/cfs-npm-authenticate
with:
working-directory: .
token: ${{ steps.npm-auth.outputs.token }}
- uses: ./.github/actions/cfs-npm-authenticate
with:
working-directory: packages/pyright
token: ${{ steps.npm-auth.outputs.token }}
- uses: ./.github/actions/cfs-npm-authenticate
with:
working-directory: packages/pyright-internal
token: ${{ steps.npm-auth.outputs.token }}
- uses: ./.github/actions/cfs-npm-authenticate
with:
working-directory: packages/vscode-pyright
token: ${{ steps.npm-auth.outputs.token }}
- uses: ./.github/actions/cfs-npm-cache
- run: npm run install:all
shell: bash
working-directory: ${{ inputs.working-directory }}
- name: Cleanup .npmrc
shell: bash
run: rm .npmrc
working-directory: ${{ inputs.working-directory }}

View File

@@ -0,0 +1,19 @@
# Accessing the CFS feed requires OIDC authentication which is not allowed on branches from forks.
# https://docs.github.com/en/actions/security-for-github-actions/security-guides/automatic-token-authentication#permissions-for-the-github_token
# This action decides whether to use CFS based on the source of the branch in play.
name: npm install (consider using CFS)
on:
workflow_call:
runs:
using: composite
steps:
- name: CFS npm install
if: github.event.pull_request.head.repo.fork != true
uses: ./.github/actions/cfs-npm-install
- name: Standard npm install
if: github.event.pull_request.head.repo.fork == true
uses: ./.github/actions/standard-npm-install

View File

@@ -0,0 +1,49 @@
name: Cache npm download directory
description: Cache npm's download cache directory (npm config get cache) using actions/cache
inputs:
cache-dependency-path:
description: Glob(s) passed to hashFiles to generate the cache key
default: '**/package-lock.json'
required: false
include-npmrc-hash:
description: Include hashFiles('**/.npmrc') in the key (useful when registry settings affect cache safety)
default: 'false'
required: false
key-prefix:
description: Prefix for the generated key
default: 'node'
required: false
runs:
using: composite
steps:
- name: Get npm cache directory (non-Windows)
id: npm-cache-dir-bash
if: runner.os != 'Windows'
shell: bash
run: echo "dir=$(npm config get cache)" >> "$GITHUB_OUTPUT"
- name: Get npm cache directory (Windows)
id: npm-cache-dir-pwsh
if: runner.os == 'Windows'
shell: pwsh
run: |
$dir = npm config get cache
"dir=$dir" | Out-File -FilePath $env:GITHUB_OUTPUT -Append -Encoding utf8
- name: Cache npm cache directory (with .npmrc)
if: inputs.include-npmrc-hash == 'true'
uses: actions/cache@v4
with:
path: ${{ steps.npm-cache-dir-bash.outputs.dir || steps.npm-cache-dir-pwsh.outputs.dir }}
key: ${{ runner.os }}-${{ inputs.key-prefix }}-${{ hashFiles('**/.npmrc') }}-${{ hashFiles(inputs.cache-dependency-path) }}
restore-keys: ${{ runner.os }}-${{ inputs.key-prefix }}-${{ hashFiles('**/.npmrc') }}-
- name: Cache npm cache directory
if: inputs.include-npmrc-hash != 'true'
uses: actions/cache@v4
with:
path: ${{ steps.npm-cache-dir-bash.outputs.dir || steps.npm-cache-dir-pwsh.outputs.dir }}
key: ${{ runner.os }}-${{ inputs.key-prefix }}-${{ hashFiles(inputs.cache-dependency-path) }}
restore-keys: ${{ runner.os }}-${{ inputs.key-prefix }}-

View File

@@ -0,0 +1,15 @@
# Standard npm install using the public npm registry.
name: npm install (public registry)
on:
workflow_call:
runs:
using: composite
steps:
- uses: ./.github/actions/npm-cache-dir
- name: Standard npm install
shell: bash
run: npm run install:all

118
.github/agents/pyright-test-policy.md vendored Normal file
View File

@@ -0,0 +1,118 @@
---
name: pyright-test-policy
description: Enforces Pyright test policy, preserving type precision and requiring justification for test changes.
---
# Pyright Test Policy
Tests are the specification for Pyright behavior.
Agents must **not modify tests simply to make CI pass**.
The goal is to **preserve or improve type precision** unless a justified upstream change requires otherwise.
---
# Allowed Changes
Agents may modify tests only when one of the following is true:
1. A **typeshed stub change** legitimately alters the expected type.
2. A **Pyright diagnostic message format** changed but the semantic meaning is the same.
3. A test relied on unstable formatting or ordering.
---
# Precision Regression Rule (Default)
Any change that makes types less precise is considered a **regression by default**.
Examples:
- `T → Unknown`
- `T → Any`
- container precision loss
`list[int] → list[Any]`
- literal widening
`Literal["x"] → str`
These regressions are **allowed only with justification**.
---
# Allowed Regression With Evidence
`Unknown` or `Any` changes may be accepted **only if the PR includes**:
1. **Evidence**
- the relevant typeshed stub diff
- or an upstream typing change
2. **Reasoning**
- why Pyright cannot infer the previous precision
3. **Classification**
- A) typeshed became less precise
- B) Pyright limitation
- C) test fragility
- D) harness issue
4. **Mitigation**
When possible:
- open a typeshed issue/PR
- or add a TODO referencing the issue
---
# Forbidden Changes
Agents must NOT:
- blindly replace expected types with `Unknown` or `Any`
- remove diagnostics
- delete `reveal_type` checks
- suppress errors to make tests pass
without the justification process above.
---
# Preferred Fix Order
Agents must attempt fixes in this order:
1. **Fix Pyright behavior**
2. **Fix incorrect typeshed stub**
3. **Adjust tests (last resort)**
---
# Precision Regression Reporting
If a regression is introduced, the agent must include a report in the PR:
Example:
Precision Regression Report
Test | Before | After | Reason
---- | ---- | ---- | ----
test_numpy_array | ndarray[int] | ndarray[Any] | typeshed change in numpy/__init__.pyi
This ensures reviewers can quickly understand the impact.
---
# Review Gate
If more than **2 precision regressions** occur in a single PR, the agent must stop and request human review.
---
# Commit Message Requirements
Each fix must include:
- failure classification (A/B/C/D)
- relevant typeshed commit (if applicable)
- explanation of how the change preserves or justifies type precision

206
.github/agents/typeshed-update-agent.md vendored Normal file
View File

@@ -0,0 +1,206 @@
---
name: typeshed-update-agent
description: Updates Pyright bundled typeshed fallback and triages resulting test changes while preserving type precision.
---
# Typeshed Update Agent
This agent updates the typeshed version used by Pyright and ensures tests remain correct and precise.
The agent must follow the **Pyright Test Policy**.
---
# Phase 1 — Update Typeshed
1. Update the pinned typeshed commit or submodule.
2. Run the full Pyright test suite.
3. If all tests pass, create a PR titled:
Update typeshed to <commit>
Include the typeshed commit hash and summary.
The PR must target the upstream Pyright repository (`microsoft/pyright`), not the fork repository.
Use the fork branch as the PR head if needed, and verify the reported PR URL is under `github.com/microsoft/pyright`.
## Running The Update Script
Use the repo script (from the Pyright repo root):
```bash
python build/updateTypeshed.py
```
Useful options:
- specific commit: `python build/updateTypeshed.py --commit <typeshed_commit>`
- dry run: `python build/updateTypeshed.py --dry-run`
Notes:
- The script clones `https://github.com/python/typeshed.git` into a temporary directory.
- A local checkout of typeshed is not required to run the update.
- It updates `packages/pyright-internal/typeshed-fallback/` and writes the selected SHA to `packages/pyright-internal/typeshed-fallback/commit.txt`.
- Do not spend token budget reviewing or summarizing the full generated `typeshed-fallback` diff; it is expected to be large and noisy. Use the pinned SHA, upstream compare links, and targeted file inspection only when tests fail or a specific behavior change needs triage.
## Upstream Investigation Guidance
When behavior changes are suspected, inspect upstream typeshed directly:
- typeshed repo: `https://github.com/python/typeshed`
- compare SHAs: `https://github.com/python/typeshed/compare/<old_sha>...<new_sha>`
- specific PRs linked from changed files or commit history (for example dict constructor positional-only changes in `python/typeshed#15262`)
Always tie Pyright test changes to a concrete upstream typeshed commit or PR.
---
# Phase 2 — Failure Triage
If tests fail, the agent must classify each failure.
Possible categories:
A) Legitimate typeshed behavior change
B) Pyright bug revealed by new stubs
C) Test fragility (formatting / ordering)
D) Test harness or environment issue
The agent must inspect:
- failing test
- relevant stub definitions
- typeshed commit diff
- diagnostic output
## Known High-Risk Change Patterns
Pay extra attention when the typeshed diff includes:
- positional-only separators (`/`) added or moved in `__new__`/`__init__`
- overload reordering or overload narrowing/widening
- `Self` return type changes in constructors or metaclass `__call__`
- `contextmanager` / generator return annotation changes
- stdlib constructor stubs for `dict`, `defaultdict`, `set`, `frozenset`, `slice`
These often surface Category B regressions in constructor synthesis, overload matching, and callable conversion.
---
# Phase 3 — Diagnostic Diff
For each failing test:
1. Capture baseline diagnostics
2. Capture new diagnostics
3. Compute a diff
Track changes including:
- removed diagnostics
- added diagnostics
- `reveal_type` output changes
- type precision changes
## Targeted Test Matrix (Run Early)
Run these focused tests before full-suite reruns when related files change.
- constructor callable and default constructor behavior:
- `cd packages/pyright-internal && npm run test:norebuild -- typeEvaluator6.test.ts -t "ConstructorCallable1|ConstructorCallable2|Constructor28" --runInBand`
- contextmanager / generator behavior:
- `cd packages/pyright-internal && npm run test:norebuild -- typeEvaluator2.test.ts -t Solver7 --runInBand`
- positional-only parameter behavior:
- `cd packages/pyright-internal && npm run test:norebuild -- typeEvaluator1.test.ts -t Call3 --runInBand`
---
# Phase 4 — Fix Strategy
Preferred order:
1. Fix Pyright implementation
2. Patch incorrect typeshed stub
3. Update expected outputs (last resort)
Test updates must follow the **Precision Regression Rule**.
---
# Handling Precision Regressions
If type precision is reduced (e.g. `T → Unknown`):
1. Check whether a stub change caused the regression.
2. Attempt to restore precision via Pyright improvements.
3. If unavoidable, update tests **with justification**.
A regression report must be added to the PR.
## Regression Guardrails
- Do not accept `T -> Unknown` precision drops without root-cause analysis.
- Do not update reveal expectations until checking whether a Pyright implementation fix can preserve precision.
- If a reveal text changes due to upstream behavior, include the upstream commit/PR reference in the test update commit message or PR description.
---
# Pull Request Requirements
PR must include:
- typeshed commit bump
- Pyright fixes if needed
- minimal test updates
- precision regression report (if applicable)
- explanation for each change
## PR Output Template
Include the following sections in the PR description:
1. Upstream typeshed update
- old SHA -> new SHA
- compare URL
2. Failure classification summary
- categories A/B/C/D with counts
3. Pyright fixes
- files changed
- behavior restored
4. Test updates
- which files changed and why
5. Precision report
- any `reveal_type` deltas and justification
6. Validation
- targeted tests run
- full suite result
---
# Commit Structure
Preferred commits:
1. typeshed update
2. pyright fixes
3. justified test updates
Keeping these separate simplifies review.
---
# Safety Rules
The agent must stop and request human review if:
- more than 2 precision regressions occur
- a change affects core typing behavior
- tests require large-scale updates
## Escalation Checklist
Escalate early when any of these occur:
- constructor synthesis behavior changes in multiple unrelated samples
- new failures in both evaluator and language service suites from one stub change
- uncertainty about whether a fix belongs in Pyright versus upstream typeshed

108
.github/copilot-instructions.md vendored Normal file
View File

@@ -0,0 +1,108 @@
# Copilot Instructions for Pyright
Pyright is a static type checker for Python, written in TypeScript. It ships as an npm CLI (`pyright`), an LSP language server (`pyright-langserver`), and a VS Code extension (`vscode-pyright`).
## Build and Test
```bash
# Install all packages (from repo root)
npm install
# Build the core library
cd packages/pyright-internal && npm run build
# Run all tests (builds test server first)
cd packages/pyright-internal && npm test
# Run all tests without rebuilding the test server (faster iteration)
cd packages/pyright-internal && npm run test:norebuild
# Run a single test file
cd packages/pyright-internal && npx jest typeEvaluator1.test --forceExit
# Run a single test by name
cd packages/pyright-internal && npx jest -t "Generic1" --forceExit
# Build the CLI (webpack bundle)
npm run build:cli:dev
# Build the VS Code extension (webpack bundle)
npm run build:extension:dev
```
### Linting
```bash
# Run all checks (syncpack + eslint + prettier)
npm run check
# Individual checks
npm run check:eslint
npm run check:prettier
# Auto-fix
npm run fix:eslint
npm run fix:prettier
```
## Architecture
### Package Structure
- **`packages/pyright-internal`** — Core library: parser, binder, type evaluator, checker, language service. All logic lives here. This is the only package with tests.
- **`packages/pyright`** — CLI wrapper. Webpack-bundles `pyright-internal` into a distributable npm package with `pyright` and `pyright-langserver` entry points.
- **`packages/vscode-pyright`** — VS Code extension client that communicates with the language server.
### Analysis Pipeline
Source files are processed through these phases in order:
1. **Tokenizer** (`parser/tokenizer.ts`) — text → token stream
2. **Parser** (`parser/parser.ts`) — tokens → parse tree (AST)
3. **Binder** (`analyzer/binder.ts`) — builds scopes, symbol tables, and reverse code flow graphs
4. **Checker** (`analyzer/checker.ts`) — walks every node, triggering type evaluation and reporting diagnostics
5. **Type Evaluator** (`analyzer/typeEvaluator.ts`) — performs type inference, constraint solving, type narrowing, and overload resolution
### Key Design Patterns
**Type Evaluator closure pattern**: `typeEvaluator.ts` uses a single large `createTypeEvaluator()` factory function. Internal methods access the full closure for performance (same approach as the TypeScript compiler). The public API is defined as the `TypeEvaluator` interface in `typeEvaluatorTypes.ts`.
**Service → Program → SourceFile**: A `Service` manages a `Program`, which tracks `SourceFile` instances. The `Program` coordinates analysis ordering, prioritizing open editor files and their dependencies.
**Typeshed fallback**: `packages/pyright-internal/typeshed-fallback/` contains a bundled copy of typeshed stubs. This provides the Python stdlib type stubs when no external typeshed is available.
**Localized diagnostics**: All user-facing diagnostic messages come from `localization/localize.ts`, not inline strings.
## Test Conventions
### Test Structure
Tests live in `packages/pyright-internal/src/tests/`. There are two main patterns:
**Sample-based tests** (`typeEvaluator*.test.ts`, `checker.test.ts`):
- Each test calls `TestUtils.typeAnalyzeSampleFiles(['sampleName.py'])` to analyze a Python file from `src/tests/samples/`.
- Results are validated with `TestUtils.validateResults(results, errorCount, warningCount, infoCount, unusedCode, unreachableCode, deprecated)`.
- Sample `.py` files use comments like `# This should generate an error` to document expected diagnostics, but the actual assertion is the count passed to `validateResults`.
**Fourslash tests** (`src/tests/fourslash/`):
- Simulate LSP interactions (completions, hover, go-to-definition, rename, etc.).
- Use `// @filename:` markers to define virtual files and `///` prefix for embedded Python content.
### Adding a Test
1. Create a `.py` sample file in `src/tests/samples/` following the naming pattern (e.g., `newFeature1.py`).
2. Add a test case in the appropriate `*.test.ts` file calling `typeAnalyzeSampleFiles` and `validateResults`.
3. Test files are split across `typeEvaluator1.test.ts` through `typeEvaluator8.test.ts` for parallel execution.
### Test Policy
Tests are the specification for Pyright behavior. Never modify tests just to make CI pass. Any change that makes types less precise (e.g., `T → Unknown`, `list[int] → list[Any]`, `Literal["x"] → str`) is a regression by default and requires explicit justification. See `.github/agents/pyright-test-policy.md` for details.
## Code Style
- **Formatting**: Prettier with 4-space indentation, single quotes, 120-char print width.
- **Private members**: Must have leading underscore (`_privateMethod`). Protected and public must not.
- **Class member order**: fields → constructor → public getters/setters → public methods → protected → private (enforced by ESLint).
- **Imports**: Sorted by `simple-import-sort` ESLint plugin.
- **No explicit `public`**: The `public` keyword is forbidden on class members (use implicit public).
- **Strict TypeScript**: `strict: true`, `noImplicitReturns`, `noImplicitOverride`, target ES2020.

View File

@@ -0,0 +1,126 @@
# FIX 11453 — No error on accessing `__qualname__` of an instance
## Status: ✅ Complete
Status: 🟢 Active — fix implemented, verified & reviewed; ready to commit (PR/archival pipeline-deferred)
Owner: PylanceFix/PylanceCode (fix-loop)
Branch: `fix11453`
Worktree: `C:\Users\rchiodo\.fix_loop\repos\microsoft__pyright\.worktrees_8765\fix11453`
## Context
- Issue: https://github.com/microsoft/pyright/issues/11453
- Title: "no error on accessing `__qualname__` of instance"
- Kind: bugfix
- User impact: Pyright/Pylance fails to report the expected "cannot access attribute" diagnostic when `__qualname__` is accessed on an **instance** (e.g. `SomeClass().__qualname__`). `__qualname__` is a class-level attribute (defined on `type`), not an instance attribute, so instance access should be flagged.
- Triage (PylanceTriage handoff): Verified defect. The binder injects an implicit `__qualname__` class member (including on `object`), so instance access resolves it and skips the expected "cannot access attribute" diagnostic.
### Non-goals
- Do not change behavior for **class-level** access (`SomeClass.__qualname__` must remain valid).
- Do not change `__name__`/`__doc__`/other dunder handling beyond what is strictly required for parity with the fix (verify before touching).
- No broad refactors of the binder or type evaluator.
## Constraints & policies
- This is a `microsoft/pyright` issue (worktree is the pyright repo). PR convention: "Fixes <full URL>".
- Keep diffs surgical; pyright core is upstream-owned.
- Test placement: add a pyright-internal regression test under `packages/pyright-internal/src/tests/` (sample `.py` + `validateResults` count, or fourslash if interaction-based). Follow existing `typeEvaluator*`/`checker` sample-test conventions.
- Do not reduce type precision elsewhere; the change must be narrowly scoped to instance access of `__qualname__`.
- Test policy: tests are the spec; new test must encode the expected diagnostic.
## Strategy
Phases (high level — verify file/function names before editing; these are hypotheses, not directives):
1. **Reproduce**: Write a minimal sample showing `instance.__qualname__` should error and `Class.__qualname__` should not. Confirm current behavior produces no diagnostic on the instance access.
2. **Locate root cause**: Per triage, an implicit `__qualname__` member is injected as a class member (hypothesis: in the binder, alongside other synthesized dunders, possibly applied to `object`/all classes). Verify where `__qualname__` becomes accessible on instances. Confirm whether it is the binder injection or member-access resolution that fails to treat it as class-only.
3. **Minimal fix**: Make `__qualname__` resolve only for class-object access, not instance access — mirroring how Python exposes it via `type` (class) rather than instances. Prefer the approach that keeps `Class.__qualname__` valid and only suppresses instance access.
4. **Validate**: Run the new regression test plus the relevant existing suites (`typeEvaluator*`, `checker`) to ensure no precision regressions.
Verification approach: sample-based test with `validateResults` expected error count; confirm class access stays clean.
## Acceptance Contract
1. **Observable change**: Accessing `__qualname__` on an instance is flagged with the expected "cannot access attribute" (reportAttributeAccessIssue) diagnostic, matching runtime behavior where instances do not expose `__qualname__`.
2. **Success criteria**:
- [ ] `instance.__qualname__` (e.g. `MyClass().__qualname__`) → reports an attribute-access error.
- [ ] `MyClass.__qualname__` (class-object access) → no error, type `str`.
3. **Regression guard**:
- [ ] Existing `__name__`/class dunder behavior unchanged.
- [ ] No new false positives in `typeEvaluator*` / `checker` suites.
4. **Scope boundary**: Only `__qualname__` instance-vs-class access semantics. No changes to unrelated dunders or to the binder's broader synthesized-member logic unless proven required.
## Work items
| # | Work item | Status | Owner | Exit criteria |
|---|-----------|--------|-------|---------------|
| 1 | Reproduce no-error-on-instance behavior | ✅ Done | impl | Confirmed current build emits no diagnostic for `instance.__qualname__` |
| 2 | Verify root cause (binder implicit `__qualname__` injection) | ✅ Done | impl | Located exact injection/resolution site; confirmed root cause |
| 3 | Implement minimal fix (class-only access) | ✅ Done | impl | `instance.__qualname__` errors; `Class.__qualname__` valid |
| 4 | Add regression test (pyright-internal) | ✅ Done | impl | New sample + `validateResults` asserts expected error/no-error counts |
| 5 | Run targeted + relevant existing suites | ✅ Done | impl | New test passes; no regressions in `typeEvaluator*`/`checker` |
| 6 | Format & lint | ✅ Done | impl | `npm run check` clean for changed files |
| 7 | Debugger verification | ✅ Done | impl | Breakpoint confirms changed code path exercised (or waiver recorded) |
| 8 | Impact follow-through | ✅ Done | impl | Blast-radius of `__qualname__` injection change assessed; no orphaned call sites |
| 9 | Test coverage sufficiency | ✅ Done | impl | Coverage verified against Acceptance Contract (instance error + class-access clean) |
| 10 | Full review freshness gate (code review loop) | ✅ Done | impl | Local adversarial_review (4-reviewer panel) on worktree: zero Critical/High defects; no code changes required |
| 11 | Create/update PR | ⏸️ Pipeline-deferred | pipeline | PR/push gated by pipeline permissions (fix-loop boundary) |
## Investigation log
- 2026-06-15: **Work item 1 (Reproduce) — DONE.** Updated existing sample `packages/pyright-internal/src/tests/samples/classes3.py` (which already documents this exact bug at the `instance.__qualname__` line) and bumped expected error count in `typeEvaluator3.test.ts` `Classes3` test 3 → 4. Test run RED as expected: "Expected 4 errors, got 3"; `instance.__qualname__` not flagged. Other 3 errors (`__dummy__`, `instance.__name__`, `self.__name__`) unchanged.
- 2026-06-15: **Work item 2 (Root cause) — DONE.** Verified via static analysis + CPython runtime check + in-repo test documentation.
- Injection site: `binder.ts` ~line 510 `this._addImplicitSymbolToCurrentScope('__qualname__', node, 'str')` injects `__qualname__` into every class scope's symbol table.
- Because the scope is a Class scope, `_addSymbolToCurrentScope` sets `SymbolFlags.ClassMember`. `getClassMemberIterator` (`typeUtils.ts` ~line 1880) yields any symbol with `isClassMember()`, so instance member access finds `__qualname__` and skips the expected "cannot access attribute" diagnostic.
- Why injected at all: `__qualname__` must be name-resolvable inside a class body (`print(__qualname__)`), like `__doc__`/`__module__`. Unlike those, `__qualname__` is NOT a valid instance/class-dict attribute at runtime.
- CPython evidence: `A().__qualname__` → AttributeError even when `__qualname__='custom'` is assigned in the class body; `__qualname__` never in `B.__dict__`. Metaclass `type` defines `__qualname__: str` and `__name__: str`, so `Class.__qualname__` resolves via the metaclass regardless of the binder injection.
- 2026-06-15: **Work item 7 (Debugger verification) — DONE** via `_DebuggerInvestigation`. Confirmed at runtime the implicit `__qualname__` symbol in `TestClass` has `isClassMember()=true`, `isInstanceMember()=false` (raw flags 68 = ClassMember|IgnoredForProtocolMatch), single Intrinsic("str") decl; `__name__` is absent from the class symbol table. Confirmed `getClassMemberIterator` (`typeUtils.ts` ~L1883) yields it on instance access, suppressing the error. Root cause confirmed exactly as hypothesized.
- 2026-06-15: **Work items 36, 8 — DONE.**
- **Fix (item 3)** in `binder.ts`: `_addImplicitSymbolToCurrentScope(name, node, type, isClassMember = true)` threads a new optional param to `_addSymbolToCurrentScope(name, isInitiallyUnbound, isClassMember = true)`, which now only sets `SymbolFlags.ClassMember` when scope is Class AND `isClassMember`. The `__qualname__` class-scope injection passes `/* isClassMember */ false` (with explanatory comment); `__doc__`/`__module__` unchanged.
- **Regression test (item 4)**: `classes3.py` marks `instance.__qualname__` as expected error; `typeEvaluator3` `Classes3` count 3→4. Added `reveal_type(qualname, expected_text="str")` precision guard, plus new `completions.qualname.fourslash.ts` (instance excludes `__qualname__`, includes `__doc__`/`__module__`; class includes `__qualname__`).
- **Tests (item 5)**: Classes3 green; full `typeEvaluator1-8` + `checker.test` = 9 suites / 1234 tests pass; new fourslash test passes; fourslash completions/hover 333/333 pass.
- **Format & lint (item 6)**: prettier --check clean on changed TS; eslint (ESLINT_USE_FLAT_CONFIG=false) exit 0, no errors.
- **Impact follow-through (item 8)** via `_PylanceImpactFollowThrough`: gaps-fixed; H1H7 processed (instance error, class precision str, instance/class completion surfaces tested; protocol/function/metaclass paths waived with evidence). No remaining actionable gaps.
- 2026-06-15: **Work item 9 (Test coverage sufficiency) — DONE** via `_PylanceTestCoverage` adversarial panel. Filled high/medium gaps in `classes3.py`:
- Subclass: `Sub(TestClass)``Sub.__qualname__` reveals `str`; `Sub().__qualname__` errors (MRO does not surface base's non-member `__qualname__`).
- Nested/inner class: `Outer.Inner` body `print(__qualname__)` resolves; `Inner.__qualname__` reveals `str`; `Outer.Inner().__qualname__` errors.
- Generic class-object: in `func1(cls: type[_T])`, `cls.__qualname__` reveals `str`.
- Bumped `typeEvaluator3` `Classes3` expected error count 4 → 6; re-ran PASS (all 6 errors + `reveal_type` str guards). Low-priority metaclass/dataclass case deemed sufficiently covered by the general member-access mechanism.
- 2026-06-15: **Work item 10 (Code review loop) — DONE.** Review Center (`_PylanceChangeReview`) is bound to the pyrx repo and cannot review this standalone pyright worktree, so ran the local `adversarial_review` tool (advocate/skeptic/architect/rules panel) on the worktree.
- **Outcome: zero Critical/High code defects.** All four reviewers endorsed the fix as a precise, root-cause fix (binder injection) with strong test coverage. No code changes required.
- Findings (all non-actionable for code):
- [issue] "Plan still active in `.github/plans/` — archive before merge." NOT actionable here: per fix-loop pipeline boundary, the pipeline owns plan archival/PR; impl must not archive or push. Pipeline-deferred.
- [warning] "post-archive `npm run fix:files`" — tied to archival; pipeline-handled.
- [info] Obscure edge: `self.__qualname__ = x` / `cls.__qualname__ = x` member-assignment in a method can re-stamp ClassMember via `_getMemberAccessInfo`. Out of scope — and `self.__qualname__ = x` SETS a real instance attribute at runtime, so resolving is correct there. Left as-is.
- [info] Comment could mention `getClassMemberIterator` gates on `isClassMember()` — existing comment already explains the why; acceptable.
- [info] Could add in-class-body completion marker — already covered by `print(__qualname__)` resolution in the nested-class sample.
- [info] Audit direct symbol-table iterators — covered by green typeEvaluator1-8 + checker (1234 tests) and fourslash completions/hover (333 tests); repo-wide grep shows only `classes3.py` references instance `__qualname__`.
- Verified binder.ts change is present (line 517 `__qualname__` injected with `isClassMember=false`); reviewer's "pre-fix" note was confusion with a separate pyrx mirror checkout. `git diff --stat` confirms `binder.ts` + `classes3.py` + `typeEvaluator3.test.ts` modified (+ new untracked fourslash test).
- Decision: No code changes required from review. Proceeding to commit (AUTO_DRIVE_GIT=true). Push/PR (item 11) + plan archival remain pipeline-gated per fix-loop boundary.
## Root cause (verified)
The binder unconditionally injects an implicit `__qualname__` symbol into each class scope's symbol table (`binder.ts` ~L510). In a Class scope, `_addSymbolToCurrentScope` stamps it with `SymbolFlags.ClassMember`. Instance member-access resolution (`getClassMemberIterator`, `typeUtils.ts` ~L1880) treats any `isClassMember()` symbol as accessible, so `instance.__qualname__` resolves to `str` and the expected "cannot access attribute" diagnostic is suppressed. At runtime, `__qualname__` is exposed only via the metaclass `type` (so `Class.__qualname__` works) and never as an instance attribute.
## Decisions
- 2026-06-15: Adopt class-only access semantics for `__qualname__` (instance access should error), consistent with CPython where `__qualname__` is exposed via `type`, not instances.
- 2026-06-15: **Planned fix** — make the binder's implicit `__qualname__` symbol scope-only by omitting the `ClassMember` flag, so it remains name-resolvable inside the class body but is not exposed as a class/instance member. `Class.__qualname__` still resolves via metaclass `type.__qualname__: str`; `instance.__qualname__` now errors like `__name__`. Implement via an optional param on `_addImplicitSymbolToCurrentScope` / `_addSymbolToCurrentScope` to suppress the `ClassMember` flag. Change isolated to `__qualname__` only — NOT `__doc__`/`__module__` (which are legitimately instance-accessible).
## Risks / unknowns
- Risk: `__qualname__` may be needed on class objects in some synthesized contexts (e.g. functions/methods also have `__qualname__`). Ensure the fix does not break `function.__qualname__` or `Class.__qualname__`.
- Unknown: exact location and mechanism of the implicit injection (binder vs synthesized-type members vs `object` stub). Verify before editing.
- Risk: Over-broad fix could newly flag legitimate dunder access elsewhere → mitigate with focused test + full suite run.
## Learnings
- (to capture) Where pyright synthesizes/injects class-only dunders and how instance-vs-class member access is distinguished.
- 2026-06-15: Implicit class-scope dunders that are metaclass-only (e.g. `__qualname__`) must be injected WITHOUT `SymbolFlags.ClassMember` so they stay name-resolvable in the class body while being excluded from instance/class member access and completions. `__doc__`/`__module__` are legitimately instance-accessible and keep the flag.
## Next steps
1. impl: Commit the change on branch `fix11453` (AUTO_DRIVE_GIT=true).
2. pipeline: Create/update PR (work item 11) — gated on push/PR permissions.
3. pipeline: Archive plan + run `npm run fix:files` post-archival per fix-loop boundary.

69
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,69 @@
name: 'Build'
env:
NODE_VERSION: '22.x' # Shipped with VS Code.
ARTIFACT_NAME_VSIX: vsix
VSIX_NAME: vscode-pyright.vsix
on:
push:
tags:
- '1.1.[0-9][0-9][0-9]'
jobs:
build:
if: github.repository == 'microsoft/pyright'
runs-on: ubuntu-latest
name: Build
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- uses: ./.github/actions/npm-cache-dir
- run: npm run install:all
- name: Build VSIX
working-directory: packages/vscode-pyright
run: |
npm run package
mv pyright-*.vsix ${{ env.VSIX_NAME }}
- uses: actions/upload-artifact@v4
with:
name: ${{ env.ARTIFACT_NAME_VSIX }}
path: packages/vscode-pyright/${{ env.VSIX_NAME }}
create_release:
if: github.repository == 'microsoft/pyright'
runs-on: ubuntu-latest
name: Create release
needs: [build]
permissions:
contents: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
# TODO: If the release already exists (tag created via the GUI), reuse it.
- name: Create release
id: create_release
uses: ncipollo/release-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: Published ${{ github.ref_name }}
draft: true
artifacts: ./artifacts/${{ env.ARTIFACT_NAME_VSIX }}/${{ env.VSIX_NAME }}
artifactContentType: application/zip

View File

@@ -0,0 +1,104 @@
# This workflow runs when the "Run mypy_primer on PR" workflow completes.
# It downloads the diff from the other workflow instances and creates
# a summary comment in the PR.
name: Comment with mypy_primer diff
on:
workflow_run:
workflows:
- Run mypy_primer on PR
types:
- completed
permissions:
contents: read
pull-requests: write
jobs:
comment:
name: Comment PR from mypy_primer
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Download diffs
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: ${{ github.event.workflow_run.id }},
});
const matchedArtifacts = artifacts.data.artifacts.filter((artifact) =>
artifact.name.startsWith("mypy_primer_diffs"));
for (let i = 0; i < matchedArtifacts.length; i++) {
const matchArtifact = matchedArtifacts[i];
const download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: "zip",
});
fs.writeFileSync(`diff_${i}.zip`, Buffer.from(download.data));
}
- run: unzip diff_\*.zip
- run: |
cat diff_*.txt | tee fulldiff.txt
- name: Post comment
id: post-comment
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const MAX_CHARACTERS = 30000
const MAX_CHARACTERS_PER_PROJECT = MAX_CHARACTERS / 3
const fs = require('fs')
let data = fs.readFileSync('fulldiff.txt', { encoding: 'utf8' })
function truncateIfNeeded(original, maxLength) {
if (original.length <= maxLength) {
return original
}
let truncated = original.substring(0, maxLength)
// further, remove last line that might be truncated
truncated = truncated.substring(0, truncated.lastIndexOf('\n'))
let lines_truncated = original.split('\n').length - truncated.split('\n').length
return `${truncated}\n\n... (truncated ${lines_truncated} lines) ...`
}
const projects = data.split('\n\n')
// don't let one project dominate
data = projects.map(project => truncateIfNeeded(project, MAX_CHARACTERS_PER_PROJECT)).join('\n\n')
// posting comment fails if too long, so truncate
data = truncateIfNeeded(data, MAX_CHARACTERS)
console.log("Diff from mypy_primer:")
console.log(data)
let body
if (data.trim()) {
body = 'Diff from [mypy_primer](https://github.com/hauntsaninja/mypy_primer), showing the effect of this PR on open source code:\n```diff\n' + data + '```'
} else {
body = "According to [mypy_primer](https://github.com/hauntsaninja/mypy_primer), this change doesn't affect type check results on a corpus of open source code. ✅"
}
const prNumber = parseInt(fs.readFileSync("pr_number.txt", { encoding: "utf8" }))
await github.rest.issues.createComment({
issue_number: prNumber,
owner: context.repo.owner,
repo: context.repo.repo,
body
})
return prNumber
- name: Hide old comments
# v0.4.0
uses: kanga333/comment-hider@c12bb20b48aeb8fc098e35967de8d4f8018fffdf
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
leave_visible: 1
issue_number: ${{ steps.post-comment.outputs.result }}

122
.github/workflows/mypy_primer_pr.yaml vendored Normal file
View File

@@ -0,0 +1,122 @@
# This workflow runs mypy_primer, a tool that runs pyright on a variety
# of open-source Python projects that are known to type check with pyright.
# It builds pyright from the latest PR commit and the merge base of the PR
# and compares the output of both. It uploads the diffs as an artifact and
# creates a PR comment with the results (with the help of the
# mypy_primer_comment action).
# This workflow definition borrows liberally from the mypy repo. The original
# workflow was designed to work in a sharded manner where n copies of
# mypy_primer are started in parallel. Each instance runs 1/n of the projects.
# For now, we run only one instance because pyright is fast, and the number
# of projects that use pyright for type checking is small. To change this in
# the future, change the 'shard_index' matrix to [0, 1, ..., n-1] and set
# 'num-shards' to n.
name: Run mypy_primer on PR
env:
NODE_VERSION: '22.x' # Shipped with VS Code.
on:
# Run on the creation or update of a PR.
pull_request:
paths:
- 'packages/pyright/**'
- 'packages/pyright-internal/src/**'
- 'packages/pyright-internal/typeshed-fallback/**'
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
mypy_primer:
name: Run mypy_primer on PR
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
matrix:
shard-index: [0, 1, 2, 3, 4, 5, 6, 7]
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
path: pyright_to_test
fetch-depth: 2
fetch-tags: false
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: 'pyright_to_test/**/package-lock.json'
- name: Install dependencies
run: |
python -m pip install -U pip
pip install git+https://github.com/hauntsaninja/mypy_primer.git
- name: Run mypy_primer
shell: bash
env:
# mypy_primer installs both the PR and base commits. The base commit can contain
# historical peer dependency conflicts that should not block primer comparisons.
NPM_CONFIG_LEGACY_PEER_DEPS: 'true'
run: |
cd pyright_to_test
echo "new commit"
git rev-list --format=%s --max-count=1 $GITHUB_SHA
git branch new_commit $GITHUB_SHA
MERGE_BASE=$(git rev-parse "$GITHUB_SHA^1")
git checkout -b base_commit $MERGE_BASE
echo "base commit"
git rev-list --format=%s --max-count=1 base_commit
# Keep the old checker source at the merge base, but use this PR's
# dependency and bundler metadata so the old checkout can install and build.
mapfile -t BASE_BUILD_FILES < <(
git ls-tree -r --name-only "$GITHUB_SHA" |
grep -E '^(package(-lock)?\.json|packages/[^/]+/package(-lock)?\.json|packages/[^/]+/rspack\.config\.js)$'
)
echo "Using build metadata for mypy_primer base:"
printf '%s\n' "${BASE_BUILD_FILES[@]}"
git checkout $GITHUB_SHA -- "${BASE_BUILD_FILES[@]}"
printf 'legacy-peer-deps=true\n' > .npmrc
git add .npmrc "${BASE_BUILD_FILES[@]}"
git config user.name github-actions[bot]
git config user.email 41898282+github-actions[bot]@users.noreply.github.com
git commit -m "Configure build dependencies for mypy_primer base"
echo "Prepared mypy_primer base_commit with generated package and rspack build metadata."
echo ''
cd ..
npm config set legacy-peer-deps true --location=user
npm config get legacy-peer-deps
# fail action if exit code isn't zero or one
(
mypy_primer \
--repo pyright_to_test \
--type-checker pyright \
--new new_commit --old base_commit \
--num-shards 8 --shard-index ${{ matrix.shard-index }} \
--debug \
--output concise \
| tee diff_${{ matrix.shard-index }}.txt
) || [ $? -eq 1 ]
- name: Upload mypy_primer diff
uses: actions/upload-artifact@v4
with:
name: mypy_primer_diffs_${{ matrix.shard-index }}
path: diff_${{ matrix.shard-index }}.txt
- if: ${{ matrix.shard-index == 0 }}
name: Save PR number
run: |
echo ${{ github.event.pull_request.number }} | tee pr_number.txt
- if: ${{ matrix.shard-index == 0 }}
name: Upload PR number
uses: actions/upload-artifact@v4
with:
name: mypy_primer_diffs_pr_number
path: pr_number.txt

79
.github/workflows/mypy_primer_push.yaml vendored Normal file
View File

@@ -0,0 +1,79 @@
# This workflow runs mypy_primer, a tool that runs pyright on a variety
# of open-source Python projects that are known to type check with pyright.
# It builds pyright from the latest commit and the last release tag and
# compares the output of both. It uploads the diffs as an artifact.
name: Run mypy_primer on push
env:
NODE_VERSION: '22.x' # Shipped with VS Code.
on:
# Run on all pushes to main.
push:
branches:
- main
paths:
- 'packages/pyright/**'
- 'packages/pyright-internal/src/**'
- 'packages/pyright-internal/typeshed-fallback/**'
# Also run manually if requested.
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
jobs:
mypy_primer:
name: Run mypy_primer on push
runs-on: ubuntu-latest
permissions:
contents: read
strategy:
fail-fast: false
steps:
- uses: actions/checkout@v4
with:
path: pyright_to_test
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: 'pyright_to_test/**/package-lock.json'
- name: Install dependencies
run: |
python -m pip install -U pip
pip install git+https://github.com/hauntsaninja/mypy_primer.git
- name: Run mypy_primer
shell: bash
env:
# mypy_primer installs both the new and old commits. The old commit can contain
# historical peer dependency conflicts that should not block primer comparisons.
NPM_CONFIG_LEGACY_PEER_DEPS: 'true'
run: |
cd pyright_to_test
echo "new commit"
git rev-list --format=%s --max-count=1 $GITHUB_SHA
cd ..
npm config set legacy-peer-deps true --location=user
npm config get legacy-peer-deps
# fail action if exit code isn't zero or one
(
mypy_primer \
--repo pyright_to_test \
--type-checker pyright \
--new $GITHUB_SHA \
--debug \
--output concise \
| tee diff.txt
) || [ $? -eq 1 ]
- name: Upload mypy_primer diff
uses: actions/upload-artifact@v4
with:
name: mypy_primer_diffs
path: diff.txt

166
.github/workflows/validation.yml vendored Normal file
View File

@@ -0,0 +1,166 @@
name: 'Validation'
env:
NODE_VERSION: '22.x' # Shipped with VS Code.
PYTHON_VERSION: 3.11
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
typecheck:
if: github.repository == 'microsoft/pyright'
runs-on: ubuntu-latest
name: Typecheck
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- uses: ./.github/actions/npm-cache-dir
- run: npm run install:all
- run: npx lerna exec --stream --no-bail -- "tsc --noEmit"
style:
if: github.repository == 'microsoft/pyright'
runs-on: ubuntu-latest
name: Style
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- uses: ./.github/actions/npm-cache-dir
- run: npm run install:all
- name: Check diff after npm install
run: git diff --exit-code --name-only
- run: npm run check
test:
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
name: Test ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: typecheck
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- uses: ./.github/actions/npm-cache-dir
- run: npm run install:all
- name: npm test (pyright-internal)
run: npm test
working-directory: packages/pyright-internal
# Install python so we can create a VENV for tests
- name: Use Python ${{env.PYTHON_VERSION}}
uses: actions/setup-python@v5
id: install_python
with:
python-version: ${{env.PYTHON_VERSION}}
- name: Create Venv
run: |
${{ steps.install_python.outputs.python-path }} -m venv .venv
- name: Activate and install pytest (linux)
if: runner.os != 'Windows'
run: |
source .venv/bin/activate
python -m pip install pytest
python -c "import sys;print('python_venv_path=' + sys.executable)" >> $GITHUB_ENV
- name: Activate and install pytest (windows)
if: runner.os == 'Windows'
run: |
.venv\scripts\activate
python -m pip install pytest
python -c "import sys;print('python_venv_path=' + sys.executable)" | Out-File -FilePath $env:GITHUB_ENV -Append
- name: Echo python_venv_path
run: |
echo python_venv_path=${{env.python_venv_path}}
- name: Run import tests with venv
env:
CI_IMPORT_TEST_VENVPATH: '../../'
CI_IMPORT_TEST_VENV: '.venv'
run: npm run test:imports
working-directory: packages/pyright-internal
- name: Run import tests with pythonpath
env:
CI_IMPORT_TEST_PYTHONPATH: ${{env.python_venv_path}}
run: npm run test:imports
working-directory: packages/pyright-internal
build:
runs-on: ubuntu-latest
name: Build
needs: typecheck
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
- uses: ./.github/actions/choose-npm-install
- run: npm publish --dry-run
working-directory: packages/pyright
- run: npm publish --dry-run
working-directory: packages/pyright-typeserver
- run: npm run package
working-directory: packages/vscode-pyright
required:
runs-on: ubuntu-latest
name: Required
needs:
- typecheck
- style
- test
- build
steps:
- run: echo All required jobs succeeded.