Skip to content

Fix linters to make use of the new python code execution framework #360

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 123 commits into from
Dec 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
ecc1ca9
Fix Microsoft/vscode#37627 (#1368)
octref Nov 3, 2017
7c5778c
Version 0.7.0 of extension (#1381)
DonJayamanne Nov 9, 2017
9d1bf82
Update README.md
DonJayamanne Nov 9, 2017
ffba179
Update README.md
DonJayamanne Nov 9, 2017
905c713
sync fork with upstream
DonJayamanne Nov 10, 2017
acc2109
fix readme
DonJayamanne Nov 10, 2017
d470523
Merge branch 'master' of https://github.com/Microsoft/vscode-python
DonJayamanne Nov 16, 2017
d32a546
run without debugging
DonJayamanne Nov 15, 2017
3f14d0a
send terminated event when process ends and fix linters
DonJayamanne Nov 15, 2017
f37803f
gracefully handle program termination
DonJayamanne Nov 16, 2017
d69940e
use vscode infrastructure to launch code in terminals
DonJayamanne Nov 16, 2017
d392e8b
merged upstream
DonJayamanne Nov 16, 2017
11c9514
merged
DonJayamanne Nov 16, 2017
38befc0
ensure to check if launchArgs is not null
DonJayamanne Nov 16, 2017
bea91fc
ensure to check if launchArgs is not null
DonJayamanne Nov 16, 2017
0bb9054
ensure to check if launchArgs is not null
DonJayamanne Nov 16, 2017
a105a20
fix code review comments
DonJayamanne Nov 17, 2017
8b2fd7c
fixed code review comments
DonJayamanne Nov 17, 2017
5a7d21e
Merge branch 'master' into RunWithoutDebug
DonJayamanne Nov 17, 2017
acd90c5
Merge branch 'master' into RunWithoutDebug
DonJayamanne Nov 17, 2017
09b3359
fixes #250, do not copy all env variables
DonJayamanne Nov 17, 2017
9616eef
bug fix, launch using vscode and then fallback
DonJayamanne Nov 17, 2017
f9fe2a8
fix linter issue
DonJayamanne Nov 17, 2017
4963632
platform process services
DonJayamanne Nov 17, 2017
edbe63e
tests for decoder
DonJayamanne Nov 18, 2017
47acd08
tests for process service
DonJayamanne Nov 18, 2017
284e221
test to check source
DonJayamanne Nov 18, 2017
b27496b
tests for process utils
DonJayamanne Nov 20, 2017
92f775f
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 20, 2017
23fe3da
fix imports
DonJayamanne Nov 20, 2017
0277ca1
rename file
DonJayamanne Nov 20, 2017
bbc8290
environment variable parser
DonJayamanne Nov 21, 2017
29b5489
refactored variable services
DonJayamanne Nov 21, 2017
5e7a61b
environment variable caching service
DonJayamanne Nov 21, 2017
81af0e5
remove unwanted file
DonJayamanne Nov 21, 2017
e0ea914
process execution with unit tests
DonJayamanne Nov 21, 2017
f0c1978
process execution with unit tests
DonJayamanne Nov 21, 2017
32a6e53
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 21, 2017
4b30f2c
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 22, 2017
e396752
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 22, 2017
4c0bdb1
merged master
DonJayamanne Nov 22, 2017
3b71463
ensure env vars are always provided
DonJayamanne Nov 22, 2017
b5d9b1a
use range instead of xrange
DonJayamanne Nov 23, 2017
56ce88b
import reflect-metadata
DonJayamanne Nov 23, 2017
eff4792
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 28, 2017
4553c28
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 28, 2017
6382e96
added unit tests for python process and other services
DonJayamanne Nov 28, 2017
8ab2eb5
clean up of test runners and collectors
DonJayamanne Nov 28, 2017
39f272f
merged master
DonJayamanne Nov 28, 2017
b05a940
fix debugging unit tests and issue with used ports
DonJayamanne Nov 28, 2017
5049ed9
refactor code
DonJayamanne Nov 28, 2017
3c6520a
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 28, 2017
966e516
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 28, 2017
63d2d65
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 28, 2017
f6d469e
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 28, 2017
eced312
Merge branch 'master' into FixCodeExec
DonJayamanne Nov 29, 2017
ce930dc
fix for rx compilation issues
DonJayamanne Nov 29, 2017
53bbc1e
fixed linter issues and injected test debug launcher
DonJayamanne Nov 29, 2017
f0c4714
improvements to build scripts
DonJayamanne Nov 29, 2017
db0e778
update
DonJayamanne Nov 29, 2017
024509d
udpates to launc and tasks
DonJayamanne Nov 29, 2017
a32f846
add package-lock
DonJayamanne Nov 29, 2017
83a1ce5
fix linter errors
DonJayamanne Nov 29, 2017
560752b
add gulp-debounced-watch
DonJayamanne Nov 30, 2017
1addf10
refactor
DonJayamanne Nov 30, 2017
73c7c81
refactor unit tests to use DI
DonJayamanne Nov 30, 2017
07a8a18
read env variable instead on demand
DonJayamanne Nov 30, 2017
b4f5c10
refactor
DonJayamanne Nov 30, 2017
f14df93
fix #327, handle all promise rejections
DonJayamanne Nov 30, 2017
e856fe8
remove invalid item
DonJayamanne Nov 30, 2017
029e055
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 30, 2017
f0ba6d7
fixes to move interfaces around for DI
DonJayamanne Nov 30, 2017
6dcf879
improved bounce
DonJayamanne Nov 30, 2017
71c2531
bug fix
DonJayamanne Nov 30, 2017
e8c71c0
Merge remote-tracking branch 'upstream/master'
DonJayamanne Nov 30, 2017
b5c51c4
merged master
DonJayamanne Nov 30, 2017
7e6ee4c
DI for unit tests
DonJayamanne Dec 1, 2017
51cf9d2
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 1, 2017
13df41b
perf improvement
DonJayamanne Dec 1, 2017
4968ebd
improvements
DonJayamanne Dec 1, 2017
7aadc43
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 1, 2017
aa4062e
incremental changes
DonJayamanne Dec 1, 2017
9ef2465
refactored
DonJayamanne Dec 1, 2017
0e15e8d
pytest tests
DonJayamanne Dec 1, 2017
5a60422
add tests for nosetests
DonJayamanne Dec 1, 2017
5cfb06f
added more nose tests
DonJayamanne Dec 2, 2017
b2b7dc6
better options
DonJayamanne Dec 2, 2017
35b8255
fix issue
DonJayamanne Dec 2, 2017
7854924
reduce tests
DonJayamanne Dec 2, 2017
d69fd1a
remove duplicate registration
DonJayamanne Dec 2, 2017
317cf88
use mock out put for format tests
DonJayamanne Dec 2, 2017
07e0710
debug
DonJayamanne Dec 2, 2017
9e0d27a
debug
DonJayamanne Dec 2, 2017
5a22791
Fix tests
DonJayamanne Dec 2, 2017
fec7d51
Merge branch 'master' into FixCodeExec
DonJayamanne Dec 2, 2017
0c4003f
Merge branch 'FixCodeExec' of https://github.com/DonJayamanne/pythonV…
DonJayamanne Dec 2, 2017
9d6194b
removed unused method
DonJayamanne Dec 2, 2017
34158ba
speed up gulp
DonJayamanne Dec 4, 2017
c823315
removed unwanted setting
DonJayamanne Dec 4, 2017
e349e56
ensure chai 4.0.6 is used in tsd
DonJayamanne Dec 4, 2017
a1fea85
fixes
DonJayamanne Dec 4, 2017
cb0a354
bitwise operations are allowed
DonJayamanne Dec 4, 2017
f0f5c59
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 4, 2017
c464a2a
merged
DonJayamanne Dec 4, 2017
011dca1
enforce eol in vscode
DonJayamanne Dec 4, 2017
bfb8036
enforce new line
DonJayamanne Dec 4, 2017
761f057
removed ts coding conventions
DonJayamanne Dec 4, 2017
b2b9da9
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 4, 2017
51b6c81
Use spaces instead of tabs
DonJayamanne Dec 4, 2017
7fd36fc
merged master
DonJayamanne Dec 4, 2017
ada46ba
added missing license headers and fix linter warnings
DonJayamanne Dec 4, 2017
c5e2d5d
fix code comments
DonJayamanne Dec 5, 2017
b756ee8
fix code comments
DonJayamanne Dec 5, 2017
30a4091
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 5, 2017
de14c78
merged
DonJayamanne Dec 5, 2017
22e90fb
use new execution framework in linters
DonJayamanne Dec 6, 2017
b16d2f9
Merge remote-tracking branch 'upstream/master'
DonJayamanne Dec 6, 2017
d1079a2
merge master
DonJayamanne Dec 6, 2017
c0a2787
fix linter issues
DonJayamanne Dec 6, 2017
479a3c2
centralize creation of output channels
DonJayamanne Dec 6, 2017
514f654
bug fix
DonJayamanne Dec 6, 2017
2b3f2ef
code refactor
DonJayamanne Dec 6, 2017
1c7d1c9
fix code review comments
DonJayamanne Dec 7, 2017
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,102 changes: 1,007 additions & 95 deletions package-lock.json

Large diffs are not rendered by default.

3,158 changes: 1,570 additions & 1,588 deletions package.json

Large diffs are not rendered by default.

9 changes: 2 additions & 7 deletions src/client/common/configSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ export interface IUnitTestSettings {
pyTestArgs: string[];
unittestEnabled: boolean;
unittestArgs: string[];
outputWindow: string;
cwd?: string;
}
export interface IPylintCategorySeverity {
Expand Down Expand Up @@ -96,7 +95,6 @@ export interface ILintingSettings {
pylamaPath: string;
flake8Path: string;
pydocstylePath: string;
outputWindow: string;
mypyEnabled: boolean;
mypyArgs: string[];
mypyPath: string;
Expand All @@ -107,7 +105,6 @@ export interface IFormattingSettings {
autopep8Args: string[];
yapfPath: string;
yapfArgs: string[];
outputWindow: string;
}
export interface IAutoCompeteSettings {
addBrackets: boolean;
Expand Down Expand Up @@ -244,7 +241,7 @@ export class PythonSettings extends EventEmitter implements IPythonSettings {
flake8Args: [], flake8Enabled: false, flake8Path: 'flake',
lintOnSave: false, maxNumberOfProblems: 100,
mypyArgs: [], mypyEnabled: false, mypyPath: 'mypy',
outputWindow: 'python', pep8Args: [], pep8Enabled: false, pep8Path: 'pep8',
pep8Args: [], pep8Enabled: false, pep8Path: 'pep8',
pylamaArgs: [], pylamaEnabled: false, pylamaPath: 'pylama',
prospectorArgs: [], prospectorEnabled: false, prospectorPath: 'prospector',
pydocstyleArgs: [], pydocstyleEnabled: false, pydocstylePath: 'pydocstyle',
Expand Down Expand Up @@ -288,7 +285,6 @@ export class PythonSettings extends EventEmitter implements IPythonSettings {
// Support for travis.
this.formatting = this.formatting ? this.formatting : {
autopep8Args: [], autopep8Path: 'autopep8',
outputWindow: 'python',
provider: 'autopep8',
yapfArgs: [], yapfPath: 'yapf'
};
Expand Down Expand Up @@ -339,7 +335,7 @@ export class PythonSettings extends EventEmitter implements IPythonSettings {
nosetestArgs: [], pyTestArgs: [], unittestArgs: [],
promptToConfigure: true, debugPort: 3000,
nosetestsEnabled: false, pyTestEnabled: false, unittestEnabled: false,
nosetestPath: 'nosetests', pyTestPath: 'py.test', outputWindow: 'Python Test Log'
nosetestPath: 'nosetests', pyTestPath: 'py.test'
} as IUnitTestSettings;
}
}
Expand All @@ -349,7 +345,6 @@ export class PythonSettings extends EventEmitter implements IPythonSettings {
promptToConfigure: true,
debugPort: 3000,
nosetestArgs: [], nosetestPath: 'nosetest', nosetestsEnabled: false,
outputWindow: 'python',
pyTestArgs: [], pyTestEnabled: false, pyTestPath: 'pytest',
unittestArgs: [], unittestEnabled: false
};
Expand Down
2 changes: 2 additions & 0 deletions src/client/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,5 @@ export namespace LinterErrors {
export const InvalidSyntax = 'E999';
}
}

export const STANDARD_OUTPUT_CHANNEL = 'STANDARD_OUTPUT_CHANNEL';
34 changes: 34 additions & 0 deletions src/client/common/extensions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

/**
* @typedef {Object} SplitLinesOptions
* @property {boolean} [trim=true] - Whether to trim the lines.
* @property {boolean} [removeEmptyEntries=true] - Whether to remove empty entries.
*/

// tslint:disable-next-line:interface-name
interface String {
/**
* Split a string using the cr and lf characters and return them as an array.
* By default lines are trimmed and empty lines are removed.
* @param {SplitLinesOptions=} splitOptions - Options used for splitting the string.
*/
splitLines(splitOptions?: { trim: boolean, removeEmptyEntries: boolean }): string[];
}

/**
* Split a string using the cr and lf characters and return them as an array.
* By default lines are trimmed and empty lines are removed.
* @param {SplitLinesOptions=} splitOptions - Options used for splitting the string.
*/
String.prototype.splitLines = function (this: string, splitOptions: { trim: boolean, removeEmptyEntries: boolean } = { removeEmptyEntries: true, trim: true }): string[] {
let lines = this.split(/\r?\n/g);
if (splitOptions && splitOptions.trim) {
lines = lines.filter(line => line.trim());
}
if (splitOptions && splitOptions.removeEmptyEntries) {
lines = lines.filter(line => line.length > 0);
}
return lines;
};
34 changes: 10 additions & 24 deletions src/client/common/installer.ts
Original file line number Diff line number Diff line change
@@ -1,26 +1,16 @@
import { inject, injectable, named } from 'inversify';
import * as os from 'os';
import * as vscode from 'vscode';
import 'reflect-metadata';
import 'reflect-metadata';
import { ConfigurationTarget, Uri, window, workspace } from 'vscode';
import * as vscode from 'vscode';
import * as settings from './configSettings';
import { STANDARD_OUTPUT_CHANNEL } from './constants';
import { isNotInstalledError } from './helpers';
import { IInstaller, InstallerResponse, IOutputChannel, Product } from './types';
import { execPythonFile, getFullyQualifiedPythonInterpreterPath, IS_WINDOWS } from './utils';

export enum Product {
pytest = 1,
nosetest = 2,
pylint = 3,
flake8 = 4,
pep8 = 5,
pylama = 6,
prospector = 7,
pydocstyle = 8,
yapf = 9,
autopep8 = 10,
mypy = 11,
unittest = 12,
ctags = 13,
rope = 14
}
export { Product } from './types';

// tslint:disable-next-line:variable-name
const ProductInstallScripts = new Map<Product, string[]>();
Expand Down Expand Up @@ -156,15 +146,11 @@ ProductTypes.set(Product.rope, ProductType.RefactoringLibrary);

const IS_POWERSHELL = /powershell.exe$/i;

export enum InstallerResponse {
Installed,
Disabled,
Ignore
}
export class Installer implements vscode.Disposable {
@injectable()
export class Installer implements IInstaller {
private static terminal: vscode.Terminal | undefined | null;
private disposables: vscode.Disposable[] = [];
constructor(private outputChannel?: vscode.OutputChannel) {
constructor( @inject(IOutputChannel) @named(STANDARD_OUTPUT_CHANNEL) private outputChannel?: vscode.OutputChannel) {
this.disposables.push(vscode.window.onDidCloseTerminal(term => {
if (term === Installer.terminal) {
Installer.terminal = null;
Expand Down
51 changes: 16 additions & 35 deletions src/client/common/logger.ts
Original file line number Diff line number Diff line change
@@ -1,42 +1,23 @@
import * as vscode from "vscode";
import * as settings from "./configSettings";
import { injectable } from 'inversify';
import 'reflect-metadata';
import { ILogger } from './types';

let outChannel: vscode.OutputChannel;
const PREFIX = 'Python Extension: ';

class Logger {
public static IsDebug: boolean;
static initializeChannel() {
if (settings.PythonSettings.getInstance().devOptions.indexOf("DEBUG") >= 0) {
Logger.IsDebug = true;
outChannel = vscode.window.createOutputChannel("PythonExtLog");
}
@injectable()
export class Logger implements ILogger {
public logError(message: string, ex?: Error) {
console.error(`${PREFIX}${message}`, error);
}

static write(category: string = "log", title: string = "", message: any) {
Logger.initializeChannel();
if (title.length > 0) {
Logger.writeLine(category, "---------------------------");
Logger.writeLine(category, title);
}

Logger.writeLine(category, message);
public logWarning(message: string, ex?: Error) {
console.warn(`${PREFIX}${message}`, ex);
}
static writeLine(category: string = "log", line: any) {
if (process.env['VSC_PYTHON_CI_TEST'] !== '1') {
console[category](line);
}
if (outChannel) {
outChannel.appendLine(line);
}
}
}
export function error(title: string = "", message: any) {
Logger.write.apply(Logger, ["error", title, message]);
}
export function warn(title: string = "", message: any) {
Logger.write.apply(Logger, ["warn", title, message]);
// tslint:disable-next-line:no-any
export function error(title: string = '', message: any) {
new Logger().logError(`${title}, ${message}`);
}
export function log(title: string = "", message: any) {
if (!Logger.IsDebug) return;
Logger.write.apply(Logger, ["log", title, message]);
// tslint:disable-next-line:no-any
export function warn(title: string = '', message: any) {
new Logger().logWarning(`${title}, ${message}`);
}
10 changes: 9 additions & 1 deletion src/client/common/serviceRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@
// Licensed under the MIT License.

import 'reflect-metadata';
import { Disposable } from 'vscode';
import { IServiceManager } from '../ioc/types';
import { Installer } from './installer';
import { Logger } from './logger';
import { PersistentStateFactory } from './persistentState';
import { IS_WINDOWS as isWindows } from './platform/constants';
import { IPersistentStateFactory, IsWindows } from './types';
import { IDiposableRegistry, IInstaller, ILogger, IPersistentStateFactory, IsWindows } from './types';

export function registerTypes(serviceManager: IServiceManager) {
serviceManager.addSingletonInstance<boolean>(IsWindows, isWindows);
serviceManager.addSingleton<IPersistentStateFactory>(IPersistentStateFactory, PersistentStateFactory);
serviceManager.addSingleton<IInstaller>(IInstaller, Installer);
serviceManager.addSingleton<ILogger>(ILogger, Logger);

const disposableRegistry = serviceManager.get<Disposable[]>(IDiposableRegistry);
disposableRegistry.push(serviceManager.get<IInstaller>(IInstaller));
}
48 changes: 48 additions & 0 deletions src/client/common/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

import { Disposable, Uri } from 'vscode';

export const IOutputChannel = Symbol('IOutputChannel');
export const IDocumentSymbolProvider = Symbol('IDocumentSymbolProvider');
export const IsWindows = Symbol('IS_WINDOWS');
Expand All @@ -19,3 +21,49 @@ export interface IPersistentStateFactory {
createGlobalPersistentState<T>(key: string, defaultValue: T): IPersistentState<T>;
createWorkspacePersistentState<T>(key: string, defaultValue: T): IPersistentState<T>;
}

export type ExecutionInfo = {
execPath: string;
moduleName?: string;
args: string[];
product?: Product;
};

export const ILogger = Symbol('ILogger');

export interface ILogger {
logError(message: string, error?: Error);
logWarning(message: string, error?: Error);
}

export enum InstallerResponse {
Installed,
Disabled,
Ignore
}

export enum Product {
pytest = 1,
nosetest = 2,
pylint = 3,
flake8 = 4,
pep8 = 5,
pylama = 6,
prospector = 7,
pydocstyle = 8,
yapf = 9,
autopep8 = 10,
mypy = 11,
unittest = 12,
ctags = 13,
rope = 14
}

export const IInstaller = Symbol('IInstaller');

export interface IInstaller extends Disposable {
promptToInstall(product: Product, resource?: Uri): Promise<InstallerResponse>;
install(product: Product, resource?: Uri): Promise<InstallerResponse>;
isInstalled(product: Product, resource?: Uri): Promise<boolean | undefined>;
disableLinter(product: Product, resource?: Uri): Promise<void>;
}
Loading