@zzzen/pyright-internal 1.2.0-dev.20240121 → 1.2.0-dev.20240128
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/binder.js +2 -2
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.js +24 -24
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/constructorTransform.js +8 -8
- package/dist/analyzer/constructorTransform.js.map +1 -1
- package/dist/analyzer/constructors.js +1 -1
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/dataClasses.js +1 -1
- package/dist/analyzer/dataClasses.js.map +1 -1
- package/dist/analyzer/decorators.js +1 -1
- package/dist/analyzer/decorators.js.map +1 -1
- package/dist/analyzer/enums.js +0 -10
- package/dist/analyzer/enums.js.map +1 -1
- package/dist/analyzer/namedTuples.js +4 -4
- package/dist/analyzer/namedTuples.js.map +1 -1
- package/dist/analyzer/operations.js +8 -8
- package/dist/analyzer/operations.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +79 -74
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeUtils.js +7 -6
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typedDicts.js +5 -5
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/common/configOptions.d.ts +16 -0
- package/dist/common/configOptions.js +80 -0
- package/dist/common/configOptions.js.map +1 -1
- package/dist/common/diagnosticRules.d.ts +16 -0
- package/dist/common/diagnosticRules.js +16 -0
- package/dist/common/diagnosticRules.js.map +1 -1
- package/dist/localization/localize.d.ts +0 -1
- package/dist/localization/localize.js +0 -1
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.en-us.json +0 -1
- package/dist/tests/typeEvaluator1.test.js +3 -3
- package/dist/tests/typeEvaluator3.test.js +1 -1
- package/dist/tests/typeEvaluator4.test.js +1 -1
- package/package.json +1 -1
@@ -2188,7 +2188,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
2188
2188
|
if (expectedTypeDiagAddendum) {
|
2189
2189
|
diagAddendum = expectedTypeDiagAddendum;
|
2190
2190
|
}
|
2191
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
2191
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportAssignmentType, localize_1.LocMessage.typeAssignmentMismatch().format(printSrcDestTypes(type, declaredType)) +
|
2192
2192
|
diagAddendum.getString(), srcExpression !== null && srcExpression !== void 0 ? srcExpression : nameNode, (_c = (_b = diagAddendum.getEffectiveTextRange()) !== null && _b !== void 0 ? _b : srcExpression) !== null && _c !== void 0 ? _c : nameNode);
|
2193
2193
|
// Replace the assigned type with the (unnarrowed) declared type.
|
2194
2194
|
destType = declaredType;
|
@@ -2441,7 +2441,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
2441
2441
|
}
|
2442
2442
|
});
|
2443
2443
|
if (!diagAddendum.isEmpty()) {
|
2444
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
2444
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportAssignmentType, (target.nodeType === 31 /* ParseNodeType.List */
|
2445
2445
|
? localize_1.LocMessage.listAssignmentMismatch()
|
2446
2446
|
: localize_1.LocMessage.tupleAssignmentMismatch()).format({
|
2447
2447
|
type: printType(type),
|
@@ -3018,7 +3018,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
3018
3018
|
if (effectiveTypeInfo.includesIllegalTypeAliasDecl ||
|
3019
3019
|
!types_1.TypeBase.isInstantiable(type) ||
|
3020
3020
|
(flags & 2 /* EvaluatorFlags.DoNotSpecialize */) !== 0) {
|
3021
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
3021
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeForm, localize_1.LocMessage.typeAnnotationVariable(), node);
|
3022
3022
|
type = types_1.UnknownType.create();
|
3023
3023
|
}
|
3024
3024
|
}
|
@@ -3655,7 +3655,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
3655
3655
|
}
|
3656
3656
|
if (!type) {
|
3657
3657
|
if (!isIncomplete) {
|
3658
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
3658
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportAttributeAccessIssue, localize_1.LocMessage.moduleUnknownMember().format({
|
3659
3659
|
memberName,
|
3660
3660
|
moduleName: baseType.moduleName,
|
3661
3661
|
}), node.memberName);
|
@@ -3741,7 +3741,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
3741
3741
|
}
|
3742
3742
|
const rule = isFunctionRule
|
3743
3743
|
? diagnosticRules_1.DiagnosticRule.reportFunctionMemberAccess
|
3744
|
-
: diagnosticRules_1.DiagnosticRule.
|
3744
|
+
: diagnosticRules_1.DiagnosticRule.reportAttributeAccessIssue;
|
3745
3745
|
addDiagnostic(rule, diagMessage.format({ name: memberName, type: printType(baseType) }) + diag.getString(), node.memberName, (_a = diag.getEffectiveTextRange()) !== null && _a !== void 0 ? _a : node.memberName);
|
3746
3746
|
}
|
3747
3747
|
// If this is member access on a function, use "Any" so if the
|
@@ -4732,7 +4732,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
4732
4732
|
const itemMethodType = getBoundMagicMethod(concreteSubtype, getIndexAccessMagicMethodName(usage));
|
4733
4733
|
if ((flags & 256 /* EvaluatorFlags.ExpectingTypeAnnotation */) !== 0) {
|
4734
4734
|
// If the class doesn't derive from Generic, a type argument should not be allowed.
|
4735
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
4735
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeArguments, localize_1.LocMessage.typeArgsExpectingNone().format({
|
4736
4736
|
name: printType(types_1.ClassType.cloneAsInstance(concreteSubtype)),
|
4737
4737
|
}), node);
|
4738
4738
|
}
|
@@ -4800,7 +4800,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
4800
4800
|
return concreteSubtype;
|
4801
4801
|
}
|
4802
4802
|
if (concreteSubtype.typeArguments) {
|
4803
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
4803
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeArguments, localize_1.LocMessage.classAlreadySpecialized().format({
|
4804
4804
|
type: printType((0, typeUtils_1.convertToInstance)(concreteSubtype), { expandTypeAlias: true }),
|
4805
4805
|
}), node.baseExpression);
|
4806
4806
|
return concreteSubtype;
|
@@ -4837,7 +4837,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
4837
4837
|
return types_1.UnknownType.create();
|
4838
4838
|
}
|
4839
4839
|
if (!isIncomplete) {
|
4840
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
4840
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportIndexIssue, localize_1.LocMessage.typeNotSubscriptable().format({ type: printType(concreteSubtype) }), node.baseExpression);
|
4841
4841
|
}
|
4842
4842
|
return types_1.UnknownType.create();
|
4843
4843
|
});
|
@@ -4968,7 +4968,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
4968
4968
|
const magicMethodName = getIndexAccessMagicMethodName(usage);
|
4969
4969
|
const itemMethodType = getBoundMagicMethod(baseType, magicMethodName, selfType);
|
4970
4970
|
if (!itemMethodType) {
|
4971
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
4971
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportIndexIssue, localize_1.LocMessage.methodNotDefinedOnType().format({
|
4972
4972
|
name: magicMethodName,
|
4973
4973
|
type: printType(baseType),
|
4974
4974
|
}), node.baseExpression);
|
@@ -5324,7 +5324,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
5324
5324
|
// a zero-length tuple.
|
5325
5325
|
const diag = new diagnostic_1.DiagnosticAddendum();
|
5326
5326
|
diag.addMessage(localize_1.LocAddendum.useTupleInstead());
|
5327
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
5327
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeForm, localize_1.LocMessage.tupleInAnnotation() + diag.getString(), node);
|
5328
5328
|
return { type: types_1.UnknownType.create() };
|
5329
5329
|
}
|
5330
5330
|
if ((flags & 128 /* EvaluatorFlags.ExpectingInstantiableType */) !== 0 &&
|
@@ -5493,7 +5493,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
5493
5493
|
node.leftExpression.value === 'type') {
|
5494
5494
|
const diag = new diagnostic_1.DiagnosticAddendum();
|
5495
5495
|
diag.addMessage(localize_1.LocAddendum.useTypeInstead());
|
5496
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
5496
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeForm, localize_1.LocMessage.typeCallNotAllowed() + diag.getString(), node);
|
5497
5497
|
}
|
5498
5498
|
// Handle immediate calls of lambdas specially.
|
5499
5499
|
if (node.leftExpression.nodeType === 30 /* ParseNodeType.Lambda */) {
|
@@ -5593,7 +5593,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
5593
5593
|
}
|
5594
5594
|
}
|
5595
5595
|
if ((flags & 256 /* EvaluatorFlags.ExpectingTypeAnnotation */) !== 0) {
|
5596
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
5596
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeForm, localize_1.LocMessage.typeAnnotationCall(), node);
|
5597
5597
|
typeResult = { type: types_1.UnknownType.create() };
|
5598
5598
|
}
|
5599
5599
|
return typeResult;
|
@@ -5662,7 +5662,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
5662
5662
|
const assertedType = (0, typeUtils_1.convertToInstance)(getTypeOfArgumentExpectingType(node.arguments[1]).type);
|
5663
5663
|
if (!(0, types_1.isTypeSame)(assertedType, arg0TypeResult.type, { treatAnySameAsUnknown: true, ignorePseudoGeneric: true })) {
|
5664
5664
|
const srcDestTypes = printSrcDestTypes(arg0TypeResult.type, assertedType, { expandTypeAlias: true });
|
5665
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
5665
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportAssertTypeFailure, localize_1.LocMessage.assertTypeTypeMismatch().format({
|
5666
5666
|
expected: srcDestTypes.destType,
|
5667
5667
|
received: srcDestTypes.sourceType,
|
5668
5668
|
}), node.arguments[0].valueExpression);
|
@@ -5777,7 +5777,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
5777
5777
|
targetClassType = getTypeOfExpression(node.arguments[0].valueExpression).type;
|
5778
5778
|
const concreteTargetClassType = makeTopLevelTypeVarsConcrete(targetClassType);
|
5779
5779
|
if (!(0, types_1.isAnyOrUnknown)(concreteTargetClassType) && !(0, types_1.isInstantiableClass)(concreteTargetClassType)) {
|
5780
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
5780
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportArgumentType, localize_1.LocMessage.superCallFirstArg().format({ type: printType(targetClassType) }), node.arguments[0].valueExpression);
|
5781
5781
|
}
|
5782
5782
|
}
|
5783
5783
|
else {
|
@@ -5829,7 +5829,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
5829
5829
|
reportError = true;
|
5830
5830
|
}
|
5831
5831
|
if (reportError) {
|
5832
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
5832
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportArgumentType, localize_1.LocMessage.superCallSecondArg().format({ type: printType(targetClassType) }), node.arguments[1].valueExpression);
|
5833
5833
|
return { type: types_1.UnknownType.create() };
|
5834
5834
|
}
|
5835
5835
|
}
|
@@ -6264,7 +6264,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
6264
6264
|
return typeString;
|
6265
6265
|
});
|
6266
6266
|
diagAddendum.addMessage(localize_1.LocAddendum.argumentTypes().format({ types: argTypes.join(', ') }));
|
6267
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
6267
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.noOverload().format({ name: functionName }) + diagAddendum.getString(), errorNode);
|
6268
6268
|
}
|
6269
6269
|
return { argumentErrors: true, isTypeIncomplete, overloadsUsedForCall: [] };
|
6270
6270
|
}
|
@@ -6284,7 +6284,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
6284
6284
|
// was possible and emit a diagnostic that provides the most likely.
|
6285
6285
|
if (emitNoOverloadFoundError) {
|
6286
6286
|
const functionName = bestMatch.overload.details.name || '<anonymous function>';
|
6287
|
-
const diagnostic = addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
6287
|
+
const diagnostic = addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.noOverload().format({ name: functionName }), errorNode);
|
6288
6288
|
const overrideDecl = bestMatch.overload.details.declaration;
|
6289
6289
|
if (diagnostic && overrideDecl) {
|
6290
6290
|
diagnostic.addRelatedInfo(localize_1.LocAddendum.overloadIndex().format({ index: bestMatch.overloadIndex + 1 }), overrideDecl.uri, overrideDecl.range);
|
@@ -6415,7 +6415,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
6415
6415
|
// Special forms are not callable.
|
6416
6416
|
if (callTypeResult.type.specialForm) {
|
6417
6417
|
const exprNode = errorNode.nodeType === 9 /* ParseNodeType.Call */ ? errorNode.leftExpression : errorNode;
|
6418
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
6418
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.objectNotCallable().format({
|
6419
6419
|
type: printType(callTypeResult.type, { expandTypeAlias: true }),
|
6420
6420
|
}), exprNode);
|
6421
6421
|
return { returnType: types_1.UnknownType.create(), argumentErrors: true, overloadsUsedForCall };
|
@@ -6495,7 +6495,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
6495
6495
|
return validateCallArguments(errorNode, argList, { type: (0, typeUtils_1.transformPossibleRecursiveTypeAlias)(expandedCallType), isIncomplete: isCallTypeIncomplete }, typeVarContext, skipUnknownArgCheck, inferenceContext, recursionCount);
|
6496
6496
|
}
|
6497
6497
|
case 7 /* TypeCategory.Module */: {
|
6498
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
6498
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.moduleNotCallable(), errorNode);
|
6499
6499
|
return { argumentErrors: true };
|
6500
6500
|
}
|
6501
6501
|
}
|
@@ -6504,7 +6504,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
6504
6504
|
function validateCallForFunction(errorNode, argList, expandedCallType, isCallTypeIncomplete, typeVarContext, skipUnknownArgCheck, inferenceContext) {
|
6505
6505
|
var _a;
|
6506
6506
|
if (types_1.TypeBase.isInstantiable(expandedCallType)) {
|
6507
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
6507
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.callableNotInstantiable().format({
|
6508
6508
|
type: printType(expandedCallType),
|
6509
6509
|
}), errorNode);
|
6510
6510
|
return { returnType: undefined, argumentErrors: true };
|
@@ -6671,7 +6671,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
6671
6671
|
function validateCallForInstantiableClass(errorNode, argList, expandedCallType, unexpandedCallType, skipUnknownArgCheck, inferenceContext) {
|
6672
6672
|
var _a, _b;
|
6673
6673
|
if (expandedCallType.literalValue !== undefined) {
|
6674
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
6674
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.literalNotCallable(), errorNode);
|
6675
6675
|
return { returnType: types_1.UnknownType.create(), argumentErrors: true };
|
6676
6676
|
}
|
6677
6677
|
if (types_1.ClassType.isBuiltIn(expandedCallType)) {
|
@@ -6679,7 +6679,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
6679
6679
|
// Handle a call to a metaclass explicitly.
|
6680
6680
|
if ((0, typeUtils_1.isInstantiableMetaclass)(expandedCallType)) {
|
6681
6681
|
if (expandedCallType.typeArguments && expandedCallType.isTypeArgumentExplicit) {
|
6682
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
6682
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.objectNotCallable().format({
|
6683
6683
|
type: printType(expandedCallType),
|
6684
6684
|
}), errorNode);
|
6685
6685
|
return { returnType: types_1.UnknownType.create(), argumentErrors: true };
|
@@ -6751,7 +6751,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
6751
6751
|
return { returnType: createNewType(errorNode, argList) };
|
6752
6752
|
}
|
6753
6753
|
if (types_1.ClassType.isSpecialFormClass(expandedCallType)) {
|
6754
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
6754
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.typeNotIntantiable().format({ type: className }), errorNode);
|
6755
6755
|
return { returnType: types_1.UnknownType.create(), argumentErrors: true };
|
6756
6756
|
}
|
6757
6757
|
if (className === 'TypedDict') {
|
@@ -6793,14 +6793,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
6793
6793
|
}
|
6794
6794
|
}
|
6795
6795
|
});
|
6796
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
6796
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportAbstractUsage, localize_1.LocMessage.instantiateAbstract().format({
|
6797
6797
|
type: expandedCallType.details.name,
|
6798
6798
|
}) + diagAddendum.getString(), errorNode);
|
6799
6799
|
}
|
6800
6800
|
}
|
6801
6801
|
if (types_1.ClassType.isProtocolClass(expandedCallType) && !expandedCallType.includeSubclasses) {
|
6802
6802
|
// If the class is a protocol, it can't be instantiated.
|
6803
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
6803
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportAbstractUsage, localize_1.LocMessage.instantiateProtocol().format({
|
6804
6804
|
type: expandedCallType.details.name,
|
6805
6805
|
}), errorNode);
|
6806
6806
|
}
|
@@ -6848,7 +6848,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
6848
6848
|
/* selfType */ undefined, recursionCount);
|
6849
6849
|
const callMethodType = callMethodResult === null || callMethodResult === void 0 ? void 0 : callMethodResult.type;
|
6850
6850
|
if (!callMethodType) {
|
6851
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
6851
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.objectNotCallable().format({
|
6852
6852
|
type: printType(expandedCallType),
|
6853
6853
|
}), errorNode);
|
6854
6854
|
return { returnType: types_1.UnknownType.create(), argumentErrors: true };
|
@@ -7049,7 +7049,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
7049
7049
|
if (argIndex < positionalOnlyLimitIndex && argList[argIndex].name) {
|
7050
7050
|
const nameNode = argList[argIndex].name;
|
7051
7051
|
if (nameNode) {
|
7052
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
7052
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.argPositional(), nameNode);
|
7053
7053
|
reportedArgError = true;
|
7054
7054
|
}
|
7055
7055
|
}
|
@@ -7083,7 +7083,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
7083
7083
|
}
|
7084
7084
|
if (tooManyPositionals) {
|
7085
7085
|
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
7086
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
7086
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, positionParamLimitIndex === 1
|
7087
7087
|
? localize_1.LocMessage.argPositionalExpectedOne()
|
7088
7088
|
: localize_1.LocMessage.argPositionalExpectedCount().format({
|
7089
7089
|
expected: positionParamLimitIndex,
|
@@ -7116,7 +7116,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
7116
7116
|
argTypeResult.type.paramSpecAccess === 'args' &&
|
7117
7117
|
paramDetails.params[paramIndex].param.category !== 1 /* ParameterCategory.ArgsList */) {
|
7118
7118
|
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
7119
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
7119
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, positionParamLimitIndex === 1
|
7120
7120
|
? localize_1.LocMessage.argPositionalExpectedOne()
|
7121
7121
|
: localize_1.LocMessage.argPositionalExpectedCount().format({
|
7122
7122
|
expected: positionParamLimitIndex,
|
@@ -7183,7 +7183,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
7183
7183
|
// parameter unless the argument is a variadic arg as well.
|
7184
7184
|
if (isParamVariadic && !isArgCompatibleWithVariadic) {
|
7185
7185
|
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
7186
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
7186
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.unpackedArgWithVariadicParam(), argList[argIndex].valueExpression || errorNode);
|
7187
7187
|
}
|
7188
7188
|
reportedArgError = true;
|
7189
7189
|
}
|
@@ -7241,7 +7241,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
7241
7241
|
if (remainingArgCount < remainingParamCount) {
|
7242
7242
|
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
7243
7243
|
// Have we run out of arguments and still have parameters left to fill?
|
7244
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
7244
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, remainingArgCount === 1
|
7245
7245
|
? localize_1.LocMessage.argMorePositionalExpectedOne()
|
7246
7246
|
: localize_1.LocMessage.argMorePositionalExpectedCount().format({
|
7247
7247
|
expected: remainingArgCount,
|
@@ -7323,7 +7323,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
7323
7323
|
}
|
7324
7324
|
if (argsRemainingCount > 0) {
|
7325
7325
|
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
7326
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
7326
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, argsRemainingCount === 1
|
7327
7327
|
? localize_1.LocMessage.argMorePositionalExpectedOne()
|
7328
7328
|
: localize_1.LocMessage.argMorePositionalExpectedCount().format({
|
7329
7329
|
expected: argsRemainingCount,
|
@@ -7405,7 +7405,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
7405
7405
|
});
|
7406
7406
|
if (!diag.isEmpty()) {
|
7407
7407
|
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
7408
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
7408
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.unpackedTypedDictArgument() + diag.getString(), argList[argIndex].valueExpression || errorNode);
|
7409
7409
|
}
|
7410
7410
|
reportedArgError = true;
|
7411
7411
|
}
|
@@ -7466,7 +7466,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
7466
7466
|
}
|
7467
7467
|
if (!isValidMappingType) {
|
7468
7468
|
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
7469
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
7469
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.unpackedDictArgumentNotMapping(), argList[argIndex].valueExpression || errorNode);
|
7470
7470
|
}
|
7471
7471
|
reportedArgError = true;
|
7472
7472
|
}
|
@@ -7487,7 +7487,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
7487
7487
|
if (paramEntry && !paramEntry.isPositionalOnly) {
|
7488
7488
|
if (paramEntry.argsReceived > 0) {
|
7489
7489
|
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
7490
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
7490
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.paramAlreadyAssigned().format({ name: paramNameValue }), paramName);
|
7491
7491
|
}
|
7492
7492
|
reportedArgError = true;
|
7493
7493
|
}
|
@@ -7531,7 +7531,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
7531
7531
|
}
|
7532
7532
|
else {
|
7533
7533
|
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
7534
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
7534
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.paramNameMissing().format({ name: paramName.value }), paramName);
|
7535
7535
|
}
|
7536
7536
|
reportedArgError = true;
|
7537
7537
|
}
|
@@ -7542,7 +7542,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
7542
7542
|
}
|
7543
7543
|
else {
|
7544
7544
|
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
7545
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
7545
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, positionParamLimitIndex === 1
|
7546
7546
|
? localize_1.LocMessage.argPositionalExpectedOne()
|
7547
7547
|
: localize_1.LocMessage.argPositionalExpectedCount().format({
|
7548
7548
|
expected: positionParamLimitIndex,
|
@@ -7619,7 +7619,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
7619
7619
|
if (!isDiagnosticSuppressedForNode(errorNode)) {
|
7620
7620
|
const missingParamNames = unassignedParams.map((p) => `"${p}"`).join(', ');
|
7621
7621
|
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
7622
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
7622
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, unassignedParams.length === 1
|
7623
7623
|
? localize_1.LocMessage.argMissingForParam().format({ name: missingParamNames })
|
7624
7624
|
: localize_1.LocMessage.argMissingForParams().format({ names: missingParamNames }), errorNode);
|
7625
7625
|
}
|
@@ -7689,7 +7689,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
7689
7689
|
argParam.argument.argumentCategory !== 1 /* ArgumentCategory.UnpackedList */ &&
|
7690
7690
|
!argParam.mapsToVarArgList) {
|
7691
7691
|
if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
|
7692
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
7692
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.typeVarTupleMustBeUnpacked(), (_a = argParam.argument.valueExpression) !== null && _a !== void 0 ? _a : errorNode);
|
7693
7693
|
}
|
7694
7694
|
reportedArgError = true;
|
7695
7695
|
}
|
@@ -7867,7 +7867,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
7867
7867
|
if (type.boundToType && !type.boundToType.includeSubclasses && type.details.methodClass) {
|
7868
7868
|
const abstractSymbolInfo = getAbstractSymbolInfo(type.details.methodClass, type.details.name);
|
7869
7869
|
if (abstractSymbolInfo && !abstractSymbolInfo.hasImplementation) {
|
7870
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
7870
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportAbstractUsage, localize_1.LocMessage.abstractMethodInvocation().format({
|
7871
7871
|
method: type.details.name,
|
7872
7872
|
}), errorNode.nodeType === 9 /* ParseNodeType.Call */ ? errorNode.leftExpression : errorNode);
|
7873
7873
|
}
|
@@ -8021,7 +8021,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
8021
8021
|
else if (type.details.paramSpec) {
|
8022
8022
|
if (!sawParamSpecArgs || !sawParamSpecKwargs) {
|
8023
8023
|
if (!isTypeIncomplete) {
|
8024
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
8024
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.paramSpecArgsMissing().format({ type: printType(type.details.paramSpec) }), errorNode);
|
8025
8025
|
}
|
8026
8026
|
argumentErrors = true;
|
8027
8027
|
argumentMatchScore += 1;
|
@@ -8291,7 +8291,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
8291
8291
|
argumentErrors = true;
|
8292
8292
|
}
|
8293
8293
|
if (argumentErrors) {
|
8294
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
8294
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.paramSpecArgsMissing().format({
|
8295
8295
|
type: printType(functionType.details.paramSpec),
|
8296
8296
|
}), argErrorNode !== null && argErrorNode !== void 0 ? argErrorNode : errorNode);
|
8297
8297
|
}
|
@@ -8356,8 +8356,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
8356
8356
|
? 512 /* EvaluatorFlags.AllowMissingTypeArgs */ |
|
8357
8357
|
8 /* EvaluatorFlags.EvaluateStringLiteralAsType */ |
|
8358
8358
|
32 /* EvaluatorFlags.DisallowParamSpec */ |
|
8359
|
-
64 /* EvaluatorFlags.DisallowTypeVarTuple */
|
8360
|
-
|
8359
|
+
64 /* EvaluatorFlags.DisallowTypeVarTuple */ |
|
8360
|
+
16 /* EvaluatorFlags.DisallowFinal */
|
8361
|
+
: 2 /* EvaluatorFlags.DoNotSpecialize */ | 16 /* EvaluatorFlags.DisallowFinal */;
|
8361
8362
|
const exprTypeResult = getTypeOfExpression(argParam.argument.valueExpression, flags, (0, typeUtils_1.makeInferenceContext)(expectedType, !!(typeResult === null || typeResult === void 0 ? void 0 : typeResult.isIncomplete), signatureTracker));
|
8362
8363
|
argType = exprTypeResult.type;
|
8363
8364
|
// If the type includes multiple instances of a generic function
|
@@ -8484,7 +8485,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
8484
8485
|
// Mismatching parameter types are common in untyped code; don't bother spending time
|
8485
8486
|
// printing types if the diagnostic is disabled.
|
8486
8487
|
const fileInfo = AnalyzerNodeInfo.getFileInfo(argParam.errorNode);
|
8487
|
-
if (fileInfo.diagnosticRuleSet.
|
8488
|
+
if (fileInfo.diagnosticRuleSet.reportArgumentType !== 'none' &&
|
8488
8489
|
!isDiagnosticSuppressedForNode(argParam.errorNode) &&
|
8489
8490
|
!isTypeIncomplete) {
|
8490
8491
|
const argTypeText = printType(argType);
|
@@ -8528,7 +8529,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
8528
8529
|
if (expectedTypeDiag) {
|
8529
8530
|
diag = expectedTypeDiag;
|
8530
8531
|
}
|
8531
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
8532
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportArgumentType, message + diag.getString(), argParam.errorNode, (_a = diag.getEffectiveTextRange()) !== null && _a !== void 0 ? _a : argParam.errorNode);
|
8532
8533
|
}
|
8533
8534
|
return { isCompatible: false, argType, isTypeIncomplete, skippedBareTypeVarExpectedType, condition };
|
8534
8535
|
}
|
@@ -8966,7 +8967,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
8966
8967
|
const fileInfo = AnalyzerNodeInfo.getFileInfo(errorNode);
|
8967
8968
|
let className = '';
|
8968
8969
|
if (argList.length !== 2) {
|
8969
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
8970
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.newTypeParamCount(), errorNode);
|
8970
8971
|
return undefined;
|
8971
8972
|
}
|
8972
8973
|
const nameArg = argList[0];
|
@@ -8976,7 +8977,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
8976
8977
|
className = nameArg.valueExpression.strings.map((s) => s.value).join('');
|
8977
8978
|
}
|
8978
8979
|
if (!className) {
|
8979
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
8980
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportArgumentType, localize_1.LocMessage.newTypeBadName(), (_a = argList[0].node) !== null && _a !== void 0 ? _a : errorNode);
|
8980
8981
|
return undefined;
|
8981
8982
|
}
|
8982
8983
|
if (((_b = errorNode.parent) === null || _b === void 0 ? void 0 : _b.nodeType) === 3 /* ParseNodeType.Assignment */ &&
|
@@ -9166,7 +9167,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
9166
9167
|
((_a = node.parent) === null || _a === void 0 ? void 0 : _a.nodeType) !== 1 /* ParseNodeType.Argument */) {
|
9167
9168
|
const diag = new diagnostic_1.DiagnosticAddendum();
|
9168
9169
|
diag.addMessage(localize_1.LocAddendum.useDictInstead());
|
9169
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
9170
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeForm, localize_1.LocMessage.dictInAnnotation() + diag.getString(), node);
|
9170
9171
|
}
|
9171
9172
|
// If the expected type is a union, analyze for each of the subtypes
|
9172
9173
|
// to find one that matches.
|
@@ -9489,7 +9490,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
9489
9490
|
((_a = node.parent) === null || _a === void 0 ? void 0 : _a.nodeType) !== 1 /* ParseNodeType.Argument */) {
|
9490
9491
|
const diag = new diagnostic_1.DiagnosticAddendum();
|
9491
9492
|
diag.addMessage(localize_1.LocAddendum.useListInstead());
|
9492
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
9493
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeForm, localize_1.LocMessage.listInAnnotation() + diag.getString(), node);
|
9493
9494
|
}
|
9494
9495
|
// If the expected type is a union, recursively call for each of the subtypes
|
9495
9496
|
// to find one that matches.
|
@@ -10159,6 +10160,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
10159
10160
|
sawUnpacked = true;
|
10160
10161
|
};
|
10161
10162
|
typeList.forEach((entry, index) => {
|
10163
|
+
var _a;
|
10162
10164
|
let entryType = entry.type;
|
10163
10165
|
let paramCategory = 0 /* ParameterCategory.Simple */;
|
10164
10166
|
const paramName = `__p${index.toString()}`;
|
@@ -10170,7 +10172,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
10170
10172
|
else if (validateTypeArg(entry, { allowUnpackedTuples: true })) {
|
10171
10173
|
if ((0, types_1.isUnpackedClass)(entryType)) {
|
10172
10174
|
paramCategory = 1 /* ParameterCategory.ArgsList */;
|
10173
|
-
|
10175
|
+
if ((_a = entryType.tupleTypeArguments) === null || _a === void 0 ? void 0 : _a.some((typeArg) => (0, types_1.isVariadicTypeVar)(typeArg.type) || typeArg.isUnbounded)) {
|
10176
|
+
noteSawUnpacked(entry);
|
10177
|
+
}
|
10174
10178
|
}
|
10175
10179
|
}
|
10176
10180
|
else {
|
@@ -10273,7 +10277,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
10273
10277
|
}
|
10274
10278
|
let optionalType = (0, types_1.combineTypes)([typeArg0Type, noneClassType !== null && noneClassType !== void 0 ? noneClassType : types_1.UnknownType.create()]);
|
10275
10279
|
if (unionClassType && (0, types_1.isInstantiableClass)(unionClassType)) {
|
10276
|
-
optionalType = types_1.TypeBase.cloneAsSpecialForm(optionalType, unionClassType);
|
10280
|
+
optionalType = types_1.TypeBase.cloneAsSpecialForm(optionalType, types_1.ClassType.cloneAsInstance(unionClassType));
|
10277
10281
|
}
|
10278
10282
|
return optionalType;
|
10279
10283
|
}
|
@@ -10434,7 +10438,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
10434
10438
|
var _a;
|
10435
10439
|
// Self doesn't support any type arguments.
|
10436
10440
|
if (typeArgs) {
|
10437
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
10441
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeArguments, localize_1.LocMessage.typeArgsExpectingNone().format({
|
10438
10442
|
name: classType.details.name,
|
10439
10443
|
}), (_a = typeArgs[0].node) !== null && _a !== void 0 ? _a : errorNode);
|
10440
10444
|
}
|
@@ -10582,7 +10586,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
10582
10586
|
function createFinalType(classType, errorNode, typeArgs, flags) {
|
10583
10587
|
if (flags & 16 /* EvaluatorFlags.DisallowFinal */) {
|
10584
10588
|
addError(localize_1.LocMessage.finalContext(), errorNode);
|
10585
|
-
return
|
10589
|
+
return classType;
|
10586
10590
|
}
|
10587
10591
|
if (!typeArgs || typeArgs.length === 0) {
|
10588
10592
|
return classType;
|
@@ -10590,7 +10594,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
10590
10594
|
if (typeArgs.length > 1) {
|
10591
10595
|
addError(localize_1.LocMessage.finalTooManyArgs(), errorNode);
|
10592
10596
|
}
|
10593
|
-
return typeArgs[0].type;
|
10597
|
+
return types_1.TypeBase.cloneAsSpecialForm(typeArgs[0].type, classType);
|
10594
10598
|
}
|
10595
10599
|
function createConcatenateType(classType, errorNode, typeArgs, flags) {
|
10596
10600
|
if ((flags & 134217728 /* EvaluatorFlags.AllowConcatenate */) === 0) {
|
@@ -10662,6 +10666,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
10662
10666
|
let reportedUnpackedError = false;
|
10663
10667
|
// Verify that we didn't receive any inappropriate types.
|
10664
10668
|
typeArgs.forEach((typeArg, index) => {
|
10669
|
+
var _a;
|
10665
10670
|
(0, debug_1.assert)(typeArgs !== undefined);
|
10666
10671
|
if ((0, typeUtils_1.isEllipsisType)(typeArg.type)) {
|
10667
10672
|
if (!isTupleTypeParam) {
|
@@ -10673,12 +10678,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
10673
10678
|
addError(localize_1.LocMessage.ellipsisSecondArg(), typeArg.node);
|
10674
10679
|
}
|
10675
10680
|
else {
|
10676
|
-
if ((0, types_1.
|
10677
|
-
(0, types_1.isVariadicTypeVar)(typeArgs[0].type) &&
|
10678
|
-
!typeArgs[0].type.isVariadicInUnion) {
|
10681
|
+
if ((0, types_1.isVariadicTypeVar)(typeArgs[0].type) && !typeArgs[0].type.isVariadicInUnion) {
|
10679
10682
|
addError(localize_1.LocMessage.typeVarTupleContext(), typeArgs[0].node);
|
10680
10683
|
}
|
10681
|
-
else if (
|
10684
|
+
else if ((0, types_1.isUnpackedClass)(typeArgs[0].type)) {
|
10682
10685
|
addError(localize_1.LocMessage.ellipsisAfterUnpacked(), typeArg.node);
|
10683
10686
|
}
|
10684
10687
|
}
|
@@ -10686,14 +10689,16 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
10686
10689
|
else if ((0, types_1.isParamSpec)(typeArg.type) && allowParamSpec) {
|
10687
10690
|
// Nothing to do - this is allowed.
|
10688
10691
|
}
|
10689
|
-
else if ((0, types_1.isVariadicTypeVar)(typeArg.type)
|
10692
|
+
else if (paramLimit === undefined && (0, types_1.isVariadicTypeVar)(typeArg.type)) {
|
10690
10693
|
if (!typeArg.type.isVariadicInUnion) {
|
10691
10694
|
noteSawUnpacked(typeArg);
|
10692
10695
|
}
|
10693
10696
|
validateVariadicTypeVarIsUnpacked(typeArg.type, typeArg.node);
|
10694
10697
|
}
|
10695
|
-
else if (paramLimit === undefined && (0, types_1.
|
10696
|
-
|
10698
|
+
else if (paramLimit === undefined && (0, types_1.isUnpackedClass)(typeArg.type)) {
|
10699
|
+
if ((_a = typeArg.type.tupleTypeArguments) === null || _a === void 0 ? void 0 : _a.some((typeArg) => (0, types_1.isVariadicTypeVar)(typeArg.type) || typeArg.isUnbounded)) {
|
10700
|
+
noteSawUnpacked(typeArg);
|
10701
|
+
}
|
10697
10702
|
validateTypeArg(typeArg, { allowUnpackedTuples: true });
|
10698
10703
|
}
|
10699
10704
|
else {
|
@@ -10810,11 +10815,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
10810
10815
|
// is allowed if it's an unpacked variadic type var or tuple. None is also allowed
|
10811
10816
|
// since it is used to define NoReturn in typeshed stubs).
|
10812
10817
|
if (types.length === 1 && !allowSingleTypeArg && !(0, typeUtils_1.isNoneInstance)(types[0])) {
|
10813
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
10818
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeArguments, localize_1.LocMessage.unionTypeArgCount(), errorNode);
|
10814
10819
|
}
|
10815
10820
|
let unionType = (0, types_1.combineTypes)(types);
|
10816
10821
|
if (unionClassType && (0, types_1.isInstantiableClass)(unionClassType)) {
|
10817
|
-
unionType = types_1.TypeBase.cloneAsSpecialForm(unionType, unionClassType);
|
10822
|
+
unionType = types_1.TypeBase.cloneAsSpecialForm(unionType, types_1.ClassType.cloneAsInstance(unionClassType));
|
10818
10823
|
}
|
10819
10824
|
return unionType;
|
10820
10825
|
}
|
@@ -11114,7 +11119,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
11114
11119
|
if (isDeclaredTypeAlias(node.leftExpression)) {
|
11115
11120
|
typeAliasNameNode = node.leftExpression.valueExpression;
|
11116
11121
|
if (!isLegalTypeAliasExpressionForm(node.rightExpression)) {
|
11117
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
11122
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeForm, localize_1.LocMessage.typeAliasIllegalExpressionForm(), node.rightExpression);
|
11118
11123
|
}
|
11119
11124
|
}
|
11120
11125
|
else if (node.leftExpression.nodeType === 38 /* ParseNodeType.Name */) {
|
@@ -12435,7 +12440,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
12435
12440
|
}
|
12436
12441
|
}
|
12437
12442
|
if (!assignType(annotatedType, defaultValueType, diagAddendum, typeVarContext)) {
|
12438
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
12443
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportArgumentType, localize_1.LocMessage.paramAssignmentMismatch().format({
|
12439
12444
|
sourceType: printType(defaultValueType),
|
12440
12445
|
paramType: printType(annotatedType),
|
12441
12446
|
}) + diagAddendum.getString(), param.defaultValue);
|
@@ -13225,7 +13230,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
13225
13230
|
reportError = true;
|
13226
13231
|
}
|
13227
13232
|
if (reportError) {
|
13228
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
13233
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportAttributeAccessIssue, localize_1.LocMessage.importSymbolUnknown().format({ name: node.name.value }), node.name);
|
13229
13234
|
}
|
13230
13235
|
}
|
13231
13236
|
if (!symbolType) {
|
@@ -13306,7 +13311,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
13306
13311
|
}
|
13307
13312
|
const diagAddendum = new diagnostic_1.DiagnosticAddendum();
|
13308
13313
|
if (!assignType(declaredType, importedSymbolType, diagAddendum)) {
|
13309
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
13314
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportAssignmentType, localize_1.LocMessage.typeAssignmentMismatchWildcard().format({
|
13310
13315
|
...printSrcDestTypes(importedSymbolType, declaredType),
|
13311
13316
|
name,
|
13312
13317
|
}) + diagAddendum.getString(), node, (_b = node.wildcardToken) !== null && _b !== void 0 ? _b : node);
|
@@ -14008,7 +14013,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
14008
14013
|
if (typeArgs.length >= 1) {
|
14009
14014
|
// Treat type[function] as illegal.
|
14010
14015
|
if ((0, types_1.isFunction)(typeArgs[0].type) || (0, types_1.isOverloadedFunction)(typeArgs[0].type)) {
|
14011
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
14016
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeForm, localize_1.LocMessage.typeAnnotationWithCallable(), typeArgs[0].node);
|
14012
14017
|
return { type: types_1.UnknownType.create() };
|
14013
14018
|
}
|
14014
14019
|
}
|
@@ -14051,7 +14056,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
14051
14056
|
// Classes that accept inlined type dict type args allow only one.
|
14052
14057
|
if (typeArgs[0].inlinedTypeDict) {
|
14053
14058
|
if (typeArgs.length > 1) {
|
14054
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
14059
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeArguments, localize_1.LocMessage.typeArgsTooMany().format({
|
14055
14060
|
name: classType.aliasName || classType.details.name,
|
14056
14061
|
expected: 1,
|
14057
14062
|
received: typeArgCount,
|
@@ -14062,12 +14067,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
14062
14067
|
else if (typeArgCount > typeParameters.length) {
|
14063
14068
|
if (!types_1.ClassType.isPartiallyEvaluated(classType) && !types_1.ClassType.isTupleClass(classType)) {
|
14064
14069
|
if (typeParameters.length === 0) {
|
14065
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
14070
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeArguments, localize_1.LocMessage.typeArgsExpectingNone().format({
|
14066
14071
|
name: classType.aliasName || classType.details.name,
|
14067
14072
|
}), typeArgs[typeParameters.length].node);
|
14068
14073
|
}
|
14069
14074
|
else if (typeParameters.length !== 1 || !(0, types_1.isParamSpec)(typeParameters[0])) {
|
14070
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
14075
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeArguments, localize_1.LocMessage.typeArgsTooMany().format({
|
14071
14076
|
name: classType.aliasName || classType.details.name,
|
14072
14077
|
expected: typeParameters.length,
|
14073
14078
|
received: typeArgCount,
|
@@ -14077,7 +14082,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
14077
14082
|
}
|
14078
14083
|
}
|
14079
14084
|
else if (typeArgCount < minTypeArgCount) {
|
14080
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
14085
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeArguments, localize_1.LocMessage.typeArgsTooFew().format({
|
14081
14086
|
name: classType.aliasName || classType.details.name,
|
14082
14087
|
expected: minTypeArgCount,
|
14083
14088
|
received: typeArgCount,
|
@@ -14232,7 +14237,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
14232
14237
|
// Avoid emitting this error for a partially-constructed class.
|
14233
14238
|
if (!(0, types_1.isClassInstance)(typeArgType) || !types_1.ClassType.isPartiallyEvaluated(typeArgType)) {
|
14234
14239
|
(0, debug_1.assert)(typeArgs !== undefined);
|
14235
|
-
addDiagnostic(diagnosticRules_1.DiagnosticRule.
|
14240
|
+
addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeArguments, localize_1.LocMessage.typeVarAssignmentMismatch().format({
|
14236
14241
|
type: printType(typeArgType),
|
14237
14242
|
name: types_1.TypeVarType.getReadableName(typeParameters[index]),
|
14238
14243
|
}) + diag.getString(), typeArgs[index].node);
|