Skip to content

Commit 983a8df

Browse files
authored
Switch to pre-release for insiders (#18535)
* Switch to pre-release for insiders * Show both stable and pre-release options. * Update banner message.
1 parent 8261eed commit 983a8df

35 files changed

+168
-1880
lines changed

news/1 Enhancements/18144.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Use new pre-release mechanism to install insiders.

package.json

Lines changed: 0 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@
8181
"onCommand:python.enableLinting",
8282
"onCommand:python.createTerminal",
8383
"onCommand:python.configureTests",
84-
"onCommand:python.switchOffInsidersChannel",
85-
"onCommand:python.switchToDailyChannel",
86-
"onCommand:python.switchToWeeklyChannel",
8784
"onCommand:python.clearWorkspaceInterpreter",
8885
"onCommand:python.enableSourceMapSupport",
8986
"onCommand:python.launchTensorBoard",
@@ -465,21 +462,6 @@
465462
"command": "python.startREPL",
466463
"title": "%python.command.python.startREPL.title%"
467464
},
468-
{
469-
"category": "Python",
470-
"command": "python.switchOffInsidersChannel",
471-
"title": "%python.command.python.switchOffInsidersChannel.title%"
472-
},
473-
{
474-
"category": "Python",
475-
"command": "python.switchToDailyChannel",
476-
"title": "%python.command.python.switchToDailyChannel.title%"
477-
},
478-
{
479-
"category": "Python",
480-
"command": "python.switchToWeeklyChannel",
481-
"title": "%python.command.python.switchToWeeklyChannel.title%"
482-
},
483465
{
484466
"category": "Python",
485467
"command": "python.viewLanguageServerOutput",
@@ -642,17 +624,6 @@
642624
"scope": "resource",
643625
"type": "boolean"
644626
},
645-
"python.insidersChannel": {
646-
"default": "off",
647-
"description": "Set to \"weekly\" or \"daily\" to automatically download and install the latest Insiders builds of the python extension, which include upcoming features and bug fixes.",
648-
"enum": [
649-
"daily",
650-
"off",
651-
"weekly"
652-
],
653-
"scope": "machine",
654-
"type": "string"
655-
},
656627
"python.languageServer": {
657628
"default": "Default",
658629
"description": "Defines type of the language server.",
@@ -1803,24 +1774,6 @@
18031774
"title": "%python.command.python.viewLanguageServerOutput.title%",
18041775
"when": "!virtualWorkspace && shellExecutionSupported"
18051776
},
1806-
{
1807-
"category": "Python",
1808-
"command": "python.switchOffInsidersChannel",
1809-
"title": "%python.command.python.switchOffInsidersChannel.title%",
1810-
"when": "config.python.insidersChannel != 'default' && !virtualWorkspace && shellExecutionSupported"
1811-
},
1812-
{
1813-
"category": "Python",
1814-
"command": "python.switchToDailyChannel",
1815-
"title": "%python.command.python.switchToDailyChannel.title%",
1816-
"when": "config.python.insidersChannel != 'daily' && !virtualWorkspace && shellExecutionSupported"
1817-
},
1818-
{
1819-
"category": "Python",
1820-
"command": "python.switchToWeeklyChannel",
1821-
"title": "%python.command.python.switchToWeeklyChannel.title%",
1822-
"when": "config.python.insidersChannel != 'weekly' && !virtualWorkspace && shellExecutionSupported"
1823-
},
18241777
{
18251778
"category": "Python",
18261779
"command": "python.viewOutput",

package.nls.json

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77
"python.command.python.debugInTerminal.title": "Debug Python File",
88
"python.command.python.execInTerminalIcon.title": "Run Python File",
99
"python.command.python.setInterpreter.title": "Select Interpreter",
10-
"python.command.python.switchOffInsidersChannel.title": "Switch to Default Channel",
11-
"python.command.python.switchToDailyChannel.title": "Switch to Insiders Daily Channel",
12-
"python.command.python.switchToWeeklyChannel.title": "Switch to Insiders Weekly Channel",
1310
"python.command.python.clearWorkspaceInterpreter.title": "Clear Workspace Interpreter Setting",
1411
"python.command.python.viewOutput.title": "Show Output",
1512
"python.command.python.viewLanguageServerOutput.title": "Show Language Server Output",
@@ -87,16 +84,6 @@
8784
"ExtensionSurveyBanner.bannerLabelYes": "Yes, take survey now",
8885
"ExtensionSurveyBanner.bannerLabelNo": "No, thanks",
8986
"ExtensionSurveyBanner.maybeLater": "Maybe later",
90-
"ExtensionChannels.installingInsidersMessage": "Installing Insiders... ",
91-
"ExtensionChannels.installingStableMessage": "Installing Stable... ",
92-
"ExtensionChannels.installationCompleteMessage": "complete.",
93-
"ExtensionChannels.downloadingInsidersMessage": "Downloading Insiders Extension... ",
94-
"ExtensionChannels.yesWeekly": "Yes, weekly",
95-
"ExtensionChannels.yesDaily": "Yes, daily",
96-
"ExtensionChannels.promptMessage": "We noticed you are using Visual Studio Code Insiders. Would you like to use the Insiders build of the Python extension?",
97-
"ExtensionChannels.reloadToUseInsidersMessage": "Please reload Visual Studio Code to use the insiders build of the Python extension.",
98-
"ExtensionChannels.downloadCompletedOutputMessage": "Insiders build download complete.",
99-
"ExtensionChannels.startingDownloadOutputMessage": "Starting download for Insiders build.",
10087
"Interpreters.environmentPromptMessage": "We noticed a new virtual environment has been created. Do you want to select it for the workspace folder?",
10188
"Linter.replaceWithSelectedLinter": "Multiple linters are enabled in settings. Replace with '{0}'?",
10289
"Linter.install": "Install a linter to get error reporting.",
@@ -228,5 +215,8 @@
228215
"TensorBoard.launchNativeTensorBoardSessionCodeLens": "▶ Launch TensorBoard Session",
229216
"TensorBoard.enterRemoteUrl": "Enter remote URL",
230217
"TensorBoard.enterRemoteUrlDetail": "Enter a URL pointing to a remote directory containing your TensorBoard log files",
231-
"SwitchToDefaultLS.bannerMessage": "The Microsoft Python Language Server has reached end of life. Your language server has been set to the default for Python in VS Code, Pylance. If you’d like to change your language server, you can learn about how to do so [here](https://devblogs.microsoft.com/python/python-in-visual-studio-code-may-2021-release/#configuring-your-language-server). Read Pylance’s license [here](https://marketplace.visualstudio.com/items/ms-python.vscode-pylance/license)."
218+
"SwitchToDefaultLS.bannerMessage": "The Microsoft Python Language Server has reached end of life. Your language server has been set to the default for Python in VS Code, Pylance. If you’d like to change your language server, you can learn about how to do so [here](https://devblogs.microsoft.com/python/python-in-visual-studio-code-may-2021-release/#configuring-your-language-server). Read Pylance’s license [here](https://marketplace.visualstudio.com/items/ms-python.vscode-pylance/license).",
219+
"SwitchToPrereleaseExtension.bannerMessage": "We now have a new way to get pre-release (insiders) version of the Python extension. See [here](https://code.visualstudio.com/api/working-with-extensions/publishing-extension#prerelease-extensions) to learn more.",
220+
"SwitchToPrereleaseExtension.installPreRelease": "Install Pre-Release",
221+
"SwitchToPrereleaseExtension.installStable": "Install Stable"
232222
}

