Skip to content

Commit a00d42c

Browse files
committed
Merge branch 'kinto/disable-with-pyrefly' of github.com:kinto0/vscode-python into kinto/disable-with-pyrefly
2 parents e11009d + c31fd31 commit a00d42c

File tree

4 files changed

+11
-42
lines changed

4 files changed

+11
-42
lines changed

src/client/envExt/api.legacy.ts

+2-32
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// Copyright (c) Microsoft Corporation. All rights reserved.
22
// Licensed under the MIT License.
33

4-
import { Terminal, Uri, WorkspaceFolder } from 'vscode';
4+
import { Terminal, Uri } from 'vscode';
55
import { getEnvExtApi, getEnvironment } from './api.internal';
66
import { EnvironmentType, PythonEnvironment as PythonEnvironmentLegacy } from '../pythonEnvironments/info';
77
import { PythonEnvironment, PythonTerminalOptions } from './types';
88
import { Architecture } from '../common/utils/platform';
99
import { parseVersion } from '../pythonEnvironments/base/info/pythonVersion';
1010
import { PythonEnvType } from '../pythonEnvironments/base/info';
11-
import { traceError, traceInfo } from '../logging';
11+
import { traceError } from '../logging';
1212
import { reportActiveInterpreterChanged } from '../environmentApi';
1313
import { getWorkspaceFolder, getWorkspaceFolders } from '../common/vscodeApis/workspaceApis';
1414

@@ -120,36 +120,6 @@ export async function getActiveInterpreterLegacy(resource?: Uri): Promise<Python
120120
return pythonEnv ? toLegacyType(pythonEnv) : undefined;
121121
}
122122

123-
export async function ensureEnvironmentContainsPythonLegacy(
124-
pythonPath: string,
125-
workspaceFolder: WorkspaceFolder | undefined,
126-
callback: () => void,
127-
): Promise<void> {
128-
const api = await getEnvExtApi();
129-
const pythonEnv = await api.resolveEnvironment(Uri.file(pythonPath));
130-
if (!pythonEnv) {
131-
traceError(`EnvExt: Failed to resolve environment for ${pythonPath}`);
132-
return;
133-
}
134-
135-
const envType = toEnvironmentType(pythonEnv);
136-
if (envType === EnvironmentType.Conda) {
137-
const packages = await api.getPackages(pythonEnv);
138-
if (packages && packages.length > 0 && packages.some((pkg) => pkg.name.toLowerCase() === 'python')) {
139-
return;
140-
}
141-
traceInfo(`EnvExt: Python not found in ${envType} environment ${pythonPath}`);
142-
traceInfo(`EnvExt: Installing Python in ${envType} environment ${pythonPath}`);
143-
await api.installPackages(pythonEnv, ['python']);
144-
previousEnvMap.set(workspaceFolder?.uri.fsPath || '', pythonEnv);
145-
reportActiveInterpreterChanged({
146-
path: pythonPath,
147-
resource: workspaceFolder,
148-
});
149-
callback();
150-
}
151-
}
152-
153123
export async function setInterpreterLegacy(pythonPath: string, uri: Uri | undefined): Promise<void> {
154124
const api = await getEnvExtApi();
155125
const pythonEnv = await api.resolveEnvironment(Uri.file(pythonPath));

src/client/interpreter/interpreterService.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ import {
4545
} from '../pythonEnvironments/base/locator';
4646
import { sleep } from '../common/utils/async';
4747
import { useEnvExtension } from '../envExt/api.internal';
48-
import { ensureEnvironmentContainsPythonLegacy, getActiveInterpreterLegacy } from '../envExt/api.legacy';
48+
import { getActiveInterpreterLegacy } from '../envExt/api.legacy';
4949

5050
type StoredPythonEnvironment = PythonEnvironment & { store?: boolean };
5151

@@ -290,9 +290,6 @@ export class InterpreterService implements Disposable, IInterpreterService {
290290
@cache(-1, true)
291291
private async ensureEnvironmentContainsPython(pythonPath: string, workspaceFolder: WorkspaceFolder | undefined) {
292292
if (useEnvExtension()) {
293-
await ensureEnvironmentContainsPythonLegacy(pythonPath, workspaceFolder, () => {
294-
this.didChangeInterpreterEmitter.fire(workspaceFolder?.uri);
295-
});
296293
return;
297294
}
298295

src/client/terminals/envCollectionActivation/service.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,9 @@ export class TerminalEnvVarCollectionService implements IExtensionActivationServ
221221
env.PS1 = await this.getPS1(shell, resource, env);
222222
const defaultPrependOptions = await this.getPrependOptions();
223223

224-
const deactivate = await this.terminalDeactivateService.getScriptLocation(shell, resource);
225224
// Clear any previously set env vars from collection
226225
envVarCollection.clear();
227-
226+
const deactivate = await this.terminalDeactivateService.getScriptLocation(shell, resource);
228227
Object.keys(env).forEach((key) => {
229228
if (shouldSkip(key)) {
230229
return;

src/client/terminals/envCollectionActivation/shellIntegrationService.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { IDisposableRegistry, IPersistentStateFactory } from '../../common/types
1515
import { sleep } from '../../common/utils/async';
1616
import { traceError, traceVerbose } from '../../logging';
1717
import { IShellIntegrationDetectionService } from '../types';
18+
import { isTrusted } from '../../common/vscodeApis/workspaceApis';
1819

1920
/**
2021
* This is a list of shells which support shell integration:
@@ -151,10 +152,12 @@ export class ShellIntegrationDetectionService implements IShellIntegrationDetect
151152
* Creates a dummy terminal so that we are guaranteed a data write event for this shell type.
152153
*/
153154
private createDummyHiddenTerminal(shell: string) {
154-
this.terminalManager.createTerminal({
155-
shellPath: shell,
156-
hideFromUser: true,
157-
});
155+
if (isTrusted()) {
156+
this.terminalManager.createTerminal({
157+
shellPath: shell,
158+
hideFromUser: true,
159+
});
160+
}
158161
}
159162
}
160163

0 commit comments

Comments
 (0)