Skip to content

Improves linting behavior per #722 #792

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

Merged
merged 87 commits into from
Feb 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
7675901
Basic tokenizer
Dec 1, 2017
eb42669
Fixed property names
Dec 1, 2017
2756974
Tests, round I
Dec 1, 2017
c2c1ced
Tests, round II
Dec 2, 2017
a108c96
merge master
Dec 3, 2017
14864a5
tokenizer test
Dec 4, 2017
0ed51d6
Remove temorary change
Dec 4, 2017
51b544c
Fix merge issue
Dec 4, 2017
3cd11e6
Merge conflict
Dec 4, 2017
82e0ad1
Merge conflict
Dec 4, 2017
9295c1a
Completion test
Dec 4, 2017
06eb1a5
Fix last line
Dec 4, 2017
e9db8e0
Fix javascript math
Dec 4, 2017
d12ca03
Merge master
Dec 5, 2017
d8ab041
Make test await for results
Dec 5, 2017
db75cd0
Add license headers
Dec 5, 2017
9ab2c47
Rename definitions to types
Dec 5, 2017
d587485
License headers
Dec 5, 2017
1da5e0a
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Dec 5, 2017
7668cee
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Dec 11, 2017
1ac4932
Fix typo in completion details (typo)
Dec 11, 2017
2aa5a6c
Fix hover test
Dec 12, 2017
5db31bd
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Dec 12, 2017
560d2af
Russian translations
Dec 13, 2017
c71024d
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Dec 13, 2017
31aa087
Update to better translation
Dec 13, 2017
593ae05
Fix typo
Dec 13, 2017
e6d69bb
#70 How to get all parameter info when filling in a function param list
Dec 13, 2017
b5a23d3
Fix #70 How to get all parameter info when filling in a function para…
Dec 14, 2017
cd200f7
Clean up
Dec 14, 2017
7c33228
Clean imports
Dec 14, 2017
c4a6b90
CR feedback
Dec 14, 2017
f85b848
Trim whitespace for test stability
Dec 14, 2017
37c210b
More tests
Dec 15, 2017
61a5650
Better handle no-parameters documentation
Dec 15, 2017
a10305e
Better handle ellipsis and Python3
Dec 15, 2017
bfcae78
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Dec 15, 2017
42a5f79
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Dec 18, 2017
e4ba322
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Jan 8, 2018
7baec1a
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Jan 9, 2018
9cb43e7
#385 Auto-Indentation doesn't work after comment
Jan 9, 2018
5a9c3fd
#141 Auto indentation broken when return keyword involved
Jan 9, 2018
9800c4a
Undo changes
Jan 9, 2018
3205d33
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Jan 11, 2018
c1150d4
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Feb 1, 2018
30519c7
#627 Docstrings for builtin methods are not parsed correctly
Feb 5, 2018
96511cb
reStructuredText converter
Feb 5, 2018
c8670b9
Fix: period is not an operator
Feb 5, 2018
97f232f
Minor fixes
Feb 6, 2018
768bffe
Restructure
Feb 6, 2018
825f16b
Tests
Feb 6, 2018
eb36eef
Tests
Feb 6, 2018
bab4239
Code heuristics
Feb 6, 2018
2a30201
Baselines
Feb 6, 2018
e430ef8
HTML handling
Feb 6, 2018
1afa841
Lists
Feb 7, 2018
6bffb07
State machine
Feb 7, 2018
e436fde
Baselines
Feb 7, 2018
c03e619
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Feb 7, 2018
e52bcff
Squash
Feb 7, 2018
e6b8196
Merge branch 'master' of https://github.com/MikhailArkhipov/vscode-py…
Feb 7, 2018
3a0cfb1
no message
Feb 7, 2018
4616996
Merge branch 'master' of https://github.com/MikhailArkhipov/vscode-py…
Feb 7, 2018
35838b9
Whitespace difference
Feb 7, 2018
656a56b
Merge branch 'master' of https://github.com/Microsoft/vscode-python
Feb 12, 2018
6a10786
Update Jedi to 0.11.1
Feb 12, 2018
d43f097
Enable Travis
Feb 12, 2018
f8db935
Test fixes
Feb 13, 2018
a8dc597
Undo change
Feb 13, 2018
3f5d492
Jedi 0.11 with parser
Feb 13, 2018
f93a0f4
Merge master
Feb 13, 2018
f8eaa93
Undo changes
Feb 13, 2018
e4372c6
Undo changes
Feb 13, 2018
469c8a7
Test fixes
Feb 13, 2018
9dbba99
Re-lint when interpreter changes
Feb 14, 2018
fedcb68
Re-lint on linter config change
Feb 14, 2018
3562e50
Run linting command
Feb 14, 2018
845cce7
Encapsulate jupiter
Feb 15, 2018
2271fa0
Handle promise
Feb 15, 2018
609bbdd
More tests
Feb 15, 2018
7ea6fda
Tests
Feb 15, 2018
d2be4b0
Merge branch 'master' into 722
Feb 15, 2018
b4ecb5e
Merge master
Feb 15, 2018
ec47332
Use service
Feb 15, 2018
c46856b
Linter provider tests
Feb 16, 2018
0633c69
Move methods to documents manager
Feb 16, 2018
780a58d
Merge master
Feb 16, 2018
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
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,11 @@
"command": "python.enableLinting",
"title": "%python.command.python.enableLinting.title%",
"category": "Python"
},
{
"command": "python.runLinting",
"title": "%python.command.python.runLinting.title%",
"category": "Python"
}
],
"menus": {
Expand Down Expand Up @@ -1831,4 +1836,4 @@
"publisherDisplayName": "Microsoft",
"publisherId": "998b010b-e2af-44a5-a6cd-0b5fd3b9b6f8"
}
}
}
51 changes: 26 additions & 25 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,28 +26,29 @@
"python.command.python.goToPythonObject.title": "Go to Python Object",
"python.command.python.setLinter.title": "Select Linter",
"python.command.python.enableLinting.title": "Enable Linting",
"python.snippet.launch.standard.label": "Python",
"python.snippet.launch.standard.description": "Debug a Python program with standard output",
"python.snippet.launch.pyspark.label": "Python: PySpark",
"python.snippet.launch.pyspark.description": "Debug PySpark",
"python.snippet.launch.module.label": "Python: Module",
"python.snippet.launch.module.description": "Debug a Python Module",
"python.snippet.launch.terminal.label": "Python: Terminal (integrated)",
"python.snippet.launch.terminal.description": "Debug a Python program with Integrated Terminal/Console",
"python.snippet.launch.externalTerminal.label": "Python: Terminal (external)",
"python.snippet.launch.externalTerminal.description": "Debug a Python program with External Terminal/Console",
"python.snippet.launch.django.label": "Python: Django",
"python.snippet.launch.django.description": "Debug a Django Application",
"python.snippet.launch.flask.label": "Python: Flask (0.11.x or later)",
"python.snippet.launch.flask.description": "Debug a Flask Application",
"python.snippet.launch.flaskOld.label": "Python: Flask (0.10.x or earlier)",
"python.snippet.launch.flaskOld.description": "Debug an older styled Flask Application",
"python.snippet.launch.pyramid.label": "Python: Pyramid Application",
"python.snippet.launch.pyramid.description": "Debug a Pyramid Application",
"python.snippet.launch.watson.label": "Python: Watson Application",
"python.snippet.launch.watson.description": "Debug a Watson Application",
"python.snippet.launch.attach.label": "Python: Attach",
"python.snippet.launch.attach.description": "Attach the debugger for remote debugging",
"python.snippet.launch.scrapy.label": "Python: Scrapy",
"python.snippet.launch.scrapy.description": "Scrapy with Integrated Terminal/Console"
}
"python.command.python.runLinting.title": "Run Linting",
"python.snippet.launch.standard.label": "Python",
"python.snippet.launch.standard.description": "Debug a Python program with standard output",
"python.snippet.launch.pyspark.label": "Python: PySpark",
"python.snippet.launch.pyspark.description": "Debug PySpark",
"python.snippet.launch.module.label": "Python: Module",
"python.snippet.launch.module.description": "Debug a Python Module",
"python.snippet.launch.terminal.label": "Python: Terminal (integrated)",
"python.snippet.launch.terminal.description": "Debug a Python program with Integrated Terminal/Console",
"python.snippet.launch.externalTerminal.label": "Python: Terminal (external)",
"python.snippet.launch.externalTerminal.description": "Debug a Python program with External Terminal/Console",
"python.snippet.launch.django.label": "Python: Django",
"python.snippet.launch.django.description": "Debug a Django Application",
"python.snippet.launch.flask.label": "Python: Flask (0.11.x or later)",
"python.snippet.launch.flask.description": "Debug a Flask Application",
"python.snippet.launch.flaskOld.label": "Python: Flask (0.10.x or earlier)",
"python.snippet.launch.flaskOld.description": "Debug an older styled Flask Application",
"python.snippet.launch.pyramid.label": "Python: Pyramid Application",
"python.snippet.launch.pyramid.description": "Debug a Pyramid Application",
"python.snippet.launch.watson.label": "Python: Watson Application",
"python.snippet.launch.watson.description": "Debug a Watson Application",
"python.snippet.launch.attach.label": "Python: Attach",
"python.snippet.launch.attach.description": "Attach the debugger for remote debugging",
"python.snippet.launch.scrapy.label": "Python: Scrapy",
"python.snippet.launch.scrapy.description": "Scrapy with Integrated Terminal/Console"
}
51 changes: 26 additions & 25 deletions package.nls.ru.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,29 @@
"python.command.python.goToPythonObject.title": "Перейти к объекту Python",
"python.command.python.setLinter.title": "Выбрать анализатор кода",
"python.command.python.enableLinting.title": "Включить анализатор кода",
"python.snippet.launch.standard.label": "Python",
"python.snippet.launch.standard.description": "Отладить программу Python со стандартным выводом",
"python.snippet.launch.pyspark.label": "Python: PySpark",
"python.snippet.launch.pyspark.description": "Отладка PySpark",
"python.snippet.launch.module.label": "Python: Модуль",
"python.snippet.launch.module.description": "Отладка модуля",
"python.snippet.launch.terminal.label": "Python: Интегрированная консоль",
"python.snippet.launch.terminal.description": "Отладка программы Python в интегрированной консоли",
"python.snippet.launch.externalTerminal.label": "Python: Внешний терминал",
"python.snippet.launch.externalTerminal.description": "Отладка программы Python во внешней консоли",
"python.snippet.launch.django.label": "Python: Django",
"python.snippet.launch.django.description": "Отладка приложения Django",
"python.snippet.launch.flask.label": "Python: Flask (0.11.x или новее)",
"python.snippet.launch.flask.description": "Отладка приложения Flask",
"python.snippet.launch.flaskOld.label": "Python: Flask (0.10.x или старее)",
"python.snippet.launch.flaskOld.description": "Отладка приложения Flask (старый стиль)",
"python.snippet.launch.pyramid.label": "Python: Приложение Pyramid",
"python.snippet.launch.pyramid.description": "Отладка приложения Pyramid",
"python.snippet.launch.watson.label": "Python: Приложение Watson",
"python.snippet.launch.watson.description": "Отладка приложения Watson",
"python.snippet.launch.attach.label": "Python: Подключить отладчик",
"python.snippet.launch.attach.description": "Подключить отладчик для удаленной отладки",
"python.snippet.launch.scrapy.label": "Python: Scrapy",
"python.snippet.launch.scrapy.description": "Scrapy в интегрированной консоли"
}
"python.command.python.runLinting.title": "Выполнить анализ кода",
"python.snippet.launch.standard.label": "Python",
"python.snippet.launch.standard.description": "Отладить программу Python со стандартным выводом",
"python.snippet.launch.pyspark.label": "Python: PySpark",
"python.snippet.launch.pyspark.description": "Отладка PySpark",
"python.snippet.launch.module.label": "Python: Модуль",
"python.snippet.launch.module.description": "Отладка модуля",
"python.snippet.launch.terminal.label": "Python: Интегрированная консоль",
"python.snippet.launch.terminal.description": "Отладка программы Python в интегрированной консоли",
"python.snippet.launch.externalTerminal.label": "Python: Внешний терминал",
"python.snippet.launch.externalTerminal.description": "Отладка программы Python во внешней консоли",
"python.snippet.launch.django.label": "Python: Django",
"python.snippet.launch.django.description": "Отладка приложения Django",
"python.snippet.launch.flask.label": "Python: Flask (0.11.x или новее)",
"python.snippet.launch.flask.description": "Отладка приложения Flask",
"python.snippet.launch.flaskOld.label": "Python: Flask (0.10.x или старее)",
"python.snippet.launch.flaskOld.description": "Отладка приложения Flask (старый стиль)",
"python.snippet.launch.pyramid.label": "Python: Приложение Pyramid",
"python.snippet.launch.pyramid.description": "Отладка приложения Pyramid",
"python.snippet.launch.watson.label": "Python: Приложение Watson",
"python.snippet.launch.watson.description": "Отладка приложения Watson",
"python.snippet.launch.attach.label": "Python: Подключить отладчик",
"python.snippet.launch.attach.description": "Подключить отладчик для удаленной отладки",
"python.snippet.launch.scrapy.label": "Python: Scrapy",
"python.snippet.launch.scrapy.description": "Scrapy в интегрированной консоли"
}
9 changes: 9 additions & 0 deletions src/client/common/application/documentManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ import { IDocumentManager } from './types';

