@zzzen/pyright-internal 1.2.0-dev.20220807 → 1.2.0-dev.20220828
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 +9 -6
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.js +2 -1
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.js +9 -2
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/docStringConversion.js +8 -7
- package/dist/analyzer/docStringConversion.js.map +1 -1
- package/dist/analyzer/importResolver.js +2 -2
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/importResult.d.ts +2 -1
- package/dist/analyzer/packageTypeVerifier.js +26 -13
- package/dist/analyzer/packageTypeVerifier.js.map +1 -1
- package/dist/analyzer/program.d.ts +5 -1
- package/dist/analyzer/program.js +27 -3
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/service.d.ts +4 -1
- package/dist/analyzer/service.js +2 -1
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/typeEvaluator.js +82 -45
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +8 -0
- package/dist/analyzer/typeEvaluatorWithTracker.js +1 -0
- package/dist/analyzer/typeEvaluatorWithTracker.js.map +1 -1
- package/dist/analyzer/typeGuards.js +38 -9
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typeUtils.js +99 -58
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typedDicts.d.ts +3 -3
- package/dist/analyzer/typedDicts.js +9 -5
- package/dist/analyzer/typedDicts.js.map +1 -1
- package/dist/analyzer/types.js +8 -7
- package/dist/analyzer/types.js.map +1 -1
- package/dist/common/diagnostic.d.ts +5 -1
- package/dist/common/diagnostic.js +34 -0
- package/dist/common/diagnostic.js.map +1 -1
- package/dist/languageServerBase.d.ts +6 -5
- package/dist/languageServerBase.js +27 -17
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/analyzerServiceExecutor.js +4 -2
- package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
- package/dist/languageService/codeActionProvider.js +1 -1
- package/dist/languageService/codeActionProvider.js.map +1 -1
- package/dist/languageService/completionProvider.js +3 -48
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/hoverProvider.js +5 -8
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/languageService/signatureHelpProvider.js +3 -3
- package/dist/languageService/signatureHelpProvider.js.map +1 -1
- package/dist/languageService/tooltipUtils.d.ts +3 -2
- package/dist/languageService/tooltipUtils.js +30 -15
- package/dist/languageService/tooltipUtils.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.en-us.json +2 -1
- package/dist/parser/parser.js +16 -6
- package/dist/parser/parser.js.map +1 -1
- package/dist/pyright.js +3 -0
- package/dist/pyright.js.map +1 -1
- package/dist/server.js +3 -3
- package/dist/server.js.map +1 -1
- package/dist/tests/checker.test.js +1 -1
- package/dist/tests/docStringConversion.test.js +21 -21
- package/dist/tests/fourslash/completions.variableDocStrings.fourslash.js +15 -2
- package/dist/tests/fourslash/completions.variableDocStrings.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docstring.links.fourslash.js +1 -1
- package/dist/tests/fourslash/hover.docstring.links.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.variable.docString.fourslash.js +12 -7
- package/dist/tests/fourslash/hover.variable.docString.fourslash.js.map +1 -1
- package/dist/tests/harness/fourslash/testLanguageService.js +4 -2
- package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.d.ts +8 -2
- package/dist/tests/harness/fourslash/testState.js +49 -41
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/typeEvaluator2.test.js +8 -0
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +1 -1
- package/dist/tests/typeEvaluator4.test.js +2 -2
- package/dist/workspaceMap.js +18 -15
- package/dist/workspaceMap.js.map +1 -1
- package/package.json +1 -1
@@ -180,7 +180,11 @@ const maxReturnTypeInferenceArgumentCount = 6;
|
|
180
180
|
// we will analyze to determine the return type of a function
|
181
181
|
// when its parameters are unannotated? We want to keep this
|
182
182
|
// pretty low because this can be very costly.
|
183
|
-
const maxReturnTypeInferenceCodeFlowComplexity =
|
183
|
+
const maxReturnTypeInferenceCodeFlowComplexity = 32;
|
184
|
+
// What is the max complexity of the code flow graph for
|
185
|
+
// call-site type inference? This is very expensive, so we
|
186
|
+
// want to keep this very low.
|
187
|
+
const maxReturnCallSiteTypeInferenceCodeFlowComplexity = 8;
|
184
188
|
// What is the max number of return types cached per function
|
185
189
|
// when using call-site inference?
|
186
190
|
const maxCallSiteReturnTypeCacheSize = 8;
|
@@ -1884,11 +1888,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
1884
1888
|
return (suppressedNodeStack.some((suppressedNode) => ParseTreeUtils.isNodeContainedWithin(node, suppressedNode)) ||
|
1885
1889
|
speculativeTypeTracker.isSpeculative(node));
|
1886
1890
|
}
|
1887
|
-
function addDiagnostic(diagLevel, rule, message, node) {
|
1891
|
+
function addDiagnostic(diagLevel, rule, message, node, range) {
|
1888
1892
|
if (diagLevel === 'none') {
|
1889
1893
|
return undefined;
|
1890
1894
|
}
|
1891
|
-
const diagnostic = addDiagnosticWithSuppressionCheck(diagLevel, message, node);
|
1895
|
+
const diagnostic = addDiagnosticWithSuppressionCheck(diagLevel, message, node, range);
|
1892
1896
|
if (diagnostic) {
|
1893
1897
|
diagnostic.setRule(rule);
|
1894
1898
|
}
|
@@ -1917,6 +1921,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
1917
1921
|
addDiagnostic(fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.typeExpectedClass().format({ type: printType(type) }) + diag.getString(), node);
|
1918
1922
|
}
|
1919
1923
|
function assignTypeToNameNode(nameNode, type, isTypeIncomplete, ignoreEmptyContainers, srcExpression, allowAssignmentToFinalVar = false, expectedTypeDiagAddendum) {
|
1924
|
+
var _a, _b;
|
1920
1925
|
const nameValue = nameNode.value;
|
1921
1926
|
const symbolWithScope = lookUpSymbolRecursive(nameNode, nameValue, /* honorCodeFlow */ false);
|
1922
1927
|
if (!symbolWithScope) {
|
@@ -1954,7 +1959,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
1954
1959
|
addDiagnostic(fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.typeAssignmentMismatch().format({
|
1955
1960
|
sourceType: printType(type),
|
1956
1961
|
destType: printType(declaredType),
|
1957
|
-
}) + diagAddendum.getString(), srcExpression !== null && srcExpression !== void 0 ? srcExpression : nameNode);
|
1962
|
+
}) + diagAddendum.getString(), srcExpression !== null && srcExpression !== void 0 ? srcExpression : nameNode, (_b = (_a = diagAddendum.getEffectiveTextRange()) !== null && _a !== void 0 ? _a : srcExpression) !== null && _b !== void 0 ? _b : nameNode);
|
1958
1963
|
// Replace the assigned type with the (unnarrowed) declared type.
|
1959
1964
|
destType = declaredType;
|
1960
1965
|
}
|
@@ -2856,7 +2861,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
2856
2861
|
// cannot be used in this location.
|
2857
2862
|
function validateTypeVarUsage(node, type, flags) {
|
2858
2863
|
var _a;
|
2859
|
-
if (types_1.TypeBase.isInstantiable(type) && !(0, typeUtils_1.isTypeAliasPlaceholder)(type)) {
|
2864
|
+
if (types_1.TypeBase.isInstantiable(type) && !type.scopeId && !(0, typeUtils_1.isTypeAliasPlaceholder)(type)) {
|
2860
2865
|
const scopedTypeVarInfo = findScopedTypeVar(node, type);
|
2861
2866
|
type = scopedTypeVarInfo.type;
|
2862
2867
|
if ((flags & 2048 /* DisallowTypeVarsWithScopeId */) !== 0 && type.scopeId !== undefined) {
|
@@ -3145,7 +3150,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
3145
3150
|
return typeResult;
|
3146
3151
|
}
|
3147
3152
|
function getTypeOfMemberAccessWithBaseType(node, baseTypeResult, usage, flags) {
|
3148
|
-
var _a;
|
3153
|
+
var _a, _b;
|
3149
3154
|
let baseType = baseTypeResult.type;
|
3150
3155
|
const memberName = node.memberName.value;
|
3151
3156
|
let diag = new diagnostic_1.DiagnosticAddendum();
|
@@ -3239,12 +3244,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
3239
3244
|
}
|
3240
3245
|
}
|
3241
3246
|
else {
|
3242
|
-
// Handle the special case of LiteralString.
|
3243
|
-
if (types_1.ClassType.isBuiltIn(baseType, 'LiteralString') &&
|
3244
|
-
strClassType &&
|
3245
|
-
(0, types_1.isInstantiableClass)(strClassType)) {
|
3246
|
-
baseType = types_1.ClassType.cloneAsInstance(strClassType);
|
3247
|
-
}
|
3248
3247
|
// Handle the special case of 'name' and 'value' members within an enum.
|
3249
3248
|
const enumMemberResult = (0, enums_1.getTypeOfEnumMember)(evaluatorInterface, node, baseType, memberName, isIncomplete);
|
3250
3249
|
if (enumMemberResult) {
|
@@ -3421,7 +3420,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
3421
3420
|
const [ruleSet, rule] = isFunctionRule
|
3422
3421
|
? [fileInfo.diagnosticRuleSet.reportFunctionMemberAccess, diagnosticRules_1.DiagnosticRule.reportFunctionMemberAccess]
|
3423
3422
|
: [fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues];
|
3424
|
-
addDiagnostic(ruleSet, rule, diagMessage.format({ name: memberName, type: printType(baseType) }) + diag.getString(), node.memberName);
|
3423
|
+
addDiagnostic(ruleSet, rule, diagMessage.format({ name: memberName, type: printType(baseType) }) + diag.getString(), node.memberName, (_a = diag.getEffectiveTextRange()) !== null && _a !== void 0 ? _a : node.memberName);
|
3425
3424
|
}
|
3426
3425
|
// If this is member access on a function, use "Any" so if the
|
3427
3426
|
// reportFunctionMemberAccess rule is disabled, we don't trigger
|
@@ -3442,7 +3441,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
3442
3441
|
// It can also come up in cases like "isinstance(x, (list, dict))".
|
3443
3442
|
if ((0, types_1.isInstantiableClass)(type)) {
|
3444
3443
|
const argNode = ParseTreeUtils.getParentNodeOfType(node, 1 /* Argument */);
|
3445
|
-
if (argNode && ((
|
3444
|
+
if (argNode && ((_b = argNode === null || argNode === void 0 ? void 0 : argNode.parent) === null || _b === void 0 ? void 0 : _b.nodeType) === 9 /* Call */) {
|
3446
3445
|
skipPartialUnknownCheck = true;
|
3447
3446
|
}
|
3448
3447
|
}
|
@@ -5442,7 +5441,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
5442
5441
|
// Is this a union type? If so, we can expand it.
|
5443
5442
|
const argType = contextFreeArgTypes[indexToExpand];
|
5444
5443
|
if ((0, types_1.isUnion)(argType)) {
|
5445
|
-
unionToExpand = argType;
|
5444
|
+
unionToExpand = makeTopLevelTypeVarsConcrete(argType);
|
5445
|
+
break;
|
5446
|
+
}
|
5447
|
+
else if ((0, types_1.isTypeVar)(argType) && argType.details.constraints.length > 1) {
|
5448
|
+
unionToExpand = makeTopLevelTypeVarsConcrete(argType);
|
5446
5449
|
break;
|
5447
5450
|
}
|
5448
5451
|
indexToExpand++;
|
@@ -7209,6 +7212,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
7209
7212
|
return !reportedArgError;
|
7210
7213
|
}
|
7211
7214
|
function validateArgType(argParam, typeVarContext, functionType, skipUnknownCheck, skipOverloadArg, useNarrowBoundOnly, conditionFilter) {
|
7215
|
+
var _a;
|
7212
7216
|
let argType;
|
7213
7217
|
let expectedTypeDiag;
|
7214
7218
|
let isTypeIncomplete = false;
|
@@ -7382,7 +7386,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
7382
7386
|
if (expectedTypeDiag) {
|
7383
7387
|
diag = expectedTypeDiag;
|
7384
7388
|
}
|
7385
|
-
addDiagnostic(fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, message + diag.getString(), argParam.errorNode);
|
7389
|
+
addDiagnostic(fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, message + diag.getString(), argParam.errorNode, (_a = diag.getEffectiveTextRange()) !== null && _a !== void 0 ? _a : argParam.errorNode);
|
7386
7390
|
}
|
7387
7391
|
return { isCompatible: false, argType, isTypeIncomplete, condition };
|
7388
7392
|
}
|
@@ -7678,7 +7682,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
7678
7682
|
/* declaredMetaclass */ undefined, arg1Type.details.effectiveMetaclass);
|
7679
7683
|
arg1Type.tupleTypeArguments.forEach((typeArg) => {
|
7680
7684
|
const specializedType = makeTopLevelTypeVarsConcrete(typeArg.type);
|
7681
|
-
if ((0, types_1.isInstantiableClass)(specializedType) ||
|
7685
|
+
if ((0, types_1.isInstantiableClass)(specializedType) ||
|
7686
|
+
(0, types_1.isAnyOrUnknown)(specializedType) ||
|
7687
|
+
((0, types_1.isClassInstance)(specializedType) && types_1.ClassType.isBuiltIn(specializedType, 'type'))) {
|
7682
7688
|
classType.details.baseClasses.push(specializedType);
|
7683
7689
|
}
|
7684
7690
|
else {
|
@@ -8350,12 +8356,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
8350
8356
|
if ((0, types_1.isAnyOrUnknown)(subtype)) {
|
8351
8357
|
return subtype;
|
8352
8358
|
}
|
8353
|
-
if ((0, types_1.isClassInstance)(subtype) &&
|
8354
|
-
types_1.ClassType.isBuiltIn(subtype, 'LiteralString') &&
|
8355
|
-
strClassType &&
|
8356
|
-
(0, types_1.isInstantiableClass)(strClassType)) {
|
8357
|
-
return handleSubtype(types_1.ClassType.cloneAsInstance(strClassType));
|
8358
|
-
}
|
8359
8359
|
if ((0, types_1.isClassInstance)(subtype) || (0, types_1.isInstantiableClass)(subtype) || (0, types_1.isTypeVar)(subtype)) {
|
8360
8360
|
return handleSubtype(subtype);
|
8361
8361
|
}
|
@@ -8441,7 +8441,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
8441
8441
|
isIncomplete = true;
|
8442
8442
|
}
|
8443
8443
|
if (types_1.ClassType.isTypedDictClass(expectedType)) {
|
8444
|
-
const resultTypedDict = (0, typedDicts_1.assignToTypedDict)(evaluatorInterface, expectedType, keyTypes, valueTypes,
|
8444
|
+
const resultTypedDict = (0, typedDicts_1.assignToTypedDict)(evaluatorInterface, expectedType, keyTypes, valueTypes,
|
8445
|
+
// Don't overwrite existing expectedDiagAddendum messages if they were
|
8446
|
+
// already provided by getKeyValueTypesFromDictionary.
|
8447
|
+
(expectedDiagAddendum === null || expectedDiagAddendum === void 0 ? void 0 : expectedDiagAddendum.isEmpty()) ? expectedDiagAddendum : undefined);
|
8445
8448
|
if (resultTypedDict) {
|
8446
8449
|
return {
|
8447
8450
|
type: resultTypedDict,
|
@@ -8475,8 +8478,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
8475
8478
|
// and Iterable use covariant value types, so they can be narrowed.
|
8476
8479
|
const isValueTypeInvariant = (0, types_1.isClassInstance)(expectedType) &&
|
8477
8480
|
(types_1.ClassType.isBuiltIn(expectedType, 'dict') || types_1.ClassType.isBuiltIn(expectedType, 'MutableMapping'));
|
8478
|
-
const specializedKeyType = inferTypeArgFromExpectedType(expectedKeyType, keyTypes
|
8479
|
-
|
8481
|
+
const specializedKeyType = inferTypeArgFromExpectedType(expectedKeyType, keyTypes.map((result) => result.type),
|
8482
|
+
/* isNarrowable */ false);
|
8483
|
+
const specializedValueType = inferTypeArgFromExpectedType(expectedValueType, valueTypes.map((result) => result.type),
|
8480
8484
|
/* isNarrowable */ !isValueTypeInvariant);
|
8481
8485
|
if (!specializedKeyType || !specializedValueType) {
|
8482
8486
|
return undefined;
|
@@ -8490,17 +8494,18 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
8490
8494
|
const fallbackType = hasExpectedType ? types_1.AnyType.create() : types_1.UnknownType.create();
|
8491
8495
|
let keyType = fallbackType;
|
8492
8496
|
let valueType = fallbackType;
|
8493
|
-
|
8494
|
-
|
8497
|
+
const keyTypeResults = [];
|
8498
|
+
const valueTypeResults = [];
|
8495
8499
|
let isEmptyContainer = false;
|
8496
8500
|
let isIncomplete = false;
|
8497
8501
|
// Infer the key and value types if possible.
|
8498
|
-
if (getKeyAndValueTypesFromDictionary(node,
|
8502
|
+
if (getKeyAndValueTypesFromDictionary(node, keyTypeResults, valueTypeResults,
|
8503
|
+
/* forceStrictInference */ hasExpectedType)) {
|
8499
8504
|
isIncomplete = true;
|
8500
8505
|
}
|
8501
8506
|
// Strip any literal values.
|
8502
|
-
keyTypes =
|
8503
|
-
valueTypes =
|
8507
|
+
const keyTypes = keyTypeResults.map((t) => stripLiteralValue(t.type));
|
8508
|
+
const valueTypes = valueTypeResults.map((t) => stripLiteralValue(t.type));
|
8504
8509
|
keyType = keyTypes.length > 0 ? (0, types_1.combineTypes)(keyTypes) : fallbackType;
|
8505
8510
|
// If the value type differs and we're not using "strict inference mode",
|
8506
8511
|
// we need to back off because we can't properly represent the mappings
|
@@ -8562,8 +8567,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
8562
8567
|
isIncomplete = true;
|
8563
8568
|
}
|
8564
8569
|
if (forceStrictInference || index < maxEntriesToUseForInference) {
|
8565
|
-
keyTypes.push(keyType);
|
8566
|
-
valueTypes.push(valueType);
|
8570
|
+
keyTypes.push({ node: entryNode.keyExpression, type: keyType });
|
8571
|
+
valueTypes.push({ node: entryNode.valueExpression, type: valueType });
|
8567
8572
|
}
|
8568
8573
|
addUnknown = false;
|
8569
8574
|
}
|
@@ -8576,6 +8581,21 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
8576
8581
|
if ((0, types_1.isAnyOrUnknown)(unexpandedType)) {
|
8577
8582
|
addUnknown = false;
|
8578
8583
|
}
|
8584
|
+
else if ((0, types_1.isClassInstance)(unexpandedType) && types_1.ClassType.isTypedDictClass(unexpandedType)) {
|
8585
|
+
// Handle dictionary expansion for a TypedDict.
|
8586
|
+
if (strClassType && (0, types_1.isInstantiableClass)(strClassType)) {
|
8587
|
+
const strObject = types_1.ClassType.cloneAsInstance(strClassType);
|
8588
|
+
const tdEntries = (0, typedDicts_1.getTypedDictMembersForClass)(evaluatorInterface, unexpandedType,
|
8589
|
+
/* allowNarrowed */ true);
|
8590
|
+
tdEntries.forEach((entry, name) => {
|
8591
|
+
if (entry.isRequired || entry.isProvided) {
|
8592
|
+
keyTypes.push({ node: entryNode, type: types_1.ClassType.cloneWithLiteral(strObject, name) });
|
8593
|
+
valueTypes.push({ node: entryNode, type: entry.valueType });
|
8594
|
+
}
|
8595
|
+
});
|
8596
|
+
addUnknown = false;
|
8597
|
+
}
|
8598
|
+
}
|
8579
8599
|
else {
|
8580
8600
|
// Verify that the type supports the `keys` and `__getitem__` methods.
|
8581
8601
|
// This protocol is defined in the _typeshed stub. If we can't find
|
@@ -8595,8 +8615,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
8595
8615
|
const typeArgs = specializedMapping.typeArguments;
|
8596
8616
|
if (typeArgs && typeArgs.length >= 2) {
|
8597
8617
|
if (forceStrictInference || index < maxEntriesToUseForInference) {
|
8598
|
-
keyTypes.push(typeArgs[0]);
|
8599
|
-
valueTypes.push(typeArgs[1]);
|
8618
|
+
keyTypes.push({ node: entryNode, type: typeArgs[0] });
|
8619
|
+
valueTypes.push({ node: entryNode, type: typeArgs[1] });
|
8600
8620
|
}
|
8601
8621
|
addUnknown = false;
|
8602
8622
|
}
|
@@ -8619,8 +8639,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
8619
8639
|
const typeArgs = (_a = dictEntryType.tupleTypeArguments) === null || _a === void 0 ? void 0 : _a.map((t) => t.type);
|
8620
8640
|
if (typeArgs && typeArgs.length === 2) {
|
8621
8641
|
if (forceStrictInference || index < maxEntriesToUseForInference) {
|
8622
|
-
keyTypes.push(typeArgs[0]);
|
8623
|
-
valueTypes.push(typeArgs[1]);
|
8642
|
+
keyTypes.push({ node: entryNode, type: typeArgs[0] });
|
8643
|
+
valueTypes.push({ node: entryNode, type: typeArgs[1] });
|
8624
8644
|
}
|
8625
8645
|
addUnknown = false;
|
8626
8646
|
}
|
@@ -8628,8 +8648,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
8628
8648
|
}
|
8629
8649
|
if (addUnknown) {
|
8630
8650
|
if (forceStrictInference || index < maxEntriesToUseForInference) {
|
8631
|
-
keyTypes.push(types_1.UnknownType.create());
|
8632
|
-
valueTypes.push(types_1.UnknownType.create());
|
8651
|
+
keyTypes.push({ node: entryNode, type: types_1.UnknownType.create() });
|
8652
|
+
valueTypes.push({ node: entryNode, type: types_1.UnknownType.create() });
|
8633
8653
|
}
|
8634
8654
|
}
|
8635
8655
|
});
|
@@ -10002,6 +10022,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
10002
10022
|
return cachedType;
|
10003
10023
|
}
|
10004
10024
|
const specialType = createSpecialBuiltInClass(node, assignedName, aliasMapEntry);
|
10025
|
+
// Handle 'LiteralString' specially because we want it to act as
|
10026
|
+
// though it derives from 'str'.
|
10027
|
+
if (assignedName === 'LiteralString') {
|
10028
|
+
specialType.details.baseClasses.push(strClassType !== null && strClassType !== void 0 ? strClassType : types_1.AnyType.create());
|
10029
|
+
(0, typeUtils_1.computeMroLinearization)(specialType);
|
10030
|
+
}
|
10005
10031
|
writeTypeCache(node, specialType, 0 /* None */, /* isIncomplete */ false);
|
10006
10032
|
return specialType;
|
10007
10033
|
}
|
@@ -14261,7 +14287,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
14261
14287
|
}
|
14262
14288
|
const functionNode = type.details.declaration.node;
|
14263
14289
|
const codeFlowComplexity = AnalyzerNodeInfo.getCodeFlowComplexity(functionNode);
|
14264
|
-
if (codeFlowComplexity >=
|
14290
|
+
if (codeFlowComplexity >= maxReturnCallSiteTypeInferenceCodeFlowComplexity) {
|
14265
14291
|
return undefined;
|
14266
14292
|
}
|
14267
14293
|
// If an arg hasn't been matched to a specific named parameter,
|
@@ -15375,11 +15401,21 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
15375
15401
|
// For all remaining source subtypes, attempt to find a dest subtype
|
15376
15402
|
// whose primary type matches.
|
15377
15403
|
if (!isIncompatible) {
|
15378
|
-
|
15379
|
-
const destTypeIndex = remainingDestSubtypes.findIndex((destSubtype) =>
|
15380
|
-
(0, types_1.isClass)(
|
15381
|
-
|
15382
|
-
|
15404
|
+
(0, typeUtils_1.sortTypes)(remainingSrcSubtypes).forEach((srcSubtype) => {
|
15405
|
+
const destTypeIndex = remainingDestSubtypes.findIndex((destSubtype) => {
|
15406
|
+
if ((0, types_1.isClass)(srcSubtype) &&
|
15407
|
+
(0, types_1.isClass)(destSubtype) &&
|
15408
|
+
types_1.TypeBase.isInstance(srcSubtype) === types_1.TypeBase.isInstance(destSubtype) &&
|
15409
|
+
types_1.ClassType.isSameGenericClass(srcSubtype, destSubtype)) {
|
15410
|
+
return true;
|
15411
|
+
}
|
15412
|
+
if ((0, types_1.isFunction)(srcSubtype) || (0, types_1.isOverloadedFunction)(srcSubtype)) {
|
15413
|
+
if ((0, types_1.isFunction)(destSubtype) || (0, types_1.isOverloadedFunction)(destSubtype)) {
|
15414
|
+
return true;
|
15415
|
+
}
|
15416
|
+
}
|
15417
|
+
return false;
|
15418
|
+
});
|
15383
15419
|
if (destTypeIndex >= 0) {
|
15384
15420
|
if (!assignType(remainingDestSubtypes[destTypeIndex], srcSubtype, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), destTypeVarContext, srcTypeVarContext, flags, recursionCount)) {
|
15385
15421
|
isIncompatible = true;
|
@@ -17023,6 +17059,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
17023
17059
|
removeFalsinessFromType,
|
17024
17060
|
verifyRaiseExceptionType,
|
17025
17061
|
verifyDeleteExpression,
|
17062
|
+
validateOverloadedFunctionArguments,
|
17026
17063
|
isAfterNodeReachable,
|
17027
17064
|
isNodeReachable,
|
17028
17065
|
isAsymmetricDescriptorAssignment,
|