@zzzen/pyright-internal 1.2.0-dev.20240616 → 1.2.0-dev.20240623
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/dist/analyzer/cacheManager.js +3 -0
- package/dist/analyzer/cacheManager.js.map +1 -1
- package/dist/analyzer/checker.d.ts +3 -0
- package/dist/analyzer/checker.js +161 -82
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.d.ts +1 -1
- package/dist/analyzer/codeFlowEngine.js +7 -12
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/dataClasses.d.ts +2 -1
- package/dist/analyzer/dataClasses.js +5 -2
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/parseTreeUtils.js +18 -2
- package/dist/analyzer/parseTreeUtils.js.map +1 -1
- package/dist/analyzer/patternMatching.js +11 -2
- package/dist/analyzer/patternMatching.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +90 -124
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +0 -1
- package/dist/analyzer/typeUtils.js +4 -2
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/types.js +9 -6
- package/dist/analyzer/types.js.map +1 -1
- package/dist/common/diagnostic.d.ts +1 -0
- package/dist/common/diagnostic.js +5 -0
- package/dist/common/diagnostic.js.map +1 -1
- package/dist/common/docStringService.d.ts +2 -1
- package/dist/common/docStringService.js.map +1 -1
- package/dist/common/textRangeCollection.d.ts +1 -1
- package/dist/common/textRangeCollection.js +14 -14
- package/dist/common/textRangeCollection.js.map +1 -1
- package/dist/languageService/autoImporter.js +2 -2
- package/dist/languageService/autoImporter.js.map +1 -1
- package/dist/languageService/hoverProvider.d.ts +1 -1
- package/dist/languageService/hoverProvider.js +11 -7
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/languageService/signatureHelpProvider.js +19 -2
- package/dist/languageService/signatureHelpProvider.js.map +1 -1
- package/dist/localization/localize.d.ts +1 -0
- package/dist/localization/localize.js +1 -0
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.cs.json +2 -0
- package/dist/localization/package.nls.de.json +2 -0
- package/dist/localization/package.nls.en-us.json +1 -0
- package/dist/localization/package.nls.es.json +2 -0
- package/dist/localization/package.nls.fr.json +2 -0
- package/dist/localization/package.nls.it.json +2 -0
- package/dist/localization/package.nls.ja.json +2 -0
- package/dist/localization/package.nls.ko.json +2 -0
- package/dist/localization/package.nls.pl.json +2 -0
- package/dist/localization/package.nls.pt-br.json +2 -0
- package/dist/localization/package.nls.qps-ploc.json +2 -0
- package/dist/localization/package.nls.ru.json +2 -0
- package/dist/localization/package.nls.tr.json +2 -0
- package/dist/localization/package.nls.zh-cn.json +2 -0
- package/dist/localization/package.nls.zh-tw.json +2 -0
- package/dist/tests/checker.test.js +2 -2
- package/dist/tests/fourslash/hover.docstring.alias.fourslash.js +5 -5
- package/dist/tests/fourslash/hover.docstring.alias.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.init.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.init.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.variable.docString.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.variable.docString.fourslash.js.map +1 -1
- package/dist/tests/parseTreeUtils.test.js +89 -0
- package/dist/tests/parseTreeUtils.test.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +1 -1
- package/dist/tests/typeEvaluator3.test.js +1 -1
- package/dist/tests/typeEvaluator7.test.js +1 -1
- package/package.json +1 -1
@@ -2143,15 +2143,38 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
2143
2143
|
}
|
2144
2144
|
}
|
2145
2145
|
function addDiagnosticWithSuppressionCheck(diagLevel, message, node, range) {
|
2146
|
-
|
2146
|
+
var _a;
|
2147
|
+
if (isDiagnosticSuppressedForNode(node)) {
|
2148
|
+
// See if this node is suppressed but the diagnostic should be generated
|
2149
|
+
// anyway so it can be used by the caller that requested the suppression.
|
2150
|
+
const suppressionEntry = suppressedNodeStack.find((suppressedNode) => ParseTreeUtils.isNodeContainedWithin(node, suppressedNode.node) && suppressedNode.suppressedDiags);
|
2151
|
+
(_a = suppressionEntry === null || suppressionEntry === void 0 ? void 0 : suppressionEntry.suppressedDiags) === null || _a === void 0 ? void 0 : _a.push(message);
|
2152
|
+
return undefined;
|
2153
|
+
}
|
2154
|
+
if (isNodeReachable(node)) {
|
2147
2155
|
const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
|
2148
|
-
return fileInfo.diagnosticSink.addDiagnosticWithTextRange(diagLevel, message, range
|
2156
|
+
return fileInfo.diagnosticSink.addDiagnosticWithTextRange(diagLevel, message, range !== null && range !== void 0 ? range : node);
|
2149
2157
|
}
|
2150
2158
|
return undefined;
|
2151
2159
|
}
|
2152
2160
|
function isDiagnosticSuppressedForNode(node) {
|
2153
|
-
|
2154
|
-
|
2161
|
+
if (speculativeTypeTracker.isSpeculative(node, /* ignoreIfDiagnosticsAllowed */ true)) {
|
2162
|
+
return true;
|
2163
|
+
}
|
2164
|
+
return suppressedNodeStack.some((suppressedNode) => ParseTreeUtils.isNodeContainedWithin(node, suppressedNode.node));
|
2165
|
+
}
|
2166
|
+
// This function is similar to isDiagnosticSuppressedForNode except that it
|
2167
|
+
// returns false if diagnostics are suppressed for the node but the caller
|
2168
|
+
// has requested that diagnostics be generated anyway.
|
2169
|
+
function canSkipDiagnosticForNode(node) {
|
2170
|
+
if (speculativeTypeTracker.isSpeculative(node, /* ignoreIfDiagnosticsAllowed */ true)) {
|
2171
|
+
return true;
|
2172
|
+
}
|
2173
|
+
const suppressedEntries = suppressedNodeStack.filter((suppressedNode) => ParseTreeUtils.isNodeContainedWithin(node, suppressedNode.node));
|
2174
|
+
if (suppressedEntries.length === 0) {
|
2175
|
+
return false;
|
2176
|
+
}
|
2177
|
+
return suppressedEntries.every((entry) => !entry.suppressedDiags);
|
2155
2178
|
}
|
2156
2179
|
function addDiagnostic(rule, message, node, range) {
|
2157
2180
|
const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
|
@@ -4230,6 +4253,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
4230
4253
|
/* skipUnknownArgCheck */ true,
|
4231
4254
|
/* inferenceContext */ undefined,
|
4232
4255
|
/* signatureTracker */ undefined);
|
4256
|
+
}, (suppressedDiags) => {
|
4257
|
+
// If diagnostics were recorded when suppressed, add them to the
|
4258
|
+
// diagnostic as messages.
|
4259
|
+
if (diag) {
|
4260
|
+
suppressedDiags.forEach((message) => {
|
4261
|
+
diag === null || diag === void 0 ? void 0 : diag.addMessageMultiline(message);
|
4262
|
+
});
|
4263
|
+
}
|
4233
4264
|
});
|
4234
4265
|
// Collect deprecation information associated with the member access method.
|
4235
4266
|
let deprecationInfo;
|
@@ -4252,28 +4283,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
4252
4283
|
memberAccessDeprecationInfo: deprecationInfo,
|
4253
4284
|
};
|
4254
4285
|
}
|
4255
|
-
// Errors were detected when evaluating the access method call.
|
4256
|
-
if (usage.method === 'set') {
|
4257
|
-
if (usage.setType &&
|
4258
|
-
(0, types_1.isFunction)(methodType) &&
|
4259
|
-
methodType.details.parameters.length >= 2 &&
|
4260
|
-
!usage.setType.isIncomplete) {
|
4261
|
-
const setterType = types_1.FunctionType.getEffectiveParameterType(methodType, 1);
|
4262
|
-
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocAddendum.typeIncompatible().format({
|
4263
|
-
destType: printType(setterType),
|
4264
|
-
sourceType: printType(usage.setType.type),
|
4265
|
-
}));
|
4266
|
-
}
|
4267
|
-
else if ((0, types_1.isOverloadedFunction)(methodType)) {
|
4268
|
-
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocMessage.noOverload().format({ name: accessMethodName }));
|
4269
|
-
}
|
4270
|
-
}
|
4271
|
-
else {
|
4272
|
-
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocAddendum.descriptorAccessCallFailed().format({
|
4273
|
-
name: accessMethodName,
|
4274
|
-
className: printType((0, typeUtils_1.convertToInstance)(methodClassType)),
|
4275
|
-
}));
|
4276
|
-
}
|
4277
4286
|
return {
|
4278
4287
|
type: types_1.UnknownType.create(),
|
4279
4288
|
typeErrors: true,
|
@@ -5179,7 +5188,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
5179
5188
|
});
|
5180
5189
|
positionalIndexType = makeTupleObject(tupleTypeArgs);
|
5181
5190
|
}
|
5182
|
-
|
5191
|
+
const argList = [
|
5183
5192
|
{
|
5184
5193
|
argumentCategory: 0 /* ArgumentCategory.Simple */,
|
5185
5194
|
typeResult: { type: positionalIndexType, isIncomplete: isPositionalIndexTypeIncomplete },
|
@@ -5216,44 +5225,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
5216
5225
|
node: arg,
|
5217
5226
|
});
|
5218
5227
|
});
|
5219
|
-
|
5220
|
-
// Speculatively attempt the call. We may need to replace the index
|
5221
|
-
// type with 'int', and we don't want to emit errors before we know
|
5222
|
-
// which type to use.
|
5223
|
-
if (keywordArgs.length === 0 && unpackedDictArgs.length === 0 && positionalArgs.length === 1) {
|
5224
|
-
useSpeculativeMode(node, () => {
|
5225
|
-
callResult = validateCallArguments(node, argList, { type: itemMethodType },
|
5226
|
-
/* typeVarContext */ undefined,
|
5227
|
-
/* skipUnknownArgCheck */ true,
|
5228
|
-
/* inferenceContext */ undefined,
|
5229
|
-
/* signatureTracker */ undefined);
|
5230
|
-
if (callResult.argumentErrors) {
|
5231
|
-
// If the object supports "__index__" magic method, convert
|
5232
|
-
// the index to an int and try again.
|
5233
|
-
if ((0, types_1.isClassInstance)(positionalIndexType)) {
|
5234
|
-
const altArgList = [...argList];
|
5235
|
-
altArgList[0] = { ...altArgList[0] };
|
5236
|
-
const indexMethod = getBoundMagicMethod(positionalIndexType, '__index__');
|
5237
|
-
if (indexMethod) {
|
5238
|
-
const intType = getBuiltInObject(node, 'int');
|
5239
|
-
if ((0, types_1.isClassInstance)(intType)) {
|
5240
|
-
altArgList[0].typeResult = { type: intType };
|
5241
|
-
}
|
5242
|
-
}
|
5243
|
-
callResult = validateCallArguments(node, altArgList, { type: itemMethodType },
|
5244
|
-
/* typeVarContext */ undefined,
|
5245
|
-
/* skipUnknownArgCheck */ true,
|
5246
|
-
/* inferenceContext */ undefined,
|
5247
|
-
/* signatureTracker */ undefined);
|
5248
|
-
// We were successful, so replace the arg list.
|
5249
|
-
if (!callResult.argumentErrors) {
|
5250
|
-
argList = altArgList;
|
5251
|
-
}
|
5252
|
-
}
|
5253
|
-
}
|
5254
|
-
});
|
5255
|
-
}
|
5256
|
-
callResult = validateCallArguments(node, argList, { type: itemMethodType },
|
5228
|
+
const callResult = validateCallArguments(node, argList, { type: itemMethodType },
|
5257
5229
|
/* typeVarContext */ undefined,
|
5258
5230
|
/* skipUnknownArgCheck */ true,
|
5259
5231
|
/* inferenceContext */ undefined,
|
@@ -6398,7 +6370,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
6398
6370
|
if (filteredMatchResults.length === 0) {
|
6399
6371
|
// Skip the error message if we're in speculative mode because it's very
|
6400
6372
|
// expensive, and we're going to suppress the diagnostic anyway.
|
6401
|
-
if (!
|
6373
|
+
if (!canSkipDiagnosticForNode(errorNode)) {
|
6402
6374
|
const functionName = typeResult.type.overloads[0].details.name || '<anonymous function>';
|
6403
6375
|
const diagAddendum = new diagnostic_1.DiagnosticAddendum();
|
6404
6376
|
const argTypes = argList.map((t) => {
|
@@ -6490,7 +6462,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
6490
6462
|
// We couldn't find any valid overloads. Skip the error message if we're
|
6491
6463
|
// in speculative mode because it's very expensive, and we're going to
|
6492
6464
|
// suppress the diagnostic anyway.
|
6493
|
-
if (!
|
6465
|
+
if (!canSkipDiagnosticForNode(errorNode) && !isTypeIncomplete) {
|
6494
6466
|
const result = evaluateUsingBestMatchingOverload(
|
6495
6467
|
/* skipUnknownArgCheck */ true,
|
6496
6468
|
/* emitNoOverloadFoundError */ true);
|
@@ -7250,7 +7222,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
7250
7222
|
tooManyPositionals = true;
|
7251
7223
|
}
|
7252
7224
|
if (tooManyPositionals) {
|
7253
|
-
if (!
|
7225
|
+
if (!canSkipDiagnosticForNode(errorNode) && !isTypeIncomplete) {
|
7254
7226
|
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, positionParamLimitIndex === 1
|
7255
7227
|
? localize_1.LocMessage.argPositionalExpectedOne()
|
7256
7228
|
: localize_1.LocMessage.argPositionalExpectedCount().format({
|
@@ -7284,7 +7256,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
7284
7256
|
if ((0, types_1.isTypeVar)(argTypeResult.type) &&
|
7285
7257
|
argTypeResult.type.paramSpecAccess === 'args' &&
|
7286
7258
|
paramDetails.params[paramIndex].param.category !== 1 /* ParameterCategory.ArgsList */) {
|
7287
|
-
if (!
|
7259
|
+
if (!canSkipDiagnosticForNode(errorNode) && !isTypeIncomplete) {
|
7288
7260
|
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, positionParamLimitIndex === 1
|
7289
7261
|
? localize_1.LocMessage.argPositionalExpectedOne()
|
7290
7262
|
: localize_1.LocMessage.argPositionalExpectedCount().format({
|
@@ -7350,7 +7322,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
7350
7322
|
// It's not allowed to use unpacked arguments with a variadic *args
|
7351
7323
|
// parameter unless the argument is a variadic arg as well.
|
7352
7324
|
if (isParamVariadic && !isArgCompatibleWithVariadic) {
|
7353
|
-
if (!
|
7325
|
+
if (!canSkipDiagnosticForNode(errorNode) && !isTypeIncomplete) {
|
7354
7326
|
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.unpackedArgWithVariadicParam(), argList[argIndex].valueExpression || errorNode);
|
7355
7327
|
}
|
7356
7328
|
reportedArgError = true;
|
@@ -7407,7 +7379,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
7407
7379
|
: 0 /* ParameterCategory.Simple */;
|
7408
7380
|
if (remainingArgCount <= remainingParamCount) {
|
7409
7381
|
if (remainingArgCount < remainingParamCount) {
|
7410
|
-
if (!
|
7382
|
+
if (!canSkipDiagnosticForNode(errorNode) && !isTypeIncomplete) {
|
7411
7383
|
// Have we run out of arguments and still have parameters left to fill?
|
7412
7384
|
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, remainingArgCount === 1
|
7413
7385
|
? localize_1.LocMessage.argMorePositionalExpectedOne()
|
@@ -7490,7 +7462,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
7490
7462
|
argsRemainingCount--;
|
7491
7463
|
}
|
7492
7464
|
if (argsRemainingCount > 0) {
|
7493
|
-
if (!
|
7465
|
+
if (!canSkipDiagnosticForNode(errorNode) && !isTypeIncomplete) {
|
7494
7466
|
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, argsRemainingCount === 1
|
7495
7467
|
? localize_1.LocMessage.argMorePositionalExpectedOne()
|
7496
7468
|
: localize_1.LocMessage.argMorePositionalExpectedCount().format({
|
@@ -7572,7 +7544,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
7572
7544
|
}
|
7573
7545
|
});
|
7574
7546
|
if (!diag.isEmpty()) {
|
7575
|
-
if (!
|
7547
|
+
if (!canSkipDiagnosticForNode(errorNode) && !isTypeIncomplete) {
|
7576
7548
|
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.unpackedTypedDictArgument() + diag.getString(), argList[argIndex].valueExpression || errorNode);
|
7577
7549
|
}
|
7578
7550
|
reportedArgError = true;
|
@@ -7632,7 +7604,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
7632
7604
|
});
|
7633
7605
|
}
|
7634
7606
|
if (!isValidMappingType) {
|
7635
|
-
if (!
|
7607
|
+
if (!canSkipDiagnosticForNode(errorNode) && !isTypeIncomplete) {
|
7636
7608
|
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.unpackedDictArgumentNotMapping(), argList[argIndex].valueExpression || errorNode);
|
7637
7609
|
}
|
7638
7610
|
reportedArgError = true;
|
@@ -7653,7 +7625,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
7653
7625
|
const paramEntry = paramMap.get(paramNameValue);
|
7654
7626
|
if (paramEntry && !paramEntry.isPositionalOnly) {
|
7655
7627
|
if (paramEntry.argsReceived > 0) {
|
7656
|
-
if (!
|
7628
|
+
if (!canSkipDiagnosticForNode(errorNode) && !isTypeIncomplete) {
|
7657
7629
|
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.paramAlreadyAssigned().format({ name: paramNameValue }), paramName);
|
7658
7630
|
}
|
7659
7631
|
reportedArgError = true;
|
@@ -7697,7 +7669,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
7697
7669
|
trySetActive(argList[argIndex], paramDetails.params[paramDetails.kwargsIndex].param);
|
7698
7670
|
}
|
7699
7671
|
else {
|
7700
|
-
if (!
|
7672
|
+
if (!canSkipDiagnosticForNode(errorNode) && !isTypeIncomplete) {
|
7701
7673
|
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.paramNameMissing().format({ name: paramName.value }), paramName);
|
7702
7674
|
}
|
7703
7675
|
reportedArgError = true;
|
@@ -7708,7 +7680,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
7708
7680
|
paramSpecArgList.push(argList[argIndex]);
|
7709
7681
|
}
|
7710
7682
|
else {
|
7711
|
-
if (!
|
7683
|
+
if (!canSkipDiagnosticForNode(errorNode) && !isTypeIncomplete) {
|
7712
7684
|
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, positionParamLimitIndex === 1
|
7713
7685
|
? localize_1.LocMessage.argPositionalExpectedOne()
|
7714
7686
|
: localize_1.LocMessage.argPositionalExpectedCount().format({
|
@@ -7784,9 +7756,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
7784
7756
|
return !entry || entry.argsReceived < entry.argsNeeded;
|
7785
7757
|
});
|
7786
7758
|
if (unassignedParams.length > 0) {
|
7787
|
-
if (!
|
7759
|
+
if (!canSkipDiagnosticForNode(errorNode)) {
|
7788
7760
|
const missingParamNames = unassignedParams.map((p) => `"${p}"`).join(', ');
|
7789
|
-
if (!
|
7761
|
+
if (!canSkipDiagnosticForNode(errorNode) && !isTypeIncomplete) {
|
7790
7762
|
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, unassignedParams.length === 1
|
7791
7763
|
? localize_1.LocMessage.argMissingForParam().format({ name: missingParamNames })
|
7792
7764
|
: localize_1.LocMessage.argMissingForParams().format({ names: missingParamNames }), errorNode);
|
@@ -7857,7 +7829,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
7857
7829
|
if (containsVariadicTypeVar &&
|
7858
7830
|
argParam.argument.argumentCategory !== 1 /* ArgumentCategory.UnpackedList */ &&
|
7859
7831
|
!argParam.mapsToVarArgList) {
|
7860
|
-
if (!
|
7832
|
+
if (!canSkipDiagnosticForNode(errorNode) && !isTypeIncomplete) {
|
7861
7833
|
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.typeVarTupleMustBeUnpacked(), (_a = argParam.argument.valueExpression) !== null && _a !== void 0 ? _a : errorNode);
|
7862
7834
|
}
|
7863
7835
|
reportedArgError = true;
|
@@ -8636,7 +8608,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
8636
8608
|
// printing types if the diagnostic is disabled.
|
8637
8609
|
const fileInfo = AnalyzerNodeInfo.getFileInfo(argParam.errorNode);
|
8638
8610
|
if (fileInfo.diagnosticRuleSet.reportArgumentType !== 'none' &&
|
8639
|
-
!
|
8611
|
+
!canSkipDiagnosticForNode(argParam.errorNode) &&
|
8640
8612
|
!isTypeIncomplete) {
|
8641
8613
|
const argTypeText = printType(argType);
|
8642
8614
|
const paramTypeText = printType(argParam.paramType);
|
@@ -10178,9 +10150,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
10178
10150
|
}
|
10179
10151
|
}, {
|
10180
10152
|
dependentType: inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.expectedType,
|
10181
|
-
allowDiagnostics: !forceSpeculative &&
|
10182
|
-
!isDiagnosticSuppressedForNode(node) &&
|
10183
|
-
!(inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.isTypeIncomplete),
|
10153
|
+
allowDiagnostics: !forceSpeculative && !canSkipDiagnosticForNode(node) && !(inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.isTypeIncomplete),
|
10184
10154
|
});
|
10185
10155
|
// Mark the function type as no longer being evaluated.
|
10186
10156
|
functionType.details.flags &= ~131072 /* FunctionTypeFlags.PartiallyEvaluated */;
|
@@ -14234,7 +14204,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
14234
14204
|
}
|
14235
14205
|
}
|
14236
14206
|
// Allocate a new code flow analyzer.
|
14237
|
-
const analyzer = codeFlowEngine.createCodeFlowAnalyzer(
|
14207
|
+
const analyzer = codeFlowEngine.createCodeFlowAnalyzer();
|
14238
14208
|
if (entries) {
|
14239
14209
|
entries.push({ typeAtStart, codeFlowAnalyzer: analyzer });
|
14240
14210
|
}
|
@@ -14327,6 +14297,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
14327
14297
|
0) {
|
14328
14298
|
addError(localize_1.LocMessage.protocolNotAllowed(), errorNode);
|
14329
14299
|
}
|
14300
|
+
typeArgs === null || typeArgs === void 0 ? void 0 : typeArgs.forEach((typeArg) => {
|
14301
|
+
if (typeArg.typeList || !(0, types_1.isTypeVar)(typeArg.type)) {
|
14302
|
+
addError(localize_1.LocMessage.protocolTypeArgMustBeTypeParam(), typeArg.node);
|
14303
|
+
}
|
14304
|
+
});
|
14330
14305
|
return {
|
14331
14306
|
type: createSpecialType(classType, typeArgs,
|
14332
14307
|
/* paramLimit */ undefined,
|
@@ -14445,18 +14420,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
14445
14420
|
if (firstDefaultParamIndex >= 0) {
|
14446
14421
|
minTypeArgCount = firstDefaultParamIndex;
|
14447
14422
|
}
|
14448
|
-
|
14449
|
-
if (typeArgs[0].inlinedTypeDict) {
|
14450
|
-
if (typeArgs.length > 1) {
|
14451
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeArguments, localize_1.LocMessage.typeArgsTooMany().format({
|
14452
|
-
name: classType.aliasName || classType.details.name,
|
14453
|
-
expected: 1,
|
14454
|
-
received: typeArgCount,
|
14455
|
-
}), typeArgs[1].node);
|
14456
|
-
}
|
14457
|
-
return { type: typeArgs[0].inlinedTypeDict };
|
14458
|
-
}
|
14459
|
-
else if (typeArgCount > typeParameters.length) {
|
14423
|
+
if (typeArgCount > typeParameters.length) {
|
14460
14424
|
if (!types_1.ClassType.isPartiallyEvaluated(classType) && !types_1.ClassType.isTupleClass(classType)) {
|
14461
14425
|
if (typeParameters.length === 0) {
|
14462
14426
|
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeArguments, localize_1.LocMessage.typeArgsExpectingNone().format({
|
@@ -14839,11 +14803,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
14839
14803
|
return symbolWithScope;
|
14840
14804
|
}
|
14841
14805
|
// Disables recording of errors and warnings.
|
14842
|
-
function suppressDiagnostics(node, callback) {
|
14843
|
-
suppressedNodeStack.push(node);
|
14806
|
+
function suppressDiagnostics(node, callback, diagCallback) {
|
14807
|
+
suppressedNodeStack.push({ node, suppressedDiags: diagCallback ? [] : undefined });
|
14844
14808
|
try {
|
14845
14809
|
const result = callback();
|
14846
|
-
suppressedNodeStack.pop();
|
14810
|
+
const poppedNode = suppressedNodeStack.pop();
|
14811
|
+
if (diagCallback && (poppedNode === null || poppedNode === void 0 ? void 0 : poppedNode.suppressedDiags)) {
|
14812
|
+
diagCallback(poppedNode.suppressedDiags);
|
14813
|
+
}
|
14847
14814
|
return result;
|
14848
14815
|
}
|
14849
14816
|
catch (e) {
|
@@ -16090,7 +16057,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16090
16057
|
const prevTypeCache = returnTypeInferenceTypeCache;
|
16091
16058
|
returnTypeInferenceContextStack.push({
|
16092
16059
|
functionNode,
|
16093
|
-
codeFlowAnalyzer: codeFlowEngine.createCodeFlowAnalyzer(
|
16060
|
+
codeFlowAnalyzer: codeFlowEngine.createCodeFlowAnalyzer(),
|
16094
16061
|
});
|
16095
16062
|
try {
|
16096
16063
|
returnTypeInferenceTypeCache = new Map();
|
@@ -16503,6 +16470,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16503
16470
|
while (destTypeArgs.length > srcTypeArgs.length && destTypeArgs[destTypeArgs.length - 1].isOptional) {
|
16504
16471
|
destTypeArgs.splice(destTypeArgs.length - 1, 1);
|
16505
16472
|
}
|
16473
|
+
const srcArgsToCapture = srcTypeArgs.length - destTypeArgs.length + 1;
|
16474
|
+
let skipAdjustSrc = false;
|
16506
16475
|
// If we're doing reverse type mappings and the source contains a variadic
|
16507
16476
|
// TypeVar, we need to adjust the dest so the reverse type mapping assignment
|
16508
16477
|
// can be performed.
|
@@ -16528,10 +16497,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16528
16497
|
isUnbounded: false,
|
16529
16498
|
});
|
16530
16499
|
}
|
16500
|
+
skipAdjustSrc = true;
|
16531
16501
|
}
|
16532
16502
|
}
|
16533
16503
|
else {
|
16534
|
-
const srcArgsToCapture = srcTypeArgs.length - destTypeArgs.length + 1;
|
16535
16504
|
if (destUnboundedOrVariadicIndex >= 0 && srcArgsToCapture >= 0) {
|
16536
16505
|
// If the dest contains a variadic element, determine which source
|
16537
16506
|
// args map to this element and package them up into an unpacked tuple.
|
@@ -16560,30 +16529,27 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
|
|
16560
16529
|
isUnbounded: false,
|
16561
16530
|
});
|
16562
16531
|
}
|
16532
|
+
skipAdjustSrc = true;
|
16563
16533
|
}
|
16564
|
-
|
16565
|
-
|
16566
|
-
|
16567
|
-
|
16568
|
-
|
16569
|
-
|
16570
|
-
|
16571
|
-
|
16572
|
-
|
16573
|
-
|
16574
|
-
|
16575
|
-
|
16576
|
-
!t.type.isVariadicInUnion) {
|
16577
|
-
return types_1.TypeVarType.cloneForUnpacked(t.type, /* isInUnion */ true);
|
16578
|
-
}
|
16579
|
-
return t.type;
|
16580
|
-
});
|
16581
|
-
srcTypeArgs.splice(destUnboundedOrVariadicIndex, 0, {
|
16582
|
-
type: removedArgTypes.length > 0 ? (0, types_1.combineTypes)(removedArgTypes) : types_1.AnyType.create(),
|
16583
|
-
isUnbounded: false,
|
16584
|
-
});
|
16534
|
+
}
|
16535
|
+
}
|
16536
|
+
if (!skipAdjustSrc && destUnboundedOrVariadicIndex >= 0 && srcArgsToCapture >= 0) {
|
16537
|
+
// If possible, package up the source entries that correspond to
|
16538
|
+
// the dest unbounded tuple. This isn't possible if the source contains
|
16539
|
+
// an unbounded tuple outside of this range.
|
16540
|
+
if (srcUnboundedIndex < 0 ||
|
16541
|
+
(srcUnboundedIndex >= destUnboundedOrVariadicIndex &&
|
16542
|
+
srcUnboundedIndex < destUnboundedOrVariadicIndex + srcArgsToCapture)) {
|
16543
|
+
const removedArgTypes = srcTypeArgs.splice(destUnboundedOrVariadicIndex, srcArgsToCapture).map((t) => {
|
16544
|
+
if ((0, types_1.isTypeVar)(t.type) && (0, types_1.isUnpackedVariadicTypeVar)(t.type) && !t.type.isVariadicInUnion) {
|
16545
|
+
return types_1.TypeVarType.cloneForUnpacked(t.type, /* isInUnion */ true);
|
16585
16546
|
}
|
16586
|
-
|
16547
|
+
return t.type;
|
16548
|
+
});
|
16549
|
+
srcTypeArgs.splice(destUnboundedOrVariadicIndex, 0, {
|
16550
|
+
type: removedArgTypes.length > 0 ? (0, types_1.combineTypes)(removedArgTypes) : types_1.AnyType.create(),
|
16551
|
+
isUnbounded: false,
|
16552
|
+
});
|
16587
16553
|
}
|
16588
16554
|
}
|
16589
16555
|
return destTypeArgs.length === srcTypeArgs.length;
|