You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit e4f9939
Browse filesBrowse the repository at this point in the historyBrowse files
Keep PEP 723 inline script CodeLens live and persistent (#1906)
## Summary
- Keep the setup CodeLens available whenever a recognizable PEP 723
script block exists, including incomplete or malformed live edits.
- Keep `Script environment ready (Python X.Y.Z)` persistent for
validated, available script environments.
- Re-evaluate unsaved metadata edits immediately while preserving Ready
and exact-file routing for body-only edits.
- Prevent pending saved-metadata reads from restoring stale routing
after a live metadata edit.
- Validate malformed metadata when setup is invoked, preserving
diagnostics and avoiding invalid environment associations.
- Harden setup, save, cache-repair, and stale-operation behavior and
document the updated user flow.
- Add focused parser, routing, CodeLens, detector, setup, manager, and
real VS Code integration coverage.
## Validation
- `npm run lint`
- `npm run compile-tests`
- `npm run unittest` — 2,812 passing, 7 pending after rebasing onto the
latest `main`
- Production webpack build
- Inline VS Code integration — 8 passing
- Real-environment PEP 723 workflows — 21 passing
- Smoke suite — 31 passing
- Environment discovery E2E — 4 passing
- Manual Windows VS Code Insiders testbed matrix covering setup,
persistent Ready, live edits, Undo/Revert, malformed metadata,
diagnostics, quick fixes, Run File, Pylance routing, cache repair,
restart persistence, and feature-off behavior
- Static core, additional-use-case, quick-fix, and 8-KiB boundary
verification
## Notes
The tolerant block detector is presentation-only. Semantic parsing
remains authoritative for diagnostics, setup eligibility, environment
identity, persistence, and exact-file routing.
A separate full integration run completed with 57 passing and 8 pending
tests plus one existing environment-creation timeout. The timed-out
fixture selects the system manager, which cannot quick-create
headlessly; instrumentation confirmed it does not enter the PEP 723
path.
---------
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copy file name to clipboardExpand all lines: .github/instructions/testing-workflow.instructions.md
+1Lines changed: 1 addition & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,7 @@ This guide covers the full testing lifecycle:
21
21
- Pip commands that return JSON must pass `--disable-pip-version-check`; the process helper combines stderr with stdout, so update notices can otherwise make valid JSON unparseable (1).
22
22
- When a view subscribes to a newly added provider event, TypeMoq-based view tests must return a real `EventEmitter.event`; an unstubbed event yields an undefined disposable and fails during teardown (1).
23
23
- Test agent selections across a full reload with `python.defaultInterpreterPath` set. An effective manager value equal to the extension default does not prove a workspace value was saved; tool-owned persistence must inspect `workspaceValue` or startup can restore the global interpreter (1).
24
+
-`vscode.executeCodeLensProvider` verifies provider output, not visible editor refresh. VS Code cancels its debounced CodeLens refresh when the editor loses focus; account for background UI automation restoring focus to another app before diagnosing a stale rendered lens (1).
Copy file name to clipboardExpand all lines: docs/managing-python-projects.md
+3-1Lines changed: 3 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -101,7 +101,9 @@ When you create a script, the extension generates a single `.py` file with PEP 7
101
101
102
102
An inline-script environment is built from the script's `# /// script` block and stored in the extension's cache, where it is shared by every script with the same dependencies and base interpreter. Because editing one would silently change the others, these environments are not user-managed: the Python Environments views do not offer install, uninstall, or version-change actions for them. Their package list remains visible.
103
103
104
-
A CodeLens above the `# /// script` block offers **Set up environment for this script**, and the same action is available as a quick fix on an unresolved import. For a few seconds after setup succeeds it is replaced by a **Script environment ready (Python X.Y.Z)** confirmation naming the Python that was selected — useful when `requires-python` matches several installed versions, or when one was installed on demand. The confirmation is plain text rather than a clickable action, and it expires on its own; at every other time the setup CodeLens behaves exactly as before.
104
+
A CodeLens stays above the `# /// script` block, including while its metadata is incomplete, malformed, or unsaved. It offers **Set up environment for this script** until the block matches a validated environment, then displays **Script environment ready (Python X.Y.Z)** as persistent, non-clickable text. The ready label also appears for environments restored after reopening VS Code.
105
+
106
+
The CodeLens follows the live block text: editing the block offers setup immediately without requiring a save, while editing Python code outside it does not change its fingerprint. Diagnostics continue to explain malformed metadata as you type; a warning popup appears only if you try to set up an invalid block. Setup saves valid unsaved changes before creating the environment. Execution and interpreter routing still use validated, saved metadata, and saving can restore a matching existing association without rebuilding it.
105
107
106
108
Setup records which distributions it installed. If that record and the environment's contents later disagree — for example after installing a package into it from a terminal — every script sharing the environment needs setup again. Saving or reopening a script does not repair it; use the script's setup action to rebuild from its declared dependencies.
0 commit comments