@zzzen/pyright-internal 1.2.0-dev.20221204 → 1.2.0-dev.20221211
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/aliasDeclarationUtils.js +23 -9
- package/dist/analyzer/aliasDeclarationUtils.js.map +1 -1
- package/dist/analyzer/analyzerFileInfo.d.ts +1 -0
- package/dist/analyzer/analyzerFileInfo.js.map +1 -1
- package/dist/analyzer/backgroundAnalysisProgram.d.ts +1 -0
- package/dist/analyzer/backgroundAnalysisProgram.js +3 -0
- package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
- package/dist/analyzer/binder.js +2 -2
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.js +16 -7
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/importResolver.js +2 -2
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/program.d.ts +1 -0
- package/dist/analyzer/program.js +14 -2
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/service.js +8 -4
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/typeDocStringUtils.d.ts +2 -0
- package/dist/analyzer/typeDocStringUtils.js +14 -13
- package/dist/analyzer/typeDocStringUtils.js.map +1 -1
- package/dist/analyzer/typeEvaluator.d.ts +0 -1
- package/dist/analyzer/typeEvaluator.js +100 -41
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +1 -1
- package/dist/analyzer/typeUtils.js +2 -1
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/types.d.ts +1 -1
- package/dist/analyzer/types.js +17 -4
- package/dist/analyzer/types.js.map +1 -1
- package/dist/backgroundAnalysisBase.d.ts +1 -1
- package/dist/common/commandLineOptions.d.ts +1 -1
- package/dist/common/commandLineOptions.js +0 -2
- package/dist/common/commandLineOptions.js.map +1 -1
- package/dist/common/configOptions.d.ts +1 -1
- package/dist/common/configOptions.js +4 -3
- package/dist/common/configOptions.js.map +1 -1
- package/dist/common/diagnosticRules.d.ts +1 -0
- package/dist/common/diagnosticRules.js +1 -0
- package/dist/common/diagnosticRules.js.map +1 -1
- package/dist/common/positionUtils.js +3 -9
- package/dist/common/positionUtils.js.map +1 -1
- package/dist/languageServerBase.js +2 -0
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/completionProvider.d.ts +1 -0
- package/dist/languageService/completionProvider.js +4 -0
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/documentSymbolProvider.d.ts +1 -1
- package/dist/languageService/documentSymbolProvider.js +1 -1
- package/dist/languageService/documentSymbolProvider.js.map +1 -1
- package/dist/languageService/hoverProvider.d.ts +1 -0
- package/dist/languageService/hoverProvider.js +19 -3
- package/dist/languageService/hoverProvider.js.map +1 -1
- package/dist/localization/localize.d.ts +3 -1
- package/dist/localization/localize.js +1 -1
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.en-us.json +1 -1
- package/dist/parser/parser.js +6 -14
- package/dist/parser/parser.js.map +1 -1
- package/dist/parser/tokenizer.js +9 -20
- package/dist/parser/tokenizer.js.map +1 -1
- package/dist/pyright.js +3 -1
- package/dist/pyright.js.map +1 -1
- package/dist/tests/checker.test.js +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.fourslash.js +9 -7
- package/dist/tests/fourslash/hover.docFromSrc.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module2.fourslash.js +4 -1
- package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module2.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport2.fourslash.js +2 -1
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport2.fourslash.js.map +1 -1
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport3.fourslash.js +8 -1
- package/dist/tests/fourslash/hover.docFromSrc.relativeImport3.fourslash.js.map +1 -1
- package/dist/tests/fourslash/shadowedImports.fourslash.js +12 -0
- package/dist/tests/fourslash/shadowedImports.fourslash.js.map +1 -1
- package/dist/tests/indentationUtils.ptvs.test.js +3 -7
- package/dist/tests/indentationUtils.ptvs.test.js.map +1 -1
- package/dist/tests/indentationUtils.test.js +4 -4
- package/dist/tests/parser.test.js +3 -3
- package/dist/tests/tokenizer.test.js +2 -2
- package/dist/tests/typeEvaluator3.test.js +14 -0
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/package.json +1 -1
@@ -28,7 +28,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
28
28
|
return result;
|
29
29
|
};
|
30
30
|
Object.defineProperty(exports, "__esModule", { value: true });
|
31
|
-
exports.getVariableDocString = exports.getFunctionOrClassDeclDocString = exports.getClassDocString = exports.getModuleDocString = exports.getVariableInStubFileDocStrings = exports.getPropertyDocStringInherited = exports.getOverloadedFunctionDocStringsInherited = exports.getFunctionDocStringInherited = void 0;
|
31
|
+
exports.getVariableDocString = exports.getFunctionOrClassDeclDocString = exports.getClassDocString = exports.getModuleDocString = exports.getModuleNodeDocString = exports.getVariableInStubFileDocStrings = exports.getPropertyDocStringInherited = exports.getOverloadedFunctionDocStringsInherited = exports.getFunctionDocStringInherited = void 0;
|
32
32
|
const declaration_1 = require("../analyzer/declaration");
|
33
33
|
const ParseTreeUtils = __importStar(require("../analyzer/parseTreeUtils"));
|
34
34
|
const sourceMapper_1 = require("../analyzer/sourceMapper");
|
@@ -141,12 +141,24 @@ function getVariableInStubFileDocStrings(decl, sourceMapper) {
|
|
141
141
|
return docStrings;
|
142
142
|
}
|
143
143
|
exports.getVariableInStubFileDocStrings = getVariableInStubFileDocStrings;
|
144
|
+
function getModuleNodeDocString(modules) {
|
145
|
+
for (const module of modules) {
|
146
|
+
if (module.statements) {
|
147
|
+
const docString = ParseTreeUtils.getDocString(module.statements);
|
148
|
+
if (docString) {
|
149
|
+
return docString;
|
150
|
+
}
|
151
|
+
}
|
152
|
+
}
|
153
|
+
return undefined;
|
154
|
+
}
|
155
|
+
exports.getModuleNodeDocString = getModuleNodeDocString;
|
144
156
|
function getModuleDocString(type, resolvedDecl, sourceMapper) {
|
145
157
|
let docString = type.docString;
|
146
158
|
if (!docString) {
|
147
159
|
if (resolvedDecl && (0, sourceMapper_1.isStubFile)(resolvedDecl.path)) {
|
148
160
|
const modules = sourceMapper.findModules(resolvedDecl.path);
|
149
|
-
docString =
|
161
|
+
docString = getModuleNodeDocString(modules);
|
150
162
|
}
|
151
163
|
}
|
152
164
|
return docString;
|
@@ -287,15 +299,4 @@ function _getFunctionOrClassDeclsDocString(decls) {
|
|
287
299
|
}
|
288
300
|
return undefined;
|
289
301
|
}
|
290
|
-
function _getModuleNodeDocString(modules) {
|
291
|
-
for (const module of modules) {
|
292
|
-
if (module.statements) {
|
293
|
-
const docString = ParseTreeUtils.getDocString(module.statements);
|
294
|
-
if (docString) {
|
295
|
-
return docString;
|
296
|
-
}
|
297
|
-
}
|
298
|
-
}
|
299
|
-
return undefined;
|
300
|
-
}
|
301
302
|
//# sourceMappingURL=typeDocStringUtils.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"typeDocStringUtils.js","sourceRoot":"","sources":["../../../src/analyzer/typeDocStringUtils.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;;;;;;;AAEH,yDAUiC;AACjC,2EAA6D;AAC7D,2DAAoE;AACpE,6CAU2B;AAG3B,2CAMqB;AAErB,MAAM,qCAAqC,GACvC;iCAC4C;6BACJ;8BACA,CAAC;AAE7C,SAAS,sBAAsB,CAAC,IAA2C,EAAE,SAAqB;IAC9F,IAAI,IAAI,CAAC,QAAQ,+BAAoC,EAAE;QACnD,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE;YAC7B,OAAO,KAAK,CAAC;SAChB;QACD,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC;KAC5B;IAED,+DAA+D;IAC/D,+BAA+B;IAC/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C5F;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,SAAS,oCAAoC,CAAC,YAAiC,EAAE,YAA0B;IACvG,IAAI,SAAS,GAAG,iCAAiC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;IAClE,IAAI,CAAC,SAAS,IAAI,IAAA,yBAAU,EAAC,YAAY,CAAC,IAAI,CAAC,EAAE;QAC7C,MAAM,SAAS,GAAG,YAAY,CAAC,wBAAwB,CAAC,YAAY,CAAC,CAAC;QACtE,SAAS,GAAG,iCAAiC,CAAC,SAAS,CAAC,CAAC;KAC5D;IAED,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,SAAS,iCAAiC,CAAC,KAAiD;IACxF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACtB,MAAM,SAAS,GAAG,+BAA+B,CAAC,IAAI,CAAC,CAAC;QACxD,IAAI,SAAS,EAAE;YACX,OAAO,SAAS,CAAC;SACpB;KACJ;IAED,OAAO,SAAS,CAAC;AACrB,CAAC"}
|
@@ -11,7 +11,6 @@ export interface EvaluatorOptions {
|
|
11
11
|
printTypeFlags: TypePrinter.PrintTypeFlags;
|
12
12
|
logCalls: boolean;
|
13
13
|
minimumLoggingThreshold: number;
|
14
|
-
analyzeUnannotatedFunctions: boolean;
|
15
14
|
evaluateUnknownImportsAsAny: boolean;
|
16
15
|
verifyTypeCacheEvaluatorFlags: boolean;
|
17
16
|
}
|
@@ -205,6 +205,12 @@ const maxOverloadUnionExpansionCount = 64;
|
|
205
205
|
// Maximum number of recursive function return type inference attempts
|
206
206
|
// that can be concurrently pending before we give up.
|
207
207
|
const maxInferFunctionReturnRecursionCount = 12;
|
208
|
+
// Maximum recursion amount when comparing two recursive type aliases.
|
209
|
+
// Increasing this can greatly increase the time required to evaluate
|
210
|
+
// two recursive type aliases that have the same definition. Decreasing
|
211
|
+
// it can increase the chance of false negatives for such recursive
|
212
|
+
// type aliases.
|
213
|
+
const maxRecursiveTypeAliasRecursionCount = 10;
|
208
214
|
// This switch enables a special debug mode that attempts to catch
|
209
215
|
// bugs due to inconsistent evaluation flags used when reading types
|
210
216
|
// from the type cache.
|
@@ -697,7 +703,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
697
703
|
}
|
698
704
|
}
|
699
705
|
if (flags & 65536 /* DisallowRecursiveTypeAliasPlaceholder */) {
|
700
|
-
if ((0, typeUtils_1.isTypeAliasPlaceholder)(typeResult.type)) {
|
706
|
+
if ((0, types_1.isTypeVar)(typeResult.type) && (0, typeUtils_1.isTypeAliasPlaceholder)(typeResult.type)) {
|
701
707
|
typeResult.type.details.illegalRecursionDetected = true;
|
702
708
|
}
|
703
709
|
}
|
@@ -1980,6 +1986,17 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
1980
1986
|
if (diagLevel === 'none') {
|
1981
1987
|
return undefined;
|
1982
1988
|
}
|
1989
|
+
// Should we suppress this diagnostic because it's within an unannotated function?
|
1990
|
+
const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
|
1991
|
+
if (!fileInfo.diagnosticRuleSet.analyzeUnannotatedFunctions) {
|
1992
|
+
const containingFunction = ParseTreeUtils.getEnclosingFunction(node);
|
1993
|
+
// Is the target node within the body of the function? If so, suppress the diagnostic.
|
1994
|
+
if (containingFunction &&
|
1995
|
+
ParseTreeUtils.isUnannotatedFunction(containingFunction) &&
|
1996
|
+
ParseTreeUtils.isNodeContainedWithin(node, containingFunction.suite)) {
|
1997
|
+
return undefined;
|
1998
|
+
}
|
1999
|
+
}
|
1983
2000
|
const diagnostic = addDiagnosticWithSuppressionCheck(diagLevel, message, node, range);
|
1984
2001
|
if (diagnostic) {
|
1985
2002
|
diagnostic.setRule(rule);
|
@@ -2752,15 +2769,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
2752
2769
|
let type;
|
2753
2770
|
let isIncomplete = false;
|
2754
2771
|
const allowForwardReferences = (flags & 4 /* AllowForwardReferences */) !== 0 || fileInfo.isStubFile;
|
2755
|
-
if (!evaluatorOptions.analyzeUnannotatedFunctions) {
|
2756
|
-
const containingFunction = ParseTreeUtils.getEnclosingFunction(node);
|
2757
|
-
if (containingFunction && ParseTreeUtils.isUnannotatedFunction(containingFunction)) {
|
2758
|
-
return {
|
2759
|
-
type: types_1.AnyType.create(),
|
2760
|
-
isIncomplete: false,
|
2761
|
-
};
|
2762
|
-
}
|
2763
|
-
}
|
2764
2772
|
// Does this name refer to a PEP 695-style type parameter?
|
2765
2773
|
const typeParamSymbol = AnalyzerNodeInfo.getTypeParameterSymbol(node);
|
2766
2774
|
if (typeParamSymbol) {
|
@@ -2789,6 +2797,18 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
2789
2797
|
useCodeFlowAnalysis = false;
|
2790
2798
|
}
|
2791
2799
|
symbol = symbolWithScope.symbol;
|
2800
|
+
setSymbolAccessed(fileInfo, symbol, node);
|
2801
|
+
// If we're not supposed to be analyzing this function, skip the remaining work
|
2802
|
+
// to determine the name's type. Simply evaluate its type as Any.
|
2803
|
+
if (!fileInfo.diagnosticRuleSet.analyzeUnannotatedFunctions) {
|
2804
|
+
const containingFunction = ParseTreeUtils.getEnclosingFunction(node);
|
2805
|
+
if (containingFunction && ParseTreeUtils.isUnannotatedFunction(containingFunction)) {
|
2806
|
+
return {
|
2807
|
+
type: types_1.AnyType.create(),
|
2808
|
+
isIncomplete: false,
|
2809
|
+
};
|
2810
|
+
}
|
2811
|
+
}
|
2792
2812
|
// Get the effective type (either the declared type or the inferred type).
|
2793
2813
|
// If we're using code flow analysis, pass the usage node so we consider
|
2794
2814
|
// only the assignment nodes that are reachable from this usage.
|
@@ -2845,7 +2865,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
2845
2865
|
}
|
2846
2866
|
// Detect, report, and fill in missing type arguments if appropriate.
|
2847
2867
|
type = reportMissingTypeArguments(node, type, flags);
|
2848
|
-
setSymbolAccessed(fileInfo, symbol, node);
|
2849
2868
|
if ((flags & 1024 /* ExpectingTypeAnnotation */) !== 0) {
|
2850
2869
|
// Verify that the name does not refer to a (non type alias) variable.
|
2851
2870
|
if (effectiveTypeInfo.includesVariableDecl && !type.typeAliasInfo) {
|
@@ -4402,7 +4421,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
4402
4421
|
if (typeAliasResult) {
|
4403
4422
|
return typeAliasResult;
|
4404
4423
|
}
|
4405
|
-
if ((0, typeUtils_1.isTypeAliasPlaceholder)(baseTypeResult.type)) {
|
4424
|
+
if ((0, types_1.isTypeVar)(baseTypeResult.type) && (0, typeUtils_1.isTypeAliasPlaceholder)(baseTypeResult.type)) {
|
4406
4425
|
const typeArgTypes = getTypeArgs(node, flags).map((t) => (0, typeUtils_1.convertToInstance)(t.type));
|
4407
4426
|
const type = types_1.TypeBase.cloneForTypeAlias(baseTypeResult.type, baseTypeResult.type.details.recursiveTypeAliasName, '', baseTypeResult.type.details.recursiveTypeAliasScopeId, baseTypeResult.type.details.recursiveTypeParameters, typeArgTypes);
|
4408
4427
|
return { type };
|
@@ -5787,7 +5806,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
5787
5806
|
}
|
5788
5807
|
});
|
5789
5808
|
}
|
5790
|
-
if (!validatedTypes && argList.
|
5809
|
+
if (!validatedTypes && argList.some((arg) => arg.argumentCategory === 0 /* Simple */)) {
|
5791
5810
|
// Suppress this error if the class was instantiated from a custom
|
5792
5811
|
// metaclass because it's likely that it's a false positive. Also
|
5793
5812
|
// suppress the error if the class's metaclass has a __call__ method.
|
@@ -6974,9 +6993,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
6974
6993
|
((0, types_1.isClassInstance)(argType) &&
|
6975
6994
|
(0, typeUtils_1.isTupleClass)(argType) &&
|
6976
6995
|
argType.tupleTypeArguments &&
|
6977
|
-
argType.tupleTypeArguments.
|
6996
|
+
argType.tupleTypeArguments.length === 1 &&
|
6997
|
+
(0, types_1.isUnpackedVariadicTypeVar)(argType.tupleTypeArguments[0].type));
|
6978
6998
|
if (containsVariadicTypeVar &&
|
6979
|
-
argParam.argument.argumentCategory !== 1 /* UnpackedList */
|
6999
|
+
argParam.argument.argumentCategory !== 1 /* UnpackedList */ &&
|
7000
|
+
!argParam.mapsToVarArgList) {
|
6980
7001
|
addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.typeVarTupleMustBeUnpacked(), (_a = argParam.argument.valueExpression) !== null && _a !== void 0 ? _a : errorNode);
|
6981
7002
|
reportedArgError = true;
|
6982
7003
|
}
|
@@ -8743,13 +8764,21 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
8743
8764
|
let effectiveExpectedType = expectedType;
|
8744
8765
|
if (expectedType && (0, types_1.isUnion)(expectedType)) {
|
8745
8766
|
let matchingSubtype;
|
8767
|
+
let matchingSubtypeResult;
|
8746
8768
|
(0, typeUtils_1.doForEachSubtype)(expectedType, (subtype) => {
|
8747
|
-
if
|
8748
|
-
|
8749
|
-
|
8750
|
-
|
8751
|
-
|
8769
|
+
// Use shortcut if we've already found a match.
|
8770
|
+
if (matchingSubtypeResult && !matchingSubtypeResult.typeErrors) {
|
8771
|
+
return;
|
8772
|
+
}
|
8773
|
+
const subtypeResult = useSpeculativeMode(node, () => {
|
8774
|
+
return getTypeOfDictionaryExpected(node, subtype);
|
8775
|
+
});
|
8776
|
+
if (subtypeResult && assignType(subtype, subtypeResult.type)) {
|
8777
|
+
// If this is the first result we're seeing or it's the first result
|
8778
|
+
// without errors, select it as the match.
|
8779
|
+
if (!matchingSubtypeResult || (matchingSubtypeResult.typeErrors && !subtypeResult.typeErrors)) {
|
8752
8780
|
matchingSubtype = subtype;
|
8781
|
+
matchingSubtypeResult = subtypeResult;
|
8753
8782
|
}
|
8754
8783
|
}
|
8755
8784
|
});
|
@@ -9011,13 +9040,21 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
9011
9040
|
let effectiveExpectedType = expectedType;
|
9012
9041
|
if (expectedType && (0, types_1.isUnion)(expectedType)) {
|
9013
9042
|
let matchingSubtype;
|
9043
|
+
let matchingSubtypeResult;
|
9014
9044
|
(0, typeUtils_1.doForEachSubtype)(expectedType, (subtype) => {
|
9015
|
-
if
|
9016
|
-
|
9017
|
-
|
9018
|
-
|
9019
|
-
|
9045
|
+
// Use shortcut if we've already found a match.
|
9046
|
+
if (matchingSubtypeResult && !matchingSubtypeResult.typeErrors) {
|
9047
|
+
return;
|
9048
|
+
}
|
9049
|
+
const subtypeResult = useSpeculativeMode(node, () => {
|
9050
|
+
return getTypeOfListOrSetExpected(node, subtype);
|
9051
|
+
});
|
9052
|
+
if (subtypeResult && assignType(subtype, subtypeResult.type)) {
|
9053
|
+
// If this is the first result we're seeing or it's the first result
|
9054
|
+
// without errors, select it as the match.
|
9055
|
+
if (!matchingSubtypeResult || (matchingSubtypeResult.typeErrors && !subtypeResult.typeErrors)) {
|
9020
9056
|
matchingSubtype = subtype;
|
9057
|
+
matchingSubtypeResult = subtypeResult;
|
9021
9058
|
}
|
9022
9059
|
}
|
9023
9060
|
});
|
@@ -14716,6 +14753,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
14716
14753
|
var _a;
|
14717
14754
|
let returnType;
|
14718
14755
|
let isIncomplete = false;
|
14756
|
+
let analyzeUnannotatedFunctions = true;
|
14719
14757
|
// Don't attempt to infer the return type for a stub file.
|
14720
14758
|
if (types_1.FunctionType.isStubDefinition(type)) {
|
14721
14759
|
return types_1.UnknownType.create();
|
@@ -14733,8 +14771,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
14733
14771
|
}
|
14734
14772
|
else if (type.details.declaration) {
|
14735
14773
|
const functionNode = type.details.declaration.node;
|
14774
|
+
analyzeUnannotatedFunctions =
|
14775
|
+
AnalyzerNodeInfo.getFileInfo(functionNode).diagnosticRuleSet.analyzeUnannotatedFunctions;
|
14736
14776
|
// Skip return type inference if we are in "skip unannotated function" mode.
|
14737
|
-
if (
|
14777
|
+
if (analyzeUnannotatedFunctions && !checkCodeFlowTooComplex(functionNode.suite)) {
|
14738
14778
|
const codeFlowComplexity = AnalyzerNodeInfo.getCodeFlowComplexity(functionNode);
|
14739
14779
|
// For very complex functions that have no annotated parameter types,
|
14740
14780
|
// don't attempt to infer the return type because it can be extremely
|
@@ -14771,7 +14811,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
14771
14811
|
// params, try to analyze the function with the provided argument types and
|
14772
14812
|
// attempt to do a better job at inference.
|
14773
14813
|
if (!isIncomplete &&
|
14774
|
-
|
14814
|
+
analyzeUnannotatedFunctions &&
|
14775
14815
|
(0, typeUtils_1.isPartlyUnknown)(returnType) &&
|
14776
14816
|
types_1.FunctionType.hasUnannotatedParams(type) &&
|
14777
14817
|
!types_1.FunctionType.isStubDefinition(type) &&
|
@@ -15405,8 +15445,22 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
15405
15445
|
}
|
15406
15446
|
}
|
15407
15447
|
// Transform recursive type aliases if necessary.
|
15408
|
-
|
15409
|
-
|
15448
|
+
const transformedDestType = (0, typeUtils_1.transformPossibleRecursiveTypeAlias)(destType);
|
15449
|
+
const transformedSrcType = (0, typeUtils_1.transformPossibleRecursiveTypeAlias)(srcType);
|
15450
|
+
// Did both the source and dest include recursive type aliases?
|
15451
|
+
// If so, we are potentially dealing with different recursive type
|
15452
|
+
// aliases that are defined in the same way.
|
15453
|
+
if (transformedDestType !== destType &&
|
15454
|
+
transformedSrcType !== srcType &&
|
15455
|
+
(0, types_1.isUnion)(transformedDestType) &&
|
15456
|
+
(0, types_1.isUnion)(transformedSrcType)) {
|
15457
|
+
// Use a smaller recursive limit in this case to prevent runaway recursion.
|
15458
|
+
if (recursionCount > maxRecursiveTypeAliasRecursionCount) {
|
15459
|
+
return true;
|
15460
|
+
}
|
15461
|
+
}
|
15462
|
+
destType = transformedDestType;
|
15463
|
+
srcType = transformedSrcType;
|
15410
15464
|
// If the source or dest is unbound, allow the assignment. The
|
15411
15465
|
// error will be reported elsewhere.
|
15412
15466
|
if ((0, types_1.isUnbound)(destType) || (0, types_1.isUnbound)(srcType)) {
|
@@ -15628,19 +15682,21 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
15628
15682
|
}
|
15629
15683
|
instantiableType = (0, typeUtils_1.convertToInstantiable)(typeTypeArg);
|
15630
15684
|
}
|
15631
|
-
else {
|
15685
|
+
else if (types_1.TypeBase.isInstantiable(destType)) {
|
15632
15686
|
typeTypeArg = objectType !== null && objectType !== void 0 ? objectType : types_1.AnyType.create();
|
15633
15687
|
instantiableType = expandedSrcType;
|
15634
15688
|
}
|
15635
|
-
if (
|
15636
|
-
if (
|
15637
|
-
|
15689
|
+
if (instantiableType && typeTypeArg) {
|
15690
|
+
if ((0, types_1.isClassInstance)(typeTypeArg) || (0, types_1.isTypeVar)(typeTypeArg)) {
|
15691
|
+
if (assignType(destType, instantiableType, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), destTypeVarContext, srcTypeVarContext, flags, recursionCount)) {
|
15692
|
+
return true;
|
15693
|
+
}
|
15694
|
+
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.typeAssignmentMismatch().format({
|
15695
|
+
sourceType: printType(srcType),
|
15696
|
+
destType: printType(destType),
|
15697
|
+
}));
|
15698
|
+
return false;
|
15638
15699
|
}
|
15639
|
-
diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.typeAssignmentMismatch().format({
|
15640
|
-
sourceType: printType(srcType),
|
15641
|
-
destType: printType(destType),
|
15642
|
-
}));
|
15643
|
-
return false;
|
15644
15700
|
}
|
15645
15701
|
}
|
15646
15702
|
if ((0, types_1.isInstantiableClass)(destType)) {
|
@@ -16103,7 +16159,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
16103
16159
|
// in case the destType is a union with hundreds of literals.
|
16104
16160
|
if ((0, types_1.isClassInstance)(srcType) &&
|
16105
16161
|
(0, typeUtils_1.isLiteralType)(srcType) &&
|
16106
|
-
types_1.UnionType.containsType(destType, srcType, recursionCount)) {
|
16162
|
+
types_1.UnionType.containsType(destType, srcType, /* exclusionSet */ undefined, recursionCount)) {
|
16107
16163
|
return true;
|
16108
16164
|
}
|
16109
16165
|
(0, typeUtils_1.doForEachSubtype)(destType, (subtype) => {
|
@@ -17248,7 +17304,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
17248
17304
|
if ((0, types_1.isAnyOrUnknown)(srcType)) {
|
17249
17305
|
return srcType;
|
17250
17306
|
}
|
17251
|
-
let effectiveSrcType = srcType;
|
17307
|
+
let effectiveSrcType = (0, typeUtils_1.transformPossibleRecursiveTypeAlias)(srcType);
|
17252
17308
|
if ((0, types_1.isTypeVar)(srcType)) {
|
17253
17309
|
if ((0, types_1.isTypeSame)(srcType, destType)) {
|
17254
17310
|
return srcType;
|
@@ -17262,7 +17318,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
17262
17318
|
return srcType;
|
17263
17319
|
}
|
17264
17320
|
// If there's a bound type, make sure the source is derived from it.
|
17265
|
-
if (destType.details.boundType) {
|
17321
|
+
if (destType.details.boundType && !(0, typeUtils_1.isTypeAliasPlaceholder)(effectiveSrcType)) {
|
17266
17322
|
if (!assignType(destType.details.boundType, effectiveSrcType, diag.createAddendum(),
|
17267
17323
|
/* destTypeVarContext */ undefined,
|
17268
17324
|
/* srcTypeVarContext */ undefined)) {
|
@@ -17303,6 +17359,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
|
|
17303
17359
|
if (constraints.length === 0) {
|
17304
17360
|
return srcType;
|
17305
17361
|
}
|
17362
|
+
if ((0, typeUtils_1.isTypeAliasPlaceholder)(srcType)) {
|
17363
|
+
return srcType;
|
17364
|
+
}
|
17306
17365
|
if ((0, types_1.isTypeVar)(srcType) && srcType.details.constraints.length > 0) {
|
17307
17366
|
// Make sure all the source constraint types map to constraint types in the dest.
|
17308
17367
|
if (srcType.details.constraints.every((sourceConstraint) => {
|