coc-pyright 1.1.185 → 1.1.194

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.
package/README.md CHANGED
@@ -67,6 +67,7 @@ These configurations are used by `coc-pyright`, you need to set them in your `co
67
67
  | pyright.server | Custom `pyright-langserver` path | '' |
68
68
  | pyright.disableCompletion | Disables completion from Pyright, left other LSP features work | false |
69
69
  | pyright.disableDiagnostics | Disable diagnostics from Pyright | false |
70
+ | pyright.completion.importSupport | Enable `python-import` completion source support | true |
70
71
  | pyright.completion.snippetSupport | Enable completion snippets support | true |
71
72
  | pyright.organizeimports.provider | Organize imports provider, `pyright` or `isort` | pyright |
72
73
 
package/lib/index.js CHANGED
@@ -1212,7 +1212,7 @@ var require_lru_cache = __commonJS({
1212
1212
  if (this[DISPOSE] && this[LRU_LIST] && this[LRU_LIST].length) {
1213
1213
  this[LRU_LIST].forEach((hit) => this[DISPOSE](hit.key, hit.value));
1214
1214
  }
1215
- this[CACHE] = new Map();
1215
+ this[CACHE] = /* @__PURE__ */ new Map();
1216
1216
  this[LRU_LIST] = new Yallist();
1217
1217
  this[LENGTH] = 0;
1218
1218
  }
@@ -1443,7 +1443,7 @@ var require_range = __commonJS({
1443
1443
  const compRe = loose ? re[t.COMPARATORLOOSE] : re[t.COMPARATOR];
1444
1444
  const rangeList = range.split(" ").map((comp) => parseComparator(comp, this.options)).join(" ").split(/\s+/).map((comp) => replaceGTE0(comp, this.options)).filter(this.options.loose ? (comp) => !!comp.match(compRe) : () => true).map((comp) => new Comparator(comp, this.options));
1445
1445
  const l = rangeList.length;
1446
- const rangeMap = new Map();
1446
+ const rangeMap = /* @__PURE__ */ new Map();
1447
1447
  for (const comp of rangeList) {
1448
1448
  if (isNullSet(comp))
1449
1449
  return [comp];
@@ -2162,7 +2162,7 @@ var require_subset = __commonJS({
2162
2162
  else
2163
2163
  dom = [new Comparator(">=0.0.0")];
2164
2164
  }
2165
- const eqSet = new Set();
2165
+ const eqSet = /* @__PURE__ */ new Set();
2166
2166
  let gt, lt2;
2167
2167
  for (const c of sub) {
2168
2168
  if (c.operator === ">" || c.operator === ">=")
@@ -16559,7 +16559,7 @@ var require_distinct = __commonJS({
16559
16559
  var noop_1 = require_noop();
16560
16560
  function distinct(keySelector, flushes) {
16561
16561
  return lift_1.operate(function(source, subscriber) {
16562
- var distinctKeys = new Set();
16562
+ var distinctKeys = /* @__PURE__ */ new Set();
16563
16563
  source.subscribe(new OperatorSubscriber_1.OperatorSubscriber(subscriber, function(value) {
16564
16564
  var key = keySelector ? keySelector(value) : value;
16565
16565
  if (!distinctKeys.has(key)) {
@@ -16994,7 +16994,7 @@ var require_groupBy = __commonJS({
16994
16994
  } else {
16995
16995
  duration = elementOrOptions.duration, element = elementOrOptions.element, connector = elementOrOptions.connector;
16996
16996
  }
16997
- var groups = new Map();
16997
+ var groups = /* @__PURE__ */ new Map();
16998
16998
  var notify = function(cb) {
16999
16999
  groups.forEach(cb);
17000
17000
  cb(subscriber);
@@ -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) {
@@ -21349,7 +21351,7 @@ var _PythonSettings = class {
21349
21351
  }
21350
21352
  };
21351
21353
  var PythonSettings = _PythonSettings;
21352
- PythonSettings.pythonSettings = new Map();
21354
+ PythonSettings.pythonSettings = /* @__PURE__ */ new Map();
21353
21355
  function getPythonExecutable(pythonPath) {
21354
21356
  pythonPath = (0, import_untildify.default)(pythonPath);
21355
21357
  if (pythonPath === "python" || pythonPath.indexOf(import_path.default.sep) === -1 || import_path.default.basename(pythonPath) === import_path.default.dirname(pythonPath)) {
@@ -21387,12 +21389,6 @@ var import_coc3 = __toModule(require("coc.nvim"));
21387
21389
  var import_diff_match_patch = __toModule(require_diff_match_patch());
21388
21390
  var import_os = __toModule(require("os"));
21389
21391
  var NEW_LINE_LENGTH = import_os.EOL.length;
21390
- var EditAction;
21391
- (function(EditAction2) {
21392
- EditAction2[EditAction2["Delete"] = 0] = "Delete";
21393
- EditAction2[EditAction2["Insert"] = 1] = "Insert";
21394
- EditAction2[EditAction2["Replace"] = 2] = "Replace";
21395
- })(EditAction || (EditAction = {}));
21396
21392
  var Edit = class {
21397
21393
  constructor(action, start) {
21398
21394
  this.action = action;
@@ -21401,11 +21397,11 @@ var Edit = class {
21401
21397
  }
21402
21398
  apply() {
21403
21399
  switch (this.action) {
21404
- case 1:
21400
+ case 1 /* Insert */:
21405
21401
  return import_coc3.TextEdit.insert(this.start, this.text);
21406
- case 0:
21402
+ case 0 /* Delete */:
21407
21403
  return import_coc3.TextEdit.del(import_coc3.Range.create(this.start, this.end));
21408
- case 2:
21404
+ case 2 /* Replace */:
21409
21405
  return import_coc3.TextEdit.replace(import_coc3.Range.create(this.start, this.end), this.text);
21410
21406
  default:
21411
21407
  return {
@@ -21438,17 +21434,17 @@ function getTextEditsInternal(before, diffs, startLine = 0) {
21438
21434
  switch (diffs[i][0]) {
21439
21435
  case dmp.DIFF_DELETE:
21440
21436
  if (edit === null) {
21441
- edit = new Edit(0, start);
21442
- } else if (edit.action !== 0) {
21437
+ edit = new Edit(0 /* Delete */, start);
21438
+ } else if (edit.action !== 0 /* Delete */) {
21443
21439
  throw new Error("cannot format due to an internal error.");
21444
21440
  }
21445
21441
  edit.end = { line, character };
21446
21442
  break;
21447
21443
  case dmp.DIFF_INSERT:
21448
21444
  if (edit === null) {
21449
- edit = new Edit(1, start);
21450
- } else if (edit.action === 0) {
21451
- edit.action = 2;
21445
+ edit = new Edit(1 /* Insert */, start);
21446
+ } else if (edit.action === 0 /* Delete */) {
21447
+ edit.action = 2 /* Replace */;
21452
21448
  }
21453
21449
  line = start.line;
21454
21450
  character = start.character;
@@ -22062,7 +22058,11 @@ var BlackdFormatter = class extends BaseFormatter {
22062
22058
  import_coc7.window.showErrorMessage("blackd request error");
22063
22059
  this.outputChannel.appendLine("");
22064
22060
  this.outputChannel.appendLine(`${"#".repeat(10)} blackd request error:`);
22065
- this.outputChannel.appendLine(e);
22061
+ if (typeof e === "string") {
22062
+ this.outputChannel.appendLine(e);
22063
+ } else if (e instanceof Error) {
22064
+ this.outputChannel.appendLine(e.message);
22065
+ }
22066
22066
  return [];
22067
22067
  }
22068
22068
  }
@@ -22084,7 +22084,7 @@ var BlackdFormatter = class extends BaseFormatter {
22084
22084
  // src/formatProvider.ts
22085
22085
  var PythonFormattingEditProvider = class {
22086
22086
  constructor() {
22087
- this.formatters = new Map();
22087
+ this.formatters = /* @__PURE__ */ new Map();
22088
22088
  this.disposables = [];
22089
22089
  this.pythonSettings = PythonSettings.getInstance();
22090
22090
  this.outputChannel = import_coc8.window.createOutputChannel("coc-pyright-formatting");
@@ -22178,7 +22178,12 @@ async function sortImports(extensionRoot, outputChannel) {
22178
22178
  const edits = getTextEditsFromPatch(doc.getDocumentContent(), patch);
22179
22179
  await doc.applyEdits(edits);
22180
22180
  } catch (err) {
22181
- const message = typeof err === "string" ? err : err.message ? err.message : err;
22181
+ let message = "";
22182
+ if (typeof err === "string") {
22183
+ message = err;
22184
+ } else if (err instanceof Error) {
22185
+ message = err.message;
22186
+ }
22182
22187
  outputChannel.appendLine(`${"#".repeat(10)} isort Output ${"#".repeat(10)}`);
22183
22188
  outputChannel.appendLine(`Error from isort:
