Skip to content

Commit 99349d5

Browse files
authored
Update Jedi and parso (#6999)
* Update requirements.txt * Update Jedi signatures * News file * Move tslint disable * Python 2.7 tests
1 parent 039e562 commit 99349d5

5 files changed

Lines changed: 72 additions & 43 deletions

File tree

news/1 Enhancements/6294.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update Jedi to 0.15.0 and parso to 0.5.1.

requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
jedi==0.13.3
2-
parso==0.5.0
1+
jedi==0.15.0
2+
parso==0.5.1
33
isort==4.3.21
44
ptvsd==4.3.2

src/test/languageServers/jedi/definitions/hover.jedi.test.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,14 @@ suite('Hover Definition (Jedi)', () => {
208208
assert.equal(def.length, 1, 'Definition length is incorrect');
209209
assert.equal(`${def[0].range!.start.line},${def[0].range!.start.character}`, '8,11', 'Start position is incorrect');
210210
assert.equal(`${def[0].range!.end.line},${def[0].range!.end.character}`, '8,15', 'End position is incorrect');
211-
// tslint:disable-next-line:prefer-template
212-
assert.equal(normalizeMarkedString(def[0].contents[0]), '```python' + EOL +
213-
'def acos(x)' + EOL +
214-
'```' + EOL +
215-
'Return the arc cosine (measured in radians) of x.', 'Invalid contents');
216-
}).then(done, done);
211+
assert.equal(
212+
normalizeMarkedString(def[0].contents[0]),
213+
// tslint:disable-next-line:prefer-template
214+
'```python' + EOL + 'def acos(x: SupportsFloat)' + EOL + '```' + EOL + 'Return the arc cosine (measured in radians) of x.',
215+
'Invalid contents'
216+
);
217+
})
218+
.then(done, done);
217219
});
218220

