coc-pyright 1.1.180 → 1.1.190

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/lib/index.js +47 -24
  2. package/package.json +9 -9
package/lib/index.js CHANGED
@@ -21206,7 +21206,6 @@ var SystemVariables = class extends AbstractSystemVariables {
21206
21206
  // src/configSettings.ts
21207
21207
  var _PythonSettings = class {
21208
21208
  constructor() {
21209
- this.isWindows = process.platform === "win32";
21210
21209
  this.disposables = [];
21211
21210
  this._pythonPath = "";
21212
21211
  this.workspaceRoot = import_coc2.workspace.root ? import_coc2.workspace.root : __dirname;
@@ -21231,6 +21230,9 @@ var _PythonSettings = class {
21231
21230
  this.disposables = [];
21232
21231
  }
21233
21232
  resolvePythonFromVENV() {
21233
+ function pythonBinFromPath(p) {
21234
+ return process.platform === "win32" ? import_path.default.join(p, "Scripts", "python.exe") : import_path.default.join(p, "bin", "python");
21235
+ }
21234
21236
  try {
21235
21237
  let p = import_path.default.join(this.workspaceRoot, ".python-version");
21236
21238
  if (import_fs_extra.default.existsSync(p)) {
@@ -21255,20 +21257,20 @@ var _PythonSettings = class {
21255
21257
  info = item;
21256
21258
  }
21257
21259
  if (info) {
21258
- if (this.isWindows) {
21259
- return import_path.default.join(info, "Scripts", "python.exe");
21260
- }
21261
- return import_path.default.join(info, "bin", "python");
21260
+ return pythonBinFromPath(info);
21262
21261
  }
21263
21262
  }
21263
+ if (process.env.VIRTUAL_ENV && import_fs_extra.default.existsSync(import_path.default.join(process.env.VIRTUAL_ENV, "pyvenv.cfg"))) {
21264
+ return pythonBinFromPath(process.env.VIRTUAL_ENV);
21265
+ }
21266
+ if (process.env.CONDA_PREFIX) {
21267
+ return pythonBinFromPath(process.env.CONDA_PREFIX);
21268
+ }
21264
21269
  const files = import_fs_extra.default.readdirSync(this.workspaceRoot);
21265
21270
  for (const file of files) {
21266
- const p2 = import_path.default.join(this.workspaceRoot, file);
21267
- if (import_fs_extra.default.existsSync(import_path.default.join(p2, "pyvenv.cfg"))) {
21268
- if (this.isWindows) {
21269
- return import_path.default.join(p2, "Scripts", "python.exe");
21270
- }
21271
- return import_path.default.join(p2, "bin", "python");
21271
+ const x = import_path.default.join(this.workspaceRoot, file);
21272
+ if (import_fs_extra.default.existsSync(import_path.default.join(x, "pyvenv.cfg"))) {
21273
+ return pythonBinFromPath(x);
21272
21274
  }
21273
21275
  }
21274
21276
  } catch (e) {
@@ -22062,7 +22064,11 @@ var BlackdFormatter = class extends BaseFormatter {
22062
22064
  import_coc7.window.showErrorMessage("blackd request error");
22063
22065
  this.outputChannel.appendLine("");
22064
22066
  this.outputChannel.appendLine(`${"#".repeat(10)} blackd request error:`);
22065
- this.outputChannel.appendLine(e);
22067
+ if (typeof e === "string") {
22068
+ this.outputChannel.appendLine(e);
22069
+ } else if (e instanceof Error) {
22070
+ this.outputChannel.appendLine(e.message);
22071
+ }
22066
22072
  return [];
22067
22073
  }
22068
22074
  }
@@ -22178,7 +22184,12 @@ async function sortImports(extensionRoot, outputChannel) {
22178
22184
  const edits = getTextEditsFromPatch(doc.getDocumentContent(), patch);
22179
22185
  await doc.applyEdits(edits);
22180
22186
  } catch (err) {
22181
- const message = typeof err === "string" ? err : err.message ? err.message : err;
22187
+ let message = "";
22188
+ if (typeof err === "string") {
22189
+ message = err;
22190
+ } else if (err instanceof Error) {
22191
+ message = err.message;
22192
+ }
22182
22193
  outputChannel.appendLine(`${"#".repeat(10)} isort Output ${"#".repeat(10)}`);
22183
22194
  outputChannel.appendLine(`Error from isort:
22184
22195
  ${message}`);
@@ -22326,7 +22337,9 @@ var BaseLinter = class {
22326
22337
  return await this.parseMessages(result.stdout, document, cancellation, regEx);
22327
22338
  } catch (error) {
22328
22339
  this.outputChannel.appendLine(`Linting with ${this.info.id} failed:`);
22329
- this.outputChannel.appendLine(error.message.toString());
22340
+ if (error instanceof Error) {
22341
+ this.outputChannel.appendLine(error.message.toString());
22342
+ }
22330
22343
  return [];
22331
22344
  }
22332
22345
  }
@@ -22342,10 +22355,14 @@ var BaseLinter = class {
22342
22355
  break;
22343
22356
  }
22344
22357
  }
22345
- } catch (ex) {
22358
+ } catch (err) {
22346
22359
  this.outputChannel.appendLine(`${"#".repeat(10)} Linter ${this.info.id} failed to parse the line:`);
22347
22360
  this.outputChannel.appendLine(line);
22348
- this.outputChannel.appendLine(ex);
22361
+ if (typeof err === "string") {
22362
+ this.outputChannel.appendLine(err);
22363
+ } else if (err instanceof Error) {
22364
+ this.outputChannel.appendLine(err.message);
22365
+ }
22349
22366
  }
22350
22367
  }
22351
22368
  return messages;
@@ -22559,9 +22576,13 @@ var PyDocStyle = class extends BaseLinter {
22559
22576
  type: "",
22560
22577
  provider: this.info.id
22561
22578
  };
22562
- } catch (ex) {
22579
+ } catch (err) {
22563
22580
  this.outputChannel.appendLine(`Failed to parse pydocstyle line '${line}'`);
22564
- this.outputChannel.appendLine(ex.message);
22581
+ if (typeof err === "string") {
22582
+ this.outputChannel.appendLine(err);
22583
+ } else if (err instanceof Error) {
22584
+ this.outputChannel.appendLine(err.message);
22585
+ }
22565
22586
  return;
22566
22587
  }
22567
22588
  }).filter((item) => item !== void 0).map((item) => item);