package.nls.zh-cn.json

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
"python.command.python.createTerminal.title": "创建终端",
55
"python.command.python.execInTerminal.title": "在终端中运行 Python 文件",
66
"python.command.python.setInterpreter.title": "选择解释器",
7-
"python.command.python.switchOffInsidersChannel.title": "切换到默认版本",
8-
"python.command.python.switchToDailyChannel.title": "切换到每日预览版本",
9-
"python.command.python.switchToWeeklyChannel.title": "切换到每周预览版本",
107
"python.command.python.clearWorkspaceInterpreter.title": "清除工作区解释器设置",
118
"python.command.python.viewOutput.title": "显示输出",
129
"python.command.python.viewLanguageServerOutput.title": "显示语言服务器输出",
@@ -76,16 +73,6 @@
7673
"ExtensionSurveyBanner.bannerLabelYes": "是的,现在接受调查",
7774
"ExtensionSurveyBanner.bannerLabelNo": "不,谢谢",
7875
"ExtensionSurveyBanner.maybeLater": "稍后提醒",
79-
"ExtensionChannels.installingInsidersMessage": "正在安装预览版... ",
80-
"ExtensionChannels.installingStableMessage": "正在安装稳定版... ",
81-
"ExtensionChannels.installationCompleteMessage": "完成。",
82-
"ExtensionChannels.downloadingInsidersMessage": "正在下载预览版... ",
83-
"ExtensionChannels.yesWeekly": "是,每周版",
84-
"ExtensionChannels.yesDaily": "是,每日版",
85-
"ExtensionChannels.promptMessage": "您正在使用 Visual Studio Code 预览版,是否安装 Python 扩展的预览版?",
86-
"ExtensionChannels.reloadToUseInsidersMessage": "请重新加载 Visual Studio Code 以使用 Python 扩展的预览版。",
87-
"ExtensionChannels.downloadCompletedOutputMessage": "预览版下载完成。",
88-
"ExtensionChannels.startingDownloadOutputMessage": "开始下载预览版。",
8976
"Interpreters.environmentPromptMessage": "检测到新的虚拟环境,是否在此工作区中使用它?",
9077
"Linter.replaceWithSelectedLinter": "设置中启用了多个代码检查器,是否用 '{0}' 替换?",
9178
"Linter.install": "请安装一个代码检查器以获得错误报告。",