219221
test('Highlight Multiline Method Signature', done => {

src/test/languageServers/jedi/definitions/navigation.test.ts

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,37 @@ import * as assert from 'assert';
77
import * as path from 'path';
88
import * as vscode from 'vscode';
99
import { EXTENSION_ROOT_DIR } from '../../../../client/common/constants';
10+
import { rootWorkspaceUri } from '../../../common';
1011
import { closeActiveWindows, initialize, initializeTest } from '../../../initialize';
12+
import { UnitTestIocContainer } from '../../../testing/serviceRegistry';
1113

1214
const decoratorsPath = path.join(EXTENSION_ROOT_DIR, 'src', 'test', 'pythonFiles', 'definition', 'navigation');
1315
const fileDefinitions = path.join(decoratorsPath, 'definitions.py');
1416
const fileUsages = path.join(decoratorsPath, 'usages.py');
1517

1618
// tslint:disable-next-line:max-func-body-length
1719
suite('Language Server: Definition Navigation', () => {
18-
suiteSetup(initialize);
20+
let isPython2: boolean;
21+
let ioc: UnitTestIocContainer;
22+
23+
suiteSetup(async () => {
24+
await initialize();
25+
initializeDI();
26+
isPython2 = (await ioc.getPythonMajorVersion(rootWorkspaceUri!)) === 2;
27+
});
1928
setup(initializeTest);
2029
suiteTeardown(closeActiveWindows);
21-
teardown(closeActiveWindows);
30+
teardown(async () => {
31+
await closeActiveWindows();
32+
await ioc.dispose();
33+
});
34+
35+
function initializeDI() {
36+
ioc = new UnitTestIocContainer();
37+
ioc.registerCommonTypes();
38+
ioc.registerVariableTypes();
39+
ioc.registerProcessTypes();
40+
}
2241

2342
const assertFile = (expectedLocation: string, location: vscode.Uri) => {
2443
const relLocation = vscode.workspace.asRelativePath(location);
@@ -42,7 +61,7 @@ suite('Language Server: Definition Navigation', () => {
4261
assert(vscode.window.activeTextEditor, 'No active editor');
4362

4463
const locations = await vscode.commands.executeCommand<vscode.Location[]>('vscode.executeDefinitionProvider', textDocument.uri, startPosition);
45-
assert.equal(expectedFiles.length, locations!.length, 'Wrong number of results');
64+
assert.equal(locations!.length, expectedFiles.length, 'Wrong number of results');
4665

4766
for (let i = 0; i < locations!.length; i += 1) {
4867
assertFile(expectedFiles[i], locations![i].uri);
@@ -107,24 +126,18 @@ suite('Language Server: Definition Navigation', () => {
107126
[new vscode.Range(14, 0, 18, 7)]
108127
));
109128

110-
test('Specifically imported decorator usage', buildTest(
111-
fileUsages,
112-
new vscode.Position(7, 1),
113-
[fileDefinitions],
114-
[new vscode.Range(2, 0, 11, 17)]
115-
));
129+
test('Specifically imported decorator usage', async () => {
130+
const navigationTest = buildTest(fileUsages, new vscode.Position(7, 1), isPython2 ? [] : [fileDefinitions], [new vscode.Range(2, 0, 11, 17)]);
131+
await navigationTest();
132+
});
116133

117-
test('Specifically imported function decorated by stdlib', buildTest(
118-
fileUsages,
119-
new vscode.Position(14, 6),
120-
[fileDefinitions],
121-
[new vscode.Range(21, 0, 27, 17)]
122-
));
134+
test('Specifically imported function decorated by stdlib', async () => {
135+
const navigationTest = buildTest(fileUsages, new vscode.Position(14, 6), isPython2 ? [] : [fileDefinitions], [new vscode.Range(21, 0, 27, 17)]);
136+
await navigationTest();
137+
});
123138

124-
test('Specifically imported function decorated by local decorator', buildTest(
125-
fileUsages,
126-
new vscode.Position(15, 6),
127-
[fileDefinitions],
128-
[new vscode.Range(14, 0, 18, 7)]
129-
));
139+
test('Specifically imported function decorated by local decorator', async () => {
140+
const navigationTest = buildTest(fileUsages, new vscode.Position(15, 6), isPython2 ? [] : [fileDefinitions], [new vscode.Range(14, 0, 18, 7)]);
141+
await navigationTest();
142+
});
130143
});

src/test/languageServers/jedi/signature/signature.jedi.test.ts

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,28 @@ suite('Signatures (Jedi)', () => {
6565
});
6666

6767
test('For intrinsic', async () => {
68-
const expected = [
68+
let expected: SignatureHelpResult[];
69+
if (isPython2) {
70+
expected = [
71+
new SignatureHelpResult(0, 0, 0, 0, null),
72+
new SignatureHelpResult(0, 1, 0, 0, null),
73+
new SignatureHelpResult(0, 2, 0, 0, null),
74+
new SignatureHelpResult(0, 3, 0, 0, null),
75+
new SignatureHelpResult(0, 4, 0, 0, null),
76+
new SignatureHelpResult(0, 5, 0, 0, null),
77+
new SignatureHelpResult(0, 6, 1, 0, 'x'),
78+
new SignatureHelpResult(0, 7, 1, 0, 'x')
79+
];
80+
} else {
81+
expected = [
6982
new SignatureHelpResult(0, 0, 0, 0, null),
7083
new SignatureHelpResult(0, 1, 0, 0, null),
7184
new SignatureHelpResult(0, 2, 0, 0, null),
7285
new SignatureHelpResult(0, 3, 0, 0, null),
7386
new SignatureHelpResult(0, 4, 0, 0, null),
7487
new SignatureHelpResult(0, 5, 0, 0, null),
75-
new SignatureHelpResult(0, 6, 1, 0, 'stop'),
76-
new SignatureHelpResult(0, 7, 1, 0, 'stop')
88+
new SignatureHelpResult(0, 6, 2, 0, 'start'),
89+
new SignatureHelpResult(0, 7, 2, 0, 'start')
7790
// new SignatureHelpResult(0, 6, 1, 0, 'start'),
7891
// new SignatureHelpResult(0, 7, 1, 0, 'start'),
7992
// new SignatureHelpResult(0, 8, 1, 1, 'stop'),
@@ -82,6 +95,7 @@ suite('Signatures (Jedi)', () => {
8295
// new SignatureHelpResult(0, 11, 1, 2, 'step'),
8396
// new SignatureHelpResult(1, 0, 1, 2, 'step')
8497
];
98+
}
8599

86100
const document = await openDocument(path.join(autoCompPath, 'basicSig.py'));
87101
for (let i = 0; i < expected.length; i += 1) {
@@ -92,18 +106,17 @@ suite('Signatures (Jedi)', () => {
92106
test('For ellipsis', async function () {
93107
if (isPython2) {
94108
// tslint:disable-next-line:no-invalid-this
95-
this.skip();
96-
return;
109+
return this.skip();
97110
}
98111
const expected = [
99112
new SignatureHelpResult(0, 5, 0, 0, null),
100-
new SignatureHelpResult(0, 6, 1, 0, 'value'),
101-
new SignatureHelpResult(0, 7, 1, 0, 'value'),
102-
new SignatureHelpResult(0, 8, 1, 1, '...'),
103-
new SignatureHelpResult(0, 9, 1, 1, '...'),
104-
new SignatureHelpResult(0, 10, 1, 1, '...'),
105-
new SignatureHelpResult(0, 11, 1, 2, 'sep'),
106-
new SignatureHelpResult(0, 12, 1, 2, 'sep')
113+
new SignatureHelpResult(0, 6, 1, 0, 'values'),
114+
new SignatureHelpResult(0, 7, 1, 0, 'values'),
115+
new SignatureHelpResult(0, 8, 1, 0, 'values'),
116+
new SignatureHelpResult(0, 9, 1, 0, 'values'),
117+
new SignatureHelpResult(0, 10, 1, 0, 'values'),
118+
new SignatureHelpResult(0, 11, 1, 0, 'values'),
119+
new SignatureHelpResult(0, 12, 1, 0, 'values')
107120
];
108121

109122
const document = await openDocument(path.join(autoCompPath, 'ellipsis.py'));
@@ -115,9 +128,9 @@ suite('Signatures (Jedi)', () => {
115128
test('For pow', async () => {
116129
let expected: SignatureHelpResult;
117130
if (isPython2) {
118-
expected = new SignatureHelpResult(0, 4, 1, 0, 'x');
131+
expected = new SignatureHelpResult(0, 4, 4, 0, 'x');
119132
} else {
120-
expected = new SignatureHelpResult(0, 4, 1, 0, null);
133+
expected = new SignatureHelpResult(0, 4, 4, 0, null);
121134
}
122135

123136
const document = await openDocument(path.join(autoCompPath, 'noSigPy3.py'));

0 commit comments

Comments
 (0)