Skip to content

Commit 5b0152d

Browse files
author
Kartik Raj
authored
Upgrade isort to 5.3.2 (#13340)
* Upgrade isort + remove unnecessary logging * Remove old workaround * Update test * News entries * Revert test
1 parent 0c6f631 commit 5b0152d

7 files changed

Lines changed: 17 additions & 36 deletions

File tree

news/1 Enhancements/12932.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Upgraded isort to `5.3.2`.

news/2 Fixes/12949.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fixed `Sort imports` command with setuptools version `49.2`.

pythonFiles/sortImports.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,6 @@
99
isort_path = os.path.join(os.path.dirname(__file__), "lib", "python")
1010
sys.path.insert(0, isort_path)
1111

12-
# Work around stdin buffering issues on windows (https://bugs.python.org/issue40540)
13-
# caused in part by isort seeking within the stdin stream by replacing the
14-
# stream with something which is definitely seekable.
15-
try:
16-
# python 3
17-
stdin = sys.stdin.buffer
18-
except AttributeError:
19-
# python 2
20-
stdin = sys.stdin
21-
22-
sys.stdin = io.BytesIO(stdin.read())
23-
# End workaround
24-
2512
import isort.main
2613

2714
isort.main.main()

requirements.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# IntelliSense
22
jedi==0.17.2
33
# Sort Imports
4-
isort==4.3.21
4+
isort==5.3.2
55
# DS Python daemon
66
python-jsonrpc-server==0.2.0

requirements.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,18 @@
77
future==0.18.2 \
88
--hash=sha256:b1bead90b70cf6ec3f0710ae53a525360fa360d306a86583adc6bf83a4db537d \
99
# via python-jsonrpc-server
10-
isort==4.3.21 \
11-
--hash=sha256:54da7e92468955c4fceacd0c86bd0ec997b0e1ee80d97f67c35a78b719dccab1 \
12-
--hash=sha256:6e811fcb295968434526407adb8796944f1988c5b65e8139058f2014cbe100fd
10+
isort==5.3.2 \
11+
--hash=sha256:5196bd2f5b23dc91215734b1c96c6d28390061d69860a948094c12635d6d64e6 \
12+
--hash=sha256:ba83762132a8661d3525f87a86549712fb7d8da79eeb452e01f327ada9e87920 \
13+
# via -r requirements.in
1314
jedi==0.17.2 \
1415
--hash=sha256:86ed7d9b750603e4ba582ea8edc678657fb4007894a12bcf6f4bb97892f31d20 \
15-
--hash=sha256:98cc583fa0f2f8304968199b01b6b4b94f469a1f4a74c1560506ca2a211378b5
16+
--hash=sha256:98cc583fa0f2f8304968199b01b6b4b94f469a1f4a74c1560506ca2a211378b5 \
17+
# via -r requirements.in
1618
parso==0.7.0 \
1719
--hash=sha256:158c140fc04112dc45bca311633ae5033c2c2a7b732fa33d0955bad8152a8dd0 \
1820
--hash=sha256:908e9fae2144a076d72ae4e25539143d40b8e3eafbaeae03c1bfe226f4cdf12c \
1921
# via jedi
2022
python-jsonrpc-server==0.2.0 \
21-
--hash=sha256:59ce9c9523c14c493a327b3a27ee37464a36dc2b9d8ab485ecbcedd38840380a
23+
--hash=sha256:59ce9c9523c14c493a327b3a27ee37464a36dc2b9d8ab485ecbcedd38840380a \
24+
# via -r requirements.in

src/test/common.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,9 @@ export async function updateSetting(
7878
resource: Uri | undefined,
7979
configTarget: ConfigurationTarget
8080
) {
81-
// The hooks and tests which use this method often timeout especially in case of multiroot workspaces.
82-
// I am suspecting this is because the configTarget is ConfigurationTarget.WorkspaceFolder
83-
// and updates in that configTarget take longer time. Logging to see if there's any truth to this.
84-
console.log(`Starting diagnosis for configuration: ${configTarget}`);
85-
console.time('Update setting diagnosis');
8681
const vscode = require('vscode') as typeof import('vscode');
8782
const settings = vscode.workspace.getConfiguration('python', resource || null);
8883
const currentValue = settings.inspect(setting);
89-
console.timeLog('Update setting diagnosis');
9084
if (
9185
currentValue !== undefined &&
9286
((configTarget === vscode.ConfigurationTarget.Global && currentValue.globalValue === value) ||
@@ -95,12 +89,9 @@ export async function updateSetting(
9589
currentValue.workspaceFolderValue === value))
9690
) {
9791
await disposePythonSettings();
98-
console.timeEnd('Update setting diagnosis');
9992
return;
10093
}
101-
console.timeLog('Update setting diagnosis');
10294
await settings.update(setting, value, configTarget);
103-
console.timeLog('Update setting diagnosis');
10495

10596
// We've experienced trouble with .update in the past, where VSC returns stale data even
10697
// after invoking the update method. This issue has regressed a few times as well. This
@@ -110,8 +101,6 @@ export async function updateSetting(
110101
// ... please see issue #2356 and PR #2332 for a discussion on the matter
111102

112103
await disposePythonSettings();
113-
console.timeEnd('Update setting diagnosis');
114-
console.log('Ending diagnosis');
115104
}
116105

117106
export async function clearPythonPathInWorkspaceFolder(resource: string | Uri) {

src/test/format/extension.sort.test.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ suite('Sorting', () => {
6868
const edit = (await sorter.provideDocumentSortImportsEdits(textDocument.uri))!;
6969
expect(edit.entries()).to.be.lengthOf(1);
7070
const edits = edit.entries()[0][1];
71+
expect(edits.length).to.equal(4);
7172
assert.equal(
7273
edits.filter((value) => value.newText === EOL && value.range.isEqual(new Range(2, 0, 2, 0))).length,
7374
1,
@@ -81,15 +82,14 @@ suite('Sorting', () => {
8182
assert.equal(
8283
edits.filter(
8384
(value) =>
84-
value.newText ===
85-
`from rope.base import libutils${EOL}from rope.refactor.extract import ExtractMethod, ExtractVariable${EOL}from rope.refactor.rename import Rename${EOL}` &&
86-
value.range.isEqual(new Range(6, 0, 6, 0))
85+
value.newText === `from rope.refactor.extract import ExtractMethod, ExtractVariable${EOL}` &&
86+
value.range.isEqual(new Range(15, 0, 15, 0))
8787
).length,
8888
1,
8989
'Text not found'
9090
);
9191
assert.equal(
92-
edits.filter((value) => value.newText === '' && value.range.isEqual(new Range(13, 0, 18, 0))).length,
92+
edits.filter((value) => value.newText === '' && value.range.isEqual(new Range(16, 0, 18, 0))).length,
9393
1,
9494
'"" not found'
9595
);
@@ -129,7 +129,7 @@ suite('Sorting', () => {
129129
test('With Changes and Config in Args', async () => {
130130
await updateSetting(
131131
'sortImports.args',
132-
['-sp', path.join(sortingPath, 'withconfig')],
132+
['--sp', path.join(sortingPath, 'withconfig')],
133133
Uri.file(sortingPath),
134134
ConfigurationTarget.Workspace
135135
);
@@ -146,7 +146,7 @@ suite('Sorting', () => {
146146
test('With Changes and Config in Args (via Command)', async () => {
147147
await updateSetting(
148148
'sortImports.args',
149-
['-sp', path.join(sortingPath, 'withconfig')],
149+
['--sp', path.join(sortingPath, 'withconfig')],
150150
Uri.file(sortingPath),
151151
configTarget
152152
);

0 commit comments

Comments
 (0)