diff --git a/src/client/activation/analysis.ts b/src/client/activation/analysis.ts index 8072e99d32af..bf8fd4c9e587 100644 --- a/src/client/activation/analysis.ts +++ b/src/client/activation/analysis.ts @@ -240,7 +240,6 @@ export class AnalysisExtensionActivator implements IExtensionActivator { maxDocumentationTextLength: 0 }, asyncStartup: true, - intelliCodeEnabled: settings.intelliCodeEnabled, testEnvironment: isTestExecution() } }; diff --git a/src/client/activation/downloader.ts b/src/client/activation/downloader.ts index f6d7036ad12a..f28075571579 100644 --- a/src/client/activation/downloader.ts +++ b/src/client/activation/downloader.ts @@ -21,7 +21,6 @@ const downloadUriPrefix = 'https://pvsc.blob.core.windows.net/python-analysis'; const downloadBaseFileName = 'Python-Analysis-VSCode'; const downloadVersion = '0.1.0'; const downloadFileExtension = '.nupkg'; -const modelName = 'model-sequence.json.gz'; export class AnalysisEngineDownloader { private readonly output: OutputChannel; @@ -56,29 +55,6 @@ export class AnalysisEngineDownloader { } } - public async downloadIntelliCodeModel(context: ExtensionContext): Promise { - const modelFolder = path.join(context.extensionPath, 'analysis', 'Pythia', 'model'); - const localPath = path.join(modelFolder, modelName); - if (await this.fs.fileExists(localPath)) { - return; - } - - let localTempFilePath = ''; - try { - localTempFilePath = await this.downloadFile(downloadUriPrefix, modelName, 'Downloading IntelliCode Model File... '); - await this.fs.createDirectory(modelFolder); - await this.fs.copyFile(localTempFilePath, localPath); - } catch (err) { - this.output.appendLine('failed.'); - this.output.appendLine(err); - throw new Error(err); - } finally { - if (localTempFilePath.length > 0) { - await this.fs.deleteFile(localTempFilePath); - } - } - } - private async downloadFile(location: string, fileName: string, title: string): Promise { const uri = `${location}/${fileName}`; this.output.append(`Downloading ${uri}... `); diff --git a/src/client/activation/hashVerifier.ts b/src/client/activation/hashVerifier.ts index c62cb36484f7..61d1177966f9 100644 --- a/src/client/activation/hashVerifier.ts +++ b/src/client/activation/hashVerifier.ts @@ -22,7 +22,7 @@ export class HashVerifier { readStream.pipe(hash); await deferred.promise; - const actual = hash.read(); - return expectedDigest === platformString ? true : actual === expectedDigest; + const actual = hash.read() as string; + return expectedDigest === platformString ? true : actual.toLowerCase() === expectedDigest.toLowerCase(); } } diff --git a/src/client/common/configSettings.ts b/src/client/common/configSettings.ts index 63408c7c5638..033a33096cab 100644 --- a/src/client/common/configSettings.ts +++ b/src/client/common/configSettings.ts @@ -25,7 +25,6 @@ export const IS_WINDOWS = /^win/.test(process.platform); // tslint:disable-next-line:completed-docs export class PythonSettings extends EventEmitter implements IPythonSettings { private static pythonSettings: Map = new Map(); - public intelliCodeEnabled = true; public downloadCodeAnalysis = true; public jediEnabled = true; public jediPath = ''; @@ -127,8 +126,6 @@ export class PythonSettings extends EventEmitter implements IPythonSettings { this.jediPath = ''; } this.jediMemoryLimit = pythonSettings.get('jediMemoryLimit')!; - } else { - this.intelliCodeEnabled = systemVariables.resolveAny(pythonSettings.get('intelliCodeEnabled', true))!; } // tslint:disable-next-line:no-backbone-get-set-outside-model no-non-null-assertion diff --git a/src/client/common/types.ts b/src/client/common/types.ts index 05a03ee04cf7..547ccc8f6401 100644 --- a/src/client/common/types.ts +++ b/src/client/common/types.ts @@ -100,7 +100,6 @@ export interface IPythonSettings { readonly pythonPath: string; readonly venvPath: string; readonly venvFolders: string[]; - readonly intelliCodeEnabled: boolean; readonly downloadCodeAnalysis: boolean; readonly jediEnabled: boolean; readonly jediPath: string; diff --git a/src/client/formatters/lineFormatter.ts b/src/client/formatters/lineFormatter.ts index 28a71f6ff08d..9bd256f50177 100644 --- a/src/client/formatters/lineFormatter.ts +++ b/src/client/formatters/lineFormatter.ts @@ -98,6 +98,8 @@ export class LineFormatter { private handleOperator(index: number): void { const t = this.tokens.getItemAt(index); const prev = index > 0 ? this.tokens.getItemAt(index - 1) : undefined; + const next = index < this.tokens.count - 1 ? this.tokens.getItemAt(index + 1) : undefined; + if (t.length === 1) { const opCode = this.text.charCodeAt(t.start); switch (opCode) { @@ -107,6 +109,14 @@ export class LineFormatter { } break; case Char.Period: + if (prev && this.isKeyword(prev, 'from')) { + this.builder.softAppendSpace(); + } + this.builder.append(this.text[t.start]); + if (next && this.isKeyword(next, 'import')) { + this.builder.softAppendSpace(); + } + return; case Char.At: case Char.ExclamationMark: this.builder.append(this.text[t.start]); diff --git a/src/test/format/extension.lineFormatter.test.ts b/src/test/format/extension.lineFormatter.test.ts index 46ca5e46f816..656f22c3ffd6 100644 --- a/src/test/format/extension.lineFormatter.test.ts +++ b/src/test/format/extension.lineFormatter.test.ts @@ -112,6 +112,15 @@ suite('Formatting - line formatter', () => { test('Function returning tuple', () => { testFormatLine('x,y=f(a)', 'x, y = f(a)'); }); + test('from. import A', () => { + testFormatLine('from. import A', 'from . import A'); + }); + test('from .. import', () => { + testFormatLine('from ..import', 'from .. import'); + }); + test('from..x import', () => { + testFormatLine('from..x import', 'from ..x import'); + }); test('Grammar file', () => { const content = fs.readFileSync(grammarFile).toString('utf8'); const lines = content.splitLines({ trim: false, removeEmptyEntries: false });