Skip to content

Commit eee1529

Browse files
author
Mikhail Arkhipov
authored
Fix bug, remove unnecessary flag, fix hash comparison on Linux (#1734)
* Undo changes * Test fixes * Increase timeout * Remove double event listening * Remove test * Revert "Remove test" This reverts commit e240c3f. * Revert "Remove double event listening" This reverts commit af573be. * #1096 The if statement is automatically formatted incorrectly * Merge fix * Add more tests * More tests * Typo * Test * Also better handle multiline arguments * Add a couple missing periods [skip ci] * Undo changes * Test fixes * Increase timeout * Remove double event listening * Remove test * Revert "Remove test" This reverts commit e240c3f. * Revert "Remove double event listening" This reverts commit af573be. * Merge fix * #1257 On type formatting errors for args and kwargs * Handle f-strings * Stop importing from test code * #1308 Single line statements leading to an indentation on the next line * #726 editing python after inline if statement invalid indent * Undo change * Move constant * Harden LS startup error checks * #1364 Intellisense doesn't work after specific const string * Telemetry for the analysis enging * PR feedback * Fix typo * Test baseline update * Jedi 0.12 * Priority to goto_defition * News * Replace unzip * Linux flavors + test * Grammar check * Grammar test * Test baselines * Add news * Pin dependency [skip ci] * Specify markdown as preferable format * Improve function argument detection * Specify markdown * Pythia setting * Baseline updates * Baseline update * Improve startup * Handle missing interpreter better * Handle interpreter change * Delete old file * Fix LS startup time reporting * Remove Async suffix from IFileSystem * Remove Pythia * Remove pre-packaged MSIL * Exe name on Unix * Plain linux * Fix casing * Fix message * Update PTVS engine activation steps * Type formatter eats space in from . * fIX CASING * Remove flag
1 parent 3877334 commit eee1529

File tree

7 files changed

+21
-31
lines changed

7 files changed

+21
-31
lines changed

src/client/activation/analysis.ts

-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,6 @@ export class AnalysisExtensionActivator implements IExtensionActivator {
240240
maxDocumentationTextLength: 0
241241
},
242242
asyncStartup: true,
243-
intelliCodeEnabled: settings.intelliCodeEnabled,
244243
testEnvironment: isTestExecution()
245244
}
246245
};

src/client/activation/downloader.ts

-24
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ const downloadUriPrefix = 'https://pvsc.blob.core.windows.net/python-analysis';
2121
const downloadBaseFileName = 'Python-Analysis-VSCode';
2222
const downloadVersion = '0.1.0';
2323
const downloadFileExtension = '.nupkg';
24-
const modelName = 'model-sequence.json.gz';
2524

2625
export class AnalysisEngineDownloader {
2726
private readonly output: OutputChannel;
@@ -56,29 +55,6 @@ export class AnalysisEngineDownloader {
5655
}
5756
}
5857

59-
public async downloadIntelliCodeModel(context: ExtensionContext): Promise<void> {
60-
const modelFolder = path.join(context.extensionPath, 'analysis', 'Pythia', 'model');
61-
const localPath = path.join(modelFolder, modelName);
62-
if (await this.fs.fileExists(localPath)) {
63-
return;
64-
}
65-
66-
let localTempFilePath = '';
67-
try {
68-
localTempFilePath = await this.downloadFile(downloadUriPrefix, modelName, 'Downloading IntelliCode Model File... ');
69-
await this.fs.createDirectory(modelFolder);
70-
await this.fs.copyFile(localTempFilePath, localPath);
71-
} catch (err) {
72-
this.output.appendLine('failed.');
73-
this.output.appendLine(err);
74-
throw new Error(err);
75-
} finally {
76-
if (localTempFilePath.length > 0) {
77-
await this.fs.deleteFile(localTempFilePath);
78-
}
79-
}
80-
}
81-
8258
private async downloadFile(location: string, fileName: string, title: string): Promise<string> {
8359
const uri = `${location}/${fileName}`;
8460
this.output.append(`Downloading ${uri}... `);

src/client/activation/hashVerifier.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export class HashVerifier {
2222

2323
readStream.pipe(hash);
2424
await deferred.promise;
25-
const actual = hash.read();
26-
return expectedDigest === platformString ? true : actual === expectedDigest;
25+
const actual = hash.read() as string;
26+
return expectedDigest === platformString ? true : actual.toLowerCase() === expectedDigest.toLowerCase();
2727
}
2828
}

src/client/common/configSettings.ts

-3
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export const IS_WINDOWS = /^win/.test(process.platform);
2525
// tslint:disable-next-line:completed-docs
2626
export class PythonSettings extends EventEmitter implements IPythonSettings {
2727
private static pythonSettings: Map<string, PythonSettings> = new Map<string, PythonSettings>();
28-
public intelliCodeEnabled = true;
2928
public downloadCodeAnalysis = true;
3029
public jediEnabled = true;
3130
public jediPath = '';
@@ -127,8 +126,6 @@ export class PythonSettings extends EventEmitter implements IPythonSettings {
127126
this.jediPath = '';
128127
}
129128
this.jediMemoryLimit = pythonSettings.get<number>('jediMemoryLimit')!;
130-
} else {
131-
this.intelliCodeEnabled = systemVariables.resolveAny(pythonSettings.get<boolean>('intelliCodeEnabled', true))!;
132129
}
133130

134131
// tslint:disable-next-line:no-backbone-get-set-outside-model no-non-null-assertion

src/client/common/types.ts

-1
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ export interface IPythonSettings {
100100
readonly pythonPath: string;
101101
readonly venvPath: string;
102102
readonly venvFolders: string[];
103-
readonly intelliCodeEnabled: boolean;
104103
readonly downloadCodeAnalysis: boolean;
105104
readonly jediEnabled: boolean;
106105
readonly jediPath: string;

src/client/formatters/lineFormatter.ts

+10
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ export class LineFormatter {
9898
private handleOperator(index: number): void {
9999
const t = this.tokens.getItemAt(index);
100100
const prev = index > 0 ? this.tokens.getItemAt(index - 1) : undefined;
101+
const next = index < this.tokens.count - 1 ? this.tokens.getItemAt(index + 1) : undefined;
102+
101103
if (t.length === 1) {
102104
const opCode = this.text.charCodeAt(t.start);
103105
switch (opCode) {
@@ -107,6 +109,14 @@ export class LineFormatter {
107109
}
108110
break;
109111
case Char.Period:
112+
if (prev && this.isKeyword(prev, 'from')) {
113+
this.builder.softAppendSpace();
114+
}
115+
this.builder.append(this.text[t.start]);
116+
if (next && this.isKeyword(next, 'import')) {
117+
this.builder.softAppendSpace();
118+
}
119+
return;
110120
case Char.At:
111121
case Char.ExclamationMark:
112122
this.builder.append(this.text[t.start]);

src/test/format/extension.lineFormatter.test.ts

+9
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@ suite('Formatting - line formatter', () => {
112112
test('Function returning tuple', () => {
113113
testFormatLine('x,y=f(a)', 'x, y = f(a)');
114114
});
115+
test('from. import A', () => {
116+
testFormatLine('from. import A', 'from . import A');
117+
});
118+
test('from .. import', () => {
119+
testFormatLine('from ..import', 'from .. import');
120+
});
121+
test('from..x import', () => {
122+
testFormatLine('from..x import', 'from ..x import');
123+
});
115124
test('Grammar file', () => {
116125
const content = fs.readFileSync(grammarFile).toString('utf8');
117126
const lines = content.splitLines({ trim: false, removeEmptyEntries: false });

0 commit comments

Comments
 (0)