@injectable()
export class DocumentManager implements IDocumentManager {
public get textDocuments(): TextDocument[] {
return workspace.textDocuments;
}
public get activeTextEditor(): TextEditor | undefined {
return window.activeTextEditor;
}
Expand All @@ -30,6 +33,12 @@ export class DocumentManager implements IDocumentManager {
public get onDidChangeTextEditorViewColumn(): Event<TextEditorViewColumnChangeEvent> {
return window.onDidChangeTextEditorViewColumn;
}
public get onDidOpenTextDocument(): Event<TextDocument> {
return workspace.onDidOpenTextDocument;
}
public get onDidCloseTextDocument(): Event<TextDocument> {
return workspace.onDidCloseTextDocument;
}
public get onDidSaveTextDocument(): Event<TextDocument> {
return workspace.onDidSaveTextDocument;
}
Expand Down
14 changes: 14 additions & 0 deletions src/client/common/application/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,12 @@ export interface ICommandManager {
export const IDocumentManager = Symbol('IDocumentManager');

export interface IDocumentManager {
/**
* All text documents currently known to the system.
*
* @readonly
*/
readonly textDocuments: TextDocument[];
/**
* The currently active editor or `undefined`. The active editor is the one
* that currently has focus or, when none has focus, the one that has changed
Expand Down Expand Up @@ -352,6 +358,14 @@ export interface IDocumentManager {
*/
readonly onDidChangeTextEditorViewColumn: Event<TextEditorViewColumnChangeEvent>;

/**
* An event that is emitted when a [text document](#TextDocument) is opened.
*/
readonly onDidOpenTextDocument: Event<TextDocument>;
/**
* An event that is emitted when a [text document](#TextDocument) is disposed.
*/
readonly onDidCloseTextDocument: Event<TextDocument>;
/**
* An event that is emitted when a [text document](#TextDocument) is saved to disk.
*/
Expand Down
3 changes: 3 additions & 0 deletions src/client/common/application/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,7 @@ export class WorkspaceService implements IWorkspaceService {
public findFiles(include: vscode.GlobPattern, exclude?: vscode.GlobPattern, maxResults?: number, token?: vscode.CancellationToken): Thenable<vscode.Uri[]> {
return vscode.workspace.findFiles(include, exclude, maxResults, token);
}
public get onDidSaveTextDocument(): vscode.Event<vscode.TextDocument> {
return vscode.workspace.onDidSaveTextDocument;
}
}
1 change: 1 addition & 0 deletions src/client/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export namespace Commands {
export const Create_Terminal = 'python.createTerminal';
export const Set_Linter = 'python.setLinter';
export const Enable_Linter = 'python.enableLinting';
export const Run_Linter = 'python.runLinting';
}
export namespace Octicons {
export const Test_Pass = '$(check)';
Expand Down
31 changes: 9 additions & 22 deletions src/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ import { registerTypes as interpretersRegisterTypes } from './interpreter/servic
import { ServiceContainer } from './ioc/container';
import { ServiceManager } from './ioc/serviceManager';
import { IServiceContainer } from './ioc/types';
import { JupyterProvider } from './jupyter/provider';
import { JediFactory } from './languageServices/jediProxyFactory';
import { LinterCommands } from './linters/linterCommands';
import { registerTypes as lintersRegisterTypes } from './linters/serviceRegistry';
import { ILintingEngine } from './linters/types';
import { PythonCompletionItemProvider } from './providers/completionProvider';
import { PythonDefinitionProvider } from './providers/definitionProvider';
import { PythonFormattingEditProvider } from './providers/formatProvider';
Expand Down Expand Up @@ -165,29 +165,16 @@ export async function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(vscode.languages.registerDocumentRangeFormattingEditProvider(PYTHON, formatProvider));
}

// tslint:disable-next-line:promise-function-async
const linterProvider = new LinterProvider(context, standardOutputChannel, (a, b) => Promise.resolve(false), serviceContainer);
const linterProvider = new LinterProvider(context, serviceContainer);
context.subscriptions.push(linterProvider);
const jupyterExtInstalled = vscode.extensions.getExtension('donjayamanne.jupyter');
if (jupyterExtInstalled) {
if (jupyterExtInstalled.isActive) {
// tslint:disable-next-line:no-unsafe-any
jupyterExtInstalled.exports.registerLanguageProvider(PYTHON.language, new JupyterProvider());
// tslint:disable-next-line:no-unsafe-any
linterProvider.documentHasJupyterCodeCells = jupyterExtInstalled.exports.hasCodeCells;
}

jupyterExtInstalled.activate().then(() => {
// tslint:disable-next-line:no-unsafe-any
jupyterExtInstalled.exports.registerLanguageProvider(PYTHON.language, new JupyterProvider());
// tslint:disable-next-line:no-unsafe-any
linterProvider.documentHasJupyterCodeCells = jupyterExtInstalled.exports.hasCodeCells;
});
}

const jupyterExtension = vscode.extensions.getExtension('donjayamanne.jupyter');
const lintingEngine = serviceContainer.get<ILintingEngine>(ILintingEngine);
lintingEngine.linkJupiterExtension(jupyterExtension).ignoreErrors();

tests.activate(context, unitTestOutChannel, symbolProvider, serviceContainer);

context.subscriptions.push(new WorkspaceSymbols(serviceContainer));

context.subscriptions.push(vscode.languages.registerOnTypeFormattingEditProvider(PYTHON, new BlockFormatProviders(), ':'));
context.subscriptions.push(vscode.languages.registerOnTypeFormattingEditProvider(PYTHON, new OnEnterFormatter(), '\n'));

Expand All @@ -199,9 +186,9 @@ export async function activate(context: vscode.ExtensionContext) {
// tslint:disable-next-line:no-unused-expression
new BannerService(persistentStateFactory);

const deprecationMgr = new FeatureDeprecationManager(persistentStateFactory, !!jupyterExtInstalled);
const deprecationMgr = new FeatureDeprecationManager(persistentStateFactory, !!jupyterExtension);
deprecationMgr.initialize();
context.subscriptions.push(new FeatureDeprecationManager(persistentStateFactory, !!jupyterExtInstalled));
context.subscriptions.push(new FeatureDeprecationManager(persistentStateFactory, !!jupyterExtension));
}

async function sendStartupTelemetry(activatedPromise: Promise<void>, serviceContainer: IServiceContainer) {
Expand Down
4 changes: 2 additions & 2 deletions src/client/interpreter/contracts.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CodeLensProvider, ConfigurationTarget, Disposable, TextDocument, Uri } from 'vscode';
import { CodeLensProvider, ConfigurationTarget, Disposable, Event, TextDocument, Uri } from 'vscode';
import { Architecture } from '../common/platform/types';

export const INTERPRETER_LOCATOR_SERVICE = 'IInterpreterLocatorService';
Expand Down Expand Up @@ -75,8 +75,8 @@ export type WorkspacePythonPath = {
};

export const IInterpreterService = Symbol('IInterpreterService');

export interface IInterpreterService {
onDidChangeInterpreter: Event<void>;
getInterpreters(resource?: Uri): Promise<PythonInterpreter[]>;
autoSetInterpreter(): Promise<void>;
getActiveInterpreter(resource?: Uri): Promise<PythonInterpreter | undefined>;
Expand Down
9 changes: 1 addition & 8 deletions src/client/interpreter/display/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class InterpreterDisplay implements IInterpreterDisplay {
private readonly configurationService: IConfigurationService;
private readonly helper: IInterpreterHelper;
private readonly workspaceService: IWorkspaceService;
private currentWorkspaceInterpreter?: Uri;

constructor(@inject(IServiceContainer) serviceContainer: IServiceContainer) {
this.interpreterService = serviceContainer.get<IInterpreterService>(IInterpreterService);
this.virtualEnvMgr = serviceContainer.get<IVirtualEnvironmentManager>(IVirtualEnvironmentManager);
Expand Down Expand Up @@ -48,14 +48,7 @@ export class InterpreterDisplay implements IInterpreterDisplay {
}
await this.updateDisplay(resource);
}
private shouldRefresh(workspaceFolder?: Uri) {
if (!workspaceFolder || !this.currentWorkspaceInterpreter) {
return true;
}
return !this.fileSystem.arePathsSame(workspaceFolder.fsPath, this.currentWorkspaceInterpreter.fsPath);
}
private async updateDisplay(workspaceFolder?: Uri) {
this.currentWorkspaceInterpreter = workspaceFolder;
const interpreters = await this.interpreterService.getInterpreters(workspaceFolder);
const interpreter = await this.interpreterService.getActiveInterpreter(workspaceFolder);
const pythonPath = interpreter ? interpreter.path : this.configurationService.getSettings(workspaceFolder).pythonPath;
Expand Down
Loading