package.nls.zh-tw.json

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,6 @@
2727
"Pylance.pylanceRevertToJediPrompt": "Pylance 延伸模組未安裝,但 python.languageServer 的值被設為 \"Pylance\"。是否安裝 Pylance 延伸模組,或選擇使用 Jedi?",
2828
"Pylance.pylanceInstallPylance": "安裝 Pylance",
2929
"Pylance.pylanceRevertToJedi": "使用 Jedi",
30-
"python.command.python.switchOffInsidersChannel.title": "切換至預設頻道",
31-
"python.command.python.switchToDailyChannel.title": "切換至 Insiders 每日頻道",
32-
"python.command.python.switchToWeeklyChannel.title": "切換至 Insiders 每週頻道",
3330
"python.command.python.clearWorkspaceInterpreter.title": "清除工作區直譯器設定",
3431
"python.command.python.reportIssue.title": "回報問題...",
3532
"python.command.python.viewOutput.title": "顯示輸出",
@@ -79,16 +76,6 @@
7976
"ExtensionSurveyBanner.bannerLabelYes": "是,現在填寫調查",
8077
"ExtensionSurveyBanner.bannerLabelNo": "不了,謝謝",
8178
"ExtensionSurveyBanner.maybeLater": "等一下",
82-
"ExtensionChannels.installingInsidersMessage": "正在安裝 Insiders... ",
83-
"ExtensionChannels.installingStableMessage": "正在安裝穩定版... ",
84-
"ExtensionChannels.installationCompleteMessage": "完成。",
85-
"ExtensionChannels.downloadingInsidersMessage": "正在下載 Insiders 延伸模組... ",
86-
"ExtensionChannels.yesWeekly": "是,每週",
87-
"ExtensionChannels.yesDaily": "是,每天",
88-
"ExtensionChannels.promptMessage": "我們發覺到您在使用 Visual Studio Code Insiders。請問您是否想使用 Python 延伸模組的 Insiders 組建?",
89-
"ExtensionChannels.reloadToUseInsidersMessage": "請重新載入 Visual Studio Code 以使用 Python 延伸模組的 Insiders 組建。",
90-
"ExtensionChannels.downloadCompletedOutputMessage": "Insiders 組建下載完成。",
91-
"ExtensionChannels.startingDownloadOutputMessage": "開始下載 Insiders 組建。",
9279
"Interpreters.environmentPromptMessage": "We noticed a new virtual environment has been created. Do you want to select it for the workspace folder?",
9380
"Linter.replaceWithSelectedLinter": "設定中啟用了多個 Linter。是否用 '{0}' 取代?",
9481
"Installer.noCondaOrPipInstaller": "選取環境中沒有可用的 Conda 或 Pip 安裝工具。",
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/* eslint-disable max-classes-per-file */
2+
// Copyright (c) Microsoft Corporation. All rights reserved.
3+
// Licensed under the MIT License.
4+
5+
import { inject, injectable, named } from 'inversify';
6+
import { ConfigurationTarget, DiagnosticSeverity } from 'vscode';
7+
import { ICommandManager, IWorkspaceService } from '../../../common/application/types';
8+
import { PVSC_EXTENSION_ID } from '../../../common/constants';
9+
import { IDisposableRegistry, Resource } from '../../../common/types';
10+
import { SwitchToPrereleaseExtension } from '../../../common/utils/localize';
11+
import { IServiceContainer } from '../../../ioc/types';
12+
import { sendTelemetryEvent } from '../../../telemetry';
13+
import { EventName } from '../../../telemetry/constants';
14+
import { BaseDiagnostic, BaseDiagnosticsService } from '../base';
15+
import { DiagnosticCodes } from '../constants';
16+
import { DiagnosticCommandPromptHandlerServiceId, MessageCommandPrompt } from '../promptHandler';
17+
import { DiagnosticScope, IDiagnostic, IDiagnosticHandlerService } from '../types';
18+
19+
export class SwitchToPreReleaseExtensionDiagnostic extends BaseDiagnostic {
20+
constructor(message: string, resource: Resource) {
21+
super(
22+
DiagnosticCodes.SwitchToPreReleaseExtensionDiagnostic,
23+
message,
24+
DiagnosticSeverity.Warning,
25+
DiagnosticScope.Global,
26+
resource,
27+
);
28+
}
29+
}
30+
31+
export const SwitchToPreReleaseExtensionDiagnosticServiceId = 'SwitchToPreReleaseExtensionDiagnosticServiceId';
32+
33+
@injectable()
34+
export class SwitchToPreReleaseExtensionDiagnosticService extends BaseDiagnosticsService {
35+
constructor(
36+
@inject(IServiceContainer) serviceContainer: IServiceContainer,
37+
@inject(IWorkspaceService) private readonly workspaceService: IWorkspaceService,
38+
@inject(ICommandManager) private readonly commandManager: ICommandManager,
39+
@inject(IDiagnosticHandlerService)
40+
@named(DiagnosticCommandPromptHandlerServiceId)
41+
protected readonly messageService: IDiagnosticHandlerService<MessageCommandPrompt>,
42+
@inject(IDisposableRegistry) disposableRegistry: IDisposableRegistry,
43+
) {
44+
super(
45+
[DiagnosticCodes.SwitchToPreReleaseExtensionDiagnostic],
46+
serviceContainer,
47+
disposableRegistry,
48+
true,
49+
true,
50+
);
51+
}
52+
53+
public diagnose(resource: Resource): Promise<IDiagnostic[]> {
54+
const config = this.workspaceService.getConfiguration('python', resource);
55+
const value = config.inspect<string>('insidersChannel');
56+
if (value) {
57+
const insiderType = value.globalValue ?? value.globalLanguageValue;
58+
if (insiderType) {
59+
return Promise.resolve([
60+
new SwitchToPreReleaseExtensionDiagnostic(SwitchToPrereleaseExtension.bannerMessage(), resource),
61+
]);
62+
}
63+
}
64+
return Promise.resolve([]);
65+
}
66+
67+
protected async onHandle(diagnostics: IDiagnostic[]): Promise<void> {
68+
if (diagnostics.length === 0 || !this.canHandle(diagnostics[0])) {
69+
return;
70+
}
71+
72+
const diagnostic = diagnostics[0];
73+
if (await this.filterService.shouldIgnoreDiagnostic(diagnostic.code)) {
74+
return;
75+
}
76+
77+
await this.messageService.handle(diagnostic, {
78+
onClose: () => {
79+
sendTelemetryEvent(EventName.INSIDERS_PROMPT, undefined, { selection: 'closed' });
80+
},
81+
commandPrompts: [
82+
{
83+
prompt: SwitchToPrereleaseExtension.installPreRelease(),
84+
command: {
85+
diagnostic,
86+
invoke: (): Promise<void> => this.installExtension(true, diagnostic.resource),
87+
},
88+
},
89+
{
90+
prompt: SwitchToPrereleaseExtension.installStable(),
91+
command: {
92+
diagnostic,
93+
invoke: (): Promise<void> => this.installExtension(false, diagnostic.resource),
94+
},
95+
},
96+
],
97+
});
98+
}
99+
100+
private async installExtension(preRelease: boolean, resource: Resource): Promise<void> {
101+
sendTelemetryEvent(EventName.INSIDERS_PROMPT, undefined, { selection: preRelease ? 'preRelease' : 'stable' });
102+
const config = this.workspaceService.getConfiguration('python', resource);
103+
const setting = config.inspect<string>('insidersChannel');
104+
if (setting) {
105+
config.update('insidersChannel', undefined, ConfigurationTarget.Global);
106+
}
107+
await this.commandManager.executeCommand(`workbench.extensions.installExtension`, PVSC_EXTENSION_ID, {
108+
installPreReleaseVersion: preRelease,
109+
});
110+
}
111+
}

