coc-pyright 1.1.301 → 1.1.303
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/lib/index.js +1290 -1179
- package/package.json +6 -6
- package/schemas/pyrightconfig.schema.json +1 -1
package/lib/index.js
CHANGED
|
@@ -3454,20 +3454,30 @@ var require_fs = __commonJS({
|
|
|
3454
3454
|
});
|
|
3455
3455
|
});
|
|
3456
3456
|
};
|
|
3457
|
-
|
|
3458
|
-
|
|
3459
|
-
|
|
3460
|
-
|
|
3461
|
-
|
|
3462
|
-
|
|
3463
|
-
|
|
3464
|
-
|
|
3465
|
-
|
|
3466
|
-
resolve({ bytesWritten, buffers: buffers2 });
|
|
3467
|
-
});
|
|
3457
|
+
exports.readv = function(fd, buffers, ...args) {
|
|
3458
|
+
if (typeof args[args.length - 1] === "function") {
|
|
3459
|
+
return fs6.readv(fd, buffers, ...args);
|
|
3460
|
+
}
|
|
3461
|
+
return new Promise((resolve, reject) => {
|
|
3462
|
+
fs6.readv(fd, buffers, ...args, (err, bytesRead, buffers2) => {
|
|
3463
|
+
if (err)
|
|
3464
|
+
return reject(err);
|
|
3465
|
+
resolve({ bytesRead, buffers: buffers2 });
|
|
3468
3466
|
});
|
|
3469
|
-
};
|
|
3470
|
-
}
|
|
3467
|
+
});
|
|
3468
|
+
};
|
|
3469
|
+
exports.writev = function(fd, buffers, ...args) {
|
|
3470
|
+
if (typeof args[args.length - 1] === "function") {
|
|
3471
|
+
return fs6.writev(fd, buffers, ...args);
|
|
3472
|
+
}
|
|
3473
|
+
return new Promise((resolve, reject) => {
|
|
3474
|
+
fs6.writev(fd, buffers, ...args, (err, bytesWritten, buffers2) => {
|
|
3475
|
+
if (err)
|
|
3476
|
+
return reject(err);
|
|
3477
|
+
resolve({ bytesWritten, buffers: buffers2 });
|
|
3478
|
+
});
|
|
3479
|
+
});
|
|
3480
|
+
};
|
|
3471
3481
|
if (typeof fs6.realpath.native === "function") {
|
|
3472
3482
|
exports.realpath.native = u(fs6.realpath.native);
|
|
3473
3483
|
} else {
|
|
@@ -3765,9 +3775,13 @@ var require_copy = __commonJS({
|
|
|
3765
3775
|
stat.checkParentPaths(src, srcStat, dest, "copy", (err2) => {
|
|
3766
3776
|
if (err2)
|
|
3767
3777
|
return cb(err2);
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3778
|
+
runFilter(src, dest, opts, (err3, include) => {
|
|
3779
|
+
if (err3)
|
|
3780
|
+
return cb(err3);
|
|
3781
|
+
if (!include)
|
|
3782
|
+
return cb();
|
|
3783
|
+
checkParentDir(destStat, src, dest, opts, cb);
|
|
3784
|
+
});
|
|
3771
3785
|
});
|
|
3772
3786
|
});
|
|
3773
3787
|
}
|
|
@@ -3785,17 +3799,10 @@ var require_copy = __commonJS({
|
|
|
3785
3799
|
});
|
|
3786
3800
|
});
|
|
3787
3801
|
}
|
|
3788
|
-
function
|
|
3789
|
-
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
return cb();
|
|
3793
|
-
}, (error) => cb(error));
|
|
3794
|
-
}
|
|
3795
|
-
function startCopy(destStat, src, dest, opts, cb) {
|
|
3796
|
-
if (opts.filter)
|
|
3797
|
-
return handleFilter(getStats, destStat, src, dest, opts, cb);
|
|
3798
|
-
return getStats(destStat, src, dest, opts, cb);
|
|
3802
|
+
function runFilter(src, dest, opts, cb) {
|
|
3803
|
+
if (!opts.filter)
|
|
3804
|
+
return cb(null, true);
|
|
3805
|
+
Promise.resolve(opts.filter(src, dest)).then((include) => cb(null, include), (error) => cb(error));
|
|
3799
3806
|
}
|
|
3800
3807
|
function getStats(destStat, src, dest, opts, cb) {
|
|
3801
3808
|
const stat2 = opts.dereference ? fs6.stat : fs6.lstat;
|
|
@@ -3906,14 +3913,20 @@ var require_copy = __commonJS({
|
|
|
3906
3913
|
function copyDirItem(items, item, src, dest, opts, cb) {
|
|
3907
3914
|
const srcItem = path12.join(src, item);
|
|
3908
3915
|
const destItem = path12.join(dest, item);
|
|
3909
|
-
|
|
3916
|
+
runFilter(srcItem, destItem, opts, (err, include) => {
|
|
3910
3917
|
if (err)
|
|
3911
3918
|
return cb(err);
|
|
3912
|
-
|
|
3913
|
-
|
|
3919
|
+
if (!include)
|
|
3920
|
+
return copyDirItems(items, src, dest, opts, cb);
|
|
3921
|
+
stat.checkPaths(srcItem, destItem, "copy", opts, (err2, stats) => {
|
|
3914
3922
|
if (err2)
|
|
3915
3923
|
return cb(err2);
|
|
3916
|
-
|
|
3924
|
+
const { destStat } = stats;
|
|
3925
|
+
getStats(destStat, srcItem, destItem, opts, (err3) => {
|
|
3926
|
+
if (err3)
|
|
3927
|
+
return cb(err3);
|
|
3928
|
+
return copyDirItems(items, src, dest, opts, cb);
|
|
3929
|
+
});
|
|
3917
3930
|
});
|
|
3918
3931
|
});
|
|
3919
3932
|
}
|
|
@@ -3939,7 +3952,7 @@ var require_copy = __commonJS({
|
|
|
3939
3952
|
if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
|
|
3940
3953
|
return cb(new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`));
|
|
3941
3954
|
}
|
|
3942
|
-
if (
|
|
3955
|
+
if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
|
|
3943
3956
|
return cb(new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`));
|
|
3944
3957
|
}
|
|
3945
3958
|
return copyLink(resolvedSrc, dest, cb);
|
|
@@ -3983,9 +3996,6 @@ var require_copy_sync = __commonJS({
|
|
|
3983
3996
|
}
|
|
3984
3997
|
const { srcStat, destStat } = stat.checkPathsSync(src, dest, "copy", opts);
|
|
3985
3998
|
stat.checkParentPathsSync(src, srcStat, dest, "copy");
|
|
3986
|
-
return handleFilterAndCopy(destStat, src, dest, opts);
|
|
3987
|
-
}
|
|
3988
|
-
function handleFilterAndCopy(destStat, src, dest, opts) {
|
|
3989
3999
|
if (opts.filter && !opts.filter(src, dest))
|
|
3990
4000
|
return;
|
|
3991
4001
|
const destParent = path12.dirname(dest);
|
|
@@ -3993,11 +4003,6 @@ var require_copy_sync = __commonJS({
|
|
|
3993
4003
|
mkdirsSync(destParent);
|
|
3994
4004
|
return getStats(destStat, src, dest, opts);
|
|
3995
4005
|
}
|
|
3996
|
-
function startCopy(destStat, src, dest, opts) {
|
|
3997
|
-
if (opts.filter && !opts.filter(src, dest))
|
|
3998
|
-
return;
|
|
3999
|
-
return getStats(destStat, src, dest, opts);
|
|
4000
|
-
}
|
|
4001
4006
|
function getStats(destStat, src, dest, opts) {
|
|
4002
4007
|
const statSync = opts.dereference ? fs6.statSync : fs6.lstatSync;
|
|
4003
4008
|
const srcStat = statSync(src);
|
|
@@ -4066,8 +4071,10 @@ var require_copy_sync = __commonJS({
|
|
|
4066
4071
|
function copyDirItem(item, src, dest, opts) {
|
|
4067
4072
|
const srcItem = path12.join(src, item);
|
|
4068
4073
|
const destItem = path12.join(dest, item);
|
|
4074
|
+
if (opts.filter && !opts.filter(srcItem, destItem))
|
|
4075
|
+
return;
|
|
4069
4076
|
const { destStat } = stat.checkPathsSync(srcItem, destItem, "copy", opts);
|
|
4070
|
-
return
|
|
4077
|
+
return getStats(destStat, srcItem, destItem, opts);
|
|
4071
4078
|
}
|
|
4072
4079
|
function onLink(destStat, src, dest, opts) {
|
|
4073
4080
|
let resolvedSrc = fs6.readlinkSync(src);
|
|
@@ -4091,7 +4098,7 @@ var require_copy_sync = __commonJS({
|
|
|
4091
4098
|
if (stat.isSrcSubdir(resolvedSrc, resolvedDest)) {
|
|
4092
4099
|
throw new Error(`Cannot copy '${resolvedSrc}' to a subdirectory of itself, '${resolvedDest}'.`);
|
|
4093
4100
|
}
|
|
4094
|
-
if (
|
|
4101
|
+
if (stat.isSrcSubdir(resolvedDest, resolvedSrc)) {
|
|
4095
4102
|
throw new Error(`Cannot overwrite '${resolvedDest}' with '${resolvedSrc}'.`);
|
|
4096
4103
|
}
|
|
4097
4104
|
return copyLink(resolvedSrc, dest);
|
|
@@ -4117,261 +4124,17 @@ var require_copy2 = __commonJS({
|
|
|
4117
4124
|
}
|
|
4118
4125
|
});
|
|
4119
4126
|
|
|
4120
|
-
// node_modules/fs-extra/lib/remove/rimraf.js
|
|
4121
|
-
var require_rimraf = __commonJS({
|
|
4122
|
-
"node_modules/fs-extra/lib/remove/rimraf.js"(exports, module2) {
|
|
4123
|
-
"use strict";
|
|
4124
|
-
var fs6 = require_graceful_fs();
|
|
4125
|
-
var path12 = require("path");
|
|
4126
|
-
var assert = require("assert");
|
|
4127
|
-
var isWindows = process.platform === "win32";
|
|
4128
|
-
function defaults(options) {
|
|
4129
|
-
const methods = [
|
|
4130
|
-
"unlink",
|
|
4131
|
-
"chmod",
|
|
4132
|
-
"stat",
|
|
4133
|
-
"lstat",
|
|
4134
|
-
"rmdir",
|
|
4135
|
-
"readdir"
|
|
4136
|
-
];
|
|
4137
|
-
methods.forEach((m) => {
|
|
4138
|
-
options[m] = options[m] || fs6[m];
|
|
4139
|
-
m = m + "Sync";
|
|
4140
|
-
options[m] = options[m] || fs6[m];
|
|
4141
|
-
});
|
|
4142
|
-
options.maxBusyTries = options.maxBusyTries || 3;
|
|
4143
|
-
}
|
|
4144
|
-
function rimraf(p, options, cb) {
|
|
4145
|
-
let busyTries = 0;
|
|
4146
|
-
if (typeof options === "function") {
|
|
4147
|
-
cb = options;
|
|
4148
|
-
options = {};
|
|
4149
|
-
}
|
|
4150
|
-
assert(p, "rimraf: missing path");
|
|
4151
|
-
assert.strictEqual(typeof p, "string", "rimraf: path should be a string");
|
|
4152
|
-
assert.strictEqual(typeof cb, "function", "rimraf: callback function required");
|
|
4153
|
-
assert(options, "rimraf: invalid options argument provided");
|
|
4154
|
-
assert.strictEqual(typeof options, "object", "rimraf: options should be object");
|
|
4155
|
-
defaults(options);
|
|
4156
|
-
rimraf_(p, options, function CB(er) {
|
|
4157
|
-
if (er) {
|
|
4158
|
-
if ((er.code === "EBUSY" || er.code === "ENOTEMPTY" || er.code === "EPERM") && busyTries < options.maxBusyTries) {
|
|
4159
|
-
busyTries++;
|
|
4160
|
-
const time = busyTries * 100;
|
|
4161
|
-
return setTimeout(() => rimraf_(p, options, CB), time);
|
|
4162
|
-
}
|
|
4163
|
-
if (er.code === "ENOENT")
|
|
4164
|
-
er = null;
|
|
4165
|
-
}
|
|
4166
|
-
cb(er);
|
|
4167
|
-
});
|
|
4168
|
-
}
|
|
4169
|
-
function rimraf_(p, options, cb) {
|
|
4170
|
-
assert(p);
|
|
4171
|
-
assert(options);
|
|
4172
|
-
assert(typeof cb === "function");
|
|
4173
|
-
options.lstat(p, (er, st) => {
|
|
4174
|
-
if (er && er.code === "ENOENT") {
|
|
4175
|
-
return cb(null);
|
|
4176
|
-
}
|
|
4177
|
-
if (er && er.code === "EPERM" && isWindows) {
|
|
4178
|
-
return fixWinEPERM(p, options, er, cb);
|
|
4179
|
-
}
|
|
4180
|
-
if (st && st.isDirectory()) {
|
|
4181
|
-
return rmdir(p, options, er, cb);
|
|
4182
|
-
}
|
|
4183
|
-
options.unlink(p, (er2) => {
|
|
4184
|
-
if (er2) {
|
|
4185
|
-
if (er2.code === "ENOENT") {
|
|
4186
|
-
return cb(null);
|
|
4187
|
-
}
|
|
4188
|
-
if (er2.code === "EPERM") {
|
|
4189
|
-
return isWindows ? fixWinEPERM(p, options, er2, cb) : rmdir(p, options, er2, cb);
|
|
4190
|
-
}
|
|
4191
|
-
if (er2.code === "EISDIR") {
|
|
4192
|
-
return rmdir(p, options, er2, cb);
|
|
4193
|
-
}
|
|
4194
|
-
}
|
|
4195
|
-
return cb(er2);
|
|
4196
|
-
});
|
|
4197
|
-
});
|
|
4198
|
-
}
|
|
4199
|
-
function fixWinEPERM(p, options, er, cb) {
|
|
4200
|
-
assert(p);
|
|
4201
|
-
assert(options);
|
|
4202
|
-
assert(typeof cb === "function");
|
|
4203
|
-
options.chmod(p, 438, (er2) => {
|
|
4204
|
-
if (er2) {
|
|
4205
|
-
cb(er2.code === "ENOENT" ? null : er);
|
|
4206
|
-
} else {
|
|
4207
|
-
options.stat(p, (er3, stats) => {
|
|
4208
|
-
if (er3) {
|
|
4209
|
-
cb(er3.code === "ENOENT" ? null : er);
|
|
4210
|
-
} else if (stats.isDirectory()) {
|
|
4211
|
-
rmdir(p, options, er, cb);
|
|
4212
|
-
} else {
|
|
4213
|
-
options.unlink(p, cb);
|
|
4214
|
-
}
|
|
4215
|
-
});
|
|
4216
|
-
}
|
|
4217
|
-
});
|
|
4218
|
-
}
|
|
4219
|
-
function fixWinEPERMSync(p, options, er) {
|
|
4220
|
-
let stats;
|
|
4221
|
-
assert(p);
|
|
4222
|
-
assert(options);
|
|
4223
|
-
try {
|
|
4224
|
-
options.chmodSync(p, 438);
|
|
4225
|
-
} catch (er2) {
|
|
4226
|
-
if (er2.code === "ENOENT") {
|
|
4227
|
-
return;
|
|
4228
|
-
} else {
|
|
4229
|
-
throw er;
|
|
4230
|
-
}
|
|
4231
|
-
}
|
|
4232
|
-
try {
|
|
4233
|
-
stats = options.statSync(p);
|
|
4234
|
-
} catch (er3) {
|
|
4235
|
-
if (er3.code === "ENOENT") {
|
|
4236
|
-
return;
|
|
4237
|
-
} else {
|
|
4238
|
-
throw er;
|
|
4239
|
-
}
|
|
4240
|
-
}
|
|
4241
|
-
if (stats.isDirectory()) {
|
|
4242
|
-
rmdirSync(p, options, er);
|
|
4243
|
-
} else {
|
|
4244
|
-
options.unlinkSync(p);
|
|
4245
|
-
}
|
|
4246
|
-
}
|
|
4247
|
-
function rmdir(p, options, originalEr, cb) {
|
|
4248
|
-
assert(p);
|
|
4249
|
-
assert(options);
|
|
4250
|
-
assert(typeof cb === "function");
|
|
4251
|
-
options.rmdir(p, (er) => {
|
|
4252
|
-
if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM")) {
|
|
4253
|
-
rmkids(p, options, cb);
|
|
4254
|
-
} else if (er && er.code === "ENOTDIR") {
|
|
4255
|
-
cb(originalEr);
|
|
4256
|
-
} else {
|
|
4257
|
-
cb(er);
|
|
4258
|
-
}
|
|
4259
|
-
});
|
|
4260
|
-
}
|
|
4261
|
-
function rmkids(p, options, cb) {
|
|
4262
|
-
assert(p);
|
|
4263
|
-
assert(options);
|
|
4264
|
-
assert(typeof cb === "function");
|
|
4265
|
-
options.readdir(p, (er, files) => {
|
|
4266
|
-
if (er)
|
|
4267
|
-
return cb(er);
|
|
4268
|
-
let n = files.length;
|
|
4269
|
-
let errState;
|
|
4270
|
-
if (n === 0)
|
|
4271
|
-
return options.rmdir(p, cb);
|
|
4272
|
-
files.forEach((f) => {
|
|
4273
|
-
rimraf(path12.join(p, f), options, (er2) => {
|
|
4274
|
-
if (errState) {
|
|
4275
|
-
return;
|
|
4276
|
-
}
|
|
4277
|
-
if (er2)
|
|
4278
|
-
return cb(errState = er2);
|
|
4279
|
-
if (--n === 0) {
|
|
4280
|
-
options.rmdir(p, cb);
|
|
4281
|
-
}
|
|
4282
|
-
});
|
|
4283
|
-
});
|
|
4284
|
-
});
|
|
4285
|
-
}
|
|
4286
|
-
function rimrafSync(p, options) {
|
|
4287
|
-
let st;
|
|
4288
|
-
options = options || {};
|
|
4289
|
-
defaults(options);
|
|
4290
|
-
assert(p, "rimraf: missing path");
|
|
4291
|
-
assert.strictEqual(typeof p, "string", "rimraf: path should be a string");
|
|
4292
|
-
assert(options, "rimraf: missing options");
|
|
4293
|
-
assert.strictEqual(typeof options, "object", "rimraf: options should be object");
|
|
4294
|
-
try {
|
|
4295
|
-
st = options.lstatSync(p);
|
|
4296
|
-
} catch (er) {
|
|
4297
|
-
if (er.code === "ENOENT") {
|
|
4298
|
-
return;
|
|
4299
|
-
}
|
|
4300
|
-
if (er.code === "EPERM" && isWindows) {
|
|
4301
|
-
fixWinEPERMSync(p, options, er);
|
|
4302
|
-
}
|
|
4303
|
-
}
|
|
4304
|
-
try {
|
|
4305
|
-
if (st && st.isDirectory()) {
|
|
4306
|
-
rmdirSync(p, options, null);
|
|
4307
|
-
} else {
|
|
4308
|
-
options.unlinkSync(p);
|
|
4309
|
-
}
|
|
4310
|
-
} catch (er) {
|
|
4311
|
-
if (er.code === "ENOENT") {
|
|
4312
|
-
return;
|
|
4313
|
-
} else if (er.code === "EPERM") {
|
|
4314
|
-
return isWindows ? fixWinEPERMSync(p, options, er) : rmdirSync(p, options, er);
|
|
4315
|
-
} else if (er.code !== "EISDIR") {
|
|
4316
|
-
throw er;
|
|
4317
|
-
}
|
|
4318
|
-
rmdirSync(p, options, er);
|
|
4319
|
-
}
|
|
4320
|
-
}
|
|
4321
|
-
function rmdirSync(p, options, originalEr) {
|
|
4322
|
-
assert(p);
|
|
4323
|
-
assert(options);
|
|
4324
|
-
try {
|
|
4325
|
-
options.rmdirSync(p);
|
|
4326
|
-
} catch (er) {
|
|
4327
|
-
if (er.code === "ENOTDIR") {
|
|
4328
|
-
throw originalEr;
|
|
4329
|
-
} else if (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM") {
|
|
4330
|
-
rmkidsSync(p, options);
|
|
4331
|
-
} else if (er.code !== "ENOENT") {
|
|
4332
|
-
throw er;
|
|
4333
|
-
}
|
|
4334
|
-
}
|
|
4335
|
-
}
|
|
4336
|
-
function rmkidsSync(p, options) {
|
|
4337
|
-
assert(p);
|
|
4338
|
-
assert(options);
|
|
4339
|
-
options.readdirSync(p).forEach((f) => rimrafSync(path12.join(p, f), options));
|
|
4340
|
-
if (isWindows) {
|
|
4341
|
-
const startTime = Date.now();
|
|
4342
|
-
do {
|
|
4343
|
-
try {
|
|
4344
|
-
const ret = options.rmdirSync(p, options);
|
|
4345
|
-
return ret;
|
|
4346
|
-
} catch {
|
|
4347
|
-
}
|
|
4348
|
-
} while (Date.now() - startTime < 500);
|
|
4349
|
-
} else {
|
|
4350
|
-
const ret = options.rmdirSync(p, options);
|
|
4351
|
-
return ret;
|
|
4352
|
-
}
|
|
4353
|
-
}
|
|
4354
|
-
module2.exports = rimraf;
|
|
4355
|
-
rimraf.sync = rimrafSync;
|
|
4356
|
-
}
|
|
4357
|
-
});
|
|
4358
|
-
|
|
4359
4127
|
// node_modules/fs-extra/lib/remove/index.js
|
|
4360
4128
|
var require_remove = __commonJS({
|
|
4361
4129
|
"node_modules/fs-extra/lib/remove/index.js"(exports, module2) {
|
|
4362
4130
|
"use strict";
|
|
4363
4131
|
var fs6 = require_graceful_fs();
|
|
4364
4132
|
var u = require_universalify().fromCallback;
|
|
4365
|
-
var rimraf = require_rimraf();
|
|
4366
4133
|
function remove(path12, callback) {
|
|
4367
|
-
|
|
4368
|
-
return fs6.rm(path12, { recursive: true, force: true }, callback);
|
|
4369
|
-
rimraf(path12, callback);
|
|
4134
|
+
fs6.rm(path12, { recursive: true, force: true }, callback);
|
|
4370
4135
|
}
|
|
4371
4136
|
function removeSync(path12) {
|
|
4372
|
-
|
|
4373
|
-
return fs6.rmSync(path12, { recursive: true, force: true });
|
|
4374
|
-
rimraf.sync(path12);
|
|
4137
|
+
fs6.rmSync(path12, { recursive: true, force: true });
|
|
4375
4138
|
}
|
|
4376
4139
|
module2.exports = {
|
|
4377
4140
|
remove: u(remove),
|
|
@@ -5082,7 +4845,8 @@ var require_move = __commonJS({
|
|
|
5082
4845
|
function moveAcrossDevice(src, dest, overwrite, cb) {
|
|
5083
4846
|
const opts = {
|
|
5084
4847
|
overwrite,
|
|
5085
|
-
errorOnExist: true
|
|
4848
|
+
errorOnExist: true,
|
|
4849
|
+
preserveTimestamps: true
|
|
5086
4850
|
};
|
|
5087
4851
|
copy(src, dest, opts, (err) => {
|
|
5088
4852
|
if (err)
|
|
@@ -5141,7 +4905,8 @@ var require_move_sync = __commonJS({
|
|
|
5141
4905
|
function moveAcrossDevice(src, dest, overwrite) {
|
|
5142
4906
|
const opts = {
|
|
5143
4907
|
overwrite,
|
|
5144
|
-
errorOnExist: true
|
|
4908
|
+
errorOnExist: true,
|
|
4909
|
+
preserveTimestamps: true
|
|
5145
4910
|
};
|
|
5146
4911
|
copySync(src, dest, opts);
|
|
5147
4912
|
return removeSync(src);
|
|
@@ -6128,7 +5893,7 @@ var require_positionUtils = __commonJS({
|
|
|
6128
5893
|
"node_modules/@zzzen/pyright-internal/dist/common/positionUtils.js"(exports) {
|
|
6129
5894
|
"use strict";
|
|
6130
5895
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6131
|
-
exports.getLineEndPosition = exports.convertTextRangeToRange = exports.convertRangeToTextRange = exports.convertPositionToOffset = exports.convertOffsetsToRange = exports.convertOffsetToPosition = void 0;
|
|
5896
|
+
exports.getLineEndOffset = exports.getLineEndPosition = exports.convertTextRangeToRange = exports.convertRangeToTextRange = exports.convertPositionToOffset = exports.convertOffsetsToRange = exports.convertOffsetToPosition = void 0;
|
|
6132
5897
|
var debug_1 = require_debug2();
|
|
6133
5898
|
var textRange_1 = require_textRange();
|
|
6134
5899
|
function convertOffsetToPosition(offset, lines) {
|
|
@@ -6177,16 +5942,24 @@ var require_positionUtils = __commonJS({
|
|
|
6177
5942
|
return convertOffsetsToRange(range.start, textRange_1.TextRange.getEnd(range), lines);
|
|
6178
5943
|
}
|
|
6179
5944
|
exports.convertTextRangeToRange = convertTextRangeToRange;
|
|
6180
|
-
function getLineEndPosition(tokenizerOutput, line) {
|
|
6181
|
-
|
|
6182
|
-
const lineRange = lines.getItemAt(line);
|
|
6183
|
-
const char = line < lines.count - 1 ? lineRange.length - tokenizerOutput.predominantEndOfLineSequence.length : lineRange.length;
|
|
6184
|
-
return {
|
|
6185
|
-
line,
|
|
6186
|
-
character: char
|
|
6187
|
-
};
|
|
5945
|
+
function getLineEndPosition(tokenizerOutput, text, line) {
|
|
5946
|
+
return convertOffsetToPosition(getLineEndOffset(tokenizerOutput, text, line), tokenizerOutput.lines);
|
|
6188
5947
|
}
|
|
6189
5948
|
exports.getLineEndPosition = getLineEndPosition;
|
|
5949
|
+
function getLineEndOffset(tokenizerOutput, text, line) {
|
|
5950
|
+
const lineRange = tokenizerOutput.lines.getItemAt(line);
|
|
5951
|
+
const lineEndOffset = textRange_1.TextRange.getEnd(lineRange);
|
|
5952
|
+
let newLineLength = 0;
|
|
5953
|
+
for (let i = lineEndOffset - 1; i >= lineRange.start; i--) {
|
|
5954
|
+
const char = text[i];
|
|
5955
|
+
if (char !== "\r" && char !== "\n") {
|
|
5956
|
+
break;
|
|
5957
|
+
}
|
|
5958
|
+
newLineLength++;
|
|
5959
|
+
}
|
|
5960
|
+
return lineEndOffset - newLineLength;
|
|
5961
|
+
}
|
|
5962
|
+
exports.getLineEndOffset = getLineEndOffset;
|
|
6190
5963
|
}
|
|
6191
5964
|
});
|
|
6192
5965
|
|
|
@@ -20549,7 +20322,7 @@ var require_pathConsts = __commonJS({
|
|
|
20549
20322
|
"node_modules/@zzzen/pyright-internal/dist/common/pathConsts.js"(exports) {
|
|
20550
20323
|
"use strict";
|
|
20551
20324
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20552
|
-
exports.stubsSuffix = exports.src = exports.distPackages = exports.sitePackages = exports.lib64 = exports.libAlternate = exports.lib = exports.typeshedFallback = void 0;
|
|
20325
|
+
exports.defaultStubsDirectory = exports.stubsSuffix = exports.src = exports.distPackages = exports.sitePackages = exports.lib64 = exports.libAlternate = exports.lib = exports.typeshedFallback = void 0;
|
|
20553
20326
|
exports.typeshedFallback = "typeshed-fallback";
|
|
20554
20327
|
exports.lib = "lib";
|
|
20555
20328
|
exports.libAlternate = "Lib";
|
|
@@ -20558,6 +20331,7 @@ var require_pathConsts = __commonJS({
|
|
|
20558
20331
|
exports.distPackages = "dist-packages";
|
|
20559
20332
|
exports.src = "src";
|
|
20560
20333
|
exports.stubsSuffix = "-stubs";
|
|
20334
|
+
exports.defaultStubsDirectory = "typings";
|
|
20561
20335
|
}
|
|
20562
20336
|
});
|
|
20563
20337
|
|
|
@@ -22410,7 +22184,7 @@ var require_configOptions = __commonJS({
|
|
|
22410
22184
|
reportMissingImports: "error",
|
|
22411
22185
|
reportMissingModuleSource: "warning",
|
|
22412
22186
|
reportMissingTypeStubs: "error",
|
|
22413
|
-
reportImportCycles: "
|
|
22187
|
+
reportImportCycles: "none",
|
|
22414
22188
|
reportUnusedImport: "error",
|
|
22415
22189
|
reportUnusedClass: "error",
|
|
22416
22190
|
reportUnusedFunction: "error",
|
|
@@ -23505,7 +23279,7 @@ var require_declarationUtils = __commonJS({
|
|
|
23505
23279
|
"node_modules/@zzzen/pyright-internal/dist/analyzer/declarationUtils.js"(exports) {
|
|
23506
23280
|
"use strict";
|
|
23507
23281
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23508
|
-
exports.createSynthesizedAliasDeclaration = exports.getDeclarationsWithUsesLocalNameRemoved = exports.isDefinedInFile = exports.getNameNodeForDeclaration = exports.getNameFromDeclaration = exports.areDeclarationsSame = exports.hasTypeForDeclaration = void 0;
|
|
23282
|
+
exports.resolveAliasDeclaration = exports.createSynthesizedAliasDeclaration = exports.getDeclarationsWithUsesLocalNameRemoved = exports.isDefinedInFile = exports.getNameNodeForDeclaration = exports.getNameFromDeclaration = exports.areDeclarationsSame = exports.hasTypeForDeclaration = void 0;
|
|
23509
23283
|
var textRange_1 = require_textRange();
|
|
23510
23284
|
var declaration_1 = require_declaration();
|
|
23511
23285
|
var parseTreeUtils_1 = require_parseTreeUtils();
|
|
@@ -23645,6 +23419,106 @@ var require_declarationUtils = __commonJS({
|
|
|
23645
23419
|
};
|
|
23646
23420
|
}
|
|
23647
23421
|
exports.createSynthesizedAliasDeclaration = createSynthesizedAliasDeclaration;
|
|
23422
|
+
function resolveAliasDeclaration(importLookup, declaration, resolveLocalNames, allowExternallyHiddenAccess) {
|
|
23423
|
+
let curDeclaration = declaration;
|
|
23424
|
+
const alreadyVisited = [];
|
|
23425
|
+
let isPrivate = false;
|
|
23426
|
+
let sawPyTypedTransition = false;
|
|
23427
|
+
let privatePyTypedImported;
|
|
23428
|
+
let privatePyTypedImporter;
|
|
23429
|
+
while (true) {
|
|
23430
|
+
if (curDeclaration.type !== 8 || !curDeclaration.symbolName) {
|
|
23431
|
+
return {
|
|
23432
|
+
declaration: curDeclaration,
|
|
23433
|
+
isPrivate,
|
|
23434
|
+
privatePyTypedImported,
|
|
23435
|
+
privatePyTypedImporter
|
|
23436
|
+
};
|
|
23437
|
+
}
|
|
23438
|
+
if (!resolveLocalNames && curDeclaration.usesLocalName) {
|
|
23439
|
+
return {
|
|
23440
|
+
declaration: curDeclaration,
|
|
23441
|
+
isPrivate,
|
|
23442
|
+
privatePyTypedImported,
|
|
23443
|
+
privatePyTypedImporter
|
|
23444
|
+
};
|
|
23445
|
+
}
|
|
23446
|
+
let lookupResult;
|
|
23447
|
+
if (curDeclaration.path && curDeclaration.loadSymbolsFromPath) {
|
|
23448
|
+
lookupResult = importLookup(curDeclaration.path);
|
|
23449
|
+
}
|
|
23450
|
+
const symbol = lookupResult ? lookupResult.symbolTable.get(curDeclaration.symbolName) : void 0;
|
|
23451
|
+
if (!symbol) {
|
|
23452
|
+
if (curDeclaration.submoduleFallback) {
|
|
23453
|
+
if (curDeclaration.symbolName) {
|
|
23454
|
+
if (curDeclaration.submoduleFallback.type === 8 && curDeclaration.submoduleFallback.path) {
|
|
23455
|
+
const lookupResult2 = importLookup(curDeclaration.submoduleFallback.path);
|
|
23456
|
+
if (!lookupResult2) {
|
|
23457
|
+
return void 0;
|
|
23458
|
+
}
|
|
23459
|
+
}
|
|
23460
|
+
}
|
|
23461
|
+
return resolveAliasDeclaration(importLookup, curDeclaration.submoduleFallback, resolveLocalNames, allowExternallyHiddenAccess);
|
|
23462
|
+
}
|
|
23463
|
+
if (curDeclaration.isNativeLib) {
|
|
23464
|
+
return {
|
|
23465
|
+
declaration: void 0,
|
|
23466
|
+
isPrivate
|
|
23467
|
+
};
|
|
23468
|
+
}
|
|
23469
|
+
return void 0;
|
|
23470
|
+
}
|
|
23471
|
+
if (symbol.isPrivateMember()) {
|
|
23472
|
+
isPrivate = true;
|
|
23473
|
+
}
|
|
23474
|
+
if (symbol.isExternallyHidden() && !allowExternallyHiddenAccess) {
|
|
23475
|
+
return void 0;
|
|
23476
|
+
}
|
|
23477
|
+
let declarations = symbol.getTypedDeclarations();
|
|
23478
|
+
declarations = declarations.filter((decl) => !decl.isInExceptSuite);
|
|
23479
|
+
if (declarations.length === 0) {
|
|
23480
|
+
declarations = symbol.getDeclarations();
|
|
23481
|
+
declarations = declarations.filter((decl) => !decl.isInExceptSuite);
|
|
23482
|
+
}
|
|
23483
|
+
if (declarations.length === 0) {
|
|
23484
|
+
declarations = symbol.getDeclarations();
|
|
23485
|
+
}
|
|
23486
|
+
if (declarations.length === 0) {
|
|
23487
|
+
return void 0;
|
|
23488
|
+
}
|
|
23489
|
+
const unvisitedDecls = declarations.filter((decl) => !alreadyVisited.includes(decl));
|
|
23490
|
+
if (unvisitedDecls.length > 0) {
|
|
23491
|
+
curDeclaration = unvisitedDecls[unvisitedDecls.length - 1];
|
|
23492
|
+
} else {
|
|
23493
|
+
curDeclaration = declarations[declarations.length - 1];
|
|
23494
|
+
}
|
|
23495
|
+
if (lookupResult === null || lookupResult === void 0 ? void 0 : lookupResult.isInPyTypedPackage) {
|
|
23496
|
+
if (!sawPyTypedTransition) {
|
|
23497
|
+
if (symbol.isPrivatePyTypedImport()) {
|
|
23498
|
+
privatePyTypedImporter = curDeclaration === null || curDeclaration === void 0 ? void 0 : curDeclaration.moduleName;
|
|
23499
|
+
}
|
|
23500
|
+
sawPyTypedTransition = true;
|
|
23501
|
+
} else {
|
|
23502
|
+
if (!symbol.isPrivatePyTypedImport()) {
|
|
23503
|
+
privatePyTypedImported = privatePyTypedImported !== null && privatePyTypedImported !== void 0 ? privatePyTypedImported : curDeclaration === null || curDeclaration === void 0 ? void 0 : curDeclaration.moduleName;
|
|
23504
|
+
}
|
|
23505
|
+
}
|
|
23506
|
+
}
|
|
23507
|
+
if (alreadyVisited.find((decl) => decl === curDeclaration)) {
|
|
23508
|
+
if (curDeclaration.path === declaration.path && curDeclaration.type === 8 && curDeclaration.submoduleFallback) {
|
|
23509
|
+
return resolveAliasDeclaration(importLookup, curDeclaration.submoduleFallback, resolveLocalNames, allowExternallyHiddenAccess);
|
|
23510
|
+
}
|
|
23511
|
+
return {
|
|
23512
|
+
declaration,
|
|
23513
|
+
isPrivate,
|
|
23514
|
+
privatePyTypedImported,
|
|
23515
|
+
privatePyTypedImporter
|
|
23516
|
+
};
|
|
23517
|
+
}
|
|
23518
|
+
alreadyVisited.push(curDeclaration);
|
|
23519
|
+
}
|
|
23520
|
+
}
|
|
23521
|
+
exports.resolveAliasDeclaration = resolveAliasDeclaration;
|
|
23648
23522
|
}
|
|
23649
23523
|
});
|
|
23650
23524
|
|
|
@@ -25615,6 +25489,16 @@ var require_types = __commonJS({
|
|
|
25615
25489
|
return newInstance;
|
|
25616
25490
|
}
|
|
25617
25491
|
TypeVarType2.cloneAsInstantiable = cloneAsInstantiable;
|
|
25492
|
+
function cloneForNewName(type, name) {
|
|
25493
|
+
const newInstance = TypeBase.cloneType(type);
|
|
25494
|
+
newInstance.details = { ...type.details };
|
|
25495
|
+
newInstance.details.name = name;
|
|
25496
|
+
if (newInstance.scopeId) {
|
|
25497
|
+
newInstance.nameWithScope = makeNameWithScope(name, newInstance.scopeId);
|
|
25498
|
+
}
|
|
25499
|
+
return newInstance;
|
|
25500
|
+
}
|
|
25501
|
+
TypeVarType2.cloneForNewName = cloneForNewName;
|
|
25618
25502
|
function cloneForScopeId(type, scopeId, scopeName, scopeType) {
|
|
25619
25503
|
const newInstance = TypeBase.cloneType(type);
|
|
25620
25504
|
newInstance.nameWithScope = makeNameWithScope(type.details.name, scopeId);
|
|
@@ -26287,148 +26171,6 @@ var require_types = __commonJS({
|
|
|
26287
26171
|
}
|
|
26288
26172
|
});
|
|
26289
26173
|
|
|
26290
|
-
// node_modules/@zzzen/pyright-internal/dist/analyzer/parameterUtils.js
|
|
26291
|
-
var require_parameterUtils = __commonJS({
|
|
26292
|
-
"node_modules/@zzzen/pyright-internal/dist/analyzer/parameterUtils.js"(exports) {
|
|
26293
|
-
"use strict";
|
|
26294
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26295
|
-
exports.isTypedKwargs = void 0;
|
|
26296
|
-
var types_1 = require_types();
|
|
26297
|
-
function isTypedKwargs(param) {
|
|
26298
|
-
return param.category === 2 && (0, types_1.isClassInstance)(param.type) && (0, types_1.isUnpackedClass)(param.type) && types_1.ClassType.isTypedDictClass(param.type) && !!param.type.details.typedDictEntries;
|
|
26299
|
-
}
|
|
26300
|
-
exports.isTypedKwargs = isTypedKwargs;
|
|
26301
|
-
}
|
|
26302
|
-
});
|
|
26303
|
-
|
|
26304
|
-
// node_modules/@zzzen/pyright-internal/dist/analyzer/scopeUtils.js
|
|
26305
|
-
var require_scopeUtils = __commonJS({
|
|
26306
|
-
"node_modules/@zzzen/pyright-internal/dist/analyzer/scopeUtils.js"(exports) {
|
|
26307
|
-
"use strict";
|
|
26308
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26309
|
-
exports.findTopNodeInScope = exports.getScopeHierarchy = exports.getScopeForNode = exports.getBuiltInScope = void 0;
|
|
26310
|
-
var analyzerNodeInfo_1 = require_analyzerNodeInfo();
|
|
26311
|
-
var parseTreeUtils_1 = require_parseTreeUtils();
|
|
26312
|
-
function getBuiltInScope(currentScope) {
|
|
26313
|
-
let builtInScope = currentScope;
|
|
26314
|
-
while (builtInScope.type !== 4) {
|
|
26315
|
-
builtInScope = builtInScope.parent;
|
|
26316
|
-
}
|
|
26317
|
-
return builtInScope;
|
|
26318
|
-
}
|
|
26319
|
-
exports.getBuiltInScope = getBuiltInScope;
|
|
26320
|
-
function getScopeForNode(node) {
|
|
26321
|
-
const scopeNode = (0, parseTreeUtils_1.getEvaluationScopeNode)(node);
|
|
26322
|
-
return (0, analyzerNodeInfo_1.getScope)(scopeNode);
|
|
26323
|
-
}
|
|
26324
|
-
exports.getScopeForNode = getScopeForNode;
|
|
26325
|
-
function getScopeHierarchy(node, stopScope) {
|
|
26326
|
-
const scopeHierarchy = [];
|
|
26327
|
-
let curNode = node;
|
|
26328
|
-
while (curNode) {
|
|
26329
|
-
const curScope = getScopeForNode(curNode);
|
|
26330
|
-
if (!curScope) {
|
|
26331
|
-
return void 0;
|
|
26332
|
-
}
|
|
26333
|
-
if (scopeHierarchy.length === 0 || scopeHierarchy[scopeHierarchy.length - 1] !== curScope) {
|
|
26334
|
-
scopeHierarchy.push(curScope);
|
|
26335
|
-
}
|
|
26336
|
-
if (curScope === stopScope) {
|
|
26337
|
-
return scopeHierarchy;
|
|
26338
|
-
}
|
|
26339
|
-
curNode = curNode.parent;
|
|
26340
|
-
}
|
|
26341
|
-
return stopScope ? void 0 : scopeHierarchy;
|
|
26342
|
-
}
|
|
26343
|
-
exports.getScopeHierarchy = getScopeHierarchy;
|
|
26344
|
-
function findTopNodeInScope(node, scope) {
|
|
26345
|
-
let curNode = node;
|
|
26346
|
-
let prevNode;
|
|
26347
|
-
let foundScope = false;
|
|
26348
|
-
while (curNode) {
|
|
26349
|
-
if ((0, analyzerNodeInfo_1.getScope)(curNode) === scope) {
|
|
26350
|
-
foundScope = true;
|
|
26351
|
-
} else if (foundScope) {
|
|
26352
|
-
return prevNode;
|
|
26353
|
-
}
|
|
26354
|
-
prevNode = curNode;
|
|
26355
|
-
curNode = curNode.parent;
|
|
26356
|
-
}
|
|
26357
|
-
return void 0;
|
|
26358
|
-
}
|
|
26359
|
-
exports.findTopNodeInScope = findTopNodeInScope;
|
|
26360
|
-
}
|
|
26361
|
-
});
|
|
26362
|
-
|
|
26363
|
-
// node_modules/@zzzen/pyright-internal/dist/analyzer/sourceFileInfoUtils.js
|
|
26364
|
-
var require_sourceFileInfoUtils = __commonJS({
|
|
26365
|
-
"node_modules/@zzzen/pyright-internal/dist/analyzer/sourceFileInfoUtils.js"(exports) {
|
|
26366
|
-
"use strict";
|
|
26367
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26368
|
-
exports.collectImportedByFiles = exports.isUserCode = void 0;
|
|
26369
|
-
function isUserCode(fileInfo) {
|
|
26370
|
-
return !!fileInfo && fileInfo.isTracked && !fileInfo.isThirdPartyImport && !fileInfo.isTypeshedFile;
|
|
26371
|
-
}
|
|
26372
|
-
exports.isUserCode = isUserCode;
|
|
26373
|
-
function collectImportedByFiles(fileInfo) {
|
|
26374
|
-
const importedByFiles = /* @__PURE__ */ new Set();
|
|
26375
|
-
_collectImportedByFiles(fileInfo, importedByFiles);
|
|
26376
|
-
return importedByFiles;
|
|
26377
|
-
}
|
|
26378
|
-
exports.collectImportedByFiles = collectImportedByFiles;
|
|
26379
|
-
function _collectImportedByFiles(fileInfo, importedByFiles) {
|
|
26380
|
-
fileInfo.importedBy.forEach((dep) => {
|
|
26381
|
-
if (importedByFiles.has(dep)) {
|
|
26382
|
-
return;
|
|
26383
|
-
}
|
|
26384
|
-
importedByFiles.add(dep);
|
|
26385
|
-
_collectImportedByFiles(dep, importedByFiles);
|
|
26386
|
-
});
|
|
26387
|
-
}
|
|
26388
|
-
}
|
|
26389
|
-
});
|
|
26390
|
-
|
|
26391
|
-
// node_modules/@zzzen/pyright-internal/dist/analyzer/sourceMapperUtils.js
|
|
26392
|
-
var require_sourceMapperUtils = __commonJS({
|
|
26393
|
-
"node_modules/@zzzen/pyright-internal/dist/analyzer/sourceMapperUtils.js"(exports) {
|
|
26394
|
-
"use strict";
|
|
26395
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26396
|
-
exports.buildImportTree = void 0;
|
|
26397
|
-
var MAX_TREE_SEARCH_COUNT = 1e3;
|
|
26398
|
-
var NumberReference = class {
|
|
26399
|
-
constructor() {
|
|
26400
|
-
this.value = 0;
|
|
26401
|
-
}
|
|
26402
|
-
};
|
|
26403
|
-
function _buildImportTreeImpl(to, from, next, previous, totalSearched, token) {
|
|
26404
|
-
if (totalSearched.value > MAX_TREE_SEARCH_COUNT || token.isCancellationRequested) {
|
|
26405
|
-
return [];
|
|
26406
|
-
}
|
|
26407
|
-
totalSearched.value += 1;
|
|
26408
|
-
if (from === to) {
|
|
26409
|
-
return previous.length ? previous : [from];
|
|
26410
|
-
} else if (previous.length > 1 && previous.find((s) => s === from)) {
|
|
26411
|
-
return [];
|
|
26412
|
-
} else {
|
|
26413
|
-
const nextEntries = next(from);
|
|
26414
|
-
for (let i = 0; i < nextEntries.length && !token.isCancellationRequested; i++) {
|
|
26415
|
-
const subentries = _buildImportTreeImpl(to, nextEntries[i], next, [...previous, from], totalSearched, token);
|
|
26416
|
-
if (subentries.length > 0) {
|
|
26417
|
-
return subentries;
|
|
26418
|
-
}
|
|
26419
|
-
}
|
|
26420
|
-
}
|
|
26421
|
-
return [];
|
|
26422
|
-
}
|
|
26423
|
-
function buildImportTree(to, from, next, token) {
|
|
26424
|
-
const totalCountRef = new NumberReference();
|
|
26425
|
-
const results = _buildImportTreeImpl(to, from, next, [], totalCountRef, token);
|
|
26426
|
-
return results.length > 0 ? results : [from];
|
|
26427
|
-
}
|
|
26428
|
-
exports.buildImportTree = buildImportTree;
|
|
26429
|
-
}
|
|
26430
|
-
});
|
|
26431
|
-
|
|
26432
26174
|
// node_modules/@zzzen/pyright-internal/dist/analyzer/symbol.js
|
|
26433
26175
|
var require_symbol = __commonJS({
|
|
26434
26176
|
"node_modules/@zzzen/pyright-internal/dist/analyzer/symbol.js"(exports) {
|
|
@@ -26750,11 +26492,13 @@ var require_typeVarContext = __commonJS({
|
|
|
26750
26492
|
case 1:
|
|
26751
26493
|
case 2:
|
|
26752
26494
|
case 3:
|
|
26753
|
-
case 5:
|
|
26754
|
-
case 6:
|
|
26755
26495
|
case 10: {
|
|
26756
26496
|
return 0.5;
|
|
26757
26497
|
}
|
|
26498
|
+
case 5:
|
|
26499
|
+
case 6: {
|
|
26500
|
+
return 0.8;
|
|
26501
|
+
}
|
|
26758
26502
|
case 0:
|
|
26759
26503
|
case 4:
|
|
26760
26504
|
return 1;
|
|
@@ -26932,12 +26676,11 @@ var require_typeUtils = __commonJS({
|
|
|
26932
26676
|
"node_modules/@zzzen/pyright-internal/dist/analyzer/typeUtils.js"(exports) {
|
|
26933
26677
|
"use strict";
|
|
26934
26678
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26935
|
-
exports.
|
|
26936
|
-
exports.convertParamSpecValueToType = exports.convertTypeToParamSpecValue = exports.getDeclaringModulesForType = exports.computeMroLinearization = exports.isVarianceOfTypeArgumentCompatible = exports.combineVariances = exports.requiresSpecialization = exports.requiresTypeArguments = exports.getGeneratorTypeArgs = exports.removeParamSpecVariadicsFromFunction = exports.removeParamSpecVariadicsFromSignature = exports.specializeTupleClass = exports.combineSameSizedTuples = exports.explodeGenericClass = exports.isPartlyUnknown = exports.containsUnknown = exports.getMembersForModule = exports.getMembersForClass = exports.convertToInstantiable = exports.convertToInstance = exports.isEffectivelyInstantiable = exports.isMetaclassInstance = exports.getGeneratorYieldType = exports.getDeclaredGeneratorReturnType = exports.synthesizeTypeVarForSelfCls = exports.derivesFromClassRecursive = exports.specializeForBaseClass = exports.buildTypeVarContext = exports.buildTypeVarContextFromSpecializedClass = exports.setTypeArgumentsRecursive = exports.specializeClassType = void 0;
|
|
26679
|
+
exports.getTypeVarArgumentsRecursive = exports.addTypeVarsToListIfUnique = exports.getClassFieldsRecursive = exports.getClassIterator = exports.getClassMemberIterator = exports.lookUpClassMember = exports.lookUpObjectMember = exports.getContainerDepth = exports.getProtocolSymbols = exports.transformExpectedTypeForConstructor = exports.validateTypeVarDefault = exports.applySolvedTypeVars = exports.ensureFunctionSignaturesAreUnique = exports.populateTypeVarContextForSelfType = exports.partiallySpecializeType = exports.isUnboundedTupleClass = exports.isTupleClass = exports.isMaybeDescriptorInstance = exports.isDescriptorInstance = exports.isProperty = exports.isEllipsisType = exports.getUnionSubtypeCount = exports.getLiteralTypeClassName = exports.containsLiteralType = exports.containsType = exports.isLiteralTypeOrUnion = exports.isLiteralType = exports.getSpecializedTupleType = exports.getTypeVarScopeId = exports.transformPossibleRecursiveTypeAlias = exports.isTypeAliasRecursive = exports.isTypeAliasPlaceholder = exports.getTypeCondition = exports.addConditionToType = exports.getFullNameOfType = exports.derivesFromAnyOrUnknown = exports.isUnionableType = exports.preserveUnknown = exports.areTypesSame = exports.doForEachSubtype = exports.sortTypes = exports.mapSubtypes = exports.makeInferenceContext = exports.isTypeVarSame = exports.isIncompleteUnknown = exports.isOptionalType = exports.UniqueSignatureTracker = exports.AssignTypeFlags = exports.ClassIteratorFlags = exports.ClassMemberLookupFlags = void 0;
|
|
26680
|
+
exports.convertParamSpecValueToType = exports.convertTypeToParamSpecValue = exports.getDeclaringModulesForType = exports.computeMroLinearization = exports.isVarianceOfTypeArgumentCompatible = exports.combineVariances = exports.requiresSpecialization = exports.requiresTypeArguments = exports.getGeneratorTypeArgs = exports.removeParamSpecVariadicsFromFunction = exports.removeParamSpecVariadicsFromSignature = exports.specializeTupleClass = exports.combineSameSizedTuples = exports.explodeGenericClass = exports.isPartlyUnknown = exports.containsUnknown = exports.getMembersForModule = exports.getMembersForClass = exports.convertToInstantiable = exports.convertToInstance = exports.isEffectivelyInstantiable = exports.isMetaclassInstance = exports.getGeneratorYieldType = exports.getDeclaredGeneratorReturnType = exports.synthesizeTypeVarForSelfCls = exports.derivesFromClassRecursive = exports.specializeForBaseClass = exports.buildTypeVarContext = exports.buildTypeVarContextFromSpecializedClass = exports.setTypeArgumentsRecursive = exports.specializeClassType = exports.isTypeVarLimitedToCallable = void 0;
|
|
26937
26681
|
var collectionUtils_1 = require_collectionUtils();
|
|
26938
26682
|
var debug_1 = require_debug2();
|
|
26939
26683
|
var symbol_1 = require_symbol();
|
|
26940
|
-
var symbolNameUtils_1 = require_symbolNameUtils();
|
|
26941
26684
|
var symbolUtils_1 = require_symbolUtils();
|
|
26942
26685
|
var types_1 = require_types();
|
|
26943
26686
|
var typeVarContext_1 = require_typeVarContext();
|
|
@@ -26974,169 +26717,25 @@ var require_typeUtils = __commonJS({
|
|
|
26974
26717
|
AssignTypeFlags2[AssignTypeFlags2["IgnoreTypeVarScope"] = 512] = "IgnoreTypeVarScope";
|
|
26975
26718
|
AssignTypeFlags2[AssignTypeFlags2["PopulatingExpectedType"] = 1024] = "PopulatingExpectedType";
|
|
26976
26719
|
})(AssignTypeFlags = exports.AssignTypeFlags || (exports.AssignTypeFlags = {}));
|
|
26977
|
-
var
|
|
26978
|
-
|
|
26979
|
-
|
|
26980
|
-
ParameterSource2[ParameterSource2["PositionOrKeyword"] = 1] = "PositionOrKeyword";
|
|
26981
|
-
ParameterSource2[ParameterSource2["KeywordOnly"] = 2] = "KeywordOnly";
|
|
26982
|
-
})(ParameterSource = exports.ParameterSource || (exports.ParameterSource = {}));
|
|
26983
|
-
function getParameterListDetails(type) {
|
|
26984
|
-
const result = {
|
|
26985
|
-
firstPositionOrKeywordIndex: 0,
|
|
26986
|
-
positionParamCount: 0,
|
|
26987
|
-
positionOnlyParamCount: 0,
|
|
26988
|
-
params: [],
|
|
26989
|
-
hasUnpackedVariadicTypeVar: false,
|
|
26990
|
-
hasUnpackedTypedDict: false
|
|
26991
|
-
};
|
|
26992
|
-
let positionOnlyIndex = type.details.parameters.findIndex((p) => p.category === 0 && !p.name);
|
|
26993
|
-
if (positionOnlyIndex < 0) {
|
|
26994
|
-
for (let i = 0; i < type.details.parameters.length; i++) {
|
|
26995
|
-
const p = type.details.parameters[i];
|
|
26996
|
-
if (p.category !== 0) {
|
|
26997
|
-
break;
|
|
26998
|
-
}
|
|
26999
|
-
if (!p.name) {
|
|
27000
|
-
break;
|
|
27001
|
-
}
|
|
27002
|
-
if ((0, symbolNameUtils_1.isDunderName)(p.name) || !p.name.startsWith("__")) {
|
|
27003
|
-
break;
|
|
27004
|
-
}
|
|
27005
|
-
positionOnlyIndex = i + 1;
|
|
27006
|
-
}
|
|
26720
|
+
var UniqueSignatureTracker = class {
|
|
26721
|
+
constructor() {
|
|
26722
|
+
this.signaturesSeen = [];
|
|
27007
26723
|
}
|
|
27008
|
-
|
|
27009
|
-
|
|
26724
|
+
findSignature(signature) {
|
|
26725
|
+
return this.signaturesSeen.find((s) => {
|
|
26726
|
+
return (0, types_1.isTypeSame)(signature, s.type);
|
|
26727
|
+
});
|
|
27010
26728
|
}
|
|
27011
|
-
|
|
27012
|
-
|
|
27013
|
-
|
|
26729
|
+
addSignature(signature) {
|
|
26730
|
+
const existingSignature = this.findSignature(signature);
|
|
26731
|
+
if (existingSignature) {
|
|
26732
|
+
existingSignature.count++;
|
|
26733
|
+
} else {
|
|
26734
|
+
this.signaturesSeen.push({ type: signature, count: 1 });
|
|
27014
26735
|
}
|
|
27015
|
-
result.positionOnlyParamCount++;
|
|
27016
26736
|
}
|
|
27017
|
-
|
|
27018
|
-
|
|
27019
|
-
if (param.name) {
|
|
27020
|
-
let source;
|
|
27021
|
-
if (sourceOverride !== void 0) {
|
|
27022
|
-
source = sourceOverride;
|
|
27023
|
-
} else if (param.category === 1) {
|
|
27024
|
-
source = ParameterSource.PositionOnly;
|
|
27025
|
-
} else if (sawKeywordOnlySeparator) {
|
|
27026
|
-
source = ParameterSource.KeywordOnly;
|
|
27027
|
-
} else if (positionOnlyIndex >= 0 && index < positionOnlyIndex) {
|
|
27028
|
-
source = ParameterSource.PositionOnly;
|
|
27029
|
-
} else {
|
|
27030
|
-
source = ParameterSource.PositionOrKeyword;
|
|
27031
|
-
}
|
|
27032
|
-
result.params.push({
|
|
27033
|
-
param,
|
|
27034
|
-
index,
|
|
27035
|
-
type: typeOverride !== null && typeOverride !== void 0 ? typeOverride : types_1.FunctionType.getEffectiveParameterType(type, index),
|
|
27036
|
-
defaultArgType: defaultArgTypeOverride,
|
|
27037
|
-
source
|
|
27038
|
-
});
|
|
27039
|
-
}
|
|
27040
|
-
};
|
|
27041
|
-
type.details.parameters.forEach((param, index) => {
|
|
27042
|
-
var _a, _b;
|
|
27043
|
-
if (param.category === 1) {
|
|
27044
|
-
const paramType = types_1.FunctionType.getEffectiveParameterType(type, index);
|
|
27045
|
-
if (param.name && (0, types_1.isUnpackedClass)(paramType) && paramType.tupleTypeArguments) {
|
|
27046
|
-
const addToPositionalOnly = index < result.positionOnlyParamCount;
|
|
27047
|
-
paramType.tupleTypeArguments.forEach((tupleArg, tupleIndex) => {
|
|
27048
|
-
const category = (0, types_1.isVariadicTypeVar)(tupleArg.type) || tupleArg.isUnbounded ? 1 : 0;
|
|
27049
|
-
if (category === 1) {
|
|
27050
|
-
result.argsIndex = result.params.length;
|
|
27051
|
-
}
|
|
27052
|
-
if ((0, types_1.isVariadicTypeVar)(param.type)) {
|
|
27053
|
-
result.hasUnpackedVariadicTypeVar = true;
|
|
27054
|
-
}
|
|
27055
|
-
addVirtualParameter(
|
|
27056
|
-
{
|
|
27057
|
-
category,
|
|
27058
|
-
name: `${param.name}[${tupleIndex.toString()}]`,
|
|
27059
|
-
isNameSynthesized: true,
|
|
27060
|
-
type: tupleArg.type,
|
|
27061
|
-
hasDeclaredType: true
|
|
27062
|
-
},
|
|
27063
|
-
index,
|
|
27064
|
-
tupleArg.type,
|
|
27065
|
-
/* defaultArgTypeOverride */
|
|
27066
|
-
void 0,
|
|
27067
|
-
ParameterSource.PositionOnly
|
|
27068
|
-
);
|
|
27069
|
-
if (category === 0) {
|
|
27070
|
-
result.positionParamCount++;
|
|
27071
|
-
}
|
|
27072
|
-
if (tupleIndex > 0 && addToPositionalOnly) {
|
|
27073
|
-
result.positionOnlyParamCount++;
|
|
27074
|
-
}
|
|
27075
|
-
});
|
|
27076
|
-
if (!sawKeywordOnlySeparator && (positionOnlyIndex < 0 || index >= positionOnlyIndex)) {
|
|
27077
|
-
result.firstKeywordOnlyIndex = result.params.length;
|
|
27078
|
-
sawKeywordOnlySeparator = true;
|
|
27079
|
-
}
|
|
27080
|
-
} else {
|
|
27081
|
-
if (param.name && result.argsIndex === void 0) {
|
|
27082
|
-
result.argsIndex = result.params.length;
|
|
27083
|
-
if ((0, types_1.isVariadicTypeVar)(param.type)) {
|
|
27084
|
-
result.hasUnpackedVariadicTypeVar = true;
|
|
27085
|
-
}
|
|
27086
|
-
}
|
|
27087
|
-
if (!sawKeywordOnlySeparator && (positionOnlyIndex < 0 || index >= positionOnlyIndex)) {
|
|
27088
|
-
result.firstKeywordOnlyIndex = result.params.length;
|
|
27089
|
-
if (param.name) {
|
|
27090
|
-
result.firstKeywordOnlyIndex++;
|
|
27091
|
-
}
|
|
27092
|
-
sawKeywordOnlySeparator = true;
|
|
27093
|
-
}
|
|
27094
|
-
addVirtualParameter(param, index);
|
|
27095
|
-
}
|
|
27096
|
-
} else if (param.category === 2) {
|
|
27097
|
-
sawKeywordOnlySeparator = true;
|
|
27098
|
-
const paramType = types_1.FunctionType.getEffectiveParameterType(type, index);
|
|
27099
|
-
if ((0, types_1.isClassInstance)(paramType) && (0, types_1.isUnpackedClass)(paramType) && paramType.details.typedDictEntries) {
|
|
27100
|
-
if (result.firstKeywordOnlyIndex === void 0) {
|
|
27101
|
-
result.firstKeywordOnlyIndex = result.params.length;
|
|
27102
|
-
}
|
|
27103
|
-
const typedDictType = paramType;
|
|
27104
|
-
paramType.details.typedDictEntries.forEach((entry, name) => {
|
|
27105
|
-
const specializedParamType = partiallySpecializeType(entry.valueType, typedDictType);
|
|
27106
|
-
addVirtualParameter({
|
|
27107
|
-
category: 0,
|
|
27108
|
-
name,
|
|
27109
|
-
type: specializedParamType,
|
|
27110
|
-
hasDeclaredType: true,
|
|
27111
|
-
hasDefault: !entry.isRequired
|
|
27112
|
-
}, index, specializedParamType);
|
|
27113
|
-
});
|
|
27114
|
-
result.hasUnpackedTypedDict = true;
|
|
27115
|
-
} else if (param.name) {
|
|
27116
|
-
if (result.kwargsIndex === void 0) {
|
|
27117
|
-
result.kwargsIndex = result.params.length;
|
|
27118
|
-
}
|
|
27119
|
-
if (result.firstKeywordOnlyIndex === void 0) {
|
|
27120
|
-
result.firstKeywordOnlyIndex = result.params.length;
|
|
27121
|
-
}
|
|
27122
|
-
addVirtualParameter(param, index);
|
|
27123
|
-
}
|
|
27124
|
-
} else if (param.category === 0) {
|
|
27125
|
-
if (param.name && !sawKeywordOnlySeparator) {
|
|
27126
|
-
result.positionParamCount++;
|
|
27127
|
-
}
|
|
27128
|
-
addVirtualParameter(
|
|
27129
|
-
param,
|
|
27130
|
-
index,
|
|
27131
|
-
/* typeOverride */
|
|
27132
|
-
void 0,
|
|
27133
|
-
((_a = type.specializedTypes) === null || _a === void 0 ? void 0 : _a.parameterDefaultArgs) ? (_b = type.specializedTypes) === null || _b === void 0 ? void 0 : _b.parameterDefaultArgs[index] : void 0
|
|
27134
|
-
);
|
|
27135
|
-
}
|
|
27136
|
-
});
|
|
27137
|
-
return result;
|
|
27138
|
-
}
|
|
27139
|
-
exports.getParameterListDetails = getParameterListDetails;
|
|
26737
|
+
};
|
|
26738
|
+
exports.UniqueSignatureTracker = UniqueSignatureTracker;
|
|
27140
26739
|
function isOptionalType(type) {
|
|
27141
26740
|
if ((0, types_1.isUnion)(type)) {
|
|
27142
26741
|
return (0, types_1.findSubtype)(type, (subtype) => (0, types_1.isNoneInstance)(subtype)) !== void 0;
|
|
@@ -27148,6 +26747,31 @@ var require_typeUtils = __commonJS({
|
|
|
27148
26747
|
return (0, types_1.isUnknown)(type) && type.isIncomplete;
|
|
27149
26748
|
}
|
|
27150
26749
|
exports.isIncompleteUnknown = isIncompleteUnknown;
|
|
26750
|
+
function isTypeVarSame(type1, type2) {
|
|
26751
|
+
if ((0, types_1.isTypeSame)(type1, type2)) {
|
|
26752
|
+
return true;
|
|
26753
|
+
}
|
|
26754
|
+
if (type1.details.isParamSpec || type1.details.isVariadic || !type1.details.boundType) {
|
|
26755
|
+
return false;
|
|
26756
|
+
}
|
|
26757
|
+
if (!(0, types_1.isUnion)(type2)) {
|
|
26758
|
+
return false;
|
|
26759
|
+
}
|
|
26760
|
+
let isCompatible = true;
|
|
26761
|
+
doForEachSubtype(type2, (subtype) => {
|
|
26762
|
+
if (!isCompatible) {
|
|
26763
|
+
return;
|
|
26764
|
+
}
|
|
26765
|
+
if (!(0, types_1.isTypeSame)(type1, subtype)) {
|
|
26766
|
+
const conditions = getTypeCondition(subtype);
|
|
26767
|
+
if (!conditions || !conditions.some((condition) => condition.typeVarName === type1.nameWithScope)) {
|
|
26768
|
+
isCompatible = false;
|
|
26769
|
+
}
|
|
26770
|
+
}
|
|
26771
|
+
});
|
|
26772
|
+
return isCompatible;
|
|
26773
|
+
}
|
|
26774
|
+
exports.isTypeVarSame = isTypeVarSame;
|
|
27151
26775
|
function makeInferenceContext(expectedType, typeVarContext, isTypeIncomplete) {
|
|
27152
26776
|
if (!expectedType) {
|
|
27153
26777
|
return void 0;
|
|
@@ -27640,6 +27264,11 @@ var require_typeUtils = __commonJS({
|
|
|
27640
27264
|
typeVarContext.setTypeVarType(synthesizedSelfTypeVar, convertToInstance(selfClass));
|
|
27641
27265
|
}
|
|
27642
27266
|
exports.populateTypeVarContextForSelfType = populateTypeVarContextForSelfType;
|
|
27267
|
+
function ensureFunctionSignaturesAreUnique(type, signatureTracker) {
|
|
27268
|
+
const transformer = new UniqueFunctionSignatureTransformer(signatureTracker);
|
|
27269
|
+
return transformer.apply(type, 0);
|
|
27270
|
+
}
|
|
27271
|
+
exports.ensureFunctionSignaturesAreUnique = ensureFunctionSignaturesAreUnique;
|
|
27643
27272
|
function applySolvedTypeVars(type, typeVarContext, options = {}) {
|
|
27644
27273
|
if (typeVarContext.isEmpty() && !options.unknownIfNotFound && !options.eliminateUnsolvedInUnions) {
|
|
27645
27274
|
return type;
|
|
@@ -28306,10 +27935,12 @@ var require_typeUtils = __commonJS({
|
|
|
28306
27935
|
if (type.typeAliasInfo && type !== result) {
|
|
28307
27936
|
result = types_1.TypeBase.cloneForTypeAlias(result, type.typeAliasInfo.name, type.typeAliasInfo.fullName, type.typeAliasInfo.typeVarScopeId, type.typeAliasInfo.typeParameters, type.typeAliasInfo.typeArguments);
|
|
28308
27937
|
}
|
|
28309
|
-
if (
|
|
28310
|
-
type.cached
|
|
27938
|
+
if (type !== result) {
|
|
27939
|
+
if (!type.cached) {
|
|
27940
|
+
type.cached = {};
|
|
27941
|
+
}
|
|
27942
|
+
type.cached.instanceType = result;
|
|
28311
27943
|
}
|
|
28312
|
-
type.cached.instanceType = result;
|
|
28313
27944
|
return result;
|
|
28314
27945
|
}
|
|
28315
27946
|
exports.convertToInstance = convertToInstance;
|
|
@@ -28963,7 +28594,7 @@ var require_typeUtils = __commonJS({
|
|
|
28963
28594
|
return type;
|
|
28964
28595
|
}
|
|
28965
28596
|
recursionCount++;
|
|
28966
|
-
type = this.
|
|
28597
|
+
type = this.transformGenericTypeAlias(type, recursionCount);
|
|
28967
28598
|
if (!requiresSpecialization(type)) {
|
|
28968
28599
|
return type;
|
|
28969
28600
|
}
|
|
@@ -29033,14 +28664,14 @@ var require_typeUtils = __commonJS({
|
|
|
29033
28664
|
return !(0, types_1.isNever)(newUnionType) ? newUnionType : types_1.UnknownType.create();
|
|
29034
28665
|
}
|
|
29035
28666
|
if ((0, types_1.isClass)(type)) {
|
|
29036
|
-
return this.
|
|
28667
|
+
return this.transformTypeVarsInClassType(type, recursionCount);
|
|
29037
28668
|
}
|
|
29038
28669
|
if ((0, types_1.isFunction)(type)) {
|
|
29039
28670
|
if (this._pendingFunctionTransformations.some((t) => t === type)) {
|
|
29040
28671
|
return type;
|
|
29041
28672
|
}
|
|
29042
28673
|
this._pendingFunctionTransformations.push(type);
|
|
29043
|
-
const result = this.
|
|
28674
|
+
const result = this.transformTypeVarsInFunctionType(type, recursionCount);
|
|
29044
28675
|
this._pendingFunctionTransformations.pop();
|
|
29045
28676
|
return result;
|
|
29046
28677
|
}
|
|
@@ -29052,7 +28683,7 @@ var require_typeUtils = __commonJS({
|
|
|
29052
28683
|
let requiresUpdate = false;
|
|
29053
28684
|
const newOverloads = [];
|
|
29054
28685
|
type.overloads.forEach((entry) => {
|
|
29055
|
-
const replacementType = this.
|
|
28686
|
+
const replacementType = this.transformTypeVarsInFunctionType(entry, recursionCount);
|
|
29056
28687
|
if ((0, types_1.isFunction)(replacementType)) {
|
|
29057
28688
|
newOverloads.push(replacementType);
|
|
29058
28689
|
} else {
|
|
@@ -29068,7 +28699,7 @@ var require_typeUtils = __commonJS({
|
|
|
29068
28699
|
return type;
|
|
29069
28700
|
}
|
|
29070
28701
|
transformTypeVar(typeVar, recursionCount) {
|
|
29071
|
-
return
|
|
28702
|
+
return void 0;
|
|
29072
28703
|
}
|
|
29073
28704
|
transformTupleTypeVar(paramSpec, recursionCount) {
|
|
29074
28705
|
return void 0;
|
|
@@ -29082,7 +28713,7 @@ var require_typeUtils = __commonJS({
|
|
|
29082
28713
|
doForEachSignatureContext(callback) {
|
|
29083
28714
|
return callback();
|
|
29084
28715
|
}
|
|
29085
|
-
|
|
28716
|
+
transformGenericTypeAlias(type, recursionCount) {
|
|
29086
28717
|
if (!type.typeAliasInfo || !type.typeAliasInfo.typeParameters || !type.typeAliasInfo.typeArguments) {
|
|
29087
28718
|
return type;
|
|
29088
28719
|
}
|
|
@@ -29096,11 +28727,11 @@ var require_typeUtils = __commonJS({
|
|
|
29096
28727
|
});
|
|
29097
28728
|
return requiresUpdate ? types_1.TypeBase.cloneForTypeAlias(type, type.typeAliasInfo.name, type.typeAliasInfo.fullName, type.typeAliasInfo.typeVarScopeId, type.typeAliasInfo.typeParameters, newTypeArgs) : type;
|
|
29098
28729
|
}
|
|
29099
|
-
|
|
28730
|
+
transformTypeVarsInClassType(classType, recursionCount) {
|
|
29100
28731
|
if (types_1.ClassType.getTypeParameters(classType).length === 0 && !types_1.ClassType.isSpecialBuiltIn(classType)) {
|
|
29101
28732
|
return classType;
|
|
29102
28733
|
}
|
|
29103
|
-
let newTypeArgs
|
|
28734
|
+
let newTypeArgs;
|
|
29104
28735
|
let newTupleTypeArgs;
|
|
29105
28736
|
let specializationNeeded = false;
|
|
29106
28737
|
const typeParams = types_1.ClassType.getTypeParameters(classType);
|
|
@@ -29115,43 +28746,6 @@ var require_typeUtils = __commonJS({
|
|
|
29115
28746
|
};
|
|
29116
28747
|
const wasTransformingTypeArg = this._isTransformingTypeArg;
|
|
29117
28748
|
this._isTransformingTypeArg = true;
|
|
29118
|
-
if (classType.typeArguments) {
|
|
29119
|
-
newTypeArgs = classType.typeArguments.map((oldTypeArgType) => {
|
|
29120
|
-
if ((0, types_1.isTypeVar)(oldTypeArgType) && oldTypeArgType.details.isParamSpec) {
|
|
29121
|
-
return transformParamSpec(oldTypeArgType);
|
|
29122
|
-
}
|
|
29123
|
-
let newTypeArgType = this.apply(oldTypeArgType, recursionCount);
|
|
29124
|
-
if (newTypeArgType !== oldTypeArgType) {
|
|
29125
|
-
specializationNeeded = true;
|
|
29126
|
-
if ((0, types_1.isTypeVar)(oldTypeArgType) && (0, types_1.isVariadicTypeVar)(oldTypeArgType) && oldTypeArgType.isVariadicInUnion) {
|
|
29127
|
-
newTypeArgType = _expandVariadicUnpackedUnion(newTypeArgType);
|
|
29128
|
-
}
|
|
29129
|
-
}
|
|
29130
|
-
return newTypeArgType;
|
|
29131
|
-
});
|
|
29132
|
-
} else {
|
|
29133
|
-
typeParams.forEach((typeParam) => {
|
|
29134
|
-
let replacementType = typeParam;
|
|
29135
|
-
if (typeParam.details.isParamSpec) {
|
|
29136
|
-
replacementType = transformParamSpec(typeParam);
|
|
29137
|
-
if (replacementType !== typeParam) {
|
|
29138
|
-
specializationNeeded = true;
|
|
29139
|
-
}
|
|
29140
|
-
} else {
|
|
29141
|
-
const typeParamName = types_1.TypeVarType.getNameWithScope(typeParam);
|
|
29142
|
-
if (!this._pendingTypeVarTransformations.has(typeParamName)) {
|
|
29143
|
-
const transformedType = this.transformTypeVar(typeParam, recursionCount);
|
|
29144
|
-
replacementType = transformedType !== null && transformedType !== void 0 ? transformedType : typeParam;
|
|
29145
|
-
if (replacementType !== typeParam) {
|
|
29146
|
-
specializationNeeded = true;
|
|
29147
|
-
} else if (transformedType !== void 0 && !classType.typeArguments) {
|
|
29148
|
-
specializationNeeded = true;
|
|
29149
|
-
}
|
|
29150
|
-
}
|
|
29151
|
-
}
|
|
29152
|
-
newTypeArgs.push(replacementType);
|
|
29153
|
-
});
|
|
29154
|
-
}
|
|
29155
28749
|
if (types_1.ClassType.isTupleClass(classType)) {
|
|
29156
28750
|
if (classType.tupleTypeArguments) {
|
|
29157
28751
|
newTupleTypeArgs = [];
|
|
@@ -29172,6 +28766,60 @@ var require_typeUtils = __commonJS({
|
|
|
29172
28766
|
specializationNeeded = true;
|
|
29173
28767
|
}
|
|
29174
28768
|
}
|
|
28769
|
+
if (newTupleTypeArgs && newTupleTypeArgs.length > 0) {
|
|
28770
|
+
newTypeArgs = [
|
|
28771
|
+
(0, types_1.combineTypes)(newTupleTypeArgs.map((t) => {
|
|
28772
|
+
if ((0, types_1.isTypeVar)(t.type) && (0, types_1.isUnpackedVariadicTypeVar)(t.type)) {
|
|
28773
|
+
return types_1.TypeVarType.cloneForUnpacked(
|
|
28774
|
+
t.type,
|
|
28775
|
+
/* isInUnion */
|
|
28776
|
+
true
|
|
28777
|
+
);
|
|
28778
|
+
}
|
|
28779
|
+
return t.type;
|
|
28780
|
+
}))
|
|
28781
|
+
];
|
|
28782
|
+
}
|
|
28783
|
+
}
|
|
28784
|
+
if (!newTypeArgs) {
|
|
28785
|
+
if (classType.typeArguments) {
|
|
28786
|
+
newTypeArgs = classType.typeArguments.map((oldTypeArgType) => {
|
|
28787
|
+
if ((0, types_1.isTypeVar)(oldTypeArgType) && oldTypeArgType.details.isParamSpec) {
|
|
28788
|
+
return transformParamSpec(oldTypeArgType);
|
|
28789
|
+
}
|
|
28790
|
+
let newTypeArgType = this.apply(oldTypeArgType, recursionCount);
|
|
28791
|
+
if (newTypeArgType !== oldTypeArgType) {
|
|
28792
|
+
specializationNeeded = true;
|
|
28793
|
+
if ((0, types_1.isTypeVar)(oldTypeArgType) && (0, types_1.isVariadicTypeVar)(oldTypeArgType) && oldTypeArgType.isVariadicInUnion) {
|
|
28794
|
+
newTypeArgType = _expandVariadicUnpackedUnion(newTypeArgType);
|
|
28795
|
+
}
|
|
28796
|
+
}
|
|
28797
|
+
return newTypeArgType;
|
|
28798
|
+
});
|
|
28799
|
+
} else {
|
|
28800
|
+
newTypeArgs = [];
|
|
28801
|
+
typeParams.forEach((typeParam) => {
|
|
28802
|
+
let replacementType = typeParam;
|
|
28803
|
+
if (typeParam.details.isParamSpec) {
|
|
28804
|
+
replacementType = transformParamSpec(typeParam);
|
|
28805
|
+
if (replacementType !== typeParam) {
|
|
28806
|
+
specializationNeeded = true;
|
|
28807
|
+
}
|
|
28808
|
+
} else {
|
|
28809
|
+
const typeParamName = types_1.TypeVarType.getNameWithScope(typeParam);
|
|
28810
|
+
if (!this._pendingTypeVarTransformations.has(typeParamName)) {
|
|
28811
|
+
const transformedType = this.transformTypeVar(typeParam, recursionCount);
|
|
28812
|
+
replacementType = transformedType !== null && transformedType !== void 0 ? transformedType : typeParam;
|
|
28813
|
+
if (replacementType !== typeParam) {
|
|
28814
|
+
specializationNeeded = true;
|
|
28815
|
+
} else if (transformedType !== void 0 && !classType.typeArguments) {
|
|
28816
|
+
specializationNeeded = true;
|
|
28817
|
+
}
|
|
28818
|
+
}
|
|
28819
|
+
}
|
|
28820
|
+
newTypeArgs.push(replacementType);
|
|
28821
|
+
});
|
|
28822
|
+
}
|
|
29175
28823
|
}
|
|
29176
28824
|
this._isTransformingTypeArg = wasTransformingTypeArg;
|
|
29177
28825
|
if (!specializationNeeded) {
|
|
@@ -29187,7 +28835,7 @@ var require_typeUtils = __commonJS({
|
|
|
29187
28835
|
newTupleTypeArgs
|
|
29188
28836
|
);
|
|
29189
28837
|
}
|
|
29190
|
-
|
|
28838
|
+
transformTypeVarsInFunctionType(sourceType, recursionCount) {
|
|
29191
28839
|
return this.doForEachSignatureContext(() => {
|
|
29192
28840
|
let functionType = sourceType;
|
|
29193
28841
|
if (functionType.details.paramSpec) {
|
|
@@ -29334,6 +28982,29 @@ var require_typeUtils = __commonJS({
|
|
|
29334
28982
|
return void 0;
|
|
29335
28983
|
}
|
|
29336
28984
|
};
|
|
28985
|
+
var UniqueFunctionSignatureTransformer = class extends TypeVarTransformer {
|
|
28986
|
+
constructor(_signatureTracker) {
|
|
28987
|
+
super();
|
|
28988
|
+
this._signatureTracker = _signatureTracker;
|
|
28989
|
+
}
|
|
28990
|
+
transformTypeVarsInFunctionType(sourceType, recursionCount) {
|
|
28991
|
+
if (sourceType.details.typeParameters.length === 0) {
|
|
28992
|
+
return super.transformTypeVarsInFunctionType(sourceType, recursionCount);
|
|
28993
|
+
}
|
|
28994
|
+
let updatedSourceType = sourceType;
|
|
28995
|
+
const existingSignature = this._signatureTracker.findSignature(sourceType);
|
|
28996
|
+
if (existingSignature) {
|
|
28997
|
+
const typeVarContext = new typeVarContext_1.TypeVarContext(getTypeVarScopeId(sourceType));
|
|
28998
|
+
sourceType.details.typeParameters.forEach((typeParam) => {
|
|
28999
|
+
const replacement = types_1.TypeVarType.cloneForNewName(typeParam, `${typeParam.details.name}(${existingSignature.count})`);
|
|
29000
|
+
typeVarContext.setTypeVarType(typeParam, replacement);
|
|
29001
|
+
updatedSourceType = applySolvedTypeVars(sourceType, typeVarContext);
|
|
29002
|
+
});
|
|
29003
|
+
}
|
|
29004
|
+
this._signatureTracker.addSignature(sourceType);
|
|
29005
|
+
return updatedSourceType;
|
|
29006
|
+
}
|
|
29007
|
+
};
|
|
29337
29008
|
var ApplySolvedTypeVarsTransformer = class extends TypeVarTransformer {
|
|
29338
29009
|
constructor(_typeVarContext, _options) {
|
|
29339
29010
|
super();
|
|
@@ -29512,6 +29183,313 @@ var require_typeUtils = __commonJS({
|
|
|
29512
29183
|
}
|
|
29513
29184
|
});
|
|
29514
29185
|
|
|
29186
|
+
// node_modules/@zzzen/pyright-internal/dist/analyzer/parameterUtils.js
|
|
29187
|
+
var require_parameterUtils = __commonJS({
|
|
29188
|
+
"node_modules/@zzzen/pyright-internal/dist/analyzer/parameterUtils.js"(exports) {
|
|
29189
|
+
"use strict";
|
|
29190
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29191
|
+
exports.getParameterListDetails = exports.ParameterSource = exports.isTypedKwargs = void 0;
|
|
29192
|
+
var symbolNameUtils_1 = require_symbolNameUtils();
|
|
29193
|
+
var types_1 = require_types();
|
|
29194
|
+
var typeUtils_1 = require_typeUtils();
|
|
29195
|
+
function isTypedKwargs(param) {
|
|
29196
|
+
return param.category === 2 && (0, types_1.isClassInstance)(param.type) && (0, types_1.isUnpackedClass)(param.type) && types_1.ClassType.isTypedDictClass(param.type) && !!param.type.details.typedDictEntries;
|
|
29197
|
+
}
|
|
29198
|
+
exports.isTypedKwargs = isTypedKwargs;
|
|
29199
|
+
var ParameterSource;
|
|
29200
|
+
(function(ParameterSource2) {
|
|
29201
|
+
ParameterSource2[ParameterSource2["PositionOnly"] = 0] = "PositionOnly";
|
|
29202
|
+
ParameterSource2[ParameterSource2["PositionOrKeyword"] = 1] = "PositionOrKeyword";
|
|
29203
|
+
ParameterSource2[ParameterSource2["KeywordOnly"] = 2] = "KeywordOnly";
|
|
29204
|
+
})(ParameterSource = exports.ParameterSource || (exports.ParameterSource = {}));
|
|
29205
|
+
function getParameterListDetails(type) {
|
|
29206
|
+
const result = {
|
|
29207
|
+
firstPositionOrKeywordIndex: 0,
|
|
29208
|
+
positionParamCount: 0,
|
|
29209
|
+
positionOnlyParamCount: 0,
|
|
29210
|
+
params: [],
|
|
29211
|
+
hasUnpackedVariadicTypeVar: false,
|
|
29212
|
+
hasUnpackedTypedDict: false
|
|
29213
|
+
};
|
|
29214
|
+
let positionOnlyIndex = type.details.parameters.findIndex((p) => p.category === 0 && !p.name);
|
|
29215
|
+
if (positionOnlyIndex < 0) {
|
|
29216
|
+
for (let i = 0; i < type.details.parameters.length; i++) {
|
|
29217
|
+
const p = type.details.parameters[i];
|
|
29218
|
+
if (p.category !== 0) {
|
|
29219
|
+
break;
|
|
29220
|
+
}
|
|
29221
|
+
if (!p.name) {
|
|
29222
|
+
break;
|
|
29223
|
+
}
|
|
29224
|
+
if ((0, symbolNameUtils_1.isDunderName)(p.name) || !p.name.startsWith("__")) {
|
|
29225
|
+
break;
|
|
29226
|
+
}
|
|
29227
|
+
positionOnlyIndex = i + 1;
|
|
29228
|
+
}
|
|
29229
|
+
}
|
|
29230
|
+
if (positionOnlyIndex >= 0) {
|
|
29231
|
+
result.firstPositionOrKeywordIndex = positionOnlyIndex;
|
|
29232
|
+
}
|
|
29233
|
+
for (let i = 0; i < positionOnlyIndex; i++) {
|
|
29234
|
+
if (type.details.parameters[i].hasDefault) {
|
|
29235
|
+
break;
|
|
29236
|
+
}
|
|
29237
|
+
result.positionOnlyParamCount++;
|
|
29238
|
+
}
|
|
29239
|
+
let sawKeywordOnlySeparator = false;
|
|
29240
|
+
const addVirtualParameter = (param, index, typeOverride, defaultArgTypeOverride, sourceOverride) => {
|
|
29241
|
+
if (param.name) {
|
|
29242
|
+
let source;
|
|
29243
|
+
if (sourceOverride !== void 0) {
|
|
29244
|
+
source = sourceOverride;
|
|
29245
|
+
} else if (param.category === 1) {
|
|
29246
|
+
source = ParameterSource.PositionOnly;
|
|
29247
|
+
} else if (sawKeywordOnlySeparator) {
|
|
29248
|
+
source = ParameterSource.KeywordOnly;
|
|
29249
|
+
} else if (positionOnlyIndex >= 0 && index < positionOnlyIndex) {
|
|
29250
|
+
source = ParameterSource.PositionOnly;
|
|
29251
|
+
} else {
|
|
29252
|
+
source = ParameterSource.PositionOrKeyword;
|
|
29253
|
+
}
|
|
29254
|
+
result.params.push({
|
|
29255
|
+
param,
|
|
29256
|
+
index,
|
|
29257
|
+
type: typeOverride !== null && typeOverride !== void 0 ? typeOverride : types_1.FunctionType.getEffectiveParameterType(type, index),
|
|
29258
|
+
defaultArgType: defaultArgTypeOverride,
|
|
29259
|
+
source
|
|
29260
|
+
});
|
|
29261
|
+
}
|
|
29262
|
+
};
|
|
29263
|
+
type.details.parameters.forEach((param, index) => {
|
|
29264
|
+
var _a, _b;
|
|
29265
|
+
if (param.category === 1) {
|
|
29266
|
+
const paramType = types_1.FunctionType.getEffectiveParameterType(type, index);
|
|
29267
|
+
if (param.name && (0, types_1.isUnpackedClass)(paramType) && paramType.tupleTypeArguments) {
|
|
29268
|
+
const addToPositionalOnly = index < result.positionOnlyParamCount;
|
|
29269
|
+
paramType.tupleTypeArguments.forEach((tupleArg, tupleIndex) => {
|
|
29270
|
+
const category = (0, types_1.isVariadicTypeVar)(tupleArg.type) || tupleArg.isUnbounded ? 1 : 0;
|
|
29271
|
+
if (category === 1) {
|
|
29272
|
+
result.argsIndex = result.params.length;
|
|
29273
|
+
}
|
|
29274
|
+
if ((0, types_1.isVariadicTypeVar)(param.type)) {
|
|
29275
|
+
result.hasUnpackedVariadicTypeVar = true;
|
|
29276
|
+
}
|
|
29277
|
+
addVirtualParameter(
|
|
29278
|
+
{
|
|
29279
|
+
category,
|
|
29280
|
+
name: `${param.name}[${tupleIndex.toString()}]`,
|
|
29281
|
+
isNameSynthesized: true,
|
|
29282
|
+
type: tupleArg.type,
|
|
29283
|
+
hasDeclaredType: true
|
|
29284
|
+
},
|
|
29285
|
+
index,
|
|
29286
|
+
tupleArg.type,
|
|
29287
|
+
/* defaultArgTypeOverride */
|
|
29288
|
+
void 0,
|
|
29289
|
+
ParameterSource.PositionOnly
|
|
29290
|
+
);
|
|
29291
|
+
if (category === 0) {
|
|
29292
|
+
result.positionParamCount++;
|
|
29293
|
+
}
|
|
29294
|
+
if (tupleIndex > 0 && addToPositionalOnly) {
|
|
29295
|
+
result.positionOnlyParamCount++;
|
|
29296
|
+
}
|
|
29297
|
+
});
|
|
29298
|
+
if (!sawKeywordOnlySeparator && (positionOnlyIndex < 0 || index >= positionOnlyIndex)) {
|
|
29299
|
+
result.firstKeywordOnlyIndex = result.params.length;
|
|
29300
|
+
sawKeywordOnlySeparator = true;
|
|
29301
|
+
}
|
|
29302
|
+
} else {
|
|
29303
|
+
if (param.name && result.argsIndex === void 0) {
|
|
29304
|
+
result.argsIndex = result.params.length;
|
|
29305
|
+
if ((0, types_1.isVariadicTypeVar)(param.type)) {
|
|
29306
|
+
result.hasUnpackedVariadicTypeVar = true;
|
|
29307
|
+
}
|
|
29308
|
+
}
|
|
29309
|
+
if (!sawKeywordOnlySeparator && (positionOnlyIndex < 0 || index >= positionOnlyIndex)) {
|
|
29310
|
+
result.firstKeywordOnlyIndex = result.params.length;
|
|
29311
|
+
if (param.name) {
|
|
29312
|
+
result.firstKeywordOnlyIndex++;
|
|
29313
|
+
}
|
|
29314
|
+
sawKeywordOnlySeparator = true;
|
|
29315
|
+
}
|
|
29316
|
+
addVirtualParameter(param, index);
|
|
29317
|
+
}
|
|
29318
|
+
} else if (param.category === 2) {
|
|
29319
|
+
sawKeywordOnlySeparator = true;
|
|
29320
|
+
const paramType = types_1.FunctionType.getEffectiveParameterType(type, index);
|
|
29321
|
+
if ((0, types_1.isClassInstance)(paramType) && (0, types_1.isUnpackedClass)(paramType) && paramType.details.typedDictEntries) {
|
|
29322
|
+
if (result.firstKeywordOnlyIndex === void 0) {
|
|
29323
|
+
result.firstKeywordOnlyIndex = result.params.length;
|
|
29324
|
+
}
|
|
29325
|
+
const typedDictType = paramType;
|
|
29326
|
+
paramType.details.typedDictEntries.forEach((entry, name) => {
|
|
29327
|
+
const specializedParamType = (0, typeUtils_1.partiallySpecializeType)(entry.valueType, typedDictType);
|
|
29328
|
+
addVirtualParameter({
|
|
29329
|
+
category: 0,
|
|
29330
|
+
name,
|
|
29331
|
+
type: specializedParamType,
|
|
29332
|
+
hasDeclaredType: true,
|
|
29333
|
+
hasDefault: !entry.isRequired
|
|
29334
|
+
}, index, specializedParamType);
|
|
29335
|
+
});
|
|
29336
|
+
result.hasUnpackedTypedDict = true;
|
|
29337
|
+
} else if (param.name) {
|
|
29338
|
+
if (result.kwargsIndex === void 0) {
|
|
29339
|
+
result.kwargsIndex = result.params.length;
|
|
29340
|
+
}
|
|
29341
|
+
if (result.firstKeywordOnlyIndex === void 0) {
|
|
29342
|
+
result.firstKeywordOnlyIndex = result.params.length;
|
|
29343
|
+
}
|
|
29344
|
+
addVirtualParameter(param, index);
|
|
29345
|
+
}
|
|
29346
|
+
} else if (param.category === 0) {
|
|
29347
|
+
if (param.name && !sawKeywordOnlySeparator) {
|
|
29348
|
+
result.positionParamCount++;
|
|
29349
|
+
}
|
|
29350
|
+
addVirtualParameter(
|
|
29351
|
+
param,
|
|
29352
|
+
index,
|
|
29353
|
+
/* typeOverride */
|
|
29354
|
+
void 0,
|
|
29355
|
+
((_a = type.specializedTypes) === null || _a === void 0 ? void 0 : _a.parameterDefaultArgs) ? (_b = type.specializedTypes) === null || _b === void 0 ? void 0 : _b.parameterDefaultArgs[index] : void 0
|
|
29356
|
+
);
|
|
29357
|
+
}
|
|
29358
|
+
});
|
|
29359
|
+
return result;
|
|
29360
|
+
}
|
|
29361
|
+
exports.getParameterListDetails = getParameterListDetails;
|
|
29362
|
+
}
|
|
29363
|
+
});
|
|
29364
|
+
|
|
29365
|
+
// node_modules/@zzzen/pyright-internal/dist/analyzer/scopeUtils.js
|
|
29366
|
+
var require_scopeUtils = __commonJS({
|
|
29367
|
+
"node_modules/@zzzen/pyright-internal/dist/analyzer/scopeUtils.js"(exports) {
|
|
29368
|
+
"use strict";
|
|
29369
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29370
|
+
exports.findTopNodeInScope = exports.getScopeHierarchy = exports.getScopeForNode = exports.getBuiltInScope = void 0;
|
|
29371
|
+
var analyzerNodeInfo_1 = require_analyzerNodeInfo();
|
|
29372
|
+
var parseTreeUtils_1 = require_parseTreeUtils();
|
|
29373
|
+
function getBuiltInScope(currentScope) {
|
|
29374
|
+
let builtInScope = currentScope;
|
|
29375
|
+
while (builtInScope.type !== 4) {
|
|
29376
|
+
builtInScope = builtInScope.parent;
|
|
29377
|
+
}
|
|
29378
|
+
return builtInScope;
|
|
29379
|
+
}
|
|
29380
|
+
exports.getBuiltInScope = getBuiltInScope;
|
|
29381
|
+
function getScopeForNode(node) {
|
|
29382
|
+
const scopeNode = (0, parseTreeUtils_1.getEvaluationScopeNode)(node);
|
|
29383
|
+
return (0, analyzerNodeInfo_1.getScope)(scopeNode);
|
|
29384
|
+
}
|
|
29385
|
+
exports.getScopeForNode = getScopeForNode;
|
|
29386
|
+
function getScopeHierarchy(node, stopScope) {
|
|
29387
|
+
const scopeHierarchy = [];
|
|
29388
|
+
let curNode = node;
|
|
29389
|
+
while (curNode) {
|
|
29390
|
+
const curScope = getScopeForNode(curNode);
|
|
29391
|
+
if (!curScope) {
|
|
29392
|
+
return void 0;
|
|
29393
|
+
}
|
|
29394
|
+
if (scopeHierarchy.length === 0 || scopeHierarchy[scopeHierarchy.length - 1] !== curScope) {
|
|
29395
|
+
scopeHierarchy.push(curScope);
|
|
29396
|
+
}
|
|
29397
|
+
if (curScope === stopScope) {
|
|
29398
|
+
return scopeHierarchy;
|
|
29399
|
+
}
|
|
29400
|
+
curNode = curNode.parent;
|
|
29401
|
+
}
|
|
29402
|
+
return stopScope ? void 0 : scopeHierarchy;
|
|
29403
|
+
}
|
|
29404
|
+
exports.getScopeHierarchy = getScopeHierarchy;
|
|
29405
|
+
function findTopNodeInScope(node, scope) {
|
|
29406
|
+
let curNode = node;
|
|
29407
|
+
let prevNode;
|
|
29408
|
+
let foundScope = false;
|
|
29409
|
+
while (curNode) {
|
|
29410
|
+
if ((0, analyzerNodeInfo_1.getScope)(curNode) === scope) {
|
|
29411
|
+
foundScope = true;
|
|
29412
|
+
} else if (foundScope) {
|
|
29413
|
+
return prevNode;
|
|
29414
|
+
}
|
|
29415
|
+
prevNode = curNode;
|
|
29416
|
+
curNode = curNode.parent;
|
|
29417
|
+
}
|
|
29418
|
+
return void 0;
|
|
29419
|
+
}
|
|
29420
|
+
exports.findTopNodeInScope = findTopNodeInScope;
|
|
29421
|
+
}
|
|
29422
|
+
});
|
|
29423
|
+
|
|
29424
|
+
// node_modules/@zzzen/pyright-internal/dist/analyzer/sourceFileInfoUtils.js
|
|
29425
|
+
var require_sourceFileInfoUtils = __commonJS({
|
|
29426
|
+
"node_modules/@zzzen/pyright-internal/dist/analyzer/sourceFileInfoUtils.js"(exports) {
|
|
29427
|
+
"use strict";
|
|
29428
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29429
|
+
exports.collectImportedByFiles = exports.isUserCode = void 0;
|
|
29430
|
+
function isUserCode(fileInfo) {
|
|
29431
|
+
return !!fileInfo && fileInfo.isTracked && !fileInfo.isThirdPartyImport && !fileInfo.isTypeshedFile;
|
|
29432
|
+
}
|
|
29433
|
+
exports.isUserCode = isUserCode;
|
|
29434
|
+
function collectImportedByFiles(fileInfo) {
|
|
29435
|
+
const importedByFiles = /* @__PURE__ */ new Set();
|
|
29436
|
+
_collectImportedByFiles(fileInfo, importedByFiles);
|
|
29437
|
+
return importedByFiles;
|
|
29438
|
+
}
|
|
29439
|
+
exports.collectImportedByFiles = collectImportedByFiles;
|
|
29440
|
+
function _collectImportedByFiles(fileInfo, importedByFiles) {
|
|
29441
|
+
fileInfo.importedBy.forEach((dep) => {
|
|
29442
|
+
if (importedByFiles.has(dep)) {
|
|
29443
|
+
return;
|
|
29444
|
+
}
|
|
29445
|
+
importedByFiles.add(dep);
|
|
29446
|
+
_collectImportedByFiles(dep, importedByFiles);
|
|
29447
|
+
});
|
|
29448
|
+
}
|
|
29449
|
+
}
|
|
29450
|
+
});
|
|
29451
|
+
|
|
29452
|
+
// node_modules/@zzzen/pyright-internal/dist/analyzer/sourceMapperUtils.js
|
|
29453
|
+
var require_sourceMapperUtils = __commonJS({
|
|
29454
|
+
"node_modules/@zzzen/pyright-internal/dist/analyzer/sourceMapperUtils.js"(exports) {
|
|
29455
|
+
"use strict";
|
|
29456
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29457
|
+
exports.buildImportTree = void 0;
|
|
29458
|
+
var MAX_TREE_SEARCH_COUNT = 1e3;
|
|
29459
|
+
var NumberReference = class {
|
|
29460
|
+
constructor() {
|
|
29461
|
+
this.value = 0;
|
|
29462
|
+
}
|
|
29463
|
+
};
|
|
29464
|
+
function buildImportTree(to, from, next, token) {
|
|
29465
|
+
const totalCountRef = new NumberReference();
|
|
29466
|
+
const results = _buildImportTreeImpl(to, from, next, [], totalCountRef, token);
|
|
29467
|
+
return results.length > 0 ? results : [from];
|
|
29468
|
+
}
|
|
29469
|
+
exports.buildImportTree = buildImportTree;
|
|
29470
|
+
function _buildImportTreeImpl(to, from, next, previous, totalSearched, token) {
|
|
29471
|
+
if (totalSearched.value > MAX_TREE_SEARCH_COUNT || token.isCancellationRequested) {
|
|
29472
|
+
return [];
|
|
29473
|
+
}
|
|
29474
|
+
totalSearched.value += 1;
|
|
29475
|
+
if (from === to) {
|
|
29476
|
+
return previous.length ? previous : [from];
|
|
29477
|
+
}
|
|
29478
|
+
if (previous.length > 1 && previous.find((s) => s === from)) {
|
|
29479
|
+
return [];
|
|
29480
|
+
}
|
|
29481
|
+
const nextEntries = next(from);
|
|
29482
|
+
for (let i = 0; i < nextEntries.length && !token.isCancellationRequested; i++) {
|
|
29483
|
+
const subentries = _buildImportTreeImpl(to, nextEntries[i], next, [...previous, from], totalSearched, token);
|
|
29484
|
+
if (subentries.length > 0) {
|
|
29485
|
+
return subentries;
|
|
29486
|
+
}
|
|
29487
|
+
}
|
|
29488
|
+
return [];
|
|
29489
|
+
}
|
|
29490
|
+
}
|
|
29491
|
+
});
|
|
29492
|
+
|
|
29515
29493
|
// node_modules/@zzzen/pyright-internal/dist/analyzer/sourceMapper.js
|
|
29516
29494
|
var require_sourceMapper = __commonJS({
|
|
29517
29495
|
"node_modules/@zzzen/pyright-internal/dist/analyzer/sourceMapper.js"(exports) {
|
|
@@ -30712,7 +30690,6 @@ var require_package_nls_en_us = __commonJS({
|
|
|
30712
30690
|
tupleEntryTypeMismatch: "Tuple entry {entry} is incorrect type",
|
|
30713
30691
|
tupleAssignmentMismatch: 'Type "{type}" is incompatible with target tuple',
|
|
30714
30692
|
tupleSizeMismatch: "Element size mismatch; expected {expected} but received {received}",
|
|
30715
|
-
tupleSizeMismatchIndeterminate: "Tuple size mismatch; expected {expected} but received indeterminate number",
|
|
30716
30693
|
typeAssignmentMismatch: 'Type "{sourceType}" cannot be assigned to type "{destType}"',
|
|
30717
30694
|
typeBound: 'Type "{sourceType}" is incompatible with bound type "{destType}" for type variable "{name}"',
|
|
30718
30695
|
typeConstrainedTypeVar: 'Type "{type}" is incompatible with constrained type variable "{name}"',
|
|
@@ -31595,7 +31572,6 @@ var require_localize = __commonJS({
|
|
|
31595
31572
|
DiagnosticAddendum2.tupleEntryTypeMismatch = () => new ParameterizedString(getRawString("DiagnosticAddendum.tupleEntryTypeMismatch"));
|
|
31596
31573
|
DiagnosticAddendum2.tupleAssignmentMismatch = () => new ParameterizedString(getRawString("DiagnosticAddendum.tupleAssignmentMismatch"));
|
|
31597
31574
|
DiagnosticAddendum2.tupleSizeMismatch = () => new ParameterizedString(getRawString("DiagnosticAddendum.tupleSizeMismatch"));
|
|
31598
|
-
DiagnosticAddendum2.tupleSizeMismatchIndeterminate = () => new ParameterizedString(getRawString("DiagnosticAddendum.tupleSizeMismatchIndeterminate"));
|
|
31599
31575
|
DiagnosticAddendum2.typeAssignmentMismatch = () => new ParameterizedString(getRawString("DiagnosticAddendum.typeAssignmentMismatch"));
|
|
31600
31576
|
DiagnosticAddendum2.typeBound = () => new ParameterizedString(getRawString("DiagnosticAddendum.typeBound"));
|
|
31601
31577
|
DiagnosticAddendum2.typeConstrainedTypeVar = () => new ParameterizedString(getRawString("DiagnosticAddendum.typeConstrainedTypeVar"));
|
|
@@ -31834,15 +31810,47 @@ var require_typedDicts = __commonJS({
|
|
|
31834
31810
|
});
|
|
31835
31811
|
types_1.FunctionType.addDefaultParameters(newType);
|
|
31836
31812
|
newType.details.declaredReturnType = types_1.ClassType.cloneAsInstance(classType);
|
|
31837
|
-
const
|
|
31838
|
-
|
|
31813
|
+
const initOverride1 = types_1.FunctionType.createSynthesizedInstance(
|
|
31814
|
+
"__init__",
|
|
31815
|
+
256
|
|
31816
|
+
/* Overloaded */
|
|
31817
|
+
);
|
|
31818
|
+
types_1.FunctionType.addParameter(initOverride1, {
|
|
31839
31819
|
category: 0,
|
|
31840
31820
|
name: "self",
|
|
31841
31821
|
type: types_1.ClassType.cloneAsInstance(classType),
|
|
31842
31822
|
hasDeclaredType: true
|
|
31843
31823
|
});
|
|
31844
|
-
|
|
31845
|
-
types_1.FunctionType.addParameter(
|
|
31824
|
+
initOverride1.details.declaredReturnType = types_1.NoneType.createInstance();
|
|
31825
|
+
types_1.FunctionType.addParameter(initOverride1, {
|
|
31826
|
+
category: 0,
|
|
31827
|
+
name: "__map",
|
|
31828
|
+
type: types_1.ClassType.cloneAsInstance(classType),
|
|
31829
|
+
hasDeclaredType: true
|
|
31830
|
+
});
|
|
31831
|
+
types_1.FunctionType.addParameter(initOverride1, {
|
|
31832
|
+
category: 0,
|
|
31833
|
+
name: "",
|
|
31834
|
+
type: types_1.UnknownType.create()
|
|
31835
|
+
});
|
|
31836
|
+
types_1.FunctionType.addParameter(initOverride1, {
|
|
31837
|
+
category: 1,
|
|
31838
|
+
type: types_1.AnyType.create(),
|
|
31839
|
+
hasDeclaredType: true
|
|
31840
|
+
});
|
|
31841
|
+
const initOverride2 = types_1.FunctionType.createSynthesizedInstance(
|
|
31842
|
+
"__init__",
|
|
31843
|
+
256
|
|
31844
|
+
/* Overloaded */
|
|
31845
|
+
);
|
|
31846
|
+
types_1.FunctionType.addParameter(initOverride2, {
|
|
31847
|
+
category: 0,
|
|
31848
|
+
name: "self",
|
|
31849
|
+
type: types_1.ClassType.cloneAsInstance(classType),
|
|
31850
|
+
hasDeclaredType: true
|
|
31851
|
+
});
|
|
31852
|
+
initOverride2.details.declaredReturnType = types_1.NoneType.createInstance();
|
|
31853
|
+
types_1.FunctionType.addParameter(initOverride2, {
|
|
31846
31854
|
category: 1,
|
|
31847
31855
|
type: types_1.AnyType.create(),
|
|
31848
31856
|
hasDeclaredType: true
|
|
@@ -31850,7 +31858,14 @@ var require_typedDicts = __commonJS({
|
|
|
31850
31858
|
const entries = getTypedDictMembersForClass(evaluator, classType);
|
|
31851
31859
|
let allEntriesAreNotRequired = true;
|
|
31852
31860
|
entries.forEach((entry, name) => {
|
|
31853
|
-
types_1.FunctionType.addParameter(
|
|
31861
|
+
types_1.FunctionType.addParameter(initOverride1, {
|
|
31862
|
+
category: 0,
|
|
31863
|
+
name,
|
|
31864
|
+
hasDefault: true,
|
|
31865
|
+
type: entry.valueType,
|
|
31866
|
+
hasDeclaredType: true
|
|
31867
|
+
});
|
|
31868
|
+
types_1.FunctionType.addParameter(initOverride2, {
|
|
31854
31869
|
category: 0,
|
|
31855
31870
|
name,
|
|
31856
31871
|
hasDefault: !entry.isRequired,
|
|
@@ -31862,6 +31877,7 @@ var require_typedDicts = __commonJS({
|
|
|
31862
31877
|
}
|
|
31863
31878
|
});
|
|
31864
31879
|
const symbolTable = classType.details.fields;
|
|
31880
|
+
const initType = types_1.OverloadedFunctionType.create([initOverride1, initOverride2]);
|
|
31865
31881
|
symbolTable.set("__init__", symbol_1.Symbol.createWithType(4, initType));
|
|
31866
31882
|
symbolTable.set("__new__", symbol_1.Symbol.createWithType(4, newType));
|
|
31867
31883
|
const strClass = evaluator.getBuiltInType(node, "str");
|
|
@@ -32387,6 +32403,7 @@ var require_typedDicts = __commonJS({
|
|
|
32387
32403
|
let diag = new diagnostic_1.DiagnosticAddendum();
|
|
32388
32404
|
let allDiagsInvolveNotRequiredKeys = true;
|
|
32389
32405
|
const resultingType = (0, typeUtils_1.mapSubtypes)(indexType, (subtype) => {
|
|
32406
|
+
var _a, _b;
|
|
32390
32407
|
if ((0, types_1.isAnyOrUnknown)(subtype)) {
|
|
32391
32408
|
return subtype;
|
|
32392
32409
|
}
|
|
@@ -32416,7 +32433,7 @@ var require_typedDicts = __commonJS({
|
|
|
32416
32433
|
}
|
|
32417
32434
|
}
|
|
32418
32435
|
if (usage.method === "set") {
|
|
32419
|
-
if (!evaluator.assignType(entry.valueType, usage.setType || types_1.AnyType.create(), diag)) {
|
|
32436
|
+
if (!evaluator.assignType(entry.valueType, (_b = (_a = usage.setType) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : types_1.AnyType.create(), diag)) {
|
|
32420
32437
|
allDiagsInvolveNotRequiredKeys = false;
|
|
32421
32438
|
}
|
|
32422
32439
|
} else if (usage.method === "del" && entry.isRequired) {
|
|
@@ -35527,7 +35544,7 @@ var require_documentSymbolCollector = __commonJS({
|
|
|
35527
35544
|
if (index === 0) {
|
|
35528
35545
|
const decls = [];
|
|
35529
35546
|
decls.push(...((_d = evaluator.getDeclarationsForNameNode(moduleName.nameParts[0])) === null || _d === void 0 ? void 0 : _d.filter((d) => (0, declaration_1.isAliasDeclaration)(d))) || []);
|
|
35530
|
-
if (decls.length === 0) {
|
|
35547
|
+
if (decls.length === 0 || moduleName.parent.nodeType !== 21) {
|
|
35531
35548
|
return decls;
|
|
35532
35549
|
}
|
|
35533
35550
|
const isImportAsWithAlias = moduleName.nameParts.length === 1 && moduleName.parent.nodeType === 21 && !!moduleName.parent.alias;
|
|
@@ -36450,12 +36467,17 @@ ${methodBody}`;
|
|
|
36450
36467
|
return sb + `super().${decl.node.name.value}(${parameters.map(convertToString).join(", ")})`;
|
|
36451
36468
|
function getParameters(parameters2) {
|
|
36452
36469
|
const results = [];
|
|
36453
|
-
let
|
|
36470
|
+
let sawKeywordOnlySeparator = false;
|
|
36454
36471
|
for (const parameter of parameters2) {
|
|
36455
36472
|
if (parameter.name) {
|
|
36456
|
-
results.push([
|
|
36473
|
+
results.push([
|
|
36474
|
+
parameter,
|
|
36475
|
+
parameter.category === 0 && !!parameter.name && sawKeywordOnlySeparator
|
|
36476
|
+
]);
|
|
36477
|
+
}
|
|
36478
|
+
if (parameter.category === 1) {
|
|
36479
|
+
sawKeywordOnlySeparator = true;
|
|
36457
36480
|
}
|
|
36458
|
-
keywordOnly = parameter.category === 1 || parameter.category === 2;
|
|
36459
36481
|
}
|
|
36460
36482
|
return results;
|
|
36461
36483
|
}
|
|
@@ -37269,7 +37291,7 @@ ${methodBody}`;
|
|
|
37269
37291
|
const hidden = !(0, symbolUtils_1.isVisibleExternally)(symbol) && !symbol.getDeclarations().some((d) => (0, declarationUtils_1.isDefinedInFile)(d, this._filePath));
|
|
37270
37292
|
if (!hidden && includeSymbolCallback(symbol, name)) {
|
|
37271
37293
|
if (!completionMap.has(name)) {
|
|
37272
|
-
const skipForClass =
|
|
37294
|
+
const skipForClass = !this._shouldShowAutoParensForClass(symbol, node);
|
|
37273
37295
|
this._addSymbol(name, symbol, priorWord, completionMap, {
|
|
37274
37296
|
boundObjectOrClass,
|
|
37275
37297
|
funcParensDisabled: isInImport || insideTypeAnnotation || skipForClass,
|
|
@@ -37279,6 +37301,21 @@ ${methodBody}`;
|
|
|
37279
37301
|
}
|
|
37280
37302
|
});
|
|
37281
37303
|
}
|
|
37304
|
+
_shouldShowAutoParensForClass(symbol, node) {
|
|
37305
|
+
var _a;
|
|
37306
|
+
if (symbol.getDeclarations().every(
|
|
37307
|
+
(d) => d.type !== 6
|
|
37308
|
+
/* Class */
|
|
37309
|
+
)) {
|
|
37310
|
+
return true;
|
|
37311
|
+
}
|
|
37312
|
+
if (((_a = node.parent) === null || _a === void 0 ? void 0 : _a.nodeType) === 1) {
|
|
37313
|
+
return true;
|
|
37314
|
+
}
|
|
37315
|
+
const nodeIndex = ParseTreeUtils.getTokenIndexAtLeft(this._parseResults.tokenizerOutput.tokens, node.start);
|
|
37316
|
+
const prevToken = ParseTreeUtils.getTokenAtIndex(this._parseResults.tokenizerOutput.tokens, nodeIndex);
|
|
37317
|
+
return prevToken && prevToken.type === 9 && prevToken.operatorType === 2;
|
|
37318
|
+
}
|
|
37282
37319
|
_addSymbol(name, symbol, priorWord, completionMap, detail) {
|
|
37283
37320
|
var _a, _b, _c, _d;
|
|
37284
37321
|
let primaryDecl = (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(symbol);
|
|
@@ -37980,115 +38017,6 @@ var require_documentHighlightProvider = __commonJS({
|
|
|
37980
38017
|
}
|
|
37981
38018
|
});
|
|
37982
38019
|
|
|
37983
|
-
// node_modules/@zzzen/pyright-internal/dist/analyzer/aliasDeclarationUtils.js
|
|
37984
|
-
var require_aliasDeclarationUtils = __commonJS({
|
|
37985
|
-
"node_modules/@zzzen/pyright-internal/dist/analyzer/aliasDeclarationUtils.js"(exports) {
|
|
37986
|
-
"use strict";
|
|
37987
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
37988
|
-
exports.resolveAliasDeclaration = void 0;
|
|
37989
|
-
function resolveAliasDeclaration(importLookup, declaration, resolveLocalNames, allowExternallyHiddenAccess) {
|
|
37990
|
-
let curDeclaration = declaration;
|
|
37991
|
-
const alreadyVisited = [];
|
|
37992
|
-
let isPrivate = false;
|
|
37993
|
-
let sawPyTypedTransition = false;
|
|
37994
|
-
let privatePyTypedImported;
|
|
37995
|
-
let privatePyTypedImporter;
|
|
37996
|
-
while (true) {
|
|
37997
|
-
if (curDeclaration.type !== 8 || !curDeclaration.symbolName) {
|
|
37998
|
-
return {
|
|
37999
|
-
declaration: curDeclaration,
|
|
38000
|
-
isPrivate,
|
|
38001
|
-
privatePyTypedImported,
|
|
38002
|
-
privatePyTypedImporter
|
|
38003
|
-
};
|
|
38004
|
-
}
|
|
38005
|
-
if (!resolveLocalNames && curDeclaration.usesLocalName) {
|
|
38006
|
-
return {
|
|
38007
|
-
declaration: curDeclaration,
|
|
38008
|
-
isPrivate,
|
|
38009
|
-
privatePyTypedImported,
|
|
38010
|
-
privatePyTypedImporter
|
|
38011
|
-
};
|
|
38012
|
-
}
|
|
38013
|
-
let lookupResult;
|
|
38014
|
-
if (curDeclaration.path && curDeclaration.loadSymbolsFromPath) {
|
|
38015
|
-
lookupResult = importLookup(curDeclaration.path);
|
|
38016
|
-
}
|
|
38017
|
-
const symbol = lookupResult ? lookupResult.symbolTable.get(curDeclaration.symbolName) : void 0;
|
|
38018
|
-
if (!symbol) {
|
|
38019
|
-
if (curDeclaration.submoduleFallback) {
|
|
38020
|
-
if (curDeclaration.symbolName) {
|
|
38021
|
-
if (curDeclaration.submoduleFallback.type === 8 && curDeclaration.submoduleFallback.path) {
|
|
38022
|
-
const lookupResult2 = importLookup(curDeclaration.submoduleFallback.path);
|
|
38023
|
-
if (!lookupResult2) {
|
|
38024
|
-
return void 0;
|
|
38025
|
-
}
|
|
38026
|
-
}
|
|
38027
|
-
}
|
|
38028
|
-
return resolveAliasDeclaration(importLookup, curDeclaration.submoduleFallback, resolveLocalNames, allowExternallyHiddenAccess);
|
|
38029
|
-
}
|
|
38030
|
-
if (curDeclaration.isNativeLib) {
|
|
38031
|
-
return {
|
|
38032
|
-
declaration: void 0,
|
|
38033
|
-
isPrivate
|
|
38034
|
-
};
|
|
38035
|
-
}
|
|
38036
|
-
return void 0;
|
|
38037
|
-
}
|
|
38038
|
-
if (symbol.isPrivateMember()) {
|
|
38039
|
-
isPrivate = true;
|
|
38040
|
-
}
|
|
38041
|
-
if (symbol.isExternallyHidden() && !allowExternallyHiddenAccess) {
|
|
38042
|
-
return void 0;
|
|
38043
|
-
}
|
|
38044
|
-
let declarations = symbol.getTypedDeclarations();
|
|
38045
|
-
declarations = declarations.filter((decl) => !decl.isInExceptSuite);
|
|
38046
|
-
if (declarations.length === 0) {
|
|
38047
|
-
declarations = symbol.getDeclarations();
|
|
38048
|
-
declarations = declarations.filter((decl) => !decl.isInExceptSuite);
|
|
38049
|
-
}
|
|
38050
|
-
if (declarations.length === 0) {
|
|
38051
|
-
declarations = symbol.getDeclarations();
|
|
38052
|
-
}
|
|
38053
|
-
if (declarations.length === 0) {
|
|
38054
|
-
return void 0;
|
|
38055
|
-
}
|
|
38056
|
-
const unvisitedDecls = declarations.filter((decl) => !alreadyVisited.includes(decl));
|
|
38057
|
-
if (unvisitedDecls.length > 0) {
|
|
38058
|
-
curDeclaration = unvisitedDecls[unvisitedDecls.length - 1];
|
|
38059
|
-
} else {
|
|
38060
|
-
curDeclaration = declarations[declarations.length - 1];
|
|
38061
|
-
}
|
|
38062
|
-
if (lookupResult === null || lookupResult === void 0 ? void 0 : lookupResult.isInPyTypedPackage) {
|
|
38063
|
-
if (!sawPyTypedTransition) {
|
|
38064
|
-
if (symbol.isPrivatePyTypedImport()) {
|
|
38065
|
-
privatePyTypedImporter = curDeclaration === null || curDeclaration === void 0 ? void 0 : curDeclaration.moduleName;
|
|
38066
|
-
}
|
|
38067
|
-
sawPyTypedTransition = true;
|
|
38068
|
-
} else {
|
|
38069
|
-
if (!symbol.isPrivatePyTypedImport()) {
|
|
38070
|
-
privatePyTypedImported = privatePyTypedImported !== null && privatePyTypedImported !== void 0 ? privatePyTypedImported : curDeclaration === null || curDeclaration === void 0 ? void 0 : curDeclaration.moduleName;
|
|
38071
|
-
}
|
|
38072
|
-
}
|
|
38073
|
-
}
|
|
38074
|
-
if (alreadyVisited.find((decl) => decl === curDeclaration)) {
|
|
38075
|
-
if (curDeclaration.path === declaration.path && curDeclaration.type === 8 && curDeclaration.submoduleFallback) {
|
|
38076
|
-
return resolveAliasDeclaration(importLookup, curDeclaration.submoduleFallback, resolveLocalNames, allowExternallyHiddenAccess);
|
|
38077
|
-
}
|
|
38078
|
-
return {
|
|
38079
|
-
declaration,
|
|
38080
|
-
isPrivate,
|
|
38081
|
-
privatePyTypedImported,
|
|
38082
|
-
privatePyTypedImporter
|
|
38083
|
-
};
|
|
38084
|
-
}
|
|
38085
|
-
alreadyVisited.push(curDeclaration);
|
|
38086
|
-
}
|
|
38087
|
-
}
|
|
38088
|
-
exports.resolveAliasDeclaration = resolveAliasDeclaration;
|
|
38089
|
-
}
|
|
38090
|
-
});
|
|
38091
|
-
|
|
38092
38020
|
// node_modules/@zzzen/pyright-internal/dist/languageService/documentSymbolProvider.js
|
|
38093
38021
|
var require_documentSymbolProvider = __commonJS({
|
|
38094
38022
|
"node_modules/@zzzen/pyright-internal/dist/languageService/documentSymbolProvider.js"(exports) {
|
|
@@ -38125,7 +38053,6 @@ var require_documentSymbolProvider = __commonJS({
|
|
|
38125
38053
|
exports.DocumentSymbolProvider = exports.convertToFlatSymbols = exports.getIndexAliasData = void 0;
|
|
38126
38054
|
var vscode_languageserver_1 = require_main3();
|
|
38127
38055
|
var vscode_uri_1 = (init_esm(), __toCommonJS(esm_exports));
|
|
38128
|
-
var aliasDeclarationUtils_1 = require_aliasDeclarationUtils();
|
|
38129
38056
|
var AnalyzerNodeInfo = __importStar(require_analyzerNodeInfo());
|
|
38130
38057
|
var declarationUtils_1 = require_declarationUtils();
|
|
38131
38058
|
var symbolUtils_1 = require_symbolUtils();
|
|
@@ -38139,7 +38066,7 @@ var require_documentSymbolProvider = __commonJS({
|
|
|
38139
38066
|
if (!declaration.symbolName) {
|
|
38140
38067
|
return void 0;
|
|
38141
38068
|
}
|
|
38142
|
-
const resolvedInfo = (0,
|
|
38069
|
+
const resolvedInfo = (0, declarationUtils_1.resolveAliasDeclaration)(
|
|
38143
38070
|
importLookup,
|
|
38144
38071
|
declaration,
|
|
38145
38072
|
/* resolveLocalNames */
|
|
@@ -38480,12 +38407,11 @@ var require_hoverProvider = __commonJS({
|
|
|
38480
38407
|
results.lastKnownModule = primaryDeclaration.moduleName;
|
|
38481
38408
|
} else if (!node.parent || node.parent.nodeType !== 37) {
|
|
38482
38409
|
if (results.parts.length === 0) {
|
|
38483
|
-
|
|
38410
|
+
const type = this._getType(evaluator, node);
|
|
38484
38411
|
let typeText;
|
|
38485
38412
|
if ((0, types_1.isModule)(type)) {
|
|
38486
38413
|
typeText = "(module) " + node.value;
|
|
38487
38414
|
} else {
|
|
38488
|
-
type = this._limitOverloadBasedOnCall(node, evaluator, type);
|
|
38489
38415
|
let label = "function";
|
|
38490
38416
|
let isProperty = false;
|
|
38491
38417
|
if ((0, typeUtils_1.isMaybeDescriptorInstance)(
|
|
@@ -38564,17 +38490,17 @@ var require_hoverProvider = __commonJS({
|
|
|
38564
38490
|
typeNode = declaration.node;
|
|
38565
38491
|
}
|
|
38566
38492
|
}
|
|
38567
|
-
let type =
|
|
38568
|
-
if ((
|
|
38569
|
-
const inferredType =
|
|
38570
|
-
if (
|
|
38493
|
+
let type = this._getType(evaluator, typeNode);
|
|
38494
|
+
if ((0, types_1.isUnknown)(type) && resolvedDecl.alternativeTypeNode && (0, parseNodes_1.isExpressionNode)(resolvedDecl.alternativeTypeNode)) {
|
|
38495
|
+
const inferredType = this._getType(evaluator, resolvedDecl.alternativeTypeNode);
|
|
38496
|
+
if (!(0, types_1.isUnknown)(inferredType)) {
|
|
38571
38497
|
type = inferredType;
|
|
38572
38498
|
typeNode = resolvedDecl.alternativeTypeNode;
|
|
38573
38499
|
}
|
|
38574
38500
|
}
|
|
38575
38501
|
let expandTypeAlias = false;
|
|
38576
38502
|
let typeVarName;
|
|
38577
|
-
if (
|
|
38503
|
+
if (type.typeAliasInfo && typeNode.nodeType === 38) {
|
|
38578
38504
|
const typeAliasInfo = (0, types_1.getTypeAliasInfo)(type);
|
|
38579
38505
|
if ((typeAliasInfo === null || typeAliasInfo === void 0 ? void 0 : typeAliasInfo.name) === typeNode.value) {
|
|
38580
38506
|
if ((0, types_1.isTypeVar)(type)) {
|
|
@@ -38655,22 +38581,19 @@ var require_hoverProvider = __commonJS({
|
|
|
38655
38581
|
);
|
|
38656
38582
|
label = isProperty ? "property" : "method";
|
|
38657
38583
|
}
|
|
38658
|
-
let type =
|
|
38584
|
+
let type = this._getType(evaluator, node);
|
|
38659
38585
|
const resolvedType = extensibility_1.Extensions.getProgramExtensions(resolvedDecl.node).map((e) => {
|
|
38660
38586
|
var _a2;
|
|
38661
38587
|
return (_a2 = e.typeProviderExtension) === null || _a2 === void 0 ? void 0 : _a2.tryGetFunctionNodeType(resolvedDecl.node, evaluator, token);
|
|
38662
|
-
}).find((t) => !!t) ||
|
|
38663
|
-
type =
|
|
38664
|
-
|
|
38665
|
-
|
|
38666
|
-
|
|
38667
|
-
|
|
38668
|
-
|
|
38669
|
-
|
|
38670
|
-
|
|
38671
|
-
true
|
|
38672
|
-
);
|
|
38673
|
-
}
|
|
38588
|
+
}).find((t) => !!t) || this._getType(evaluator, resolvedDecl.node.name);
|
|
38589
|
+
type = (0, types_1.isAnyOrUnknown)(type) ? resolvedType : type;
|
|
38590
|
+
const signatureString = (0, tooltipUtils_1.getToolTipForType)(type, label, node.value, evaluator, isProperty, functionSignatureDisplay);
|
|
38591
|
+
this._addResultsPart(
|
|
38592
|
+
parts,
|
|
38593
|
+
signatureString,
|
|
38594
|
+
/* python */
|
|
38595
|
+
true
|
|
38596
|
+
);
|
|
38674
38597
|
this._addDocumentationPart(format, sourceMapper, parts, node, evaluator, resolvedDecl);
|
|
38675
38598
|
break;
|
|
38676
38599
|
}
|
|
@@ -38742,12 +38665,12 @@ var require_hoverProvider = __commonJS({
|
|
|
38742
38665
|
if (!callLeftNode || !callLeftNode.parent || callLeftNode.parent.nodeType !== 9 || callLeftNode.parent.leftExpression !== callLeftNode) {
|
|
38743
38666
|
return false;
|
|
38744
38667
|
}
|
|
38745
|
-
const classType =
|
|
38746
|
-
if (!
|
|
38668
|
+
const classType = this._getType(evaluator, node);
|
|
38669
|
+
if (!(0, types_1.isInstantiableClass)(classType)) {
|
|
38747
38670
|
return false;
|
|
38748
38671
|
}
|
|
38749
|
-
const instanceType =
|
|
38750
|
-
if (!
|
|
38672
|
+
const instanceType = this._getType(evaluator, callLeftNode.parent);
|
|
38673
|
+
if (!(0, types_1.isClassInstance)(instanceType)) {
|
|
38751
38674
|
return false;
|
|
38752
38675
|
}
|
|
38753
38676
|
let methodType;
|
|
@@ -38760,7 +38683,7 @@ var require_hoverProvider = __commonJS({
|
|
|
38760
38683
|
if (initMember) {
|
|
38761
38684
|
const functionType = evaluator.getTypeOfMember(initMember);
|
|
38762
38685
|
if ((0, types_1.isFunction)(functionType) || (0, types_1.isOverloadedFunction)(functionType)) {
|
|
38763
|
-
methodType =
|
|
38686
|
+
methodType = this._bindFunctionToClassOrObject(evaluator, node, instanceType, functionType);
|
|
38764
38687
|
}
|
|
38765
38688
|
}
|
|
38766
38689
|
if (!methodType || methodType && (0, types_1.isFunction)(methodType) && (types_1.FunctionType.hasDefaultParameters(methodType) || methodType.details.parameters.length === 0)) {
|
|
@@ -38773,15 +38696,11 @@ var require_hoverProvider = __commonJS({
|
|
|
38773
38696
|
if (newMember) {
|
|
38774
38697
|
const newMemberType = evaluator.getTypeOfMember(newMember);
|
|
38775
38698
|
if ((0, types_1.isFunction)(newMemberType) || (0, types_1.isOverloadedFunction)(newMemberType)) {
|
|
38776
|
-
methodType =
|
|
38699
|
+
methodType = this._bindFunctionToClassOrObject(
|
|
38700
|
+
evaluator,
|
|
38701
|
+
node,
|
|
38777
38702
|
instanceType,
|
|
38778
38703
|
newMemberType,
|
|
38779
|
-
/* memberClass */
|
|
38780
|
-
void 0,
|
|
38781
|
-
/* errorNode */
|
|
38782
|
-
void 0,
|
|
38783
|
-
/* recursiveCount */
|
|
38784
|
-
void 0,
|
|
38785
38704
|
/* treatConstructorAsClassMember */
|
|
38786
38705
|
true
|
|
38787
38706
|
);
|
|
@@ -38789,7 +38708,6 @@ var require_hoverProvider = __commonJS({
|
|
|
38789
38708
|
}
|
|
38790
38709
|
}
|
|
38791
38710
|
if (methodType && ((0, types_1.isFunction)(methodType) || (0, types_1.isOverloadedFunction)(methodType))) {
|
|
38792
|
-
methodType = this._limitOverloadBasedOnCall(node, evaluator, methodType);
|
|
38793
38711
|
this._addResultsPart(
|
|
38794
38712
|
parts,
|
|
38795
38713
|
(0, tooltipUtils_1.getConstructorTooltip)(node.value, methodType, evaluator, functionSignatureDisplay),
|
|
@@ -38805,32 +38723,54 @@ var require_hoverProvider = __commonJS({
|
|
|
38805
38723
|
return false;
|
|
38806
38724
|
}
|
|
38807
38725
|
static _getTypeText(node, evaluator, expandTypeAlias = false) {
|
|
38808
|
-
|
|
38809
|
-
type = this._limitOverloadBasedOnCall(node, evaluator, type);
|
|
38726
|
+
const type = this._getType(evaluator, node);
|
|
38810
38727
|
return ": " + evaluator.printType(type, { expandTypeAlias });
|
|
38811
38728
|
}
|
|
38812
38729
|
static _getTypesText(nodes, evaluator, expandTypeAlias = false) {
|
|
38813
38730
|
const type = (0, tooltipUtils_1.combineExpressionTypes)(nodes, evaluator);
|
|
38814
38731
|
return ": " + evaluator.printType(type, { expandTypeAlias });
|
|
38815
38732
|
}
|
|
38816
|
-
static
|
|
38817
|
-
|
|
38818
|
-
|
|
38819
|
-
|
|
38820
|
-
|
|
38821
|
-
|
|
38822
|
-
|
|
38823
|
-
|
|
38824
|
-
|
|
38825
|
-
|
|
38826
|
-
|
|
38827
|
-
|
|
38828
|
-
|
|
38733
|
+
static _bindFunctionToClassOrObject(evaluator, node, baseType, memberType, treatConstructorAsClassMember) {
|
|
38734
|
+
const methodType = evaluator.bindFunctionToClassOrObject(
|
|
38735
|
+
baseType,
|
|
38736
|
+
memberType,
|
|
38737
|
+
/* memberClass */
|
|
38738
|
+
void 0,
|
|
38739
|
+
/* errorNode */
|
|
38740
|
+
void 0,
|
|
38741
|
+
/* recursiveCount */
|
|
38742
|
+
void 0,
|
|
38743
|
+
treatConstructorAsClassMember
|
|
38744
|
+
);
|
|
38745
|
+
if (!methodType) {
|
|
38746
|
+
return void 0;
|
|
38829
38747
|
}
|
|
38830
|
-
return
|
|
38748
|
+
return this._limitOverloadBasedOnCall(evaluator, methodType, node);
|
|
38749
|
+
}
|
|
38750
|
+
static _getType(evaluator, node) {
|
|
38751
|
+
var _a;
|
|
38752
|
+
const type = (_a = evaluator.getType(node)) !== null && _a !== void 0 ? _a : types_1.UnknownType.create();
|
|
38753
|
+
return this._limitOverloadBasedOnCall(evaluator, type, node);
|
|
38754
|
+
}
|
|
38755
|
+
static _limitOverloadBasedOnCall(evaluator, type, node) {
|
|
38756
|
+
if (!(0, types_1.isOverloadedFunction)(type) || node.nodeType !== 38) {
|
|
38757
|
+
return type;
|
|
38758
|
+
}
|
|
38759
|
+
const callNode = ParseTreeUtils.getCallForName(node);
|
|
38760
|
+
if (!callNode) {
|
|
38761
|
+
return type;
|
|
38762
|
+
}
|
|
38763
|
+
const callTypeResult = evaluator.getTypeResult(callNode);
|
|
38764
|
+
if (!callTypeResult || !callTypeResult.overloadsUsedForCall || callTypeResult.overloadsUsedForCall.length === 0) {
|
|
38765
|
+
return type;
|
|
38766
|
+
}
|
|
38767
|
+
if (callTypeResult.overloadsUsedForCall.length === 1) {
|
|
38768
|
+
return callTypeResult.overloadsUsedForCall[0];
|
|
38769
|
+
}
|
|
38770
|
+
return types_1.OverloadedFunctionType.create(callTypeResult.overloadsUsedForCall);
|
|
38831
38771
|
}
|
|
38832
38772
|
static _addDocumentationPart(format, sourceMapper, parts, node, evaluator, resolvedDecl) {
|
|
38833
|
-
const type =
|
|
38773
|
+
const type = this._getType(evaluator, node);
|
|
38834
38774
|
this._addDocumentationPartForType(format, sourceMapper, parts, type, resolvedDecl, evaluator, node.value);
|
|
38835
38775
|
}
|
|
38836
38776
|
static _addDocumentationPartForType(format, sourceMapper, parts, type, resolvedDecl, evaluator, name) {
|
|
@@ -39913,7 +39853,7 @@ var require_binder = __commonJS({
|
|
|
39913
39853
|
return result;
|
|
39914
39854
|
};
|
|
39915
39855
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39916
|
-
exports.ReturnFinder = exports.YieldFinder = exports.Binder = void 0;
|
|
39856
|
+
exports.DummyScopeGenerator = exports.ReturnFinder = exports.YieldFinder = exports.Binder = void 0;
|
|
39917
39857
|
var collectionUtils_1 = require_collectionUtils();
|
|
39918
39858
|
var debug_1 = require_debug2();
|
|
39919
39859
|
var diagnosticRules_1 = require_diagnosticRules();
|
|
@@ -41667,6 +41607,10 @@ var require_binder = __commonJS({
|
|
|
41667
41607
|
this._targetFunctionDeclaration.isGenerator = true;
|
|
41668
41608
|
}
|
|
41669
41609
|
}
|
|
41610
|
+
if (!this._moduleSymbolOnly) {
|
|
41611
|
+
const dummyScopeGenerator = new DummyScopeGenerator(this._currentScope);
|
|
41612
|
+
dummyScopeGenerator.walk(statement);
|
|
41613
|
+
}
|
|
41670
41614
|
}
|
|
41671
41615
|
}
|
|
41672
41616
|
return false;
|
|
@@ -42864,6 +42808,39 @@ var require_binder = __commonJS({
|
|
|
42864
42808
|
}
|
|
42865
42809
|
};
|
|
42866
42810
|
exports.ReturnFinder = ReturnFinder;
|
|
42811
|
+
var DummyScopeGenerator = class extends parseTreeWalker_1.ParseTreeWalker {
|
|
42812
|
+
constructor(currentScope) {
|
|
42813
|
+
super();
|
|
42814
|
+
this._currentScope = currentScope;
|
|
42815
|
+
}
|
|
42816
|
+
visitClass(node) {
|
|
42817
|
+
const newScope = this._createNewScope(2, () => {
|
|
42818
|
+
this.walk(node.suite);
|
|
42819
|
+
});
|
|
42820
|
+
if (!AnalyzerNodeInfo.getScope(node)) {
|
|
42821
|
+
AnalyzerNodeInfo.setScope(node, newScope);
|
|
42822
|
+
}
|
|
42823
|
+
return false;
|
|
42824
|
+
}
|
|
42825
|
+
visitFunction(node) {
|
|
42826
|
+
const newScope = this._createNewScope(1, () => {
|
|
42827
|
+
this.walk(node.suite);
|
|
42828
|
+
});
|
|
42829
|
+
if (!AnalyzerNodeInfo.getScope(node)) {
|
|
42830
|
+
AnalyzerNodeInfo.setScope(node, newScope);
|
|
42831
|
+
}
|
|
42832
|
+
return false;
|
|
42833
|
+
}
|
|
42834
|
+
_createNewScope(scopeType, callback) {
|
|
42835
|
+
const prevScope = this._currentScope;
|
|
42836
|
+
const newScope = new scope_1.Scope(scopeType, this._currentScope);
|
|
42837
|
+
this._currentScope = newScope;
|
|
42838
|
+
callback();
|
|
42839
|
+
this._currentScope = prevScope;
|
|
42840
|
+
return newScope;
|
|
42841
|
+
}
|
|
42842
|
+
};
|
|
42843
|
+
exports.DummyScopeGenerator = DummyScopeGenerator;
|
|
42867
42844
|
}
|
|
42868
42845
|
});
|
|
42869
42846
|
|
|
@@ -48640,8 +48617,13 @@ var require_constraintSolver = __commonJS({
|
|
|
48640
48617
|
makeConcrete = false;
|
|
48641
48618
|
}
|
|
48642
48619
|
}
|
|
48620
|
+
const adjWideTypeBound = makeConcrete ? evaluator.makeTopLevelTypeVarsConcrete(
|
|
48621
|
+
curWideTypeBound,
|
|
48622
|
+
/* makeParamSpecsConcrete */
|
|
48623
|
+
true
|
|
48624
|
+
) : curWideTypeBound;
|
|
48643
48625
|
if (!evaluator.assignType(
|
|
48644
|
-
|
|
48626
|
+
adjWideTypeBound,
|
|
48645
48627
|
newNarrowTypeBound,
|
|
48646
48628
|
diag === null || diag === void 0 ? void 0 : diag.createAddendum(),
|
|
48647
48629
|
/* destTypeVarContext */
|
|
@@ -49001,10 +48983,11 @@ var require_typeGuards = __commonJS({
|
|
|
49001
48983
|
var symbol_1 = require_symbol();
|
|
49002
48984
|
var typedDicts_1 = require_typedDicts();
|
|
49003
48985
|
var types_1 = require_types();
|
|
48986
|
+
var types_2 = require_types();
|
|
49004
48987
|
var typeUtils_1 = require_typeUtils();
|
|
49005
48988
|
var typeVarContext_1 = require_typeVarContext();
|
|
49006
48989
|
function getTypeNarrowingCallback(evaluator, reference, testExpression, isPositiveTest, recursionCount = 0) {
|
|
49007
|
-
if (recursionCount >
|
|
48990
|
+
if (recursionCount > types_2.maxTypeRecursionCount) {
|
|
49008
48991
|
return void 0;
|
|
49009
48992
|
}
|
|
49010
48993
|
recursionCount++;
|
|
@@ -49061,10 +49044,10 @@ var require_typeGuards = __commonJS({
|
|
|
49061
49044
|
2
|
|
49062
49045
|
/* DoNotSpecialize */
|
|
49063
49046
|
).type;
|
|
49064
|
-
if ((0,
|
|
49047
|
+
if ((0, types_2.isInstantiableClass)(callType) && types_2.ClassType.isBuiltIn(callType, "type")) {
|
|
49065
49048
|
const classTypeResult = evaluator.getTypeOfExpression(testExpression.rightExpression);
|
|
49066
49049
|
const classType = evaluator.makeTopLevelTypeVarsConcrete(classTypeResult.type);
|
|
49067
|
-
if ((0,
|
|
49050
|
+
if ((0, types_2.isInstantiableClass)(classType)) {
|
|
49068
49051
|
return (type) => {
|
|
49069
49052
|
return {
|
|
49070
49053
|
type: narrowTypeForTypeIs(evaluator, type, classType, adjIsPositiveTest),
|
|
@@ -49080,7 +49063,7 @@ var require_typeGuards = __commonJS({
|
|
|
49080
49063
|
if (ParseTreeUtils.isMatchingExpression(reference, testExpression.leftExpression)) {
|
|
49081
49064
|
const rightTypeResult = evaluator.getTypeOfExpression(testExpression.rightExpression);
|
|
49082
49065
|
const rightType = rightTypeResult.type;
|
|
49083
|
-
if ((0,
|
|
49066
|
+
if ((0, types_2.isClassInstance)(rightType) && (types_2.ClassType.isEnumClass(rightType) || types_2.ClassType.isBuiltIn(rightType, "bool")) && rightType.literalValue !== void 0) {
|
|
49084
49067
|
return (type) => {
|
|
49085
49068
|
return {
|
|
49086
49069
|
type: narrowTypeForLiteralComparison(
|
|
@@ -49099,10 +49082,10 @@ var require_typeGuards = __commonJS({
|
|
|
49099
49082
|
if (testExpression.leftExpression.nodeType === 24 && testExpression.leftExpression.items.length === 1 && !testExpression.leftExpression.trailingComma && testExpression.leftExpression.items[0].argumentCategory === 0 && ParseTreeUtils.isMatchingExpression(reference, testExpression.leftExpression.baseExpression)) {
|
|
49100
49083
|
const indexTypeResult = evaluator.getTypeOfExpression(testExpression.leftExpression.items[0].valueExpression);
|
|
49101
49084
|
const indexType = indexTypeResult.type;
|
|
49102
|
-
if ((0,
|
|
49103
|
-
if (
|
|
49085
|
+
if ((0, types_2.isClassInstance)(indexType) && (0, typeUtils_1.isLiteralType)(indexType)) {
|
|
49086
|
+
if (types_2.ClassType.isBuiltIn(indexType, "str")) {
|
|
49104
49087
|
const rightType = evaluator.getTypeOfExpression(testExpression.rightExpression).type;
|
|
49105
|
-
if ((0,
|
|
49088
|
+
if ((0, types_2.isClassInstance)(rightType) && rightType.literalValue !== void 0) {
|
|
49106
49089
|
return (type) => {
|
|
49107
49090
|
return {
|
|
49108
49091
|
type: narrowTypeForDiscriminatedDictEntryComparison(evaluator, type, indexType, rightType, adjIsPositiveTest),
|
|
@@ -49110,6 +49093,25 @@ var require_typeGuards = __commonJS({
|
|
|
49110
49093
|
};
|
|
49111
49094
|
};
|
|
49112
49095
|
}
|
|
49096
|
+
} else if (types_2.ClassType.isBuiltIn(indexType, "int")) {
|
|
49097
|
+
const rightTypeResult = evaluator.getTypeOfExpression(testExpression.rightExpression);
|
|
49098
|
+
const rightType = rightTypeResult.type;
|
|
49099
|
+
if ((0, types_2.isClassInstance)(rightType) && rightType.literalValue !== void 0) {
|
|
49100
|
+
let canNarrow = false;
|
|
49101
|
+
if (types_2.ClassType.isBuiltIn(rightType, "bool")) {
|
|
49102
|
+
canNarrow = true;
|
|
49103
|
+
} else if (rightType.literalValue instanceof types_1.EnumLiteral) {
|
|
49104
|
+
canNarrow = true;
|
|
49105
|
+
}
|
|
49106
|
+
if (canNarrow) {
|
|
49107
|
+
return (type) => {
|
|
49108
|
+
return {
|
|
49109
|
+
type: narrowTypeForDiscriminatedTupleComparison(evaluator, type, indexType, rightType, adjIsPositiveTest),
|
|
49110
|
+
isIncomplete: !!rightTypeResult.isIncomplete
|
|
49111
|
+
};
|
|
49112
|
+
};
|
|
49113
|
+
}
|
|
49114
|
+
}
|
|
49113
49115
|
}
|
|
49114
49116
|
}
|
|
49115
49117
|
}
|
|
@@ -49119,7 +49121,7 @@ var require_typeGuards = __commonJS({
|
|
|
49119
49121
|
if (ParseTreeUtils.isMatchingExpression(reference, testExpression.leftExpression)) {
|
|
49120
49122
|
const rightTypeResult = evaluator.getTypeOfExpression(testExpression.rightExpression);
|
|
49121
49123
|
const rightType = rightTypeResult.type;
|
|
49122
|
-
if ((0,
|
|
49124
|
+
if ((0, types_2.isClassInstance)(rightType) && rightType.literalValue !== void 0) {
|
|
49123
49125
|
return (type) => {
|
|
49124
49126
|
return {
|
|
49125
49127
|
type: narrowTypeForLiteralComparison(
|
|
@@ -49138,10 +49140,10 @@ var require_typeGuards = __commonJS({
|
|
|
49138
49140
|
if (testExpression.leftExpression.nodeType === 24 && testExpression.leftExpression.items.length === 1 && !testExpression.leftExpression.trailingComma && testExpression.leftExpression.items[0].argumentCategory === 0 && ParseTreeUtils.isMatchingExpression(reference, testExpression.leftExpression.baseExpression)) {
|
|
49139
49141
|
const indexTypeResult = evaluator.getTypeOfExpression(testExpression.leftExpression.items[0].valueExpression);
|
|
49140
49142
|
const indexType = indexTypeResult.type;
|
|
49141
|
-
if ((0,
|
|
49142
|
-
if (
|
|
49143
|
+
if ((0, types_2.isClassInstance)(indexType) && (0, typeUtils_1.isLiteralType)(indexType)) {
|
|
49144
|
+
if (types_2.ClassType.isBuiltIn(indexType, "str")) {
|
|
49143
49145
|
const rightType = evaluator.getTypeOfExpression(testExpression.rightExpression).type;
|
|
49144
|
-
if ((0,
|
|
49146
|
+
if ((0, types_2.isClassInstance)(rightType) && rightType.literalValue !== void 0) {
|
|
49145
49147
|
return (type) => {
|
|
49146
49148
|
return {
|
|
49147
49149
|
type: narrowTypeForDiscriminatedDictEntryComparison(evaluator, type, indexType, rightType, adjIsPositiveTest2),
|
|
@@ -49149,10 +49151,10 @@ var require_typeGuards = __commonJS({
|
|
|
49149
49151
|
};
|
|
49150
49152
|
};
|
|
49151
49153
|
}
|
|
49152
|
-
} else if (
|
|
49154
|
+
} else if (types_2.ClassType.isBuiltIn(indexType, "int")) {
|
|
49153
49155
|
const rightTypeResult = evaluator.getTypeOfExpression(testExpression.rightExpression);
|
|
49154
49156
|
const rightType = rightTypeResult.type;
|
|
49155
|
-
if ((0,
|
|
49157
|
+
if ((0, types_2.isClassInstance)(rightType) && rightType.literalValue !== void 0) {
|
|
49156
49158
|
return (type) => {
|
|
49157
49159
|
return {
|
|
49158
49160
|
type: narrowTypeForDiscriminatedTupleComparison(evaluator, type, indexType, rightType, adjIsPositiveTest2),
|
|
@@ -49173,7 +49175,7 @@ var require_typeGuards = __commonJS({
|
|
|
49173
49175
|
/* DoNotSpecialize */
|
|
49174
49176
|
);
|
|
49175
49177
|
const callType = callTypeResult.type;
|
|
49176
|
-
if ((0,
|
|
49178
|
+
if ((0, types_2.isFunction)(callType) && callType.details.fullName === "builtins.len") {
|
|
49177
49179
|
const tupleLength = testExpression.rightExpression.value;
|
|
49178
49180
|
if (typeof tupleLength === "number") {
|
|
49179
49181
|
return (type) => {
|
|
@@ -49190,7 +49192,7 @@ var require_typeGuards = __commonJS({
|
|
|
49190
49192
|
const rightTypeResult = evaluator.getTypeOfExpression(testExpression.rightExpression);
|
|
49191
49193
|
const rightType = rightTypeResult.type;
|
|
49192
49194
|
const memberName = testExpression.leftExpression.memberName;
|
|
49193
|
-
if ((0,
|
|
49195
|
+
if ((0, types_2.isClassInstance)(rightType) && rightType.literalValue !== void 0) {
|
|
49194
49196
|
return (type) => {
|
|
49195
49197
|
return {
|
|
49196
49198
|
type: narrowTypeForDiscriminatedLiteralFieldComparison(evaluator, type, memberName.value, rightType, adjIsPositiveTest),
|
|
@@ -49203,7 +49205,7 @@ var require_typeGuards = __commonJS({
|
|
|
49203
49205
|
const rightTypeResult = evaluator.getTypeOfExpression(testExpression.rightExpression);
|
|
49204
49206
|
const rightType = rightTypeResult.type;
|
|
49205
49207
|
const memberName = testExpression.leftExpression.memberName;
|
|
49206
|
-
if ((0,
|
|
49208
|
+
if ((0, types_2.isClassInstance)(rightType) && (types_2.ClassType.isEnumClass(rightType) || types_2.ClassType.isBuiltIn(rightType, "bool")) && rightType.literalValue !== void 0) {
|
|
49207
49209
|
return (type) => {
|
|
49208
49210
|
return {
|
|
49209
49211
|
type: narrowTypeForDiscriminatedLiteralFieldComparison(evaluator, type, memberName.value, rightType, adjIsPositiveTest),
|
|
@@ -49237,11 +49239,11 @@ var require_typeGuards = __commonJS({
|
|
|
49237
49239
|
if (ParseTreeUtils.isMatchingExpression(reference, testExpression.rightExpression)) {
|
|
49238
49240
|
const leftTypeResult = evaluator.getTypeOfExpression(testExpression.leftExpression);
|
|
49239
49241
|
const leftType = leftTypeResult.type;
|
|
49240
|
-
if ((0,
|
|
49242
|
+
if ((0, types_2.isClassInstance)(leftType) && types_2.ClassType.isBuiltIn(leftType, "str") && (0, typeUtils_1.isLiteralType)(leftType)) {
|
|
49241
49243
|
const adjIsPositiveTest = testExpression.operator === 41 ? isPositiveTest : !isPositiveTest;
|
|
49242
49244
|
return (type) => {
|
|
49243
49245
|
return {
|
|
49244
|
-
type: narrowTypeForTypedDictKey(evaluator, type,
|
|
49246
|
+
type: narrowTypeForTypedDictKey(evaluator, type, types_2.ClassType.cloneAsInstantiable(leftType), adjIsPositiveTest),
|
|
49245
49247
|
isIncomplete: !!leftTypeResult.isIncomplete
|
|
49246
49248
|
};
|
|
49247
49249
|
};
|
|
@@ -49260,7 +49262,7 @@ var require_typeGuards = __commonJS({
|
|
|
49260
49262
|
/* DoNotSpecialize */
|
|
49261
49263
|
);
|
|
49262
49264
|
const callType = callTypeResult.type;
|
|
49263
|
-
if ((0,
|
|
49265
|
+
if ((0, types_2.isFunction)(callType) && (callType.details.builtInName === "isinstance" || callType.details.builtInName === "issubclass")) {
|
|
49264
49266
|
const isInstanceCheck = callType.details.builtInName === "isinstance";
|
|
49265
49267
|
const arg1TypeResult = evaluator.getTypeOfExpression(
|
|
49266
49268
|
arg1Expr,
|
|
@@ -49282,7 +49284,7 @@ var require_typeGuards = __commonJS({
|
|
|
49282
49284
|
false,
|
|
49283
49285
|
testExpression
|
|
49284
49286
|
);
|
|
49285
|
-
if (!(0,
|
|
49287
|
+
if (!(0, types_2.isNever)(narrowedType)) {
|
|
49286
49288
|
return {
|
|
49287
49289
|
type: narrowedType,
|
|
49288
49290
|
isIncomplete
|
|
@@ -49322,7 +49324,7 @@ var require_typeGuards = __commonJS({
|
|
|
49322
49324
|
/* DoNotSpecialize */
|
|
49323
49325
|
);
|
|
49324
49326
|
const callType = callTypeResult.type;
|
|
49325
|
-
if ((0,
|
|
49327
|
+
if ((0, types_2.isFunction)(callType) && callType.details.builtInName === "callable") {
|
|
49326
49328
|
return (type) => {
|
|
49327
49329
|
let narrowedType = narrowTypeForCallable(
|
|
49328
49330
|
evaluator,
|
|
@@ -49332,7 +49334,7 @@ var require_typeGuards = __commonJS({
|
|
|
49332
49334
|
/* allowIntersections */
|
|
49333
49335
|
false
|
|
49334
49336
|
);
|
|
49335
|
-
if (isPositiveTest && (0,
|
|
49337
|
+
if (isPositiveTest && (0, types_2.isNever)(narrowedType)) {
|
|
49336
49338
|
narrowedType = narrowTypeForCallable(
|
|
49337
49339
|
evaluator,
|
|
49338
49340
|
type,
|
|
@@ -49355,7 +49357,7 @@ var require_typeGuards = __commonJS({
|
|
|
49355
49357
|
/* DoNotSpecialize */
|
|
49356
49358
|
);
|
|
49357
49359
|
const callType = callTypeResult.type;
|
|
49358
|
-
if ((0,
|
|
49360
|
+
if ((0, types_2.isInstantiableClass)(callType) && types_2.ClassType.isBuiltIn(callType, "bool")) {
|
|
49359
49361
|
return (type) => {
|
|
49360
49362
|
return {
|
|
49361
49363
|
type: narrowTypeForTruthiness(evaluator, type, isPositiveTest),
|
|
@@ -49370,7 +49372,7 @@ var require_typeGuards = __commonJS({
|
|
|
49370
49372
|
if (ParseTreeUtils.isMatchingExpression(reference, arg0Expr)) {
|
|
49371
49373
|
let isPossiblyTypeGuard = false;
|
|
49372
49374
|
const isFunctionReturnTypeGuard = (type) => {
|
|
49373
|
-
return type.details.declaredReturnType && (0,
|
|
49375
|
+
return type.details.declaredReturnType && (0, types_2.isClassInstance)(type.details.declaredReturnType) && types_2.ClassType.isBuiltIn(type.details.declaredReturnType, ["TypeGuard", "StrictTypeGuard"]);
|
|
49374
49376
|
};
|
|
49375
49377
|
const callTypeResult = evaluator.getTypeOfExpression(
|
|
49376
49378
|
testExpression.leftExpression,
|
|
@@ -49378,17 +49380,17 @@ var require_typeGuards = __commonJS({
|
|
|
49378
49380
|
/* DoNotSpecialize */
|
|
49379
49381
|
);
|
|
49380
49382
|
const callType = callTypeResult.type;
|
|
49381
|
-
if ((0,
|
|
49383
|
+
if ((0, types_2.isFunction)(callType) && isFunctionReturnTypeGuard(callType)) {
|
|
49382
49384
|
isPossiblyTypeGuard = true;
|
|
49383
|
-
} else if ((0,
|
|
49385
|
+
} else if ((0, types_2.isOverloadedFunction)(callType) && types_2.OverloadedFunctionType.getOverloads(callType).some((o) => isFunctionReturnTypeGuard(o))) {
|
|
49384
49386
|
isPossiblyTypeGuard = true;
|
|
49385
|
-
} else if ((0,
|
|
49387
|
+
} else if ((0, types_2.isClassInstance)(callType)) {
|
|
49386
49388
|
isPossiblyTypeGuard = true;
|
|
49387
49389
|
}
|
|
49388
49390
|
if (isPossiblyTypeGuard) {
|
|
49389
49391
|
const functionReturnTypeResult = evaluator.getTypeOfExpression(testExpression);
|
|
49390
49392
|
const functionReturnType = functionReturnTypeResult.type;
|
|
49391
|
-
if ((0,
|
|
49393
|
+
if ((0, types_2.isClassInstance)(functionReturnType) && types_2.ClassType.isBuiltIn(functionReturnType, "bool") && functionReturnType.typeGuardType) {
|
|
49392
49394
|
const isStrictTypeGuard = !!functionReturnType.isStrictTypeGuard;
|
|
49393
49395
|
const typeGuardType = functionReturnType.typeGuardType;
|
|
49394
49396
|
const isIncomplete = !!callTypeResult.isIncomplete || !!functionReturnTypeResult.isIncomplete;
|
|
@@ -49538,11 +49540,11 @@ var require_typeGuards = __commonJS({
|
|
|
49538
49540
|
}
|
|
49539
49541
|
const typeOfEntry = evaluator.makeTopLevelTypeVarsConcrete(tupleType.tupleTypeArguments[indexValue].type);
|
|
49540
49542
|
if (isPositiveTest) {
|
|
49541
|
-
if (!evaluator.assignType(typeOfEntry,
|
|
49543
|
+
if (!evaluator.assignType(typeOfEntry, types_2.NoneType.createInstance())) {
|
|
49542
49544
|
return void 0;
|
|
49543
49545
|
}
|
|
49544
49546
|
} else {
|
|
49545
|
-
if ((0,
|
|
49547
|
+
if ((0, types_2.isNoneInstance)(typeOfEntry)) {
|
|
49546
49548
|
return void 0;
|
|
49547
49549
|
}
|
|
49548
49550
|
}
|
|
@@ -49559,14 +49561,14 @@ var require_typeGuards = __commonJS({
|
|
|
49559
49561
|
/* conditionFilter */
|
|
49560
49562
|
void 0,
|
|
49561
49563
|
(subtype, unexpandedSubtype) => {
|
|
49562
|
-
if ((0,
|
|
49564
|
+
if ((0, types_2.isAnyOrUnknown)(subtype)) {
|
|
49563
49565
|
return subtype;
|
|
49564
49566
|
}
|
|
49565
|
-
const adjustedSubtype = (0,
|
|
49566
|
-
if ((0,
|
|
49567
|
-
return isPositiveTest ? (0, typeUtils_1.addConditionToType)(
|
|
49567
|
+
const adjustedSubtype = (0, types_2.isTypeVar)(unexpandedSubtype) && unexpandedSubtype.details.constraints.length === 0 ? unexpandedSubtype : subtype;
|
|
49568
|
+
if ((0, types_2.isClassInstance)(subtype) && types_2.ClassType.isBuiltIn(subtype, "object")) {
|
|
49569
|
+
return isPositiveTest ? (0, typeUtils_1.addConditionToType)(types_2.NoneType.createInstance(), subtype.condition) : adjustedSubtype;
|
|
49568
49570
|
}
|
|
49569
|
-
if ((0,
|
|
49571
|
+
if ((0, types_2.isNoneInstance)(subtype) === isPositiveTest) {
|
|
49570
49572
|
return subtype;
|
|
49571
49573
|
}
|
|
49572
49574
|
return void 0;
|
|
@@ -49582,14 +49584,14 @@ var require_typeGuards = __commonJS({
|
|
|
49582
49584
|
/* conditionFilter */
|
|
49583
49585
|
void 0,
|
|
49584
49586
|
(subtype, unexpandedSubtype) => {
|
|
49585
|
-
if ((0,
|
|
49587
|
+
if ((0, types_2.isAnyOrUnknown)(subtype)) {
|
|
49586
49588
|
return subtype;
|
|
49587
49589
|
}
|
|
49588
|
-
const adjustedSubtype = (0,
|
|
49589
|
-
if ((0,
|
|
49590
|
-
return isPositiveTest ? (0, typeUtils_1.addConditionToType)(
|
|
49590
|
+
const adjustedSubtype = (0, types_2.isTypeVar)(unexpandedSubtype) && unexpandedSubtype.details.constraints.length === 0 ? unexpandedSubtype : subtype;
|
|
49591
|
+
if ((0, types_2.isClassInstance)(subtype) && types_2.ClassType.isBuiltIn(subtype, "object")) {
|
|
49592
|
+
return isPositiveTest ? (0, typeUtils_1.addConditionToType)(types_2.NoneType.createInstance(), subtype.condition) : adjustedSubtype;
|
|
49591
49593
|
}
|
|
49592
|
-
const isEllipsis = (0,
|
|
49594
|
+
const isEllipsis = (0, types_2.isClassInstance)(subtype) && types_2.ClassType.isBuiltIn(subtype, "ellipsis");
|
|
49593
49595
|
if (isEllipsis === isPositiveTest) {
|
|
49594
49596
|
return subtype;
|
|
49595
49597
|
}
|
|
@@ -49602,11 +49604,11 @@ var require_typeGuards = __commonJS({
|
|
|
49602
49604
|
const classTypeList = [];
|
|
49603
49605
|
const addClassTypesToList = (types) => {
|
|
49604
49606
|
types.forEach((subtype) => {
|
|
49605
|
-
if ((0,
|
|
49607
|
+
if ((0, types_2.isInstantiableClass)(subtype) || (0, types_2.isTypeVar)(subtype) && types_2.TypeBase.isInstantiable(subtype)) {
|
|
49606
49608
|
classTypeList.push(subtype);
|
|
49607
|
-
} else if ((0,
|
|
49609
|
+
} else if ((0, types_2.isNoneTypeClass)(subtype)) {
|
|
49608
49610
|
classTypeList.push(subtype);
|
|
49609
|
-
} else if ((0,
|
|
49611
|
+
} else if ((0, types_2.isFunction)(subtype) && subtype.details.parameters.length === 2 && subtype.details.parameters[0].category === 1 && subtype.details.parameters[1].category === 2) {
|
|
49610
49612
|
classTypeList.push(subtype);
|
|
49611
49613
|
} else {
|
|
49612
49614
|
foundNonClassType = true;
|
|
@@ -49614,10 +49616,10 @@ var require_typeGuards = __commonJS({
|
|
|
49614
49616
|
});
|
|
49615
49617
|
};
|
|
49616
49618
|
const addClassTypesRecursive = (subtype, recursionCount = 0) => {
|
|
49617
|
-
if (recursionCount >
|
|
49619
|
+
if (recursionCount > types_2.maxTypeRecursionCount) {
|
|
49618
49620
|
return;
|
|
49619
49621
|
}
|
|
49620
|
-
if ((0,
|
|
49622
|
+
if ((0, types_2.isClass)(subtype) && types_2.TypeBase.isInstance(subtype) && (0, typeUtils_1.isTupleClass)(subtype)) {
|
|
49621
49623
|
if (subtype.tupleTypeArguments) {
|
|
49622
49624
|
subtype.tupleTypeArguments.forEach((tupleEntry) => {
|
|
49623
49625
|
addClassTypesRecursive(tupleEntry.type, recursionCount + 1);
|
|
@@ -49636,29 +49638,29 @@ var require_typeGuards = __commonJS({
|
|
|
49636
49638
|
if (concreteFilterType.includeSubclasses) {
|
|
49637
49639
|
return false;
|
|
49638
49640
|
}
|
|
49639
|
-
if ((0,
|
|
49641
|
+
if ((0, types_2.isTypeVar)(filterType)) {
|
|
49640
49642
|
return false;
|
|
49641
49643
|
}
|
|
49642
|
-
if (
|
|
49644
|
+
if (types_2.ClassType.isDerivedFrom(varType, concreteFilterType)) {
|
|
49643
49645
|
return true;
|
|
49644
49646
|
}
|
|
49645
49647
|
if (isInstanceCheck) {
|
|
49646
|
-
if (
|
|
49648
|
+
if (types_2.ClassType.isProtocolClass(concreteFilterType) && evaluator.assignType(concreteFilterType, varType)) {
|
|
49647
49649
|
return true;
|
|
49648
49650
|
}
|
|
49649
49651
|
}
|
|
49650
|
-
if (
|
|
49652
|
+
if (types_2.ClassType.isBuiltIn(concreteFilterType, "dict") && types_2.ClassType.isTypedDictClass(varType)) {
|
|
49651
49653
|
return true;
|
|
49652
49654
|
}
|
|
49653
49655
|
return false;
|
|
49654
49656
|
}
|
|
49655
49657
|
exports.isIsinstanceFilterSuperclass = isIsinstanceFilterSuperclass;
|
|
49656
49658
|
function isIsinstanceFilterSubclass(evaluator, varType, filterType, concreteFilterType, isInstanceCheck) {
|
|
49657
|
-
if (
|
|
49659
|
+
if (types_2.ClassType.isDerivedFrom(concreteFilterType, varType)) {
|
|
49658
49660
|
return true;
|
|
49659
49661
|
}
|
|
49660
49662
|
if (isInstanceCheck) {
|
|
49661
|
-
if (
|
|
49663
|
+
if (types_2.ClassType.isProtocolClass(varType) && evaluator.assignType(varType, concreteFilterType)) {
|
|
49662
49664
|
return true;
|
|
49663
49665
|
}
|
|
49664
49666
|
}
|
|
@@ -49675,13 +49677,13 @@ var require_typeGuards = __commonJS({
|
|
|
49675
49677
|
let isClassRelationshipIndeterminate = false;
|
|
49676
49678
|
for (const filterType of classTypeList) {
|
|
49677
49679
|
const concreteFilterType = evaluator.makeTopLevelTypeVarsConcrete(filterType);
|
|
49678
|
-
if ((0,
|
|
49680
|
+
if ((0, types_2.isInstantiableClass)(concreteFilterType)) {
|
|
49679
49681
|
const filterIsSuperclass = isIsinstanceFilterSuperclass(evaluator, varType, filterType, concreteFilterType, isInstanceCheck);
|
|
49680
49682
|
const filterIsSubclass = isIsinstanceFilterSubclass(evaluator, varType, filterType, concreteFilterType, isInstanceCheck);
|
|
49681
49683
|
if (filterIsSuperclass) {
|
|
49682
49684
|
foundSuperclass = true;
|
|
49683
49685
|
}
|
|
49684
|
-
if (filterIsSubclass && filterIsSuperclass && !
|
|
49686
|
+
if (filterIsSubclass && filterIsSuperclass && !types_2.ClassType.isSameGenericClass(varType, concreteFilterType)) {
|
|
49685
49687
|
isClassRelationshipIndeterminate = true;
|
|
49686
49688
|
}
|
|
49687
49689
|
if (isPositiveTest) {
|
|
@@ -49689,10 +49691,10 @@ var require_typeGuards = __commonJS({
|
|
|
49689
49691
|
filteredTypes.push((0, typeUtils_1.addConditionToType)(varType, constraints));
|
|
49690
49692
|
} else if (filterIsSubclass) {
|
|
49691
49693
|
let specializedFilterType = filterType;
|
|
49692
|
-
if ((0,
|
|
49693
|
-
if (
|
|
49694
|
+
if ((0, types_2.isClass)(filterType)) {
|
|
49695
|
+
if (types_2.ClassType.isSpecialBuiltIn(filterType) || filterType.details.typeParameters.length > 0) {
|
|
49694
49696
|
const typeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(filterType));
|
|
49695
|
-
const unspecializedFilterType =
|
|
49697
|
+
const unspecializedFilterType = types_2.ClassType.cloneForSpecialization(
|
|
49696
49698
|
filterType,
|
|
49697
49699
|
/* typeArguments */
|
|
49698
49700
|
void 0,
|
|
@@ -49715,7 +49717,7 @@ var require_typeGuards = __commonJS({
|
|
|
49715
49717
|
} else if (allowIntersections) {
|
|
49716
49718
|
const className = `<subclass of ${varType.details.name} and ${concreteFilterType.details.name}>`;
|
|
49717
49719
|
const fileInfo = (0, analyzerNodeInfo_1.getFileInfo)(errorNode);
|
|
49718
|
-
let newClassType =
|
|
49720
|
+
let newClassType = types_2.ClassType.createInstantiable(
|
|
49719
49721
|
className,
|
|
49720
49722
|
ParseTreeUtils.getClassFullName(errorNode, fileInfo.moduleName, className),
|
|
49721
49723
|
fileInfo.moduleName,
|
|
@@ -49727,28 +49729,28 @@ var require_typeGuards = __commonJS({
|
|
|
49727
49729
|
varType.details.effectiveMetaclass,
|
|
49728
49730
|
varType.details.docString
|
|
49729
49731
|
);
|
|
49730
|
-
newClassType.details.baseClasses = [
|
|
49732
|
+
newClassType.details.baseClasses = [types_2.ClassType.cloneAsInstantiable(varType), concreteFilterType];
|
|
49731
49733
|
(0, typeUtils_1.computeMroLinearization)(newClassType);
|
|
49732
49734
|
newClassType = (0, typeUtils_1.addConditionToType)(newClassType, concreteFilterType.condition);
|
|
49733
|
-
if ((0,
|
|
49735
|
+
if ((0, types_2.isTypeVar)(unexpandedType) && !unexpandedType.details.isParamSpec && unexpandedType.details.constraints.length === 0) {
|
|
49734
49736
|
newClassType = (0, typeUtils_1.addConditionToType)(newClassType, [
|
|
49735
49737
|
{
|
|
49736
|
-
typeVarName:
|
|
49738
|
+
typeVarName: types_2.TypeVarType.getNameWithScope(unexpandedType),
|
|
49737
49739
|
constraintIndex: 0,
|
|
49738
49740
|
isConstrainedTypeVar: false
|
|
49739
49741
|
}
|
|
49740
49742
|
]);
|
|
49741
49743
|
}
|
|
49742
|
-
let newClassInstanceType =
|
|
49744
|
+
let newClassInstanceType = types_2.ClassType.cloneAsInstance(newClassType);
|
|
49743
49745
|
if (varType.condition) {
|
|
49744
49746
|
newClassInstanceType = (0, typeUtils_1.addConditionToType)(newClassInstanceType, varType.condition);
|
|
49745
49747
|
}
|
|
49746
|
-
filteredTypes.push(isInstanceCheck ? newClassInstanceType :
|
|
49748
|
+
filteredTypes.push(isInstanceCheck ? newClassInstanceType : types_2.ClassType.cloneAsInstantiable(newClassInstanceType));
|
|
49747
49749
|
}
|
|
49748
49750
|
}
|
|
49749
|
-
} else if ((0,
|
|
49750
|
-
if (isInstanceCheck &&
|
|
49751
|
-
if ((0,
|
|
49751
|
+
} else if ((0, types_2.isTypeVar)(filterType) && types_2.TypeBase.isInstantiable(filterType)) {
|
|
49752
|
+
if (isInstanceCheck && types_2.TypeBase.isInstance(unexpandedType)) {
|
|
49753
|
+
if ((0, types_2.isTypeVar)(unexpandedType) && (0, types_2.isTypeSame)((0, typeUtils_1.convertToInstance)(filterType), unexpandedType)) {
|
|
49752
49754
|
if (isPositiveTest) {
|
|
49753
49755
|
filteredTypes.push(unexpandedType);
|
|
49754
49756
|
}
|
|
@@ -49760,8 +49762,8 @@ var require_typeGuards = __commonJS({
|
|
|
49760
49762
|
isClassRelationshipIndeterminate = true;
|
|
49761
49763
|
}
|
|
49762
49764
|
}
|
|
49763
|
-
} else if (!isInstanceCheck &&
|
|
49764
|
-
if ((0,
|
|
49765
|
+
} else if (!isInstanceCheck && types_2.TypeBase.isInstantiable(unexpandedType)) {
|
|
49766
|
+
if ((0, types_2.isTypeVar)(unexpandedType) && (0, types_2.isTypeSame)(filterType, unexpandedType)) {
|
|
49765
49767
|
if (isPositiveTest) {
|
|
49766
49768
|
filteredTypes.push(unexpandedType);
|
|
49767
49769
|
}
|
|
@@ -49774,11 +49776,11 @@ var require_typeGuards = __commonJS({
|
|
|
49774
49776
|
}
|
|
49775
49777
|
}
|
|
49776
49778
|
}
|
|
49777
|
-
} else if ((0,
|
|
49779
|
+
} else if ((0, types_2.isFunction)(filterType)) {
|
|
49778
49780
|
if (isInstanceCheck) {
|
|
49779
49781
|
let isCallable = false;
|
|
49780
|
-
if ((0,
|
|
49781
|
-
if (
|
|
49782
|
+
if ((0, types_2.isClass)(varType)) {
|
|
49783
|
+
if (types_2.TypeBase.isInstantiable(unexpandedType)) {
|
|
49782
49784
|
isCallable = true;
|
|
49783
49785
|
} else {
|
|
49784
49786
|
isCallable = !!(0, typeUtils_1.lookUpClassMember)(varType, "__call__");
|
|
@@ -49800,7 +49802,7 @@ var require_typeGuards = __commonJS({
|
|
|
49800
49802
|
}
|
|
49801
49803
|
}
|
|
49802
49804
|
if (!isInstanceCheck) {
|
|
49803
|
-
return filteredTypes.map((t) => (0,
|
|
49805
|
+
return filteredTypes.map((t) => (0, types_2.isInstantiableClass)(t) ? (0, typeUtils_1.convertToInstantiable)((0, typeUtils_1.convertToInstance)(t)) : t);
|
|
49804
49806
|
}
|
|
49805
49807
|
return filteredTypes.map((t) => (0, typeUtils_1.convertToInstance)(t));
|
|
49806
49808
|
};
|
|
@@ -49810,7 +49812,7 @@ var require_typeGuards = __commonJS({
|
|
|
49810
49812
|
for (const filterType of classTypeList) {
|
|
49811
49813
|
const concreteFilterType = evaluator.makeTopLevelTypeVarsConcrete(filterType);
|
|
49812
49814
|
if (evaluator.assignType(varType, (0, typeUtils_1.convertToInstance)(concreteFilterType))) {
|
|
49813
|
-
if ((0,
|
|
49815
|
+
if ((0, types_2.isFunction)(filterType)) {
|
|
49814
49816
|
filteredTypes.push(unexpandedType);
|
|
49815
49817
|
} else {
|
|
49816
49818
|
filteredTypes.push((0, typeUtils_1.convertToInstance)(filterType));
|
|
@@ -49819,7 +49821,7 @@ var require_typeGuards = __commonJS({
|
|
|
49819
49821
|
}
|
|
49820
49822
|
} else if (!classTypeList.some((filterType) => {
|
|
49821
49823
|
const concreteFilterType = evaluator.makeTopLevelTypeVarsConcrete(filterType);
|
|
49822
|
-
if ((0,
|
|
49824
|
+
if ((0, types_2.isClass)(concreteFilterType) && !types_2.ClassType.isProtocolClass(concreteFilterType)) {
|
|
49823
49825
|
return false;
|
|
49824
49826
|
}
|
|
49825
49827
|
return evaluator.assignType(varType, (0, typeUtils_1.convertToInstance)(concreteFilterType));
|
|
@@ -49836,23 +49838,23 @@ var require_typeGuards = __commonJS({
|
|
|
49836
49838
|
void 0,
|
|
49837
49839
|
(subtype, unexpandedSubtype) => {
|
|
49838
49840
|
const negativeFallback = (0, typeUtils_1.getTypeCondition)(subtype) ? subtype : unexpandedSubtype;
|
|
49839
|
-
const isSubtypeTypeObject = (0,
|
|
49840
|
-
if (isPositiveTest && (0,
|
|
49841
|
+
const isSubtypeTypeObject = (0, types_2.isClassInstance)(subtype) && types_2.ClassType.isBuiltIn(subtype, "type");
|
|
49842
|
+
if (isPositiveTest && (0, types_2.isAnyOrUnknown)(subtype)) {
|
|
49841
49843
|
if (isInstanceCheck) {
|
|
49842
|
-
anyOrUnknownSubstitutions.push((0,
|
|
49844
|
+
anyOrUnknownSubstitutions.push((0, types_2.combineTypes)(classTypeList.map((classType) => (0, typeUtils_1.convertToInstance)(classType))));
|
|
49843
49845
|
} else {
|
|
49844
|
-
anyOrUnknownSubstitutions.push((0,
|
|
49846
|
+
anyOrUnknownSubstitutions.push((0, types_2.combineTypes)(classTypeList.map((classType) => (0, typeUtils_1.convertToInstantiable)((0, typeUtils_1.convertToInstance)(classType)))));
|
|
49845
49847
|
}
|
|
49846
49848
|
anyOrUnknown.push(subtype);
|
|
49847
49849
|
return void 0;
|
|
49848
49850
|
}
|
|
49849
49851
|
if (isInstanceCheck) {
|
|
49850
|
-
if ((0,
|
|
49852
|
+
if ((0, types_2.isNoneInstance)(subtype)) {
|
|
49851
49853
|
const containsNoneType = classTypeList.some((t) => {
|
|
49852
|
-
if ((0,
|
|
49854
|
+
if ((0, types_2.isNoneTypeClass)(t)) {
|
|
49853
49855
|
return true;
|
|
49854
49856
|
}
|
|
49855
|
-
return (0,
|
|
49857
|
+
return (0, types_2.isInstantiableClass)(t) && types_2.ClassType.isBuiltIn(t, "NoneType");
|
|
49856
49858
|
});
|
|
49857
49859
|
if (isPositiveTest) {
|
|
49858
49860
|
return containsNoneType ? subtype : void 0;
|
|
@@ -49860,25 +49862,25 @@ var require_typeGuards = __commonJS({
|
|
|
49860
49862
|
return containsNoneType ? void 0 : subtype;
|
|
49861
49863
|
}
|
|
49862
49864
|
}
|
|
49863
|
-
if ((0,
|
|
49865
|
+
if ((0, types_2.isModule)(subtype) || (0, types_2.isClassInstance)(subtype) && types_2.ClassType.isBuiltIn(subtype, "ModuleType")) {
|
|
49864
49866
|
if (isPositiveTest) {
|
|
49865
49867
|
const filteredTypes = classTypeList.filter((classType) => {
|
|
49866
49868
|
const concreteClassType = evaluator.makeTopLevelTypeVarsConcrete(classType);
|
|
49867
|
-
return (0,
|
|
49869
|
+
return (0, types_2.isInstantiableClass)(concreteClassType) && types_2.ClassType.isProtocolClass(concreteClassType);
|
|
49868
49870
|
});
|
|
49869
49871
|
if (filteredTypes.length > 0) {
|
|
49870
|
-
return (0, typeUtils_1.convertToInstance)((0,
|
|
49872
|
+
return (0, typeUtils_1.convertToInstance)((0, types_2.combineTypes)(filteredTypes));
|
|
49871
49873
|
}
|
|
49872
49874
|
}
|
|
49873
49875
|
}
|
|
49874
|
-
if ((0,
|
|
49875
|
-
return (0,
|
|
49876
|
+
if ((0, types_2.isClassInstance)(subtype) && !isSubtypeTypeObject) {
|
|
49877
|
+
return (0, types_2.combineTypes)(filterClassType(types_2.ClassType.cloneAsInstantiable(subtype), (0, typeUtils_1.convertToInstance)(unexpandedSubtype), (0, typeUtils_1.getTypeCondition)(subtype), negativeFallback));
|
|
49876
49878
|
}
|
|
49877
|
-
if (((0,
|
|
49878
|
-
return (0,
|
|
49879
|
+
if (((0, types_2.isFunction)(subtype) || (0, types_2.isOverloadedFunction)(subtype)) && isInstanceCheck) {
|
|
49880
|
+
return (0, types_2.combineTypes)(filterFunctionType(subtype, (0, typeUtils_1.convertToInstance)(unexpandedSubtype)));
|
|
49879
49881
|
}
|
|
49880
|
-
if ((0,
|
|
49881
|
-
const includesTypeType = classTypeList.some((classType) => (0,
|
|
49882
|
+
if ((0, types_2.isInstantiableClass)(subtype) || isSubtypeTypeObject) {
|
|
49883
|
+
const includesTypeType = classTypeList.some((classType) => (0, types_2.isInstantiableClass)(classType) && types_2.ClassType.isBuiltIn(classType, "type"));
|
|
49882
49884
|
if (isPositiveTest) {
|
|
49883
49885
|
return includesTypeType ? negativeFallback : void 0;
|
|
49884
49886
|
} else {
|
|
@@ -49886,31 +49888,31 @@ var require_typeGuards = __commonJS({
|
|
|
49886
49888
|
}
|
|
49887
49889
|
}
|
|
49888
49890
|
} else {
|
|
49889
|
-
if ((0,
|
|
49890
|
-
return (0,
|
|
49891
|
+
if ((0, types_2.isInstantiableClass)(subtype)) {
|
|
49892
|
+
return (0, types_2.combineTypes)(filterClassType(subtype, unexpandedSubtype, (0, typeUtils_1.getTypeCondition)(subtype), negativeFallback));
|
|
49891
49893
|
}
|
|
49892
49894
|
if (isSubtypeTypeObject) {
|
|
49893
49895
|
const objectType = evaluator.getBuiltInObject(errorNode, "object");
|
|
49894
|
-
if (objectType && (0,
|
|
49895
|
-
return (0,
|
|
49896
|
+
if (objectType && (0, types_2.isClassInstance)(objectType)) {
|
|
49897
|
+
return (0, types_2.combineTypes)(filterClassType(types_2.ClassType.cloneAsInstantiable(objectType), (0, typeUtils_1.convertToInstantiable)(unexpandedSubtype), (0, typeUtils_1.getTypeCondition)(subtype), negativeFallback));
|
|
49896
49898
|
}
|
|
49897
49899
|
}
|
|
49898
49900
|
}
|
|
49899
49901
|
return isPositiveTest ? void 0 : negativeFallback;
|
|
49900
49902
|
}
|
|
49901
49903
|
);
|
|
49902
|
-
if ((0,
|
|
49903
|
-
return (0,
|
|
49904
|
+
if ((0, types_2.isNever)(filteredType) && anyOrUnknownSubstitutions.length > 0) {
|
|
49905
|
+
return (0, types_2.combineTypes)(anyOrUnknownSubstitutions);
|
|
49904
49906
|
}
|
|
49905
|
-
if ((0,
|
|
49906
|
-
return (0,
|
|
49907
|
+
if ((0, types_2.isNever)(filteredType) && anyOrUnknown.length > 0) {
|
|
49908
|
+
return (0, types_2.combineTypes)(anyOrUnknown);
|
|
49907
49909
|
}
|
|
49908
49910
|
return filteredType;
|
|
49909
49911
|
}
|
|
49910
49912
|
function narrowTypeForTupleLength(evaluator, referenceType, lengthValue, isPositiveTest) {
|
|
49911
49913
|
return (0, typeUtils_1.mapSubtypes)(referenceType, (subtype) => {
|
|
49912
49914
|
const concreteSubtype = evaluator.makeTopLevelTypeVarsConcrete(subtype);
|
|
49913
|
-
if (!(0,
|
|
49915
|
+
if (!(0, types_2.isClassInstance)(concreteSubtype) || !(0, typeUtils_1.isTupleClass)(concreteSubtype) || (0, typeUtils_1.isUnboundedTupleClass)(concreteSubtype) || !concreteSubtype.tupleTypeArguments) {
|
|
49914
49916
|
return subtype;
|
|
49915
49917
|
}
|
|
49916
49918
|
const tupleLengthMatches = concreteSubtype.tupleTypeArguments.length === lengthValue;
|
|
@@ -49925,15 +49927,15 @@ var require_typeGuards = __commonJS({
|
|
|
49925
49927
|
}
|
|
49926
49928
|
return narrowTypeForContainerElementType(evaluator, referenceType, evaluator.makeTopLevelTypeVarsConcrete(elementType));
|
|
49927
49929
|
}
|
|
49928
|
-
if (!(0,
|
|
49930
|
+
if (!(0, types_2.isClassInstance)(containerType) || !types_2.ClassType.isBuiltIn(containerType, "tuple") || !containerType.tupleTypeArguments) {
|
|
49929
49931
|
return referenceType;
|
|
49930
49932
|
}
|
|
49931
49933
|
const typesToEliminate = [];
|
|
49932
49934
|
containerType.tupleTypeArguments.forEach((tupleEntry) => {
|
|
49933
49935
|
if (!tupleEntry.isUnbounded) {
|
|
49934
|
-
if ((0,
|
|
49936
|
+
if ((0, types_2.isNoneInstance)(tupleEntry.type)) {
|
|
49935
49937
|
typesToEliminate.push(tupleEntry.type);
|
|
49936
|
-
} else if ((0,
|
|
49938
|
+
} else if ((0, types_2.isClassInstance)(tupleEntry.type) && (0, typeUtils_1.isLiteralType)(tupleEntry.type)) {
|
|
49937
49939
|
typesToEliminate.push(tupleEntry.type);
|
|
49938
49940
|
}
|
|
49939
49941
|
}
|
|
@@ -49943,13 +49945,13 @@ var require_typeGuards = __commonJS({
|
|
|
49943
49945
|
}
|
|
49944
49946
|
return (0, typeUtils_1.mapSubtypes)(referenceType, (referenceSubtype) => {
|
|
49945
49947
|
referenceSubtype = evaluator.makeTopLevelTypeVarsConcrete(referenceSubtype);
|
|
49946
|
-
if ((0,
|
|
49948
|
+
if ((0, types_2.isClassInstance)(referenceSubtype) && referenceSubtype.literalValue === void 0) {
|
|
49947
49949
|
const allLiteralTypes = enumerateLiteralsForType(evaluator, referenceSubtype);
|
|
49948
49950
|
if (allLiteralTypes && allLiteralTypes.length > 0) {
|
|
49949
|
-
return (0,
|
|
49951
|
+
return (0, types_2.combineTypes)(allLiteralTypes.filter((type) => !typesToEliminate.some((t) => (0, types_2.isTypeSame)(t, type))));
|
|
49950
49952
|
}
|
|
49951
49953
|
}
|
|
49952
|
-
if (typesToEliminate.some((t) => (0,
|
|
49954
|
+
if (typesToEliminate.some((t) => (0, types_2.isTypeSame)(t, referenceSubtype))) {
|
|
49953
49955
|
return void 0;
|
|
49954
49956
|
}
|
|
49955
49957
|
return referenceSubtype;
|
|
@@ -49957,7 +49959,7 @@ var require_typeGuards = __commonJS({
|
|
|
49957
49959
|
}
|
|
49958
49960
|
function getElementTypeForContainerNarrowing(containerType) {
|
|
49959
49961
|
const supportedContainers = ["list", "set", "frozenset", "deque", "tuple", "dict", "defaultdict", "OrderedDict"];
|
|
49960
|
-
if (!(0,
|
|
49962
|
+
if (!(0, types_2.isClassInstance)(containerType) || !types_2.ClassType.isBuiltIn(containerType, supportedContainers)) {
|
|
49961
49963
|
return void 0;
|
|
49962
49964
|
}
|
|
49963
49965
|
if (!containerType.typeArguments || containerType.typeArguments.length < 1) {
|
|
@@ -49965,7 +49967,7 @@ var require_typeGuards = __commonJS({
|
|
|
49965
49967
|
}
|
|
49966
49968
|
let elementType = containerType.typeArguments[0];
|
|
49967
49969
|
if ((0, typeUtils_1.isTupleClass)(containerType) && containerType.tupleTypeArguments) {
|
|
49968
|
-
elementType = (0,
|
|
49970
|
+
elementType = (0, types_2.combineTypes)(containerType.tupleTypeArguments.map((t) => t.type));
|
|
49969
49971
|
}
|
|
49970
49972
|
return elementType;
|
|
49971
49973
|
}
|
|
@@ -49975,11 +49977,11 @@ var require_typeGuards = __commonJS({
|
|
|
49975
49977
|
const elementTypeWithoutLiteral = evaluator.stripLiteralValue(elementType);
|
|
49976
49978
|
const narrowedSupertypes = (0, typeUtils_1.mapSubtypes)(referenceType, (referenceSubtype) => {
|
|
49977
49979
|
const concreteReferenceType = evaluator.makeTopLevelTypeVarsConcrete(referenceSubtype);
|
|
49978
|
-
if ((0,
|
|
49980
|
+
if ((0, types_2.isAnyOrUnknown)(concreteReferenceType)) {
|
|
49979
49981
|
canNarrow = false;
|
|
49980
49982
|
return referenceSubtype;
|
|
49981
49983
|
}
|
|
49982
|
-
if ((0,
|
|
49984
|
+
if ((0, types_2.isClassInstance)(concreteReferenceType) && types_2.ClassType.isBuiltIn(concreteReferenceType, "type")) {
|
|
49983
49985
|
canNarrow = false;
|
|
49984
49986
|
return referenceSubtype;
|
|
49985
49987
|
}
|
|
@@ -49988,7 +49990,7 @@ var require_typeGuards = __commonJS({
|
|
|
49988
49990
|
}
|
|
49989
49991
|
if (evaluator.assignType(elementTypeWithoutLiteral, concreteReferenceType)) {
|
|
49990
49992
|
return (0, typeUtils_1.mapSubtypes)(elementType, (elementSubtype) => {
|
|
49991
|
-
if ((0,
|
|
49993
|
+
if ((0, types_2.isClassInstance)(elementSubtype) && (0, types_2.isSameWithoutLiteralValue)(referenceSubtype, elementSubtype)) {
|
|
49992
49994
|
return elementSubtype;
|
|
49993
49995
|
}
|
|
49994
49996
|
return void 0;
|
|
@@ -49998,7 +50000,7 @@ var require_typeGuards = __commonJS({
|
|
|
49998
50000
|
});
|
|
49999
50001
|
const narrowedSubtypes = (0, typeUtils_1.mapSubtypes)(elementType, (elementSubtype) => {
|
|
50000
50002
|
const concreteElementType = evaluator.makeTopLevelTypeVarsConcrete(elementSubtype);
|
|
50001
|
-
if ((0,
|
|
50003
|
+
if ((0, types_2.isAnyOrUnknown)(concreteElementType)) {
|
|
50002
50004
|
canNarrow = false;
|
|
50003
50005
|
return referenceType;
|
|
50004
50006
|
}
|
|
@@ -50007,12 +50009,12 @@ var require_typeGuards = __commonJS({
|
|
|
50007
50009
|
}
|
|
50008
50010
|
return void 0;
|
|
50009
50011
|
});
|
|
50010
|
-
return canNarrow ? (0,
|
|
50012
|
+
return canNarrow ? (0, types_2.combineTypes)([narrowedSupertypes, narrowedSubtypes]) : referenceType;
|
|
50011
50013
|
}
|
|
50012
50014
|
exports.narrowTypeForContainerElementType = narrowTypeForContainerElementType;
|
|
50013
50015
|
function narrowTypeForTypedDictKey(evaluator, referenceType, literalKey, isPositiveTest) {
|
|
50014
50016
|
const narrowedType = (0, typeUtils_1.mapSubtypes)(referenceType, (subtype) => {
|
|
50015
|
-
if ((0,
|
|
50017
|
+
if ((0, types_2.isClassInstance)(subtype) && types_2.ClassType.isTypedDictClass(subtype)) {
|
|
50016
50018
|
const entries = (0, typedDicts_1.getTypedDictMembersForClass)(
|
|
50017
50019
|
evaluator,
|
|
50018
50020
|
subtype,
|
|
@@ -50022,7 +50024,7 @@ var require_typeGuards = __commonJS({
|
|
|
50022
50024
|
const tdEntry = entries.get(literalKey.literalValue);
|
|
50023
50025
|
if (isPositiveTest) {
|
|
50024
50026
|
if (!tdEntry) {
|
|
50025
|
-
return
|
|
50027
|
+
return types_2.ClassType.isFinal(subtype) ? void 0 : subtype;
|
|
50026
50028
|
}
|
|
50027
50029
|
if (tdEntry.isRequired || tdEntry.isProvided) {
|
|
50028
50030
|
return subtype;
|
|
@@ -50039,7 +50041,7 @@ var require_typeGuards = __commonJS({
|
|
|
50039
50041
|
isRequired: false,
|
|
50040
50042
|
isProvided: true
|
|
50041
50043
|
});
|
|
50042
|
-
return
|
|
50044
|
+
return types_2.ClassType.cloneAsInstance(types_2.ClassType.cloneForNarrowedTypedDictEntries(types_2.ClassType.cloneAsInstantiable(subtype), newNarrowedEntriesMap));
|
|
50043
50045
|
} else {
|
|
50044
50046
|
return tdEntry !== void 0 && (tdEntry.isRequired || tdEntry.isProvided) ? void 0 : subtype;
|
|
50045
50047
|
}
|
|
@@ -50051,7 +50053,7 @@ var require_typeGuards = __commonJS({
|
|
|
50051
50053
|
function narrowTypeForDiscriminatedDictEntryComparison(evaluator, referenceType, indexLiteralType, literalType, isPositiveTest) {
|
|
50052
50054
|
let canNarrow = true;
|
|
50053
50055
|
const narrowedType = (0, typeUtils_1.mapSubtypes)(referenceType, (subtype) => {
|
|
50054
|
-
if ((0,
|
|
50056
|
+
if ((0, types_2.isClassInstance)(subtype) && types_2.ClassType.isTypedDictClass(subtype)) {
|
|
50055
50057
|
const symbolMap = (0, typedDicts_1.getTypedDictMembersForClass)(evaluator, subtype);
|
|
50056
50058
|
const tdEntry = symbolMap.get(indexLiteralType.literalValue);
|
|
50057
50059
|
if (tdEntry && (0, typeUtils_1.isLiteralTypeOrUnion)(tdEntry.valueType)) {
|
|
@@ -50071,7 +50073,7 @@ var require_typeGuards = __commonJS({
|
|
|
50071
50073
|
let canNarrow = true;
|
|
50072
50074
|
const narrowedType = (0, typeUtils_1.mapSubtypes)(referenceType, (subtype) => {
|
|
50073
50075
|
var _a;
|
|
50074
|
-
if ((0,
|
|
50076
|
+
if ((0, types_2.isClassInstance)(subtype) && types_2.ClassType.isTupleClass(subtype) && !(0, typeUtils_1.isUnboundedTupleClass)(subtype) && typeof indexLiteralType.literalValue === "number") {
|
|
50075
50077
|
const indexValue = indexLiteralType.literalValue;
|
|
50076
50078
|
if (subtype.tupleTypeArguments && indexValue >= 0 && indexValue < subtype.tupleTypeArguments.length) {
|
|
50077
50079
|
const tupleEntryType = (_a = subtype.tupleTypeArguments[indexValue]) === null || _a === void 0 ? void 0 : _a.type;
|
|
@@ -50092,19 +50094,19 @@ var require_typeGuards = __commonJS({
|
|
|
50092
50094
|
function narrowTypeForDiscriminatedLiteralFieldComparison(evaluator, referenceType, memberName, literalType, isPositiveTest) {
|
|
50093
50095
|
const narrowedType = (0, typeUtils_1.mapSubtypes)(referenceType, (subtype) => {
|
|
50094
50096
|
let memberInfo;
|
|
50095
|
-
if ((0,
|
|
50097
|
+
if ((0, types_2.isClassInstance)(subtype)) {
|
|
50096
50098
|
memberInfo = (0, typeUtils_1.lookUpObjectMember)(subtype, memberName);
|
|
50097
|
-
} else if ((0,
|
|
50099
|
+
} else if ((0, types_2.isInstantiableClass)(subtype)) {
|
|
50098
50100
|
memberInfo = (0, typeUtils_1.lookUpClassMember)(subtype, memberName);
|
|
50099
50101
|
}
|
|
50100
50102
|
if (memberInfo && memberInfo.isTypeDeclared) {
|
|
50101
50103
|
let memberType = evaluator.getTypeOfMember(memberInfo);
|
|
50102
|
-
if ((0,
|
|
50104
|
+
if ((0, types_2.isClassInstance)(subtype) && (0, typeUtils_1.isProperty)(memberType)) {
|
|
50103
50105
|
const getterInfo = (0, typeUtils_1.lookUpObjectMember)(memberType, "fget");
|
|
50104
50106
|
if (getterInfo && getterInfo.isTypeDeclared) {
|
|
50105
50107
|
const getterType = evaluator.getTypeOfMember(getterInfo);
|
|
50106
|
-
if ((0,
|
|
50107
|
-
const getterReturnType =
|
|
50108
|
+
if ((0, types_2.isFunction)(getterType) && getterType.details.declaredReturnType) {
|
|
50109
|
+
const getterReturnType = types_2.FunctionType.getSpecializedReturnType(getterType);
|
|
50108
50110
|
if (getterReturnType) {
|
|
50109
50111
|
memberType = getterReturnType;
|
|
50110
50112
|
}
|
|
@@ -50126,9 +50128,9 @@ var require_typeGuards = __commonJS({
|
|
|
50126
50128
|
function narrowTypeForDiscriminatedFieldNoneComparison(evaluator, referenceType, memberName, isPositiveTest) {
|
|
50127
50129
|
return (0, typeUtils_1.mapSubtypes)(referenceType, (subtype) => {
|
|
50128
50130
|
let memberInfo;
|
|
50129
|
-
if ((0,
|
|
50131
|
+
if ((0, types_2.isClassInstance)(subtype)) {
|
|
50130
50132
|
memberInfo = (0, typeUtils_1.lookUpObjectMember)(subtype, memberName);
|
|
50131
|
-
} else if ((0,
|
|
50133
|
+
} else if ((0, types_2.isInstantiableClass)(subtype)) {
|
|
50132
50134
|
memberInfo = (0, typeUtils_1.lookUpClassMember)(subtype, memberName);
|
|
50133
50135
|
}
|
|
50134
50136
|
if (memberInfo && memberInfo.isTypeDeclared) {
|
|
@@ -50140,12 +50142,12 @@ var require_typeGuards = __commonJS({
|
|
|
50140
50142
|
if ((0, typeUtils_1.isProperty)(memberSubtype) || (0, typeUtils_1.isMaybeDescriptorInstance)(memberSubtype)) {
|
|
50141
50143
|
canNarrow = false;
|
|
50142
50144
|
}
|
|
50143
|
-
if ((0,
|
|
50145
|
+
if ((0, types_2.isAnyOrUnknown)(memberSubtype) || (0, types_2.isNoneInstance)(memberSubtype) || (0, types_2.isNever)(memberSubtype)) {
|
|
50144
50146
|
canNarrow = false;
|
|
50145
50147
|
}
|
|
50146
50148
|
});
|
|
50147
50149
|
} else {
|
|
50148
|
-
canNarrow = (0,
|
|
50150
|
+
canNarrow = (0, types_2.isNoneInstance)(memberType);
|
|
50149
50151
|
}
|
|
50150
50152
|
if (canNarrow) {
|
|
50151
50153
|
return void 0;
|
|
@@ -50160,26 +50162,26 @@ var require_typeGuards = __commonJS({
|
|
|
50160
50162
|
/* conditionFilter */
|
|
50161
50163
|
void 0,
|
|
50162
50164
|
(subtype, unexpandedSubtype) => {
|
|
50163
|
-
if ((0,
|
|
50164
|
-
const matches =
|
|
50165
|
+
if ((0, types_2.isClassInstance)(subtype)) {
|
|
50166
|
+
const matches = types_2.ClassType.isDerivedFrom(classType, types_2.ClassType.cloneAsInstantiable(subtype));
|
|
50165
50167
|
if (isPositiveTest) {
|
|
50166
50168
|
if (matches) {
|
|
50167
|
-
if (
|
|
50169
|
+
if (types_2.ClassType.isSameGenericClass(subtype, classType)) {
|
|
50168
50170
|
return subtype;
|
|
50169
50171
|
}
|
|
50170
|
-
return (0, typeUtils_1.addConditionToType)(
|
|
50172
|
+
return (0, typeUtils_1.addConditionToType)(types_2.ClassType.cloneAsInstance(classType), subtype.condition);
|
|
50171
50173
|
}
|
|
50172
50174
|
return void 0;
|
|
50173
50175
|
} else {
|
|
50174
|
-
if (matches &&
|
|
50176
|
+
if (matches && types_2.ClassType.isFinal(subtype)) {
|
|
50175
50177
|
return void 0;
|
|
50176
50178
|
}
|
|
50177
50179
|
return subtype;
|
|
50178
50180
|
}
|
|
50179
|
-
} else if ((0,
|
|
50181
|
+
} else if ((0, types_2.isNoneInstance)(subtype)) {
|
|
50180
50182
|
return isPositiveTest ? void 0 : subtype;
|
|
50181
|
-
} else if ((0,
|
|
50182
|
-
return isPositiveTest ?
|
|
50183
|
+
} else if ((0, types_2.isAnyOrUnknown)(subtype)) {
|
|
50184
|
+
return isPositiveTest ? types_2.ClassType.cloneAsInstance(classType) : subtype;
|
|
50183
50185
|
}
|
|
50184
50186
|
return unexpandedSubtype;
|
|
50185
50187
|
}
|
|
@@ -50188,9 +50190,9 @@ var require_typeGuards = __commonJS({
|
|
|
50188
50190
|
function narrowTypeForLiteralComparison(evaluator, referenceType, literalType, isPositiveTest, isIsOperator) {
|
|
50189
50191
|
return (0, typeUtils_1.mapSubtypes)(referenceType, (subtype) => {
|
|
50190
50192
|
subtype = evaluator.makeTopLevelTypeVarsConcrete(subtype);
|
|
50191
|
-
if ((0,
|
|
50193
|
+
if ((0, types_2.isClassInstance)(subtype) && types_2.ClassType.isSameGenericClass(literalType, subtype)) {
|
|
50192
50194
|
if (subtype.literalValue !== void 0) {
|
|
50193
|
-
const literalValueMatches =
|
|
50195
|
+
const literalValueMatches = types_2.ClassType.isLiteralValueSame(subtype, literalType);
|
|
50194
50196
|
if (literalValueMatches && !isPositiveTest || !literalValueMatches && isPositiveTest) {
|
|
50195
50197
|
return void 0;
|
|
50196
50198
|
}
|
|
@@ -50200,11 +50202,11 @@ var require_typeGuards = __commonJS({
|
|
|
50200
50202
|
} else {
|
|
50201
50203
|
const allLiteralTypes = enumerateLiteralsForType(evaluator, subtype);
|
|
50202
50204
|
if (allLiteralTypes && allLiteralTypes.length > 0) {
|
|
50203
|
-
return (0,
|
|
50205
|
+
return (0, types_2.combineTypes)(allLiteralTypes.filter((type) => !types_2.ClassType.isLiteralValueSame(type, literalType)));
|
|
50204
50206
|
}
|
|
50205
50207
|
}
|
|
50206
50208
|
} else if (isPositiveTest) {
|
|
50207
|
-
if (isIsOperator || (0,
|
|
50209
|
+
if (isIsOperator || (0, types_2.isNoneInstance)(subtype)) {
|
|
50208
50210
|
return void 0;
|
|
50209
50211
|
}
|
|
50210
50212
|
}
|
|
@@ -50212,27 +50214,27 @@ var require_typeGuards = __commonJS({
|
|
|
50212
50214
|
});
|
|
50213
50215
|
}
|
|
50214
50216
|
function enumerateLiteralsForType(evaluator, type) {
|
|
50215
|
-
if (
|
|
50217
|
+
if (types_2.ClassType.isBuiltIn(type, "bool")) {
|
|
50216
50218
|
return [
|
|
50217
|
-
|
|
50219
|
+
types_2.ClassType.cloneWithLiteral(
|
|
50218
50220
|
type,
|
|
50219
50221
|
/* value */
|
|
50220
50222
|
true
|
|
50221
50223
|
),
|
|
50222
|
-
|
|
50224
|
+
types_2.ClassType.cloneWithLiteral(
|
|
50223
50225
|
type,
|
|
50224
50226
|
/* value */
|
|
50225
50227
|
false
|
|
50226
50228
|
)
|
|
50227
50229
|
];
|
|
50228
50230
|
}
|
|
50229
|
-
if (
|
|
50231
|
+
if (types_2.ClassType.isEnumClass(type)) {
|
|
50230
50232
|
const enumList = [];
|
|
50231
50233
|
const fields = type.details.fields;
|
|
50232
50234
|
fields.forEach((symbol) => {
|
|
50233
50235
|
if (!symbol.isIgnoredForProtocolMatch()) {
|
|
50234
50236
|
const symbolType = evaluator.getEffectiveTypeOfSymbol(symbol);
|
|
50235
|
-
if ((0,
|
|
50237
|
+
if ((0, types_2.isClassInstance)(symbolType) && types_2.ClassType.isSameGenericClass(type, symbolType) && symbolType.literalValue !== void 0) {
|
|
50236
50238
|
enumList.push(symbolType);
|
|
50237
50239
|
}
|
|
50238
50240
|
}
|
|
@@ -50258,7 +50260,7 @@ var require_typeGuards = __commonJS({
|
|
|
50258
50260
|
return isPositiveTest ? void 0 : subtype;
|
|
50259
50261
|
}
|
|
50260
50262
|
case 7: {
|
|
50261
|
-
if (
|
|
50263
|
+
if (types_2.TypeBase.isInstantiable(subtype)) {
|
|
50262
50264
|
return isPositiveTest ? subtype : void 0;
|
|
50263
50265
|
}
|
|
50264
50266
|
const callMemberType = (0, typeUtils_1.lookUpClassMember)(subtype, "__call__");
|
|
@@ -50269,7 +50271,7 @@ var require_typeGuards = __commonJS({
|
|
|
50269
50271
|
if (allowIntersections) {
|
|
50270
50272
|
const className = `<callable subtype of ${subtype.details.name}>`;
|
|
50271
50273
|
const fileInfo = (0, analyzerNodeInfo_1.getFileInfo)(errorNode);
|
|
50272
|
-
let newClassType =
|
|
50274
|
+
let newClassType = types_2.ClassType.createInstantiable(
|
|
50273
50275
|
className,
|
|
50274
50276
|
ParseTreeUtils.getClassFullName(errorNode, fileInfo.moduleName, className),
|
|
50275
50277
|
fileInfo.moduleName,
|
|
@@ -50281,21 +50283,21 @@ var require_typeGuards = __commonJS({
|
|
|
50281
50283
|
subtype.details.effectiveMetaclass,
|
|
50282
50284
|
subtype.details.docString
|
|
50283
50285
|
);
|
|
50284
|
-
newClassType.details.baseClasses = [
|
|
50286
|
+
newClassType.details.baseClasses = [types_2.ClassType.cloneAsInstantiable(subtype)];
|
|
50285
50287
|
(0, typeUtils_1.computeMroLinearization)(newClassType);
|
|
50286
50288
|
newClassType = (0, typeUtils_1.addConditionToType)(newClassType, subtype.condition);
|
|
50287
|
-
const callMethod =
|
|
50289
|
+
const callMethod = types_2.FunctionType.createSynthesizedInstance("__call__");
|
|
50288
50290
|
const selfParam = {
|
|
50289
50291
|
category: 0,
|
|
50290
50292
|
name: "self",
|
|
50291
|
-
type:
|
|
50293
|
+
type: types_2.ClassType.cloneAsInstance(newClassType),
|
|
50292
50294
|
hasDeclaredType: true
|
|
50293
50295
|
};
|
|
50294
|
-
|
|
50295
|
-
|
|
50296
|
-
callMethod.details.declaredReturnType =
|
|
50296
|
+
types_2.FunctionType.addParameter(callMethod, selfParam);
|
|
50297
|
+
types_2.FunctionType.addDefaultParameters(callMethod);
|
|
50298
|
+
callMethod.details.declaredReturnType = types_2.UnknownType.create();
|
|
50297
50299
|
newClassType.details.fields.set("__call__", symbol_1.Symbol.createWithType(4, callMethod));
|
|
50298
|
-
return
|
|
50300
|
+
return types_2.ClassType.cloneAsInstance(newClassType);
|
|
50299
50301
|
}
|
|
50300
50302
|
return void 0;
|
|
50301
50303
|
} else {
|
|
@@ -50524,8 +50526,43 @@ var require_patternMatching = __commonJS({
|
|
|
50524
50526
|
return (0, types_1.combineTypes)(narrowedTypes);
|
|
50525
50527
|
}
|
|
50526
50528
|
function narrowTypeBasedOnMappingPattern(evaluator, type, pattern, isPositiveTest) {
|
|
50529
|
+
type = (0, typeUtils_1.transformPossibleRecursiveTypeAlias)(type);
|
|
50527
50530
|
if (!isPositiveTest) {
|
|
50528
|
-
|
|
50531
|
+
if (pattern.entries.length !== 1 || pattern.entries[0].nodeType !== 71) {
|
|
50532
|
+
return type;
|
|
50533
|
+
}
|
|
50534
|
+
const keyPattern = pattern.entries[0].keyPattern;
|
|
50535
|
+
const valuePattern = pattern.entries[0].valuePattern;
|
|
50536
|
+
if (keyPattern.nodeType !== 67 || valuePattern.nodeType !== 66 || !valuePattern.orPatterns.every(
|
|
50537
|
+
(orPattern) => orPattern.nodeType === 67
|
|
50538
|
+
/* PatternLiteral */
|
|
50539
|
+
)) {
|
|
50540
|
+
return type;
|
|
50541
|
+
}
|
|
50542
|
+
const keyType = evaluator.getTypeOfExpression(keyPattern.expression).type;
|
|
50543
|
+
if (!(0, types_1.isClassInstance)(keyType) || !types_1.ClassType.isBuiltIn(keyType, "str") || keyType.literalValue === void 0) {
|
|
50544
|
+
return type;
|
|
50545
|
+
}
|
|
50546
|
+
const keyValue = keyType.literalValue;
|
|
50547
|
+
const valueTypes = valuePattern.orPatterns.map((orPattern) => evaluator.getTypeOfExpression(orPattern.expression).type);
|
|
50548
|
+
return (0, typeUtils_1.mapSubtypes)(type, (subtype) => {
|
|
50549
|
+
if ((0, types_1.isClassInstance)(subtype) && types_1.ClassType.isTypedDictClass(subtype)) {
|
|
50550
|
+
const typedDictMembers = (0, typedDicts_1.getTypedDictMembersForClass)(
|
|
50551
|
+
evaluator,
|
|
50552
|
+
subtype,
|
|
50553
|
+
/* allowNarrowed */
|
|
50554
|
+
true
|
|
50555
|
+
);
|
|
50556
|
+
const member = typedDictMembers.get(keyValue);
|
|
50557
|
+
if (member && (member.isRequired || member.isProvided) && (0, types_1.isClassInstance)(member.valueType)) {
|
|
50558
|
+
const memberValueType = member.valueType;
|
|
50559
|
+
if (valueTypes.some((valueType) => (0, types_1.isClassInstance)(valueType) && types_1.ClassType.isSameGenericClass(valueType, memberValueType) && valueType.literalValue === memberValueType.literalValue)) {
|
|
50560
|
+
return void 0;
|
|
50561
|
+
}
|
|
50562
|
+
}
|
|
50563
|
+
}
|
|
50564
|
+
return subtype;
|
|
50565
|
+
});
|
|
50529
50566
|
}
|
|
50530
50567
|
let mappingInfo = getMappingPatternInfo(evaluator, type);
|
|
50531
50568
|
mappingInfo = mappingInfo.filter((mappingSubtypeInfo) => {
|
|
@@ -50840,7 +50877,7 @@ var require_patternMatching = __commonJS({
|
|
|
50840
50877
|
if (allEnumTypes) {
|
|
50841
50878
|
return (0, types_1.combineTypes)(allEnumTypes.filter((enumType) => !types_1.ClassType.isLiteralValueSame(valueSubtypeExpanded, enumType)));
|
|
50842
50879
|
}
|
|
50843
|
-
} else if ((0, types_1.isClassInstance)(subjectSubtypeExpanded) && (0, types_1.isClassInstance)(valueSubtypeExpanded) && types_1.ClassType.isLiteralValueSame(valueSubtypeExpanded, subjectSubtypeExpanded)) {
|
|
50880
|
+
} else if ((0, types_1.isClassInstance)(subjectSubtypeExpanded) && (0, types_1.isClassInstance)(valueSubtypeExpanded) && (0, typeUtils_1.isLiteralType)(subjectSubtypeExpanded) && types_1.ClassType.isLiteralValueSame(valueSubtypeExpanded, subjectSubtypeExpanded)) {
|
|
50844
50881
|
return void 0;
|
|
50845
50882
|
}
|
|
50846
50883
|
return subjectSubtypeExpanded;
|
|
@@ -51323,8 +51360,8 @@ var require_regions = __commonJS({
|
|
|
51323
51360
|
return comments;
|
|
51324
51361
|
}
|
|
51325
51362
|
exports.getRegionComments = getRegionComments;
|
|
51326
|
-
var
|
|
51327
|
-
var
|
|
51363
|
+
var StartRegionRegEx = /^\s*region\b/;
|
|
51364
|
+
var EndRegionRegEx = /^\s*endregion\b/;
|
|
51328
51365
|
function getRegionCommentType(comment, parseResults) {
|
|
51329
51366
|
const hashOffset = comment.start - 1;
|
|
51330
51367
|
const hashPosition = (0, positionUtils_1.convertOffsetToPosition)(hashOffset, parseResults.tokenizerOutput.lines);
|
|
@@ -51335,8 +51372,8 @@ var require_regions = __commonJS({
|
|
|
51335
51372
|
return void 0;
|
|
51336
51373
|
}
|
|
51337
51374
|
}
|
|
51338
|
-
const startRegionMatch =
|
|
51339
|
-
const endRegionMatch =
|
|
51375
|
+
const startRegionMatch = StartRegionRegEx.exec(comment.value);
|
|
51376
|
+
const endRegionMatch = EndRegionRegEx.exec(comment.value);
|
|
51340
51377
|
if (startRegionMatch) {
|
|
51341
51378
|
return 0;
|
|
51342
51379
|
} else if (endRegionMatch) {
|
|
@@ -52808,6 +52845,7 @@ var require_constructorTransform = __commonJS({
|
|
|
52808
52845
|
var diagnosticRules_1 = require_diagnosticRules();
|
|
52809
52846
|
var localize_1 = require_localize();
|
|
52810
52847
|
var analyzerNodeInfo_1 = require_analyzerNodeInfo();
|
|
52848
|
+
var parameterUtils_1 = require_parameterUtils();
|
|
52811
52849
|
var symbol_1 = require_symbol();
|
|
52812
52850
|
var types_1 = require_types();
|
|
52813
52851
|
var typeUtils_1 = require_typeUtils();
|
|
@@ -52854,7 +52892,7 @@ var require_constructorTransform = __commonJS({
|
|
|
52854
52892
|
return result;
|
|
52855
52893
|
}
|
|
52856
52894
|
const paramMap = /* @__PURE__ */ new Map();
|
|
52857
|
-
const paramListDetails = (0,
|
|
52895
|
+
const paramListDetails = (0, parameterUtils_1.getParameterListDetails)(origFunctionType);
|
|
52858
52896
|
let argumentErrors = false;
|
|
52859
52897
|
let reportedPositionalError = false;
|
|
52860
52898
|
const typeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(origFunctionType));
|
|
@@ -52865,7 +52903,7 @@ var require_constructorTransform = __commonJS({
|
|
|
52865
52903
|
return;
|
|
52866
52904
|
}
|
|
52867
52905
|
if (!arg.name) {
|
|
52868
|
-
if (argIndex >= paramListDetails.params.length || paramListDetails.params[argIndex].source ===
|
|
52906
|
+
if (argIndex >= paramListDetails.params.length || paramListDetails.params[argIndex].source === parameterUtils_1.ParameterSource.KeywordOnly) {
|
|
52869
52907
|
if (paramListDetails.argsIndex !== void 0) {
|
|
52870
52908
|
const paramType = types_1.FunctionType.getEffectiveParameterType(origFunctionType, paramListDetails.params[paramListDetails.argsIndex].index);
|
|
52871
52909
|
const diag = new diagnostic_1.DiagnosticAddendum();
|
|
@@ -52917,7 +52955,7 @@ var require_constructorTransform = __commonJS({
|
|
|
52917
52955
|
} else {
|
|
52918
52956
|
const matchingParam = paramListDetails.params.find((paramInfo) => {
|
|
52919
52957
|
var _a2;
|
|
52920
|
-
return paramInfo.param.name === ((_a2 = arg.name) === null || _a2 === void 0 ? void 0 : _a2.value) && paramInfo.source !==
|
|
52958
|
+
return paramInfo.param.name === ((_a2 = arg.name) === null || _a2 === void 0 ? void 0 : _a2.value) && paramInfo.source !== parameterUtils_1.ParameterSource.PositionOnly;
|
|
52921
52959
|
});
|
|
52922
52960
|
if (!matchingParam) {
|
|
52923
52961
|
if (paramListDetails.kwargsIndex === void 0) {
|
|
@@ -54419,7 +54457,7 @@ var require_properties = __commonJS({
|
|
|
54419
54457
|
});
|
|
54420
54458
|
const propertyObject = types_1.ClassType.cloneAsInstance(propertyClass);
|
|
54421
54459
|
propertyClass.isAsymmetricDescriptor = false;
|
|
54422
|
-
updateGetSetDelMethodForClonedProperty(
|
|
54460
|
+
updateGetSetDelMethodForClonedProperty(evaluator, propertyObject);
|
|
54423
54461
|
const fgetSymbol = symbol_1.Symbol.createWithType(4, types_1.FunctionType.cloneWithNewFlags(
|
|
54424
54462
|
fget,
|
|
54425
54463
|
fget.details.flags | 4
|
|
@@ -54429,7 +54467,7 @@ var require_properties = __commonJS({
|
|
|
54429
54467
|
if (types_1.FunctionType.isClassMethod(fget)) {
|
|
54430
54468
|
propertyClass.details.flags |= 4194304;
|
|
54431
54469
|
}
|
|
54432
|
-
addGetMethodToPropertySymbolTable(propertyObject, fget);
|
|
54470
|
+
addGetMethodToPropertySymbolTable(evaluator, propertyObject, fget);
|
|
54433
54471
|
addDecoratorMethodsToPropertySymbolTable(propertyObject);
|
|
54434
54472
|
return propertyObject;
|
|
54435
54473
|
}
|
|
@@ -54479,14 +54517,14 @@ var require_properties = __commonJS({
|
|
|
54479
54517
|
fields.set(name, symbol);
|
|
54480
54518
|
}
|
|
54481
54519
|
});
|
|
54482
|
-
updateGetSetDelMethodForClonedProperty(
|
|
54520
|
+
updateGetSetDelMethodForClonedProperty(evaluator, propertyObject);
|
|
54483
54521
|
const fsetSymbol = symbol_1.Symbol.createWithType(4, types_1.FunctionType.cloneWithNewFlags(
|
|
54484
54522
|
fset,
|
|
54485
54523
|
fset.details.flags | 4
|
|
54486
54524
|
/* StaticMethod */
|
|
54487
54525
|
));
|
|
54488
54526
|
fields.set("fset", fsetSymbol);
|
|
54489
|
-
addSetMethodToPropertySymbolTable(propertyObject, fset
|
|
54527
|
+
addSetMethodToPropertySymbolTable(evaluator, propertyObject, fset);
|
|
54490
54528
|
addDecoratorMethodsToPropertySymbolTable(propertyObject);
|
|
54491
54529
|
return propertyObject;
|
|
54492
54530
|
}
|
|
@@ -54510,19 +54548,19 @@ var require_properties = __commonJS({
|
|
|
54510
54548
|
fields.set(name, symbol);
|
|
54511
54549
|
}
|
|
54512
54550
|
});
|
|
54513
|
-
updateGetSetDelMethodForClonedProperty(
|
|
54551
|
+
updateGetSetDelMethodForClonedProperty(evaluator, propertyObject);
|
|
54514
54552
|
const fdelSymbol = symbol_1.Symbol.createWithType(4, types_1.FunctionType.cloneWithNewFlags(
|
|
54515
54553
|
fdel,
|
|
54516
54554
|
fdel.details.flags | 4
|
|
54517
54555
|
/* StaticMethod */
|
|
54518
54556
|
));
|
|
54519
54557
|
fields.set("fdel", fdelSymbol);
|
|
54520
|
-
addDelMethodToPropertySymbolTable(propertyObject, fdel
|
|
54558
|
+
addDelMethodToPropertySymbolTable(evaluator, propertyObject, fdel);
|
|
54521
54559
|
addDecoratorMethodsToPropertySymbolTable(propertyObject);
|
|
54522
54560
|
return propertyObject;
|
|
54523
54561
|
}
|
|
54524
54562
|
exports.clonePropertyWithDeleter = clonePropertyWithDeleter;
|
|
54525
|
-
function addGetMethodToPropertySymbolTable(propertyObject, fget) {
|
|
54563
|
+
function addGetMethodToPropertySymbolTable(evaluator, propertyObject, fget) {
|
|
54526
54564
|
const fields = propertyObject.details.fields;
|
|
54527
54565
|
const getFunction1 = types_1.FunctionType.createSynthesizedInstance(
|
|
54528
54566
|
"__get__",
|
|
@@ -54585,7 +54623,7 @@ var require_properties = __commonJS({
|
|
|
54585
54623
|
const getSymbol = symbol_1.Symbol.createWithType(4, getFunctionOverload);
|
|
54586
54624
|
fields.set("__get__", getSymbol);
|
|
54587
54625
|
}
|
|
54588
|
-
function addSetMethodToPropertySymbolTable(propertyObject, fset
|
|
54626
|
+
function addSetMethodToPropertySymbolTable(evaluator, propertyObject, fset) {
|
|
54589
54627
|
const fields = propertyObject.details.fields;
|
|
54590
54628
|
const setFunction = types_1.FunctionType.createSynthesizedInstance("__set__");
|
|
54591
54629
|
types_1.FunctionType.addParameter(setFunction, {
|
|
@@ -54619,7 +54657,7 @@ var require_properties = __commonJS({
|
|
|
54619
54657
|
const setSymbol = symbol_1.Symbol.createWithType(4, setFunction);
|
|
54620
54658
|
fields.set("__set__", setSymbol);
|
|
54621
54659
|
}
|
|
54622
|
-
function addDelMethodToPropertySymbolTable(propertyObject, fdel
|
|
54660
|
+
function addDelMethodToPropertySymbolTable(evaluator, propertyObject, fdel) {
|
|
54623
54661
|
const fields = propertyObject.details.fields;
|
|
54624
54662
|
const delFunction = types_1.FunctionType.createSynthesizedInstance("__delete__");
|
|
54625
54663
|
types_1.FunctionType.addParameter(delFunction, {
|
|
@@ -54643,22 +54681,22 @@ var require_properties = __commonJS({
|
|
|
54643
54681
|
const delSymbol = symbol_1.Symbol.createWithType(4, delFunction);
|
|
54644
54682
|
fields.set("__delete__", delSymbol);
|
|
54645
54683
|
}
|
|
54646
|
-
function updateGetSetDelMethodForClonedProperty(
|
|
54684
|
+
function updateGetSetDelMethodForClonedProperty(evaluator, propertyObject) {
|
|
54647
54685
|
const fields = propertyObject.details.fields;
|
|
54648
54686
|
const fgetSymbol = fields.get("fget");
|
|
54649
54687
|
const fgetType = fgetSymbol === null || fgetSymbol === void 0 ? void 0 : fgetSymbol.getSynthesizedType();
|
|
54650
54688
|
if (fgetType && (0, types_1.isFunction)(fgetType)) {
|
|
54651
|
-
addGetMethodToPropertySymbolTable(propertyObject, fgetType);
|
|
54689
|
+
addGetMethodToPropertySymbolTable(evaluator, propertyObject, fgetType);
|
|
54652
54690
|
}
|
|
54653
54691
|
const fsetSymbol = fields.get("fset");
|
|
54654
54692
|
const fsetType = fsetSymbol === null || fsetSymbol === void 0 ? void 0 : fsetSymbol.getSynthesizedType();
|
|
54655
54693
|
if (fsetType && (0, types_1.isFunction)(fsetType)) {
|
|
54656
|
-
addSetMethodToPropertySymbolTable(propertyObject, fsetType
|
|
54694
|
+
addSetMethodToPropertySymbolTable(evaluator, propertyObject, fsetType);
|
|
54657
54695
|
}
|
|
54658
54696
|
const fdelSymbol = fields.get("fdel");
|
|
54659
54697
|
const fdelType = fdelSymbol === null || fdelSymbol === void 0 ? void 0 : fdelSymbol.getSynthesizedType();
|
|
54660
54698
|
if (fdelType && (0, types_1.isFunction)(fdelType)) {
|
|
54661
|
-
addDelMethodToPropertySymbolTable(propertyObject, fdelType
|
|
54699
|
+
addDelMethodToPropertySymbolTable(evaluator, propertyObject, fdelType);
|
|
54662
54700
|
}
|
|
54663
54701
|
}
|
|
54664
54702
|
function addDecoratorMethodsToPropertySymbolTable(propertyObject) {
|
|
@@ -54827,7 +54865,8 @@ var require_protocols = __commonJS({
|
|
|
54827
54865
|
);
|
|
54828
54866
|
const genericDestTypeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(destType));
|
|
54829
54867
|
const selfTypeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(destType));
|
|
54830
|
-
|
|
54868
|
+
const noLiteralSrcType = evaluator.stripLiteralValue(srcType);
|
|
54869
|
+
(0, typeUtils_1.populateTypeVarContextForSelfType)(selfTypeVarContext, destType, noLiteralSrcType);
|
|
54831
54870
|
if (types_1.ClassType.isTypedDictClass(srcType)) {
|
|
54832
54871
|
const typedDictClassType = evaluator.getTypedDictClassType();
|
|
54833
54872
|
if (typedDictClassType && (0, types_1.isInstantiableClass)(typedDictClassType)) {
|
|
@@ -54890,7 +54929,7 @@ var require_protocols = __commonJS({
|
|
|
54890
54929
|
if ((0, types_1.isFunction)(symbolType)) {
|
|
54891
54930
|
evaluator.inferReturnTypeIfNecessary(symbolType);
|
|
54892
54931
|
}
|
|
54893
|
-
srcMemberType = (0, typeUtils_1.partiallySpecializeType)(symbolType, srcMemberInfo.classType,
|
|
54932
|
+
srcMemberType = (0, typeUtils_1.partiallySpecializeType)(symbolType, srcMemberInfo.classType, noLiteralSrcType);
|
|
54894
54933
|
} else {
|
|
54895
54934
|
srcMemberType = types_1.UnknownType.create();
|
|
54896
54935
|
}
|
|
@@ -55241,12 +55280,29 @@ var require_typeCacheUtils = __commonJS({
|
|
|
55241
55280
|
if (this._speculativeContextStack.some((context) => !context.allowCacheRetention)) {
|
|
55242
55281
|
return;
|
|
55243
55282
|
}
|
|
55283
|
+
const maxCacheEntriesPerNode = 8;
|
|
55244
55284
|
let cacheEntries = this._speculativeTypeCache.get(node.id);
|
|
55245
55285
|
if (!cacheEntries) {
|
|
55246
55286
|
cacheEntries = [];
|
|
55247
|
-
|
|
55287
|
+
} else {
|
|
55288
|
+
cacheEntries = cacheEntries.filter((entry) => {
|
|
55289
|
+
if (entry.typeResult.isIncomplete && entry.incompleteGenerationCount !== incompleteGenerationCount) {
|
|
55290
|
+
return false;
|
|
55291
|
+
}
|
|
55292
|
+
if (expectedType) {
|
|
55293
|
+
if (!entry.expectedType) {
|
|
55294
|
+
return true;
|
|
55295
|
+
}
|
|
55296
|
+
return !(0, types_1.isTypeSame)(entry.expectedType, expectedType);
|
|
55297
|
+
}
|
|
55298
|
+
return !!entry.expectedType;
|
|
55299
|
+
});
|
|
55300
|
+
if (cacheEntries.length >= maxCacheEntriesPerNode) {
|
|
55301
|
+
cacheEntries.slice(1);
|
|
55302
|
+
}
|
|
55248
55303
|
}
|
|
55249
55304
|
cacheEntries.push({ typeResult, expectedType, incompleteGenerationCount });
|
|
55305
|
+
this._speculativeTypeCache.set(node.id, cacheEntries);
|
|
55250
55306
|
}
|
|
55251
55307
|
getSpeculativeType(node, expectedType) {
|
|
55252
55308
|
if (this._speculativeContextStack.some((context) => ParseTreeUtils.isNodeContainedWithin(node, context.speculativeRootNode))) {
|
|
@@ -55315,7 +55371,6 @@ var require_typeEvaluator = __commonJS({
|
|
|
55315
55371
|
var localize_1 = require_localize();
|
|
55316
55372
|
var parseNodes_1 = require_parseNodes();
|
|
55317
55373
|
var parser_1 = require_parser();
|
|
55318
|
-
var DeclarationUtils = __importStar(require_aliasDeclarationUtils());
|
|
55319
55374
|
var analyzerFileInfo_1 = require_analyzerFileInfo();
|
|
55320
55375
|
var AnalyzerNodeInfo = __importStar(require_analyzerNodeInfo());
|
|
55321
55376
|
var codeFlowEngine_1 = require_codeFlowEngine();
|
|
@@ -55327,6 +55382,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
55327
55382
|
var enums_1 = require_enums();
|
|
55328
55383
|
var functionTransform_1 = require_functionTransform();
|
|
55329
55384
|
var namedTuples_1 = require_namedTuples();
|
|
55385
|
+
var parameterUtils_1 = require_parameterUtils();
|
|
55330
55386
|
var ParseTreeUtils = __importStar(require_parseTreeUtils());
|
|
55331
55387
|
var patternMatching_1 = require_patternMatching();
|
|
55332
55388
|
var properties_1 = require_properties();
|
|
@@ -55523,6 +55579,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
55523
55579
|
let dictClassType;
|
|
55524
55580
|
let typedDictClassType;
|
|
55525
55581
|
let typedDictPrivateClassType;
|
|
55582
|
+
let mappingType;
|
|
55526
55583
|
let printExpressionSpaceCount = 0;
|
|
55527
55584
|
let incompleteGenerationCount = 0;
|
|
55528
55585
|
const returnTypeInferenceContextStack = [];
|
|
@@ -55736,6 +55793,10 @@ var require_typeEvaluator = __commonJS({
|
|
|
55736
55793
|
dictClassType = getBuiltInType(node, "dict");
|
|
55737
55794
|
typedDictClassType = getTypingType(node, "TypedDict");
|
|
55738
55795
|
typedDictPrivateClassType = getTypingType(node, "_TypedDict");
|
|
55796
|
+
mappingType = getTypeshedType(node, "SupportsKeysAndGetItem");
|
|
55797
|
+
if (!mappingType) {
|
|
55798
|
+
mappingType = getTypingType(node, "Mapping");
|
|
55799
|
+
}
|
|
55739
55800
|
}
|
|
55740
55801
|
}
|
|
55741
55802
|
function getTypeOfExpression(node, flags = 0, inferenceContext) {
|
|
@@ -56153,7 +56214,11 @@ var require_typeEvaluator = __commonJS({
|
|
|
56153
56214
|
}
|
|
56154
56215
|
if (types_1.ClassType.isBuiltIn(subtype, "LiteralString")) {
|
|
56155
56216
|
if (strClassType && (0, types_1.isInstantiableClass)(strClassType)) {
|
|
56156
|
-
|
|
56217
|
+
let strInstance = types_1.ClassType.cloneAsInstance(strClassType);
|
|
56218
|
+
if (subtype.condition) {
|
|
56219
|
+
strInstance = types_1.TypeBase.cloneForCondition(strInstance, (0, typeUtils_1.getTypeCondition)(subtype));
|
|
56220
|
+
}
|
|
56221
|
+
return strInstance;
|
|
56157
56222
|
}
|
|
56158
56223
|
}
|
|
56159
56224
|
}
|
|
@@ -57360,7 +57425,12 @@ var require_typeEvaluator = __commonJS({
|
|
|
57360
57425
|
const setTypeResult = getTypeOfMemberAccessWithBaseType(
|
|
57361
57426
|
target,
|
|
57362
57427
|
baseTypeResult,
|
|
57363
|
-
{
|
|
57428
|
+
{
|
|
57429
|
+
method: "set",
|
|
57430
|
+
setType: { type, isIncomplete: isTypeIncomplete },
|
|
57431
|
+
setErrorNode: srcExpr,
|
|
57432
|
+
setExpectedTypeDiag: expectedTypeDiagAddendum
|
|
57433
|
+
},
|
|
57364
57434
|
0
|
|
57365
57435
|
/* None */
|
|
57366
57436
|
);
|
|
@@ -57484,9 +57554,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
57484
57554
|
const sourceEntryTypes = tupleType.tupleTypeArguments.map((t) => (0, typeUtils_1.addConditionToType)(t.type, (0, typeUtils_1.getTypeCondition)(subtype)));
|
|
57485
57555
|
const unboundedIndex = tupleType.tupleTypeArguments.findIndex((t) => t.isUnbounded);
|
|
57486
57556
|
if (unboundedIndex >= 0) {
|
|
57487
|
-
if (sourceEntryTypes.length
|
|
57488
|
-
sourceEntryTypes.splice(unboundedIndex, 1);
|
|
57489
|
-
} else if (sourceEntryTypes.length < targetTypes.length) {
|
|
57557
|
+
if (sourceEntryTypes.length < targetTypes.length) {
|
|
57490
57558
|
const typeToReplicate = sourceEntryTypes.length > 0 ? sourceEntryTypes[unboundedIndex] : types_1.AnyType.create();
|
|
57491
57559
|
while (sourceEntryTypes.length < targetTypes.length) {
|
|
57492
57560
|
sourceEntryTypes.splice(unboundedIndex, 0, typeToReplicate);
|
|
@@ -57558,7 +57626,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
57558
57626
|
/* None */
|
|
57559
57627
|
);
|
|
57560
57628
|
}
|
|
57561
|
-
function makeTopLevelTypeVarsConcrete(type, conditionFilter) {
|
|
57629
|
+
function makeTopLevelTypeVarsConcrete(type, makeParamSpecsConcrete = false, conditionFilter) {
|
|
57562
57630
|
return (0, typeUtils_1.mapSubtypes)(type, (subtype) => {
|
|
57563
57631
|
if ((0, types_1.isParamSpec)(subtype)) {
|
|
57564
57632
|
if (subtype.paramSpecAccess === "args") {
|
|
@@ -57578,6 +57646,17 @@ var require_typeEvaluator = __commonJS({
|
|
|
57578
57646
|
return types_1.UnknownType.create();
|
|
57579
57647
|
}
|
|
57580
57648
|
}
|
|
57649
|
+
if (makeParamSpecsConcrete && (0, types_1.isFunction)(subtype) && subtype.details.parameters.length === 0 && subtype.details.paramSpec) {
|
|
57650
|
+
const concreteFunction = types_1.FunctionType.createInstance(
|
|
57651
|
+
"",
|
|
57652
|
+
"",
|
|
57653
|
+
"",
|
|
57654
|
+
64 | 32768
|
|
57655
|
+
/* SkipArgsKwargsCompatibilityCheck */
|
|
57656
|
+
);
|
|
57657
|
+
types_1.FunctionType.addDefaultParameters(concreteFunction);
|
|
57658
|
+
return types_1.FunctionType.cloneForParamSpec(subtype, concreteFunction);
|
|
57659
|
+
}
|
|
57581
57660
|
if ((0, types_1.isVariadicTypeVar)(subtype)) {
|
|
57582
57661
|
if (tupleClassType && (0, types_1.isInstantiableClass)(tupleClassType)) {
|
|
57583
57662
|
return (0, typeUtils_1.convertToInstance)((0, typeUtils_1.specializeTupleClass)(
|
|
@@ -57749,7 +57828,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
57749
57828
|
baseTypeResult,
|
|
57750
57829
|
{
|
|
57751
57830
|
method: "set",
|
|
57752
|
-
setType: type,
|
|
57831
|
+
setType: { type, isIncomplete: isTypeIncomplete },
|
|
57753
57832
|
setErrorNode: srcExpr,
|
|
57754
57833
|
setExpectedTypeDiag: expectedTypeDiagAddendum
|
|
57755
57834
|
},
|
|
@@ -58938,12 +59017,14 @@ var require_typeEvaluator = __commonJS({
|
|
|
58938
59017
|
}
|
|
58939
59018
|
type = descriptorResult.type;
|
|
58940
59019
|
if (usage.method === "set" && usage.setType) {
|
|
58941
|
-
if (!assignType(type, usage.setType, diag === null || diag === void 0 ? void 0 : diag.createAddendum())) {
|
|
58942
|
-
|
|
58943
|
-
|
|
58944
|
-
|
|
58945
|
-
|
|
58946
|
-
|
|
59020
|
+
if (!assignType(type, usage.setType.type, diag === null || diag === void 0 ? void 0 : diag.createAddendum())) {
|
|
59021
|
+
if (!usage.setType.isIncomplete) {
|
|
59022
|
+
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.memberAssignment().format({
|
|
59023
|
+
type: printType(usage.setType.type),
|
|
59024
|
+
name: memberName,
|
|
59025
|
+
classType: printObjectTypeForClass(classType)
|
|
59026
|
+
}));
|
|
59027
|
+
}
|
|
58947
59028
|
return void 0;
|
|
58948
59029
|
}
|
|
58949
59030
|
if ((0, types_1.isInstantiableClass)(memberInfo.classType) && types_1.ClassType.isFrozenDataClass(memberInfo.classType) && isAccessedThroughObject) {
|
|
@@ -58984,7 +59065,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
58984
59065
|
let isTypeValid = true;
|
|
58985
59066
|
let isAsymmetricDescriptor = false;
|
|
58986
59067
|
type = (0, typeUtils_1.mapSubtypes)(type, (subtype) => {
|
|
58987
|
-
var _a;
|
|
59068
|
+
var _a, _b, _c;
|
|
58988
59069
|
const concreteSubtype = makeTopLevelTypeVarsConcrete(subtype);
|
|
58989
59070
|
const isClassMember = !memberInfo || memberInfo.isClassMember;
|
|
58990
59071
|
if ((0, types_1.isClass)(concreteSubtype) && isClassMember) {
|
|
@@ -59055,7 +59136,10 @@ var require_typeEvaluator = __commonJS({
|
|
|
59055
59136
|
} else if (usage.method === "set") {
|
|
59056
59137
|
argList.push({
|
|
59057
59138
|
argumentCategory: 0,
|
|
59058
|
-
typeResult: {
|
|
59139
|
+
typeResult: {
|
|
59140
|
+
type: (_b = (_a = usage.setType) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : types_1.UnknownType.create(),
|
|
59141
|
+
isIncomplete: !!((_c = usage.setType) === null || _c === void 0 ? void 0 : _c.isIncomplete)
|
|
59142
|
+
}
|
|
59059
59143
|
});
|
|
59060
59144
|
}
|
|
59061
59145
|
if (types_1.ClassType.isPropertyClass(lookupClass) && memberInfo && (0, types_1.isInstantiableClass)(memberInfo.classType)) {
|
|
@@ -59111,11 +59195,11 @@ var require_typeEvaluator = __commonJS({
|
|
|
59111
59195
|
);
|
|
59112
59196
|
if (callResult.argumentErrors) {
|
|
59113
59197
|
if (usage.method === "set") {
|
|
59114
|
-
if (usage.setType && (0, types_1.isFunction)(boundMethodType) && boundMethodType.details.parameters.length >= 2) {
|
|
59198
|
+
if (usage.setType && (0, types_1.isFunction)(boundMethodType) && boundMethodType.details.parameters.length >= 2 && !usage.setType.isIncomplete) {
|
|
59115
59199
|
const setterType = types_1.FunctionType.getEffectiveParameterType(boundMethodType, 1);
|
|
59116
59200
|
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.typeIncompatible().format({
|
|
59117
59201
|
destType: printType(setterType),
|
|
59118
|
-
sourceType: printType(usage.setType)
|
|
59202
|
+
sourceType: printType(usage.setType.type)
|
|
59119
59203
|
}));
|
|
59120
59204
|
} else if ((0, types_1.isOverloadedFunction)(boundMethodType)) {
|
|
59121
59205
|
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.Diagnostic.noOverload().format({ name: accessMethodName }));
|
|
@@ -59266,7 +59350,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
59266
59350
|
return isAsymmetric;
|
|
59267
59351
|
}
|
|
59268
59352
|
function applyAttributeAccessOverride(classType, errorNode, usage, memberName) {
|
|
59269
|
-
var _a, _b, _c;
|
|
59353
|
+
var _a, _b, _c, _d, _e;
|
|
59270
59354
|
const getAttributeAccessMember = (name) => {
|
|
59271
59355
|
var _a2;
|
|
59272
59356
|
return (_a2 = getTypeOfClassMember(
|
|
@@ -59310,7 +59394,10 @@ var require_typeEvaluator = __commonJS({
|
|
|
59310
59394
|
argList.push({
|
|
59311
59395
|
// Provide "value" argument.
|
|
59312
59396
|
argumentCategory: 0,
|
|
59313
|
-
typeResult: {
|
|
59397
|
+
typeResult: {
|
|
59398
|
+
type: (_c = (_b = usage.setType) === null || _b === void 0 ? void 0 : _b.type) !== null && _c !== void 0 ? _c : types_1.UnknownType.create(),
|
|
59399
|
+
isIncomplete: !!((_d = usage.setType) === null || _d === void 0 ? void 0 : _d.isIncomplete)
|
|
59400
|
+
}
|
|
59314
59401
|
});
|
|
59315
59402
|
}
|
|
59316
59403
|
if ((0, types_1.isFunction)(accessMemberType) || (0, types_1.isOverloadedFunction)(accessMemberType)) {
|
|
@@ -59325,7 +59412,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
59325
59412
|
/* skipUnknownArgCheck */
|
|
59326
59413
|
true
|
|
59327
59414
|
);
|
|
59328
|
-
return (
|
|
59415
|
+
return (_e = callResult.returnType) !== null && _e !== void 0 ? _e : types_1.UnknownType.create();
|
|
59329
59416
|
}
|
|
59330
59417
|
}
|
|
59331
59418
|
}
|
|
@@ -59909,7 +59996,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
59909
59996
|
}
|
|
59910
59997
|
}
|
|
59911
59998
|
function getTypeOfIndexedObjectOrClass(node, baseType, usage) {
|
|
59912
|
-
var _a, _b, _c;
|
|
59999
|
+
var _a, _b, _c, _d, _e, _f;
|
|
59913
60000
|
if ((0, types_1.isClassInstance)(baseType) && types_1.ClassType.isTypedDictClass(baseType)) {
|
|
59914
60001
|
const typeFromTypedDict = (0, typedDicts_1.getTypeOfIndexedTypedDict)(evaluatorInterface, node, baseType, usage);
|
|
59915
60002
|
if (typeFromTypedDict) {
|
|
@@ -60043,14 +60130,22 @@ var require_typeEvaluator = __commonJS({
|
|
|
60043
60130
|
}
|
|
60044
60131
|
];
|
|
60045
60132
|
if (usage.method === "set") {
|
|
60046
|
-
let setType = usage.setType || types_1.AnyType.create();
|
|
60133
|
+
let setType = (_d = (_c = usage.setType) === null || _c === void 0 ? void 0 : _c.type) !== null && _d !== void 0 ? _d : types_1.AnyType.create();
|
|
60047
60134
|
if ((0, types_1.isTypeVar)(setType) && setType.details.constraints.length > 0) {
|
|
60048
60135
|
const conditionFilter = (0, types_1.isClassInstance)(baseType) ? baseType.condition : void 0;
|
|
60049
|
-
setType = makeTopLevelTypeVarsConcrete(
|
|
60136
|
+
setType = makeTopLevelTypeVarsConcrete(
|
|
60137
|
+
setType,
|
|
60138
|
+
/* makeParamSpecsConcrete */
|
|
60139
|
+
void 0,
|
|
60140
|
+
conditionFilter
|
|
60141
|
+
);
|
|
60050
60142
|
}
|
|
60051
60143
|
argList.push({
|
|
60052
60144
|
argumentCategory: 0,
|
|
60053
|
-
typeResult: {
|
|
60145
|
+
typeResult: {
|
|
60146
|
+
type: setType,
|
|
60147
|
+
isIncomplete: !!((_e = usage.setType) === null || _e === void 0 ? void 0 : _e.isIncomplete)
|
|
60148
|
+
}
|
|
60054
60149
|
});
|
|
60055
60150
|
}
|
|
60056
60151
|
keywordArgs.forEach((arg) => {
|
|
@@ -60093,7 +60188,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
60093
60188
|
}
|
|
60094
60189
|
callResult = validateCallArguments(node, argList, { type: itemMethodType });
|
|
60095
60190
|
return {
|
|
60096
|
-
type: (
|
|
60191
|
+
type: (_f = callResult.returnType) !== null && _f !== void 0 ? _f : types_1.UnknownType.create(),
|
|
60097
60192
|
isIncomplete: !!callResult.isTypeIncomplete
|
|
60098
60193
|
};
|
|
60099
60194
|
}
|
|
@@ -60965,7 +61060,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
60965
61060
|
if (initMethodType && !skipConstructorCheck(initMethodType)) {
|
|
60966
61061
|
if (inferenceContext) {
|
|
60967
61062
|
const expectedCallResult = validateConstructorMethodWithExpectedType(errorNode, argList, type, skipUnknownArgCheck, inferenceContext, initMethodType);
|
|
60968
|
-
if (expectedCallResult) {
|
|
61063
|
+
if (expectedCallResult && !expectedCallResult.argumentErrors) {
|
|
60969
61064
|
returnType = expectedCallResult.returnType;
|
|
60970
61065
|
if (expectedCallResult.isTypeIncomplete) {
|
|
60971
61066
|
isTypeIncomplete = true;
|
|
@@ -61039,10 +61134,12 @@ var require_typeEvaluator = __commonJS({
|
|
|
61039
61134
|
}
|
|
61040
61135
|
if (constructorMethodInfo && !skipConstructorCheck(constructorMethodInfo.type)) {
|
|
61041
61136
|
const constructorMethodType = constructorMethodInfo.type;
|
|
61137
|
+
let newReturnType;
|
|
61042
61138
|
if (inferenceContext && !returnType) {
|
|
61043
61139
|
const expectedCallResult = validateConstructorMethodWithExpectedType(errorNode, argList, type, skipUnknownArgCheck, inferenceContext, constructorMethodType);
|
|
61044
|
-
if (expectedCallResult) {
|
|
61045
|
-
|
|
61140
|
+
if (expectedCallResult && !expectedCallResult.argumentErrors) {
|
|
61141
|
+
newReturnType = expectedCallResult.returnType;
|
|
61142
|
+
returnType = newReturnType;
|
|
61046
61143
|
if (expectedCallResult.isTypeIncomplete) {
|
|
61047
61144
|
isTypeIncomplete = true;
|
|
61048
61145
|
}
|
|
@@ -61066,8 +61163,8 @@ var require_typeEvaluator = __commonJS({
|
|
|
61066
61163
|
}
|
|
61067
61164
|
if (callResult.argumentErrors) {
|
|
61068
61165
|
reportedErrors = true;
|
|
61069
|
-
} else {
|
|
61070
|
-
|
|
61166
|
+
} else if (!newReturnType) {
|
|
61167
|
+
newReturnType = callResult.returnType;
|
|
61071
61168
|
if (newReturnType) {
|
|
61072
61169
|
if ((0, types_1.isClassInstance)(newReturnType) && types_1.ClassType.isSameGenericClass(newReturnType, type)) {
|
|
61073
61170
|
if (!(0, typeUtils_1.isPartlyUnknown)(newReturnType) && !(0, typeUtils_1.requiresSpecialization)(newReturnType) || returnType === void 0) {
|
|
@@ -61571,7 +61668,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
61571
61668
|
}
|
|
61572
61669
|
function matchFunctionArgumentsToParameters(errorNode, argList, typeResult, overloadIndex) {
|
|
61573
61670
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
61574
|
-
const paramDetails = (0,
|
|
61671
|
+
const paramDetails = (0, parameterUtils_1.getParameterListDetails)(typeResult.type);
|
|
61575
61672
|
let argIndex = 0;
|
|
61576
61673
|
let matchedUnpackedListOfUnknownLength = false;
|
|
61577
61674
|
let reportedArgError = false;
|
|
@@ -61585,7 +61682,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
61585
61682
|
paramMap.set(param.name, {
|
|
61586
61683
|
argsNeeded: param.category === 0 && !param.hasDefault ? 1 : 0,
|
|
61587
61684
|
argsReceived: 0,
|
|
61588
|
-
isPositionalOnly: paramInfo.source ===
|
|
61685
|
+
isPositionalOnly: paramInfo.source === parameterUtils_1.ParameterSource.PositionOnly
|
|
61589
61686
|
});
|
|
61590
61687
|
}
|
|
61591
61688
|
});
|
|
@@ -61927,10 +62024,6 @@ var require_typeEvaluator = __commonJS({
|
|
|
61927
62024
|
});
|
|
61928
62025
|
}
|
|
61929
62026
|
} else {
|
|
61930
|
-
let mappingType = getTypeshedType(errorNode, "SupportsKeysAndGetItem");
|
|
61931
|
-
if (!mappingType) {
|
|
61932
|
-
mappingType = getTypingType(errorNode, "Mapping");
|
|
61933
|
-
}
|
|
61934
62027
|
const strObjType = getBuiltInObject(errorNode, "str");
|
|
61935
62028
|
if (mappingType && (0, types_1.isInstantiableClass)(mappingType) && strObjType && (0, types_1.isClassInstance)(strObjType)) {
|
|
61936
62029
|
const mappingTypeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(mappingType));
|
|
@@ -62279,26 +62372,29 @@ var require_typeEvaluator = __commonJS({
|
|
|
62279
62372
|
if (typeVarMatchingCount > 0) {
|
|
62280
62373
|
let passCount = Math.min(typeVarMatchingCount, 2);
|
|
62281
62374
|
for (let i = 0; i < passCount; i++) {
|
|
62375
|
+
const signatureTracker2 = new typeUtils_1.UniqueSignatureTracker();
|
|
62282
62376
|
useSpeculativeMode(errorNode, () => {
|
|
62283
62377
|
matchResults.argParams.forEach((argParam) => {
|
|
62284
|
-
if (argParam.requiresTypeVarMatching) {
|
|
62285
|
-
|
|
62286
|
-
|
|
62287
|
-
|
|
62288
|
-
|
|
62289
|
-
|
|
62290
|
-
|
|
62291
|
-
|
|
62292
|
-
|
|
62293
|
-
|
|
62294
|
-
|
|
62295
|
-
|
|
62296
|
-
|
|
62297
|
-
|
|
62298
|
-
|
|
62299
|
-
|
|
62300
|
-
|
|
62301
|
-
|
|
62378
|
+
if (!argParam.requiresTypeVarMatching) {
|
|
62379
|
+
return;
|
|
62380
|
+
}
|
|
62381
|
+
const argResult = validateArgType(
|
|
62382
|
+
argParam,
|
|
62383
|
+
typeVarContext,
|
|
62384
|
+
signatureTracker2,
|
|
62385
|
+
{ type, isIncomplete: matchResults.isTypeIncomplete },
|
|
62386
|
+
skipUnknownArgCheck,
|
|
62387
|
+
/* skipOverloadArg */
|
|
62388
|
+
i === 0,
|
|
62389
|
+
/* useNarrowBoundOnly */
|
|
62390
|
+
passCount > 1 && i === 0,
|
|
62391
|
+
typeCondition
|
|
62392
|
+
);
|
|
62393
|
+
if (argResult.isTypeIncomplete) {
|
|
62394
|
+
isTypeIncomplete = true;
|
|
62395
|
+
}
|
|
62396
|
+
if (i === 0 && argResult.skippedOverloadArg) {
|
|
62397
|
+
passCount++;
|
|
62302
62398
|
}
|
|
62303
62399
|
});
|
|
62304
62400
|
});
|
|
@@ -62309,11 +62405,13 @@ var require_typeEvaluator = __commonJS({
|
|
|
62309
62405
|
let sawParamSpecKwargs = false;
|
|
62310
62406
|
let condition = [];
|
|
62311
62407
|
const argResults = [];
|
|
62408
|
+
const signatureTracker = new typeUtils_1.UniqueSignatureTracker();
|
|
62312
62409
|
matchResults.argParams.forEach((argParam) => {
|
|
62313
62410
|
var _a;
|
|
62314
62411
|
const argResult = validateArgType(
|
|
62315
62412
|
argParam,
|
|
62316
62413
|
typeVarContext,
|
|
62414
|
+
signatureTracker,
|
|
62317
62415
|
{ type, isIncomplete: matchResults.isTypeIncomplete },
|
|
62318
62416
|
skipUnknownArgCheck,
|
|
62319
62417
|
/* skipOverloadArg */
|
|
@@ -62505,6 +62603,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
62505
62603
|
(paramInfo) => paramInfo.category === 2
|
|
62506
62604
|
/* VarArgDictionary */
|
|
62507
62605
|
);
|
|
62606
|
+
const signatureTracker = new typeUtils_1.UniqueSignatureTracker();
|
|
62508
62607
|
argList.forEach((arg) => {
|
|
62509
62608
|
var _a2;
|
|
62510
62609
|
if (arg.argumentCategory === 0) {
|
|
@@ -62547,6 +62646,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
62547
62646
|
errorNode: arg.valueExpression || errorNode
|
|
62548
62647
|
},
|
|
62549
62648
|
srcTypeVarContext,
|
|
62649
|
+
signatureTracker,
|
|
62550
62650
|
/* functionType */
|
|
62551
62651
|
void 0,
|
|
62552
62652
|
/* skipUnknownArgCheck */
|
|
@@ -62582,7 +62682,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
62582
62682
|
}
|
|
62583
62683
|
return !reportedArgError;
|
|
62584
62684
|
}
|
|
62585
|
-
function validateArgType(argParam, typeVarContext, typeResult, skipUnknownCheck, skipOverloadArg, useNarrowBoundOnly, conditionFilter) {
|
|
62685
|
+
function validateArgType(argParam, typeVarContext, signatureTracker, typeResult, skipUnknownCheck, skipOverloadArg, useNarrowBoundOnly, conditionFilter) {
|
|
62586
62686
|
var _a;
|
|
62587
62687
|
let argType;
|
|
62588
62688
|
let expectedTypeDiag;
|
|
@@ -62640,6 +62740,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
62640
62740
|
}
|
|
62641
62741
|
}
|
|
62642
62742
|
}
|
|
62743
|
+
argType = (0, typeUtils_1.ensureFunctionSignaturesAreUnique)(argType, signatureTracker);
|
|
62643
62744
|
if (argParam.paramCategory === 2 && (0, types_1.isTypeVar)(argParam.paramType)) {
|
|
62644
62745
|
argType = stripLiteralValue(argType);
|
|
62645
62746
|
}
|
|
@@ -64119,10 +64220,6 @@ var require_typeEvaluator = __commonJS({
|
|
|
64119
64220
|
}
|
|
64120
64221
|
addUnknown = false;
|
|
64121
64222
|
} else if (entryNode.nodeType === 16) {
|
|
64122
|
-
let mappingType = getTypeshedType(node, "SupportsKeysAndGetItem");
|
|
64123
|
-
if (!mappingType) {
|
|
64124
|
-
mappingType = getTypingType(node, "Mapping");
|
|
64125
|
-
}
|
|
64126
64223
|
let expectedType;
|
|
64127
64224
|
if (expectedKeyType && expectedValueType) {
|
|
64128
64225
|
if (mappingType && (0, types_1.isInstantiableClass)(mappingType)) {
|
|
@@ -64163,39 +64260,37 @@ var require_typeEvaluator = __commonJS({
|
|
|
64163
64260
|
});
|
|
64164
64261
|
addUnknown = false;
|
|
64165
64262
|
}
|
|
64166
|
-
} else {
|
|
64167
|
-
|
|
64168
|
-
|
|
64169
|
-
mappingType
|
|
64170
|
-
|
|
64171
|
-
|
|
64172
|
-
|
|
64173
|
-
|
|
64174
|
-
|
|
64175
|
-
|
|
64176
|
-
|
|
64177
|
-
|
|
64178
|
-
|
|
64179
|
-
|
|
64180
|
-
|
|
64181
|
-
|
|
64182
|
-
|
|
64183
|
-
|
|
64184
|
-
|
|
64185
|
-
))
|
|
64186
|
-
|
|
64187
|
-
|
|
64188
|
-
if (
|
|
64189
|
-
|
|
64190
|
-
|
|
64191
|
-
valueTypes.push({ node: entryNode, type: typeArgs[1] });
|
|
64192
|
-
}
|
|
64193
|
-
addUnknown = false;
|
|
64263
|
+
} else if (mappingType && (0, types_1.isInstantiableClass)(mappingType)) {
|
|
64264
|
+
const mappingTypeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(mappingType));
|
|
64265
|
+
mappingType = types_1.ClassType.cloneForSpecialization(
|
|
64266
|
+
mappingType,
|
|
64267
|
+
mappingType.details.typeParameters,
|
|
64268
|
+
/* isTypeArgumentExplicit */
|
|
64269
|
+
true
|
|
64270
|
+
);
|
|
64271
|
+
if (assignType(
|
|
64272
|
+
types_1.ClassType.cloneAsInstance(mappingType),
|
|
64273
|
+
unexpandedType,
|
|
64274
|
+
/* diag */
|
|
64275
|
+
void 0,
|
|
64276
|
+
mappingTypeVarContext,
|
|
64277
|
+
/* srcTypeVarContext */
|
|
64278
|
+
void 0,
|
|
64279
|
+
128
|
|
64280
|
+
/* RetainLiteralsForTypeVar */
|
|
64281
|
+
)) {
|
|
64282
|
+
const specializedMapping = (0, typeUtils_1.applySolvedTypeVars)(mappingType, mappingTypeVarContext);
|
|
64283
|
+
const typeArgs = specializedMapping.typeArguments;
|
|
64284
|
+
if (typeArgs && typeArgs.length >= 2) {
|
|
64285
|
+
if (forceStrictInference || index < maxEntriesToUseForInference) {
|
|
64286
|
+
keyTypes.push({ node: entryNode, type: typeArgs[0] });
|
|
64287
|
+
valueTypes.push({ node: entryNode, type: typeArgs[1] });
|
|
64194
64288
|
}
|
|
64195
|
-
|
|
64196
|
-
const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
|
|
64197
|
-
addDiagnostic(fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.dictUnpackIsNotMapping(), entryNode);
|
|
64289
|
+
addUnknown = false;
|
|
64198
64290
|
}
|
|
64291
|
+
} else {
|
|
64292
|
+
const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
|
|
64293
|
+
addDiagnostic(fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.dictUnpackIsNotMapping(), entryNode);
|
|
64199
64294
|
}
|
|
64200
64295
|
}
|
|
64201
64296
|
} else if (entryNode.nodeType === 32) {
|
|
@@ -66179,7 +66274,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
66179
66274
|
addError(localize_1.Localizer.Diagnostic.methodOrdering(), node.name);
|
|
66180
66275
|
}
|
|
66181
66276
|
const innerScope = ScopeUtils.getScopeForNode(node.suite);
|
|
66182
|
-
classType.details.fields = (innerScope === null || innerScope === void 0 ? void 0 : innerScope.symbolTable)
|
|
66277
|
+
classType.details.fields = (innerScope === null || innerScope === void 0 ? void 0 : innerScope.symbolTable) ? new Map(innerScope.symbolTable) : /* @__PURE__ */ new Map();
|
|
66183
66278
|
const slotsNames = innerScope === null || innerScope === void 0 ? void 0 : innerScope.getSlotsNames();
|
|
66184
66279
|
if (slotsNames) {
|
|
66185
66280
|
classType.details.localSlotsNames = slotsNames;
|
|
@@ -66660,7 +66755,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
66660
66755
|
if (newMethodMember) {
|
|
66661
66756
|
const newMethodType = getTypeOfMember(newMethodMember);
|
|
66662
66757
|
if ((0, types_1.isFunction)(newMethodType)) {
|
|
66663
|
-
const paramListDetails = (0,
|
|
66758
|
+
const paramListDetails = (0, parameterUtils_1.getParameterListDetails)(newMethodType);
|
|
66664
66759
|
if (paramListDetails.firstKeywordOnlyIndex !== void 0) {
|
|
66665
66760
|
const paramMap = /* @__PURE__ */ new Map();
|
|
66666
66761
|
for (let i = paramListDetails.firstKeywordOnlyIndex; i < paramListDetails.params.length; i++) {
|
|
@@ -66671,6 +66766,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
66671
66766
|
}
|
|
66672
66767
|
argList.forEach((arg) => {
|
|
66673
66768
|
var _a, _b, _c;
|
|
66769
|
+
const signatureTracker = new typeUtils_1.UniqueSignatureTracker();
|
|
66674
66770
|
if (arg.argumentCategory === 0 && arg.name) {
|
|
66675
66771
|
const paramIndex = (_a = paramMap.get(arg.name.value)) !== null && _a !== void 0 ? _a : paramListDetails.kwargsIndex;
|
|
66676
66772
|
if (paramIndex !== void 0) {
|
|
@@ -66685,6 +66781,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
66685
66781
|
validateArgType(
|
|
66686
66782
|
argParam,
|
|
66687
66783
|
new typeVarContext_1.TypeVarContext(),
|
|
66784
|
+
signatureTracker,
|
|
66688
66785
|
{ type: newMethodType },
|
|
66689
66786
|
/* skipUnknownCheck */
|
|
66690
66787
|
true,
|
|
@@ -67697,7 +67794,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
67697
67794
|
return getExceptionType(subType, node.typeExpression);
|
|
67698
67795
|
});
|
|
67699
67796
|
if (node.isExceptGroup) {
|
|
67700
|
-
targetType = getBuiltInObject(node, "
|
|
67797
|
+
targetType = getBuiltInObject(node, "BaseExceptionGroup", [targetType]);
|
|
67701
67798
|
}
|
|
67702
67799
|
if (node.name) {
|
|
67703
67800
|
assignTypeToExpression(
|
|
@@ -69584,10 +69681,10 @@ var require_typeEvaluator = __commonJS({
|
|
|
69584
69681
|
}
|
|
69585
69682
|
function resolveAliasDeclaration(declaration, resolveLocalNames, allowExternallyHiddenAccess = false) {
|
|
69586
69683
|
var _a;
|
|
69587
|
-
return (_a =
|
|
69684
|
+
return (_a = (0, declarationUtils_1.resolveAliasDeclaration)(importLookup, declaration, resolveLocalNames, allowExternallyHiddenAccess)) === null || _a === void 0 ? void 0 : _a.declaration;
|
|
69588
69685
|
}
|
|
69589
69686
|
function resolveAliasDeclarationWithInfo(declaration, resolveLocalNames, allowExternallyHiddenAccess = false) {
|
|
69590
|
-
return
|
|
69687
|
+
return (0, declarationUtils_1.resolveAliasDeclaration)(importLookup, declaration, resolveLocalNames, allowExternallyHiddenAccess);
|
|
69591
69688
|
}
|
|
69592
69689
|
function getEffectiveTypeOfSymbol(symbol) {
|
|
69593
69690
|
return getEffectiveTypeOfSymbolForUsage(symbol).type;
|
|
@@ -69609,7 +69706,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
69609
69706
|
}
|
|
69610
69707
|
}
|
|
69611
69708
|
const typedDecls = symbol.getTypedDeclarations();
|
|
69612
|
-
const
|
|
69709
|
+
const result2 = {
|
|
69613
69710
|
type: declaredType !== null && declaredType !== void 0 ? declaredType : types_1.UnknownType.create(),
|
|
69614
69711
|
isIncomplete: isIncomplete2,
|
|
69615
69712
|
includesVariableDecl: typedDecls.some(
|
|
@@ -69619,17 +69716,17 @@ var require_typeEvaluator = __commonJS({
|
|
|
69619
69716
|
includesIllegalTypeAliasDecl: !typedDecls.every((decl) => isPossibleTypeAliasDeclaration(decl)),
|
|
69620
69717
|
isRecursiveDefinition: !declaredType
|
|
69621
69718
|
};
|
|
69622
|
-
return
|
|
69719
|
+
return result2;
|
|
69623
69720
|
}
|
|
69624
69721
|
}
|
|
69625
69722
|
let cacheEntries = effectiveTypeCache.get(symbol.id);
|
|
69626
69723
|
const usageNodeId = usageNode ? usageNode.id : void 0;
|
|
69627
69724
|
const effectiveTypeCacheKey = `${usageNodeId === void 0 ? "." : usageNodeId.toString()}${useLastDecl ? "*" : ""}`;
|
|
69628
69725
|
if (cacheEntries) {
|
|
69629
|
-
const
|
|
69630
|
-
if (
|
|
69631
|
-
if (!
|
|
69632
|
-
return
|
|
69726
|
+
const result2 = cacheEntries.get(effectiveTypeCacheKey);
|
|
69727
|
+
if (result2) {
|
|
69728
|
+
if (!result2.isIncomplete) {
|
|
69729
|
+
return result2;
|
|
69633
69730
|
}
|
|
69634
69731
|
}
|
|
69635
69732
|
}
|
|
@@ -69641,15 +69738,15 @@ var require_typeEvaluator = __commonJS({
|
|
|
69641
69738
|
let includesSpeculativeResult = false;
|
|
69642
69739
|
let declIndexToConsider;
|
|
69643
69740
|
if (decls.length > maxDeclarationsToUseForInference) {
|
|
69644
|
-
const
|
|
69741
|
+
const result2 = {
|
|
69645
69742
|
type: types_1.UnknownType.create(),
|
|
69646
69743
|
isIncomplete: false,
|
|
69647
69744
|
includesVariableDecl: false,
|
|
69648
69745
|
includesIllegalTypeAliasDecl: !decls.every((decl) => isPossibleTypeAliasDeclaration(decl)),
|
|
69649
69746
|
isRecursiveDefinition: false
|
|
69650
69747
|
};
|
|
69651
|
-
addToEffectiveTypeCache(
|
|
69652
|
-
return
|
|
69748
|
+
addToEffectiveTypeCache(result2);
|
|
69749
|
+
return result2;
|
|
69653
69750
|
}
|
|
69654
69751
|
if (useLastDecl) {
|
|
69655
69752
|
decls.forEach((decl, index) => {
|
|
@@ -69753,35 +69850,32 @@ var require_typeEvaluator = __commonJS({
|
|
|
69753
69850
|
}
|
|
69754
69851
|
}
|
|
69755
69852
|
});
|
|
69853
|
+
const evaluationAttempts = ((_b = (_a = cacheEntries === null || cacheEntries === void 0 ? void 0 : cacheEntries.get(effectiveTypeCacheKey)) === null || _a === void 0 ? void 0 : _a.evaluationAttempts) !== null && _b !== void 0 ? _b : 0) + 1;
|
|
69854
|
+
let resultType;
|
|
69756
69855
|
if (typesToCombine.length > 0) {
|
|
69757
|
-
const evaluationAttempts = ((_b = (_a = cacheEntries === null || cacheEntries === void 0 ? void 0 : cacheEntries.get(effectiveTypeCacheKey)) === null || _a === void 0 ? void 0 : _a.evaluationAttempts) !== null && _b !== void 0 ? _b : 0) + 1;
|
|
69758
69856
|
isIncomplete = sawPendingEvaluation && evaluationAttempts < maxEffectiveTypeEvaluationAttempts;
|
|
69759
|
-
|
|
69760
|
-
|
|
69761
|
-
|
|
69762
|
-
includesVariableDecl,
|
|
69763
|
-
includesIllegalTypeAliasDecl: !decls.every((decl) => isPossibleTypeAliasDeclaration(decl)),
|
|
69764
|
-
isRecursiveDefinition: false,
|
|
69765
|
-
evaluationAttempts
|
|
69766
|
-
};
|
|
69767
|
-
if (!includesSpeculativeResult) {
|
|
69768
|
-
addToEffectiveTypeCache(result);
|
|
69769
|
-
}
|
|
69770
|
-
return result;
|
|
69857
|
+
resultType = (0, types_1.combineTypes)(typesToCombine);
|
|
69858
|
+
} else {
|
|
69859
|
+
resultType = types_1.UnboundType.create();
|
|
69771
69860
|
}
|
|
69772
|
-
|
|
69773
|
-
type:
|
|
69861
|
+
const result = {
|
|
69862
|
+
type: resultType,
|
|
69774
69863
|
isIncomplete,
|
|
69775
69864
|
includesVariableDecl,
|
|
69776
69865
|
includesIllegalTypeAliasDecl: !decls.every((decl) => isPossibleTypeAliasDeclaration(decl)),
|
|
69777
|
-
isRecursiveDefinition: false
|
|
69866
|
+
isRecursiveDefinition: false,
|
|
69867
|
+
evaluationAttempts
|
|
69778
69868
|
};
|
|
69779
|
-
|
|
69869
|
+
if (!includesSpeculativeResult) {
|
|
69870
|
+
addToEffectiveTypeCache(result);
|
|
69871
|
+
}
|
|
69872
|
+
return result;
|
|
69873
|
+
function addToEffectiveTypeCache(result2) {
|
|
69780
69874
|
if (!cacheEntries) {
|
|
69781
69875
|
cacheEntries = /* @__PURE__ */ new Map();
|
|
69782
69876
|
effectiveTypeCache.set(symbol.id, cacheEntries);
|
|
69783
69877
|
}
|
|
69784
|
-
cacheEntries.set(effectiveTypeCacheKey,
|
|
69878
|
+
cacheEntries.set(effectiveTypeCacheKey, result2);
|
|
69785
69879
|
}
|
|
69786
69880
|
}
|
|
69787
69881
|
function getDeclaredTypeOfSymbol(symbol, usageNode) {
|
|
@@ -69867,6 +69961,9 @@ var require_typeEvaluator = __commonJS({
|
|
|
69867
69961
|
if (types_1.FunctionType.isStubDefinition(type)) {
|
|
69868
69962
|
return types_1.UnknownType.create();
|
|
69869
69963
|
}
|
|
69964
|
+
if (types_1.FunctionType.isOverloaded(type) && !types_1.FunctionType.isSynthesizedMethod(type)) {
|
|
69965
|
+
return types_1.UnknownType.create();
|
|
69966
|
+
}
|
|
69870
69967
|
if (type.inferredReturnType) {
|
|
69871
69968
|
returnType = type.inferredReturnType;
|
|
69872
69969
|
} else {
|
|
@@ -70219,7 +70316,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
70219
70316
|
});
|
|
70220
70317
|
return isAssignable;
|
|
70221
70318
|
}
|
|
70222
|
-
function assignTupleTypeArgs(destType, srcType, diag,
|
|
70319
|
+
function assignTupleTypeArgs(destType, srcType, diag, destTypeVarContext, srcTypeVarContext, flags, recursionCount) {
|
|
70223
70320
|
var _a, _b;
|
|
70224
70321
|
const destTypeArgs = [...(_a = destType.tupleTypeArguments) !== null && _a !== void 0 ? _a : []];
|
|
70225
70322
|
const srcTypeArgs = [...(_b = srcType.tupleTypeArguments) !== null && _b !== void 0 ? _b : []];
|
|
@@ -70274,16 +70371,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
70274
70371
|
if (srcTypeArgs.length === destTypeArgs.length) {
|
|
70275
70372
|
for (let argIndex = 0; argIndex < srcTypeArgs.length; argIndex++) {
|
|
70276
70373
|
const entryDiag = diag === null || diag === void 0 ? void 0 : diag.createAddendum();
|
|
70277
|
-
if (!assignType(
|
|
70278
|
-
destTypeArgs[argIndex].type,
|
|
70279
|
-
srcTypeArgs[argIndex].type,
|
|
70280
|
-
entryDiag === null || entryDiag === void 0 ? void 0 : entryDiag.createAddendum(),
|
|
70281
|
-
typeVarContext,
|
|
70282
|
-
/* srcTypeVarContext */
|
|
70283
|
-
void 0,
|
|
70284
|
-
flags,
|
|
70285
|
-
recursionCount
|
|
70286
|
-
)) {
|
|
70374
|
+
if (!assignType(destTypeArgs[argIndex].type, srcTypeArgs[argIndex].type, entryDiag === null || entryDiag === void 0 ? void 0 : entryDiag.createAddendum(), destTypeVarContext, srcTypeVarContext, flags, recursionCount)) {
|
|
70287
70375
|
if (entryDiag) {
|
|
70288
70376
|
entryDiag.addMessage(localize_1.Localizer.DiagnosticAddendum.tupleEntryTypeMismatch().format({
|
|
70289
70377
|
entry: argIndex + 1
|
|
@@ -70293,14 +70381,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
70293
70381
|
}
|
|
70294
70382
|
}
|
|
70295
70383
|
} else {
|
|
70296
|
-
if (srcUnboundedIndex
|
|
70297
|
-
if (!destType.isUnpacked) {
|
|
70298
|
-
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.tupleSizeMismatchIndeterminate().format({
|
|
70299
|
-
expected: destTypeArgs.length
|
|
70300
|
-
}));
|
|
70301
|
-
return false;
|
|
70302
|
-
}
|
|
70303
|
-
} else {
|
|
70384
|
+
if (srcUnboundedIndex < 0) {
|
|
70304
70385
|
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.tupleSizeMismatch().format({
|
|
70305
70386
|
expected: destTypeArgs.length,
|
|
70306
70387
|
received: srcTypeArgs.length
|
|
@@ -70335,7 +70416,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
70335
70416
|
curSrcType = (0, typeUtils_1.specializeForBaseClass)(curSrcType, ancestorType);
|
|
70336
70417
|
}
|
|
70337
70418
|
if (ancestorIndex === 0 && destType.tupleTypeArguments && curSrcType.tupleTypeArguments) {
|
|
70338
|
-
return assignTupleTypeArgs(destType, curSrcType, diag,
|
|
70419
|
+
return assignTupleTypeArgs(destType, curSrcType, diag, destTypeVarContext, srcTypeVarContext, flags, recursionCount);
|
|
70339
70420
|
}
|
|
70340
70421
|
const ancestorTypeParams = types_1.ClassType.getTypeParameters(ancestorType);
|
|
70341
70422
|
if (ancestorTypeParams.length === 0) {
|
|
@@ -70406,6 +70487,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
70406
70487
|
destTypeArgs = destType.typeArguments;
|
|
70407
70488
|
srcTypeArgs = srcType.typeArguments;
|
|
70408
70489
|
}
|
|
70490
|
+
let isCompatible = true;
|
|
70409
70491
|
if (srcTypeArgs) {
|
|
70410
70492
|
for (let srcArgIndex = 0; srcArgIndex < srcTypeArgs.length; srcArgIndex++) {
|
|
70411
70493
|
const srcTypeArg = srcTypeArgs[srcArgIndex];
|
|
@@ -70426,7 +70508,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
70426
70508
|
diag.addAddendum(assignmentDiag);
|
|
70427
70509
|
}
|
|
70428
70510
|
}
|
|
70429
|
-
|
|
70511
|
+
isCompatible = false;
|
|
70430
70512
|
}
|
|
70431
70513
|
} else if (types_1.TypeVarType.getVariance(destTypeParam) === 4) {
|
|
70432
70514
|
if (!assignType(srcTypeArg, destTypeArg, assignmentDiag, srcTypeVarContext, destTypeVarContext, flags ^ 2 | 128, recursionCount)) {
|
|
@@ -70437,7 +70519,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
70437
70519
|
}));
|
|
70438
70520
|
childDiag.addAddendum(assignmentDiag);
|
|
70439
70521
|
}
|
|
70440
|
-
|
|
70522
|
+
isCompatible = false;
|
|
70441
70523
|
}
|
|
70442
70524
|
} else {
|
|
70443
70525
|
if (!assignType(destTypeArg, srcTypeArg, assignmentDiag, destTypeVarContext, srcTypeVarContext, flags | 1, recursionCount)) {
|
|
@@ -70449,13 +70531,13 @@ var require_typeEvaluator = __commonJS({
|
|
|
70449
70531
|
}));
|
|
70450
70532
|
childDiag.addAddendum(assignmentDiag);
|
|
70451
70533
|
}
|
|
70452
|
-
|
|
70534
|
+
isCompatible = false;
|
|
70453
70535
|
}
|
|
70454
70536
|
}
|
|
70455
70537
|
}
|
|
70456
70538
|
}
|
|
70457
70539
|
}
|
|
70458
|
-
return
|
|
70540
|
+
return isCompatible;
|
|
70459
70541
|
}
|
|
70460
70542
|
function assignType(destType, srcType, diag, destTypeVarContext, srcTypeVarContext, flags = 0, recursionCount = 0) {
|
|
70461
70543
|
var _a, _b;
|
|
@@ -70502,7 +70584,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
70502
70584
|
const originalFlags = flags;
|
|
70503
70585
|
flags &= ~64;
|
|
70504
70586
|
if ((0, types_1.isTypeVar)(destType)) {
|
|
70505
|
-
if ((0,
|
|
70587
|
+
if ((0, typeUtils_1.isTypeVarSame)(destType, srcType)) {
|
|
70506
70588
|
if (destType.scopeId && (destTypeVarContext === null || destTypeVarContext === void 0 ? void 0 : destTypeVarContext.hasSolveForScope(destType.scopeId))) {
|
|
70507
70589
|
return (0, constraintSolver_1.assignTypeToTypeVar)(evaluatorInterface, destType, srcType, diag, destTypeVarContext, flags, recursionCount);
|
|
70508
70590
|
}
|
|
@@ -70602,6 +70684,9 @@ var require_typeEvaluator = __commonJS({
|
|
|
70602
70684
|
}
|
|
70603
70685
|
}
|
|
70604
70686
|
if ((0, types_1.isNever)(srcType)) {
|
|
70687
|
+
if ((flags & 1) !== 0) {
|
|
70688
|
+
return (0, types_1.isNever)(destType);
|
|
70689
|
+
}
|
|
70605
70690
|
const targetTypeVarContext = (flags & 2) === 0 ? destTypeVarContext : srcTypeVarContext;
|
|
70606
70691
|
if (targetTypeVarContext) {
|
|
70607
70692
|
(0, typeUtils_1.setTypeArgumentsRecursive)(destType, types_1.UnknownType.create(), targetTypeVarContext, recursionCount);
|
|
@@ -70795,8 +70880,8 @@ var require_typeEvaluator = __commonJS({
|
|
|
70795
70880
|
if (destCallbackType) {
|
|
70796
70881
|
return assignType(destCallbackType, concreteSrcType, diag, destTypeVarContext, srcTypeVarContext, flags, recursionCount);
|
|
70797
70882
|
}
|
|
70798
|
-
if (
|
|
70799
|
-
return assignType(destType,
|
|
70883
|
+
if (functionObj && (0, types_1.isClassInstance)(functionObj)) {
|
|
70884
|
+
return assignType(destType, functionObj, diag, destTypeVarContext, srcTypeVarContext, flags, recursionCount);
|
|
70800
70885
|
}
|
|
70801
70886
|
} else if ((0, types_1.isModule)(concreteSrcType)) {
|
|
70802
70887
|
if (types_1.ClassType.isBuiltIn(destType, "ModuleType")) {
|
|
@@ -71531,7 +71616,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
71531
71616
|
if (srcDetails.params.length < destDetails.argsIndex) {
|
|
71532
71617
|
return;
|
|
71533
71618
|
}
|
|
71534
|
-
let srcLastToPackIndex = srcDetails.params.findIndex((p, i) => i >= destDetails.argsIndex && p.source ===
|
|
71619
|
+
let srcLastToPackIndex = srcDetails.params.findIndex((p, i) => i >= destDetails.argsIndex && p.source === parameterUtils_1.ParameterSource.KeywordOnly);
|
|
71535
71620
|
if (srcLastToPackIndex < 0) {
|
|
71536
71621
|
srcLastToPackIndex = srcDetails.params.length;
|
|
71537
71622
|
}
|
|
@@ -71578,7 +71663,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
71578
71663
|
},
|
|
71579
71664
|
type: srcPositionalsType,
|
|
71580
71665
|
index: -1,
|
|
71581
|
-
source:
|
|
71666
|
+
source: parameterUtils_1.ParameterSource.PositionOnly
|
|
71582
71667
|
},
|
|
71583
71668
|
...srcDetails.params.slice(destDetails.argsIndex + srcPositionalsToPack.length, srcDetails.params.length)
|
|
71584
71669
|
];
|
|
@@ -71592,9 +71677,9 @@ var require_typeEvaluator = __commonJS({
|
|
|
71592
71677
|
/* VarArgDictionary */
|
|
71593
71678
|
);
|
|
71594
71679
|
srcDetails.kwargsIndex = kwargsIndex >= 0 ? kwargsIndex : void 0;
|
|
71595
|
-
const firstKeywordOnlyIndex = srcDetails.params.findIndex((param) => param.source ===
|
|
71680
|
+
const firstKeywordOnlyIndex = srcDetails.params.findIndex((param) => param.source === parameterUtils_1.ParameterSource.KeywordOnly);
|
|
71596
71681
|
srcDetails.firstKeywordOnlyIndex = firstKeywordOnlyIndex >= 0 ? firstKeywordOnlyIndex : void 0;
|
|
71597
|
-
srcDetails.positionOnlyParamCount = Math.max(0, srcDetails.params.findIndex((p) => p.source !==
|
|
71682
|
+
srcDetails.positionOnlyParamCount = Math.max(0, srcDetails.params.findIndex((p) => p.source !== parameterUtils_1.ParameterSource.PositionOnly || p.param.category !== 0 || p.param.hasDefault));
|
|
71598
71683
|
}
|
|
71599
71684
|
}
|
|
71600
71685
|
function assignFunction(destType, srcType, diag, destTypeVarContext, srcTypeVarContext, flags, recursionCount) {
|
|
@@ -71604,8 +71689,8 @@ var require_typeEvaluator = __commonJS({
|
|
|
71604
71689
|
flags &= ~32;
|
|
71605
71690
|
destType = (0, typeUtils_1.removeParamSpecVariadicsFromFunction)(destType);
|
|
71606
71691
|
srcType = (0, typeUtils_1.removeParamSpecVariadicsFromFunction)(srcType);
|
|
71607
|
-
const destParamDetails = (0,
|
|
71608
|
-
const srcParamDetails = (0,
|
|
71692
|
+
const destParamDetails = (0, parameterUtils_1.getParameterListDetails)(destType);
|
|
71693
|
+
const srcParamDetails = (0, parameterUtils_1.getParameterListDetails)(srcType);
|
|
71609
71694
|
adjustSourceParamDetailsForDestVariadic(srcParamDetails, destParamDetails);
|
|
71610
71695
|
const targetIncludesParamSpec = (flags & 2) !== 0 ? !!srcType.details.paramSpec : !!destType.details.paramSpec;
|
|
71611
71696
|
const destPositionalCount = (_b = (_a = destParamDetails.argsIndex) !== null && _a !== void 0 ? _a : destParamDetails.firstKeywordOnlyIndex) !== null && _b !== void 0 ? _b : destParamDetails.params.length;
|
|
@@ -71619,7 +71704,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
71619
71704
|
const destParamName = (_e = destParam.param.name) !== null && _e !== void 0 ? _e : "";
|
|
71620
71705
|
const srcParamName = (_f = srcParam.param.name) !== null && _f !== void 0 ? _f : "";
|
|
71621
71706
|
if (destParamName && !(0, symbolNameUtils_1.isPrivateOrProtectedName)(destParamName) && !(0, symbolNameUtils_1.isPrivateOrProtectedName)(srcParamName)) {
|
|
71622
|
-
const isDestPositionalOnly = destParam.source ===
|
|
71707
|
+
const isDestPositionalOnly = destParam.source === parameterUtils_1.ParameterSource.PositionOnly;
|
|
71623
71708
|
if (!isDestPositionalOnly && destParam.param.category !== 1 && srcParam.param.category !== 1 && destParamName !== srcParamName) {
|
|
71624
71709
|
diag === null || diag === void 0 ? void 0 : diag.createAddendum().addMessage(localize_1.Localizer.DiagnosticAddendum.functionParamName().format({
|
|
71625
71710
|
srcName: srcParamName,
|
|
@@ -71690,7 +71775,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
71690
71775
|
if (!assignFunctionParameter(destParamType, srcArgsType, paramIndex, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), destTypeVarContext, srcTypeVarContext, flags, recursionCount)) {
|
|
71691
71776
|
canAssign = false;
|
|
71692
71777
|
}
|
|
71693
|
-
if (destParamDetails.params[paramIndex].source !==
|
|
71778
|
+
if (destParamDetails.params[paramIndex].source !== parameterUtils_1.ParameterSource.PositionOnly && srcParamDetails.kwargsIndex === void 0) {
|
|
71694
71779
|
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.namedParamMissingInSource().format({
|
|
71695
71780
|
name: (_g = destParamDetails.params[paramIndex].param.name) !== null && _g !== void 0 ? _g : ""
|
|
71696
71781
|
}));
|
|
@@ -72083,8 +72168,8 @@ var require_typeEvaluator = __commonJS({
|
|
|
72083
72168
|
}
|
|
72084
72169
|
function validateOverrideMethodInternal(baseMethod, overrideMethod, diag, enforceParamNames) {
|
|
72085
72170
|
var _a, _b;
|
|
72086
|
-
const baseParamDetails = (0,
|
|
72087
|
-
const overrideParamDetails = (0,
|
|
72171
|
+
const baseParamDetails = (0, parameterUtils_1.getParameterListDetails)(baseMethod);
|
|
72172
|
+
const overrideParamDetails = (0, parameterUtils_1.getParameterListDetails)(overrideMethod);
|
|
72088
72173
|
let canOverride = true;
|
|
72089
72174
|
if (types_1.FunctionType.isStaticMethod(baseMethod)) {
|
|
72090
72175
|
if (!types_1.FunctionType.isStaticMethod(overrideMethod)) {
|
|
@@ -72152,10 +72237,10 @@ var require_typeEvaluator = __commonJS({
|
|
|
72152
72237
|
}
|
|
72153
72238
|
const baseParam = baseParamDetails.params[i].param;
|
|
72154
72239
|
const overrideParam = overrideParamDetails.params[i].param;
|
|
72155
|
-
if (i >= baseParamDetails.positionOnlyParamCount && !(0, symbolNameUtils_1.isPrivateOrProtectedName)(baseParam.name || "") && baseParamDetails.params[i].source !==
|
|
72240
|
+
if (i >= baseParamDetails.positionOnlyParamCount && !(0, symbolNameUtils_1.isPrivateOrProtectedName)(baseParam.name || "") && baseParamDetails.params[i].source !== parameterUtils_1.ParameterSource.PositionOnly && baseParam.category === 0 && baseParam.name !== overrideParam.name) {
|
|
72156
72241
|
if (overrideParam.category === 0) {
|
|
72157
72242
|
if (enforceParamNames) {
|
|
72158
|
-
if (overrideParamDetails.params[i].source ===
|
|
72243
|
+
if (overrideParamDetails.params[i].source === parameterUtils_1.ParameterSource.PositionOnly) {
|
|
72159
72244
|
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideParamNamePositionOnly().format({
|
|
72160
72245
|
index: i + 1,
|
|
72161
72246
|
baseName: baseParam.name || "*"
|
|
@@ -72236,11 +72321,11 @@ var require_typeEvaluator = __commonJS({
|
|
|
72236
72321
|
}
|
|
72237
72322
|
}
|
|
72238
72323
|
const baseKwOnlyParams = baseParamDetails.params.filter(
|
|
72239
|
-
(paramInfo) => paramInfo.source ===
|
|
72324
|
+
(paramInfo) => paramInfo.source === parameterUtils_1.ParameterSource.KeywordOnly && paramInfo.param.category === 0
|
|
72240
72325
|
/* Simple */
|
|
72241
72326
|
);
|
|
72242
72327
|
const overrideWkOnlyParams = overrideParamDetails.params.filter(
|
|
72243
|
-
(paramInfo) => paramInfo.source ===
|
|
72328
|
+
(paramInfo) => paramInfo.source === parameterUtils_1.ParameterSource.KeywordOnly && paramInfo.param.category === 0
|
|
72244
72329
|
/* Simple */
|
|
72245
72330
|
);
|
|
72246
72331
|
baseKwOnlyParams.forEach((paramInfo) => {
|
|
@@ -72820,6 +72905,7 @@ var require_checker = __commonJS({
|
|
|
72820
72905
|
var declaration_1 = require_declaration();
|
|
72821
72906
|
var importResolver_1 = require_importResolver();
|
|
72822
72907
|
var importStatementUtils_1 = require_importStatementUtils();
|
|
72908
|
+
var parameterUtils_1 = require_parameterUtils();
|
|
72823
72909
|
var ParseTreeUtils = __importStar(require_parseTreeUtils());
|
|
72824
72910
|
var parseTreeWalker_1 = require_parseTreeWalker();
|
|
72825
72911
|
var patternMatching_1 = require_patternMatching();
|
|
@@ -75578,7 +75664,7 @@ var require_checker = __commonJS({
|
|
|
75578
75664
|
if (!(0, types_1.isFunction)(postInitType) || !types_1.FunctionType.isInstanceMethod(postInitType) || !postInitType.details.declaration) {
|
|
75579
75665
|
return;
|
|
75580
75666
|
}
|
|
75581
|
-
const paramListDetails = (0,
|
|
75667
|
+
const paramListDetails = (0, parameterUtils_1.getParameterListDetails)(postInitType);
|
|
75582
75668
|
if (paramListDetails.argsIndex !== void 0 || paramListDetails.kwargsIndex !== void 0 || paramListDetails.firstKeywordOnlyIndex !== void 0) {
|
|
75583
75669
|
return;
|
|
75584
75670
|
}
|
|
@@ -76105,6 +76191,7 @@ var require_checker = __commonJS({
|
|
|
76105
76191
|
});
|
|
76106
76192
|
}
|
|
76107
76193
|
_validateOverrideDecoratorPresent(overrideType, baseMember) {
|
|
76194
|
+
var _a;
|
|
76108
76195
|
if (this._fileInfo.diagnosticRuleSet.reportImplicitOverride === "none") {
|
|
76109
76196
|
return;
|
|
76110
76197
|
}
|
|
@@ -76113,10 +76200,21 @@ var require_checker = __commonJS({
|
|
|
76113
76200
|
overrideFunction = overrideType;
|
|
76114
76201
|
} else if ((0, types_1.isOverloadedFunction)(overrideType)) {
|
|
76115
76202
|
overrideFunction = types_1.OverloadedFunctionType.getImplementation(overrideType);
|
|
76203
|
+
} else if ((0, types_1.isClassInstance)(overrideType) && types_1.ClassType.isPropertyClass(overrideType)) {
|
|
76204
|
+
const fgetSymbol = overrideType.details.fields.get("fget");
|
|
76205
|
+
if (fgetSymbol) {
|
|
76206
|
+
const fgetType = (_a = this._evaluator.getDeclaredTypeOfSymbol(fgetSymbol)) === null || _a === void 0 ? void 0 : _a.type;
|
|
76207
|
+
if (fgetType && (0, types_1.isFunction)(fgetType)) {
|
|
76208
|
+
overrideFunction = fgetType;
|
|
76209
|
+
}
|
|
76210
|
+
}
|
|
76116
76211
|
}
|
|
76117
76212
|
if (!(overrideFunction === null || overrideFunction === void 0 ? void 0 : overrideFunction.details.declaration) || types_1.FunctionType.isOverridden(overrideFunction)) {
|
|
76118
76213
|
return;
|
|
76119
76214
|
}
|
|
76215
|
+
if (overrideFunction.details.name === "__init__" || overrideFunction.details.name === "__new__") {
|
|
76216
|
+
return;
|
|
76217
|
+
}
|
|
76120
76218
|
const funcNode = overrideFunction.details.declaration.node;
|
|
76121
76219
|
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportImplicitOverride, diagnosticRules_1.DiagnosticRule.reportImplicitOverride, localize_1.Localizer.Diagnostic.overrideDecoratorMissing().format({
|
|
76122
76220
|
name: funcNode.name.value,
|
|
@@ -76127,11 +76225,20 @@ var require_checker = __commonJS({
|
|
|
76127
76225
|
// decorator. In this case, an error is reported because no base class has declared
|
|
76128
76226
|
// a method of the same name.
|
|
76129
76227
|
_validateOverrideDecoratorNotPresent(overrideType) {
|
|
76228
|
+
var _a;
|
|
76130
76229
|
let overrideFunction;
|
|
76131
76230
|
if ((0, types_1.isFunction)(overrideType)) {
|
|
76132
76231
|
overrideFunction = overrideType;
|
|
76133
76232
|
} else if ((0, types_1.isOverloadedFunction)(overrideType)) {
|
|
76134
76233
|
overrideFunction = types_1.OverloadedFunctionType.getImplementation(overrideType);
|
|
76234
|
+
} else if ((0, types_1.isClassInstance)(overrideType) && types_1.ClassType.isPropertyClass(overrideType)) {
|
|
76235
|
+
const fgetSymbol = overrideType.details.fields.get("fget");
|
|
76236
|
+
if (fgetSymbol) {
|
|
76237
|
+
const fgetType = (_a = this._evaluator.getDeclaredTypeOfSymbol(fgetSymbol)) === null || _a === void 0 ? void 0 : _a.type;
|
|
76238
|
+
if (fgetType && (0, types_1.isFunction)(fgetType)) {
|
|
76239
|
+
overrideFunction = fgetType;
|
|
76240
|
+
}
|
|
76241
|
+
}
|
|
76135
76242
|
}
|
|
76136
76243
|
if (!(overrideFunction === null || overrideFunction === void 0 ? void 0 : overrideFunction.details.declaration) || !types_1.FunctionType.isOverridden(overrideFunction)) {
|
|
76137
76244
|
return;
|
|
@@ -76500,6 +76607,9 @@ var require_checker = __commonJS({
|
|
|
76500
76607
|
if (types_1.FunctionType.isOverloaded(functionType)) {
|
|
76501
76608
|
return;
|
|
76502
76609
|
}
|
|
76610
|
+
if ((0, types_1.isClassInstance)(paramType) && types_1.ClassType.isBuiltIn(paramType, "LiteralString") && types_1.ClassType.isBuiltIn(classType, "str")) {
|
|
76611
|
+
return;
|
|
76612
|
+
}
|
|
76503
76613
|
const typeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(functionType));
|
|
76504
76614
|
if (!this._evaluator.assignType(
|
|
76505
76615
|
paramType,
|
|
@@ -76669,10 +76779,11 @@ var require_checker = __commonJS({
|
|
|
76669
76779
|
});
|
|
76670
76780
|
}
|
|
76671
76781
|
_addDiagnosticForRegionComment(regionComment, message) {
|
|
76672
|
-
|
|
76673
|
-
|
|
76674
|
-
|
|
76675
|
-
|
|
76782
|
+
return this._evaluator.addDiagnosticForTextRange(this._fileInfo, "error", "", message, {
|
|
76783
|
+
// extend range to include # character
|
|
76784
|
+
start: regionComment.comment.start - 1,
|
|
76785
|
+
length: regionComment.comment.length + 1
|
|
76786
|
+
});
|
|
76676
76787
|
}
|
|
76677
76788
|
};
|
|
76678
76789
|
exports.Checker = Checker;
|
|
@@ -77551,7 +77662,7 @@ var require_sourceFile = __commonJS({
|
|
|
77551
77662
|
} catch (error) {
|
|
77552
77663
|
diagSink.addError(`Source file could not be read`, (0, textRange_1.getEmptyRange)());
|
|
77553
77664
|
fileContents = "";
|
|
77554
|
-
if (!this.fileSystem.existsSync(this.
|
|
77665
|
+
if (!this.fileSystem.existsSync(this._realFilePath)) {
|
|
77555
77666
|
this._isFileDeleted = true;
|
|
77556
77667
|
}
|
|
77557
77668
|
}
|