Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
b4424c1
Remove the experiment
Sep 3, 2021
7993e17
News file
Sep 3, 2021
560ea71
Fix linting issue
Sep 3, 2021
68bb632
Turn JediLSP option into Jedi
Sep 7, 2021
185d72e
Remove commented code
Sep 7, 2021
0c12ed3
Update comment
Sep 8, 2021
34ea029
Always register no LS activator
Sep 8, 2021
ca5dbff
Add basic 2.7 LS support (Pylance or None)
Sep 8, 2021
c48302d
Skip tests on Python 2.7
Sep 8, 2021
0fd8455
Fix unit tests
Sep 8, 2021
4f5612c
Default to Pylance
Sep 8, 2021
61dad1c
Fix unit tests
Sep 8, 2021
ec0db02
Set default LS to Jedi
Sep 8, 2021
777680e
Install JediLSP requirements for testing
Sep 8, 2021
9044986
Change default back to none
Sep 8, 2021
6bf6a24
Typo
Sep 8, 2021
4bafd38
Turn condition around to match comment
Sep 8, 2021
7f5bb1b
Remove JediLSP requirements
Sep 8, 2021
bd91ebe
Default to None
Sep 9, 2021
ac36ebd
Install JediLSP requirements
Sep 9, 2021
df2841f
Install JediLSP reqs for smoke tests too
Sep 9, 2021
f432385
Merge branch 'main' into 11995-use-jedi-lsp-
Sep 9, 2021
efdab05
Install JediLSP reqs in coverage step
Sep 9, 2021
3733b58
Undo PR check workflow changes
Sep 9, 2021
d85d0a9
Turns out it won't run if there's no 'run' keyword
Sep 9, 2021
fc85f2a
Change condition order
Sep 9, 2021
5418db5
Add activation service unit tests
Sep 9, 2021
010d3d4
Remove comment
Sep 9, 2021
f38558f
Add NoLanguageServerExtensionActivator check
Sep 9, 2021
b1f3819
Delete Jedi tests
Sep 9, 2021
54ca6b5
Change condition order
Sep 9, 2021
4ab65ad
Add diagnostic
Sep 13, 2021
a7ac22c
Add tests
Sep 13, 2021
4ec2900
Merge branch 'main' into 11995-27-notification
Sep 14, 2021
d538ba8
Run diagnostic in the background
Sep 14, 2021
ebf6f6b
Remove manual diagnostic handling
Sep 14, 2021
1c32f1b
Localize "do not show again"
Sep 14, 2021
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
1 change: 1 addition & 0 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@
"products.installingModule": "Installing {0}",
"OutdatedDebugger.updateDebuggerMessage": "We noticed you are attaching to ptvsd (Python debugger), which was deprecated on May 1st, 2020. Please switch to [debugpy](https://aka.ms/migrateToDebugpy).",
"Python27Support.bannerMessage": "The Python extension will have limited support for Python 2.7 starting in the next release, due to changes in external projects we rely on. [Learn more](https://aka.ms/python-27-support).",
"Python27Support.jediMessage": "IntelliSense with Jedi for Python 2.7 is no longer supported. [Learn more](https://aka.ms/python-27-support).",
"Jupyter.extensionRequired": "The Jupyter extension is required to perform that task. Click Yes to open the Jupyter extension installation page.",
"TensorBoard.missingSourceFile": "We could not locate the requested source file on disk. Please manually specify the file.",
"TensorBoard.selectMissingSourceFile": "Choose File",
Expand Down
24 changes: 1 addition & 23 deletions src/client/activation/activationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
import '../common/extensions';

import { inject, injectable } from 'inversify';
import { ConfigurationChangeEvent, ConfigurationTarget, Disposable, OutputChannel, Uri } from 'vscode';