src/client/application/diagnostics/commands/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import { DiagnosticScope, IDiagnostic, IDiagnosticCommand } from '../types';
88

99
export type CommandOption<Type, Option> = { type: Type; options: Option };
1010
type LaunchBrowserOption = CommandOption<'launch', string>;
11-
type IgnoreDiagnostOption = CommandOption<'ignore', DiagnosticScope>;
11+
type IgnoreDiagnosticOption = CommandOption<'ignore', DiagnosticScope>;
1212
type ExecuteVSCCommandOption = CommandOption<'executeVSCCommand', CommandsWithoutArgs>;
13-
export type CommandOptions = LaunchBrowserOption | IgnoreDiagnostOption | ExecuteVSCCommandOption;
13+
export type CommandOptions = LaunchBrowserOption | IgnoreDiagnosticOption | ExecuteVSCCommandOption;
1414

1515
export const IDiagnosticsCommandFactory = Symbol('IDiagnosticsCommandFactory');
1616

src/client/application/diagnostics/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ export enum DiagnosticCodes {
2121
PylanceDefaultDiagnostic = 'PylanceDefaultDiagnostic',
2222
JediPython27NotSupportedDiagnostic = 'JediPython27NotSupportedDiagnostic',
2323
SwitchToDefaultLanguageServerDiagnostic = 'SwitchToDefaultLanguageServerDiagnostic',
24+
SwitchToPreReleaseExtensionDiagnostic = 'SwitchToPreReleaseExtensionDiagnostic',
2425
}

