Skip to content

Commit e465e3c

Browse files
committed
cleanup: simplify comments and update docs
1 parent 9f20b46 commit e465e3c

5 files changed

Lines changed: 22 additions & 15 deletions

File tree

.github/instructions/generic.instructions.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ Provide project context and coding guidelines that AI should follow when generat
4444
- When using `getConfiguration().inspect()`, always pass a scope/Uri to `getConfiguration(section, scope)` — otherwise `workspaceFolderValue` will be `undefined` because VS Code doesn't know which folder to inspect (1)
4545
- **path.normalize() vs path.resolve()**: On Windows, `path.normalize('\test')` keeps it as `\test`, but `path.resolve('\test')` adds the current drive → `C:\test`. When comparing paths, use `path.resolve()` on BOTH sides or they won't match (2)
4646
- **Path comparisons vs user display**: Use `normalizePath()` from `pathUtils.ts` when comparing paths or using them as map keys, but preserve original paths for user-facing output like settings, logs, and UI (1)
47-
- **Test settings must be set PROGRAMMATICALLY**: Smoke/E2E/integration tests require `python.useEnvironmentsExtension` to be true. Settings.json files alone are unreliable because installed extensions (like ms-python.python) may override with defaults. Use `initializeTestSettings()` from `src/test/initialize.ts` in `suiteSetup()` BEFORE activating the extension — this follows the vscode-python pattern (2)
47+
- **CI test jobs need webpack build**: Smoke/E2E/integration tests run in a real VS Code instance against `dist/extension.js` (built by webpack). CI jobs must run `npm run compile` (webpack), not just `npm run compile-tests` (tsc). Without webpack, the extension code isn't built and tests run against stale/missing code (1)
48+
- **Use inspect() for setting checks with defaults from other extensions**: When checking `python.useEnvironmentsExtension`, use `config.inspect()` and only check explicit user values (`globalValue`, `workspaceValue`, `workspaceFolderValue`). Ignore `defaultValue` as it may come from other extensions' package.json even when not installed (1)
4849
- **API is flat, not nested**: Use `api.getEnvironments()`, NOT `api.environments.getEnvironments()`. The extension exports a flat API object (1)
4950
- **PythonEnvironment has `envId`, not `id`**: The environment identifier is `env.envId` (a `PythonEnvironmentId` object with `id` and `managerId`), not a direct `id` property (1)

.github/skills/run-e2e-tests/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ E2E tests have system requirements:
7373

7474
- **Python installed** - At least one Python interpreter must be discoverable
7575
- **Extension builds** - Run `npm run compile` before tests
76-
- **Test settings** - Tests call `initializeTestSettings()` in `suiteSetup()` to configure `python.useEnvironmentsExtension: true` before activation
76+
- **CI needs webpack build** - Run `npm run compile` (webpack) before tests, not just `npm run compile-tests` (tsc)
7777

7878
## Adding New E2E Tests
7979

.github/skills/run-integration-tests/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ suite('Integration: [Component A] + [Component B]', function () {
102102

103103
## Prerequisites
104104

105-
- **Test settings** - Tests call `initializeTestSettings()` in `suiteSetup()` to configure `python.useEnvironmentsExtension: true` before activation
105+
- **CI needs webpack build** - Run `npm run compile` (webpack) before tests, not just `npm run compile-tests` (tsc)
106106
- **Extension builds** - Run `npm run compile` before tests
107107

108108
## Notes

.github/skills/run-smoke-tests/SKILL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ suite('Smoke: [Feature Name]', function () {
117117

118118
## Prerequisites
119119

120-
- **Test settings must be set PROGRAMMATICALLY**: Tests call `initializeTestSettings()` from `src/test/initialize.ts` in `suiteSetup()` to set `python.useEnvironmentsExtension: true` before extension activation. This follows the vscode-python pattern and is more reliable than static settings.json files
120+
- **CI needs webpack build**: The extension must be built with `npm run compile` (webpack) before tests run. The test runner uses `dist/extension.js` which is only created by webpack, not by `npm run compile-tests` (tsc)
121121
- **Extension builds**: Run `npm run compile` before tests
122122

123123
## Notes

src/extension.ts

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
1-
import { commands, ExtensionContext, extensions, l10n, LogOutputChannel, ProgressLocation, Terminal, Uri, window } from 'vscode';
1+
import {
2+
commands,
3+
ExtensionContext,
4+
extensions,
5+
l10n,
6+
LogOutputChannel,
7+
ProgressLocation,
8+
Terminal,
9+
Uri,
10+
window,
11+
} from 'vscode';
212
import { PythonEnvironment, PythonEnvironmentApi, PythonProjectCreator } from './api';
313
import { ENVS_EXTENSION_ID } from './common/constants';
414
import { ensureCorrectVersion } from './common/extVersion';
@@ -87,18 +97,14 @@ import { registerPoetryFeatures } from './managers/poetry/main';
8797
import { registerPyenvFeatures } from './managers/pyenv/main';
8898

8999
export async function activate(context: ExtensionContext): Promise<PythonEnvironmentApi | undefined> {
90-
// Use inspect() to check if the user has EXPLICITLY disabled this extension.
91-
// Only skip activation if someone explicitly set useEnvironmentsExtension to false.
92-
// This ignores defaultValues from other extensions' package.json and defaults to
93-
// activating the extension if no explicit setting exists.
100+
// Only skip activation if user explicitly set useEnvironmentsExtension to false
94101
const config = getConfiguration('python');
95102
const inspection = config.inspect<boolean>('useEnvironmentsExtension');
96-
97-
// Check for explicit false values (user deliberately disabled the extension)
98-
const explicitlyDisabled = inspection?.globalValue === false ||
99-
inspection?.workspaceValue === false ||
100-
inspection?.workspaceFolderValue === false;
101-
103+
const explicitlyDisabled =
104+
inspection?.globalValue === false ||
105+
inspection?.workspaceValue === false ||
106+
inspection?.workspaceFolderValue === false;
107+
102108
const useEnvironmentsExtension = !explicitlyDisabled;
103109
traceInfo(`Experiment Status: useEnvironmentsExtension setting set to ${useEnvironmentsExtension}`);
104110
if (!useEnvironmentsExtension) {

0 commit comments

Comments
 (0)