22184
22189
  ${message}`);
@@ -22196,8 +22201,7 @@ var import_minimatch = __toModule(require_minimatch());
22196
22201
  var import_path4 = __toModule(require("path"));
22197
22202
 
22198
22203
  // src/types.ts
22199
- var Product;
22200
- (function(Product2) {
22204
+ var Product = /* @__PURE__ */ ((Product2) => {
22201
22205
  Product2[Product2["pylint"] = 1] = "pylint";
22202
22206
  Product2[Product2["flake8"] = 2] = "flake8";
22203
22207
  Product2[Product2["pycodestyle"] = 3] = "pycodestyle";
@@ -22213,26 +22217,27 @@ var Product;
22213
22217
  Product2[Product2["darker"] = 13] = "darker";
22214
22218
  Product2[Product2["rope"] = 14] = "rope";
22215
22219
  Product2[Product2["blackd"] = 15] = "blackd";
22216
- })(Product || (Product = {}));
22217
- var LintMessageSeverity;
22218
- (function(LintMessageSeverity2) {
22220
+ return Product2;
22221
+ })(Product || {});
22222
+ var LintMessageSeverity = /* @__PURE__ */ ((LintMessageSeverity2) => {
22219
22223
  LintMessageSeverity2[LintMessageSeverity2["Hint"] = 0] = "Hint";
22220
22224
  LintMessageSeverity2[LintMessageSeverity2["Error"] = 1] = "Error";
22221
22225
  LintMessageSeverity2[LintMessageSeverity2["Warning"] = 2] = "Warning";
22222
22226
  LintMessageSeverity2[LintMessageSeverity2["Information"] = 3] = "Information";
22223
- })(LintMessageSeverity || (LintMessageSeverity = {}));
22227
+ return LintMessageSeverity2;
22228
+ })(LintMessageSeverity || {});
22224
22229
  var LinterErrors;
22225
- (function(LinterErrors2) {
22230
+ ((LinterErrors2) => {
22226
22231
  let pylint;
22227
- (function(pylint2) {
22232
+ ((pylint2) => {
22228
22233
  pylint2.InvalidSyntax = "E0001";
22229
22234
  })(pylint = LinterErrors2.pylint || (LinterErrors2.pylint = {}));
22230
22235
  let prospector;
22231
- (function(prospector2) {
22236
+ ((prospector2) => {
22232
22237
  prospector2.InvalidSyntax = "F999";
22233
22238
  })(prospector = LinterErrors2.prospector || (LinterErrors2.prospector = {}));
22234
22239
  let flake8;
22235
- (function(flake82) {
22240
+ ((flake82) => {
22236
22241
  flake82.InvalidSyntax = "E999";
22237
22242
  })(flake8 = LinterErrors2.flake8 || (LinterErrors2.flake8 = {}));
22238
22243
  })(LinterErrors || (LinterErrors = {}));
@@ -22326,7 +22331,9 @@ var BaseLinter = class {
22326
22331
  return await this.parseMessages(result.stdout, document, cancellation, regEx);
22327
22332
  } catch (error) {
22328
22333
  this.outputChannel.appendLine(`Linting with ${this.info.id} failed:`);
22329
- this.outputChannel.appendLine(error.message.toString());
22334
+ if (error instanceof Error) {
22335
+ this.outputChannel.appendLine(error.message.toString());
22336
+ }
22330
22337
  return [];
22331
22338
  }
22332
22339
  }
@@ -22342,10 +22349,14 @@ var BaseLinter = class {
22342
22349
  break;
22343
22350
  }
22344
22351
  }
22345
- } catch (ex) {
22352
+ } catch (err) {
22346
22353
  this.outputChannel.appendLine(`${"#".repeat(10)} Linter ${this.info.id} failed to parse the line:`);
22347
22354
  this.outputChannel.appendLine(line);
22348
- this.outputChannel.appendLine(ex);
22355
+ if (typeof err === "string") {
22356
+ this.outputChannel.appendLine(err);
22357
+ } else if (err instanceof Error) {
22358
+ this.outputChannel.appendLine(err.message);
22359
+ }
22349
22360
  }
22350
22361
  }
22351
22362
  return messages;
@@ -22559,9 +22570,13 @@ var PyDocStyle = class extends BaseLinter {
22559
22570
  type: "",
22560
22571
  provider: this.info.id
22561
22572
  };
22562
- } catch (ex) {
22573
+ } catch (err) {
22563
22574
  this.outputChannel.appendLine(`Failed to parse pydocstyle line '${line}'`);
22564
- this.outputChannel.appendLine(ex.message);
22575
+ if (typeof err === "string") {
22576
+ this.outputChannel.appendLine(err);
22577
+ } else if (err instanceof Error) {
22578
+ this.outputChannel.appendLine(err.message);
22579
+ }
22565
22580
  return;
22566
22581
  }
22567
22582
  }).filter((item) => item !== void 0).map((item) => item);
@@ -22715,7 +22730,7 @@ var Pytype = class extends BaseLinter {
22715
22730
  // src/linters/lintingEngine.ts
22716
22731
  "use strict";
22717
22732
  var PYTHON = { language: "python" };
22718
- var lintSeverityToVSSeverity = new Map();
22733
+ var lintSeverityToVSSeverity = /* @__PURE__ */ new Map();
22719
22734
  lintSeverityToVSSeverity.set(LintMessageSeverity.Error, import_coc20.DiagnosticSeverity.Error);
22720
22735
  lintSeverityToVSSeverity.set(LintMessageSeverity.Hint, import_coc20.DiagnosticSeverity.Hint);
22721
22736
  lintSeverityToVSSeverity.set(LintMessageSeverity.Information, import_coc20.DiagnosticSeverity.Information);
@@ -22733,7 +22748,7 @@ var DisabledLinter = class {
22733
22748
  };
22734
22749
  var LintingEngine = class {
22735
22750
  constructor() {
22736
- this.pendingLintings = new Map();
22751
+ this.pendingLintings = /* @__PURE__ */ new Map();
22737
22752
  this.outputChannel = import_coc20.window.createOutputChannel("coc-pyright-linting");
22738
22753
  this.diagnosticCollection = import_coc20.languages.createDiagnosticCollection("python");
22739
22754
  this.configService = PythonSettings.getInstance();
@@ -23195,7 +23210,7 @@ async function applyImports(doc, resp, outputChannel) {
23195
23210
  if (typeof error === "string") {
23196
23211
  errorMessage = error;
23197
23212
  }
23198
- if (typeof error === "object" && error.message) {
23213
+ if (error instanceof Error) {
23199
23214
  errorMessage = error.message;
23200
23215
  }
23201
23216
  outputChannel.appendLine(`${"#".repeat(10)}Rope Output${"#".repeat(10)}`);
@@ -23245,7 +23260,7 @@ async function extractName(textEditor, newName, renameResponse, outputChannel) {
23245
23260
  if (typeof error === "string") {
23246
23261
  errorMessage = error;
23247
23262
  }
23248
- if (typeof error === "object" && error.message) {
23263
+ if (error instanceof Error) {
23249
23264
  errorMessage = error.message;
23250
23265
  }
23251
23266
  outputChannel.appendLine(`${"#".repeat(10)}Refactor Output${"#".repeat(10)}`);
@@ -23433,8 +23448,11 @@ async function activate(context) {
23433
23448
  context.subscriptions.push(new LinterProvider(context));
23434
23449
  const codeActionProvider = new PythonCodeActionProvider();
23435
23450
  context.subscriptions.push(import_coc24.languages.registerCodeActionProvider(documentSelector, codeActionProvider, "Pyright"));
23436
- const provider = new ImportCompletionProvider();
23437
- context.subscriptions.push(import_coc24.languages.registerCompletionItemProvider("python-import", "PY", "python", provider, [" "]));
23451
+ const importSupport = pyrightCfg.get("completion.importSupport");
23452
+ if (importSupport) {
23453
+ const provider = new ImportCompletionProvider();
23454
+ context.subscriptions.push(import_coc24.languages.registerCompletionItemProvider("python-import", "PY", ["python"], provider, [" "]));
23455
+ }
23438
23456
  const textEditorCommands = ["pyright.organizeimports", "pyright.addoptionalforparam"];
23439
23457
  textEditorCommands.forEach((commandName) => {
23440
23458
  context.subscriptions.push(import_coc24.commands.registerCommand(commandName, async (offset) => {
@@ -23520,7 +23538,7 @@ var ImportCompletionProvider = class {
23520
23538
  return [];
23521
23539
  const items = [];
23522
23540
  for (const o of result.items) {
23523
- items.push({ label: o.word, sortText: o.sortText });
23541
+ items.push({ label: o.word, sortText: o.sortText, kind: import_coc24.CompletionItemKind.Module, filterText: o.filterText });
23524
23542
  }
23525
23543
  return items;
23526
23544
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coc-pyright",
3
- "version": "1.1.185",
3
+ "version": "1.1.194",
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.3.0",
46
- "@typescript-eslint/parser": "^5.3.0",
47
- "coc.nvim": "^0.0.81-next.1",
45
+ "@typescript-eslint/eslint-plugin": "^5.6.0",
46
+ "@typescript-eslint/parser": "^5.6.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.2.0",
49
+ "esbuild": "^0.14.2",
50
+ "eslint": "^8.4.1",
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.3",
61
61
  "untildify": "^4.0.0",
62
62
  "which": "^2.0.2"
63
63
  },
@@ -163,7 +163,7 @@
163
163
  "reportPropertyTypeMismatch": {
164
164
  "type": "string",
165
165
  "description": "Diagnostics for property whose setter and getter have mismatched types.",
166
- "default": "error",
166
+ "default": "none",
167
167
  "enum": [
168
168
  "none",
169
169
  "information",
@@ -1271,6 +1271,11 @@
1271
1271
  "default": false,
1272
1272
  "description": "Disable diagnostics from Pyright"
1273
1273
  },
1274
+ "pyright.completion.importSupport": {
1275
+ "type": "boolean",
1276
+ "default": true,
1277
+ "description": "Enable `python-import` completion source, will list suggestions after input `import`"
1278
+ },
1274
1279
  "pyright.completion.snippetSupport": {
1275
1280
  "type": "boolean",
1276
1281
  "default": true,
@@ -1342,6 +1347,6 @@
1342
1347
  ]
1343
1348
  },
1344
1349
  "dependencies": {
1345
- "pyright": "^1.1.185"
1350
+ "pyright": "^1.1.194"
1346
1351
  }
1347
1352
  }
@@ -141,7 +141,7 @@
141
141
  "$id": "#/properties/reportPropertyTypeMismatch",
142
142
  "$ref": "#/definitions/diagnostic",
143
143
  "title": "Controls reporting of property getter/setter type mismatches",
144
- "default": "error"
144
+ "default": "none"
145
145
  },
146
146
  "reportFunctionMemberAccess": {
147
147
  "$id": "#/properties/reportFunctionMemberAccess",