src/client/application/diagnostics/serviceRegistry.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ import {
4040
SwitchToDefaultLanguageServerDiagnosticService,
4141
SwitchToDefaultLanguageServerDiagnosticServiceId,
4242
} from './checks/switchToDefaultLS';
43+
import {
44+
SwitchToPreReleaseExtensionDiagnosticService,
45+
SwitchToPreReleaseExtensionDiagnosticServiceId,
46+
} from './checks/switchToPreReleaseExtension';
4347
import { DiagnosticsCommandFactory } from './commands/factory';
4448
import { IDiagnosticsCommandFactory } from './commands/types';
4549
import { DiagnosticFilterService } from './filter';
@@ -111,6 +115,12 @@ export function registerTypes(serviceManager: IServiceManager): void {
111115
SwitchToDefaultLanguageServerDiagnosticServiceId,
112116
);
113117

118+
serviceManager.addSingleton<IDiagnosticsService>(
119+
IDiagnosticsService,
120+
SwitchToPreReleaseExtensionDiagnosticService,
121+
SwitchToPreReleaseExtensionDiagnosticServiceId,
122+
);
123+
114124
serviceManager.addSingleton<IDiagnosticsCommandFactory>(IDiagnosticsCommandFactory, DiagnosticsCommandFactory);
115125
serviceManager.addSingleton<IApplicationDiagnostics>(IApplicationDiagnostics, ApplicationDiagnostics);
116126
}

src/client/common/application/commands.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,7 @@ export type CommandsWithoutArgs = keyof ICommandNameWithoutArgumentTypeMapping;
1616
* @interface ICommandNameWithoutArgumentTypeMapping
1717
*/
1818
interface ICommandNameWithoutArgumentTypeMapping {
19-
[Commands.SwitchToInsidersDaily]: [];
20-
[Commands.SwitchToInsidersWeekly]: [];
2119
[Commands.ClearWorkspaceInterpreter]: [];
22-
[Commands.SwitchOffInsidersChannel]: [];
2320
[Commands.Set_Interpreter]: [];
2421
[Commands.Set_ShebangInterpreter]: [];
2522
[Commands.Run_Linter]: [];
@@ -61,7 +58,14 @@ export interface ICommandNameArgumentTypeMapping extends ICommandNameWithoutArgu
6158
['workbench.action.quickOpen']: [string];
6259
['workbench.extensions.installExtension']: [
6360
Uri | 'ms-python.python',
64-
{ installOnlyNewlyAddedFromExtensionPackVSIX?: boolean } | undefined,
61+
(
62+
| {
63+
installOnlyNewlyAddedFromExtensionPackVSIX?: boolean;
64+
installPreReleaseVersion?: boolean;
65+
donotSync?: boolean;
66+
}
67+
| undefined
68+
),
6569
];
6670
['workbench.action.files.openFolder']: [];
6771
['workbench.action.openWorkspace']: [];

0 commit comments

Comments
 (0)