coc-pyright 1.1.310 → 1.1.315
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/lib/index.js +1436 -942
- package/package.json +7 -7
package/lib/index.js
CHANGED
|
@@ -191,7 +191,7 @@ var require_semver = __commonJS({
|
|
|
191
191
|
version = version.version;
|
|
192
192
|
}
|
|
193
193
|
} else if (typeof version !== "string") {
|
|
194
|
-
throw new TypeError(`Invalid
|
|
194
|
+
throw new TypeError(`Invalid version. Must be a string. Got type "${typeof version}".`);
|
|
195
195
|
}
|
|
196
196
|
if (version.length > MAX_LENGTH) {
|
|
197
197
|
throw new TypeError(
|
|
@@ -2569,95 +2569,91 @@ var require_isexe = __commonJS({
|
|
|
2569
2569
|
}
|
|
2570
2570
|
});
|
|
2571
2571
|
|
|
2572
|
-
// node_modules/which/
|
|
2573
|
-
var
|
|
2574
|
-
"node_modules/which/
|
|
2575
|
-
var isWindows = process.platform === "win32" || process.env.OSTYPE === "cygwin" || process.env.OSTYPE === "msys";
|
|
2576
|
-
var path12 = require("path");
|
|
2577
|
-
var COLON = isWindows ? ";" : ":";
|
|
2572
|
+
// node_modules/which/lib/index.js
|
|
2573
|
+
var require_lib = __commonJS({
|
|
2574
|
+
"node_modules/which/lib/index.js"(exports, module2) {
|
|
2578
2575
|
var isexe = require_isexe();
|
|
2576
|
+
var { join: join5, delimiter, sep, posix } = require("path");
|
|
2577
|
+
var isWindows = process.platform === "win32";
|
|
2578
|
+
var rSlash = new RegExp(`[${posix.sep}${sep === posix.sep ? "" : sep}]`.replace(/(\\)/g, "\\$1"));
|
|
2579
|
+
var rRel = new RegExp(`^\\.${rSlash.source}`);
|
|
2579
2580
|
var getNotFoundError = (cmd) => Object.assign(new Error(`not found: ${cmd}`), { code: "ENOENT" });
|
|
2580
|
-
var getPathInfo = (cmd,
|
|
2581
|
-
|
|
2582
|
-
|
|
2581
|
+
var getPathInfo = (cmd, {
|
|
2582
|
+
path: optPath = process.env.PATH,
|
|
2583
|
+
pathExt: optPathExt = process.env.PATHEXT,
|
|
2584
|
+
delimiter: optDelimiter = delimiter
|
|
2585
|
+
}) => {
|
|
2586
|
+
const pathEnv = cmd.match(rSlash) ? [""] : [
|
|
2583
2587
|
// windows always checks the cwd first
|
|
2584
2588
|
...isWindows ? [process.cwd()] : [],
|
|
2585
|
-
...(
|
|
2586
|
-
"").split(
|
|
2589
|
+
...(optPath || /* istanbul ignore next: very unusual */
|
|
2590
|
+
"").split(optDelimiter)
|
|
2587
2591
|
];
|
|
2588
|
-
const pathExtExe = isWindows ? opt.pathExt || process.env.PATHEXT || ".EXE;.CMD;.BAT;.COM" : "";
|
|
2589
|
-
const pathExt = isWindows ? pathExtExe.split(colon) : [""];
|
|
2590
2592
|
if (isWindows) {
|
|
2591
|
-
|
|
2593
|
+
const pathExtExe = optPathExt || [".EXE", ".CMD", ".BAT", ".COM"].join(optDelimiter);
|
|
2594
|
+
const pathExt = pathExtExe.split(optDelimiter).reduce((acc, item) => {
|
|
2595
|
+
acc.push(item);
|
|
2596
|
+
acc.push(item.toLowerCase());
|
|
2597
|
+
return acc;
|
|
2598
|
+
}, []);
|
|
2599
|
+
if (cmd.includes(".") && pathExt[0] !== "") {
|
|
2592
2600
|
pathExt.unshift("");
|
|
2601
|
+
}
|
|
2602
|
+
return { pathEnv, pathExt, pathExtExe };
|
|
2593
2603
|
}
|
|
2594
|
-
return {
|
|
2595
|
-
pathEnv,
|
|
2596
|
-
pathExt,
|
|
2597
|
-
pathExtExe
|
|
2598
|
-
};
|
|
2604
|
+
return { pathEnv, pathExt: [""] };
|
|
2599
2605
|
};
|
|
2600
|
-
var
|
|
2601
|
-
|
|
2602
|
-
|
|
2603
|
-
|
|
2604
|
-
|
|
2605
|
-
|
|
2606
|
-
opt = {};
|
|
2606
|
+
var getPathPart = (raw, cmd) => {
|
|
2607
|
+
const pathPart = /^".*"$/.test(raw) ? raw.slice(1, -1) : raw;
|
|
2608
|
+
const prefix = !pathPart && rRel.test(cmd) ? cmd.slice(0, 2) : "";
|
|
2609
|
+
return prefix + join5(pathPart, cmd);
|
|
2610
|
+
};
|
|
2611
|
+
var which6 = async (cmd, opt = {}) => {
|
|
2607
2612
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
2608
2613
|
const found = [];
|
|
2609
|
-
|
|
2610
|
-
|
|
2611
|
-
|
|
2612
|
-
|
|
2613
|
-
|
|
2614
|
-
|
|
2615
|
-
|
|
2616
|
-
|
|
2617
|
-
|
|
2618
|
-
|
|
2619
|
-
if (ii === pathExt.length)
|
|
2620
|
-
return resolve(step(i + 1));
|
|
2621
|
-
const ext = pathExt[ii];
|
|
2622
|
-
isexe(p + ext, { pathExt: pathExtExe }, (er, is) => {
|
|
2623
|
-
if (!er && is) {
|
|
2624
|
-
if (opt.all)
|
|
2625
|
-
found.push(p + ext);
|
|
2626
|
-
else
|
|
2627
|
-
return resolve(p + ext);
|
|
2614
|
+
for (const envPart of pathEnv) {
|
|
2615
|
+
const p = getPathPart(envPart, cmd);
|
|
2616
|
+
for (const ext of pathExt) {
|
|
2617
|
+
const withExt = p + ext;
|
|
2618
|
+
const is = await isexe(withExt, { pathExt: pathExtExe, ignoreErrors: true });
|
|
2619
|
+
if (is) {
|
|
2620
|
+
if (!opt.all) {
|
|
2621
|
+
return withExt;
|
|
2622
|
+
}
|
|
2623
|
+
found.push(withExt);
|
|
2628
2624
|
}
|
|
2629
|
-
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2627
|
+
if (opt.all && found.length) {
|
|
2628
|
+
return found;
|
|
2629
|
+
}
|
|
2630
|
+
if (opt.nothrow) {
|
|
2631
|
+
return null;
|
|
2632
|
+
}
|
|
2633
|
+
throw getNotFoundError(cmd);
|
|
2633
2634
|
};
|
|
2634
|
-
var whichSync = (cmd, opt) => {
|
|
2635
|
-
opt = opt || {};
|
|
2635
|
+
var whichSync = (cmd, opt = {}) => {
|
|
2636
2636
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
2637
2637
|
const found = [];
|
|
2638
|
-
for (
|
|
2639
|
-
const
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
const is = isexe.sync(cur, { pathExt: pathExtExe });
|
|
2647
|
-
if (is) {
|
|
2648
|
-
if (opt.all)
|
|
2649
|
-
found.push(cur);
|
|
2650
|
-
else
|
|
2651
|
-
return cur;
|
|
2638
|
+
for (const pathEnvPart of pathEnv) {
|
|
2639
|
+
const p = getPathPart(pathEnvPart, cmd);
|
|
2640
|
+
for (const ext of pathExt) {
|
|
2641
|
+
const withExt = p + ext;
|
|
2642
|
+
const is = isexe.sync(withExt, { pathExt: pathExtExe, ignoreErrors: true });
|
|
2643
|
+
if (is) {
|
|
2644
|
+
if (!opt.all) {
|
|
2645
|
+
return withExt;
|
|
2652
2646
|
}
|
|
2653
|
-
|
|
2647
|
+
found.push(withExt);
|
|
2654
2648
|
}
|
|
2655
2649
|
}
|
|
2656
2650
|
}
|
|
2657
|
-
if (opt.all && found.length)
|
|
2651
|
+
if (opt.all && found.length) {
|
|
2658
2652
|
return found;
|
|
2659
|
-
|
|
2653
|
+
}
|
|
2654
|
+
if (opt.nothrow) {
|
|
2660
2655
|
return null;
|
|
2656
|
+
}
|
|
2661
2657
|
throw getNotFoundError(cmd);
|
|
2662
2658
|
};
|
|
2663
2659
|
module2.exports = which6;
|
|
@@ -4974,7 +4970,7 @@ var require_move2 = __commonJS({
|
|
|
4974
4970
|
});
|
|
4975
4971
|
|
|
4976
4972
|
// node_modules/fs-extra/lib/index.js
|
|
4977
|
-
var
|
|
4973
|
+
var require_lib2 = __commonJS({
|
|
4978
4974
|
"node_modules/fs-extra/lib/index.js"(exports, module2) {
|
|
4979
4975
|
"use strict";
|
|
4980
4976
|
module2.exports = {
|
|
@@ -18494,9 +18490,9 @@ var require_package_nls_en_us = __commonJS({
|
|
|
18494
18490
|
functionInConditionalExpression: "Conditional expression references function which always evaluates to True",
|
|
18495
18491
|
functionTypeParametersIllegal: "Function type parameter syntax requires Python 3.12 or newer",
|
|
18496
18492
|
futureImportLocationNotAllowed: "Imports from __future__ must be at the beginning of the file",
|
|
18497
|
-
generatorAsyncReturnType: 'Return type of async generator function must be "AsyncGenerator
|
|
18493
|
+
generatorAsyncReturnType: 'Return type of async generator function must be compatible with "AsyncGenerator[{yieldType}, Any]"',
|
|
18498
18494
|
generatorNotParenthesized: "Generator expressions must be parenthesized if not sole argument",
|
|
18499
|
-
generatorSyncReturnType: 'Return type of generator function must be "Generator
|
|
18495
|
+
generatorSyncReturnType: 'Return type of generator function must be compatible with "Generator[{yieldType}, Any, Any]"',
|
|
18500
18496
|
genericBaseClassNotAllowed: '"Generic" base class cannot be used with type parameter syntax',
|
|
18501
18497
|
genericClassAssigned: "Generic class type cannot be assigned",
|
|
18502
18498
|
genericClassDeleted: "Generic class type cannot be deleted",
|
|
@@ -18828,6 +18824,7 @@ var require_package_nls_en_us = __commonJS({
|
|
|
18828
18824
|
unpackedArgInTypeArgument: "Unpacked arguments cannot be used in type argument lists",
|
|
18829
18825
|
unpackedArgWithVariadicParam: "Unpacked argument cannot be used for TypeVarTuple parameter",
|
|
18830
18826
|
unpackedDictArgumentNotMapping: 'Argument expression after ** must be a mapping with a "str" key type',
|
|
18827
|
+
unpackedDictSubscriptIllegal: "Dictionary unpack operator in subscript is not allowed",
|
|
18831
18828
|
unpackedSubscriptIllegal: "Unpack operator in subscript requires Python 3.11 or newer",
|
|
18832
18829
|
unpackedTypedDictArgument: "Unable to match unpacked TypedDict argument to parameters",
|
|
18833
18830
|
unpackedTypeVarTupleExpected: "Expected unpacked TypeVarTuple; use Unpack[{name1}] or *{name2}",
|
|
@@ -18860,7 +18857,6 @@ var require_package_nls_en_us = __commonJS({
|
|
|
18860
18857
|
yieldFromIllegal: 'Use of "yield from" requires Python 3.3 or newer',
|
|
18861
18858
|
yieldFromOutsideAsync: '"yield from" not allowed in an async function',
|
|
18862
18859
|
yieldOutsideFunction: '"yield" not allowed outside of a function or lambda',
|
|
18863
|
-
yieldTypeMismatch: 'Expression of type "{exprType}" cannot be assigned to yield type "{yieldType}"',
|
|
18864
18860
|
yieldWithinListCompr: '"yield" not allowed inside a list comprehension',
|
|
18865
18861
|
zeroCaseStatementsFound: "Match statement must include at least one case statement",
|
|
18866
18862
|
zeroLengthTupleNotAllowed: "Zero-length tuple not allowed in this context"
|
|
@@ -18929,6 +18925,8 @@ var require_package_nls_en_us = __commonJS({
|
|
|
18929
18925
|
overrideNotClassMethod: "Base method is declared as a classmethod but override is not",
|
|
18930
18926
|
overrideNotInstanceMethod: "Base method is declared as an instance method but override is not",
|
|
18931
18927
|
overrideNotStaticMethod: "Base method is declared as a staticmethod but override is not",
|
|
18928
|
+
overrideOverloadNoMatch: "Overload {index} is not compatible with base method",
|
|
18929
|
+
overrideOverloadOrder: "Overloads for override method must be in the same order as the base method",
|
|
18932
18930
|
overrideParamKeywordNoDefault: 'Keyword parameter "{name}" mismatch: base parameter has default argument value, override parameter does not',
|
|
18933
18931
|
overrideParamKeywordType: 'Keyword parameter "{name}" type mismatch: base parameter is type "{baseType}", override parameter is type "{overrideType}"',
|
|
18934
18932
|
overrideParamName: 'Parameter {index} name mismatch: base parameter is named "{baseName}", override parameter is named "{overrideName}"',
|
|
@@ -19395,9 +19393,9 @@ var require_localize = __commonJS({
|
|
|
19395
19393
|
Diagnostic6.functionInConditionalExpression = () => getRawString("Diagnostic.functionInConditionalExpression");
|
|
19396
19394
|
Diagnostic6.functionTypeParametersIllegal = () => getRawString("Diagnostic.functionTypeParametersIllegal");
|
|
19397
19395
|
Diagnostic6.futureImportLocationNotAllowed = () => getRawString("Diagnostic.futureImportLocationNotAllowed");
|
|
19398
|
-
Diagnostic6.generatorAsyncReturnType = () => getRawString("Diagnostic.generatorAsyncReturnType");
|
|
19396
|
+
Diagnostic6.generatorAsyncReturnType = () => new ParameterizedString(getRawString("Diagnostic.generatorAsyncReturnType"));
|
|
19399
19397
|
Diagnostic6.generatorNotParenthesized = () => getRawString("Diagnostic.generatorNotParenthesized");
|
|
19400
|
-
Diagnostic6.generatorSyncReturnType = () => getRawString("Diagnostic.generatorSyncReturnType");
|
|
19398
|
+
Diagnostic6.generatorSyncReturnType = () => new ParameterizedString(getRawString("Diagnostic.generatorSyncReturnType"));
|
|
19401
19399
|
Diagnostic6.genericBaseClassNotAllowed = () => getRawString("Diagnostic.genericBaseClassNotAllowed");
|
|
19402
19400
|
Diagnostic6.genericClassAssigned = () => getRawString("Diagnostic.genericClassAssigned");
|
|
19403
19401
|
Diagnostic6.genericClassDeleted = () => getRawString("Diagnostic.genericClassDeleted");
|
|
@@ -19728,6 +19726,7 @@ var require_localize = __commonJS({
|
|
|
19728
19726
|
Diagnostic6.unpackedArgInTypeArgument = () => getRawString("Diagnostic.unpackedArgInTypeArgument");
|
|
19729
19727
|
Diagnostic6.unpackedArgWithVariadicParam = () => getRawString("Diagnostic.unpackedArgWithVariadicParam");
|
|
19730
19728
|
Diagnostic6.unpackedDictArgumentNotMapping = () => getRawString("Diagnostic.unpackedDictArgumentNotMapping");
|
|
19729
|
+
Diagnostic6.unpackedDictSubscriptIllegal = () => getRawString("Diagnostic.unpackedDictSubscriptIllegal");
|
|
19731
19730
|
Diagnostic6.unpackedSubscriptIllegal = () => getRawString("Diagnostic.unpackedSubscriptIllegal");
|
|
19732
19731
|
Diagnostic6.unpackedTypedDictArgument = () => getRawString("Diagnostic.unpackedTypedDictArgument");
|
|
19733
19732
|
Diagnostic6.unpackedTypeVarTupleExpected = () => new ParameterizedString(getRawString("Diagnostic.unpackedTypeVarTupleExpected"));
|
|
@@ -19760,7 +19759,6 @@ var require_localize = __commonJS({
|
|
|
19760
19759
|
Diagnostic6.yieldFromIllegal = () => getRawString("Diagnostic.yieldFromIllegal");
|
|
19761
19760
|
Diagnostic6.yieldFromOutsideAsync = () => getRawString("Diagnostic.yieldFromOutsideAsync");
|
|
19762
19761
|
Diagnostic6.yieldOutsideFunction = () => getRawString("Diagnostic.yieldOutsideFunction");
|
|
19763
|
-
Diagnostic6.yieldTypeMismatch = () => new ParameterizedString(getRawString("Diagnostic.yieldTypeMismatch"));
|
|
19764
19762
|
Diagnostic6.yieldWithinListCompr = () => getRawString("Diagnostic.yieldWithinListCompr");
|
|
19765
19763
|
Diagnostic6.zeroCaseStatementsFound = () => getRawString("Diagnostic.zeroCaseStatementsFound");
|
|
19766
19764
|
Diagnostic6.zeroLengthTupleNotAllowed = () => getRawString("Diagnostic.zeroLengthTupleNotAllowed");
|
|
@@ -19830,6 +19828,8 @@ var require_localize = __commonJS({
|
|
|
19830
19828
|
DiagnosticAddendum2.overrideNotClassMethod = () => getRawString("DiagnosticAddendum.overrideNotClassMethod");
|
|
19831
19829
|
DiagnosticAddendum2.overrideNotInstanceMethod = () => getRawString("DiagnosticAddendum.overrideNotInstanceMethod");
|
|
19832
19830
|
DiagnosticAddendum2.overrideNotStaticMethod = () => getRawString("DiagnosticAddendum.overrideNotStaticMethod");
|
|
19831
|
+
DiagnosticAddendum2.overrideOverloadNoMatch = () => new ParameterizedString(getRawString("DiagnosticAddendum.overrideOverloadNoMatch"));
|
|
19832
|
+
DiagnosticAddendum2.overrideOverloadOrder = () => getRawString("DiagnosticAddendum.overrideOverloadOrder");
|
|
19833
19833
|
DiagnosticAddendum2.overrideParamKeywordNoDefault = () => new ParameterizedString(getRawString("DiagnosticAddendum.overrideParamKeywordNoDefault"));
|
|
19834
19834
|
DiagnosticAddendum2.overrideParamKeywordType = () => new ParameterizedString(getRawString("DiagnosticAddendum.overrideParamKeywordType"));
|
|
19835
19835
|
DiagnosticAddendum2.overrideParamName = () => new ParameterizedString(getRawString("DiagnosticAddendum.overrideParamName"));
|
|
@@ -29214,13 +29214,17 @@ var require_types = __commonJS({
|
|
|
29214
29214
|
function create(overloads) {
|
|
29215
29215
|
const newType = {
|
|
29216
29216
|
category: 6,
|
|
29217
|
-
overloads,
|
|
29217
|
+
overloads: [],
|
|
29218
29218
|
flags: 2
|
|
29219
29219
|
};
|
|
29220
|
+
overloads.forEach((overload) => {
|
|
29221
|
+
OverloadedFunctionType2.addOverload(newType, overload);
|
|
29222
|
+
});
|
|
29220
29223
|
return newType;
|
|
29221
29224
|
}
|
|
29222
29225
|
OverloadedFunctionType2.create = create;
|
|
29223
29226
|
function addOverload(type, functionType) {
|
|
29227
|
+
functionType.overloaded = type;
|
|
29224
29228
|
type.overloads.push(functionType);
|
|
29225
29229
|
}
|
|
29226
29230
|
OverloadedFunctionType2.addOverload = addOverload;
|
|
@@ -29546,13 +29550,18 @@ var require_types = __commonJS({
|
|
|
29546
29550
|
return newInstance;
|
|
29547
29551
|
}
|
|
29548
29552
|
TypeVarType2.cloneAsSpecializedSelf = cloneAsSpecializedSelf;
|
|
29549
|
-
function cloneAsInScopePlaceholder(type) {
|
|
29553
|
+
function cloneAsInScopePlaceholder(type, usageOffset) {
|
|
29550
29554
|
if (type.isInScopePlaceholder) {
|
|
29551
29555
|
return type;
|
|
29552
29556
|
}
|
|
29557
|
+
let newNameWithScope = type.nameWithScope;
|
|
29558
|
+
if (usageOffset) {
|
|
29559
|
+
newNameWithScope = `${type.nameWithScope}-${usageOffset}`;
|
|
29560
|
+
}
|
|
29553
29561
|
const newInstance = TypeBase.cloneType(type);
|
|
29554
29562
|
newInstance.isInScopePlaceholder = true;
|
|
29555
29563
|
newInstance.scopeId = exports.InScopePlaceholderScopeId;
|
|
29564
|
+
newInstance.nameWithScope = newNameWithScope;
|
|
29556
29565
|
return newInstance;
|
|
29557
29566
|
}
|
|
29558
29567
|
TypeVarType2.cloneAsInScopePlaceholder = cloneAsInScopePlaceholder;
|
|
@@ -29593,10 +29602,7 @@ var require_types = __commonJS({
|
|
|
29593
29602
|
function getVariance(type) {
|
|
29594
29603
|
var _a;
|
|
29595
29604
|
const variance = (_a = type.computedVariance) !== null && _a !== void 0 ? _a : type.details.declaredVariance;
|
|
29596
|
-
(0, debug_1.assert)(
|
|
29597
|
-
variance !== 0
|
|
29598
|
-
/* Auto */
|
|
29599
|
-
);
|
|
29605
|
+
(0, debug_1.assert)(variance !== 0, "Expected variance to be inferred");
|
|
29600
29606
|
return variance;
|
|
29601
29607
|
}
|
|
29602
29608
|
TypeVarType2.getVariance = getVariance;
|
|
@@ -29781,7 +29787,7 @@ var require_types = __commonJS({
|
|
|
29781
29787
|
if (!ClassType.isLiteralValueSame(type1, classType2)) {
|
|
29782
29788
|
return false;
|
|
29783
29789
|
}
|
|
29784
|
-
if (!ClassType.isTypedDictNarrowedEntriesSame(type1, classType2)) {
|
|
29790
|
+
if (!options.ignoreTypedDictNarrowEntries && !ClassType.isTypedDictNarrowedEntriesSame(type1, classType2)) {
|
|
29785
29791
|
return false;
|
|
29786
29792
|
}
|
|
29787
29793
|
return true;
|
|
@@ -29817,19 +29823,17 @@ var require_types = __commonJS({
|
|
|
29817
29823
|
return false;
|
|
29818
29824
|
}
|
|
29819
29825
|
}
|
|
29820
|
-
|
|
29821
|
-
|
|
29822
|
-
|
|
29823
|
-
if (
|
|
29824
|
-
|
|
29825
|
-
|
|
29826
|
-
|
|
29827
|
-
if (!isTypeSame(paramSpec1, paramSpec2, options, recursionCount)) {
|
|
29828
|
-
return false;
|
|
29829
|
-
}
|
|
29830
|
-
} else if (paramSpec2) {
|
|
29826
|
+
const paramSpec1 = type1.details.paramSpec;
|
|
29827
|
+
const paramSpec2 = functionType2.details.paramSpec;
|
|
29828
|
+
if (paramSpec1) {
|
|
29829
|
+
if (!paramSpec2) {
|
|
29830
|
+
return false;
|
|
29831
|
+
}
|
|
29832
|
+
if (!isTypeSame(paramSpec1, paramSpec2, options, recursionCount)) {
|
|
29831
29833
|
return false;
|
|
29832
29834
|
}
|
|
29835
|
+
} else if (paramSpec2) {
|
|
29836
|
+
return false;
|
|
29833
29837
|
}
|
|
29834
29838
|
let return1Type = type1.details.declaredReturnType;
|
|
29835
29839
|
if (type1.specializedTypes && type1.specializedTypes.returnType) {
|
|
@@ -30213,6 +30217,7 @@ var require_typeVarContext = __commonJS({
|
|
|
30213
30217
|
exports.TypeVarContext = exports.TypeVarSignatureContext = void 0;
|
|
30214
30218
|
var debug_1 = require_debug2();
|
|
30215
30219
|
var types_1 = require_types();
|
|
30220
|
+
var maxSignatureContextCount = 64;
|
|
30216
30221
|
var TypeVarSignatureContext = class {
|
|
30217
30222
|
constructor() {
|
|
30218
30223
|
this._typeVarMap = /* @__PURE__ */ new Map();
|
|
@@ -30419,7 +30424,9 @@ var require_typeVarContext = __commonJS({
|
|
|
30419
30424
|
// Copy the specified signature contexts into this type var context.
|
|
30420
30425
|
copySignatureContexts(contexts) {
|
|
30421
30426
|
(0, debug_1.assert)(contexts.length > 0);
|
|
30422
|
-
|
|
30427
|
+
if (contexts.length < maxSignatureContextCount) {
|
|
30428
|
+
this._signatureContexts = Array.from(contexts);
|
|
30429
|
+
}
|
|
30423
30430
|
}
|
|
30424
30431
|
// Returns the list of scopes this type var map is "solving".
|
|
30425
30432
|
getSolveForScopes() {
|
|
@@ -30511,19 +30518,172 @@ var require_typeVarContext = __commonJS({
|
|
|
30511
30518
|
}
|
|
30512
30519
|
});
|
|
30513
30520
|
|
|
30521
|
+
// node_modules/@zzzen/pyright-internal/dist/analyzer/typeWalker.js
|
|
30522
|
+
var require_typeWalker = __commonJS({
|
|
30523
|
+
"node_modules/@zzzen/pyright-internal/dist/analyzer/typeWalker.js"(exports) {
|
|
30524
|
+
"use strict";
|
|
30525
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30526
|
+
exports.TypeWalker = void 0;
|
|
30527
|
+
var debug_1 = require_debug2();
|
|
30528
|
+
var types_1 = require_types();
|
|
30529
|
+
var TypeWalker = class {
|
|
30530
|
+
constructor() {
|
|
30531
|
+
this._recursionCount = 0;
|
|
30532
|
+
this._isWalkCanceled = false;
|
|
30533
|
+
this._hitRecursionLimit = false;
|
|
30534
|
+
}
|
|
30535
|
+
get isRecursionLimitHit() {
|
|
30536
|
+
return this._hitRecursionLimit;
|
|
30537
|
+
}
|
|
30538
|
+
get isWalkCanceled() {
|
|
30539
|
+
return this._isWalkCanceled;
|
|
30540
|
+
}
|
|
30541
|
+
walk(type) {
|
|
30542
|
+
if (this._recursionCount > types_1.maxTypeRecursionCount) {
|
|
30543
|
+
this._hitRecursionLimit = true;
|
|
30544
|
+
return;
|
|
30545
|
+
}
|
|
30546
|
+
if (this._isWalkCanceled) {
|
|
30547
|
+
return;
|
|
30548
|
+
}
|
|
30549
|
+
this._recursionCount++;
|
|
30550
|
+
if (type.typeAliasInfo) {
|
|
30551
|
+
this.visitTypeAlias(type);
|
|
30552
|
+
}
|
|
30553
|
+
switch (type.category) {
|
|
30554
|
+
case 0:
|
|
30555
|
+
this.visitUnbound(type);
|
|
30556
|
+
break;
|
|
30557
|
+
case 2:
|
|
30558
|
+
this.visitAny(type);
|
|
30559
|
+
break;
|
|
30560
|
+
case 1:
|
|
30561
|
+
this.visitUnknown(type);
|
|
30562
|
+
break;
|
|
30563
|
+
case 3:
|
|
30564
|
+
this.visitNone(type);
|
|
30565
|
+
break;
|
|
30566
|
+
case 4:
|
|
30567
|
+
this.visitNever(type);
|
|
30568
|
+
break;
|
|
30569
|
+
case 5:
|
|
30570
|
+
this.visitFunction(type);
|
|
30571
|
+
break;
|
|
30572
|
+
case 6:
|
|
30573
|
+
this.visitOverloadedFunction(type);
|
|
30574
|
+
break;
|
|
30575
|
+
case 7:
|
|
30576
|
+
this.visitClass(type);
|
|
30577
|
+
break;
|
|
30578
|
+
case 8:
|
|
30579
|
+
this.visitModule(type);
|
|
30580
|
+
break;
|
|
30581
|
+
case 9:
|
|
30582
|
+
this.visitUnion(type);
|
|
30583
|
+
break;
|
|
30584
|
+
case 10:
|
|
30585
|
+
this.visitTypeVar(type);
|
|
30586
|
+
break;
|
|
30587
|
+
default:
|
|
30588
|
+
(0, debug_1.assertNever)(type);
|
|
30589
|
+
}
|
|
30590
|
+
this._recursionCount--;
|
|
30591
|
+
}
|
|
30592
|
+
cancelWalk() {
|
|
30593
|
+
this._isWalkCanceled = true;
|
|
30594
|
+
}
|
|
30595
|
+
visitTypeAlias(type) {
|
|
30596
|
+
(0, debug_1.assert)(type.typeAliasInfo);
|
|
30597
|
+
if (type.typeAliasInfo.typeArguments) {
|
|
30598
|
+
for (const typeArg of type.typeAliasInfo.typeArguments) {
|
|
30599
|
+
this.walk(typeArg);
|
|
30600
|
+
if (this._isWalkCanceled) {
|
|
30601
|
+
break;
|
|
30602
|
+
}
|
|
30603
|
+
}
|
|
30604
|
+
}
|
|
30605
|
+
}
|
|
30606
|
+
visitUnbound(type) {
|
|
30607
|
+
}
|
|
30608
|
+
visitAny(type) {
|
|
30609
|
+
}
|
|
30610
|
+
visitUnknown(type) {
|
|
30611
|
+
}
|
|
30612
|
+
visitNone(type) {
|
|
30613
|
+
}
|
|
30614
|
+
visitNever(type) {
|
|
30615
|
+
}
|
|
30616
|
+
visitFunction(type) {
|
|
30617
|
+
var _a;
|
|
30618
|
+
for (let i = 0; i < type.details.parameters.length; i++) {
|
|
30619
|
+
if (type.details.parameters[i].name) {
|
|
30620
|
+
const paramType = types_1.FunctionType.getEffectiveParameterType(type, i);
|
|
30621
|
+
this.walk(paramType);
|
|
30622
|
+
if (this._isWalkCanceled) {
|
|
30623
|
+
break;
|
|
30624
|
+
}
|
|
30625
|
+
}
|
|
30626
|
+
}
|
|
30627
|
+
if (!this._isWalkCanceled && !types_1.FunctionType.isParamSpecValue(type)) {
|
|
30628
|
+
const returnType = (_a = type.details.declaredReturnType) !== null && _a !== void 0 ? _a : type.inferredReturnType;
|
|
30629
|
+
if (returnType) {
|
|
30630
|
+
this.walk(returnType);
|
|
30631
|
+
}
|
|
30632
|
+
}
|
|
30633
|
+
}
|
|
30634
|
+
visitOverloadedFunction(type) {
|
|
30635
|
+
for (const overload of type.overloads) {
|
|
30636
|
+
this.walk(overload);
|
|
30637
|
+
if (this._isWalkCanceled) {
|
|
30638
|
+
break;
|
|
30639
|
+
}
|
|
30640
|
+
}
|
|
30641
|
+
}
|
|
30642
|
+
visitClass(type) {
|
|
30643
|
+
var _a;
|
|
30644
|
+
if (!types_1.ClassType.isPseudoGenericClass(type)) {
|
|
30645
|
+
const typeArgs = ((_a = type.tupleTypeArguments) === null || _a === void 0 ? void 0 : _a.map((t) => t.type)) || type.typeArguments;
|
|
30646
|
+
if (typeArgs) {
|
|
30647
|
+
for (const argType of typeArgs) {
|
|
30648
|
+
this.walk(argType);
|
|
30649
|
+
if (this._isWalkCanceled) {
|
|
30650
|
+
break;
|
|
30651
|
+
}
|
|
30652
|
+
}
|
|
30653
|
+
}
|
|
30654
|
+
}
|
|
30655
|
+
}
|
|
30656
|
+
visitModule(type) {
|
|
30657
|
+
}
|
|
30658
|
+
visitUnion(type) {
|
|
30659
|
+
for (const subtype of type.subtypes) {
|
|
30660
|
+
this.walk(subtype);
|
|
30661
|
+
if (this._isWalkCanceled) {
|
|
30662
|
+
break;
|
|
30663
|
+
}
|
|
30664
|
+
}
|
|
30665
|
+
}
|
|
30666
|
+
visitTypeVar(type) {
|
|
30667
|
+
}
|
|
30668
|
+
};
|
|
30669
|
+
exports.TypeWalker = TypeWalker;
|
|
30670
|
+
}
|
|
30671
|
+
});
|
|
30672
|
+
|
|
30514
30673
|
// node_modules/@zzzen/pyright-internal/dist/analyzer/typeUtils.js
|
|
30515
30674
|
var require_typeUtils = __commonJS({
|
|
30516
30675
|
"node_modules/@zzzen/pyright-internal/dist/analyzer/typeUtils.js"(exports) {
|
|
30517
30676
|
"use strict";
|
|
30518
30677
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30519
|
-
exports.lookUpObjectMember = exports.getContainerDepth = exports.getProtocolSymbolsRecursive = exports.getProtocolSymbols = exports.transformExpectedType = exports.validateTypeVarDefault = exports.applyInScopePlaceholders = exports.applySourceContextTypeVarsToSignature = exports.applySourceContextTypeVars = exports.applySolvedTypeVars = exports.ensureFunctionSignaturesAreUnique = exports.populateTypeVarContextForSelfType = exports.partiallySpecializeType = exports.isUnboundedTupleClass = exports.isTupleClass = exports.isMaybeDescriptorInstance = exports.isDescriptorInstance = exports.isCallableType = exports.isProperty = exports.isEllipsisType = exports.getUnionSubtypeCount = exports.getLiteralTypeClassName = exports.containsLiteralType = exports.
|
|
30520
|
-
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.
|
|
30678
|
+
exports.lookUpClassMember = exports.lookUpObjectMember = exports.getContainerDepth = exports.getProtocolSymbolsRecursive = exports.getProtocolSymbols = exports.transformExpectedType = exports.validateTypeVarDefault = exports.applyInScopePlaceholders = exports.applySourceContextTypeVarsToSignature = exports.applySourceContextTypeVars = exports.applySolvedTypeVars = exports.ensureFunctionSignaturesAreUnique = exports.populateTypeVarContextForSelfType = exports.partiallySpecializeType = exports.isUnboundedTupleClass = exports.isTupleClass = exports.isMaybeDescriptorInstance = exports.isDescriptorInstance = exports.isCallableType = exports.isProperty = exports.isEllipsisType = exports.getUnionSubtypeCount = exports.getLiteralTypeClassName = exports.containsLiteralType = exports.isLiteralTypeOrUnion = exports.isLiteralType = exports.getSpecializedTupleType = exports.getTypeVarScopeIds = 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;
|
|
30679
|
+
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.containsAnyOrUnknown = exports.getMembersForModule = exports.getMembersForClass = exports.convertToInstantiable = exports.convertToInstance = exports.isEffectivelyInstantiable = exports.isMetaclassInstance = exports.isInstantiableMetaclass = exports.getGeneratorYieldType = exports.getDeclaredGeneratorReturnType = exports.synthesizeTypeVarForSelfCls = exports.derivesFromClassRecursive = exports.specializeForBaseClass = exports.buildTypeVarContext = exports.buildTypeVarContextFromSpecializedClass = exports.setTypeArgumentsRecursive = exports.specializeClassType = exports.isTypeVarLimitedToCallable = exports.getTypeVarArgumentsRecursive = exports.addTypeVarsToListIfUnique = exports.getClassFieldsRecursive = exports.getClassIterator = exports.getClassMemberIterator = void 0;
|
|
30521
30680
|
var collectionUtils_1 = require_collectionUtils();
|
|
30522
30681
|
var debug_1 = require_debug2();
|
|
30523
30682
|
var symbol_1 = require_symbol();
|
|
30524
30683
|
var symbolUtils_1 = require_symbolUtils();
|
|
30525
30684
|
var types_1 = require_types();
|
|
30526
30685
|
var typeVarContext_1 = require_typeVarContext();
|
|
30686
|
+
var typeWalker_1 = require_typeWalker();
|
|
30527
30687
|
var ClassMemberLookupFlags;
|
|
30528
30688
|
(function(ClassMemberLookupFlags2) {
|
|
30529
30689
|
ClassMemberLookupFlags2[ClassMemberLookupFlags2["Default"] = 0] = "Default";
|
|
@@ -30537,10 +30697,9 @@ var require_typeUtils = __commonJS({
|
|
|
30537
30697
|
var ClassIteratorFlags;
|
|
30538
30698
|
(function(ClassIteratorFlags2) {
|
|
30539
30699
|
ClassIteratorFlags2[ClassIteratorFlags2["Default"] = 0] = "Default";
|
|
30540
|
-
ClassIteratorFlags2[ClassIteratorFlags2["
|
|
30541
|
-
ClassIteratorFlags2[ClassIteratorFlags2["
|
|
30542
|
-
ClassIteratorFlags2[ClassIteratorFlags2["
|
|
30543
|
-
ClassIteratorFlags2[ClassIteratorFlags2["SkipTypeBaseClass"] = 8] = "SkipTypeBaseClass";
|
|
30700
|
+
ClassIteratorFlags2[ClassIteratorFlags2["SkipBaseClasses"] = 1] = "SkipBaseClasses";
|
|
30701
|
+
ClassIteratorFlags2[ClassIteratorFlags2["SkipObjectBaseClass"] = 2] = "SkipObjectBaseClass";
|
|
30702
|
+
ClassIteratorFlags2[ClassIteratorFlags2["SkipTypeBaseClass"] = 4] = "SkipTypeBaseClass";
|
|
30544
30703
|
})(ClassIteratorFlags = exports.ClassIteratorFlags || (exports.ClassIteratorFlags = {}));
|
|
30545
30704
|
var AssignTypeFlags;
|
|
30546
30705
|
(function(AssignTypeFlags2) {
|
|
@@ -30559,19 +30718,27 @@ var require_typeUtils = __commonJS({
|
|
|
30559
30718
|
})(AssignTypeFlags = exports.AssignTypeFlags || (exports.AssignTypeFlags = {}));
|
|
30560
30719
|
var UniqueSignatureTracker = class {
|
|
30561
30720
|
constructor() {
|
|
30562
|
-
this.
|
|
30721
|
+
this._signaturesSeen = [];
|
|
30563
30722
|
}
|
|
30564
30723
|
findSignature(signature) {
|
|
30565
|
-
|
|
30566
|
-
|
|
30724
|
+
let effectiveSignature = signature;
|
|
30725
|
+
if ((0, types_1.isFunction)(signature) && signature.overloaded) {
|
|
30726
|
+
effectiveSignature = signature.overloaded;
|
|
30727
|
+
}
|
|
30728
|
+
return this._signaturesSeen.find((s) => {
|
|
30729
|
+
return (0, types_1.isTypeSame)(effectiveSignature, s.type);
|
|
30567
30730
|
});
|
|
30568
30731
|
}
|
|
30569
|
-
addSignature(signature) {
|
|
30570
|
-
|
|
30732
|
+
addSignature(signature, offset) {
|
|
30733
|
+
var _a;
|
|
30734
|
+
const effectiveSignature = (_a = signature.overloaded) !== null && _a !== void 0 ? _a : signature;
|
|
30735
|
+
const existingSignature = this.findSignature(effectiveSignature);
|
|
30571
30736
|
if (existingSignature) {
|
|
30572
|
-
existingSignature.
|
|
30737
|
+
if (!existingSignature.expressionOffsets.some((o) => o === offset)) {
|
|
30738
|
+
existingSignature.expressionOffsets.push(offset);
|
|
30739
|
+
}
|
|
30573
30740
|
} else {
|
|
30574
|
-
this.
|
|
30741
|
+
this._signaturesSeen.push({ type: effectiveSignature, expressionOffsets: [offset] });
|
|
30575
30742
|
}
|
|
30576
30743
|
}
|
|
30577
30744
|
};
|
|
@@ -30612,11 +30779,11 @@ var require_typeUtils = __commonJS({
|
|
|
30612
30779
|
return isCompatible;
|
|
30613
30780
|
}
|
|
30614
30781
|
exports.isTypeVarSame = isTypeVarSame;
|
|
30615
|
-
function makeInferenceContext(expectedType, isTypeIncomplete) {
|
|
30782
|
+
function makeInferenceContext(expectedType, isTypeIncomplete, signatureTracker) {
|
|
30616
30783
|
if (!expectedType) {
|
|
30617
30784
|
return void 0;
|
|
30618
30785
|
}
|
|
30619
|
-
return { expectedType, isTypeIncomplete };
|
|
30786
|
+
return { expectedType, isTypeIncomplete, signatureTracker };
|
|
30620
30787
|
}
|
|
30621
30788
|
exports.makeInferenceContext = makeInferenceContext;
|
|
30622
30789
|
function mapSubtypes(type, callback) {
|
|
@@ -30981,49 +31148,28 @@ var require_typeUtils = __commonJS({
|
|
|
30981
31148
|
return false;
|
|
30982
31149
|
}
|
|
30983
31150
|
exports.isLiteralTypeOrUnion = isLiteralTypeOrUnion;
|
|
30984
|
-
function
|
|
30985
|
-
|
|
30986
|
-
|
|
30987
|
-
|
|
30988
|
-
|
|
30989
|
-
|
|
30990
|
-
if (predicate(type)) {
|
|
30991
|
-
return true;
|
|
30992
|
-
}
|
|
30993
|
-
if (includeTypeArgs && (0, types_1.isClass)(type)) {
|
|
30994
|
-
const typeArgs = ((_a = type.tupleTypeArguments) === null || _a === void 0 ? void 0 : _a.map((t) => t.type)) || type.typeArguments;
|
|
30995
|
-
if (typeArgs) {
|
|
30996
|
-
return typeArgs.some((typeArg) => containsType(typeArg, predicate, includeTypeArgs, recursionCount));
|
|
30997
|
-
}
|
|
30998
|
-
}
|
|
30999
|
-
if ((0, types_1.isUnion)(type)) {
|
|
31000
|
-
return type.subtypes.some((subtype) => containsType(subtype, predicate, includeTypeArgs, recursionCount));
|
|
31001
|
-
}
|
|
31002
|
-
if ((0, types_1.isOverloadedFunction)(type)) {
|
|
31003
|
-
return type.overloads.some((overload) => containsType(overload, predicate, includeTypeArgs, recursionCount));
|
|
31004
|
-
}
|
|
31005
|
-
if ((0, types_1.isFunction)(type)) {
|
|
31006
|
-
const returnType = types_1.FunctionType.getSpecializedReturnType(type);
|
|
31007
|
-
if (returnType && containsType(returnType, predicate, includeTypeArgs, recursionCount)) {
|
|
31008
|
-
return true;
|
|
31151
|
+
function containsLiteralType(type, includeTypeArgs = false) {
|
|
31152
|
+
class ContainsLiteralTypeWalker extends typeWalker_1.TypeWalker {
|
|
31153
|
+
constructor(_includeTypeArgs) {
|
|
31154
|
+
super();
|
|
31155
|
+
this._includeTypeArgs = _includeTypeArgs;
|
|
31156
|
+
this.foundLiteral = false;
|
|
31009
31157
|
}
|
|
31010
|
-
|
|
31011
|
-
|
|
31012
|
-
|
|
31013
|
-
|
|
31158
|
+
visitClass(classType) {
|
|
31159
|
+
if ((0, types_1.isClassInstance)(classType)) {
|
|
31160
|
+
if (isLiteralType(classType) || types_1.ClassType.isBuiltIn(classType, "LiteralString")) {
|
|
31161
|
+
this.foundLiteral = true;
|
|
31162
|
+
this.cancelWalk();
|
|
31163
|
+
}
|
|
31164
|
+
}
|
|
31165
|
+
if (this._includeTypeArgs) {
|
|
31166
|
+
super.visitClass(classType);
|
|
31014
31167
|
}
|
|
31015
31168
|
}
|
|
31016
31169
|
}
|
|
31017
|
-
|
|
31018
|
-
|
|
31019
|
-
|
|
31020
|
-
function containsLiteralType(type, includeTypeArgs = false, recursionCount = 0) {
|
|
31021
|
-
return containsType(type, (t) => {
|
|
31022
|
-
if (!(0, types_1.isClassInstance)(t)) {
|
|
31023
|
-
return false;
|
|
31024
|
-
}
|
|
31025
|
-
return isLiteralType(t) || types_1.ClassType.isBuiltIn(t, "LiteralString");
|
|
31026
|
-
}, includeTypeArgs, recursionCount);
|
|
31170
|
+
const walker = new ContainsLiteralTypeWalker(includeTypeArgs);
|
|
31171
|
+
walker.walk(type);
|
|
31172
|
+
return walker.foundLiteral;
|
|
31027
31173
|
}
|
|
31028
31174
|
exports.containsLiteralType = containsLiteralType;
|
|
31029
31175
|
function getLiteralTypeClassName(type) {
|
|
@@ -31119,11 +31265,7 @@ var require_typeUtils = __commonJS({
|
|
|
31119
31265
|
if (types_1.ClassType.isUnspecialized(contextClassType)) {
|
|
31120
31266
|
return type;
|
|
31121
31267
|
}
|
|
31122
|
-
const typeVarContext = buildTypeVarContextFromSpecializedClass(
|
|
31123
|
-
contextClassType,
|
|
31124
|
-
/* makeConcrete */
|
|
31125
|
-
void 0
|
|
31126
|
-
);
|
|
31268
|
+
const typeVarContext = buildTypeVarContextFromSpecializedClass(contextClassType);
|
|
31127
31269
|
if (selfClass) {
|
|
31128
31270
|
populateTypeVarContextForSelfType(typeVarContext, contextClassType, selfClass);
|
|
31129
31271
|
}
|
|
@@ -31139,8 +31281,8 @@ var require_typeUtils = __commonJS({
|
|
|
31139
31281
|
typeVarContext.setTypeVarType(synthesizedSelfTypeVar, convertToInstance(selfClass));
|
|
31140
31282
|
}
|
|
31141
31283
|
exports.populateTypeVarContextForSelfType = populateTypeVarContextForSelfType;
|
|
31142
|
-
function ensureFunctionSignaturesAreUnique(type, signatureTracker) {
|
|
31143
|
-
const transformer = new UniqueFunctionSignatureTransformer(signatureTracker);
|
|
31284
|
+
function ensureFunctionSignaturesAreUnique(type, signatureTracker, expressionOffset) {
|
|
31285
|
+
const transformer = new UniqueFunctionSignatureTransformer(signatureTracker, expressionOffset);
|
|
31144
31286
|
return transformer.apply(type, 0);
|
|
31145
31287
|
}
|
|
31146
31288
|
exports.ensureFunctionSignaturesAreUnique = ensureFunctionSignaturesAreUnique;
|
|
@@ -31207,8 +31349,8 @@ var require_typeUtils = __commonJS({
|
|
|
31207
31349
|
}
|
|
31208
31350
|
}
|
|
31209
31351
|
exports.validateTypeVarDefault = validateTypeVarDefault;
|
|
31210
|
-
function transformExpectedType(expectedType, liveTypeVarScopes) {
|
|
31211
|
-
const transformer = new ExpectedTypeTransformer(liveTypeVarScopes);
|
|
31352
|
+
function transformExpectedType(expectedType, liveTypeVarScopes, usageOffset) {
|
|
31353
|
+
const transformer = new ExpectedTypeTransformer(liveTypeVarScopes, usageOffset);
|
|
31212
31354
|
return transformer.apply(expectedType, 0);
|
|
31213
31355
|
}
|
|
31214
31356
|
exports.transformExpectedType = transformExpectedType;
|
|
@@ -31278,37 +31420,39 @@ var require_typeUtils = __commonJS({
|
|
|
31278
31420
|
return 1 + maxChildDepth;
|
|
31279
31421
|
}
|
|
31280
31422
|
exports.getContainerDepth = getContainerDepth;
|
|
31281
|
-
function lookUpObjectMember(objectType, memberName, flags = 0) {
|
|
31423
|
+
function lookUpObjectMember(objectType, memberName, flags = 0, skipMroClass) {
|
|
31282
31424
|
if ((0, types_1.isClassInstance)(objectType)) {
|
|
31283
|
-
return lookUpClassMember(objectType, memberName, flags);
|
|
31425
|
+
return lookUpClassMember(objectType, memberName, flags, skipMroClass);
|
|
31284
31426
|
}
|
|
31285
31427
|
return void 0;
|
|
31286
31428
|
}
|
|
31287
31429
|
exports.lookUpObjectMember = lookUpObjectMember;
|
|
31288
|
-
function lookUpClassMember(classType, memberName, flags = 0) {
|
|
31430
|
+
function lookUpClassMember(classType, memberName, flags = 0, skipMroClass) {
|
|
31289
31431
|
var _a;
|
|
31290
|
-
const memberItr = getClassMemberIterator(classType, memberName, flags);
|
|
31432
|
+
const memberItr = getClassMemberIterator(classType, memberName, flags, skipMroClass);
|
|
31291
31433
|
return (_a = memberItr.next()) === null || _a === void 0 ? void 0 : _a.value;
|
|
31292
31434
|
}
|
|
31293
31435
|
exports.lookUpClassMember = lookUpClassMember;
|
|
31294
|
-
function* getClassMemberIterator(classType, memberName, flags = 0) {
|
|
31436
|
+
function* getClassMemberIterator(classType, memberName, flags = 0, skipMroClass) {
|
|
31295
31437
|
const declaredTypesOnly = (flags & 16) !== 0;
|
|
31296
31438
|
let skippedUndeclaredType = false;
|
|
31297
31439
|
if ((0, types_1.isClass)(classType)) {
|
|
31298
31440
|
let classFlags = 0;
|
|
31299
31441
|
if (flags & 1) {
|
|
31300
|
-
|
|
31442
|
+
if ((0, types_1.isClass)(classType)) {
|
|
31443
|
+
skipMroClass = classType;
|
|
31444
|
+
}
|
|
31301
31445
|
}
|
|
31302
31446
|
if (flags & 2) {
|
|
31303
|
-
classFlags = classFlags |
|
|
31447
|
+
classFlags = classFlags | 1;
|
|
31304
31448
|
}
|
|
31305
31449
|
if (flags & 4) {
|
|
31306
|
-
classFlags = classFlags |
|
|
31450
|
+
classFlags = classFlags | 2;
|
|
31307
31451
|
}
|
|
31308
31452
|
if (flags & 32) {
|
|
31309
|
-
classFlags = classFlags |
|
|
31453
|
+
classFlags = classFlags | 4;
|
|
31310
31454
|
}
|
|
31311
|
-
const classItr = getClassIterator(classType, classFlags);
|
|
31455
|
+
const classItr = getClassIterator(classType, classFlags, skipMroClass);
|
|
31312
31456
|
for (const [mroClass, specializedMroClass] of classItr) {
|
|
31313
31457
|
if (!(0, types_1.isInstantiableClass)(mroClass)) {
|
|
31314
31458
|
if (!declaredTypesOnly) {
|
|
@@ -31394,23 +31538,29 @@ var require_typeUtils = __commonJS({
|
|
|
31394
31538
|
return void 0;
|
|
31395
31539
|
}
|
|
31396
31540
|
exports.getClassMemberIterator = getClassMemberIterator;
|
|
31397
|
-
function* getClassIterator(classType, flags = 0) {
|
|
31541
|
+
function* getClassIterator(classType, flags = 0, skipMroClass) {
|
|
31398
31542
|
if ((0, types_1.isClass)(classType)) {
|
|
31399
|
-
let
|
|
31543
|
+
let foundSkipMroClass = skipMroClass === void 0;
|
|
31400
31544
|
for (const mroClass of classType.details.mro) {
|
|
31401
|
-
if (
|
|
31402
|
-
|
|
31403
|
-
|
|
31545
|
+
if (!foundSkipMroClass && skipMroClass) {
|
|
31546
|
+
if (!(0, types_1.isClass)(mroClass)) {
|
|
31547
|
+
foundSkipMroClass = true;
|
|
31548
|
+
} else if (types_1.ClassType.isSameGenericClass(mroClass, skipMroClass)) {
|
|
31549
|
+
foundSkipMroClass = true;
|
|
31550
|
+
continue;
|
|
31551
|
+
} else {
|
|
31552
|
+
continue;
|
|
31553
|
+
}
|
|
31404
31554
|
}
|
|
31405
31555
|
const specializedMroClass = partiallySpecializeType(mroClass, classType);
|
|
31406
|
-
if (flags &
|
|
31556
|
+
if (flags & 2) {
|
|
31407
31557
|
if ((0, types_1.isInstantiableClass)(specializedMroClass)) {
|
|
31408
31558
|
if (types_1.ClassType.isBuiltIn(specializedMroClass, "object")) {
|
|
31409
31559
|
break;
|
|
31410
31560
|
}
|
|
31411
31561
|
}
|
|
31412
31562
|
}
|
|
31413
|
-
if (flags &
|
|
31563
|
+
if (flags & 4) {
|
|
31414
31564
|
if ((0, types_1.isInstantiableClass)(specializedMroClass)) {
|
|
31415
31565
|
if (types_1.ClassType.isBuiltIn(specializedMroClass, "type")) {
|
|
31416
31566
|
break;
|
|
@@ -31418,7 +31568,7 @@ var require_typeUtils = __commonJS({
|
|
|
31418
31568
|
}
|
|
31419
31569
|
}
|
|
31420
31570
|
yield [mroClass, specializedMroClass];
|
|
31421
|
-
if ((flags &
|
|
31571
|
+
if ((flags & 1) !== 0) {
|
|
31422
31572
|
break;
|
|
31423
31573
|
}
|
|
31424
31574
|
}
|
|
@@ -31660,13 +31810,9 @@ var require_typeUtils = __commonJS({
|
|
|
31660
31810
|
}
|
|
31661
31811
|
}
|
|
31662
31812
|
exports.setTypeArgumentsRecursive = setTypeArgumentsRecursive;
|
|
31663
|
-
function buildTypeVarContextFromSpecializedClass(classType
|
|
31813
|
+
function buildTypeVarContextFromSpecializedClass(classType) {
|
|
31664
31814
|
const typeParameters = types_1.ClassType.getTypeParameters(classType);
|
|
31665
|
-
|
|
31666
|
-
if (!typeArguments && !makeConcrete) {
|
|
31667
|
-
typeArguments = typeParameters;
|
|
31668
|
-
}
|
|
31669
|
-
const typeVarContext = buildTypeVarContext(typeParameters, typeArguments, getTypeVarScopeId(classType));
|
|
31815
|
+
const typeVarContext = buildTypeVarContext(typeParameters, classType.typeArguments, getTypeVarScopeId(classType));
|
|
31670
31816
|
if (types_1.ClassType.isTupleClass(classType) && classType.tupleTypeArguments && typeParameters.length >= 1) {
|
|
31671
31817
|
typeVarContext.setTupleTypeVar(typeParameters[0], classType.tupleTypeArguments);
|
|
31672
31818
|
}
|
|
@@ -31678,7 +31824,7 @@ var require_typeUtils = __commonJS({
|
|
|
31678
31824
|
typeParameters.forEach((typeParam, index) => {
|
|
31679
31825
|
let typeArgType;
|
|
31680
31826
|
if (typeArgs) {
|
|
31681
|
-
if (
|
|
31827
|
+
if (typeParam.details.isParamSpec) {
|
|
31682
31828
|
if (index < typeArgs.length) {
|
|
31683
31829
|
typeArgType = typeArgs[index];
|
|
31684
31830
|
if ((0, types_1.isFunction)(typeArgType) && types_1.FunctionType.isParamSpecValue(typeArgType)) {
|
|
@@ -31954,26 +32100,34 @@ var require_typeUtils = __commonJS({
|
|
|
31954
32100
|
});
|
|
31955
32101
|
}
|
|
31956
32102
|
exports.getMembersForModule = getMembersForModule;
|
|
31957
|
-
function containsAnyOrUnknown(type) {
|
|
31958
|
-
|
|
31959
|
-
|
|
31960
|
-
|
|
31961
|
-
|
|
32103
|
+
function containsAnyOrUnknown(type, recurse) {
|
|
32104
|
+
class AnyOrUnknownWalker extends typeWalker_1.TypeWalker {
|
|
32105
|
+
constructor(_recurse) {
|
|
32106
|
+
super();
|
|
32107
|
+
this._recurse = _recurse;
|
|
31962
32108
|
}
|
|
31963
|
-
|
|
31964
|
-
|
|
31965
|
-
}
|
|
31966
|
-
exports.containsAnyOrUnknown = containsAnyOrUnknown;
|
|
31967
|
-
function containsUnknown(type) {
|
|
31968
|
-
let foundUnknown = false;
|
|
31969
|
-
doForEachSubtype(type, (subtype) => {
|
|
31970
|
-
if ((0, types_1.isUnknown)(subtype)) {
|
|
31971
|
-
foundUnknown = true;
|
|
32109
|
+
visitUnknown(type2) {
|
|
32110
|
+
this.anyOrUnknownType = this.anyOrUnknownType ? preserveUnknown(this.anyOrUnknownType, type2) : type2;
|
|
31972
32111
|
}
|
|
31973
|
-
|
|
31974
|
-
|
|
32112
|
+
visitAny(type2) {
|
|
32113
|
+
this.anyOrUnknownType = this.anyOrUnknownType ? preserveUnknown(this.anyOrUnknownType, type2) : type2;
|
|
32114
|
+
}
|
|
32115
|
+
visitClass(type2) {
|
|
32116
|
+
if (this._recurse) {
|
|
32117
|
+
super.visitClass(type2);
|
|
32118
|
+
}
|
|
32119
|
+
}
|
|
32120
|
+
visitFunction(type2) {
|
|
32121
|
+
if (this._recurse) {
|
|
32122
|
+
super.visitFunction(type2);
|
|
32123
|
+
}
|
|
32124
|
+
}
|
|
32125
|
+
}
|
|
32126
|
+
const walker = new AnyOrUnknownWalker(recurse);
|
|
32127
|
+
walker.walk(type);
|
|
32128
|
+
return walker.anyOrUnknownType;
|
|
31975
32129
|
}
|
|
31976
|
-
exports.
|
|
32130
|
+
exports.containsAnyOrUnknown = containsAnyOrUnknown;
|
|
31977
32131
|
function isPartlyUnknown(type, allowUnknownTypeArgsForClasses = false, recursionCount = 0) {
|
|
31978
32132
|
var _a, _b;
|
|
31979
32133
|
if (recursionCount > types_1.maxTypeRecursionCount) {
|
|
@@ -32212,13 +32366,29 @@ var require_typeUtils = __commonJS({
|
|
|
32212
32366
|
return false;
|
|
32213
32367
|
}
|
|
32214
32368
|
recursionCount++;
|
|
32369
|
+
const canUseCache = !ignorePseudoGeneric && !ignoreSelf;
|
|
32370
|
+
if (canUseCache && ((_a = type.cached) === null || _a === void 0 ? void 0 : _a.requiresSpecialization) !== void 0) {
|
|
32371
|
+
return type.cached.requiresSpecialization;
|
|
32372
|
+
}
|
|
32373
|
+
const result = _requiresSpecialization(type, ignorePseudoGeneric, ignoreSelf, recursionCount);
|
|
32374
|
+
if (canUseCache) {
|
|
32375
|
+
if (type.cached === void 0) {
|
|
32376
|
+
type.cached = {};
|
|
32377
|
+
}
|
|
32378
|
+
type.cached.requiresSpecialization = result;
|
|
32379
|
+
}
|
|
32380
|
+
return result;
|
|
32381
|
+
}
|
|
32382
|
+
exports.requiresSpecialization = requiresSpecialization;
|
|
32383
|
+
function _requiresSpecialization(type, ignorePseudoGeneric = false, ignoreSelf = false, recursionCount = 0) {
|
|
32384
|
+
var _a;
|
|
32215
32385
|
switch (type.category) {
|
|
32216
32386
|
case 7: {
|
|
32217
32387
|
if (types_1.ClassType.isPseudoGenericClass(type) && ignorePseudoGeneric) {
|
|
32218
32388
|
return false;
|
|
32219
32389
|
}
|
|
32220
32390
|
if (type.typeArguments) {
|
|
32221
|
-
return type.typeArguments.
|
|
32391
|
+
return type.typeArguments.some((typeArg) => requiresSpecialization(typeArg, ignorePseudoGeneric, ignoreSelf, recursionCount));
|
|
32222
32392
|
}
|
|
32223
32393
|
return types_1.ClassType.getTypeParameters(type).length > 0;
|
|
32224
32394
|
}
|
|
@@ -32244,10 +32414,10 @@ var require_typeUtils = __commonJS({
|
|
|
32244
32414
|
return false;
|
|
32245
32415
|
}
|
|
32246
32416
|
case 6: {
|
|
32247
|
-
return type.overloads.
|
|
32417
|
+
return type.overloads.some((overload) => requiresSpecialization(overload, ignorePseudoGeneric, ignoreSelf, recursionCount));
|
|
32248
32418
|
}
|
|
32249
32419
|
case 9: {
|
|
32250
|
-
return
|
|
32420
|
+
return type.subtypes.some((subtype) => requiresSpecialization(subtype, ignorePseudoGeneric, ignoreSelf, recursionCount));
|
|
32251
32421
|
}
|
|
32252
32422
|
case 10: {
|
|
32253
32423
|
if (!type.details.recursiveTypeAliasName) {
|
|
@@ -32263,7 +32433,6 @@ var require_typeUtils = __commonJS({
|
|
|
32263
32433
|
}
|
|
32264
32434
|
return false;
|
|
32265
32435
|
}
|
|
32266
|
-
exports.requiresSpecialization = requiresSpecialization;
|
|
32267
32436
|
function combineVariances(variance1, variance2) {
|
|
32268
32437
|
if (variance1 === 1) {
|
|
32269
32438
|
return variance2;
|
|
@@ -32335,11 +32504,7 @@ var require_typeUtils = __commonJS({
|
|
|
32335
32504
|
const classListsToMerge = [];
|
|
32336
32505
|
filteredBaseClasses.forEach((baseClass) => {
|
|
32337
32506
|
if ((0, types_1.isInstantiableClass)(baseClass)) {
|
|
32338
|
-
const typeVarContext2 = buildTypeVarContextFromSpecializedClass(
|
|
32339
|
-
baseClass,
|
|
32340
|
-
/* makeConcrete */
|
|
32341
|
-
false
|
|
32342
|
-
);
|
|
32507
|
+
const typeVarContext2 = buildTypeVarContextFromSpecializedClass(baseClass);
|
|
32343
32508
|
classListsToMerge.push(baseClass.details.mro.map((mroClass) => {
|
|
32344
32509
|
return applySolvedTypeVars(mroClass, typeVarContext2);
|
|
32345
32510
|
}));
|
|
@@ -32348,18 +32513,10 @@ var require_typeUtils = __commonJS({
|
|
|
32348
32513
|
}
|
|
32349
32514
|
});
|
|
32350
32515
|
classListsToMerge.push(filteredBaseClasses.map((baseClass) => {
|
|
32351
|
-
const typeVarContext2 = buildTypeVarContextFromSpecializedClass(
|
|
32352
|
-
classType,
|
|
32353
|
-
/* makeConcrete */
|
|
32354
|
-
false
|
|
32355
|
-
);
|
|
32516
|
+
const typeVarContext2 = buildTypeVarContextFromSpecializedClass(classType);
|
|
32356
32517
|
return applySolvedTypeVars(baseClass, typeVarContext2);
|
|
32357
32518
|
}));
|
|
32358
|
-
const typeVarContext = buildTypeVarContextFromSpecializedClass(
|
|
32359
|
-
classType,
|
|
32360
|
-
/* makeConcrete */
|
|
32361
|
-
false
|
|
32362
|
-
);
|
|
32519
|
+
const typeVarContext = buildTypeVarContextFromSpecializedClass(classType);
|
|
32363
32520
|
classType.details.mro.push(applySolvedTypeVars(classType, typeVarContext));
|
|
32364
32521
|
function isInTail(searchClass, classLists) {
|
|
32365
32522
|
return classLists.some((classList) => {
|
|
@@ -32367,14 +32524,8 @@ var require_typeUtils = __commonJS({
|
|
|
32367
32524
|
});
|
|
32368
32525
|
}
|
|
32369
32526
|
function filterClass(classToFilter, classLists) {
|
|
32370
|
-
if ((classToFilter === null || classToFilter === void 0 ? void 0 : classToFilter.category) !== 7) {
|
|
32371
|
-
(0, debug_1.fail)(`Corrupted class type when computing MRO for ${classType.details.name}: ${JSON.stringify(classToFilter)}`);
|
|
32372
|
-
}
|
|
32373
32527
|
for (let i = 0; i < classLists.length; i++) {
|
|
32374
32528
|
classLists[i] = classLists[i].filter((value) => {
|
|
32375
|
-
if ((value === null || value === void 0 ? void 0 : value.category) === void 0) {
|
|
32376
|
-
(0, debug_1.fail)(`Unexpected undefined type when computing MRO for ${classType.details.name}: ${JSON.stringify(classLists)}`);
|
|
32377
|
-
}
|
|
32378
32529
|
return !(0, types_1.isInstantiableClass)(value) || !types_1.ClassType.isSameGenericClass(value, classToFilter);
|
|
32379
32530
|
});
|
|
32380
32531
|
}
|
|
@@ -32678,13 +32829,13 @@ var require_typeUtils = __commonJS({
|
|
|
32678
32829
|
return requiresUpdate ? types_1.TypeBase.cloneForTypeAlias(type, type.typeAliasInfo.name, type.typeAliasInfo.fullName, type.typeAliasInfo.typeVarScopeId, type.typeAliasInfo.typeParameters, newTypeArgs) : type;
|
|
32679
32830
|
}
|
|
32680
32831
|
transformTypeVarsInClassType(classType, recursionCount) {
|
|
32681
|
-
|
|
32832
|
+
const typeParams = types_1.ClassType.getTypeParameters(classType);
|
|
32833
|
+
if (typeParams.length === 0 && !types_1.ClassType.isSpecialBuiltIn(classType)) {
|
|
32682
32834
|
return classType;
|
|
32683
32835
|
}
|
|
32684
32836
|
let newTypeArgs;
|
|
32685
32837
|
let newTupleTypeArgs;
|
|
32686
32838
|
let specializationNeeded = false;
|
|
32687
|
-
const typeParams = types_1.ClassType.getTypeParameters(classType);
|
|
32688
32839
|
const transformParamSpec = (paramSpec) => {
|
|
32689
32840
|
const paramSpecValue = this.transformParamSpec(paramSpec, recursionCount);
|
|
32690
32841
|
if (paramSpecValue) {
|
|
@@ -32939,9 +33090,16 @@ var require_typeUtils = __commonJS({
|
|
|
32939
33090
|
}
|
|
32940
33091
|
};
|
|
32941
33092
|
var UniqueFunctionSignatureTransformer = class extends TypeVarTransformer {
|
|
32942
|
-
constructor(_signatureTracker) {
|
|
33093
|
+
constructor(_signatureTracker, _expressionOffset) {
|
|
32943
33094
|
super();
|
|
32944
33095
|
this._signatureTracker = _signatureTracker;
|
|
33096
|
+
this._expressionOffset = _expressionOffset;
|
|
33097
|
+
}
|
|
33098
|
+
transformGenericTypeAlias(type, recursionCount) {
|
|
33099
|
+
return type;
|
|
33100
|
+
}
|
|
33101
|
+
transformTypeVarsInClassType(classType, recursionCount) {
|
|
33102
|
+
return classType;
|
|
32945
33103
|
}
|
|
32946
33104
|
transformTypeVarsInFunctionType(sourceType, recursionCount) {
|
|
32947
33105
|
if (sourceType.details.typeParameters.length === 0) {
|
|
@@ -32951,13 +33109,23 @@ var require_typeUtils = __commonJS({
|
|
|
32951
33109
|
const existingSignature = this._signatureTracker.findSignature(sourceType);
|
|
32952
33110
|
if (existingSignature) {
|
|
32953
33111
|
const typeVarContext = new typeVarContext_1.TypeVarContext(getTypeVarScopeId(sourceType));
|
|
32954
|
-
|
|
32955
|
-
|
|
32956
|
-
|
|
33112
|
+
let offsetIndex = existingSignature.expressionOffsets.findIndex((offset) => offset === this._expressionOffset);
|
|
33113
|
+
if (offsetIndex < 0) {
|
|
33114
|
+
offsetIndex = existingSignature.expressionOffsets.length;
|
|
33115
|
+
}
|
|
33116
|
+
if (offsetIndex > 0) {
|
|
33117
|
+
sourceType.details.typeParameters.forEach((typeParam) => {
|
|
33118
|
+
let replacement = types_1.TypeVarType.cloneForNewName(typeParam, `${typeParam.details.name}(${offsetIndex})`);
|
|
33119
|
+
if (replacement.details.isParamSpec) {
|
|
33120
|
+
replacement = convertTypeToParamSpecValue(replacement);
|
|
33121
|
+
}
|
|
33122
|
+
typeVarContext.setTypeVarType(typeParam, replacement);
|
|
33123
|
+
});
|
|
32957
33124
|
updatedSourceType = applySolvedTypeVars(sourceType, typeVarContext);
|
|
32958
|
-
|
|
33125
|
+
(0, debug_1.assert)((0, types_1.isFunction)(updatedSourceType) || (0, types_1.isOverloadedFunction)(updatedSourceType));
|
|
33126
|
+
}
|
|
32959
33127
|
}
|
|
32960
|
-
this._signatureTracker.addSignature(sourceType);
|
|
33128
|
+
this._signatureTracker.addSignature(sourceType, this._expressionOffset);
|
|
32961
33129
|
return updatedSourceType;
|
|
32962
33130
|
}
|
|
32963
33131
|
};
|
|
@@ -33070,7 +33238,7 @@ var require_typeUtils = __commonJS({
|
|
|
33070
33238
|
return signatureContext.getTupleTypeVar(typeVar);
|
|
33071
33239
|
}
|
|
33072
33240
|
transformParamSpec(paramSpec, recursionCount) {
|
|
33073
|
-
var _a;
|
|
33241
|
+
var _a, _b;
|
|
33074
33242
|
const signatureContext = this._typeVarContext.getSignatureContext((_a = this._activeTypeVarSignatureContextIndex) !== null && _a !== void 0 ? _a : 0);
|
|
33075
33243
|
if (this._isSolvingDefaultType && !paramSpec.scopeId) {
|
|
33076
33244
|
const replacementEntry = signatureContext.getTypeVars().find((entry) => entry.typeVar.details.name === paramSpec.details.name);
|
|
@@ -33091,7 +33259,10 @@ var require_typeUtils = __commonJS({
|
|
|
33091
33259
|
}
|
|
33092
33260
|
let useDefaultOrUnknown = false;
|
|
33093
33261
|
if (this._options.unknownIfNotFound && !this._typeVarContext.hasSolveForScope(types_1.WildcardTypeVarScopeId)) {
|
|
33094
|
-
|
|
33262
|
+
const exemptTypeVars = (_b = this._options.unknownExemptTypeVars) !== null && _b !== void 0 ? _b : [];
|
|
33263
|
+
if (!exemptTypeVars.some((t) => (0, types_1.isTypeSame)(t, paramSpec, { ignoreTypeFlags: true }))) {
|
|
33264
|
+
useDefaultOrUnknown = true;
|
|
33265
|
+
}
|
|
33095
33266
|
} else if (this._options.applyInScopePlaceholders && paramSpec.isInScopePlaceholder) {
|
|
33096
33267
|
useDefaultOrUnknown = true;
|
|
33097
33268
|
}
|
|
@@ -33143,19 +33314,20 @@ var require_typeUtils = __commonJS({
|
|
|
33143
33314
|
}
|
|
33144
33315
|
};
|
|
33145
33316
|
var ExpectedTypeTransformer = class extends TypeVarTransformer {
|
|
33146
|
-
constructor(_liveTypeVarScopes) {
|
|
33317
|
+
constructor(_liveTypeVarScopes, _usageOffset) {
|
|
33147
33318
|
super();
|
|
33148
33319
|
this._liveTypeVarScopes = _liveTypeVarScopes;
|
|
33320
|
+
this._usageOffset = _usageOffset;
|
|
33149
33321
|
}
|
|
33150
33322
|
transformTypeVar(typeVar) {
|
|
33151
33323
|
if (!this._isTypeVarLive(typeVar)) {
|
|
33152
|
-
return types_1.TypeVarType.cloneAsInScopePlaceholder(typeVar);
|
|
33324
|
+
return types_1.TypeVarType.cloneAsInScopePlaceholder(typeVar, this._usageOffset);
|
|
33153
33325
|
}
|
|
33154
33326
|
return typeVar;
|
|
33155
33327
|
}
|
|
33156
33328
|
transformParamSpec(paramSpec) {
|
|
33157
33329
|
if (!this._isTypeVarLive(paramSpec)) {
|
|
33158
|
-
return convertTypeToParamSpecValue(types_1.TypeVarType.cloneAsInScopePlaceholder(paramSpec));
|
|
33330
|
+
return convertTypeToParamSpecValue(types_1.TypeVarType.cloneAsInScopePlaceholder(paramSpec, this._usageOffset));
|
|
33159
33331
|
}
|
|
33160
33332
|
return void 0;
|
|
33161
33333
|
}
|
|
@@ -33171,7 +33343,7 @@ var require_typeUtils = __commonJS({
|
|
|
33171
33343
|
transformTypeVar(typeVar) {
|
|
33172
33344
|
var _a;
|
|
33173
33345
|
if (typeVar.isInScopePlaceholder) {
|
|
33174
|
-
return (_a = this._signatureContext.getTypeVarType(typeVar)) !== null && _a !== void 0 ? _a :
|
|
33346
|
+
return (_a = this._signatureContext.getTypeVarType(typeVar)) !== null && _a !== void 0 ? _a : typeVar;
|
|
33175
33347
|
}
|
|
33176
33348
|
return typeVar;
|
|
33177
33349
|
}
|
|
@@ -33775,7 +33947,7 @@ var require_definitionProvider = __commonJS({
|
|
|
33775
33947
|
return result;
|
|
33776
33948
|
};
|
|
33777
33949
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
33778
|
-
exports.TypeDefinitionProvider = exports.DefinitionProvider = exports.DefinitionFilter = void 0;
|
|
33950
|
+
exports.TypeDefinitionProvider = exports.DefinitionProvider = exports.filterDefinitions = exports.addDeclarationsToDefinitions = exports.DefinitionFilter = void 0;
|
|
33779
33951
|
var analyzerNodeInfo_1 = require_analyzerNodeInfo();
|
|
33780
33952
|
var declaration_1 = require_declaration();
|
|
33781
33953
|
var ParseTreeUtils = __importStar(require_parseTreeUtils());
|
|
@@ -33794,6 +33966,78 @@ var require_definitionProvider = __commonJS({
|
|
|
33794
33966
|
DefinitionFilter2["PreferSource"] = "preferSource";
|
|
33795
33967
|
DefinitionFilter2["PreferStubs"] = "preferStubs";
|
|
33796
33968
|
})(DefinitionFilter = exports.DefinitionFilter || (exports.DefinitionFilter = {}));
|
|
33969
|
+
function addDeclarationsToDefinitions(evaluator, sourceMapper, declarations, definitions) {
|
|
33970
|
+
if (!declarations) {
|
|
33971
|
+
return;
|
|
33972
|
+
}
|
|
33973
|
+
declarations.forEach((decl) => {
|
|
33974
|
+
var _a;
|
|
33975
|
+
let resolvedDecl = evaluator.resolveAliasDeclaration(
|
|
33976
|
+
decl,
|
|
33977
|
+
/* resolveLocalNames */
|
|
33978
|
+
true,
|
|
33979
|
+
{
|
|
33980
|
+
allowExternallyHiddenAccess: true
|
|
33981
|
+
}
|
|
33982
|
+
);
|
|
33983
|
+
if (!resolvedDecl || !resolvedDecl.path) {
|
|
33984
|
+
return;
|
|
33985
|
+
}
|
|
33986
|
+
if (resolvedDecl.type === 8 && resolvedDecl.isUnresolved) {
|
|
33987
|
+
return;
|
|
33988
|
+
}
|
|
33989
|
+
if (resolvedDecl.type === 8 && resolvedDecl.symbolName && resolvedDecl.submoduleFallback && resolvedDecl.submoduleFallback.path) {
|
|
33990
|
+
resolvedDecl = resolvedDecl.submoduleFallback;
|
|
33991
|
+
}
|
|
33992
|
+
_addIfUnique(definitions, {
|
|
33993
|
+
path: resolvedDecl.path,
|
|
33994
|
+
range: resolvedDecl.range
|
|
33995
|
+
});
|
|
33996
|
+
if ((0, declaration_1.isFunctionDeclaration)(resolvedDecl)) {
|
|
33997
|
+
const functionType = (_a = evaluator.getTypeForDeclaration(resolvedDecl)) === null || _a === void 0 ? void 0 : _a.type;
|
|
33998
|
+
if (functionType && (0, types_1.isOverloadedFunction)(functionType)) {
|
|
33999
|
+
for (const overloadDecl of functionType.overloads.map((o) => o.details.declaration).filter(core_1.isDefined)) {
|
|
34000
|
+
_addIfUnique(definitions, {
|
|
34001
|
+
path: overloadDecl.path,
|
|
34002
|
+
range: overloadDecl.range
|
|
34003
|
+
});
|
|
34004
|
+
}
|
|
34005
|
+
}
|
|
34006
|
+
}
|
|
34007
|
+
if (!(0, sourceMapper_1.isStubFile)(resolvedDecl.path)) {
|
|
34008
|
+
return;
|
|
34009
|
+
}
|
|
34010
|
+
if (resolvedDecl.type === 8) {
|
|
34011
|
+
sourceMapper.findModules(resolvedDecl.path).map((m) => {
|
|
34012
|
+
var _a2;
|
|
34013
|
+
return (_a2 = (0, analyzerNodeInfo_1.getFileInfo)(m)) === null || _a2 === void 0 ? void 0 : _a2.filePath;
|
|
34014
|
+
}).filter(core_1.isDefined).forEach((f) => _addIfUnique(definitions, _createModuleEntry(f)));
|
|
34015
|
+
return;
|
|
34016
|
+
}
|
|
34017
|
+
const implDecls = sourceMapper.findDeclarations(resolvedDecl);
|
|
34018
|
+
for (const implDecl of implDecls) {
|
|
34019
|
+
if (implDecl && implDecl.path) {
|
|
34020
|
+
_addIfUnique(definitions, {
|
|
34021
|
+
path: implDecl.path,
|
|
34022
|
+
range: implDecl.range
|
|
34023
|
+
});
|
|
34024
|
+
}
|
|
34025
|
+
}
|
|
34026
|
+
});
|
|
34027
|
+
}
|
|
34028
|
+
exports.addDeclarationsToDefinitions = addDeclarationsToDefinitions;
|
|
34029
|
+
function filterDefinitions(filter, definitions) {
|
|
34030
|
+
if (filter === DefinitionFilter.All) {
|
|
34031
|
+
return definitions;
|
|
34032
|
+
}
|
|
34033
|
+
const preferStubs = filter === DefinitionFilter.PreferStubs;
|
|
34034
|
+
const wantedFile = (v) => preferStubs === (0, sourceMapper_1.isStubFile)(v.path);
|
|
34035
|
+
if (definitions.find(wantedFile)) {
|
|
34036
|
+
return definitions.filter(wantedFile);
|
|
34037
|
+
}
|
|
34038
|
+
return definitions;
|
|
34039
|
+
}
|
|
34040
|
+
exports.filterDefinitions = filterDefinitions;
|
|
33797
34041
|
var DefinitionProviderBase = class {
|
|
33798
34042
|
constructor(sourceMapper, evaluator, node, offset, _filter, token) {
|
|
33799
34043
|
this.sourceMapper = sourceMapper;
|
|
@@ -33824,71 +34068,10 @@ var require_definitionProvider = __commonJS({
|
|
|
33824
34068
|
if (definitions.length === 0) {
|
|
33825
34069
|
return void 0;
|
|
33826
34070
|
}
|
|
33827
|
-
|
|
33828
|
-
return definitions;
|
|
33829
|
-
}
|
|
33830
|
-
const preferStubs = this._filter === DefinitionFilter.PreferStubs;
|
|
33831
|
-
const wantedFile = (v) => preferStubs === (0, sourceMapper_1.isStubFile)(v.path);
|
|
33832
|
-
if (definitions.find(wantedFile)) {
|
|
33833
|
-
return definitions.filter(wantedFile);
|
|
33834
|
-
}
|
|
33835
|
-
return definitions;
|
|
34071
|
+
return filterDefinitions(this._filter, definitions);
|
|
33836
34072
|
}
|
|
33837
34073
|
resolveDeclarations(declarations, definitions) {
|
|
33838
|
-
|
|
33839
|
-
declarations.forEach((decl) => {
|
|
33840
|
-
var _a;
|
|
33841
|
-
let resolvedDecl = this.evaluator.resolveAliasDeclaration(
|
|
33842
|
-
decl,
|
|
33843
|
-
/* resolveLocalNames */
|
|
33844
|
-
true,
|
|
33845
|
-
{
|
|
33846
|
-
allowExternallyHiddenAccess: true
|
|
33847
|
-
}
|
|
33848
|
-
);
|
|
33849
|
-
if (resolvedDecl && resolvedDecl.path) {
|
|
33850
|
-
if (resolvedDecl.type === 8 && resolvedDecl.isUnresolved) {
|
|
33851
|
-
return;
|
|
33852
|
-
}
|
|
33853
|
-
if (resolvedDecl.type === 8 && resolvedDecl.symbolName && resolvedDecl.submoduleFallback && resolvedDecl.submoduleFallback.path) {
|
|
33854
|
-
resolvedDecl = resolvedDecl.submoduleFallback;
|
|
33855
|
-
}
|
|
33856
|
-
_addIfUnique(definitions, {
|
|
33857
|
-
path: resolvedDecl.path,
|
|
33858
|
-
range: resolvedDecl.range
|
|
33859
|
-
});
|
|
33860
|
-
if ((0, declaration_1.isFunctionDeclaration)(resolvedDecl)) {
|
|
33861
|
-
const functionType = (_a = this.evaluator.getTypeForDeclaration(resolvedDecl)) === null || _a === void 0 ? void 0 : _a.type;
|
|
33862
|
-
if (functionType && (0, types_1.isOverloadedFunction)(functionType)) {
|
|
33863
|
-
for (const overloadDecl of functionType.overloads.map((o) => o.details.declaration).filter(core_1.isDefined)) {
|
|
33864
|
-
_addIfUnique(definitions, {
|
|
33865
|
-
path: overloadDecl.path,
|
|
33866
|
-
range: overloadDecl.range
|
|
33867
|
-
});
|
|
33868
|
-
}
|
|
33869
|
-
}
|
|
33870
|
-
}
|
|
33871
|
-
if ((0, sourceMapper_1.isStubFile)(resolvedDecl.path)) {
|
|
33872
|
-
if (resolvedDecl.type === 8) {
|
|
33873
|
-
this.sourceMapper.findModules(resolvedDecl.path).map((m) => {
|
|
33874
|
-
var _a2;
|
|
33875
|
-
return (_a2 = (0, analyzerNodeInfo_1.getFileInfo)(m)) === null || _a2 === void 0 ? void 0 : _a2.filePath;
|
|
33876
|
-
}).filter(core_1.isDefined).forEach((f) => _addIfUnique(definitions, _createModuleEntry(f)));
|
|
33877
|
-
} else {
|
|
33878
|
-
const implDecls = this.sourceMapper.findDeclarations(resolvedDecl);
|
|
33879
|
-
for (const implDecl of implDecls) {
|
|
33880
|
-
if (implDecl && implDecl.path) {
|
|
33881
|
-
_addIfUnique(definitions, {
|
|
33882
|
-
path: implDecl.path,
|
|
33883
|
-
range: implDecl.range
|
|
33884
|
-
});
|
|
33885
|
-
}
|
|
33886
|
-
}
|
|
33887
|
-
}
|
|
33888
|
-
}
|
|
33889
|
-
}
|
|
33890
|
-
});
|
|
33891
|
-
}
|
|
34074
|
+
addDeclarationsToDefinitions(this.evaluator, this.sourceMapper, declarations, definitions);
|
|
33892
34075
|
}
|
|
33893
34076
|
};
|
|
33894
34077
|
var DefinitionProvider = class extends DefinitionProviderBase {
|
|
@@ -37544,6 +37727,9 @@ var require_readonlyAugmentedFileSystem = __commonJS({
|
|
|
37544
37727
|
statSync(path12) {
|
|
37545
37728
|
return this.realFS.statSync(this.getOriginalPath(path12));
|
|
37546
37729
|
}
|
|
37730
|
+
rmdirSync(path12) {
|
|
37731
|
+
throw new Error("Operation is not allowed.");
|
|
37732
|
+
}
|
|
37547
37733
|
unlinkSync(path12) {
|
|
37548
37734
|
throw new Error("Operation is not allowed.");
|
|
37549
37735
|
}
|
|
@@ -37677,6 +37863,9 @@ var require_pyrightFileSystem = __commonJS({
|
|
|
37677
37863
|
writeFileSync(path12, data, encoding) {
|
|
37678
37864
|
this.realFS.writeFileSync(this.getOriginalPath(path12), data, encoding);
|
|
37679
37865
|
}
|
|
37866
|
+
rmdirSync(path12) {
|
|
37867
|
+
this.realFS.rmdirSync(this.getOriginalPath(path12));
|
|
37868
|
+
}
|
|
37680
37869
|
unlinkSync(path12) {
|
|
37681
37870
|
this.realFS.unlinkSync(this.getOriginalPath(path12));
|
|
37682
37871
|
}
|
|
@@ -38672,11 +38861,11 @@ var require_importResolver = __commonJS({
|
|
|
38672
38861
|
}
|
|
38673
38862
|
getTypeshedStdLibPath(execEnv) {
|
|
38674
38863
|
const unused = [];
|
|
38675
|
-
return this._getStdlibTypeshedPath(execEnv, unused);
|
|
38864
|
+
return this._getStdlibTypeshedPath(this._configOptions.typeshedPath, execEnv.pythonVersion, unused);
|
|
38676
38865
|
}
|
|
38677
38866
|
getTypeshedThirdPartyPath(execEnv) {
|
|
38678
38867
|
const unused = [];
|
|
38679
|
-
return this._getThirdPartyTypeshedPath(
|
|
38868
|
+
return this._getThirdPartyTypeshedPath(this._configOptions.typeshedPath, unused);
|
|
38680
38869
|
}
|
|
38681
38870
|
isStdlibModule(module3, execEnv) {
|
|
38682
38871
|
if (!this._stdlibModules) {
|
|
@@ -38687,7 +38876,7 @@ var require_importResolver = __commonJS({
|
|
|
38687
38876
|
getImportRoots(execEnv, forLogging = false) {
|
|
38688
38877
|
const importFailureInfo = [];
|
|
38689
38878
|
const roots = [];
|
|
38690
|
-
const stdTypeshed = this._getStdlibTypeshedPath(execEnv, importFailureInfo);
|
|
38879
|
+
const stdTypeshed = this._getStdlibTypeshedPath(this._configOptions.typeshedPath, execEnv.pythonVersion, importFailureInfo);
|
|
38691
38880
|
if (stdTypeshed) {
|
|
38692
38881
|
roots.push(stdTypeshed);
|
|
38693
38882
|
}
|
|
@@ -38699,12 +38888,12 @@ var require_importResolver = __commonJS({
|
|
|
38699
38888
|
roots.push(this._configOptions.stubPath);
|
|
38700
38889
|
}
|
|
38701
38890
|
if (forLogging) {
|
|
38702
|
-
const thirdPartyRoot = this._getThirdPartyTypeshedPath(
|
|
38891
|
+
const thirdPartyRoot = this._getThirdPartyTypeshedPath(this._configOptions.typeshedPath, importFailureInfo);
|
|
38703
38892
|
if (thirdPartyRoot) {
|
|
38704
38893
|
roots.push((0, pathUtils_1.combinePaths)(thirdPartyRoot, "..."));
|
|
38705
38894
|
}
|
|
38706
38895
|
} else {
|
|
38707
|
-
const thirdPartyPaths = this._getThirdPartyTypeshedPackageRoots(
|
|
38896
|
+
const thirdPartyPaths = this._getThirdPartyTypeshedPackageRoots(importFailureInfo);
|
|
38708
38897
|
(0, collectionUtils_1.appendArray)(roots, thirdPartyPaths);
|
|
38709
38898
|
}
|
|
38710
38899
|
const typeshedPathEx = this.getTypeshedPathEx(execEnv, importFailureInfo);
|
|
@@ -38752,6 +38941,26 @@ var require_importResolver = __commonJS({
|
|
|
38752
38941
|
importFailureInfo.push(...this._cachedPythonSearchPaths.failureInfo);
|
|
38753
38942
|
return this._cachedPythonSearchPaths.paths;
|
|
38754
38943
|
}
|
|
38944
|
+
getTypeshedStdlibExcludeList(customTypeshedPath, pythonVersion) {
|
|
38945
|
+
const unused = [];
|
|
38946
|
+
const typeshedStdlibPath = this._getStdlibTypeshedPath(customTypeshedPath, pythonVersion, unused);
|
|
38947
|
+
const excludes = [];
|
|
38948
|
+
if (!typeshedStdlibPath) {
|
|
38949
|
+
return excludes;
|
|
38950
|
+
}
|
|
38951
|
+
if (!this._cachedTypeshedStdLibModuleVersions) {
|
|
38952
|
+
this._cachedTypeshedStdLibModuleVersions = this._readTypeshedStdLibVersions(customTypeshedPath, []);
|
|
38953
|
+
}
|
|
38954
|
+
this._cachedTypeshedStdLibModuleVersions.forEach((versionRange, moduleName) => {
|
|
38955
|
+
if (versionRange.max !== void 0 && pythonVersion > versionRange.max) {
|
|
38956
|
+
const moduleDirPath = (0, pathUtils_1.combinePaths)(typeshedStdlibPath, ...moduleName.split("."));
|
|
38957
|
+
excludes.push(moduleDirPath);
|
|
38958
|
+
const moduleFilePath = moduleDirPath + ".pyi";
|
|
38959
|
+
excludes.push(moduleFilePath);
|
|
38960
|
+
}
|
|
38961
|
+
});
|
|
38962
|
+
return excludes;
|
|
38963
|
+
}
|
|
38755
38964
|
readdirEntriesCached(path12) {
|
|
38756
38965
|
const cachedValue = this._cachedEntriesForPath.get(path12);
|
|
38757
38966
|
if (cachedValue) {
|
|
@@ -39116,7 +39325,7 @@ var require_importResolver = __commonJS({
|
|
|
39116
39325
|
let isLocalTypingsFile = false;
|
|
39117
39326
|
const importFailureInfo = [];
|
|
39118
39327
|
let moduleNameWithInvalidCharacters;
|
|
39119
|
-
const stdLibTypeshedPath = this._getStdlibTypeshedPath(execEnv, importFailureInfo);
|
|
39328
|
+
const stdLibTypeshedPath = this._getStdlibTypeshedPath(this._configOptions.typeshedPath, execEnv.pythonVersion, importFailureInfo);
|
|
39120
39329
|
if (stdLibTypeshedPath) {
|
|
39121
39330
|
moduleName = this.getModuleNameFromPath(stdLibTypeshedPath, filePath);
|
|
39122
39331
|
if (moduleName) {
|
|
@@ -39125,7 +39334,7 @@ var require_importResolver = __commonJS({
|
|
|
39125
39334
|
nameParts: moduleName.split("."),
|
|
39126
39335
|
importedSymbols: void 0
|
|
39127
39336
|
};
|
|
39128
|
-
if (this._isStdlibTypeshedStubValidForVersion(moduleDescriptor, execEnv, [])) {
|
|
39337
|
+
if (this._isStdlibTypeshedStubValidForVersion(moduleDescriptor, this._configOptions.typeshedPath, execEnv.pythonVersion, [])) {
|
|
39129
39338
|
return { moduleName, importType, isLocalTypingsFile };
|
|
39130
39339
|
}
|
|
39131
39340
|
}
|
|
@@ -39170,7 +39379,7 @@ var require_importResolver = __commonJS({
|
|
|
39170
39379
|
}
|
|
39171
39380
|
}
|
|
39172
39381
|
}
|
|
39173
|
-
const thirdPartyTypeshedPath = this._getThirdPartyTypeshedPath(
|
|
39382
|
+
const thirdPartyTypeshedPath = this._getThirdPartyTypeshedPath(this._configOptions.typeshedPath, importFailureInfo);
|
|
39174
39383
|
if (thirdPartyTypeshedPath) {
|
|
39175
39384
|
const candidateModuleName = this.getModuleNameFromPath(
|
|
39176
39385
|
thirdPartyTypeshedPath,
|
|
@@ -39513,7 +39722,7 @@ var require_importResolver = __commonJS({
|
|
|
39513
39722
|
} else {
|
|
39514
39723
|
importFailureInfo.push("No python interpreter search path");
|
|
39515
39724
|
}
|
|
39516
|
-
if (execEnv.root !== this._getTypeshedRoot(
|
|
39725
|
+
if (execEnv.root !== this._getTypeshedRoot(this._configOptions.typeshedPath, importFailureInfo)) {
|
|
39517
39726
|
if ((bestResultSoFar === null || bestResultSoFar === void 0 ? void 0 : bestResultSoFar.pyTypedInfo) && !bestResultSoFar.isPartlyResolved) {
|
|
39518
39727
|
return bestResultSoFar;
|
|
39519
39728
|
}
|
|
@@ -39626,12 +39835,12 @@ var require_importResolver = __commonJS({
|
|
|
39626
39835
|
importFailureInfo.push(`Looking for typeshed ${isStdLib ? PythonPathUtils.stdLibFolderName : PythonPathUtils.thirdPartyFolderName} path`);
|
|
39627
39836
|
let typeshedPaths;
|
|
39628
39837
|
if (isStdLib) {
|
|
39629
|
-
const path12 = this._getStdlibTypeshedPath(execEnv, importFailureInfo, moduleDescriptor);
|
|
39838
|
+
const path12 = this._getStdlibTypeshedPath(this._configOptions.typeshedPath, execEnv.pythonVersion, importFailureInfo, moduleDescriptor);
|
|
39630
39839
|
if (path12) {
|
|
39631
39840
|
typeshedPaths = [path12];
|
|
39632
39841
|
}
|
|
39633
39842
|
} else {
|
|
39634
|
-
typeshedPaths = this._getThirdPartyTypeshedPackagePaths(moduleDescriptor,
|
|
39843
|
+
typeshedPaths = this._getThirdPartyTypeshedPackagePaths(moduleDescriptor, importFailureInfo);
|
|
39635
39844
|
}
|
|
39636
39845
|
if (typeshedPaths) {
|
|
39637
39846
|
for (const typeshedPath of typeshedPaths) {
|
|
@@ -39712,14 +39921,13 @@ var require_importResolver = __commonJS({
|
|
|
39712
39921
|
const importFailureInfo = [];
|
|
39713
39922
|
let typeshedPaths;
|
|
39714
39923
|
if (isStdLib) {
|
|
39715
|
-
const path12 = this._getStdlibTypeshedPath(execEnv, importFailureInfo, moduleDescriptor);
|
|
39924
|
+
const path12 = this._getStdlibTypeshedPath(this._configOptions.typeshedPath, execEnv.pythonVersion, importFailureInfo, moduleDescriptor);
|
|
39716
39925
|
if (path12) {
|
|
39717
39926
|
typeshedPaths = [path12];
|
|
39718
39927
|
}
|
|
39719
39928
|
} else {
|
|
39720
39929
|
typeshedPaths = this._getThirdPartyTypeshedPackagePaths(
|
|
39721
39930
|
moduleDescriptor,
|
|
39722
|
-
execEnv,
|
|
39723
39931
|
importFailureInfo,
|
|
39724
39932
|
/* includeMatchOnly */
|
|
39725
39933
|
false
|
|
@@ -39742,50 +39950,50 @@ var require_importResolver = __commonJS({
|
|
|
39742
39950
|
// Returns the directory for a module within the stdlib typeshed directory.
|
|
39743
39951
|
// If moduleDescriptor is provided, it is filtered based on the VERSIONS
|
|
39744
39952
|
// file in the typeshed stubs.
|
|
39745
|
-
_getStdlibTypeshedPath(
|
|
39953
|
+
_getStdlibTypeshedPath(customTypeshedPath, pythonVersion, importFailureInfo, moduleDescriptor) {
|
|
39746
39954
|
const subdirectory = this._getTypeshedSubdirectory(
|
|
39747
39955
|
/* isStdLib */
|
|
39748
39956
|
true,
|
|
39749
|
-
|
|
39957
|
+
customTypeshedPath,
|
|
39750
39958
|
importFailureInfo
|
|
39751
39959
|
);
|
|
39752
|
-
if (subdirectory && moduleDescriptor && !this._isStdlibTypeshedStubValidForVersion(moduleDescriptor,
|
|
39960
|
+
if (subdirectory && moduleDescriptor && !this._isStdlibTypeshedStubValidForVersion(moduleDescriptor, customTypeshedPath, pythonVersion, importFailureInfo)) {
|
|
39753
39961
|
return void 0;
|
|
39754
39962
|
}
|
|
39755
39963
|
return subdirectory;
|
|
39756
39964
|
}
|
|
39757
|
-
_getThirdPartyTypeshedPath(
|
|
39965
|
+
_getThirdPartyTypeshedPath(customTypeshedPath, importFailureInfo) {
|
|
39758
39966
|
return this._getTypeshedSubdirectory(
|
|
39759
39967
|
/* isStdLib */
|
|
39760
39968
|
false,
|
|
39761
|
-
|
|
39969
|
+
customTypeshedPath,
|
|
39762
39970
|
importFailureInfo
|
|
39763
39971
|
);
|
|
39764
39972
|
}
|
|
39765
|
-
_isStdlibTypeshedStubValidForVersion(moduleDescriptor,
|
|
39973
|
+
_isStdlibTypeshedStubValidForVersion(moduleDescriptor, customTypeshedPath, pythonVersion, importFailureInfo) {
|
|
39766
39974
|
if (!this._cachedTypeshedStdLibModuleVersions) {
|
|
39767
|
-
this._cachedTypeshedStdLibModuleVersions = this._readTypeshedStdLibVersions(
|
|
39975
|
+
this._cachedTypeshedStdLibModuleVersions = this._readTypeshedStdLibVersions(customTypeshedPath, importFailureInfo);
|
|
39768
39976
|
}
|
|
39769
39977
|
for (let namePartCount = 1; namePartCount <= moduleDescriptor.nameParts.length; namePartCount++) {
|
|
39770
39978
|
const namePartsToConsider = moduleDescriptor.nameParts.slice(0, namePartCount);
|
|
39771
39979
|
const versionRange = this._cachedTypeshedStdLibModuleVersions.get(namePartsToConsider.join("."));
|
|
39772
39980
|
if (versionRange) {
|
|
39773
|
-
if (
|
|
39981
|
+
if (pythonVersion < versionRange.min) {
|
|
39774
39982
|
return false;
|
|
39775
39983
|
}
|
|
39776
|
-
if (versionRange.max !== void 0 &&
|
|
39984
|
+
if (versionRange.max !== void 0 && pythonVersion > versionRange.max) {
|
|
39777
39985
|
return false;
|
|
39778
39986
|
}
|
|
39779
39987
|
}
|
|
39780
39988
|
}
|
|
39781
39989
|
return true;
|
|
39782
39990
|
}
|
|
39783
|
-
_readTypeshedStdLibVersions(
|
|
39991
|
+
_readTypeshedStdLibVersions(customTypeshedPath, importFailureInfo) {
|
|
39784
39992
|
const versionRangeMap = /* @__PURE__ */ new Map();
|
|
39785
39993
|
const typeshedStdLibPath = this._getTypeshedSubdirectory(
|
|
39786
39994
|
/* isStdLib */
|
|
39787
39995
|
true,
|
|
39788
|
-
|
|
39996
|
+
customTypeshedPath,
|
|
39789
39997
|
importFailureInfo
|
|
39790
39998
|
);
|
|
39791
39999
|
if (typeshedStdLibPath) {
|
|
@@ -39831,8 +40039,8 @@ var require_importResolver = __commonJS({
|
|
|
39831
40039
|
}
|
|
39832
40040
|
return versionRangeMap;
|
|
39833
40041
|
}
|
|
39834
|
-
_getThirdPartyTypeshedPackagePaths(moduleDescriptor,
|
|
39835
|
-
const typeshedPath = this._getThirdPartyTypeshedPath(
|
|
40042
|
+
_getThirdPartyTypeshedPackagePaths(moduleDescriptor, importFailureInfo, includeMatchOnly = true) {
|
|
40043
|
+
const typeshedPath = this._getThirdPartyTypeshedPath(this._configOptions.typeshedPath, importFailureInfo);
|
|
39836
40044
|
if (!this._cachedTypeshedThirdPartyPackagePaths) {
|
|
39837
40045
|
this._buildTypeshedThirdPartyPackageMap(typeshedPath);
|
|
39838
40046
|
}
|
|
@@ -39845,22 +40053,21 @@ var require_importResolver = __commonJS({
|
|
|
39845
40053
|
}
|
|
39846
40054
|
return [];
|
|
39847
40055
|
}
|
|
39848
|
-
_getThirdPartyTypeshedPackageRoots(
|
|
39849
|
-
const typeshedPath = this._getThirdPartyTypeshedPath(
|
|
40056
|
+
_getThirdPartyTypeshedPackageRoots(importFailureInfo) {
|
|
40057
|
+
const typeshedPath = this._getThirdPartyTypeshedPath(this._configOptions.typeshedPath, importFailureInfo);
|
|
39850
40058
|
if (!this._cachedTypeshedThirdPartyPackagePaths) {
|
|
39851
40059
|
this._buildTypeshedThirdPartyPackageMap(typeshedPath);
|
|
39852
40060
|
}
|
|
39853
40061
|
return this._cachedTypeshedThirdPartyPackageRoots;
|
|
39854
40062
|
}
|
|
39855
|
-
_getTypeshedRoot(
|
|
40063
|
+
_getTypeshedRoot(customTypeshedPath, importFailureInfo) {
|
|
39856
40064
|
if (this._cachedTypeshedRoot !== void 0) {
|
|
39857
40065
|
return this._cachedTypeshedRoot;
|
|
39858
40066
|
}
|
|
39859
40067
|
let typeshedPath = "";
|
|
39860
|
-
if (
|
|
39861
|
-
|
|
39862
|
-
|
|
39863
|
-
typeshedPath = possibleTypeshedPath;
|
|
40068
|
+
if (customTypeshedPath) {
|
|
40069
|
+
if (this.dirExistsCached(customTypeshedPath)) {
|
|
40070
|
+
typeshedPath = customTypeshedPath;
|
|
39864
40071
|
}
|
|
39865
40072
|
} else {
|
|
39866
40073
|
const pythonSearchPaths = this.getPythonSearchPaths(importFailureInfo);
|
|
@@ -39878,7 +40085,7 @@ var require_importResolver = __commonJS({
|
|
|
39878
40085
|
this._cachedTypeshedRoot = typeshedPath;
|
|
39879
40086
|
return typeshedPath;
|
|
39880
40087
|
}
|
|
39881
|
-
_getTypeshedSubdirectory(isStdLib,
|
|
40088
|
+
_getTypeshedSubdirectory(isStdLib, customTypeshedPath, importFailureInfo) {
|
|
39882
40089
|
if (isStdLib) {
|
|
39883
40090
|
if (this._cachedTypeshedStdLibPath !== void 0) {
|
|
39884
40091
|
return this._cachedTypeshedStdLibPath;
|
|
@@ -39888,7 +40095,7 @@ var require_importResolver = __commonJS({
|
|
|
39888
40095
|
return this._cachedTypeshedThirdPartyPath;
|
|
39889
40096
|
}
|
|
39890
40097
|
}
|
|
39891
|
-
let typeshedPath = this._getTypeshedRoot(
|
|
40098
|
+
let typeshedPath = this._getTypeshedRoot(customTypeshedPath, importFailureInfo);
|
|
39892
40099
|
typeshedPath = PythonPathUtils.getTypeshedSubdirectory(typeshedPath, isStdLib);
|
|
39893
40100
|
if (!this.dirExistsCached(typeshedPath)) {
|
|
39894
40101
|
return void 0;
|
|
@@ -40378,6 +40585,7 @@ var require_typeEvaluatorTypes = __commonJS({
|
|
|
40378
40585
|
EvaluatorFlags2[EvaluatorFlags2["DisallowTypeVarTuple"] = 64] = "DisallowTypeVarTuple";
|
|
40379
40586
|
EvaluatorFlags2[EvaluatorFlags2["ExpectingType"] = 128] = "ExpectingType";
|
|
40380
40587
|
EvaluatorFlags2[EvaluatorFlags2["ExpectingTypeAnnotation"] = 256] = "ExpectingTypeAnnotation";
|
|
40588
|
+
EvaluatorFlags2[EvaluatorFlags2["AllowMissingTypeArgs"] = 512] = "AllowMissingTypeArgs";
|
|
40381
40589
|
EvaluatorFlags2[EvaluatorFlags2["AllowGenericClassType"] = 1024] = "AllowGenericClassType";
|
|
40382
40590
|
EvaluatorFlags2[EvaluatorFlags2["DisallowTypeVarsWithScopeId"] = 2048] = "DisallowTypeVarsWithScopeId";
|
|
40383
40591
|
EvaluatorFlags2[EvaluatorFlags2["DisallowTypeVarsWithoutScopeId"] = 4096] = "DisallowTypeVarsWithoutScopeId";
|
|
@@ -40672,13 +40880,15 @@ var require_constraintSolver = __commonJS({
|
|
|
40672
40880
|
return false;
|
|
40673
40881
|
}
|
|
40674
40882
|
if ((flags & 1024) !== 0) {
|
|
40675
|
-
if (
|
|
40676
|
-
|
|
40677
|
-
|
|
40678
|
-
|
|
40679
|
-
|
|
40680
|
-
|
|
40681
|
-
|
|
40883
|
+
if (!curEntry) {
|
|
40884
|
+
if ((flags & 1) !== 0) {
|
|
40885
|
+
newNarrowTypeBound = adjSrcType;
|
|
40886
|
+
newWideTypeBound = adjSrcType;
|
|
40887
|
+
} else if (isContravariant) {
|
|
40888
|
+
newNarrowTypeBound = adjSrcType;
|
|
40889
|
+
} else {
|
|
40890
|
+
newWideTypeBound = adjSrcType;
|
|
40891
|
+
}
|
|
40682
40892
|
}
|
|
40683
40893
|
} else if (isContravariant) {
|
|
40684
40894
|
if (!curWideTypeBound) {
|
|
@@ -40695,7 +40905,9 @@ var require_constraintSolver = __commonJS({
|
|
|
40695
40905
|
flags & 512,
|
|
40696
40906
|
recursionCount
|
|
40697
40907
|
)) {
|
|
40698
|
-
|
|
40908
|
+
if (!(0, types_1.isAny)(curWideTypeBound)) {
|
|
40909
|
+
newWideTypeBound = adjSrcType;
|
|
40910
|
+
}
|
|
40699
40911
|
} else if (!evaluator.assignType(
|
|
40700
40912
|
adjSrcType,
|
|
40701
40913
|
curWideTypeBound,
|
|
@@ -40748,7 +40960,8 @@ var require_constraintSolver = __commonJS({
|
|
|
40748
40960
|
curNarrowTypeBound,
|
|
40749
40961
|
adjSrcType,
|
|
40750
40962
|
diagAddendum,
|
|
40751
|
-
|
|
40963
|
+
/* destTypeVarContext */
|
|
40964
|
+
void 0,
|
|
40752
40965
|
/* srcTypeVarContext */
|
|
40753
40966
|
void 0,
|
|
40754
40967
|
flags,
|
|
@@ -40759,7 +40972,8 @@ var require_constraintSolver = __commonJS({
|
|
|
40759
40972
|
curNarrowTypeBound,
|
|
40760
40973
|
/* diag */
|
|
40761
40974
|
void 0,
|
|
40762
|
-
|
|
40975
|
+
/* destTypeVarContext */
|
|
40976
|
+
void 0,
|
|
40763
40977
|
/* srcTypeVarContext */
|
|
40764
40978
|
void 0,
|
|
40765
40979
|
flags & 512,
|
|
@@ -40782,7 +40996,8 @@ var require_constraintSolver = __commonJS({
|
|
|
40782
40996
|
curNarrowTypeBound,
|
|
40783
40997
|
/* diag */
|
|
40784
40998
|
void 0,
|
|
40785
|
-
|
|
40999
|
+
/* destTypeVarContext */
|
|
41000
|
+
void 0,
|
|
40786
41001
|
/* srcTypeVarContext */
|
|
40787
41002
|
void 0,
|
|
40788
41003
|
flags & 512,
|
|
@@ -40970,7 +41185,7 @@ var require_constraintSolver = __commonJS({
|
|
|
40970
41185
|
});
|
|
40971
41186
|
return isAssignable;
|
|
40972
41187
|
}
|
|
40973
|
-
function populateTypeVarContextBasedOnExpectedType(evaluator, type, expectedType, typeVarContext, liveTypeVarScopes) {
|
|
41188
|
+
function populateTypeVarContextBasedOnExpectedType(evaluator, type, expectedType, typeVarContext, liveTypeVarScopes, usageOffset = void 0) {
|
|
40974
41189
|
if ((0, types_1.isAny)(expectedType)) {
|
|
40975
41190
|
type.details.typeParameters.forEach((typeParam) => {
|
|
40976
41191
|
typeVarContext.setTypeVarType(typeParam, expectedType);
|
|
@@ -41003,7 +41218,7 @@ var require_constraintSolver = __commonJS({
|
|
|
41003
41218
|
sameClassTypeVarContext.getPrimarySignature().getTypeVars().forEach((entry) => {
|
|
41004
41219
|
let typeArgValue = sameClassTypeVarContext.getPrimarySignature().getTypeVarType(entry.typeVar);
|
|
41005
41220
|
if (typeArgValue && liveTypeVarScopes) {
|
|
41006
|
-
typeArgValue = (0, typeUtils_1.transformExpectedType)(typeArgValue, liveTypeVarScopes);
|
|
41221
|
+
typeArgValue = (0, typeUtils_1.transformExpectedType)(typeArgValue, liveTypeVarScopes, usageOffset);
|
|
41007
41222
|
}
|
|
41008
41223
|
if (typeArgValue) {
|
|
41009
41224
|
const variance = types_1.TypeVarType.getVariance(entry.typeVar);
|
|
@@ -41014,6 +41229,15 @@ var require_constraintSolver = __commonJS({
|
|
|
41014
41229
|
void 0,
|
|
41015
41230
|
variance === 4 ? void 0 : typeArgValue
|
|
41016
41231
|
);
|
|
41232
|
+
if (entry.tupleTypes) {
|
|
41233
|
+
typeVarContext.setTupleTypeVar(entry.typeVar, entry.tupleTypes.map((tupleEntry) => {
|
|
41234
|
+
let tupleType = tupleEntry.type;
|
|
41235
|
+
if (liveTypeVarScopes) {
|
|
41236
|
+
tupleType = (0, typeUtils_1.transformExpectedType)(tupleEntry.type, liveTypeVarScopes, usageOffset);
|
|
41237
|
+
}
|
|
41238
|
+
return { type: tupleType, isUnbounded: tupleEntry.isUnbounded };
|
|
41239
|
+
}));
|
|
41240
|
+
}
|
|
41017
41241
|
}
|
|
41018
41242
|
});
|
|
41019
41243
|
return true;
|
|
@@ -41065,7 +41289,7 @@ var require_constraintSolver = __commonJS({
|
|
|
41065
41289
|
if (index < expectedTypeArgs.length) {
|
|
41066
41290
|
let typeArgValue = (0, typeUtils_1.transformPossibleRecursiveTypeAlias)(expectedTypeArgs[index]);
|
|
41067
41291
|
if (liveTypeVarScopes) {
|
|
41068
|
-
typeArgValue = (0, typeUtils_1.transformExpectedType)(typeArgValue, liveTypeVarScopes);
|
|
41292
|
+
typeArgValue = (0, typeUtils_1.transformExpectedType)(typeArgValue, liveTypeVarScopes, usageOffset);
|
|
41069
41293
|
}
|
|
41070
41294
|
if (typeArgValue) {
|
|
41071
41295
|
const variance = types_1.TypeVarType.getVariance(typeVar);
|
|
@@ -42927,7 +43151,8 @@ var require_typeGuards = __commonJS({
|
|
|
42927
43151
|
varType,
|
|
42928
43152
|
typeVarContext,
|
|
42929
43153
|
/* liveTypeVarScopes */
|
|
42930
|
-
void 0
|
|
43154
|
+
void 0,
|
|
43155
|
+
errorNode.start
|
|
42931
43156
|
)) {
|
|
42932
43157
|
specializedFilterType = (0, typeUtils_1.applySolvedTypeVars)(unspecializedFilterType, typeVarContext, { unknownIfNotFound: true });
|
|
42933
43158
|
}
|
|
@@ -43319,7 +43544,7 @@ var require_typeGuards = __commonJS({
|
|
|
43319
43544
|
}
|
|
43320
43545
|
if (memberInfo && memberInfo.isTypeDeclared) {
|
|
43321
43546
|
let memberType = evaluator.getTypeOfMember(memberInfo);
|
|
43322
|
-
if ((0, types_1.isClassInstance)(subtype) && (0, typeUtils_1.isProperty)(memberType)) {
|
|
43547
|
+
if ((0, types_1.isClassInstance)(subtype) && (0, types_1.isClassInstance)(memberType) && (0, typeUtils_1.isProperty)(memberType)) {
|
|
43323
43548
|
const getterInfo = (0, typeUtils_1.lookUpObjectMember)(memberType, "fget");
|
|
43324
43549
|
if (getterInfo && getterInfo.isTypeDeclared) {
|
|
43325
43550
|
const getterType = evaluator.getTypeOfMember(getterInfo);
|
|
@@ -44028,6 +44253,8 @@ var require_patternMatching = __commonJS({
|
|
|
44028
44253
|
subjectSubtypeExpanded,
|
|
44029
44254
|
typeVarContext,
|
|
44030
44255
|
/* liveTypeVarScopes */
|
|
44256
|
+
void 0,
|
|
44257
|
+
/* usageOffset */
|
|
44031
44258
|
void 0
|
|
44032
44259
|
)) {
|
|
44033
44260
|
resultType = (0, typeUtils_1.applySolvedTypeVars)(matchTypeInstance, typeVarContext, {
|
|
@@ -46570,12 +46797,10 @@ var require_constructors = __commonJS({
|
|
|
46570
46797
|
}
|
|
46571
46798
|
newMethodReturnType = newCallResult.returnType;
|
|
46572
46799
|
}
|
|
46573
|
-
if (!newMethodReturnType) {
|
|
46800
|
+
if (!newMethodReturnType || isDefaultNewMethod(newMethodTypeResult === null || newMethodTypeResult === void 0 ? void 0 : newMethodTypeResult.type)) {
|
|
46574
46801
|
newMethodReturnType = types_1.ClassType.cloneAsInstance(type);
|
|
46575
|
-
} else if (!(0, types_1.isNever)(newMethodReturnType)) {
|
|
46576
|
-
|
|
46577
|
-
newMethodReturnType = types_1.ClassType.cloneAsInstance(type);
|
|
46578
|
-
}
|
|
46802
|
+
} else if (!(0, types_1.isNever)(newMethodReturnType) && !(0, types_1.isClassInstance)(newMethodReturnType)) {
|
|
46803
|
+
newMethodReturnType = (0, typeUtils_1.applySolvedTypeVars)(types_1.ClassType.cloneAsInstance(type), new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(type)), { unknownIfNotFound: true });
|
|
46579
46804
|
}
|
|
46580
46805
|
let initMethodTypeResult;
|
|
46581
46806
|
if (!argumentErrors && !(0, types_1.isNever)(newMethodReturnType) && !shouldSkipInitEvaluation(evaluator, type, newMethodReturnType)) {
|
|
@@ -46585,7 +46810,7 @@ var require_constructors = __commonJS({
|
|
|
46585
46810
|
}
|
|
46586
46811
|
initMethodTypeResult = evaluator.getTypeOfObjectMember(
|
|
46587
46812
|
errorNode,
|
|
46588
|
-
|
|
46813
|
+
initMethodBindToType,
|
|
46589
46814
|
"__init__",
|
|
46590
46815
|
{ method: "get" },
|
|
46591
46816
|
/* diag */
|
|
@@ -46689,7 +46914,7 @@ var require_constructors = __commonJS({
|
|
|
46689
46914
|
expectedSubType = (0, typeUtils_1.transformPossibleRecursiveTypeAlias)(expectedSubType);
|
|
46690
46915
|
const typeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(type));
|
|
46691
46916
|
typeVarContext.addSolveForScope((0, typeUtils_1.getTypeVarScopeId)(initMethodType));
|
|
46692
|
-
if ((0, constraintSolver_1.populateTypeVarContextBasedOnExpectedType)(evaluator, types_1.ClassType.cloneAsInstance(type), expectedSubType, typeVarContext, (0, parseTreeUtils_1.getTypeVarScopesForNode)(errorNode))) {
|
|
46917
|
+
if ((0, constraintSolver_1.populateTypeVarContextBasedOnExpectedType)(evaluator, types_1.ClassType.cloneAsInstance(type), expectedSubType, typeVarContext, (0, parseTreeUtils_1.getTypeVarScopesForNode)(errorNode), errorNode.start)) {
|
|
46693
46918
|
const specializedConstructor = (0, typeUtils_1.applySolvedTypeVars)(initMethodType, typeVarContext);
|
|
46694
46919
|
let callResult;
|
|
46695
46920
|
callResult = evaluator.useSpeculativeMode(errorNode, () => {
|
|
@@ -46714,11 +46939,7 @@ var require_constructors = __commonJS({
|
|
|
46714
46939
|
}
|
|
46715
46940
|
}
|
|
46716
46941
|
if (!returnType) {
|
|
46717
|
-
const typeVarContext = type.typeArguments ? (0, typeUtils_1.buildTypeVarContextFromSpecializedClass)(
|
|
46718
|
-
type,
|
|
46719
|
-
/* makeConcrete */
|
|
46720
|
-
false
|
|
46721
|
-
) : new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(type));
|
|
46942
|
+
const typeVarContext = type.typeArguments ? (0, typeUtils_1.buildTypeVarContextFromSpecializedClass)(type) : new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(type));
|
|
46722
46943
|
typeVarContext.addSolveForScope((0, typeUtils_1.getTypeVarScopeId)(initMethodType));
|
|
46723
46944
|
const callResult = evaluator.validateCallArguments(errorNode, argList, { type: initMethodType }, typeVarContext, skipUnknownArgCheck);
|
|
46724
46945
|
let adjustedClassType = type;
|
|
@@ -46745,7 +46966,10 @@ var require_constructors = __commonJS({
|
|
|
46745
46966
|
}
|
|
46746
46967
|
function validateFallbackConstructorCall(evaluator, errorNode, argList, type, inferenceContext) {
|
|
46747
46968
|
let reportedErrors = false;
|
|
46748
|
-
if (argList.length > 0
|
|
46969
|
+
if (argList.length > 0 && argList.some(
|
|
46970
|
+
(arg) => arg.argumentCategory === 0
|
|
46971
|
+
/* Simple */
|
|
46972
|
+
)) {
|
|
46749
46973
|
const fileInfo = (0, analyzerNodeInfo_1.getFileInfo)(errorNode);
|
|
46750
46974
|
evaluator.addDiagnostic(fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.constructorNoArgs().format({ type: type.aliasName || type.details.name }), errorNode);
|
|
46751
46975
|
reportedErrors = true;
|
|
@@ -46759,7 +46983,7 @@ var require_constructors = __commonJS({
|
|
|
46759
46983
|
}
|
|
46760
46984
|
const typeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(type));
|
|
46761
46985
|
if (inferenceContext) {
|
|
46762
|
-
(0, constraintSolver_1.populateTypeVarContextBasedOnExpectedType)(evaluator, types_1.ClassType.cloneAsInstance(type), inferenceContext.expectedType, typeVarContext, (0, parseTreeUtils_1.getTypeVarScopesForNode)(errorNode));
|
|
46986
|
+
(0, constraintSolver_1.populateTypeVarContextBasedOnExpectedType)(evaluator, types_1.ClassType.cloneAsInstance(type), inferenceContext.expectedType, typeVarContext, (0, parseTreeUtils_1.getTypeVarScopesForNode)(errorNode), errorNode.start);
|
|
46763
46987
|
}
|
|
46764
46988
|
return {
|
|
46765
46989
|
argumentErrors: reportedErrors,
|
|
@@ -46968,6 +47192,27 @@ var require_constructors = __commonJS({
|
|
|
46968
47192
|
});
|
|
46969
47193
|
return skipInitCheck;
|
|
46970
47194
|
}
|
|
47195
|
+
function isDefaultNewMethod(newMethod) {
|
|
47196
|
+
var _a;
|
|
47197
|
+
if (!newMethod || !(0, types_1.isFunction)(newMethod)) {
|
|
47198
|
+
return false;
|
|
47199
|
+
}
|
|
47200
|
+
if (newMethod.details.paramSpec) {
|
|
47201
|
+
return false;
|
|
47202
|
+
}
|
|
47203
|
+
const params = newMethod.details.parameters;
|
|
47204
|
+
if (params.length !== 2) {
|
|
47205
|
+
return false;
|
|
47206
|
+
}
|
|
47207
|
+
if (params[0].category !== 1 || params[1].category !== 2) {
|
|
47208
|
+
return false;
|
|
47209
|
+
}
|
|
47210
|
+
const returnType = (_a = newMethod.details.declaredReturnType) !== null && _a !== void 0 ? _a : newMethod.inferredReturnType;
|
|
47211
|
+
if (!returnType || !(0, types_1.isTypeVar)(returnType) || !returnType.details.isSynthesizedSelf) {
|
|
47212
|
+
return false;
|
|
47213
|
+
}
|
|
47214
|
+
return true;
|
|
47215
|
+
}
|
|
46971
47216
|
}
|
|
46972
47217
|
});
|
|
46973
47218
|
|
|
@@ -47855,11 +48100,7 @@ var require_dataClasses = __commonJS({
|
|
|
47855
48100
|
let allAncestorsAreKnown = true;
|
|
47856
48101
|
types_1.ClassType.getReverseMro(classType).forEach((mroClass) => {
|
|
47857
48102
|
if ((0, types_1.isInstantiableClass)(mroClass)) {
|
|
47858
|
-
const typeVarContext = (0, typeUtils_1.buildTypeVarContextFromSpecializedClass)(
|
|
47859
|
-
mroClass,
|
|
47860
|
-
/* makeConcrete */
|
|
47861
|
-
false
|
|
47862
|
-
);
|
|
48103
|
+
const typeVarContext = (0, typeUtils_1.buildTypeVarContextFromSpecializedClass)(mroClass);
|
|
47863
48104
|
const dataClassEntries = types_1.ClassType.getDataClassEntries(mroClass);
|
|
47864
48105
|
dataClassEntries.forEach((entry) => {
|
|
47865
48106
|
const existingIndex = entries.findIndex((e) => e.name === entry.name);
|
|
@@ -48887,6 +49128,18 @@ var require_operations = __commonJS({
|
|
|
48887
49128
|
if (!evaluator.validateTypeArg({ ...leftTypeResult, node: leftExpression }, { allowVariadicTypeVar: true, allowUnpackedTuples: true }) || !evaluator.validateTypeArg({ ...rightTypeResult, node: rightExpression }, { allowVariadicTypeVar: true, allowUnpackedTuples: true })) {
|
|
48888
49129
|
return { type: types_1.UnknownType.create() };
|
|
48889
49130
|
}
|
|
49131
|
+
adjustedLeftType = evaluator.reportMissingTypeArguments(
|
|
49132
|
+
node.leftExpression,
|
|
49133
|
+
adjustedLeftType,
|
|
49134
|
+
flags | 128
|
|
49135
|
+
/* ExpectingType */
|
|
49136
|
+
);
|
|
49137
|
+
adjustedRightType = evaluator.reportMissingTypeArguments(
|
|
49138
|
+
node.rightExpression,
|
|
49139
|
+
adjustedRightType,
|
|
49140
|
+
flags | 128
|
|
49141
|
+
/* ExpectingType */
|
|
49142
|
+
);
|
|
48890
49143
|
const newUnion = (0, types_1.combineTypes)([adjustedLeftType, adjustedRightType]);
|
|
48891
49144
|
if ((0, types_1.isUnion)(newUnion)) {
|
|
48892
49145
|
types_1.TypeBase.setSpecialForm(newUnion);
|
|
@@ -49726,13 +49979,7 @@ var require_protocols = __commonJS({
|
|
|
49726
49979
|
if ((flags & 1) !== 0) {
|
|
49727
49980
|
return (0, types_1.isTypeSame)(destType, srcType);
|
|
49728
49981
|
}
|
|
49729
|
-
const
|
|
49730
|
-
destType,
|
|
49731
|
-
void 0,
|
|
49732
|
-
/* isTypeArgumentExplicit */
|
|
49733
|
-
false
|
|
49734
|
-
);
|
|
49735
|
-
const genericDestTypeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(destType));
|
|
49982
|
+
const protocolTypeVarContext = createProtocolTypeVarContext(evaluator, destType, destTypeVarContext);
|
|
49736
49983
|
const selfTypeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(destType));
|
|
49737
49984
|
const noLiteralSrcType = evaluator.stripLiteralValue(srcType);
|
|
49738
49985
|
(0, typeUtils_1.populateTypeVarContextForSelfType)(selfTypeVarContext, destType, noLiteralSrcType);
|
|
@@ -49763,282 +50010,286 @@ var require_protocols = __commonJS({
|
|
|
49763
50010
|
if (!typesAreConsistent && !diag) {
|
|
49764
50011
|
return;
|
|
49765
50012
|
}
|
|
49766
|
-
if (symbol.isClassMember()
|
|
49767
|
-
|
|
49768
|
-
|
|
49769
|
-
|
|
49770
|
-
|
|
50013
|
+
if (!symbol.isClassMember() || symbol.isIgnoredForProtocolMatch() || checkedSymbolSet.has(name)) {
|
|
50014
|
+
return;
|
|
50015
|
+
}
|
|
50016
|
+
let isMemberFromMetaclass = false;
|
|
50017
|
+
let srcMemberInfo;
|
|
50018
|
+
if (!treatSourceAsInstantiable && name === "__class_getitem__") {
|
|
50019
|
+
return;
|
|
50020
|
+
}
|
|
50021
|
+
if (name === "__slots__") {
|
|
50022
|
+
return;
|
|
50023
|
+
}
|
|
50024
|
+
checkedSymbolSet.add(name);
|
|
50025
|
+
if (treatSourceAsInstantiable && srcType.details.effectiveMetaclass && (0, types_1.isInstantiableClass)(srcType.details.effectiveMetaclass)) {
|
|
50026
|
+
srcMemberInfo = (0, typeUtils_1.lookUpClassMember)(srcType.details.effectiveMetaclass, name);
|
|
50027
|
+
if (srcMemberInfo) {
|
|
50028
|
+
srcClassTypeVarContext.addSolveForScope((0, typeUtils_1.getTypeVarScopeId)(srcType.details.effectiveMetaclass));
|
|
50029
|
+
isMemberFromMetaclass = true;
|
|
49771
50030
|
}
|
|
49772
|
-
|
|
49773
|
-
|
|
50031
|
+
}
|
|
50032
|
+
if (!srcMemberInfo) {
|
|
50033
|
+
srcMemberInfo = (0, typeUtils_1.lookUpClassMember)(srcType, name);
|
|
50034
|
+
}
|
|
50035
|
+
if (!srcMemberInfo) {
|
|
50036
|
+
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.protocolMemberMissing().format({ name }));
|
|
50037
|
+
typesAreConsistent = false;
|
|
50038
|
+
return;
|
|
50039
|
+
}
|
|
50040
|
+
if (symbol.isClassVar() && !srcMemberInfo.symbol.isClassVar() && !srcMemberInfo.symbol.isClassMember()) {
|
|
50041
|
+
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.protocolMemberClassVar().format({ name }));
|
|
50042
|
+
typesAreConsistent = false;
|
|
50043
|
+
}
|
|
50044
|
+
let destMemberType = (_a = evaluator.getDeclaredTypeOfSymbol(symbol)) === null || _a === void 0 ? void 0 : _a.type;
|
|
50045
|
+
if (!destMemberType) {
|
|
50046
|
+
return;
|
|
50047
|
+
}
|
|
50048
|
+
if (!types_1.ClassType.isSameGenericClass(mroClass, destType)) {
|
|
50049
|
+
destMemberType = (0, typeUtils_1.partiallySpecializeType)(destMemberType, mroClass, srcType);
|
|
50050
|
+
}
|
|
50051
|
+
let srcMemberType;
|
|
50052
|
+
if ((0, types_1.isInstantiableClass)(srcMemberInfo.classType)) {
|
|
50053
|
+
const symbolType = evaluator.getEffectiveTypeOfSymbol(srcMemberInfo.symbol);
|
|
50054
|
+
if ((0, types_1.isFunction)(symbolType)) {
|
|
50055
|
+
evaluator.inferReturnTypeIfNecessary(symbolType);
|
|
49774
50056
|
}
|
|
49775
|
-
|
|
49776
|
-
|
|
49777
|
-
|
|
49778
|
-
|
|
49779
|
-
|
|
49780
|
-
|
|
50057
|
+
srcMemberType = (0, typeUtils_1.partiallySpecializeType)(symbolType, srcMemberInfo.classType, noLiteralSrcType);
|
|
50058
|
+
} else {
|
|
50059
|
+
srcMemberType = types_1.UnknownType.create();
|
|
50060
|
+
}
|
|
50061
|
+
if ((0, types_1.isFunction)(srcMemberType) || (0, types_1.isOverloadedFunction)(srcMemberType)) {
|
|
50062
|
+
if (isMemberFromMetaclass) {
|
|
50063
|
+
const boundSrcFunction = evaluator.bindFunctionToClassOrObject(
|
|
50064
|
+
types_1.ClassType.cloneAsInstance(srcType),
|
|
50065
|
+
srcMemberType,
|
|
50066
|
+
/* memberClass */
|
|
50067
|
+
void 0,
|
|
50068
|
+
/* errorNode */
|
|
50069
|
+
void 0,
|
|
50070
|
+
recursionCount,
|
|
50071
|
+
/* treatConstructorAsClassMember */
|
|
50072
|
+
false,
|
|
50073
|
+
srcType
|
|
50074
|
+
);
|
|
50075
|
+
if (boundSrcFunction) {
|
|
50076
|
+
srcMemberType = (0, typeUtils_1.removeParamSpecVariadicsFromSignature)(boundSrcFunction);
|
|
50077
|
+
}
|
|
50078
|
+
if ((0, types_1.isFunction)(destMemberType) || (0, types_1.isOverloadedFunction)(destMemberType)) {
|
|
50079
|
+
const boundDeclaredType = evaluator.bindFunctionToClassOrObject(
|
|
50080
|
+
types_1.ClassType.cloneAsInstance(srcType),
|
|
50081
|
+
destMemberType,
|
|
50082
|
+
/* memberClass */
|
|
50083
|
+
void 0,
|
|
50084
|
+
/* errorNode */
|
|
50085
|
+
void 0,
|
|
50086
|
+
recursionCount,
|
|
50087
|
+
/* treatConstructorAsClassMember */
|
|
50088
|
+
false,
|
|
50089
|
+
srcType
|
|
50090
|
+
);
|
|
50091
|
+
if (boundDeclaredType) {
|
|
50092
|
+
destMemberType = (0, typeUtils_1.removeParamSpecVariadicsFromSignature)(boundDeclaredType);
|
|
50093
|
+
}
|
|
50094
|
+
}
|
|
50095
|
+
} else if ((0, types_1.isInstantiableClass)(srcMemberInfo.classType)) {
|
|
50096
|
+
destMemberType = (0, typeUtils_1.applySolvedTypeVars)(destMemberType, selfTypeVarContext);
|
|
50097
|
+
const boundSrcFunction = evaluator.bindFunctionToClassOrObject(
|
|
50098
|
+
treatSourceAsInstantiable ? srcType : types_1.ClassType.cloneAsInstance(srcType),
|
|
50099
|
+
srcMemberType,
|
|
50100
|
+
srcMemberInfo.classType,
|
|
50101
|
+
/* errorNode */
|
|
50102
|
+
void 0,
|
|
50103
|
+
recursionCount
|
|
50104
|
+
);
|
|
50105
|
+
if (boundSrcFunction) {
|
|
50106
|
+
srcMemberType = (0, typeUtils_1.removeParamSpecVariadicsFromSignature)(boundSrcFunction);
|
|
50107
|
+
}
|
|
50108
|
+
if ((0, types_1.isFunction)(destMemberType) || (0, types_1.isOverloadedFunction)(destMemberType)) {
|
|
50109
|
+
const boundDeclaredType = evaluator.bindFunctionToClassOrObject(
|
|
50110
|
+
types_1.ClassType.cloneAsInstance(srcType),
|
|
50111
|
+
destMemberType,
|
|
50112
|
+
srcMemberInfo.classType,
|
|
50113
|
+
/* errorNode */
|
|
50114
|
+
void 0,
|
|
50115
|
+
recursionCount
|
|
50116
|
+
);
|
|
50117
|
+
if (boundDeclaredType) {
|
|
50118
|
+
destMemberType = (0, typeUtils_1.removeParamSpecVariadicsFromSignature)(boundDeclaredType);
|
|
50119
|
+
}
|
|
49781
50120
|
}
|
|
49782
50121
|
}
|
|
49783
|
-
|
|
49784
|
-
|
|
49785
|
-
|
|
49786
|
-
|
|
49787
|
-
|
|
49788
|
-
|
|
50122
|
+
} else {
|
|
50123
|
+
destMemberType = (0, typeUtils_1.applySolvedTypeVars)(destMemberType, selfTypeVarContext);
|
|
50124
|
+
}
|
|
50125
|
+
const subDiag = diag === null || diag === void 0 ? void 0 : diag.createAddendum();
|
|
50126
|
+
if ((0, types_1.isClassInstance)(destMemberType) && types_1.ClassType.isPropertyClass(destMemberType)) {
|
|
50127
|
+
if ((0, types_1.isClassInstance)(srcMemberType) && types_1.ClassType.isPropertyClass(srcMemberType) && !treatSourceAsInstantiable) {
|
|
50128
|
+
if (!(0, properties_1.assignProperty)(evaluator, types_1.ClassType.cloneAsInstantiable(destMemberType), types_1.ClassType.cloneAsInstantiable(srcMemberType), mroClass, srcType, subDiag === null || subDiag === void 0 ? void 0 : subDiag.createAddendum(), protocolTypeVarContext, selfTypeVarContext, recursionCount)) {
|
|
50129
|
+
if (subDiag) {
|
|
50130
|
+
subDiag.addMessage(localize_1.Localizer.DiagnosticAddendum.memberTypeMismatch().format({ name }));
|
|
50131
|
+
}
|
|
50132
|
+
typesAreConsistent = false;
|
|
50133
|
+
}
|
|
49789
50134
|
} else {
|
|
49790
|
-
|
|
49791
|
-
|
|
49792
|
-
|
|
49793
|
-
|
|
49794
|
-
|
|
49795
|
-
|
|
49796
|
-
|
|
49797
|
-
|
|
49798
|
-
|
|
49799
|
-
|
|
49800
|
-
|
|
49801
|
-
|
|
49802
|
-
|
|
49803
|
-
|
|
49804
|
-
|
|
49805
|
-
if (
|
|
49806
|
-
|
|
49807
|
-
const boundSrcFunction = evaluator.bindFunctionToClassOrObject(
|
|
49808
|
-
types_1.ClassType.cloneAsInstance(srcType),
|
|
49809
|
-
srcMemberType,
|
|
49810
|
-
/* memberClass */
|
|
49811
|
-
void 0,
|
|
49812
|
-
/* errorNode */
|
|
49813
|
-
void 0,
|
|
49814
|
-
recursionCount,
|
|
49815
|
-
/* treatConstructorAsClassMember */
|
|
49816
|
-
false,
|
|
49817
|
-
srcType
|
|
49818
|
-
);
|
|
49819
|
-
if (boundSrcFunction) {
|
|
49820
|
-
srcMemberType = (0, typeUtils_1.removeParamSpecVariadicsFromSignature)(boundSrcFunction);
|
|
49821
|
-
}
|
|
49822
|
-
if ((0, types_1.isFunction)(destMemberType) || (0, types_1.isOverloadedFunction)(destMemberType)) {
|
|
49823
|
-
const boundDeclaredType = evaluator.bindFunctionToClassOrObject(
|
|
49824
|
-
types_1.ClassType.cloneAsInstance(srcType),
|
|
49825
|
-
destMemberType,
|
|
49826
|
-
/* memberClass */
|
|
49827
|
-
void 0,
|
|
49828
|
-
/* errorNode */
|
|
49829
|
-
void 0,
|
|
49830
|
-
recursionCount,
|
|
49831
|
-
/* treatConstructorAsClassMember */
|
|
49832
|
-
false,
|
|
49833
|
-
srcType
|
|
49834
|
-
);
|
|
49835
|
-
if (boundDeclaredType) {
|
|
49836
|
-
destMemberType = (0, typeUtils_1.removeParamSpecVariadicsFromSignature)(boundDeclaredType);
|
|
49837
|
-
}
|
|
49838
|
-
}
|
|
49839
|
-
} else if ((0, types_1.isInstantiableClass)(srcMemberInfo.classType)) {
|
|
49840
|
-
destMemberType = (0, typeUtils_1.applySolvedTypeVars)(destMemberType, selfTypeVarContext);
|
|
49841
|
-
const boundSrcFunction = evaluator.bindFunctionToClassOrObject(
|
|
49842
|
-
treatSourceAsInstantiable ? srcType : types_1.ClassType.cloneAsInstance(srcType),
|
|
49843
|
-
srcMemberType,
|
|
49844
|
-
srcMemberInfo.classType,
|
|
49845
|
-
/* errorNode */
|
|
49846
|
-
void 0,
|
|
49847
|
-
recursionCount
|
|
49848
|
-
);
|
|
49849
|
-
if (boundSrcFunction) {
|
|
49850
|
-
srcMemberType = (0, typeUtils_1.removeParamSpecVariadicsFromSignature)(boundSrcFunction);
|
|
49851
|
-
}
|
|
49852
|
-
if ((0, types_1.isFunction)(destMemberType) || (0, types_1.isOverloadedFunction)(destMemberType)) {
|
|
49853
|
-
const boundDeclaredType = evaluator.bindFunctionToClassOrObject(
|
|
49854
|
-
types_1.ClassType.cloneAsInstance(srcType),
|
|
49855
|
-
destMemberType,
|
|
49856
|
-
srcMemberInfo.classType,
|
|
49857
|
-
/* errorNode */
|
|
49858
|
-
void 0,
|
|
49859
|
-
recursionCount
|
|
49860
|
-
);
|
|
49861
|
-
if (boundDeclaredType) {
|
|
49862
|
-
destMemberType = (0, typeUtils_1.removeParamSpecVariadicsFromSignature)(boundDeclaredType);
|
|
49863
|
-
}
|
|
49864
|
-
}
|
|
49865
|
-
}
|
|
49866
|
-
} else {
|
|
49867
|
-
destMemberType = (0, typeUtils_1.applySolvedTypeVars)(destMemberType, selfTypeVarContext);
|
|
49868
|
-
}
|
|
49869
|
-
const subDiag = diag === null || diag === void 0 ? void 0 : diag.createAddendum();
|
|
49870
|
-
if ((0, types_1.isClassInstance)(destMemberType) && types_1.ClassType.isPropertyClass(destMemberType)) {
|
|
49871
|
-
if ((0, types_1.isClassInstance)(srcMemberType) && types_1.ClassType.isPropertyClass(srcMemberType) && !treatSourceAsInstantiable) {
|
|
49872
|
-
if (!(0, properties_1.assignProperty)(evaluator, types_1.ClassType.cloneAsInstantiable(destMemberType), types_1.ClassType.cloneAsInstantiable(srcMemberType), mroClass, srcType, subDiag === null || subDiag === void 0 ? void 0 : subDiag.createAddendum(), genericDestTypeVarContext, selfTypeVarContext, recursionCount)) {
|
|
49873
|
-
if (subDiag) {
|
|
49874
|
-
subDiag.addMessage(localize_1.Localizer.DiagnosticAddendum.memberTypeMismatch().format({ name }));
|
|
49875
|
-
}
|
|
49876
|
-
typesAreConsistent = false;
|
|
49877
|
-
}
|
|
49878
|
-
} else {
|
|
49879
|
-
const getterType = evaluator.getGetterTypeFromProperty(
|
|
49880
|
-
destMemberType,
|
|
49881
|
-
/* inferTypeIfNeeded */
|
|
49882
|
-
true
|
|
49883
|
-
);
|
|
49884
|
-
if (!getterType || !evaluator.assignType(
|
|
49885
|
-
getterType,
|
|
49886
|
-
srcMemberType,
|
|
49887
|
-
subDiag === null || subDiag === void 0 ? void 0 : subDiag.createAddendum(),
|
|
49888
|
-
genericDestTypeVarContext,
|
|
49889
|
-
/* srcTypeVarContext */
|
|
49890
|
-
void 0,
|
|
49891
|
-
assignTypeFlags,
|
|
49892
|
-
recursionCount
|
|
49893
|
-
)) {
|
|
49894
|
-
if (subDiag) {
|
|
49895
|
-
subDiag.addMessage(localize_1.Localizer.DiagnosticAddendum.memberTypeMismatch().format({ name }));
|
|
49896
|
-
}
|
|
49897
|
-
typesAreConsistent = false;
|
|
49898
|
-
}
|
|
49899
|
-
}
|
|
49900
|
-
} else {
|
|
49901
|
-
const primaryDecl = symbol.getDeclarations()[0];
|
|
49902
|
-
const isInvariant = (primaryDecl === null || primaryDecl === void 0 ? void 0 : primaryDecl.type) === 1 && !primaryDecl.isFinal;
|
|
49903
|
-
if (!evaluator.assignType(
|
|
49904
|
-
destMemberType,
|
|
49905
|
-
srcMemberType,
|
|
49906
|
-
subDiag === null || subDiag === void 0 ? void 0 : subDiag.createAddendum(),
|
|
49907
|
-
genericDestTypeVarContext,
|
|
49908
|
-
/* srcTypeVarContext */
|
|
49909
|
-
void 0,
|
|
49910
|
-
isInvariant ? assignTypeFlags | 1 : assignTypeFlags,
|
|
49911
|
-
recursionCount
|
|
49912
|
-
)) {
|
|
49913
|
-
if (subDiag) {
|
|
49914
|
-
if (isInvariant) {
|
|
49915
|
-
subDiag.addMessage(localize_1.Localizer.DiagnosticAddendum.memberIsInvariant().format({ name }));
|
|
49916
|
-
}
|
|
49917
|
-
subDiag.addMessage(localize_1.Localizer.DiagnosticAddendum.memberTypeMismatch().format({ name }));
|
|
49918
|
-
}
|
|
49919
|
-
typesAreConsistent = false;
|
|
49920
|
-
}
|
|
50135
|
+
const getterType = evaluator.getGetterTypeFromProperty(
|
|
50136
|
+
destMemberType,
|
|
50137
|
+
/* inferTypeIfNeeded */
|
|
50138
|
+
true
|
|
50139
|
+
);
|
|
50140
|
+
if (!getterType || !evaluator.assignType(
|
|
50141
|
+
getterType,
|
|
50142
|
+
srcMemberType,
|
|
50143
|
+
subDiag === null || subDiag === void 0 ? void 0 : subDiag.createAddendum(),
|
|
50144
|
+
protocolTypeVarContext,
|
|
50145
|
+
/* srcTypeVarContext */
|
|
50146
|
+
void 0,
|
|
50147
|
+
assignTypeFlags,
|
|
50148
|
+
recursionCount
|
|
50149
|
+
)) {
|
|
50150
|
+
if (subDiag) {
|
|
50151
|
+
subDiag.addMessage(localize_1.Localizer.DiagnosticAddendum.memberTypeMismatch().format({ name }));
|
|
49921
50152
|
}
|
|
49922
|
-
|
|
49923
|
-
|
|
49924
|
-
|
|
49925
|
-
|
|
49926
|
-
|
|
49927
|
-
|
|
49928
|
-
|
|
49929
|
-
|
|
49930
|
-
|
|
49931
|
-
|
|
49932
|
-
|
|
49933
|
-
|
|
49934
|
-
|
|
50153
|
+
typesAreConsistent = false;
|
|
50154
|
+
}
|
|
50155
|
+
}
|
|
50156
|
+
} else {
|
|
50157
|
+
const primaryDecl = symbol.getDeclarations()[0];
|
|
50158
|
+
const isInvariant = (primaryDecl === null || primaryDecl === void 0 ? void 0 : primaryDecl.type) === 1 && !primaryDecl.isFinal;
|
|
50159
|
+
if (!evaluator.assignType(
|
|
50160
|
+
destMemberType,
|
|
50161
|
+
srcMemberType,
|
|
50162
|
+
subDiag === null || subDiag === void 0 ? void 0 : subDiag.createAddendum(),
|
|
50163
|
+
protocolTypeVarContext,
|
|
50164
|
+
/* srcTypeVarContext */
|
|
50165
|
+
void 0,
|
|
50166
|
+
isInvariant ? assignTypeFlags | 1 : assignTypeFlags,
|
|
50167
|
+
recursionCount
|
|
50168
|
+
)) {
|
|
50169
|
+
if (subDiag) {
|
|
50170
|
+
if (isInvariant) {
|
|
50171
|
+
subDiag.addMessage(localize_1.Localizer.DiagnosticAddendum.memberIsInvariant().format({ name }));
|
|
49935
50172
|
}
|
|
50173
|
+
subDiag.addMessage(localize_1.Localizer.DiagnosticAddendum.memberTypeMismatch().format({ name }));
|
|
49936
50174
|
}
|
|
49937
|
-
|
|
49938
|
-
|
|
49939
|
-
|
|
50175
|
+
typesAreConsistent = false;
|
|
50176
|
+
}
|
|
50177
|
+
}
|
|
50178
|
+
const isDestFinal = symbol.getTypedDeclarations().some((decl) => decl.type === 1 && !!decl.isFinal);
|
|
50179
|
+
const isSrcFinal = srcMemberInfo.symbol.getTypedDeclarations().some((decl) => decl.type === 1 && !!decl.isFinal);
|
|
50180
|
+
if (isDestFinal !== isSrcFinal) {
|
|
50181
|
+
if (isDestFinal) {
|
|
50182
|
+
if (subDiag) {
|
|
50183
|
+
subDiag.addMessage(localize_1.Localizer.DiagnosticAddendum.memberIsFinalInProtocol().format({ name }));
|
|
50184
|
+
}
|
|
50185
|
+
} else {
|
|
50186
|
+
if (subDiag) {
|
|
50187
|
+
subDiag.addMessage(localize_1.Localizer.DiagnosticAddendum.memberIsNotFinalInProtocol().format({ name }));
|
|
49940
50188
|
}
|
|
49941
50189
|
}
|
|
50190
|
+
typesAreConsistent = false;
|
|
49942
50191
|
}
|
|
49943
50192
|
});
|
|
49944
50193
|
});
|
|
49945
50194
|
if (typesAreConsistent && destType.details.typeParameters.length > 0) {
|
|
49946
|
-
const
|
|
50195
|
+
const genericProtocolType = types_1.ClassType.cloneForSpecialization(
|
|
50196
|
+
destType,
|
|
50197
|
+
void 0,
|
|
50198
|
+
/* isTypeArgumentExplicit */
|
|
50199
|
+
false
|
|
50200
|
+
);
|
|
50201
|
+
const specializedProtocolType = (0, typeUtils_1.applySolvedTypeVars)(genericProtocolType, protocolTypeVarContext);
|
|
49947
50202
|
if (destType.typeArguments) {
|
|
49948
|
-
if (!evaluator.verifyTypeArgumentsAssignable(destType,
|
|
50203
|
+
if (!evaluator.verifyTypeArgumentsAssignable(destType, specializedProtocolType, diag, destTypeVarContext, srcTypeVarContext, flags, recursionCount)) {
|
|
49949
50204
|
typesAreConsistent = false;
|
|
49950
50205
|
}
|
|
49951
|
-
} else if (destTypeVarContext &&
|
|
49952
|
-
const
|
|
49953
|
-
|
|
49954
|
-
|
|
49955
|
-
|
|
49956
|
-
|
|
49957
|
-
/* narrowBound */
|
|
49958
|
-
void 0,
|
|
49959
|
-
/* narrowBoundNoLiterals */
|
|
49960
|
-
void 0,
|
|
49961
|
-
typeArgType
|
|
49962
|
-
);
|
|
50206
|
+
} else if (destTypeVarContext && !destTypeVarContext.isLocked()) {
|
|
50207
|
+
for (const typeParam of destType.details.typeParameters) {
|
|
50208
|
+
const typeArgEntry = protocolTypeVarContext.getPrimarySignature().getTypeVar(typeParam);
|
|
50209
|
+
if (typeArgEntry) {
|
|
50210
|
+
destTypeVarContext.setTypeVarType(typeParam, typeArgEntry === null || typeArgEntry === void 0 ? void 0 : typeArgEntry.narrowBound, typeArgEntry === null || typeArgEntry === void 0 ? void 0 : typeArgEntry.narrowBoundNoLiterals, typeArgEntry === null || typeArgEntry === void 0 ? void 0 : typeArgEntry.wideBound);
|
|
50211
|
+
}
|
|
49963
50212
|
}
|
|
49964
50213
|
}
|
|
49965
50214
|
}
|
|
49966
50215
|
return typesAreConsistent;
|
|
49967
50216
|
}
|
|
49968
|
-
function assignModuleToProtocol(evaluator, destType, srcType, diag,
|
|
50217
|
+
function assignModuleToProtocol(evaluator, destType, srcType, diag, destTypeVarContext, flags, recursionCount) {
|
|
49969
50218
|
if (recursionCount > types_1.maxTypeRecursionCount) {
|
|
49970
50219
|
return true;
|
|
49971
50220
|
}
|
|
49972
50221
|
recursionCount++;
|
|
49973
50222
|
let typesAreConsistent = true;
|
|
49974
50223
|
const checkedSymbolSet = /* @__PURE__ */ new Set();
|
|
49975
|
-
const
|
|
49976
|
-
destType,
|
|
49977
|
-
void 0,
|
|
49978
|
-
/* isTypeArgumentExplicit */
|
|
49979
|
-
false
|
|
49980
|
-
);
|
|
49981
|
-
const genericDestTypeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(destType));
|
|
50224
|
+
const protocolTypeVarContext = createProtocolTypeVarContext(evaluator, destType, destTypeVarContext);
|
|
49982
50225
|
destType.details.mro.forEach((mroClass) => {
|
|
49983
50226
|
if (!(0, types_1.isInstantiableClass)(mroClass) || !types_1.ClassType.isProtocolClass(mroClass)) {
|
|
49984
50227
|
return;
|
|
49985
50228
|
}
|
|
49986
50229
|
mroClass.details.fields.forEach((symbol, name) => {
|
|
49987
50230
|
var _a;
|
|
49988
|
-
if (symbol.isClassMember()
|
|
49989
|
-
|
|
49990
|
-
|
|
49991
|
-
|
|
49992
|
-
|
|
49993
|
-
|
|
49994
|
-
|
|
49995
|
-
|
|
49996
|
-
|
|
49997
|
-
|
|
49998
|
-
|
|
49999
|
-
|
|
50000
|
-
|
|
50001
|
-
|
|
50002
|
-
|
|
50003
|
-
|
|
50004
|
-
|
|
50005
|
-
|
|
50006
|
-
|
|
50007
|
-
|
|
50008
|
-
|
|
50009
|
-
|
|
50010
|
-
|
|
50011
|
-
|
|
50012
|
-
|
|
50013
|
-
|
|
50014
|
-
|
|
50015
|
-
|
|
50016
|
-
destMemberType,
|
|
50017
|
-
srcMemberType,
|
|
50018
|
-
subDiag === null || subDiag === void 0 ? void 0 : subDiag.createAddendum(),
|
|
50019
|
-
genericDestTypeVarContext,
|
|
50020
|
-
/* srcTypeVarContext */
|
|
50021
|
-
void 0,
|
|
50022
|
-
0,
|
|
50023
|
-
recursionCount
|
|
50024
|
-
)) {
|
|
50025
|
-
if (subDiag) {
|
|
50026
|
-
subDiag.addMessage(localize_1.Localizer.DiagnosticAddendum.memberTypeMismatch().format({ name }));
|
|
50027
|
-
}
|
|
50028
|
-
typesAreConsistent = false;
|
|
50029
|
-
}
|
|
50231
|
+
if (!symbol.isClassMember() || symbol.isIgnoredForProtocolMatch() || checkedSymbolSet.has(name)) {
|
|
50232
|
+
return;
|
|
50233
|
+
}
|
|
50234
|
+
checkedSymbolSet.add(name);
|
|
50235
|
+
const memberSymbol = srcType.fields.get(name);
|
|
50236
|
+
if (!memberSymbol) {
|
|
50237
|
+
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.protocolMemberMissing().format({ name }));
|
|
50238
|
+
typesAreConsistent = false;
|
|
50239
|
+
return;
|
|
50240
|
+
}
|
|
50241
|
+
let destMemberType = (_a = evaluator.getDeclaredTypeOfSymbol(symbol)) === null || _a === void 0 ? void 0 : _a.type;
|
|
50242
|
+
if (!destMemberType) {
|
|
50243
|
+
return;
|
|
50244
|
+
}
|
|
50245
|
+
destMemberType = (0, typeUtils_1.partiallySpecializeType)(destMemberType, destType);
|
|
50246
|
+
const srcMemberType = evaluator.getEffectiveTypeOfSymbol(memberSymbol);
|
|
50247
|
+
if ((0, types_1.isFunction)(srcMemberType) || (0, types_1.isOverloadedFunction)(srcMemberType)) {
|
|
50248
|
+
if ((0, types_1.isFunction)(destMemberType) || (0, types_1.isOverloadedFunction)(destMemberType)) {
|
|
50249
|
+
const boundDeclaredType = evaluator.bindFunctionToClassOrObject(
|
|
50250
|
+
types_1.ClassType.cloneAsInstance(destType),
|
|
50251
|
+
destMemberType,
|
|
50252
|
+
destType,
|
|
50253
|
+
/* errorNode */
|
|
50254
|
+
void 0,
|
|
50255
|
+
recursionCount
|
|
50256
|
+
);
|
|
50257
|
+
if (boundDeclaredType) {
|
|
50258
|
+
destMemberType = boundDeclaredType;
|
|
50030
50259
|
}
|
|
50031
50260
|
}
|
|
50032
50261
|
}
|
|
50262
|
+
const subDiag = diag === null || diag === void 0 ? void 0 : diag.createAddendum();
|
|
50263
|
+
if (!evaluator.assignType(
|
|
50264
|
+
destMemberType,
|
|
50265
|
+
srcMemberType,
|
|
50266
|
+
subDiag === null || subDiag === void 0 ? void 0 : subDiag.createAddendum(),
|
|
50267
|
+
protocolTypeVarContext,
|
|
50268
|
+
/* srcTypeVarContext */
|
|
50269
|
+
void 0,
|
|
50270
|
+
0,
|
|
50271
|
+
recursionCount
|
|
50272
|
+
)) {
|
|
50273
|
+
if (subDiag) {
|
|
50274
|
+
subDiag.addMessage(localize_1.Localizer.DiagnosticAddendum.memberTypeMismatch().format({ name }));
|
|
50275
|
+
}
|
|
50276
|
+
typesAreConsistent = false;
|
|
50277
|
+
}
|
|
50033
50278
|
});
|
|
50034
50279
|
});
|
|
50035
50280
|
if (typesAreConsistent && destType.details.typeParameters.length > 0 && destType.typeArguments) {
|
|
50036
|
-
const
|
|
50281
|
+
const genericProtocolType = types_1.ClassType.cloneForSpecialization(
|
|
50282
|
+
destType,
|
|
50283
|
+
void 0,
|
|
50284
|
+
/* isTypeArgumentExplicit */
|
|
50285
|
+
false
|
|
50286
|
+
);
|
|
50287
|
+
const specializedProtocolType = (0, typeUtils_1.applySolvedTypeVars)(genericProtocolType, protocolTypeVarContext);
|
|
50037
50288
|
if (!evaluator.verifyTypeArgumentsAssignable(
|
|
50038
50289
|
destType,
|
|
50039
|
-
|
|
50290
|
+
specializedProtocolType,
|
|
50040
50291
|
diag,
|
|
50041
|
-
|
|
50292
|
+
destTypeVarContext,
|
|
50042
50293
|
/* srcTypeVarContext */
|
|
50043
50294
|
void 0,
|
|
50044
50295
|
flags,
|
|
@@ -50050,6 +50301,34 @@ var require_protocols = __commonJS({
|
|
|
50050
50301
|
return typesAreConsistent;
|
|
50051
50302
|
}
|
|
50052
50303
|
exports.assignModuleToProtocol = assignModuleToProtocol;
|
|
50304
|
+
function createProtocolTypeVarContext(evaluator, destType, destTypeVarContext) {
|
|
50305
|
+
const protocolTypeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(destType));
|
|
50306
|
+
if (destType === null || destType === void 0 ? void 0 : destType.typeArguments) {
|
|
50307
|
+
evaluator.inferTypeParameterVarianceForClass(destType);
|
|
50308
|
+
let specializedDestType = destType;
|
|
50309
|
+
if (destTypeVarContext) {
|
|
50310
|
+
specializedDestType = (0, typeUtils_1.applySolvedTypeVars)(destType, destTypeVarContext, {
|
|
50311
|
+
useNarrowBoundOnly: true
|
|
50312
|
+
});
|
|
50313
|
+
}
|
|
50314
|
+
destType.details.typeParameters.forEach((typeParam, index) => {
|
|
50315
|
+
if (index < specializedDestType.typeArguments.length) {
|
|
50316
|
+
const typeArg = specializedDestType.typeArguments[index];
|
|
50317
|
+
if (!(0, typeUtils_1.requiresSpecialization)(typeArg)) {
|
|
50318
|
+
const typeParamVariance = types_1.TypeVarType.getVariance(typeParam);
|
|
50319
|
+
protocolTypeVarContext.setTypeVarType(
|
|
50320
|
+
typeParam,
|
|
50321
|
+
typeParamVariance !== 4 ? typeArg : void 0,
|
|
50322
|
+
/* narrowBoundNoLiterals */
|
|
50323
|
+
void 0,
|
|
50324
|
+
typeParamVariance !== 3 ? typeArg : void 0
|
|
50325
|
+
);
|
|
50326
|
+
}
|
|
50327
|
+
}
|
|
50328
|
+
});
|
|
50329
|
+
}
|
|
50330
|
+
return protocolTypeVarContext;
|
|
50331
|
+
}
|
|
50053
50332
|
}
|
|
50054
50333
|
});
|
|
50055
50334
|
|
|
@@ -51593,9 +51872,22 @@ var require_typeEvaluator = __commonJS({
|
|
|
51593
51872
|
);
|
|
51594
51873
|
if (inferenceContext && !(0, types_1.isAnyOrUnknown)(inferenceContext.expectedType) && !(0, types_1.isNever)(inferenceContext.expectedType)) {
|
|
51595
51874
|
expectedTypeCache.set(node.id, inferenceContext.expectedType);
|
|
51875
|
+
if (inferenceContext.signatureTracker && (0, types_1.isFunction)(typeResult.type)) {
|
|
51876
|
+
typeResult.type = (0, typeUtils_1.ensureFunctionSignaturesAreUnique)(typeResult.type, inferenceContext.signatureTracker, node.start);
|
|
51877
|
+
}
|
|
51596
51878
|
if (!typeResult.isIncomplete && !typeResult.expectedTypeDiagAddendum) {
|
|
51597
51879
|
const diag = new diagnostic_1.DiagnosticAddendum();
|
|
51598
|
-
if (!assignType(
|
|
51880
|
+
if (!assignType(
|
|
51881
|
+
inferenceContext.expectedType,
|
|
51882
|
+
typeResult.type,
|
|
51883
|
+
diag,
|
|
51884
|
+
/* destTypeVarContext */
|
|
51885
|
+
void 0,
|
|
51886
|
+
/* srcTypeVarContext */
|
|
51887
|
+
void 0,
|
|
51888
|
+
512
|
|
51889
|
+
/* IgnoreTypeVarScope */
|
|
51890
|
+
)) {
|
|
51599
51891
|
typeResult.typeErrors = true;
|
|
51600
51892
|
typeResult.expectedTypeDiagAddendum = diag;
|
|
51601
51893
|
diag.addTextRange(node);
|
|
@@ -51899,6 +52191,9 @@ var require_typeEvaluator = __commonJS({
|
|
|
51899
52191
|
flags |= 2;
|
|
51900
52192
|
}
|
|
51901
52193
|
const decoratorTypeResult = getTypeOfExpression(node.expression, flags);
|
|
52194
|
+
if ((0, types_1.isFunction)(decoratorTypeResult.type) && decoratorTypeResult.type.details.builtInName === "type_check_only") {
|
|
52195
|
+
return functionOrClassType;
|
|
52196
|
+
}
|
|
51902
52197
|
if ((0, types_1.isInstantiableClass)(decoratorTypeResult.type) && types_1.ClassType.isBuiltIn(decoratorTypeResult.type, "classmethod") && (0, typeUtils_1.isProperty)(functionOrClassType)) {
|
|
51903
52198
|
return functionOrClassType;
|
|
51904
52199
|
}
|
|
@@ -53985,11 +54280,13 @@ var require_typeEvaluator = __commonJS({
|
|
|
53985
54280
|
return type;
|
|
53986
54281
|
}
|
|
53987
54282
|
if ((0, types_1.isInstantiableClass)(type)) {
|
|
53988
|
-
if ((flags & 128) !== 0) {
|
|
53989
|
-
if ((0, typeUtils_1.requiresTypeArguments)(type)
|
|
53990
|
-
|
|
53991
|
-
|
|
53992
|
-
|
|
54283
|
+
if ((flags & 128) !== 0 && (flags & 512) === 0) {
|
|
54284
|
+
if (!type.typeAliasInfo && (0, typeUtils_1.requiresTypeArguments)(type)) {
|
|
54285
|
+
if (!type.typeArguments || !type.isTypeArgumentExplicit) {
|
|
54286
|
+
addDiagnostic(AnalyzerNodeInfo.getFileInfo(node).diagnosticRuleSet.reportMissingTypeArgument, diagnosticRules_1.DiagnosticRule.reportMissingTypeArgument, localize_1.Localizer.Diagnostic.typeArgsMissingForClass().format({
|
|
54287
|
+
name: type.aliasName || type.details.name
|
|
54288
|
+
}), node);
|
|
54289
|
+
}
|
|
53993
54290
|
}
|
|
53994
54291
|
}
|
|
53995
54292
|
if (!type.typeArguments) {
|
|
@@ -55940,7 +56237,12 @@ var require_typeEvaluator = __commonJS({
|
|
|
55940
56237
|
}
|
|
55941
56238
|
let expectedTypeDiagAddendum;
|
|
55942
56239
|
if (effectiveExpectedType) {
|
|
55943
|
-
const result = getTypeOfTupleWithContext(node, (0, typeUtils_1.makeInferenceContext)(
|
|
56240
|
+
const result = getTypeOfTupleWithContext(node, (0, typeUtils_1.makeInferenceContext)(
|
|
56241
|
+
effectiveExpectedType,
|
|
56242
|
+
/* isTypeIncomplete */
|
|
56243
|
+
false,
|
|
56244
|
+
inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.signatureTracker
|
|
56245
|
+
));
|
|
55944
56246
|
if (result && !result.typeErrors) {
|
|
55945
56247
|
return result;
|
|
55946
56248
|
}
|
|
@@ -55975,7 +56277,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
55975
56277
|
}
|
|
55976
56278
|
} else {
|
|
55977
56279
|
const tupleTypeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(tupleClassType));
|
|
55978
|
-
if (!(0, constraintSolver_1.populateTypeVarContextBasedOnExpectedType)(evaluatorInterface, types_1.ClassType.cloneAsInstance(tupleClassType), inferenceContext.expectedType, tupleTypeVarContext, ParseTreeUtils.getTypeVarScopesForNode(node))) {
|
|
56280
|
+
if (!(0, constraintSolver_1.populateTypeVarContextBasedOnExpectedType)(evaluatorInterface, types_1.ClassType.cloneAsInstance(tupleClassType), inferenceContext.expectedType, tupleTypeVarContext, ParseTreeUtils.getTypeVarScopesForNode(node), node.start)) {
|
|
55979
56281
|
return void 0;
|
|
55980
56282
|
}
|
|
55981
56283
|
const specializedTuple = (0, typeUtils_1.applySolvedTypeVars)(tupleClassType, tupleTypeVarContext);
|
|
@@ -55991,7 +56293,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
55991
56293
|
expr,
|
|
55992
56294
|
/* flags */
|
|
55993
56295
|
void 0,
|
|
55994
|
-
(0, typeUtils_1.makeInferenceContext)(index < expectedTypes.length ? expectedTypes[index] : void 0)
|
|
56296
|
+
(0, typeUtils_1.makeInferenceContext)(index < expectedTypes.length ? expectedTypes[index] : void 0, inferenceContext.isTypeIncomplete, inferenceContext.signatureTracker)
|
|
55995
56297
|
));
|
|
55996
56298
|
const isIncomplete = entryTypeResults.some((result) => result.isIncomplete);
|
|
55997
56299
|
const type = (0, typeUtils_1.convertToInstance)((0, typeUtils_1.specializeTupleClass)(
|
|
@@ -56079,6 +56381,9 @@ var require_typeEvaluator = __commonJS({
|
|
|
56079
56381
|
return functionArg;
|
|
56080
56382
|
});
|
|
56081
56383
|
let typeResult = { type: types_1.UnknownType.create() };
|
|
56384
|
+
if (inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.signatureTracker) {
|
|
56385
|
+
baseTypeResult.type = (0, typeUtils_1.ensureFunctionSignaturesAreUnique)(baseTypeResult.type, inferenceContext.signatureTracker, node.leftExpression.start);
|
|
56386
|
+
}
|
|
56082
56387
|
if (!(0, typeUtils_1.isTypeAliasPlaceholder)(baseTypeResult.type)) {
|
|
56083
56388
|
if (node.leftExpression.nodeType === 38 && node.leftExpression.value === "super") {
|
|
56084
56389
|
typeResult = getTypeOfSuperCall(node);
|
|
@@ -56305,9 +56610,12 @@ var require_typeEvaluator = __commonJS({
|
|
|
56305
56610
|
return types_1.NoneType.createInstance();
|
|
56306
56611
|
}
|
|
56307
56612
|
function getTypeOfSuperCall(node) {
|
|
56613
|
+
var _a;
|
|
56308
56614
|
if (node.arguments.length > 2) {
|
|
56309
56615
|
addError(localize_1.Localizer.Diagnostic.superCallArgCount(), node.arguments[2]);
|
|
56310
56616
|
}
|
|
56617
|
+
const enclosingClass = ParseTreeUtils.getEnclosingClass(node);
|
|
56618
|
+
const enclosingClassType = enclosingClass ? (_a = getTypeOfClass(enclosingClass)) === null || _a === void 0 ? void 0 : _a.classType : void 0;
|
|
56311
56619
|
let targetClassType;
|
|
56312
56620
|
if (node.arguments.length > 0) {
|
|
56313
56621
|
targetClassType = getTypeOfExpression(node.arguments[0].valueExpression).type;
|
|
@@ -56316,10 +56624,8 @@ var require_typeEvaluator = __commonJS({
|
|
|
56316
56624
|
addDiagnostic(AnalyzerNodeInfo.getFileInfo(node).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.superCallFirstArg().format({ type: printType(targetClassType) }), node.arguments[0].valueExpression);
|
|
56317
56625
|
}
|
|
56318
56626
|
} else {
|
|
56319
|
-
|
|
56320
|
-
|
|
56321
|
-
const classTypeInfo = getTypeOfClass(enclosingClass);
|
|
56322
|
-
targetClassType = classTypeInfo ? classTypeInfo.classType : types_1.UnknownType.create();
|
|
56627
|
+
if (enclosingClassType) {
|
|
56628
|
+
targetClassType = enclosingClassType !== null && enclosingClassType !== void 0 ? enclosingClassType : types_1.UnknownType.create();
|
|
56323
56629
|
} else {
|
|
56324
56630
|
addError(localize_1.Localizer.Diagnostic.superCallZeroArgForm(), node.leftExpression);
|
|
56325
56631
|
targetClassType = types_1.UnknownType.create();
|
|
@@ -56361,28 +56667,23 @@ var require_typeEvaluator = __commonJS({
|
|
|
56361
56667
|
const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
|
|
56362
56668
|
addDiagnostic(fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.superCallSecondArg().format({ type: printType(targetClassType) }), node.arguments[1].valueExpression);
|
|
56363
56669
|
}
|
|
56364
|
-
} else {
|
|
56670
|
+
} else if (enclosingClassType) {
|
|
56671
|
+
bindToType = types_1.ClassType.cloneAsInstance(enclosingClassType);
|
|
56365
56672
|
const enclosingMethod = ParseTreeUtils.getEnclosingFunction(node);
|
|
56366
56673
|
let implicitBindToType;
|
|
56367
56674
|
if (enclosingMethod) {
|
|
56368
56675
|
const methodTypeInfo = getTypeOfFunction(enclosingMethod);
|
|
56369
56676
|
if (methodTypeInfo) {
|
|
56370
56677
|
const methodType = methodTypeInfo.functionType;
|
|
56371
|
-
if (types_1.FunctionType.isClassMethod(methodType)) {
|
|
56678
|
+
if (types_1.FunctionType.isClassMethod(methodType) || types_1.FunctionType.isConstructorMethod(methodType) || types_1.FunctionType.isInstanceMethod(methodType)) {
|
|
56372
56679
|
if (methodType.details.parameters.length > 0 && methodType.details.parameters[0].hasDeclaredType) {
|
|
56373
56680
|
implicitBindToType = makeTopLevelTypeVarsConcrete(methodType.details.parameters[0].type);
|
|
56374
56681
|
}
|
|
56375
|
-
} else if (types_1.FunctionType.isInstanceMethod(methodType)) {
|
|
56376
|
-
if (methodType.details.parameters.length > 0 && methodType.details.parameters[0].hasDeclaredType) {
|
|
56377
|
-
implicitBindToType = makeTopLevelTypeVarsConcrete((0, typeUtils_1.convertToInstantiable)(methodType.details.parameters[0].type));
|
|
56378
|
-
}
|
|
56379
56682
|
}
|
|
56380
56683
|
}
|
|
56381
56684
|
}
|
|
56382
|
-
if (
|
|
56383
|
-
bindToType = implicitBindToType;
|
|
56384
|
-
} else if ((0, types_1.isInstantiableClass)(targetClassType)) {
|
|
56385
|
-
bindToType = targetClassType;
|
|
56685
|
+
if (bindToType && implicitBindToType) {
|
|
56686
|
+
bindToType = (0, typeUtils_1.addConditionToType)(bindToType, (0, typeUtils_1.getTypeCondition)(implicitBindToType));
|
|
56386
56687
|
}
|
|
56387
56688
|
}
|
|
56388
56689
|
let resultIsInstance = true;
|
|
@@ -56400,12 +56701,8 @@ var require_typeEvaluator = __commonJS({
|
|
|
56400
56701
|
const parentNode = node.parent;
|
|
56401
56702
|
if (parentNode.nodeType === 35) {
|
|
56402
56703
|
const memberName = parentNode.memberName.value;
|
|
56403
|
-
const
|
|
56404
|
-
|
|
56405
|
-
memberName,
|
|
56406
|
-
1
|
|
56407
|
-
/* SkipOriginalClass */
|
|
56408
|
-
);
|
|
56704
|
+
const effectiveTargetClass = (0, types_1.isClass)(targetClassType) ? targetClassType : void 0;
|
|
56705
|
+
const lookupResults = bindToType ? (0, typeUtils_1.lookUpClassMember)(bindToType, memberName, 0, effectiveTargetClass) : void 0;
|
|
56409
56706
|
if (lookupResults && (0, types_1.isInstantiableClass)(lookupResults.classType)) {
|
|
56410
56707
|
return {
|
|
56411
56708
|
type: resultIsInstance ? types_1.ClassType.cloneAsInstance(lookupResults.classType) : lookupResults.classType,
|
|
@@ -56509,16 +56806,26 @@ var require_typeEvaluator = __commonJS({
|
|
|
56509
56806
|
let isSubtypeSubsumed = false;
|
|
56510
56807
|
for (let dedupedIndex = 0; dedupedIndex < dedupedMatchResults.length; dedupedIndex++) {
|
|
56511
56808
|
if (assignType(dedupedMatchResults[dedupedIndex], result.returnType)) {
|
|
56512
|
-
|
|
56809
|
+
const anyOrUnknown = (0, typeUtils_1.containsAnyOrUnknown)(
|
|
56810
|
+
dedupedMatchResults[dedupedIndex],
|
|
56811
|
+
/* recurse */
|
|
56812
|
+
false
|
|
56813
|
+
);
|
|
56814
|
+
if (!anyOrUnknown) {
|
|
56513
56815
|
isSubtypeSubsumed = true;
|
|
56514
|
-
} else if (
|
|
56816
|
+
} else if ((0, types_1.isAny)(anyOrUnknown)) {
|
|
56515
56817
|
dedupedResultsIncludeAny = true;
|
|
56516
56818
|
}
|
|
56517
56819
|
break;
|
|
56518
56820
|
} else if (assignType(result.returnType, dedupedMatchResults[dedupedIndex])) {
|
|
56519
|
-
|
|
56821
|
+
const anyOrUnknown = (0, typeUtils_1.containsAnyOrUnknown)(
|
|
56822
|
+
result.returnType,
|
|
56823
|
+
/* recurse */
|
|
56824
|
+
false
|
|
56825
|
+
);
|
|
56826
|
+
if (!anyOrUnknown) {
|
|
56520
56827
|
dedupedMatchResults[dedupedIndex] = types_1.NeverType.createNever();
|
|
56521
|
-
} else if (
|
|
56828
|
+
} else if ((0, types_1.isAny)(anyOrUnknown)) {
|
|
56522
56829
|
dedupedResultsIncludeAny = true;
|
|
56523
56830
|
}
|
|
56524
56831
|
break;
|
|
@@ -56568,6 +56875,12 @@ var require_typeEvaluator = __commonJS({
|
|
|
56568
56875
|
if (matches.length < 2) {
|
|
56569
56876
|
return matches;
|
|
56570
56877
|
}
|
|
56878
|
+
if (matches[0].matchResults.relevance !== matches[matches.length - 1].matchResults.relevance) {
|
|
56879
|
+
matches = matches.filter((m) => m.matchResults.relevance === matches[0].matchResults.relevance);
|
|
56880
|
+
if (matches.length < 2) {
|
|
56881
|
+
return matches;
|
|
56882
|
+
}
|
|
56883
|
+
}
|
|
56571
56884
|
if ((0, typeUtils_1.areTypesSame)(matches.map((match) => match.returnType), { treatAnySameAsUnknown: true })) {
|
|
56572
56885
|
return [matches[0]];
|
|
56573
56886
|
}
|
|
@@ -56575,19 +56888,24 @@ var require_typeEvaluator = __commonJS({
|
|
|
56575
56888
|
if (!firstArgResults) {
|
|
56576
56889
|
return matches;
|
|
56577
56890
|
}
|
|
56891
|
+
let foundAmbiguousAnyArg = false;
|
|
56578
56892
|
for (let i = 0; i < firstArgResults.length; i++) {
|
|
56579
56893
|
if ((0, types_1.isAnyOrUnknown)(firstArgResults[i].argType)) {
|
|
56580
56894
|
const paramTypes = matches.map((match) => i < match.matchResults.argParams.length ? match.matchResults.argParams[i].paramType : types_1.UnknownType.create());
|
|
56581
56895
|
if (!(0, typeUtils_1.areTypesSame)(paramTypes, { treatAnySameAsUnknown: true })) {
|
|
56582
|
-
|
|
56896
|
+
foundAmbiguousAnyArg = true;
|
|
56583
56897
|
}
|
|
56584
56898
|
}
|
|
56585
56899
|
}
|
|
56900
|
+
if (foundAmbiguousAnyArg || matches.some((match) => match.argResults.length !== firstArgResults.length)) {
|
|
56901
|
+
return matches;
|
|
56902
|
+
}
|
|
56586
56903
|
return [matches[0]];
|
|
56587
56904
|
}
|
|
56588
56905
|
function getBestOverloadForArguments(errorNode, typeResult, argList) {
|
|
56589
56906
|
let overloadIndex = 0;
|
|
56590
56907
|
let matches = [];
|
|
56908
|
+
const signatureTracker = new typeUtils_1.UniqueSignatureTracker();
|
|
56591
56909
|
types_1.OverloadedFunctionType.getOverloads(typeResult.type).forEach((overload) => {
|
|
56592
56910
|
useSpeculativeMode(errorNode, () => {
|
|
56593
56911
|
const matchResults = matchFunctionArgumentsToParameters(errorNode, argList, { type: overload, isIncomplete: typeResult.isIncomplete }, overloadIndex);
|
|
@@ -56606,6 +56924,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
56606
56924
|
errorNode,
|
|
56607
56925
|
match,
|
|
56608
56926
|
new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(match.overload)),
|
|
56927
|
+
signatureTracker,
|
|
56609
56928
|
/* skipUnknownArgCheck */
|
|
56610
56929
|
true
|
|
56611
56930
|
);
|
|
@@ -56649,7 +56968,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
56649
56968
|
}
|
|
56650
56969
|
return { argumentErrors: true, isTypeIncomplete: false, overloadsUsedForCall: [] };
|
|
56651
56970
|
}
|
|
56652
|
-
|
|
56971
|
+
function evaluateUsingLastMatchingOverload(skipUnknownArgCheck2) {
|
|
56653
56972
|
const lastMatch = filteredMatchResults.reduce((previous, current) => {
|
|
56654
56973
|
return current.overloadIndex > previous.overloadIndex ? current : previous;
|
|
56655
56974
|
});
|
|
@@ -56657,7 +56976,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
56657
56976
|
effectiveTypeVarContext.addSolveForScope((0, typeUtils_1.getTypeVarScopeIds)(lastMatch.overload));
|
|
56658
56977
|
effectiveTypeVarContext.unlock();
|
|
56659
56978
|
return validateFunctionArgumentTypesWithContext(errorNode, lastMatch, effectiveTypeVarContext, skipUnknownArgCheck2, inferenceContext);
|
|
56660
|
-
}
|
|
56979
|
+
}
|
|
56661
56980
|
if (filteredMatchResults.length === 1) {
|
|
56662
56981
|
return evaluateUsingLastMatchingOverload(
|
|
56663
56982
|
/* skipUnknownArgCheck */
|
|
@@ -57077,7 +57396,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
57077
57396
|
const combinedArgType = (0, typeUtils_1.combineSameSizedTuples)(makeTopLevelTypeVarsConcrete(argType), tupleClassType);
|
|
57078
57397
|
if ((0, types_1.isClassInstance)(combinedArgType) && (0, typeUtils_1.isTupleClass)(combinedArgType)) {
|
|
57079
57398
|
const tupleTypeArgs = (_a = combinedArgType.tupleTypeArguments) !== null && _a !== void 0 ? _a : [];
|
|
57080
|
-
if (tupleTypeArgs.length !== 1) {
|
|
57399
|
+
if (tupleTypeArgs.length !== 1 || !tupleTypeArgs[0].isUnbounded) {
|
|
57081
57400
|
for (const tupleTypeArg of tupleTypeArgs) {
|
|
57082
57401
|
if (tupleTypeArg.isUnbounded) {
|
|
57083
57402
|
expandedArgList.push({
|
|
@@ -57491,6 +57810,18 @@ var require_typeEvaluator = __commonJS({
|
|
|
57491
57810
|
unpackedDictionaryArgType = types_1.UnknownType.create();
|
|
57492
57811
|
}
|
|
57493
57812
|
}
|
|
57813
|
+
if (paramDetails.kwargsIndex !== void 0 && unpackedDictionaryArgType) {
|
|
57814
|
+
const paramType = paramDetails.params[paramDetails.kwargsIndex].type;
|
|
57815
|
+
validateArgTypeParams.push({
|
|
57816
|
+
paramCategory: 0,
|
|
57817
|
+
paramType,
|
|
57818
|
+
requiresTypeVarMatching: (0, typeUtils_1.requiresSpecialization)(paramType),
|
|
57819
|
+
argType: unpackedDictionaryArgType,
|
|
57820
|
+
argument: argList[argIndex],
|
|
57821
|
+
errorNode: argList[argIndex].valueExpression || errorNode,
|
|
57822
|
+
paramName: paramDetails.params[paramDetails.kwargsIndex].param.name
|
|
57823
|
+
});
|
|
57824
|
+
}
|
|
57494
57825
|
if (!isValidMappingType) {
|
|
57495
57826
|
if (!isDiagnosticSuppressedForNode(errorNode)) {
|
|
57496
57827
|
addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.unpackedDictArgumentNotMapping(), argList[argIndex].valueExpression || errorNode);
|
|
@@ -57584,7 +57915,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
57584
57915
|
paramDetails.params.forEach((paramInfo, paramIndex2) => {
|
|
57585
57916
|
var _a2, _b2;
|
|
57586
57917
|
const param = paramInfo.param;
|
|
57587
|
-
if (paramIndex2 >= paramDetails.firstPositionOrKeywordIndex && param.category === 0 && param.name &&
|
|
57918
|
+
if (paramIndex2 >= paramDetails.firstPositionOrKeywordIndex && param.category === 0 && param.name && paramMap.has(param.name) && paramMap.get(param.name).argsReceived === 0) {
|
|
57588
57919
|
const paramType = paramDetails.params[paramIndex2].type;
|
|
57589
57920
|
validateArgTypeParams.push({
|
|
57590
57921
|
paramCategory: 0,
|
|
@@ -57704,7 +58035,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
57704
58035
|
relevance--;
|
|
57705
58036
|
}
|
|
57706
58037
|
if (["isinstance", "issubclass"].some((name) => name === typeResult.type.details.builtInName) && validateArgTypeParams.length === 2) {
|
|
57707
|
-
validateArgTypeParams[1].
|
|
58038
|
+
validateArgTypeParams[1].isinstanceParam = true;
|
|
57708
58039
|
}
|
|
57709
58040
|
return {
|
|
57710
58041
|
overload: typeResult.type,
|
|
@@ -57719,10 +58050,12 @@ var require_typeEvaluator = __commonJS({
|
|
|
57719
58050
|
};
|
|
57720
58051
|
}
|
|
57721
58052
|
function validateFunctionArgumentTypesWithContext(errorNode, matchResults, typeVarContext, skipUnknownArgCheck = false, inferenceContext) {
|
|
57722
|
-
var _a;
|
|
58053
|
+
var _a, _b;
|
|
57723
58054
|
const type = matchResults.overload;
|
|
57724
|
-
|
|
57725
|
-
|
|
58055
|
+
const signatureTracker = (_a = inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.signatureTracker) !== null && _a !== void 0 ? _a : new typeUtils_1.UniqueSignatureTracker();
|
|
58056
|
+
matchResults.overload = (0, typeUtils_1.ensureFunctionSignaturesAreUnique)(matchResults.overload, signatureTracker, errorNode.start);
|
|
58057
|
+
if (!inferenceContext || (0, types_1.isAnyOrUnknown)(inferenceContext.expectedType) || (0, types_1.isNever)(inferenceContext.expectedType) || !type.details.declaredReturnType || !(0, typeUtils_1.requiresSpecialization)((_b = types_1.FunctionType.getSpecializedReturnType(type)) !== null && _b !== void 0 ? _b : types_1.UnknownType.create())) {
|
|
58058
|
+
return validateFunctionArgumentTypes(errorNode, matchResults, typeVarContext, signatureTracker, skipUnknownArgCheck);
|
|
57726
58059
|
}
|
|
57727
58060
|
const effectiveReturnType = getFunctionEffectiveReturnType(type);
|
|
57728
58061
|
let effectiveExpectedType = inferenceContext.expectedType;
|
|
@@ -57748,7 +58081,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
57748
58081
|
effectiveFlags | 1024
|
|
57749
58082
|
/* PopulatingExpectedType */
|
|
57750
58083
|
);
|
|
57751
|
-
const speculativeResults = validateFunctionArgumentTypes(errorNode, matchResults, typeVarContextCopy, skipUnknownArgCheck);
|
|
58084
|
+
const speculativeResults = validateFunctionArgumentTypes(errorNode, matchResults, typeVarContextCopy, signatureTracker, skipUnknownArgCheck);
|
|
57752
58085
|
if (speculativeResults === null || speculativeResults === void 0 ? void 0 : speculativeResults.argumentErrors) {
|
|
57753
58086
|
effectiveExpectedType = void 0;
|
|
57754
58087
|
}
|
|
@@ -57759,7 +58092,15 @@ var require_typeEvaluator = __commonJS({
|
|
|
57759
58092
|
if ((0, types_1.isClassInstance)(effectiveReturnType)) {
|
|
57760
58093
|
if ((0, types_1.isUnion)(effectiveExpectedType)) {
|
|
57761
58094
|
const filteredType = (0, typeUtils_1.mapSubtypes)(effectiveExpectedType, (subtype) => {
|
|
57762
|
-
|
|
58095
|
+
if (!(0, types_1.isClassInstance)(subtype) || subtype.details.typeParameters.length === 0) {
|
|
58096
|
+
return void 0;
|
|
58097
|
+
}
|
|
58098
|
+
if (types_1.ClassType.isProtocolClass(subtype) || subtype.details.mro.some((mroClass) => {
|
|
58099
|
+
return (0, types_1.isClassInstance)(mroClass) && mroClass.details.typeParameters.length > 0 && types_1.ClassType.isSameGenericClass(effectiveReturnType, mroClass);
|
|
58100
|
+
})) {
|
|
58101
|
+
return subtype;
|
|
58102
|
+
}
|
|
58103
|
+
return void 0;
|
|
57763
58104
|
});
|
|
57764
58105
|
if ((0, types_1.isClassInstance)(filteredType)) {
|
|
57765
58106
|
effectiveExpectedType = filteredType;
|
|
@@ -57767,7 +58108,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
57767
58108
|
}
|
|
57768
58109
|
if ((0, types_1.isClassInstance)(effectiveExpectedType) && !(0, types_1.isTypeSame)(effectiveReturnType, effectiveExpectedType)) {
|
|
57769
58110
|
const tempTypeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(effectiveReturnType));
|
|
57770
|
-
(0, constraintSolver_1.populateTypeVarContextBasedOnExpectedType)(evaluatorInterface, effectiveReturnType, effectiveExpectedType, tempTypeVarContext, liveTypeVarScopes);
|
|
58111
|
+
(0, constraintSolver_1.populateTypeVarContextBasedOnExpectedType)(evaluatorInterface, effectiveReturnType, effectiveExpectedType, tempTypeVarContext, liveTypeVarScopes, errorNode.start);
|
|
57771
58112
|
const genericReturnType = types_1.ClassType.cloneForSpecialization(
|
|
57772
58113
|
effectiveReturnType,
|
|
57773
58114
|
/* typeArguments */
|
|
@@ -57784,7 +58125,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
57784
58125
|
});
|
|
57785
58126
|
}
|
|
57786
58127
|
}
|
|
57787
|
-
effectiveExpectedType = (0, typeUtils_1.transformExpectedType)(effectiveExpectedType, liveTypeVarScopes);
|
|
58128
|
+
effectiveExpectedType = (0, typeUtils_1.transformExpectedType)(effectiveExpectedType, liveTypeVarScopes, errorNode.start);
|
|
57788
58129
|
assignType(
|
|
57789
58130
|
effectiveReturnType,
|
|
57790
58131
|
effectiveExpectedType,
|
|
@@ -57797,9 +58138,9 @@ var require_typeEvaluator = __commonJS({
|
|
|
57797
58138
|
/* PopulatingExpectedType */
|
|
57798
58139
|
);
|
|
57799
58140
|
}
|
|
57800
|
-
return validateFunctionArgumentTypes(errorNode, matchResults, typeVarContext, skipUnknownArgCheck);
|
|
58141
|
+
return validateFunctionArgumentTypes(errorNode, matchResults, typeVarContext, signatureTracker, skipUnknownArgCheck);
|
|
57801
58142
|
}
|
|
57802
|
-
function validateFunctionArgumentTypes(errorNode, matchResults, typeVarContext, skipUnknownArgCheck = false) {
|
|
58143
|
+
function validateFunctionArgumentTypes(errorNode, matchResults, typeVarContext, signatureTracker, skipUnknownArgCheck = false) {
|
|
57803
58144
|
const type = matchResults.overload;
|
|
57804
58145
|
let isTypeIncomplete = matchResults.isTypeIncomplete;
|
|
57805
58146
|
let argumentErrors = false;
|
|
@@ -57832,13 +58173,12 @@ var require_typeEvaluator = __commonJS({
|
|
|
57832
58173
|
if (typeVarMatchingCount > 0) {
|
|
57833
58174
|
let passCount = Math.min(typeVarMatchingCount, 2);
|
|
57834
58175
|
for (let i = 0; i < passCount; i++) {
|
|
57835
|
-
const signatureTracker2 = new typeUtils_1.UniqueSignatureTracker();
|
|
57836
58176
|
useSpeculativeMode(errorNode, () => {
|
|
57837
58177
|
matchResults.argParams.forEach((argParam) => {
|
|
57838
58178
|
if (!argParam.requiresTypeVarMatching) {
|
|
57839
58179
|
return;
|
|
57840
58180
|
}
|
|
57841
|
-
const argResult = validateArgType(argParam, typeVarContext,
|
|
58181
|
+
const argResult = validateArgType(argParam, typeVarContext, signatureTracker, { type, isIncomplete: matchResults.isTypeIncomplete }, {
|
|
57842
58182
|
skipUnknownArgCheck,
|
|
57843
58183
|
skipOverloadArg: i === 0,
|
|
57844
58184
|
skipBareTypeVarExpectedType: i === 0,
|
|
@@ -57860,7 +58200,6 @@ var require_typeEvaluator = __commonJS({
|
|
|
57860
58200
|
let sawParamSpecKwargs = false;
|
|
57861
58201
|
let condition = [];
|
|
57862
58202
|
const argResults = [];
|
|
57863
|
-
const signatureTracker = new typeUtils_1.UniqueSignatureTracker();
|
|
57864
58203
|
matchResults.argParams.forEach((argParam) => {
|
|
57865
58204
|
var _a;
|
|
57866
58205
|
const argResult = validateArgType(argParam, typeVarContext, signatureTracker, { type, isIncomplete: matchResults.isTypeIncomplete }, {
|
|
@@ -58102,7 +58441,12 @@ var require_typeEvaluator = __commonJS({
|
|
|
58102
58441
|
const argResult = validateArgType(
|
|
58103
58442
|
{
|
|
58104
58443
|
paramCategory: 0,
|
|
58105
|
-
paramType: (0, typeUtils_1.transformExpectedType)(
|
|
58444
|
+
paramType: (0, typeUtils_1.transformExpectedType)(
|
|
58445
|
+
paramType,
|
|
58446
|
+
liveTypeVarScopes,
|
|
58447
|
+
/* usageOffset */
|
|
58448
|
+
void 0
|
|
58449
|
+
),
|
|
58106
58450
|
requiresTypeVarMatching: false,
|
|
58107
58451
|
argument: arg,
|
|
58108
58452
|
errorNode: arg.valueExpression || errorNode
|
|
@@ -58183,10 +58527,10 @@ var require_typeEvaluator = __commonJS({
|
|
|
58183
58527
|
if (argParam.argType) {
|
|
58184
58528
|
argType = argParam.argType;
|
|
58185
58529
|
} else {
|
|
58186
|
-
const flags = argParam.
|
|
58187
|
-
const exprTypeResult = getTypeOfExpression(argParam.argument.valueExpression, flags, (0, typeUtils_1.makeInferenceContext)(expectedType, !!(typeResult === null || typeResult === void 0 ? void 0 : typeResult.isIncomplete)));
|
|
58530
|
+
const flags = argParam.isinstanceParam ? 512 | 8 | 32 | 64 : 0;
|
|
58531
|
+
const exprTypeResult = getTypeOfExpression(argParam.argument.valueExpression, flags, (0, typeUtils_1.makeInferenceContext)(expectedType, !!(typeResult === null || typeResult === void 0 ? void 0 : typeResult.isIncomplete), signatureTracker));
|
|
58188
58532
|
argType = exprTypeResult.type;
|
|
58189
|
-
argType = (0, typeUtils_1.ensureFunctionSignaturesAreUnique)(argType, signatureTracker);
|
|
58533
|
+
argType = (0, typeUtils_1.ensureFunctionSignaturesAreUnique)(argType, signatureTracker, argParam.argument.valueExpression.start);
|
|
58190
58534
|
if (exprTypeResult.isIncomplete) {
|
|
58191
58535
|
isTypeIncomplete = true;
|
|
58192
58536
|
}
|
|
@@ -58219,7 +58563,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
58219
58563
|
} else {
|
|
58220
58564
|
if (argParam.argType) {
|
|
58221
58565
|
argType = argParam.argType;
|
|
58222
|
-
} else if (argParam.
|
|
58566
|
+
} else if (argParam.isinstanceParam && !argParam.argument.typeResult && argParam.argument.valueExpression) {
|
|
58223
58567
|
const argTypeResult = getTypeOfExpression(
|
|
58224
58568
|
argParam.argument.valueExpression,
|
|
58225
58569
|
8 | 32 | 64
|
|
@@ -58341,9 +58685,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
58341
58685
|
return { isCompatible: false, argType, isTypeIncomplete, skippedBareTypeVarExpectedType, condition };
|
|
58342
58686
|
}
|
|
58343
58687
|
if (!options.skipUnknownArgCheck) {
|
|
58344
|
-
|
|
58345
|
-
const fileInfo = AnalyzerNodeInfo.getFileInfo(argParam.errorNode);
|
|
58346
|
-
const getDiagAddendum = () => {
|
|
58688
|
+
let getDiagAddendum = function() {
|
|
58347
58689
|
const diagAddendum = new diagnostic_1.DiagnosticAddendum();
|
|
58348
58690
|
if (argParam.paramName) {
|
|
58349
58691
|
diagAddendum.addMessage((functionName ? localize_1.Localizer.DiagnosticAddendum.argParamFunction().format({
|
|
@@ -58353,6 +58695,8 @@ var require_typeEvaluator = __commonJS({
|
|
|
58353
58695
|
}
|
|
58354
58696
|
return diagAddendum;
|
|
58355
58697
|
};
|
|
58698
|
+
const simplifiedType = (0, types_1.removeUnbound)(argType);
|
|
58699
|
+
const fileInfo = AnalyzerNodeInfo.getFileInfo(argParam.errorNode);
|
|
58356
58700
|
if (fileInfo.diagnosticRuleSet.reportUnknownArgumentType !== "none" && !(0, types_1.isAny)(argParam.paramType) && !isTypeIncomplete) {
|
|
58357
58701
|
if ((0, types_1.isUnknown)(simplifiedType)) {
|
|
58358
58702
|
const diagAddendum = getDiagAddendum();
|
|
@@ -59042,6 +59386,8 @@ var require_typeEvaluator = __commonJS({
|
|
|
59042
59386
|
valueTypes,
|
|
59043
59387
|
/* forceStrictInference */
|
|
59044
59388
|
true,
|
|
59389
|
+
/* isValueTypeInvariant */
|
|
59390
|
+
true,
|
|
59045
59391
|
/* expectedKeyType */
|
|
59046
59392
|
void 0,
|
|
59047
59393
|
/* expectedValueType */
|
|
@@ -59075,7 +59421,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
59075
59421
|
return void 0;
|
|
59076
59422
|
}
|
|
59077
59423
|
const dictTypeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(builtInDict));
|
|
59078
|
-
if (!(0, constraintSolver_1.populateTypeVarContextBasedOnExpectedType)(evaluatorInterface, builtInDict, inferenceContext.expectedType, dictTypeVarContext, ParseTreeUtils.getTypeVarScopesForNode(node))) {
|
|
59424
|
+
if (!(0, constraintSolver_1.populateTypeVarContextBasedOnExpectedType)(evaluatorInterface, builtInDict, inferenceContext.expectedType, dictTypeVarContext, ParseTreeUtils.getTypeVarScopesForNode(node), node.start)) {
|
|
59079
59425
|
return void 0;
|
|
59080
59426
|
}
|
|
59081
59427
|
const specializedDict = (0, typeUtils_1.applySolvedTypeVars)(types_1.ClassType.cloneAsInstantiable(builtInDict), dictTypeVarContext);
|
|
@@ -59084,12 +59430,14 @@ var require_typeEvaluator = __commonJS({
|
|
|
59084
59430
|
}
|
|
59085
59431
|
const expectedKeyType = specializedDict.typeArguments[0];
|
|
59086
59432
|
const expectedValueType = specializedDict.typeArguments[1];
|
|
59433
|
+
const isValueTypeInvariant = (0, types_1.isClassInstance)(inferenceContext.expectedType) && (types_1.ClassType.isBuiltIn(inferenceContext.expectedType, "dict") || types_1.ClassType.isBuiltIn(inferenceContext.expectedType, "MutableMapping"));
|
|
59087
59434
|
if (getKeyAndValueTypesFromDictionary(
|
|
59088
59435
|
node,
|
|
59089
59436
|
keyTypes,
|
|
59090
59437
|
valueTypes,
|
|
59091
59438
|
/* forceStrictInference */
|
|
59092
59439
|
true,
|
|
59440
|
+
isValueTypeInvariant,
|
|
59093
59441
|
expectedKeyType,
|
|
59094
59442
|
expectedValueType,
|
|
59095
59443
|
void 0,
|
|
@@ -59097,7 +59445,6 @@ var require_typeEvaluator = __commonJS({
|
|
|
59097
59445
|
)) {
|
|
59098
59446
|
isIncomplete = true;
|
|
59099
59447
|
}
|
|
59100
|
-
const isValueTypeInvariant = (0, types_1.isClassInstance)(inferenceContext.expectedType) && (types_1.ClassType.isBuiltIn(inferenceContext.expectedType, "dict") || types_1.ClassType.isBuiltIn(inferenceContext.expectedType, "MutableMapping"));
|
|
59101
59448
|
const specializedKeyType = inferTypeArgFromExpectedEntryType(
|
|
59102
59449
|
(0, typeUtils_1.makeInferenceContext)(expectedKeyType),
|
|
59103
59450
|
keyTypes.map((result) => result.type),
|
|
@@ -59124,7 +59471,9 @@ var require_typeEvaluator = __commonJS({
|
|
|
59124
59471
|
keyTypeResults,
|
|
59125
59472
|
valueTypeResults,
|
|
59126
59473
|
/* forceStrictInference */
|
|
59127
|
-
hasExpectedType
|
|
59474
|
+
hasExpectedType,
|
|
59475
|
+
/* isValueTypeInvariant */
|
|
59476
|
+
false
|
|
59128
59477
|
)) {
|
|
59129
59478
|
isIncomplete = true;
|
|
59130
59479
|
}
|
|
@@ -59160,10 +59509,10 @@ var require_typeEvaluator = __commonJS({
|
|
|
59160
59509
|
}
|
|
59161
59510
|
return { type, isIncomplete };
|
|
59162
59511
|
}
|
|
59163
|
-
function getKeyAndValueTypesFromDictionary(node, keyTypes, valueTypes, forceStrictInference, expectedKeyType, expectedValueType, expectedTypedDictEntries, expectedDiagAddendum) {
|
|
59512
|
+
function getKeyAndValueTypesFromDictionary(node, keyTypes, valueTypes, forceStrictInference, isValueTypeInvariant, expectedKeyType, expectedValueType, expectedTypedDictEntries, expectedDiagAddendum) {
|
|
59164
59513
|
let isIncomplete = false;
|
|
59165
59514
|
node.entries.forEach((entryNode, index) => {
|
|
59166
|
-
var _a;
|
|
59515
|
+
var _a, _b, _c;
|
|
59167
59516
|
let addUnknown = true;
|
|
59168
59517
|
if (entryNode.nodeType === 17) {
|
|
59169
59518
|
const keyTypeResult = getTypeOfExpression(
|
|
@@ -59188,23 +59537,29 @@ var require_typeEvaluator = __commonJS({
|
|
|
59188
59537
|
expectedDiagAddendum.addAddendum(keyTypeResult.expectedTypeDiagAddendum);
|
|
59189
59538
|
}
|
|
59190
59539
|
let valueTypeResult;
|
|
59540
|
+
let entryInferenceContext;
|
|
59191
59541
|
if (expectedTypedDictEntries && (0, types_1.isClassInstance)(keyType) && types_1.ClassType.isBuiltIn(keyType, "str") && (0, typeUtils_1.isLiteralType)(keyType) && expectedTypedDictEntries.has(keyType.literalValue)) {
|
|
59192
59542
|
const effectiveValueType = expectedTypedDictEntries.get(keyType.literalValue).valueType;
|
|
59543
|
+
entryInferenceContext = (0, typeUtils_1.makeInferenceContext)(effectiveValueType);
|
|
59193
59544
|
valueTypeResult = getTypeOfExpression(
|
|
59194
59545
|
entryNode.valueExpression,
|
|
59195
59546
|
/* flags */
|
|
59196
59547
|
void 0,
|
|
59197
|
-
|
|
59548
|
+
entryInferenceContext
|
|
59198
59549
|
);
|
|
59199
59550
|
} else {
|
|
59200
59551
|
const effectiveValueType = expectedValueType !== null && expectedValueType !== void 0 ? expectedValueType : forceStrictInference ? types_1.NeverType.createNever() : void 0;
|
|
59552
|
+
entryInferenceContext = (0, typeUtils_1.makeInferenceContext)(effectiveValueType);
|
|
59201
59553
|
valueTypeResult = getTypeOfExpression(
|
|
59202
59554
|
entryNode.valueExpression,
|
|
59203
59555
|
/* flags */
|
|
59204
59556
|
void 0,
|
|
59205
|
-
|
|
59557
|
+
entryInferenceContext
|
|
59206
59558
|
);
|
|
59207
59559
|
}
|
|
59560
|
+
if (entryInferenceContext && !valueTypeResult.typeErrors) {
|
|
59561
|
+
valueTypeResult.type = (_a = inferTypeArgFromExpectedEntryType(entryInferenceContext, [valueTypeResult.type], !isValueTypeInvariant)) !== null && _a !== void 0 ? _a : valueTypeResult.type;
|
|
59562
|
+
}
|
|
59208
59563
|
if (expectedDiagAddendum && valueTypeResult.expectedTypeDiagAddendum) {
|
|
59209
59564
|
expectedDiagAddendum.addAddendum(valueTypeResult.expectedTypeDiagAddendum);
|
|
59210
59565
|
}
|
|
@@ -59229,12 +59584,16 @@ var require_typeEvaluator = __commonJS({
|
|
|
59229
59584
|
));
|
|
59230
59585
|
}
|
|
59231
59586
|
}
|
|
59587
|
+
const entryInferenceContext = (0, typeUtils_1.makeInferenceContext)(expectedType);
|
|
59232
59588
|
const unexpandedTypeResult = getTypeOfExpression(
|
|
59233
59589
|
entryNode.expandExpression,
|
|
59234
59590
|
/* flags */
|
|
59235
59591
|
void 0,
|
|
59236
|
-
|
|
59592
|
+
entryInferenceContext
|
|
59237
59593
|
);
|
|
59594
|
+
if (entryInferenceContext && !unexpandedTypeResult.typeErrors) {
|
|
59595
|
+
unexpandedTypeResult.type = (_b = inferTypeArgFromExpectedEntryType(entryInferenceContext, [unexpandedTypeResult.type], !isValueTypeInvariant)) !== null && _b !== void 0 ? _b : unexpandedTypeResult.type;
|
|
59596
|
+
}
|
|
59238
59597
|
if (unexpandedTypeResult.isIncomplete) {
|
|
59239
59598
|
isIncomplete = true;
|
|
59240
59599
|
}
|
|
@@ -59298,7 +59657,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
59298
59657
|
isIncomplete = true;
|
|
59299
59658
|
}
|
|
59300
59659
|
if ((0, types_1.isClassInstance)(dictEntryType) && (0, typeUtils_1.isTupleClass)(dictEntryType)) {
|
|
59301
|
-
const typeArgs = (
|
|
59660
|
+
const typeArgs = (_c = dictEntryType.tupleTypeArguments) === null || _c === void 0 ? void 0 : _c.map((t) => t.type);
|
|
59302
59661
|
if (typeArgs && typeArgs.length === 2) {
|
|
59303
59662
|
if (forceStrictInference || index < maxEntriesToUseForInference) {
|
|
59304
59663
|
keyTypes.push({ node: entryNode, type: typeArgs[0] });
|
|
@@ -59367,7 +59726,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
59367
59726
|
return void 0;
|
|
59368
59727
|
}
|
|
59369
59728
|
const typeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(builtInListOrSet));
|
|
59370
|
-
if (!(0, constraintSolver_1.populateTypeVarContextBasedOnExpectedType)(evaluatorInterface, builtInListOrSet, inferenceContext.expectedType, typeVarContext, ParseTreeUtils.getTypeVarScopesForNode(node))) {
|
|
59729
|
+
if (!(0, constraintSolver_1.populateTypeVarContextBasedOnExpectedType)(evaluatorInterface, builtInListOrSet, inferenceContext.expectedType, typeVarContext, ParseTreeUtils.getTypeVarScopesForNode(node), node.start)) {
|
|
59371
59730
|
return void 0;
|
|
59372
59731
|
}
|
|
59373
59732
|
const specializedListOrSet = (0, typeUtils_1.applySolvedTypeVars)(types_1.ClassType.cloneAsInstantiable(builtInListOrSet), typeVarContext);
|
|
@@ -59492,7 +59851,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
59492
59851
|
if ((0, types_1.isAnyOrUnknown)(inferenceContext.expectedType)) {
|
|
59493
59852
|
return inferenceContext.expectedType;
|
|
59494
59853
|
}
|
|
59495
|
-
const typeVarContext = new typeVarContext_1.TypeVarContext();
|
|
59854
|
+
const typeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(inferenceContext.expectedType));
|
|
59496
59855
|
const expectedType = inferenceContext.expectedType;
|
|
59497
59856
|
let isCompatible = true;
|
|
59498
59857
|
entryTypes.forEach((entryType) => {
|
|
@@ -59513,7 +59872,16 @@ var require_typeEvaluator = __commonJS({
|
|
|
59513
59872
|
const combinedTypes = (0, types_1.combineTypes)(entryTypes);
|
|
59514
59873
|
return (0, typeUtils_1.containsLiteralType)(inferenceContext.expectedType) ? combinedTypes : stripLiteralValue(combinedTypes);
|
|
59515
59874
|
}
|
|
59516
|
-
return (0, typeUtils_1.applySolvedTypeVars)(inferenceContext.expectedType, typeVarContext, { applyInScopePlaceholders: true })
|
|
59875
|
+
return (0, typeUtils_1.mapSubtypes)((0, typeUtils_1.applySolvedTypeVars)(inferenceContext.expectedType, typeVarContext, { applyInScopePlaceholders: true }), (subtype) => {
|
|
59876
|
+
if (entryTypes.length !== 1) {
|
|
59877
|
+
return subtype;
|
|
59878
|
+
}
|
|
59879
|
+
const entryType = entryTypes[0];
|
|
59880
|
+
if ((0, types_1.isTypeSame)(subtype, entryType, { ignoreTypedDictNarrowEntries: true }) && (0, types_1.isClass)(subtype) && (0, types_1.isClass)(entryType) && types_1.ClassType.isTypedDictClass(entryType)) {
|
|
59881
|
+
return types_1.ClassType.cloneForNarrowedTypedDictEntries(subtype, entryType.typedDictNarrowedEntries);
|
|
59882
|
+
}
|
|
59883
|
+
return subtype;
|
|
59884
|
+
});
|
|
59517
59885
|
}
|
|
59518
59886
|
function getTypeOfYield(node) {
|
|
59519
59887
|
let expectedYieldType;
|
|
@@ -59607,7 +59975,8 @@ var require_typeEvaluator = __commonJS({
|
|
|
59607
59975
|
(param) => !!param.name && param.category !== 0
|
|
59608
59976
|
/* Simple */
|
|
59609
59977
|
);
|
|
59610
|
-
|
|
59978
|
+
const hasParamSpec = !!functionType2.details.paramSpec;
|
|
59979
|
+
return hasVarArgs || hasParamSpec || functionParamCount >= minLambdaParamCount && functionParamCount <= maxLambdaParamCount;
|
|
59611
59980
|
});
|
|
59612
59981
|
}
|
|
59613
59982
|
const expectedFunctionType = expectedFunctionTypes.length > 0 ? expectedFunctionTypes[0] : void 0;
|
|
@@ -59667,9 +60036,6 @@ var require_typeEvaluator = __commonJS({
|
|
|
59667
60036
|
type: types_1.UnknownType.create()
|
|
59668
60037
|
});
|
|
59669
60038
|
}
|
|
59670
|
-
if (expectedFunctionType === null || expectedFunctionType === void 0 ? void 0 : expectedFunctionType.details.paramSpec) {
|
|
59671
|
-
functionType.details.paramSpec = expectedFunctionType.details.paramSpec;
|
|
59672
|
-
}
|
|
59673
60039
|
const expectedReturnType = expectedFunctionType ? getFunctionEffectiveReturnType(expectedFunctionType) : void 0;
|
|
59674
60040
|
useSpeculativeMode(isSpeculativeModeInUse(node) || (inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.isTypeIncomplete) ? node.expression : void 0, () => {
|
|
59675
60041
|
const returnTypeResult = getTypeOfExpression(
|
|
@@ -60096,7 +60462,9 @@ var require_typeEvaluator = __commonJS({
|
|
|
60096
60462
|
let isLiteralType = true;
|
|
60097
60463
|
(0, typeUtils_1.doForEachSubtype)(exprType.type, (subtype) => {
|
|
60098
60464
|
if (!(0, types_1.isInstantiableClass)(subtype) || subtype.literalValue === void 0) {
|
|
60099
|
-
|
|
60465
|
+
if (!(0, types_1.isNoneTypeClass)(subtype)) {
|
|
60466
|
+
isLiteralType = false;
|
|
60467
|
+
}
|
|
60100
60468
|
}
|
|
60101
60469
|
});
|
|
60102
60470
|
if (isLiteralType) {
|
|
@@ -61032,7 +61400,6 @@ var require_typeEvaluator = __commonJS({
|
|
|
61032
61400
|
let protocolTypeParameters;
|
|
61033
61401
|
const initSubclassArgs = [];
|
|
61034
61402
|
let metaclassNode;
|
|
61035
|
-
let isMetaclassDeferred = false;
|
|
61036
61403
|
let exprFlags = 128 | 1024 | 262144 | 2048 | 8192 | 16384;
|
|
61037
61404
|
if (fileInfo.isStubFile) {
|
|
61038
61405
|
exprFlags |= 4;
|
|
@@ -61066,7 +61433,6 @@ var require_typeEvaluator = __commonJS({
|
|
|
61066
61433
|
dependency: argType,
|
|
61067
61434
|
callback: () => completeClassTypeDeferred(classType, node, node.name)
|
|
61068
61435
|
});
|
|
61069
|
-
isMetaclassDeferred = true;
|
|
61070
61436
|
}
|
|
61071
61437
|
if (types_1.ClassType.isBuiltIn(argType, "Protocol")) {
|
|
61072
61438
|
if (!fileInfo.isStubFile && !types_1.ClassType.isTypingExtensionClass(argType) && fileInfo.executionEnvironment.pythonVersion < pythonVersion_1.PythonVersion.V3_7) {
|
|
@@ -61288,7 +61654,12 @@ var require_typeEvaluator = __commonJS({
|
|
|
61288
61654
|
for (let i = node.decorators.length - 1; i >= 0; i--) {
|
|
61289
61655
|
const decorator = node.decorators[i];
|
|
61290
61656
|
const newDecoratedType = applyClassDecorator(decoratedType, classType, decorator);
|
|
61291
|
-
|
|
61657
|
+
const unknownOrAny = (0, typeUtils_1.containsAnyOrUnknown)(
|
|
61658
|
+
newDecoratedType,
|
|
61659
|
+
/* recurse */
|
|
61660
|
+
false
|
|
61661
|
+
);
|
|
61662
|
+
if (unknownOrAny && (0, types_1.isUnknown)(unknownOrAny)) {
|
|
61292
61663
|
if (!foundUnknown) {
|
|
61293
61664
|
addDiagnostic(fileInfo.diagnosticRuleSet.reportUntypedClassDecorator, diagnosticRules_1.DiagnosticRule.reportUntypedClassDecorator, localize_1.Localizer.Diagnostic.classDecoratorTypeUnknown(), node.decorators[i].expression);
|
|
61294
61665
|
foundUnknown = true;
|
|
@@ -61374,9 +61745,6 @@ var require_typeEvaluator = __commonJS({
|
|
|
61374
61745
|
0
|
|
61375
61746
|
/* None */
|
|
61376
61747
|
);
|
|
61377
|
-
if (!isMetaclassDeferred) {
|
|
61378
|
-
validateInitSubclassArgs(node, classType);
|
|
61379
|
-
}
|
|
61380
61748
|
return { classType, decoratedType };
|
|
61381
61749
|
}
|
|
61382
61750
|
function validateTypeParameterDefault(errorNode, typeParam, otherLiveTypeParams) {
|
|
@@ -61649,7 +62017,6 @@ var require_typeEvaluator = __commonJS({
|
|
|
61649
62017
|
addError(localize_1.Localizer.Diagnostic.methodOrdering(), errorNode);
|
|
61650
62018
|
}
|
|
61651
62019
|
computeEffectiveMetaclass(type, errorNode);
|
|
61652
|
-
validateInitSubclassArgs(node, type);
|
|
61653
62020
|
}
|
|
61654
62021
|
function validateInitSubclassArgs(node, classType) {
|
|
61655
62022
|
const argList = [];
|
|
@@ -62066,7 +62433,12 @@ var require_typeEvaluator = __commonJS({
|
|
|
62066
62433
|
for (let i = node.decorators.length - 1; i >= 0; i--) {
|
|
62067
62434
|
const decorator = node.decorators[i];
|
|
62068
62435
|
const newDecoratedType = applyFunctionDecorator(decoratedType, functionType, decorator, node);
|
|
62069
|
-
|
|
62436
|
+
const unknownOrAny = (0, typeUtils_1.containsAnyOrUnknown)(
|
|
62437
|
+
newDecoratedType,
|
|
62438
|
+
/* recurse */
|
|
62439
|
+
false
|
|
62440
|
+
);
|
|
62441
|
+
if (unknownOrAny && (0, types_1.isUnknown)(unknownOrAny)) {
|
|
62070
62442
|
if (!foundUnknown) {
|
|
62071
62443
|
addDiagnostic(fileInfo.diagnosticRuleSet.reportUntypedFunctionDecorator, diagnosticRules_1.DiagnosticRule.reportUntypedFunctionDecorator, localize_1.Localizer.Diagnostic.functionDecoratorTypeUnknown(), node.decorators[i].expression);
|
|
62072
62444
|
foundUnknown = true;
|
|
@@ -62174,7 +62546,13 @@ var require_typeEvaluator = __commonJS({
|
|
|
62174
62546
|
if ((0, types_1.isNoneInstance)(defaultValueType) || (0, types_1.isClassInstance)(defaultValueType) && (0, symbolNameUtils_1.isPrivateOrProtectedName)(defaultValueType.details.name)) {
|
|
62175
62547
|
inferredParamType = (0, types_1.combineTypes)([defaultValueType, types_1.UnknownType.create()]);
|
|
62176
62548
|
} else {
|
|
62177
|
-
|
|
62549
|
+
let skipInference = false;
|
|
62550
|
+
if ((0, types_1.isFunction)(defaultValueType) || (0, types_1.isOverloadedFunction)(defaultValueType)) {
|
|
62551
|
+
skipInference = true;
|
|
62552
|
+
} else if ((0, types_1.isClassInstance)(defaultValueType) && types_1.ClassType.isBuiltIn(defaultValueType, ["tuple", "list", "set", "dict"])) {
|
|
62553
|
+
skipInference = true;
|
|
62554
|
+
}
|
|
62555
|
+
if (!skipInference) {
|
|
62178
62556
|
inferredParamType = stripLiteralValue(defaultValueType);
|
|
62179
62557
|
}
|
|
62180
62558
|
}
|
|
@@ -64073,7 +64451,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
64073
64451
|
return void 0;
|
|
64074
64452
|
}
|
|
64075
64453
|
function getDeclarationsForNameNode(node, skipUnreachableCode = true) {
|
|
64076
|
-
var _a;
|
|
64454
|
+
var _a, _b, _c;
|
|
64077
64455
|
if (skipUnreachableCode && AnalyzerNodeInfo.isCodeUnreachable(node)) {
|
|
64078
64456
|
return void 0;
|
|
64079
64457
|
}
|
|
@@ -64155,7 +64533,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
64155
64533
|
} else if (node.parent && node.parent.nodeType === 1 && node === node.parent.name) {
|
|
64156
64534
|
const argNode = node.parent;
|
|
64157
64535
|
const paramName = node.value;
|
|
64158
|
-
if (argNode.parent
|
|
64536
|
+
if (((_a = argNode.parent) === null || _a === void 0 ? void 0 : _a.nodeType) === 9) {
|
|
64159
64537
|
const baseType = getType(argNode.parent.leftExpression);
|
|
64160
64538
|
if (baseType) {
|
|
64161
64539
|
if ((0, types_1.isFunction)(baseType) && baseType.details.declaration) {
|
|
@@ -64171,7 +64549,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
64171
64549
|
}
|
|
64172
64550
|
});
|
|
64173
64551
|
} else if ((0, types_1.isInstantiableClass)(baseType)) {
|
|
64174
|
-
const initMethodType = (
|
|
64552
|
+
const initMethodType = (_b = getTypeOfObjectMember(
|
|
64175
64553
|
argNode.parent.leftExpression,
|
|
64176
64554
|
types_1.ClassType.cloneAsInstance(baseType),
|
|
64177
64555
|
"__init__",
|
|
@@ -64180,7 +64558,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
64180
64558
|
void 0,
|
|
64181
64559
|
4
|
|
64182
64560
|
/* SkipObjectBaseClass */
|
|
64183
|
-
)) === null ||
|
|
64561
|
+
)) === null || _b === void 0 ? void 0 : _b.type;
|
|
64184
64562
|
if (initMethodType && (0, types_1.isFunction)(initMethodType)) {
|
|
64185
64563
|
const paramDecl = getDeclarationFromFunctionNamedParameter(initMethodType, paramName);
|
|
64186
64564
|
if (paramDecl) {
|
|
@@ -64194,6 +64572,11 @@ var require_typeEvaluator = __commonJS({
|
|
|
64194
64572
|
}
|
|
64195
64573
|
}
|
|
64196
64574
|
}
|
|
64575
|
+
} else if (((_c = argNode.parent) === null || _c === void 0 ? void 0 : _c.nodeType) === 10) {
|
|
64576
|
+
const classTypeResult = getTypeOfClass(argNode.parent);
|
|
64577
|
+
if (classTypeResult) {
|
|
64578
|
+
validateInitSubclassArgs(argNode.parent, classTypeResult.classType);
|
|
64579
|
+
}
|
|
64197
64580
|
}
|
|
64198
64581
|
} else {
|
|
64199
64582
|
const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
|
|
@@ -64956,7 +65339,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
64956
65339
|
type.inferredReturnType = returnType;
|
|
64957
65340
|
}
|
|
64958
65341
|
}
|
|
64959
|
-
if (!isIncomplete && analyzeUnannotatedFunctions && (0, typeUtils_1.isPartlyUnknown)(returnType) && types_1.FunctionType.hasUnannotatedParams(type) && !types_1.FunctionType.isStubDefinition(type) && !types_1.FunctionType.isPyTypedDefinition(type) && args) {
|
|
65342
|
+
if (!isIncomplete && analyzeUnannotatedFunctions && (0, typeUtils_1.isPartlyUnknown)(returnType) && types_1.FunctionType.hasUnannotatedParams(type) && !types_1.FunctionType.isStubDefinition(type) && !types_1.FunctionType.isPyTypedDefinition(type) && !types_1.FunctionType.isWrapReturnTypeInAwait(type) && args) {
|
|
64960
65343
|
const contextualReturnType = getFunctionInferredReturnTypeUsingArguments(type, args);
|
|
64961
65344
|
if (contextualReturnType) {
|
|
64962
65345
|
returnType = contextualReturnType;
|
|
@@ -65275,10 +65658,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
65275
65658
|
});
|
|
65276
65659
|
return isAssignable;
|
|
65277
65660
|
}
|
|
65278
|
-
function
|
|
65279
|
-
var _a, _b;
|
|
65280
|
-
const destTypeArgs = [...(_a = destType.tupleTypeArguments) !== null && _a !== void 0 ? _a : []];
|
|
65281
|
-
const srcTypeArgs = [...(_b = srcType.tupleTypeArguments) !== null && _b !== void 0 ? _b : []];
|
|
65661
|
+
function adjustSourceTupleTypeArgs(destTypeArgs, srcTypeArgs) {
|
|
65282
65662
|
const destVariadicIndex = destTypeArgs.findIndex((t) => (0, types_1.isVariadicTypeVar)(t.type));
|
|
65283
65663
|
const destUnboundedIndex = destTypeArgs.findIndex((t) => t.isUnbounded);
|
|
65284
65664
|
const srcUnboundedIndex = srcTypeArgs.findIndex((t) => t.isUnbounded);
|
|
@@ -65327,6 +65707,19 @@ var require_typeEvaluator = __commonJS({
|
|
|
65327
65707
|
}
|
|
65328
65708
|
}
|
|
65329
65709
|
}
|
|
65710
|
+
}
|
|
65711
|
+
function assignTupleTypeArgs(destType, srcType, diag, destTypeVarContext, srcTypeVarContext, flags, recursionCount) {
|
|
65712
|
+
var _a, _b;
|
|
65713
|
+
const destTypeArgs = [...(_a = destType.tupleTypeArguments) !== null && _a !== void 0 ? _a : []];
|
|
65714
|
+
const srcTypeArgs = [...(_b = srcType.tupleTypeArguments) !== null && _b !== void 0 ? _b : []];
|
|
65715
|
+
let srcUnboundedIndex;
|
|
65716
|
+
if (flags & 2) {
|
|
65717
|
+
adjustSourceTupleTypeArgs(srcTypeArgs, destTypeArgs);
|
|
65718
|
+
srcUnboundedIndex = destTypeArgs.findIndex((t) => t.isUnbounded);
|
|
65719
|
+
} else {
|
|
65720
|
+
adjustSourceTupleTypeArgs(destTypeArgs, srcTypeArgs);
|
|
65721
|
+
srcUnboundedIndex = srcTypeArgs.findIndex((t) => t.isUnbounded);
|
|
65722
|
+
}
|
|
65330
65723
|
if (srcTypeArgs.length === destTypeArgs.length) {
|
|
65331
65724
|
for (let argIndex = 0; argIndex < srcTypeArgs.length; argIndex++) {
|
|
65332
65725
|
const entryDiag = diag === null || diag === void 0 ? void 0 : diag.createAddendum();
|
|
@@ -65396,6 +65789,13 @@ var require_typeEvaluator = __commonJS({
|
|
|
65396
65789
|
effectiveFlags &= ~8;
|
|
65397
65790
|
prevSrcType = curSrcType;
|
|
65398
65791
|
}
|
|
65792
|
+
if ((flags & 1) !== 0) {
|
|
65793
|
+
const srcIsLiteral = srcType.literalValue !== void 0;
|
|
65794
|
+
const destIsLiteral = destType.literalValue !== void 0;
|
|
65795
|
+
if (srcIsLiteral !== destIsLiteral) {
|
|
65796
|
+
return false;
|
|
65797
|
+
}
|
|
65798
|
+
}
|
|
65399
65799
|
if (destType.typeArguments) {
|
|
65400
65800
|
if (!verifyTypeArgumentsAssignable(destType, curSrcType, diag, destTypeVarContext, srcTypeVarContext, flags, recursionCount)) {
|
|
65401
65801
|
return false;
|
|
@@ -65535,6 +65935,9 @@ var require_typeEvaluator = __commonJS({
|
|
|
65535
65935
|
const transformedSrcType = (0, typeUtils_1.transformPossibleRecursiveTypeAlias)(srcType);
|
|
65536
65936
|
if (transformedDestType !== destType && (0, types_1.isUnion)(transformedDestType) || transformedSrcType !== srcType && (0, types_1.isUnion)(transformedSrcType)) {
|
|
65537
65937
|
if (recursionCount > maxRecursiveTypeAliasRecursionCount) {
|
|
65938
|
+
if ((0, types_1.isClassInstance)(srcType) && types_1.ClassType.isBuiltIn(srcType, "str") && (0, types_1.isUnion)(transformedDestType)) {
|
|
65939
|
+
return transformedDestType.subtypes.some((subtype) => (0, types_1.isClassInstance)(subtype) && types_1.ClassType.isBuiltIn(subtype, ["object", "str"]));
|
|
65940
|
+
}
|
|
65538
65941
|
return true;
|
|
65539
65942
|
}
|
|
65540
65943
|
}
|
|
@@ -66407,7 +66810,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
66407
66810
|
void 0,
|
|
66408
66811
|
srcTypeVarContext,
|
|
66409
66812
|
destTypeVarContext,
|
|
66410
|
-
flags ^ 2 |
|
|
66813
|
+
flags ^ 2 | 128,
|
|
66411
66814
|
recursionCount
|
|
66412
66815
|
);
|
|
66413
66816
|
specializedDestType = (0, typeUtils_1.applySolvedTypeVars)(destType, destTypeVarContext);
|
|
@@ -66422,7 +66825,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
66422
66825
|
void 0,
|
|
66423
66826
|
srcTypeVarContext,
|
|
66424
66827
|
destTypeVarContext,
|
|
66425
|
-
flags ^ 2 |
|
|
66828
|
+
flags ^ 2 | 128,
|
|
66426
66829
|
recursionCount
|
|
66427
66830
|
);
|
|
66428
66831
|
specializedSrcType = (0, typeUtils_1.applySolvedTypeVars)(srcType, srcTypeVarContext);
|
|
@@ -66824,37 +67227,34 @@ var require_typeEvaluator = __commonJS({
|
|
|
66824
67227
|
});
|
|
66825
67228
|
const srcParamSpec = effectiveSrcType.details.paramSpec;
|
|
66826
67229
|
const destParamSpec = effectiveDestType.details.paramSpec;
|
|
66827
|
-
|
|
66828
|
-
if (targetTypeVarContext.hasSolveForScope(destParamSpec.scopeId)) {
|
|
67230
|
+
if (remainingParams.length > 0 || !srcParamSpec || !(0, types_1.isTypeSame)(srcParamSpec, destParamSpec, { ignoreTypeFlags: true })) {
|
|
66829
67231
|
const remainingFunction = types_1.FunctionType.createInstance("", "", "", effectiveSrcType.details.flags | 64, effectiveSrcType.details.docString);
|
|
66830
67232
|
remainingFunction.details.typeVarScopeId = effectiveSrcType.details.typeVarScopeId;
|
|
66831
67233
|
remainingParams.forEach((param) => {
|
|
66832
67234
|
types_1.FunctionType.addParameter(remainingFunction, param);
|
|
66833
67235
|
});
|
|
66834
67236
|
remainingFunction.details.paramSpec = srcParamSpec ? (0, typeUtils_1.convertToInstance)(srcParamSpec) : void 0;
|
|
66835
|
-
if (!(
|
|
66836
|
-
evaluatorInterface,
|
|
67237
|
+
if (!assignType(
|
|
66837
67238
|
destParamSpec,
|
|
66838
67239
|
remainingFunction,
|
|
66839
67240
|
/* diag */
|
|
66840
67241
|
void 0,
|
|
66841
|
-
|
|
67242
|
+
destTypeVarContext,
|
|
67243
|
+
srcTypeVarContext,
|
|
67244
|
+
flags
|
|
66842
67245
|
)) {
|
|
66843
|
-
if (remainingParams.length > 0 || !srcParamSpec || !(
|
|
66844
|
-
evaluatorInterface,
|
|
67246
|
+
if (remainingParams.length > 0 || !srcParamSpec || !assignType(
|
|
66845
67247
|
destParamSpec,
|
|
66846
67248
|
(0, typeUtils_1.convertToInstance)(srcParamSpec),
|
|
66847
67249
|
/* diag */
|
|
66848
67250
|
void 0,
|
|
66849
|
-
|
|
67251
|
+
destTypeVarContext,
|
|
67252
|
+
srcTypeVarContext,
|
|
67253
|
+
flags
|
|
66850
67254
|
)) {
|
|
66851
67255
|
canAssign = false;
|
|
66852
67256
|
}
|
|
66853
67257
|
}
|
|
66854
|
-
} else {
|
|
66855
|
-
if (!srcParamSpec || !(0, types_1.isTypeSame)(srcParamSpec, destParamSpec, { ignoreTypeFlags: true }) || remainingParams.length > 0) {
|
|
66856
|
-
canAssign = false;
|
|
66857
|
-
}
|
|
66858
67258
|
}
|
|
66859
67259
|
}
|
|
66860
67260
|
}
|
|
@@ -66913,7 +67313,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
66913
67313
|
void 0,
|
|
66914
67314
|
/* isTypeArgumentExplicit */
|
|
66915
67315
|
false
|
|
66916
|
-
), declaredType, typeVarContext, ParseTreeUtils.getTypeVarScopesForNode(node));
|
|
67316
|
+
), declaredType, typeVarContext, ParseTreeUtils.getTypeVarScopesForNode(node), node.start);
|
|
66917
67317
|
let replacedTypeArg = false;
|
|
66918
67318
|
const newTypeArgs = assignedType.typeArguments.map((typeArg, index) => {
|
|
66919
67319
|
const typeParam = assignedType.details.typeParameters[index];
|
|
@@ -66981,7 +67381,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
66981
67381
|
}
|
|
66982
67382
|
return narrowedType;
|
|
66983
67383
|
}
|
|
66984
|
-
function validateOverrideMethod(baseMethod, overrideMethod, diag, enforceParamNames = true) {
|
|
67384
|
+
function validateOverrideMethod(baseMethod, overrideMethod, baseClass, diag, enforceParamNames = true) {
|
|
66985
67385
|
if (!(0, types_1.isFunction)(baseMethod) && !(0, types_1.isOverloadedFunction)(baseMethod)) {
|
|
66986
67386
|
diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideType().format({ type: printType(baseMethod) }));
|
|
66987
67387
|
return false;
|
|
@@ -66990,7 +67390,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
66990
67390
|
if ((0, types_1.isFunction)(overrideMethod)) {
|
|
66991
67391
|
return validateOverrideMethodInternal(baseMethod, overrideMethod, diag, enforceParamNames);
|
|
66992
67392
|
}
|
|
66993
|
-
if (
|
|
67393
|
+
if (overrideMethod.overloads.some((overrideOverload) => {
|
|
66994
67394
|
return validateOverrideMethodInternal(
|
|
66995
67395
|
baseMethod,
|
|
66996
67396
|
overrideOverload,
|
|
@@ -67001,24 +67401,75 @@ var require_typeEvaluator = __commonJS({
|
|
|
67001
67401
|
})) {
|
|
67002
67402
|
return true;
|
|
67003
67403
|
}
|
|
67004
|
-
|
|
67005
|
-
|
|
67006
|
-
|
|
67007
|
-
|
|
67008
|
-
|
|
67009
|
-
|
|
67010
|
-
void 0,
|
|
67011
|
-
enforceParamNames
|
|
67012
|
-
)) {
|
|
67404
|
+
diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideNoOverloadMatches());
|
|
67405
|
+
return false;
|
|
67406
|
+
}
|
|
67407
|
+
if ((0, types_1.isFunction)(overrideMethod)) {
|
|
67408
|
+
return types_1.OverloadedFunctionType.getOverloads(baseMethod).every((overload) => {
|
|
67409
|
+
if (baseClass && !isOverrideMethodApplicable(overload, baseClass)) {
|
|
67013
67410
|
return true;
|
|
67014
67411
|
}
|
|
67412
|
+
return validateOverrideMethodInternal(overload, overrideMethod, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), enforceParamNames);
|
|
67413
|
+
});
|
|
67414
|
+
}
|
|
67415
|
+
let previousMatchIndex = -1;
|
|
67416
|
+
let overrideOverloadIndex = 0;
|
|
67417
|
+
const baseOverloads = types_1.OverloadedFunctionType.getOverloads(baseMethod);
|
|
67418
|
+
for (const overrideOverload of types_1.OverloadedFunctionType.getOverloads(overrideMethod)) {
|
|
67419
|
+
const matchIndex = baseOverloads.findIndex((baseOverload) => {
|
|
67420
|
+
if (baseClass && !isOverrideMethodApplicable(baseOverload, baseClass)) {
|
|
67421
|
+
return false;
|
|
67422
|
+
}
|
|
67423
|
+
return validateOverrideMethodInternal(
|
|
67424
|
+
baseOverload,
|
|
67425
|
+
overrideOverload,
|
|
67426
|
+
/* diag */
|
|
67427
|
+
void 0,
|
|
67428
|
+
enforceParamNames,
|
|
67429
|
+
/* exemptSelfClsParam */
|
|
67430
|
+
false
|
|
67431
|
+
);
|
|
67432
|
+
});
|
|
67433
|
+
if (matchIndex < 0) {
|
|
67434
|
+
diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideOverloadNoMatch().format({ index: overrideOverloadIndex }));
|
|
67435
|
+
return false;
|
|
67015
67436
|
}
|
|
67016
|
-
|
|
67017
|
-
|
|
67437
|
+
if (matchIndex < previousMatchIndex) {
|
|
67438
|
+
diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideOverloadOrder());
|
|
67439
|
+
return false;
|
|
67440
|
+
}
|
|
67441
|
+
previousMatchIndex = matchIndex;
|
|
67442
|
+
overrideOverloadIndex++;
|
|
67018
67443
|
}
|
|
67019
67444
|
return true;
|
|
67020
67445
|
}
|
|
67021
|
-
function
|
|
67446
|
+
function isOverrideMethodApplicable(baseMethod, childClass) {
|
|
67447
|
+
if (!types_1.FunctionType.isInstanceMethod(baseMethod) && !types_1.FunctionType.isClassMethod(baseMethod) && !types_1.FunctionType.isConstructorMethod(baseMethod)) {
|
|
67448
|
+
return true;
|
|
67449
|
+
}
|
|
67450
|
+
const baseParamDetails = (0, parameterUtils_1.getParameterListDetails)(baseMethod);
|
|
67451
|
+
if (baseParamDetails.params.length === 0) {
|
|
67452
|
+
return true;
|
|
67453
|
+
}
|
|
67454
|
+
const baseParamType = baseParamDetails.params[0].param;
|
|
67455
|
+
if (baseParamType.category !== 0 || !baseParamType.hasDeclaredType) {
|
|
67456
|
+
return true;
|
|
67457
|
+
}
|
|
67458
|
+
const childSelfOrClsType = types_1.FunctionType.isInstanceMethod(baseMethod) ? types_1.ClassType.cloneAsInstance(childClass) : childClass;
|
|
67459
|
+
return assignType(
|
|
67460
|
+
baseParamType.type,
|
|
67461
|
+
childSelfOrClsType,
|
|
67462
|
+
/* diag */
|
|
67463
|
+
void 0,
|
|
67464
|
+
/* destTypeVarContext */
|
|
67465
|
+
void 0,
|
|
67466
|
+
/* srcTypeVarContext */
|
|
67467
|
+
void 0,
|
|
67468
|
+
8
|
|
67469
|
+
/* SkipSolveTypeVars */
|
|
67470
|
+
);
|
|
67471
|
+
}
|
|
67472
|
+
function validateOverrideMethodInternal(baseMethod, overrideMethod, diag, enforceParamNames, exemptSelfClsParam = true) {
|
|
67022
67473
|
var _a, _b;
|
|
67023
67474
|
const baseParamDetails = (0, parameterUtils_1.getParameterListDetails)(baseMethod);
|
|
67024
67475
|
const overrideParamDetails = (0, parameterUtils_1.getParameterListDetails)(overrideMethod);
|
|
@@ -67034,8 +67485,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
67034
67485
|
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideNotClassMethod());
|
|
67035
67486
|
canOverride = false;
|
|
67036
67487
|
}
|
|
67037
|
-
}
|
|
67038
|
-
if (types_1.FunctionType.isInstanceMethod(baseMethod)) {
|
|
67488
|
+
} else if (types_1.FunctionType.isInstanceMethod(baseMethod)) {
|
|
67039
67489
|
if (!types_1.FunctionType.isInstanceMethod(overrideMethod)) {
|
|
67040
67490
|
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideNotInstanceMethod());
|
|
67041
67491
|
canOverride = false;
|
|
@@ -67083,7 +67533,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
67083
67533
|
}
|
|
67084
67534
|
const positionalParamCount = Math.min(baseParamDetails.positionParamCount, overrideParamDetails.positionParamCount);
|
|
67085
67535
|
for (let i = 0; i < positionalParamCount; i++) {
|
|
67086
|
-
if (i === 0) {
|
|
67536
|
+
if (i === 0 && exemptSelfClsParam) {
|
|
67087
67537
|
if (types_1.FunctionType.isInstanceMethod(overrideMethod) || types_1.FunctionType.isClassMethod(overrideMethod) || types_1.FunctionType.isConstructorMethod(overrideMethod)) {
|
|
67088
67538
|
continue;
|
|
67089
67539
|
}
|
|
@@ -67121,7 +67571,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
67121
67571
|
const overrideParamType = overrideParamDetails.params[i].type;
|
|
67122
67572
|
const baseIsSynthesizedTypeVar = (0, types_1.isTypeVar)(baseParamType) && baseParamType.details.isSynthesized;
|
|
67123
67573
|
const overrideIsSynthesizedTypeVar = (0, types_1.isTypeVar)(overrideParamType) && overrideParamType.details.isSynthesized;
|
|
67124
|
-
if (!baseIsSynthesizedTypeVar && !overrideIsSynthesizedTypeVar) {
|
|
67574
|
+
if (!exemptSelfClsParam || !baseIsSynthesizedTypeVar && !overrideIsSynthesizedTypeVar) {
|
|
67125
67575
|
if (baseParam.category !== overrideParam.category || !assignType(
|
|
67126
67576
|
overrideParamType,
|
|
67127
67577
|
baseParamType,
|
|
@@ -67179,13 +67629,13 @@ var require_typeEvaluator = __commonJS({
|
|
|
67179
67629
|
(paramInfo) => paramInfo.source === parameterUtils_1.ParameterSource.KeywordOnly && paramInfo.param.category === 0
|
|
67180
67630
|
/* Simple */
|
|
67181
67631
|
);
|
|
67182
|
-
const
|
|
67632
|
+
const overrideKwOnlyParams = overrideParamDetails.params.filter(
|
|
67183
67633
|
(paramInfo) => paramInfo.source === parameterUtils_1.ParameterSource.KeywordOnly && paramInfo.param.category === 0
|
|
67184
67634
|
/* Simple */
|
|
67185
67635
|
);
|
|
67186
67636
|
baseKwOnlyParams.forEach((paramInfo) => {
|
|
67187
67637
|
var _a2, _b2, _c;
|
|
67188
|
-
const overrideParamInfo =
|
|
67638
|
+
const overrideParamInfo = overrideKwOnlyParams.find((pi) => paramInfo.param.name === pi.param.name);
|
|
67189
67639
|
if (!overrideParamInfo && overrideParamDetails.kwargsIndex === void 0) {
|
|
67190
67640
|
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideParamNameMissing().format({
|
|
67191
67641
|
name: (_a2 = paramInfo.param.name) !== null && _a2 !== void 0 ? _a2 : "?"
|
|
@@ -67223,7 +67673,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
67223
67673
|
}
|
|
67224
67674
|
}
|
|
67225
67675
|
});
|
|
67226
|
-
|
|
67676
|
+
overrideKwOnlyParams.forEach((paramInfo) => {
|
|
67227
67677
|
var _a2;
|
|
67228
67678
|
const baseParamInfo = baseKwOnlyParams.find((pi) => paramInfo.param.name === pi.param.name);
|
|
67229
67679
|
if (!baseParamInfo) {
|
|
@@ -67672,6 +68122,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
67672
68122
|
verifyRaiseExceptionType,
|
|
67673
68123
|
verifyDeleteExpression,
|
|
67674
68124
|
validateOverloadedFunctionArguments,
|
|
68125
|
+
validateInitSubclassArgs,
|
|
67675
68126
|
isAfterNodeReachable,
|
|
67676
68127
|
isNodeReachable,
|
|
67677
68128
|
isAsymmetricDescriptorAssignment: isAsymmetricAccessorAssignment,
|
|
@@ -67719,6 +68170,7 @@ var require_typeEvaluator = __commonJS({
|
|
|
67719
68170
|
getBuiltInObject,
|
|
67720
68171
|
getTypingType,
|
|
67721
68172
|
verifyTypeArgumentsAssignable,
|
|
68173
|
+
reportMissingTypeArguments,
|
|
67722
68174
|
inferReturnTypeIfNecessary,
|
|
67723
68175
|
inferTypeParameterVarianceForClass,
|
|
67724
68176
|
isFinalVariable,
|
|
@@ -67953,6 +68405,7 @@ var require_checker = __commonJS({
|
|
|
67953
68405
|
if (types_1.ClassType.isEnumClass(classTypeResult.classType)) {
|
|
67954
68406
|
this._validateEnumClassOverride(node, classTypeResult.classType);
|
|
67955
68407
|
}
|
|
68408
|
+
this._evaluator.validateInitSubclassArgs(node, classTypeResult.classType);
|
|
67956
68409
|
}
|
|
67957
68410
|
this._scopedNodes.push(node);
|
|
67958
68411
|
return false;
|
|
@@ -71102,6 +71555,8 @@ var require_checker = __commonJS({
|
|
|
71102
71555
|
if (!this._evaluator.validateOverrideMethod(
|
|
71103
71556
|
overriddenType,
|
|
71104
71557
|
overrideFunction,
|
|
71558
|
+
/* baseClass */
|
|
71559
|
+
void 0,
|
|
71105
71560
|
diagAddendum,
|
|
71106
71561
|
/* enforceParamNameMatch */
|
|
71107
71562
|
true
|
|
@@ -71173,6 +71628,7 @@ var require_checker = __commonJS({
|
|
|
71173
71628
|
if (!mroBaseClass) {
|
|
71174
71629
|
continue;
|
|
71175
71630
|
}
|
|
71631
|
+
(0, debug_1.assert)((0, types_1.isClass)(mroBaseClass));
|
|
71176
71632
|
const baseClassAndSymbol = (0, typeUtils_1.lookUpClassMember)(
|
|
71177
71633
|
mroBaseClass,
|
|
71178
71634
|
name,
|
|
@@ -71274,7 +71730,7 @@ var require_checker = __commonJS({
|
|
|
71274
71730
|
const exemptMethods = ["__init__", "__new__", "__init_subclass__"];
|
|
71275
71731
|
const enforceParamNameMatch = !SymbolNameUtils.isDunderName(memberName);
|
|
71276
71732
|
if (!exemptMethods.some((exempt) => exempt === memberName) && !SymbolNameUtils.isPrivateName(memberName)) {
|
|
71277
|
-
if (!this._evaluator.validateOverrideMethod(baseType, overrideType, diagAddendum, enforceParamNameMatch)) {
|
|
71733
|
+
if (!this._evaluator.validateOverrideMethod(baseType, overrideType, childClassType, diagAddendum, enforceParamNameMatch)) {
|
|
71278
71734
|
const decl = (0, types_1.isFunction)(overrideType) && overrideType.details.declaration ? overrideType.details.declaration : (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(overrideSymbol);
|
|
71279
71735
|
if (decl) {
|
|
71280
71736
|
const diag = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportIncompatibleMethodOverride, diagnosticRules_1.DiagnosticRule.reportIncompatibleMethodOverride, localize_1.Localizer.Diagnostic.incompatibleMethodOverride().format({
|
|
@@ -71358,7 +71814,7 @@ var require_checker = __commonJS({
|
|
|
71358
71814
|
} else {
|
|
71359
71815
|
const subclassMethodType = (0, typeUtils_1.partiallySpecializeType)(this._evaluator.getEffectiveTypeOfSymbol(subclassPropMethod), childClassType);
|
|
71360
71816
|
if ((0, types_1.isFunction)(subclassMethodType)) {
|
|
71361
|
-
if (!this._evaluator.validateOverrideMethod(baseClassMethodType, subclassMethodType, diagAddendum.createAddendum())) {
|
|
71817
|
+
if (!this._evaluator.validateOverrideMethod(baseClassMethodType, subclassMethodType, childClassType, diagAddendum.createAddendum())) {
|
|
71362
71818
|
diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.propertyMethodIncompatible().format({
|
|
71363
71819
|
name: methodName
|
|
71364
71820
|
}));
|
|
@@ -71615,6 +72071,9 @@ var require_checker = __commonJS({
|
|
|
71615
72071
|
if ((0, types_1.isClassInstance)(paramType) && types_1.ClassType.isProtocolClass(paramType)) {
|
|
71616
72072
|
return;
|
|
71617
72073
|
}
|
|
72074
|
+
if (paramInfo.category === 1 && (0, types_1.isParamSpec)(paramInfo.type) && paramInfo.type.paramSpecAccess === "args") {
|
|
72075
|
+
return;
|
|
72076
|
+
}
|
|
71618
72077
|
if (types_1.FunctionType.isOverloaded(functionType)) {
|
|
71619
72078
|
return;
|
|
71620
72079
|
}
|
|
@@ -71637,39 +72096,52 @@ var require_checker = __commonJS({
|
|
|
71637
72096
|
}
|
|
71638
72097
|
}
|
|
71639
72098
|
}
|
|
72099
|
+
// Determines whether a yield or yield from node is compatible with the
|
|
72100
|
+
// return type annotation of the containing function.
|
|
71640
72101
|
_validateYieldType(node, yieldType) {
|
|
71641
|
-
|
|
71642
|
-
let declaredYieldType;
|
|
72102
|
+
var _a;
|
|
71643
72103
|
const enclosingFunctionNode = ParseTreeUtils.getEnclosingFunction(node);
|
|
71644
|
-
if (enclosingFunctionNode) {
|
|
71645
|
-
|
|
71646
|
-
if (functionTypeResult) {
|
|
71647
|
-
(0, debug_1.assert)((0, types_1.isFunction)(functionTypeResult.functionType));
|
|
71648
|
-
declaredReturnType = types_1.FunctionType.getSpecializedReturnType(functionTypeResult.functionType);
|
|
71649
|
-
if (declaredReturnType) {
|
|
71650
|
-
declaredYieldType = (0, typeUtils_1.getGeneratorYieldType)(declaredReturnType, !!enclosingFunctionNode.isAsync);
|
|
71651
|
-
}
|
|
71652
|
-
if (declaredReturnType && !declaredYieldType && enclosingFunctionNode.returnTypeAnnotation) {
|
|
71653
|
-
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, enclosingFunctionNode.isAsync ? localize_1.Localizer.Diagnostic.generatorAsyncReturnType() : localize_1.Localizer.Diagnostic.generatorSyncReturnType(), enclosingFunctionNode.returnTypeAnnotation);
|
|
71654
|
-
}
|
|
71655
|
-
}
|
|
72104
|
+
if (!enclosingFunctionNode || !enclosingFunctionNode.returnTypeAnnotation) {
|
|
72105
|
+
return;
|
|
71656
72106
|
}
|
|
71657
|
-
|
|
72107
|
+
const functionTypeResult = this._evaluator.getTypeOfFunction(enclosingFunctionNode);
|
|
72108
|
+
if (!functionTypeResult) {
|
|
72109
|
+
return;
|
|
72110
|
+
}
|
|
72111
|
+
const declaredReturnType = types_1.FunctionType.getSpecializedReturnType(functionTypeResult.functionType);
|
|
72112
|
+
if (!declaredReturnType) {
|
|
72113
|
+
return;
|
|
72114
|
+
}
|
|
72115
|
+
let generatorType;
|
|
72116
|
+
if (!enclosingFunctionNode.isAsync && (0, types_1.isClassInstance)(declaredReturnType) && types_1.ClassType.isBuiltIn(declaredReturnType, "AwaitableGenerator")) {
|
|
72117
|
+
generatorType = this._evaluator.getTypingType(node, "AwaitableGenerator");
|
|
72118
|
+
} else {
|
|
72119
|
+
generatorType = this._evaluator.getTypingType(node, enclosingFunctionNode.isAsync ? "AsyncGenerator" : "Generator");
|
|
72120
|
+
}
|
|
72121
|
+
if (!generatorType || !(0, types_1.isInstantiableClass)(generatorType)) {
|
|
72122
|
+
return;
|
|
72123
|
+
}
|
|
72124
|
+
if (!this._evaluator.isNodeReachable(
|
|
71658
72125
|
node,
|
|
71659
72126
|
/* sourceNode */
|
|
71660
72127
|
void 0
|
|
71661
72128
|
)) {
|
|
71662
|
-
|
|
71663
|
-
|
|
71664
|
-
|
|
71665
|
-
|
|
71666
|
-
|
|
71667
|
-
|
|
71668
|
-
|
|
71669
|
-
|
|
71670
|
-
|
|
71671
|
-
|
|
71672
|
-
|
|
72129
|
+
return;
|
|
72130
|
+
}
|
|
72131
|
+
if ((0, types_1.isNever)(declaredReturnType)) {
|
|
72132
|
+
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.noReturnContainsYield(), node);
|
|
72133
|
+
return;
|
|
72134
|
+
}
|
|
72135
|
+
const specializedGenerator = types_1.ClassType.cloneAsInstance(types_1.ClassType.cloneForSpecialization(
|
|
72136
|
+
generatorType,
|
|
72137
|
+
[yieldType],
|
|
72138
|
+
/* isTypeArgumentExplicit */
|
|
72139
|
+
true
|
|
72140
|
+
));
|
|
72141
|
+
const diagAddendum = new diagnostic_1.DiagnosticAddendum();
|
|
72142
|
+
if (!this._evaluator.assignType(declaredReturnType, specializedGenerator, diagAddendum)) {
|
|
72143
|
+
const errorMessage = enclosingFunctionNode.isAsync ? localize_1.Localizer.Diagnostic.generatorAsyncReturnType() : localize_1.Localizer.Diagnostic.generatorSyncReturnType();
|
|
72144
|
+
this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, errorMessage.format({ yieldType: this._evaluator.printType(yieldType) }) + diagAddendum.getString(), (_a = node.expression) !== null && _a !== void 0 ? _a : node);
|
|
71673
72145
|
}
|
|
71674
72146
|
}
|
|
71675
72147
|
// Determines whether any of the except statements are unreachable because
|
|
@@ -72242,6 +72714,7 @@ var require_sourceFile = __commonJS({
|
|
|
72242
72714
|
this.checkerDiagnostics = [];
|
|
72243
72715
|
this.typeIgnoreLines = /* @__PURE__ */ new Map();
|
|
72244
72716
|
this.pyrightIgnoreLines = /* @__PURE__ */ new Map();
|
|
72717
|
+
this.accumulatedDiagnostics = [];
|
|
72245
72718
|
this.circularDependencies = [];
|
|
72246
72719
|
this.noCircularDependencyConfirmed = false;
|
|
72247
72720
|
this.isBindingNeeded = true;
|
|
@@ -72310,154 +72783,7 @@ var require_sourceFile = __commonJS({
|
|
|
72310
72783
|
if (this._writableData.diagnosticVersion === prevDiagnosticVersion) {
|
|
72311
72784
|
return void 0;
|
|
72312
72785
|
}
|
|
72313
|
-
|
|
72314
|
-
if (this._isThirdPartyImport) {
|
|
72315
|
-
includeWarningsAndErrors = false;
|
|
72316
|
-
}
|
|
72317
|
-
let diagList = [];
|
|
72318
|
-
(0, collectionUtils_1.appendArray)(diagList, this._writableData.parseDiagnostics);
|
|
72319
|
-
(0, collectionUtils_1.appendArray)(diagList, this._writableData.commentDiagnostics);
|
|
72320
|
-
(0, collectionUtils_1.appendArray)(diagList, this._writableData.bindDiagnostics);
|
|
72321
|
-
(0, collectionUtils_1.appendArray)(diagList, this._writableData.checkerDiagnostics);
|
|
72322
|
-
const prefilteredDiagList = diagList;
|
|
72323
|
-
const typeIgnoreLinesClone = new Map(this._writableData.typeIgnoreLines);
|
|
72324
|
-
const pyrightIgnoreLinesClone = new Map(this._writableData.pyrightIgnoreLines);
|
|
72325
|
-
if (this._diagnosticRuleSet.enableTypeIgnoreComments) {
|
|
72326
|
-
if (this._writableData.typeIgnoreLines.size > 0) {
|
|
72327
|
-
diagList = diagList.filter((d) => {
|
|
72328
|
-
if (d.category !== 3 && d.category !== 4 && d.category !== 5) {
|
|
72329
|
-
for (let line = d.range.start.line; line <= d.range.end.line; line++) {
|
|
72330
|
-
if (this._writableData.typeIgnoreLines.has(line)) {
|
|
72331
|
-
typeIgnoreLinesClone.delete(line);
|
|
72332
|
-
return false;
|
|
72333
|
-
}
|
|
72334
|
-
}
|
|
72335
|
-
}
|
|
72336
|
-
return true;
|
|
72337
|
-
});
|
|
72338
|
-
}
|
|
72339
|
-
}
|
|
72340
|
-
if (this._writableData.pyrightIgnoreLines.size > 0) {
|
|
72341
|
-
diagList = diagList.filter((d) => {
|
|
72342
|
-
if (d.category !== 4 && d.category !== 5) {
|
|
72343
|
-
for (let line = d.range.start.line; line <= d.range.end.line; line++) {
|
|
72344
|
-
const pyrightIgnoreComment = this._writableData.pyrightIgnoreLines.get(line);
|
|
72345
|
-
if (pyrightIgnoreComment) {
|
|
72346
|
-
if (!pyrightIgnoreComment.rulesList) {
|
|
72347
|
-
pyrightIgnoreLinesClone.delete(line);
|
|
72348
|
-
return false;
|
|
72349
|
-
}
|
|
72350
|
-
const diagRule = d.getRule();
|
|
72351
|
-
if (!diagRule) {
|
|
72352
|
-
return true;
|
|
72353
|
-
}
|
|
72354
|
-
if (pyrightIgnoreComment.rulesList.find((rule) => rule.text === diagRule)) {
|
|
72355
|
-
const oldClone = pyrightIgnoreLinesClone.get(line);
|
|
72356
|
-
if (oldClone === null || oldClone === void 0 ? void 0 : oldClone.rulesList) {
|
|
72357
|
-
const filteredRulesList = oldClone.rulesList.filter((rule) => rule.text !== diagRule);
|
|
72358
|
-
if (filteredRulesList.length === 0) {
|
|
72359
|
-
pyrightIgnoreLinesClone.delete(line);
|
|
72360
|
-
} else {
|
|
72361
|
-
pyrightIgnoreLinesClone.set(line, {
|
|
72362
|
-
range: oldClone.range,
|
|
72363
|
-
rulesList: filteredRulesList
|
|
72364
|
-
});
|
|
72365
|
-
}
|
|
72366
|
-
}
|
|
72367
|
-
return false;
|
|
72368
|
-
}
|
|
72369
|
-
return true;
|
|
72370
|
-
}
|
|
72371
|
-
}
|
|
72372
|
-
}
|
|
72373
|
-
return true;
|
|
72374
|
-
});
|
|
72375
|
-
}
|
|
72376
|
-
const unnecessaryTypeIgnoreDiags = [];
|
|
72377
|
-
if (this._diagnosticRuleSet.reportUnnecessaryTypeIgnoreComment !== "none" && !this._writableData.isCheckingNeeded) {
|
|
72378
|
-
const diagCategory = (0, diagnostic_1.convertLevelToCategory)(this._diagnosticRuleSet.reportUnnecessaryTypeIgnoreComment);
|
|
72379
|
-
const prefilteredErrorList = prefilteredDiagList.filter(
|
|
72380
|
-
(diag) => diag.category === 0 || diag.category === 1 || diag.category === 2
|
|
72381
|
-
/* Information */
|
|
72382
|
-
);
|
|
72383
|
-
const isUnreachableCodeRange = (range) => {
|
|
72384
|
-
return prefilteredDiagList.find((diag) => diag.category === 4 && diag.range.start.line <= range.start.line && diag.range.end.line >= range.end.line);
|
|
72385
|
-
};
|
|
72386
|
-
if (prefilteredErrorList.length === 0 && this._writableData.typeIgnoreAll !== void 0) {
|
|
72387
|
-
const rangeStart = this._writableData.typeIgnoreAll.range.start;
|
|
72388
|
-
const rangeEnd = rangeStart + this._writableData.typeIgnoreAll.range.length;
|
|
72389
|
-
const range = (0, positionUtils_1.convertOffsetsToRange)(rangeStart, rangeEnd, this._writableData.parseResults.tokenizerOutput.lines);
|
|
72390
|
-
if (!isUnreachableCodeRange(range) && this._diagnosticRuleSet.enableTypeIgnoreComments) {
|
|
72391
|
-
unnecessaryTypeIgnoreDiags.push(new diagnostic_1.Diagnostic(diagCategory, localize_1.Localizer.Diagnostic.unnecessaryTypeIgnore(), range));
|
|
72392
|
-
}
|
|
72393
|
-
}
|
|
72394
|
-
typeIgnoreLinesClone.forEach((ignoreComment) => {
|
|
72395
|
-
var _a;
|
|
72396
|
-
if ((_a = this._writableData.parseResults) === null || _a === void 0 ? void 0 : _a.tokenizerOutput.lines) {
|
|
72397
|
-
const rangeStart = ignoreComment.range.start;
|
|
72398
|
-
const rangeEnd = rangeStart + ignoreComment.range.length;
|
|
72399
|
-
const range = (0, positionUtils_1.convertOffsetsToRange)(rangeStart, rangeEnd, this._writableData.parseResults.tokenizerOutput.lines);
|
|
72400
|
-
if (!isUnreachableCodeRange(range) && this._diagnosticRuleSet.enableTypeIgnoreComments) {
|
|
72401
|
-
unnecessaryTypeIgnoreDiags.push(new diagnostic_1.Diagnostic(diagCategory, localize_1.Localizer.Diagnostic.unnecessaryTypeIgnore(), range));
|
|
72402
|
-
}
|
|
72403
|
-
}
|
|
72404
|
-
});
|
|
72405
|
-
pyrightIgnoreLinesClone.forEach((ignoreComment) => {
|
|
72406
|
-
var _a;
|
|
72407
|
-
if ((_a = this._writableData.parseResults) === null || _a === void 0 ? void 0 : _a.tokenizerOutput.lines) {
|
|
72408
|
-
if (!ignoreComment.rulesList) {
|
|
72409
|
-
const rangeStart = ignoreComment.range.start;
|
|
72410
|
-
const rangeEnd = rangeStart + ignoreComment.range.length;
|
|
72411
|
-
const range = (0, positionUtils_1.convertOffsetsToRange)(rangeStart, rangeEnd, this._writableData.parseResults.tokenizerOutput.lines);
|
|
72412
|
-
if (!isUnreachableCodeRange(range)) {
|
|
72413
|
-
unnecessaryTypeIgnoreDiags.push(new diagnostic_1.Diagnostic(diagCategory, localize_1.Localizer.Diagnostic.unnecessaryPyrightIgnore(), range));
|
|
72414
|
-
}
|
|
72415
|
-
} else {
|
|
72416
|
-
ignoreComment.rulesList.forEach((unusedRule) => {
|
|
72417
|
-
const rangeStart = unusedRule.range.start;
|
|
72418
|
-
const rangeEnd = rangeStart + unusedRule.range.length;
|
|
72419
|
-
const range = (0, positionUtils_1.convertOffsetsToRange)(rangeStart, rangeEnd, this._writableData.parseResults.tokenizerOutput.lines);
|
|
72420
|
-
if (!isUnreachableCodeRange(range)) {
|
|
72421
|
-
unnecessaryTypeIgnoreDiags.push(new diagnostic_1.Diagnostic(diagCategory, localize_1.Localizer.Diagnostic.unnecessaryPyrightIgnoreRule().format({
|
|
72422
|
-
name: unusedRule.text
|
|
72423
|
-
}), range));
|
|
72424
|
-
}
|
|
72425
|
-
});
|
|
72426
|
-
}
|
|
72427
|
-
}
|
|
72428
|
-
});
|
|
72429
|
-
}
|
|
72430
|
-
if (this._diagnosticRuleSet.reportImportCycles !== "none" && this._writableData.circularDependencies.length > 0) {
|
|
72431
|
-
const category = (0, diagnostic_1.convertLevelToCategory)(this._diagnosticRuleSet.reportImportCycles);
|
|
72432
|
-
this._writableData.circularDependencies.forEach((cirDep) => {
|
|
72433
|
-
const diag = new diagnostic_1.Diagnostic(category, localize_1.Localizer.Diagnostic.importCycleDetected() + "\n" + cirDep.getPaths().map((path12) => " " + path12).join("\n"), (0, textRange_1.getEmptyRange)());
|
|
72434
|
-
diag.setRule(diagnosticRules_1.DiagnosticRule.reportImportCycles);
|
|
72435
|
-
diagList.push(diag);
|
|
72436
|
-
});
|
|
72437
|
-
}
|
|
72438
|
-
if (this._writableData.hitMaxImportDepth !== void 0) {
|
|
72439
|
-
diagList.push(new diagnostic_1.Diagnostic(0, localize_1.Localizer.Diagnostic.importDepthExceeded().format({ depth: this._writableData.hitMaxImportDepth }), (0, textRange_1.getEmptyRange)()));
|
|
72440
|
-
}
|
|
72441
|
-
this._addTaskListDiagnostics(options.taskListTokens, diagList);
|
|
72442
|
-
if (options.ignore.find((ignoreFileSpec) => ignoreFileSpec.regExp.test(this._realFilePath))) {
|
|
72443
|
-
diagList = [];
|
|
72444
|
-
}
|
|
72445
|
-
if (this._diagnosticRuleSet.enableTypeIgnoreComments) {
|
|
72446
|
-
if (this._writableData.typeIgnoreAll !== void 0) {
|
|
72447
|
-
diagList = diagList.filter(
|
|
72448
|
-
(diag) => diag.category !== 0 && diag.category !== 1 && diag.category !== 2
|
|
72449
|
-
/* Information */
|
|
72450
|
-
);
|
|
72451
|
-
}
|
|
72452
|
-
}
|
|
72453
|
-
diagList = diagList.concat(unnecessaryTypeIgnoreDiags);
|
|
72454
|
-
if (!includeWarningsAndErrors) {
|
|
72455
|
-
diagList = diagList.filter(
|
|
72456
|
-
(diag) => diag.category === 3 || diag.category === 4 || diag.category === 5
|
|
72457
|
-
/* Deprecated */
|
|
72458
|
-
);
|
|
72459
|
-
}
|
|
72460
|
-
return diagList;
|
|
72786
|
+
return this._writableData.accumulatedDiagnostics;
|
|
72461
72787
|
}
|
|
72462
72788
|
getImports() {
|
|
72463
72789
|
return this._writableData.imports || [];
|
|
@@ -72604,7 +72930,7 @@ var require_sourceFile = __commonJS({
|
|
|
72604
72930
|
}
|
|
72605
72931
|
// Adds a new circular dependency for this file but only if
|
|
72606
72932
|
// it hasn't already been added.
|
|
72607
|
-
addCircularDependency(circDependency) {
|
|
72933
|
+
addCircularDependency(configOptions, circDependency) {
|
|
72608
72934
|
let updatedDependencyList = false;
|
|
72609
72935
|
if (this._writableData.circularDependencies.length < _maxImportCyclesPerFile) {
|
|
72610
72936
|
if (!this._writableData.circularDependencies.some((dep) => dep.isEqual(circDependency))) {
|
|
@@ -72613,7 +72939,7 @@ var require_sourceFile = __commonJS({
|
|
|
72613
72939
|
}
|
|
72614
72940
|
}
|
|
72615
72941
|
if (updatedDependencyList) {
|
|
72616
|
-
this.
|
|
72942
|
+
this._recomputeDiagnostics(configOptions);
|
|
72617
72943
|
}
|
|
72618
72944
|
}
|
|
72619
72945
|
setNoCircularDependencyConfirmed() {
|
|
@@ -72711,7 +73037,7 @@ var require_sourceFile = __commonJS({
|
|
|
72711
73037
|
this._writableData.isCheckingNeeded = true;
|
|
72712
73038
|
this._writableData.parseTreeNeedsCleaning = false;
|
|
72713
73039
|
this._writableData.hitMaxImportDepth = void 0;
|
|
72714
|
-
this.
|
|
73040
|
+
this._recomputeDiagnostics(configOptions);
|
|
72715
73041
|
return true;
|
|
72716
73042
|
});
|
|
72717
73043
|
}
|
|
@@ -72747,12 +73073,12 @@ var require_sourceFile = __commonJS({
|
|
|
72747
73073
|
} finally {
|
|
72748
73074
|
this._writableData.isBindingInProgress = false;
|
|
72749
73075
|
}
|
|
72750
|
-
this._writableData.diagnosticVersion++;
|
|
72751
73076
|
this._writableData.isCheckingNeeded = true;
|
|
72752
73077
|
this._writableData.isBindingNeeded = false;
|
|
73078
|
+
this._recomputeDiagnostics(configOptions);
|
|
72753
73079
|
});
|
|
72754
73080
|
}
|
|
72755
|
-
check(importResolver, evaluator, sourceMapper, dependentFiles) {
|
|
73081
|
+
check(configOptions, importResolver, evaluator, sourceMapper, dependentFiles) {
|
|
72756
73082
|
(0, debug_1.assert)(!this.isParseRequired(), "Check called before parsing");
|
|
72757
73083
|
(0, debug_1.assert)(!this.isBindingRequired(), "Check called before binding");
|
|
72758
73084
|
(0, debug_1.assert)(!this._writableData.isBindingInProgress, "Check called while binding in progress");
|
|
@@ -72782,13 +73108,166 @@ var require_sourceFile = __commonJS({
|
|
|
72782
73108
|
throw e;
|
|
72783
73109
|
} finally {
|
|
72784
73110
|
this._writableData.circularDependencies = [];
|
|
72785
|
-
this.
|
|
73111
|
+
this._recomputeDiagnostics(configOptions);
|
|
72786
73112
|
}
|
|
72787
73113
|
});
|
|
72788
73114
|
}
|
|
72789
73115
|
test_enableIPythonMode(enable) {
|
|
72790
73116
|
this._ipythonMode = enable ? IPythonMode.CellDocs : IPythonMode.None;
|
|
72791
73117
|
}
|
|
73118
|
+
// Computes an updated set of accumulated diagnostics for the file
|
|
73119
|
+
// based on the partial diagnostics from various analysis stages.
|
|
73120
|
+
_recomputeDiagnostics(configOptions) {
|
|
73121
|
+
this._writableData.diagnosticVersion++;
|
|
73122
|
+
let includeWarningsAndErrors = true;
|
|
73123
|
+
if (this._isThirdPartyImport) {
|
|
73124
|
+
includeWarningsAndErrors = false;
|
|
73125
|
+
}
|
|
73126
|
+
let diagList = [];
|
|
73127
|
+
(0, collectionUtils_1.appendArray)(diagList, this._writableData.parseDiagnostics);
|
|
73128
|
+
(0, collectionUtils_1.appendArray)(diagList, this._writableData.commentDiagnostics);
|
|
73129
|
+
(0, collectionUtils_1.appendArray)(diagList, this._writableData.bindDiagnostics);
|
|
73130
|
+
(0, collectionUtils_1.appendArray)(diagList, this._writableData.checkerDiagnostics);
|
|
73131
|
+
const prefilteredDiagList = diagList;
|
|
73132
|
+
const typeIgnoreLinesClone = new Map(this._writableData.typeIgnoreLines);
|
|
73133
|
+
const pyrightIgnoreLinesClone = new Map(this._writableData.pyrightIgnoreLines);
|
|
73134
|
+
if (this._diagnosticRuleSet.enableTypeIgnoreComments) {
|
|
73135
|
+
if (this._writableData.typeIgnoreLines.size > 0) {
|
|
73136
|
+
diagList = diagList.filter((d) => {
|
|
73137
|
+
if (d.category !== 3 && d.category !== 4 && d.category !== 5) {
|
|
73138
|
+
for (let line = d.range.start.line; line <= d.range.end.line; line++) {
|
|
73139
|
+
if (this._writableData.typeIgnoreLines.has(line)) {
|
|
73140
|
+
typeIgnoreLinesClone.delete(line);
|
|
73141
|
+
return false;
|
|
73142
|
+
}
|
|
73143
|
+
}
|
|
73144
|
+
}
|
|
73145
|
+
return true;
|
|
73146
|
+
});
|
|
73147
|
+
}
|
|
73148
|
+
}
|
|
73149
|
+
if (this._writableData.pyrightIgnoreLines.size > 0) {
|
|
73150
|
+
diagList = diagList.filter((d) => {
|
|
73151
|
+
if (d.category !== 4 && d.category !== 5) {
|
|
73152
|
+
for (let line = d.range.start.line; line <= d.range.end.line; line++) {
|
|
73153
|
+
const pyrightIgnoreComment = this._writableData.pyrightIgnoreLines.get(line);
|
|
73154
|
+
if (pyrightIgnoreComment) {
|
|
73155
|
+
if (!pyrightIgnoreComment.rulesList) {
|
|
73156
|
+
pyrightIgnoreLinesClone.delete(line);
|
|
73157
|
+
return false;
|
|
73158
|
+
}
|
|
73159
|
+
const diagRule = d.getRule();
|
|
73160
|
+
if (!diagRule) {
|
|
73161
|
+
return true;
|
|
73162
|
+
}
|
|
73163
|
+
if (pyrightIgnoreComment.rulesList.find((rule) => rule.text === diagRule)) {
|
|
73164
|
+
const oldClone = pyrightIgnoreLinesClone.get(line);
|
|
73165
|
+
if (oldClone === null || oldClone === void 0 ? void 0 : oldClone.rulesList) {
|
|
73166
|
+
const filteredRulesList = oldClone.rulesList.filter((rule) => rule.text !== diagRule);
|
|
73167
|
+
if (filteredRulesList.length === 0) {
|
|
73168
|
+
pyrightIgnoreLinesClone.delete(line);
|
|
73169
|
+
} else {
|
|
73170
|
+
pyrightIgnoreLinesClone.set(line, {
|
|
73171
|
+
range: oldClone.range,
|
|
73172
|
+
rulesList: filteredRulesList
|
|
73173
|
+
});
|
|
73174
|
+
}
|
|
73175
|
+
}
|
|
73176
|
+
return false;
|
|
73177
|
+
}
|
|
73178
|
+
return true;
|
|
73179
|
+
}
|
|
73180
|
+
}
|
|
73181
|
+
}
|
|
73182
|
+
return true;
|
|
73183
|
+
});
|
|
73184
|
+
}
|
|
73185
|
+
const unnecessaryTypeIgnoreDiags = [];
|
|
73186
|
+
if (this._diagnosticRuleSet.reportUnnecessaryTypeIgnoreComment !== "none" && !this._writableData.isCheckingNeeded) {
|
|
73187
|
+
const diagCategory = (0, diagnostic_1.convertLevelToCategory)(this._diagnosticRuleSet.reportUnnecessaryTypeIgnoreComment);
|
|
73188
|
+
const prefilteredErrorList = prefilteredDiagList.filter(
|
|
73189
|
+
(diag) => diag.category === 0 || diag.category === 1 || diag.category === 2
|
|
73190
|
+
/* Information */
|
|
73191
|
+
);
|
|
73192
|
+
const isUnreachableCodeRange = (range) => {
|
|
73193
|
+
return prefilteredDiagList.find((diag) => diag.category === 4 && diag.range.start.line <= range.start.line && diag.range.end.line >= range.end.line);
|
|
73194
|
+
};
|
|
73195
|
+
if (prefilteredErrorList.length === 0 && this._writableData.typeIgnoreAll !== void 0) {
|
|
73196
|
+
const rangeStart = this._writableData.typeIgnoreAll.range.start;
|
|
73197
|
+
const rangeEnd = rangeStart + this._writableData.typeIgnoreAll.range.length;
|
|
73198
|
+
const range = (0, positionUtils_1.convertOffsetsToRange)(rangeStart, rangeEnd, this._writableData.parseResults.tokenizerOutput.lines);
|
|
73199
|
+
if (!isUnreachableCodeRange(range) && this._diagnosticRuleSet.enableTypeIgnoreComments) {
|
|
73200
|
+
unnecessaryTypeIgnoreDiags.push(new diagnostic_1.Diagnostic(diagCategory, localize_1.Localizer.Diagnostic.unnecessaryTypeIgnore(), range));
|
|
73201
|
+
}
|
|
73202
|
+
}
|
|
73203
|
+
typeIgnoreLinesClone.forEach((ignoreComment) => {
|
|
73204
|
+
var _a;
|
|
73205
|
+
if ((_a = this._writableData.parseResults) === null || _a === void 0 ? void 0 : _a.tokenizerOutput.lines) {
|
|
73206
|
+
const rangeStart = ignoreComment.range.start;
|
|
73207
|
+
const rangeEnd = rangeStart + ignoreComment.range.length;
|
|
73208
|
+
const range = (0, positionUtils_1.convertOffsetsToRange)(rangeStart, rangeEnd, this._writableData.parseResults.tokenizerOutput.lines);
|
|
73209
|
+
if (!isUnreachableCodeRange(range) && this._diagnosticRuleSet.enableTypeIgnoreComments) {
|
|
73210
|
+
unnecessaryTypeIgnoreDiags.push(new diagnostic_1.Diagnostic(diagCategory, localize_1.Localizer.Diagnostic.unnecessaryTypeIgnore(), range));
|
|
73211
|
+
}
|
|
73212
|
+
}
|
|
73213
|
+
});
|
|
73214
|
+
pyrightIgnoreLinesClone.forEach((ignoreComment) => {
|
|
73215
|
+
var _a;
|
|
73216
|
+
if ((_a = this._writableData.parseResults) === null || _a === void 0 ? void 0 : _a.tokenizerOutput.lines) {
|
|
73217
|
+
if (!ignoreComment.rulesList) {
|
|
73218
|
+
const rangeStart = ignoreComment.range.start;
|
|
73219
|
+
const rangeEnd = rangeStart + ignoreComment.range.length;
|
|
73220
|
+
const range = (0, positionUtils_1.convertOffsetsToRange)(rangeStart, rangeEnd, this._writableData.parseResults.tokenizerOutput.lines);
|
|
73221
|
+
if (!isUnreachableCodeRange(range)) {
|
|
73222
|
+
unnecessaryTypeIgnoreDiags.push(new diagnostic_1.Diagnostic(diagCategory, localize_1.Localizer.Diagnostic.unnecessaryPyrightIgnore(), range));
|
|
73223
|
+
}
|
|
73224
|
+
} else {
|
|
73225
|
+
ignoreComment.rulesList.forEach((unusedRule) => {
|
|
73226
|
+
const rangeStart = unusedRule.range.start;
|
|
73227
|
+
const rangeEnd = rangeStart + unusedRule.range.length;
|
|
73228
|
+
const range = (0, positionUtils_1.convertOffsetsToRange)(rangeStart, rangeEnd, this._writableData.parseResults.tokenizerOutput.lines);
|
|
73229
|
+
if (!isUnreachableCodeRange(range)) {
|
|
73230
|
+
unnecessaryTypeIgnoreDiags.push(new diagnostic_1.Diagnostic(diagCategory, localize_1.Localizer.Diagnostic.unnecessaryPyrightIgnoreRule().format({
|
|
73231
|
+
name: unusedRule.text
|
|
73232
|
+
}), range));
|
|
73233
|
+
}
|
|
73234
|
+
});
|
|
73235
|
+
}
|
|
73236
|
+
}
|
|
73237
|
+
});
|
|
73238
|
+
}
|
|
73239
|
+
if (this._diagnosticRuleSet.reportImportCycles !== "none" && this._writableData.circularDependencies.length > 0) {
|
|
73240
|
+
const category = (0, diagnostic_1.convertLevelToCategory)(this._diagnosticRuleSet.reportImportCycles);
|
|
73241
|
+
this._writableData.circularDependencies.forEach((cirDep) => {
|
|
73242
|
+
const diag = new diagnostic_1.Diagnostic(category, localize_1.Localizer.Diagnostic.importCycleDetected() + "\n" + cirDep.getPaths().map((path12) => " " + path12).join("\n"), (0, textRange_1.getEmptyRange)());
|
|
73243
|
+
diag.setRule(diagnosticRules_1.DiagnosticRule.reportImportCycles);
|
|
73244
|
+
diagList.push(diag);
|
|
73245
|
+
});
|
|
73246
|
+
}
|
|
73247
|
+
if (this._writableData.hitMaxImportDepth !== void 0) {
|
|
73248
|
+
diagList.push(new diagnostic_1.Diagnostic(0, localize_1.Localizer.Diagnostic.importDepthExceeded().format({ depth: this._writableData.hitMaxImportDepth }), (0, textRange_1.getEmptyRange)()));
|
|
73249
|
+
}
|
|
73250
|
+
this._addTaskListDiagnostics(configOptions.taskListTokens, diagList);
|
|
73251
|
+
if (configOptions.ignore.find((ignoreFileSpec) => ignoreFileSpec.regExp.test(this._realFilePath))) {
|
|
73252
|
+
diagList = [];
|
|
73253
|
+
}
|
|
73254
|
+
if (this._diagnosticRuleSet.enableTypeIgnoreComments) {
|
|
73255
|
+
if (this._writableData.typeIgnoreAll !== void 0) {
|
|
73256
|
+
diagList = diagList.filter(
|
|
73257
|
+
(diag) => diag.category !== 0 && diag.category !== 1 && diag.category !== 2
|
|
73258
|
+
/* Information */
|
|
73259
|
+
);
|
|
73260
|
+
}
|
|
73261
|
+
}
|
|
73262
|
+
diagList = diagList.concat(unnecessaryTypeIgnoreDiags);
|
|
73263
|
+
if (!includeWarningsAndErrors) {
|
|
73264
|
+
diagList = diagList.filter(
|
|
73265
|
+
(diag) => diag.category === 3 || diag.category === 4 || diag.category === 5
|
|
73266
|
+
/* Deprecated */
|
|
73267
|
+
);
|
|
73268
|
+
}
|
|
73269
|
+
this._writableData.accumulatedDiagnostics = diagList;
|
|
73270
|
+
}
|
|
72792
73271
|
_cachePreEditState() {
|
|
72793
73272
|
if (this._writableData.clientDocumentContents !== void 0) {
|
|
72794
73273
|
if (this._isEditMode && !this._preEditData) {
|
|
@@ -72798,7 +73277,7 @@ var require_sourceFile = __commonJS({
|
|
|
72798
73277
|
}
|
|
72799
73278
|
}
|
|
72800
73279
|
// Get all task list diagnostics for the current file and add them
|
|
72801
|
-
// to the specified diagnostic list
|
|
73280
|
+
// to the specified diagnostic list.
|
|
72802
73281
|
_addTaskListDiagnostics(taskListTokens, diagList) {
|
|
72803
73282
|
var _a, _b;
|
|
72804
73283
|
if (!taskListTokens || taskListTokens.length === 0 || !diagList) {
|
|
@@ -73868,6 +74347,13 @@ var require_tokenizer = __commonJS({
|
|
|
73868
74347
|
);
|
|
73869
74348
|
this._tokens.push(tokenizerTypes_1.Token.create(1, this._cs.position, 0, this._getComments()));
|
|
73870
74349
|
this._addLineRange();
|
|
74350
|
+
if (this._lineRanges.length > 0) {
|
|
74351
|
+
const lastLine = this._lineRanges[this._lineRanges.length - 1];
|
|
74352
|
+
const lastCharOfLastLine = text.charCodeAt(lastLine.start + lastLine.length - 1);
|
|
74353
|
+
if (lastCharOfLastLine === 13 || lastCharOfLastLine === 10) {
|
|
74354
|
+
this._lineRanges.push({ start: this._cs.position, length: 0 });
|
|
74355
|
+
}
|
|
74356
|
+
}
|
|
73871
74357
|
let predominantEndOfLineSequence = "\n";
|
|
73872
74358
|
if (this._crCount > this._crLfCount && this._crCount > this._lfCount) {
|
|
73873
74359
|
predominantEndOfLineSequence = "\r";
|
|
@@ -74768,7 +75254,8 @@ var require_tokenizer = __commonJS({
|
|
|
74768
75254
|
} else {
|
|
74769
75255
|
const isEscapedQuote = this._cs.getCurrentChar() === 39 || this._cs.getCurrentChar() === 34;
|
|
74770
75256
|
const isEscapedNewLine = this._cs.getCurrentChar() === 13 || this._cs.getCurrentChar() === 10;
|
|
74771
|
-
|
|
75257
|
+
const isEscapedBackslash = this._cs.getCurrentChar() === 92;
|
|
75258
|
+
if (!isFString || isEscapedBackslash || isEscapedQuote || isEscapedNewLine) {
|
|
74772
75259
|
if (isEscapedNewLine) {
|
|
74773
75260
|
if (this._cs.getCurrentChar() === 13 && this._cs.nextChar === 10) {
|
|
74774
75261
|
escapedValueParts.push(this._cs.currentChar);
|
|
@@ -78144,10 +78631,13 @@ var require_parser = __commonJS({
|
|
|
78144
78631
|
this._addError(localize_1.Localizer.Diagnostic.keywordSubscriptIllegal(), argNode.name);
|
|
78145
78632
|
}
|
|
78146
78633
|
if (argType !== 0) {
|
|
78147
|
-
const
|
|
78148
|
-
if (argType ===
|
|
78634
|
+
const unpackListAllowed = this._parseOptions.isStubFile || this._isParsingQuotedText || this._getLanguageVersion() >= pythonVersion_1.PythonVersion.V3_11;
|
|
78635
|
+
if (argType === 1 && !unpackListAllowed) {
|
|
78149
78636
|
this._addError(localize_1.Localizer.Diagnostic.unpackedSubscriptIllegal(), argNode);
|
|
78150
78637
|
}
|
|
78638
|
+
if (argType === 2) {
|
|
78639
|
+
this._addError(localize_1.Localizer.Diagnostic.unpackedDictSubscriptIllegal(), argNode);
|
|
78640
|
+
}
|
|
78151
78641
|
}
|
|
78152
78642
|
if (!this._consumeTokenIfType(
|
|
78153
78643
|
12
|
|
@@ -83218,7 +83708,7 @@ var require_streams = __commonJS({
|
|
|
83218
83708
|
});
|
|
83219
83709
|
|
|
83220
83710
|
// node_modules/iconv-lite/lib/index.js
|
|
83221
|
-
var
|
|
83711
|
+
var require_lib3 = __commonJS({
|
|
83222
83712
|
"node_modules/iconv-lite/lib/index.js"(exports, module2) {
|
|
83223
83713
|
"use strict";
|
|
83224
83714
|
var Buffer2 = require_safer().Buffer;
|
|
@@ -95514,7 +96004,7 @@ var import_coc32 = require("coc.nvim");
|
|
|
95514
96004
|
var import_fs = require("fs");
|
|
95515
96005
|
var import_path7 = require("path");
|
|
95516
96006
|
var import_semver2 = __toESM(require_semver2());
|
|
95517
|
-
var import_which5 = __toESM(
|
|
96007
|
+
var import_which5 = __toESM(require_lib());
|
|
95518
96008
|
|
|
95519
96009
|
// src/commands.ts
|
|
95520
96010
|
var child_process2 = __toESM(require("child_process"));
|
|
@@ -95524,10 +96014,10 @@ var import_path2 = __toESM(require("path"));
|
|
|
95524
96014
|
// src/configSettings.ts
|
|
95525
96015
|
var child_process = __toESM(require("child_process"));
|
|
95526
96016
|
var import_coc = require("coc.nvim");
|
|
95527
|
-
var import_fs_extra = __toESM(
|
|
96017
|
+
var import_fs_extra = __toESM(require_lib2());
|
|
95528
96018
|
var import_path = __toESM(require("path"));
|
|
95529
96019
|
var import_untildify = __toESM(require_untildify());
|
|
95530
|
-
var import_which = __toESM(
|
|
96020
|
+
var import_which = __toESM(require_lib());
|
|
95531
96021
|
|
|
95532
96022
|
// src/systemVariables.ts
|
|
95533
96023
|
var Path = __toESM(require("path"));
|
|
@@ -95925,7 +96415,7 @@ var SemanticTokensWalker = class extends import_parseTreeWalker.ParseTreeWalker
|
|
|
95925
96415
|
this.semanticItems.push(item);
|
|
95926
96416
|
}
|
|
95927
96417
|
visitFormatString(node) {
|
|
95928
|
-
node.
|
|
96418
|
+
node.fieldExpressions.map((f) => this.addSemanticItem(68 /* variable */, f));
|
|
95929
96419
|
return super.visitFormatString(node);
|
|
95930
96420
|
}
|
|
95931
96421
|
visitTypeAnnotation(node) {
|
|
@@ -96332,16 +96822,16 @@ var import_coc9 = require("coc.nvim");
|
|
|
96332
96822
|
|
|
96333
96823
|
// src/features/formatters/baseFormatter.ts
|
|
96334
96824
|
var import_coc5 = require("coc.nvim");
|
|
96335
|
-
var import_fs_extra2 = __toESM(
|
|
96825
|
+
var import_fs_extra2 = __toESM(require_lib2());
|
|
96336
96826
|
var import_md5 = __toESM(require_md5());
|
|
96337
96827
|
var import_path3 = __toESM(require("path"));
|
|
96338
96828
|
var import_semver = __toESM(require_semver2());
|
|
96339
96829
|
var import_util = require("util");
|
|
96340
|
-
var import_which2 = __toESM(
|
|
96830
|
+
var import_which2 = __toESM(require_lib());
|
|
96341
96831
|
|
|
96342
96832
|
// src/processService.ts
|
|
96343
96833
|
var import_child_process = require("child_process");
|
|
96344
|
-
var iconv = __toESM(
|
|
96834
|
+
var iconv = __toESM(require_lib3());
|
|
96345
96835
|
var import_os = require("os");
|
|
96346
96836
|
var import_rxjs = __toESM(require_cjs());
|
|
96347
96837
|
|
|
@@ -97402,10 +97892,10 @@ var PythonSemanticTokensProvider = class {
|
|
|
97402
97892
|
|
|
97403
97893
|
// src/features/sortImports.ts
|
|
97404
97894
|
var import_coc13 = require("coc.nvim");
|
|
97405
|
-
var import_fs_extra3 = __toESM(
|
|
97895
|
+
var import_fs_extra3 = __toESM(require_lib2());
|
|
97406
97896
|
var import_md52 = __toESM(require_md5());
|
|
97407
97897
|
var path4 = __toESM(require("path"));
|
|
97408
|
-
var import_which3 = __toESM(
|
|
97898
|
+
var import_which3 = __toESM(require_lib());
|
|
97409
97899
|
function getTempFileWithDocumentContents2(document) {
|
|
97410
97900
|
return new Promise((resolve, reject) => {
|
|
97411
97901
|
const fsPath = import_coc13.Uri.parse(document.uri).fsPath;
|
|
@@ -97483,7 +97973,7 @@ var import_coc28 = require("coc.nvim");
|
|
|
97483
97973
|
|
|
97484
97974
|
// src/features/linters/lintingEngine.ts
|
|
97485
97975
|
var import_coc27 = require("coc.nvim");
|
|
97486
|
-
var import_fs_extra5 = __toESM(
|
|
97976
|
+
var import_fs_extra5 = __toESM(require_lib2());
|
|
97487
97977
|
var import_minimatch = __toESM(require_minimatch());
|
|
97488
97978
|
var import_path5 = __toESM(require("path"));
|
|
97489
97979
|
|
|
@@ -97724,7 +98214,7 @@ var Flake8 = class extends BaseLinter {
|
|
|
97724
98214
|
// src/features/linters/linterInfo.ts
|
|
97725
98215
|
var import_coc17 = require("coc.nvim");
|
|
97726
98216
|
var path5 = __toESM(require("path"));
|
|
97727
|
-
var import_which4 = __toESM(
|
|
98217
|
+
var import_which4 = __toESM(require_lib());
|
|
97728
98218
|
var LinterInfo = class {
|
|
97729
98219
|
constructor(product, id, configService, configFileNames = []) {
|
|
97730
98220
|
this.configService = configService;
|
|
@@ -97960,7 +98450,7 @@ var Pylint = class extends BaseLinter {
|
|
|
97960
98450
|
|
|
97961
98451
|
// src/features/linters/pytype.ts
|
|
97962
98452
|
var import_coc25 = require("coc.nvim");
|
|
97963
|
-
var import_fs_extra4 = __toESM(
|
|
98453
|
+
var import_fs_extra4 = __toESM(require_lib2());
|
|
97964
98454
|
var path8 = __toESM(require("path"));
|
|
97965
98455
|
var pytypecfg = "pytype.cfg";
|
|
97966
98456
|
var REGEX6 = '^File \\"(?<file>.*)\\", line (?<line>\\d+), in (<module>|\\w+): (?<message>.*)\\r?(\\n|$)';
|
|
@@ -98121,6 +98611,7 @@ var Ruff = class extends BaseLinter {
|
|
|
98121
98611
|
tags: ["F401", "F841"].includes(msg.code) ? [import_coc26.DiagnosticTag.Unnecessary] : [],
|
|
98122
98612
|
provider: this.info.id,
|
|
98123
98613
|
file: msg.filename,
|
|
98614
|
+
url: msg.url,
|
|
98124
98615
|
fix: this.fixToWorkspaceEdit(msg.filename, msg.fix)
|
|
98125
98616
|
};
|
|
98126
98617
|
});
|
|
@@ -98256,6 +98747,9 @@ var LintingEngine = class {
|
|
|
98256
98747
|
const severity = lintSeverityToVSSeverity.get(message.severity);
|
|
98257
98748
|
const diagnostic = import_coc27.Diagnostic.create(range, message.message, severity);
|
|
98258
98749
|
diagnostic.code = message.code;
|
|
98750
|
+
if (message.url) {
|
|
98751
|
+
diagnostic.codeDescription = { href: message.url };
|
|
98752
|
+
}
|
|
98259
98753
|
diagnostic.source = message.provider;
|
|
98260
98754
|
diagnostic.fix = message.fix;
|
|
98261
98755
|
diagnostic.tags = message.tags;
|