Skip to content
Merged
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
2 changes: 2 additions & 0 deletions news/3 Code Health/6052.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Remove `donjamayanne.jupyter` integration
(thanks [Mikhail Bulash](https://github.com/mikeroll/))
12 changes: 0 additions & 12 deletions src/client/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,18 +78,6 @@ export namespace Delays {
export const MaxUnitTestCodeLensDelay = 5000;
}

export namespace LinterErrors {
export namespace pylint {
export const InvalidSyntax = 'E0001';
}
export namespace prospector {
export const InvalidSyntax = 'F999';
}
export namespace flake8 {
export const InvalidSyntax = 'E999';
}
}

export const STANDARD_OUTPUT_CHANNEL = 'STANDARD_OUTPUT_CHANNEL';

export function isTestExecution(): boolean {
Expand Down
6 changes: 0 additions & 6 deletions src/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import {
DebugConfigurationProvider,
Disposable,
ExtensionContext,
extensions,
languages,
Memento,
OutputChannel,
Expand Down Expand Up @@ -88,7 +87,6 @@ import { IServiceContainer, IServiceManager } from './ioc/types';
import { getLanguageConfiguration } from './language/languageConfiguration';
import { LinterCommands } from './linters/linterCommands';
import { registerTypes as lintersRegisterTypes } from './linters/serviceRegistry';
import { ILintingEngine } from './linters/types';
import { PythonCodeActionProvider } from './providers/codeActionsProvider';
import { PythonFormattingEditProvider } from './providers/formatProvider';
import { LinterProvider } from './providers/linterProvider';
Expand Down Expand Up @@ -157,10 +155,6 @@ async function activateUnsafe(context: ExtensionContext): Promise<IExtensionApi>
interpreterManager.refresh(workspaceService.hasWorkspaceFolders ? workspaceService.workspaceFolders![0].uri : undefined)
.catch(ex => traceError('Python Extension: interpreterManager.refresh', ex));

const jupyterExtension = extensions.getExtension('donjayamanne.jupyter');
const lintingEngine = serviceManager.get<ILintingEngine>(ILintingEngine);
lintingEngine.linkJupyterExtension(jupyterExtension).ignoreErrors();

// Activate debug location tracker
serviceManager.get<IDebugLocationTrackerFactory>(IDebugLocationTrackerFactory);

Expand Down
93 changes: 0 additions & 93 deletions src/client/jupyter/provider.ts

This file was deleted.

33 changes: 1 addition & 32 deletions src/client/linters/lintingEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,11 @@ import { Minimatch } from 'minimatch';
import * as path from 'path';
import * as vscode from 'vscode';
import { IDocumentManager, IWorkspaceService } from '../common/application/types';
import { LinterErrors, STANDARD_OUTPUT_CHANNEL } from '../common/constants';
import { STANDARD_OUTPUT_CHANNEL } from '../common/constants';
import { IFileSystem } from '../common/platform/types';
import { IConfigurationService, IOutputChannel } from '../common/types';
import { StopWatch } from '../common/utils/stopWatch';
import { IServiceContainer } from '../ioc/types';
import { JupyterProvider } from '../jupyter/provider';
import { sendTelemetryWhenDone } from '../telemetry';
import { EventName } from '../telemetry/constants';
import { LinterTrigger, LintingTelemetry } from '../telemetry/types';
Expand All @@ -27,15 +26,8 @@ lintSeverityToVSSeverity.set(LintMessageSeverity.Hint, vscode.DiagnosticSeverity
lintSeverityToVSSeverity.set(LintMessageSeverity.Information, vscode.DiagnosticSeverity.Information);
lintSeverityToVSSeverity.set(LintMessageSeverity.Warning, vscode.DiagnosticSeverity.Warning);

// tslint:disable-next-line:interface-name
interface DocumentHasJupyterCodeCells {
// tslint:disable-next-line:callable-types
(doc: vscode.TextDocument, token: vscode.CancellationToken): Promise<Boolean>;
}

@injectable()
export class LintingEngine implements ILintingEngine {
private documentHasJupyterCodeCells: DocumentHasJupyterCodeCells;
private workspace: IWorkspaceService;
private documents: IDocumentManager;
private configurationService: IConfigurationService;
Expand All @@ -46,7 +38,6 @@ export class LintingEngine implements ILintingEngine {
private fileSystem: IFileSystem;

constructor(@inject(IServiceContainer) private serviceContainer: IServiceContainer) {
this.documentHasJupyterCodeCells = (_a, _b) => Promise.resolve(false);
this.documents = serviceContainer.get<IDocumentManager>(IDocumentManager);
this.workspace = serviceContainer.get<IWorkspaceService>(IWorkspaceService);
this.configurationService = serviceContainer.get<IConfigurationService>(IConfigurationService);
Expand Down Expand Up @@ -110,7 +101,6 @@ export class LintingEngine implements ILintingEngine {
return promise;
});

const hasJupyterCodeCells = await this.documentHasJupyterCodeCells(document, cancelToken.token);
// linters will resolve asynchronously - keep a track of all
// diagnostics reported as them come in.
let diagnostics: vscode.Diagnostic[] = [];
Expand All @@ -125,13 +115,6 @@ export class LintingEngine implements ILintingEngine {
if (this.isDocumentOpen(document.uri)) {
// Build the message and suffix the message with the name of the linter used.
for (const m of msgs) {
// Ignore magic commands from jupyter.
if (hasJupyterCodeCells && document.lineAt(m.line - 1).text.trim().startsWith('%') &&
(m.code === LinterErrors.pylint.InvalidSyntax ||
m.code === LinterErrors.prospector.InvalidSyntax ||
m.code === LinterErrors.flake8.InvalidSyntax)) {
continue;
}
diagnostics.push(this.createDiagnostics(m, document));
}
// Limit the number of messages to the max value.
Expand All @@ -142,20 +125,6 @@ export class LintingEngine implements ILintingEngine {
this.diagnosticCollection.set(document.uri, diagnostics);
}

// tslint:disable-next-line:no-any
public async linkJupyterExtension(jupyter: vscode.Extension<any> | undefined): Promise<void> {
if (!jupyter) {
return;
}
if (!jupyter.isActive) {
await jupyter.activate();
}
// tslint:disable-next-line:no-unsafe-any
jupyter.exports.registerLanguageProvider(PYTHON.language, new JupyterProvider());
// tslint:disable-next-line:no-unsafe-any
this.documentHasJupyterCodeCells = jupyter.exports.hasCodeCells;
}

private sendLinterRunTelemetry(info: ILinterInfo, resource: vscode.Uri, promise: Promise<ILintMessage[]>, stopWatch: StopWatch, trigger: LinterTrigger): void {
const linterExecutablePathName = info.pathName(resource);
const properties: LintingTelemetry = {
Expand Down
2 changes: 0 additions & 2 deletions src/client/linters/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,5 @@ export interface ILintingEngine {
readonly diagnostics: vscode.DiagnosticCollection;
lintOpenPythonFiles(): Promise<vscode.DiagnosticCollection>;
lintDocument(document: vscode.TextDocument, trigger: LinterTrigger): Promise<void>;
// tslint:disable-next-line:no-any
linkJupyterExtension(jupyter: vscode.Extension<any> | undefined): Promise<void>;
clearDiagnostics(document: vscode.TextDocument): void;
}