Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* 'master' of https://github.com/Microsoft/vscode-python:
  Fixes #56 list all environments (#219)
  Fixes #57 Disable activation on debugging (#220)
  Fixes #26 Do not run linters when linters are disabled (#222)
  • Loading branch information
DonJayamanne committed Nov 16, 2017
2 parents acc2109 + 7b0838b commit d470523
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 15 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
"Other"
],
"activationEvents": [
"onDebug",
"onLanguage:python",
"onCommand:python.execInTerminal",
"onCommand:python.sortImports",
Expand Down
15 changes: 7 additions & 8 deletions src/client/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,16 +413,15 @@ export function getWindowsLineEndingCount(document: TextDocument, offset: Number
}

export function arePathsSame(path1: string, path2: string) {
path1 = IS_WINDOWS ? path1.replace(/\//g, "\\") : path1;
path2 = IS_WINDOWS ? path2.replace(/\//g, "\\") : path2;
return path1.toUpperCase() === path2.toUpperCase();
path1 = path.normalize(path1);
path2 = path.normalize(path2);
if (IS_WINDOWS) {
return path1.toUpperCase() === path2.toUpperCase();
} else {
return path1 === path2;
}
}

export function areBasePathsSame(path1: string, path2: string) {
path1 = IS_WINDOWS ? path1.replace(/\//g, "\\") : path1;
path2 = IS_WINDOWS ? path2.replace(/\//g, "\\") : path2;
return path.dirname(path1).toUpperCase() === path.dirname(path2).toUpperCase();
}
export async function getInterpreterVersion(pythonPath: string) {
return await new Promise<string>((resolve, reject) => {
child_process.execFile(pythonPath, ['--version'], (error, stdout, stdErr) => {
Expand Down
9 changes: 4 additions & 5 deletions src/client/interpreter/locators/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import * as _ from 'lodash';
import { Disposable, Uri, workspace } from 'vscode';
import { RegistryImplementation } from '../../common/registry';
import { areBasePathsSame, arePathsSame, Is_64Bit, IS_WINDOWS } from '../../common/utils';
import { arePathsSame, Is_64Bit, IS_WINDOWS } from '../../common/utils';
import { IInterpreterLocatorService, PythonInterpreter } from '../contracts';
import { IInterpreterVersionService, InterpreterVersionService } from '../interpreterVersion';
import { InterpreterVersionService } from '../interpreterVersion';
import { VirtualEnvironmentManager } from '../virtualEnvs';
import { fixInterpreterDisplayName, fixInterpreterPath } from './helpers';
import { CondaEnvFileService, getEnvironmentsFile as getCondaEnvFile } from './services/condaEnvFileService';
Expand Down Expand Up @@ -46,16 +46,15 @@ export class PythonInterpreterLocatorService implements IInterpreterLocatorServi
}
private async getInterpretersPerResource(resource?: Uri) {
const locators = this.getLocators(resource);
const promises = locators.map(provider => provider.getInterpreters(resource));
const promises = locators.map(async provider => provider.getInterpreters(resource));
const listOfInterpreters = await Promise.all(promises);

// tslint:disable-next-line:underscore-consistent-invocation
return _.flatten(listOfInterpreters)
.map(fixInterpreterDisplayName)
.map(fixInterpreterPath)
.reduce<PythonInterpreter[]>((accumulator, current) => {
if (accumulator.findIndex(item => arePathsSame(item.path, current.path)) === -1 &&
accumulator.findIndex(item => areBasePathsSame(item.path, current.path)) === -1) {
if (accumulator.findIndex(item => arePathsSame(item.path, current.path)) === -1) {
accumulator.push(current);
}
return accumulator;
Expand Down
3 changes: 3 additions & 0 deletions src/client/providers/lintProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,9 @@ export class LintProvider implements vscode.Disposable {
const workspaceRootPath = (workspaceFolder && typeof workspaceFolder.uri.fsPath === 'string') ? workspaceFolder.uri.fsPath : undefined;
const relativeFileName = typeof workspaceRootPath === 'string' ? path.relative(workspaceRootPath, document.fileName) : document.fileName;
const settings = PythonSettings.getInstance(document.uri);
if (document.languageId !== PythonLanguage.language || !settings.linting.enabled) {
return;
}
const ignoreMinmatches = settings.linting.ignorePatterns.map(pattern => {
return new Minimatch(pattern);
});
Expand Down
3 changes: 2 additions & 1 deletion tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"Thenable",
"PromiseLike"
],
"completed-docs": false
"completed-docs": false,
"no-unsafe-any": false
}
}

0 comments on commit d470523

Please sign in to comment.