Skip to content

Encourage to the developer to create/switch to a virtual environment #19687

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/client/common/utils/localize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,12 @@ export namespace InterpreterQuickPickList {
'Use Python from `python.defaultInterpreterPath` setting',
),
};
export const tooltipMessages = {
notUsingVirtualEnv: localize(
'InterpreterQuickPickList.tooltipMessages.notUsingVirtualEnv',
"It's recommended to create a virtual environment to keep the project's dependencies isolated from the system ones",
),
};
export const browsePath = {
label: localize('InterpreterQuickPickList.browsePath.label', 'Find...'),
detail: localize(
Expand Down
8 changes: 7 additions & 1 deletion src/client/interpreter/display/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { IDisposableRegistry, IPathUtils, Resource } from '../../common/types';
import { InterpreterQuickPickList } from '../../common/utils/localize';
import { IServiceContainer } from '../../ioc/types';
import { traceLog } from '../../logging';
import { PythonEnvironment } from '../../pythonEnvironments/info';
import { PythonEnvironment, virtualEnvTypes } from '../../pythonEnvironments/info';
import {
IInterpreterDisplay,
IInterpreterHelper,
Expand Down Expand Up @@ -139,6 +139,12 @@ export class InterpreterDisplay implements IInterpreterDisplay, IExtensionSingle
this.statusBar.text = text ?? '';
this.statusBar.backgroundColor = undefined;
this.currentlySelectedInterpreterDisplay = interpreter.detailedDisplayName;
if (!virtualEnvTypes.includes(interpreter.envType)) {
const application = this.serviceContainer.get<IApplicationShell>(IApplicationShell);
application.showWarningMessage(InterpreterQuickPickList.tooltipMessages.notUsingVirtualEnv);
this.statusBar.tooltip = InterpreterQuickPickList.tooltipMessages.notUsingVirtualEnv;
this.statusBar.text = `$(alert) ${this.statusBar.text}`;
}
} else {
this.statusBar.tooltip = '';
this.statusBar.color = '';
Expand Down