@@ -23195,7 +23216,7 @@ async function applyImports(doc, resp, outputChannel) {
23195
23216
  if (typeof error === "string") {
23196
23217
  errorMessage = error;
23197
23218
  }
23198
- if (typeof error === "object" && error.message) {
23219
+ if (error instanceof Error) {
23199
23220
  errorMessage = error.message;
23200
23221
  }
23201
23222
  outputChannel.appendLine(`${"#".repeat(10)}Rope Output${"#".repeat(10)}`);
@@ -23245,7 +23266,7 @@ async function extractName(textEditor, newName, renameResponse, outputChannel) {
23245
23266
  if (typeof error === "string") {
23246
23267
  errorMessage = error;
23247
23268
  }
23248
- if (typeof error === "object" && error.message) {
23269
+ if (error instanceof Error) {
23249
23270
  errorMessage = error.message;
23250
23271
  }
23251
23272
  outputChannel.appendLine(`${"#".repeat(10)}Refactor Output${"#".repeat(10)}`);
@@ -23337,9 +23358,11 @@ async function provideCompletionItem(document, position, context, token, next) {
23337
23358
  const result = await next(document, position, context, token);
23338
23359
  if (!result)
23339
23360
  return;
23361
+ const items = Array.isArray(result) ? result : result.items;
23362
+ items.map((x) => delete x.sortText);
23363
+ items.sort((a, b) => a.kind && b.kind ? a.kind - b.kind : 0);
23340
23364
  const snippetSupport = import_coc24.workspace.getConfiguration("pyright").get("completion.snippetSupport");
23341
23365
  if (snippetSupport) {
23342
- const items = Array.isArray(result) ? result : result.items;
23343
23366
  for (const item of items) {
23344
23367
  if ((_a = item.data) == null ? void 0 : _a.funcParensDisabled)
23345
23368
  continue;
@@ -23349,7 +23372,7 @@ async function provideCompletionItem(document, position, context, token, next) {
23349
23372
  }
23350
23373
  }
23351
23374
  }
23352
- return result;
23375
+ return Array.isArray(result) ? items : { items, isIncomplete: result.isIncomplete };
23353
23376
  }
23354
23377
  async function resolveCompletionItem(item, token, next) {
23355
23378
  const result = await next(item, token);
@@ -23432,7 +23455,7 @@ async function activate(context) {
23432
23455
  const codeActionProvider = new PythonCodeActionProvider();
23433
23456
  context.subscriptions.push(import_coc24.languages.registerCodeActionProvider(documentSelector, codeActionProvider, "Pyright"));
23434
23457
  const provider = new ImportCompletionProvider();
23435
- context.subscriptions.push(import_coc24.languages.registerCompletionItemProvider("python-import", "PY", "python", provider, [" "]));
23458
+ context.subscriptions.push(import_coc24.languages.registerCompletionItemProvider("python-import", "PY", ["python"], provider, [" "]));
23436
23459
  const textEditorCommands = ["pyright.organizeimports", "pyright.addoptionalforparam"];
23437
23460
  textEditorCommands.forEach((commandName) => {
23438
23461
  context.subscriptions.push(import_coc24.commands.registerCommand(commandName, async (offset) => {
@@ -23518,7 +23541,7 @@ var ImportCompletionProvider = class {
23518
23541
  return [];
23519
23542
  const items = [];
23520
23543
  for (const o of result.items) {
23521
- items.push({ label: o.word, sortText: o.sortText });
23544
+ items.push({ label: o.word, sortText: o.sortText, kind: import_coc24.CompletionItemKind.Module, filterText: o.filterText });
23522
23545
  }
23523
23546
  return items;
23524
23547
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coc-pyright",
3
- "version": "1.1.180",
3
+ "version": "1.1.190",
4
4
  "description": "Pyright extension for coc.nvim, static type checker for Python",
5
5
  "author": "Heyward Fann <fannheyward@gmail.com>",
6
6
  "license": "MIT",
@@ -39,15 +39,15 @@
39
39
  "@types/fs-extra": "^9.0.2",
40
40
  "@types/md5": "^2.2.0",
41
41
  "@types/minimatch": "^3.0.3",
42
- "@types/node": "10.12.0",
42
+ "@types/node": "12.12",
43
43
  "@types/semver": "^7.3.9",
44
44
  "@types/which": "^2.0.0",
45
- "@typescript-eslint/eslint-plugin": "^5.1.0",
46
- "@typescript-eslint/parser": "^5.1.0",
47
- "coc.nvim": "^0.0.81-next.1",
45
+ "@typescript-eslint/eslint-plugin": "^5.4.0",
46
+ "@typescript-eslint/parser": "^5.4.0",
47
+ "coc.nvim": "^0.0.81-next.7",
48
48
  "diff-match-patch": "^1.0.5",
49
- "esbuild": "^0.13.8",
50
- "eslint": "^8.0.1",
49
+ "esbuild": "^0.13.15",
50
+ "eslint": "^8.3.0",
51
51
  "fs-extra": "^10.0.0",
52
52
  "iconv-lite": "^0.6.2",
53
53
  "md5": "^2.3.0",
@@ -57,7 +57,7 @@
57
57
  "rxjs-compat": "^6.6.7",
58
58
  "semver": "^7.3.2",
59
59
  "tree-kill": "^1.2.2",
60
- "typescript": "^4.4.4",
60
+ "typescript": "^4.5.2",
61
61
  "untildify": "^4.0.0",
62
62
  "which": "^2.0.2"
63
63
  },
@@ -1342,6 +1342,6 @@
1342
1342
  ]
1343
1343
  },
1344
1344
  "dependencies": {
1345
- "pyright": "^1.1.180"
1345
+ "pyright": "^1.1.190"
1346
1346
  }
1347
1347
  }