import { ConfigurationChangeEvent, Disposable, OutputChannel, Uri } from 'vscode';
import { LSNotSupportedDiagnosticServiceId } from '../application/diagnostics/checks/lsNotSupported';
import { IDiagnosticsService } from '../application/diagnostics/types';
import { IApplicationShell, ICommandManager, IWorkspaceService } from '../common/application/types';
Expand Down Expand Up @@ -232,8 +231,6 @@ export class LanguageServerExtensionActivationService
): Promise<RefCountedLanguageServer> {
let serverType = this.getCurrentLanguageServerType();

this.updateLanguageServerSetting(resource);

if (serverType === LanguageServerType.Microsoft) {
const lsNotSupportedDiagnosticService = this.serviceContainer.get<IDiagnosticsService>(
IDiagnosticsService,
Expand Down Expand Up @@ -345,23 +342,4 @@ export class LanguageServerExtensionActivationService
const values = await Promise.all([...this.cache.values()]);
values.forEach((v) => (v.clearAnalysisCache ? v.clearAnalysisCache() : noop()));
}

private updateLanguageServerSetting(resource: Resource): void {
// Update settings.json value to Jedi if it's JediLSP.
const settings = this.workspaceService
.getConfiguration('python', resource)
.inspect<LanguageServerType>('languageServer');

let configTarget: ConfigurationTarget;

if (settings?.workspaceValue === LanguageServerType.JediLSP) {
configTarget = ConfigurationTarget.Workspace;
} else if (settings?.globalValue === LanguageServerType.JediLSP) {
configTarget = ConfigurationTarget.Global;
} else {
return;
}

this.configurationService.updateSetting('languageServer', LanguageServerType.Jedi, resource, configTarget);
}
}
100 changes: 100 additions & 0 deletions src/client/application/diagnostics/checks/jediPython27NotSupported.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
/* eslint-disable max-classes-per-file */
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import { inject, named } from 'inversify';
import { ConfigurationTarget, DiagnosticSeverity } from 'vscode';
import { LanguageServerType } from '../../../activation/types';
import { IWorkspaceService } from '../../../common/application/types';
import { IConfigurationService, IDisposableRegistry, Resource } from '../../../common/types';
import { Common, Python27Support } from '../../../common/utils/localize';
import { IInterpreterService } from '../../../interpreter/contracts';
import { IServiceContainer } from '../../../ioc/types';
import { BaseDiagnostic, BaseDiagnosticsService } from '../base';
import { IDiagnosticsCommandFactory } from '../commands/types';
import { DiagnosticCodes } from '../constants';
import { DiagnosticCommandPromptHandlerServiceId, MessageCommandPrompt } from '../promptHandler';
import { DiagnosticScope, IDiagnostic, IDiagnosticHandlerService } from '../types';

export class JediPython27NotSupportedDiagnostic extends BaseDiagnostic {
constructor(message: string, resource: Resource) {
super(
DiagnosticCodes.JediPython27NotSupportedDiagnostic,
message,
DiagnosticSeverity.Warning,
DiagnosticScope.Global,
resource,
);
}
}

export const JediPython27NotSupportedDiagnosticServiceId = 'JediPython27NotSupportedDiagnosticServiceId';

export class JediPython27NotSupportedDiagnosticService extends BaseDiagnosticsService {
constructor(
@inject(IServiceContainer) serviceContainer: IServiceContainer,
@inject(IInterpreterService) private readonly interpreterService: IInterpreterService,
@inject(IWorkspaceService) private readonly workspaceService: IWorkspaceService,
@inject(IConfigurationService) private readonly configurationService: IConfigurationService,
@inject(IDiagnosticHandlerService)
@named(DiagnosticCommandPromptHandlerServiceId)
protected readonly messageService: IDiagnosticHandlerService<MessageCommandPrompt>,
@inject(IDisposableRegistry) disposableRegistry: IDisposableRegistry,
) {
super([DiagnosticCodes.JediPython27NotSupportedDiagnostic], serviceContainer, disposableRegistry, true);
}

public async diagnose(resource: Resource): Promise<IDiagnostic[]> {
const interpreter = await this.interpreterService.getActiveInterpreter(resource);

if (interpreter && (interpreter.version?.major ?? 0) < 3) {
return [new JediPython27NotSupportedDiagnostic(Python27Support.jediMessage(), resource)];
}

return [];
}

protected async onHandle(diagnostics: IDiagnostic[]): Promise<void> {
if (diagnostics.length === 0 || !this.canHandle(diagnostics[0])) {
return;
}
const diagnostic = diagnostics[0];
if (await this.filterService.shouldIgnoreDiagnostic(diagnostic.code)) {
return;
}

this.updateLanguageServerSetting(diagnostic.resource);

const commandFactory = this.serviceContainer.get<IDiagnosticsCommandFactory>(IDiagnosticsCommandFactory);
const options = [
{
prompt: Common.gotIt(),
},
{
prompt: Common.doNotShowAgain(),
command: commandFactory.createCommand(diagnostic, { type: 'ignore', options: DiagnosticScope.Global }),
},
];

await this.messageService.handle(diagnostic, { commandPrompts: options });
}

private updateLanguageServerSetting(resource: Resource): void {
// Update settings.json value to Jedi if it's JediLSP.
const settings = this.workspaceService
.getConfiguration('python', resource)
.inspect<LanguageServerType>('languageServer');

let configTarget: ConfigurationTarget;

if (settings?.workspaceValue === LanguageServerType.JediLSP) {
configTarget = ConfigurationTarget.Workspace;
} else if (settings?.globalValue === LanguageServerType.JediLSP) {
configTarget = ConfigurationTarget.Global;
} else {
return;
}

this.configurationService.updateSetting('languageServer', LanguageServerType.Jedi, resource, configTarget);
}
}
1 change: 1 addition & 0 deletions src/client/application/diagnostics/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ export enum DiagnosticCodes {
UpgradeCodeRunnerDiagnostic = 'UpgradeCodeRunnerDiagnostic',
PylanceDefaultDiagnostic = 'PylanceDefaultDiagnostic',
MPLSSurveyDiagnostic = 'MPLSSurveyDiagnostic',
JediPython27NotSupportedDiagnostic = 'JediPython27NotSupportedDiagnostic',
}
10 changes: 10 additions & 0 deletions src/client/application/diagnostics/serviceRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ import {
InvalidPythonPathInDebuggerService,
InvalidPythonPathInDebuggerServiceId,
} from './checks/invalidPythonPathInDebugger';
import {
JediPython27NotSupportedDiagnosticService,
JediPython27NotSupportedDiagnosticServiceId,
} from './checks/jediPython27NotSupported';
import { LSNotSupportedDiagnosticService, LSNotSupportedDiagnosticServiceId } from './checks/lsNotSupported';
import {
InvalidMacPythonInterpreterService,
Expand Down Expand Up @@ -100,6 +104,12 @@ export function registerTypes(serviceManager: IServiceManager, languageServerTyp
PylanceDefaultDiagnosticServiceId,
);

serviceManager.addSingleton<IDiagnosticsService>(
IDiagnosticsService,
JediPython27NotSupportedDiagnosticService,
JediPython27NotSupportedDiagnosticServiceId,
);

serviceManager.addSingleton<IDiagnosticsCommandFactory>(IDiagnosticsCommandFactory, DiagnosticsCommandFactory);
serviceManager.addSingleton<IApplicationDiagnostics>(IApplicationDiagnostics, ApplicationDiagnostics);

Expand Down
5 changes: 5 additions & 0 deletions src/client/common/utils/localize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,11 @@ export namespace Python27Support {
'Python27Support.bannerMessage',
'The Python extension will have limited support for Python 2.7 starting in the next release, due to changes in external projects we rely on. [Learn more](https://aka.ms/python-27-support).',
);

export const jediMessage = localize(
'Python27Support.jediMessage',
'IntelliSense with Jedi for Python 2.7 is no longer supported. [Learn more](https://aka.ms/python-27-support).',
);
}

export namespace MPLSDeprecation {
Expand Down
Loading