@zzzen/pyright-internal 1.2.0-dev.20230827 → 1.2.0-dev.20230910
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 +4 -1
- package/dist/analyzer/binder.js.map +1 -1
- package/dist/analyzer/checker.js +40 -14
- package/dist/analyzer/checker.js.map +1 -1
- package/dist/analyzer/codeFlowEngine.js +1 -2
- package/dist/analyzer/codeFlowEngine.js.map +1 -1
- package/dist/analyzer/constraintSolver.js +5 -0
- package/dist/analyzer/constraintSolver.js.map +1 -1
- package/dist/analyzer/constructors.js +16 -7
- package/dist/analyzer/constructors.js.map +1 -1
- package/dist/analyzer/declarationUtils.js +2 -0
- package/dist/analyzer/declarationUtils.js.map +1 -1
- package/dist/analyzer/decorators.js +16 -1
- package/dist/analyzer/decorators.js.map +1 -1
- package/dist/analyzer/deprecatedSymbols.js +13 -2
- package/dist/analyzer/deprecatedSymbols.js.map +1 -1
- package/dist/analyzer/importResolver.d.ts +6 -4
- package/dist/analyzer/importResolver.js +20 -18
- package/dist/analyzer/importResolver.js.map +1 -1
- package/dist/analyzer/namedTuples.js +1 -1
- package/dist/analyzer/namedTuples.js.map +1 -1
- package/dist/analyzer/packageTypeVerifier.d.ts +3 -3
- package/dist/analyzer/packageTypeVerifier.js +8 -11
- package/dist/analyzer/packageTypeVerifier.js.map +1 -1
- package/dist/analyzer/parentDirectoryCache.js +1 -1
- package/dist/analyzer/parentDirectoryCache.js.map +1 -1
- package/dist/analyzer/program.d.ts +9 -22
- package/dist/analyzer/program.js +117 -105
- package/dist/analyzer/program.js.map +1 -1
- package/dist/analyzer/protocols.js +3 -1
- package/dist/analyzer/protocols.js.map +1 -1
- package/dist/analyzer/pythonPathUtils.js +10 -8
- package/dist/analyzer/pythonPathUtils.js.map +1 -1
- package/dist/analyzer/service.d.ts +6 -3
- package/dist/analyzer/service.js +40 -20
- package/dist/analyzer/service.js.map +1 -1
- package/dist/analyzer/sourceFile.d.ts +6 -4
- package/dist/analyzer/sourceFile.js +9 -16
- package/dist/analyzer/sourceFile.js.map +1 -1
- package/dist/analyzer/sourceFileInfo.d.ts +62 -0
- package/dist/analyzer/sourceFileInfo.js +145 -0
- package/dist/analyzer/sourceFileInfo.js.map +1 -0
- package/dist/analyzer/sourceMapper.d.ts +1 -1
- package/dist/analyzer/typeDocStringUtils.js +1 -1
- package/dist/analyzer/typeEvaluator.js +361 -262
- package/dist/analyzer/typeEvaluator.js.map +1 -1
- package/dist/analyzer/typeEvaluatorTypes.d.ts +10 -8
- package/dist/analyzer/typeEvaluatorTypes.js +11 -8
- package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
- package/dist/analyzer/typeGuards.js +116 -20
- package/dist/analyzer/typeGuards.js.map +1 -1
- package/dist/analyzer/typeUtils.d.ts +6 -4
- package/dist/analyzer/typeUtils.js +104 -63
- package/dist/analyzer/typeUtils.js.map +1 -1
- package/dist/analyzer/typeWalker.js +1 -1
- package/dist/analyzer/typeWalker.js.map +1 -1
- package/dist/analyzer/types.d.ts +1 -0
- package/dist/analyzer/types.js +8 -0
- package/dist/analyzer/types.js.map +1 -1
- package/dist/backgroundAnalysis.d.ts +1 -2
- package/dist/backgroundAnalysis.js +2 -2
- package/dist/backgroundAnalysis.js.map +1 -1
- package/dist/backgroundAnalysisBase.d.ts +1 -2
- package/dist/backgroundAnalysisBase.js +4 -4
- package/dist/backgroundAnalysisBase.js.map +1 -1
- package/dist/backgroundThreadBase.d.ts +1 -1
- package/dist/backgroundThreadBase.js +1 -0
- package/dist/backgroundThreadBase.js.map +1 -1
- package/dist/common/commandLineOptions.d.ts +1 -0
- package/dist/common/commandLineOptions.js.map +1 -1
- package/dist/common/configOptions.d.ts +4 -1
- package/dist/common/configOptions.js +18 -5
- package/dist/common/configOptions.js.map +1 -1
- package/dist/common/console.d.ts +3 -0
- package/dist/common/console.js +8 -1
- package/dist/common/console.js.map +1 -1
- package/dist/common/extensibility.d.ts +10 -1
- package/dist/common/extensibility.js.map +1 -1
- package/dist/common/fileSystem.d.ts +3 -0
- package/dist/common/fileSystem.js +8 -1
- package/dist/common/fileSystem.js.map +1 -1
- package/dist/common/pathUtils.d.ts +2 -15
- package/dist/common/pathUtils.js +9 -84
- package/dist/common/pathUtils.js.map +1 -1
- package/dist/common/realFileSystem.js +22 -13
- package/dist/common/realFileSystem.js.map +1 -1
- package/dist/common/serviceProvider.d.ts +1 -4
- package/dist/common/serviceProvider.js +4 -4
- package/dist/common/serviceProvider.js.map +1 -1
- package/dist/common/serviceProviderExtensions.d.ts +10 -4
- package/dist/common/serviceProviderExtensions.js +43 -1
- package/dist/common/serviceProviderExtensions.js.map +1 -1
- package/dist/languageServerBase.d.ts +9 -9
- package/dist/languageServerBase.js +5 -4
- package/dist/languageServerBase.js.map +1 -1
- package/dist/languageService/analyzerServiceExecutor.js +3 -2
- package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
- package/dist/languageService/completionProvider.d.ts +7 -5
- package/dist/languageService/completionProvider.js +190 -176
- package/dist/languageService/completionProvider.js.map +1 -1
- package/dist/languageService/completionProviderUtils.d.ts +1 -1
- package/dist/languageService/completionProviderUtils.js +1 -1
- package/dist/languageService/completionProviderUtils.js.map +1 -1
- package/dist/localization/localize.d.ts +14 -0
- package/dist/localization/localize.js +8 -0
- package/dist/localization/localize.js.map +1 -1
- package/dist/localization/package.nls.cs.json +26 -17
- package/dist/localization/package.nls.de.json +26 -17
- package/dist/localization/package.nls.en-us.json +9 -2
- package/dist/localization/package.nls.es.json +26 -17
- package/dist/localization/package.nls.fr.json +26 -17
- package/dist/localization/package.nls.it.json +26 -17
- package/dist/localization/package.nls.ja.json +26 -17
- package/dist/localization/package.nls.ko.json +26 -17
- package/dist/localization/package.nls.pl.json +26 -17
- package/dist/localization/package.nls.pt-br.json +26 -17
- package/dist/localization/package.nls.qps-ploc.json +14 -5
- package/dist/localization/package.nls.ru.json +26 -17
- package/dist/localization/package.nls.tr.json +26 -17
- package/dist/localization/package.nls.zh-cn.json +26 -17
- package/dist/localization/package.nls.zh-tw.json +26 -17
- package/dist/pyright.js +6 -4
- package/dist/pyright.js.map +1 -1
- package/dist/server.d.ts +2 -2
- package/dist/server.js +8 -10
- package/dist/server.js.map +1 -1
- package/dist/tests/chainedSourceFiles.test.js +4 -1
- package/dist/tests/chainedSourceFiles.test.js.map +1 -1
- package/dist/tests/checker.test.js +11 -11
- package/dist/tests/checker.test.js.map +1 -1
- package/dist/tests/completions.test.js +57 -0
- package/dist/tests/completions.test.js.map +1 -1
- package/dist/tests/config.test.js +28 -22
- package/dist/tests/config.test.js.map +1 -1
- package/dist/tests/fourslash/completions.dictionary.keys.complex.fourslash.js +5 -5
- package/dist/tests/fourslash/completions.dictionary.keys.complex.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dictionary.keys.expression.fourslash.js +11 -9
- package/dist/tests/fourslash/completions.dictionary.keys.expression.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dictionary.keys.literalTypes.fourslash.js +14 -14
- package/dist/tests/fourslash/completions.dictionary.keys.literalTypes.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dictionary.keys.simple.fourslash.js +12 -12
- package/dist/tests/fourslash/completions.dictionary.keys.simple.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dictionary.keys.stringLiterals.fourslash.js +9 -9
- package/dist/tests/fourslash/completions.dictionary.keys.stringLiterals.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.dictionary.keys.symbols.fourslash.js +3 -3
- package/dist/tests/fourslash/completions.dictionary.keys.symbols.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.fstring.stringLiteral.fourslash.js +3 -3
- package/dist/tests/fourslash/completions.fstring.stringLiteral.fourslash.js.map +1 -1
- package/dist/tests/fourslash/completions.indexer.keys.getitem.fourslash.js +4 -4
- package/dist/tests/fourslash/completions.indexer.keys.getitem.fourslash.js.map +1 -1
- package/dist/tests/fourslash/fourslash.d.ts +1 -0
- package/dist/tests/fourslash/missingModuleSource.fourslash.js +4 -1
- package/dist/tests/fourslash/missingModuleSource.fourslash.js.map +1 -1
- package/dist/tests/harness/fourslash/testLanguageService.js +4 -1
- package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.Consts.d.ts +1 -0
- package/dist/tests/harness/fourslash/testState.Consts.js +2 -0
- package/dist/tests/harness/fourslash/testState.Consts.js.map +1 -1
- package/dist/tests/harness/fourslash/testState.d.ts +2 -0
- package/dist/tests/harness/fourslash/testState.js +9 -2
- package/dist/tests/harness/fourslash/testState.js.map +1 -1
- package/dist/tests/harness/vfs/filesystem.js +10 -6
- package/dist/tests/harness/vfs/filesystem.js.map +1 -1
- package/dist/tests/importResolver.test.js +14 -9
- package/dist/tests/importResolver.test.js.map +1 -1
- package/dist/tests/localizer.test.js +1 -1
- package/dist/tests/localizer.test.js.map +1 -1
- package/dist/tests/pathUtils.test.js +13 -21
- package/dist/tests/pathUtils.test.js.map +1 -1
- package/dist/tests/service.test.js +55 -0
- package/dist/tests/service.test.js.map +1 -1
- package/dist/tests/sourceFile.test.js +4 -2
- package/dist/tests/sourceFile.test.js.map +1 -1
- package/dist/tests/testState.test.js +1 -1
- package/dist/tests/testState.test.js.map +1 -1
- package/dist/tests/testUtils.js +3 -5
- package/dist/tests/testUtils.js.map +1 -1
- package/dist/tests/typeEvaluator1.test.js +2 -2
- package/dist/tests/typeEvaluator2.test.js +5 -1
- package/dist/tests/typeEvaluator2.test.js.map +1 -1
- package/dist/tests/typeEvaluator3.test.js +8 -4
- package/dist/tests/typeEvaluator3.test.js.map +1 -1
- package/dist/tests/typeEvaluator4.test.js +4 -0
- package/dist/tests/typeEvaluator4.test.js.map +1 -1
- package/dist/tests/typeEvaluator5.test.js +1 -1
- package/dist/tests/workspaceEditUtils.test.js +24 -20
- package/dist/tests/workspaceEditUtils.test.js.map +1 -1
- package/dist/workspaceFactory.d.ts +1 -0
- package/dist/workspaceFactory.js +7 -4
- package/dist/workspaceFactory.js.map +1 -1
- package/package.json +1 -1
@@ -33,12 +33,15 @@ var ClassMemberLookupFlags;
|
|
33
33
|
// By default, both class and instance variables are searched.
|
34
34
|
// If this flag is set, the instance variables are skipped.
|
35
35
|
ClassMemberLookupFlags[ClassMemberLookupFlags["SkipInstanceVariables"] = 8] = "SkipInstanceVariables";
|
36
|
+
// By default, both class and instance variables are searched.
|
37
|
+
// If this flag is set, the class variables are skipped.
|
38
|
+
ClassMemberLookupFlags[ClassMemberLookupFlags["SkipClassVariables"] = 16] = "SkipClassVariables";
|
36
39
|
// By default, the first symbol is returned even if it has only
|
37
40
|
// an inferred type associated with it. If this flag is set,
|
38
41
|
// the search looks only for symbols with declared types.
|
39
|
-
ClassMemberLookupFlags[ClassMemberLookupFlags["DeclaredTypesOnly"] =
|
42
|
+
ClassMemberLookupFlags[ClassMemberLookupFlags["DeclaredTypesOnly"] = 32] = "DeclaredTypesOnly";
|
40
43
|
// Skip the 'type' base class in particular.
|
41
|
-
ClassMemberLookupFlags[ClassMemberLookupFlags["SkipTypeBaseClass"] =
|
44
|
+
ClassMemberLookupFlags[ClassMemberLookupFlags["SkipTypeBaseClass"] = 64] = "SkipTypeBaseClass";
|
42
45
|
})(ClassMemberLookupFlags = exports.ClassMemberLookupFlags || (exports.ClassMemberLookupFlags = {}));
|
43
46
|
var ClassIteratorFlags;
|
44
47
|
(function (ClassIteratorFlags) {
|
@@ -100,6 +103,10 @@ var AssignTypeFlags;
|
|
100
103
|
// default type arguments (typically "Unknown"). This flag skips
|
101
104
|
// this step.
|
102
105
|
AssignTypeFlags[AssignTypeFlags["AllowUnspecifiedTypeArguments"] = 2048] = "AllowUnspecifiedTypeArguments";
|
106
|
+
// PEP 544 says that if the dest type is a type[Proto] class,
|
107
|
+
// the source must be a "concrete" (non-protocol) class. This
|
108
|
+
// flag skips this check.
|
109
|
+
AssignTypeFlags[AssignTypeFlags["IgnoreProtocolAssignmentCheck"] = 4096] = "IgnoreProtocolAssignmentCheck";
|
103
110
|
})(AssignTypeFlags = exports.AssignTypeFlags || (exports.AssignTypeFlags = {}));
|
104
111
|
// Tracks whether a function signature has been seen before within
|
105
112
|
// an expression. For example, in the expression "foo(foo, foo)", the
|
@@ -198,14 +205,15 @@ exports.makeInferenceContext = makeInferenceContext;
|
|
198
205
|
// Calls a callback for each subtype and combines the results
|
199
206
|
// into a final type. It performs no memory allocations if the
|
200
207
|
// transformed type is the same as the original.
|
201
|
-
function mapSubtypes(type, callback) {
|
208
|
+
function mapSubtypes(type, callback, sortSubtypes = false) {
|
202
209
|
if ((0, types_1.isUnion)(type)) {
|
203
|
-
|
204
|
-
|
210
|
+
const subtypes = sortSubtypes ? sortTypes(type.subtypes) : type.subtypes;
|
211
|
+
for (let i = 0; i < subtypes.length; i++) {
|
212
|
+
const subtype = subtypes[i];
|
205
213
|
const transformedType = callback(subtype);
|
206
214
|
// Avoid doing any memory allocations until a change is detected.
|
207
215
|
if (subtype !== transformedType) {
|
208
|
-
const typesToCombine =
|
216
|
+
const typesToCombine = subtypes.slice(0, i);
|
209
217
|
// Create a helper lambda that accumulates transformed subtypes.
|
210
218
|
const accumulateSubtype = (newSubtype) => {
|
211
219
|
if (newSubtype) {
|
@@ -213,8 +221,8 @@ function mapSubtypes(type, callback) {
|
|
213
221
|
}
|
214
222
|
};
|
215
223
|
accumulateSubtype(transformedType);
|
216
|
-
for (i++; i <
|
217
|
-
accumulateSubtype(callback(
|
224
|
+
for (i++; i < subtypes.length; i++) {
|
225
|
+
accumulateSubtype(callback(subtypes[i]));
|
218
226
|
}
|
219
227
|
const newType = (0, types_1.combineTypes)(typesToCombine);
|
220
228
|
// Do our best to retain type aliases.
|
@@ -240,8 +248,12 @@ function sortTypes(types) {
|
|
240
248
|
});
|
241
249
|
}
|
242
250
|
exports.sortTypes = sortTypes;
|
243
|
-
function compareTypes(a, b) {
|
251
|
+
function compareTypes(a, b, recursionCount = 0) {
|
244
252
|
var _a, _b;
|
253
|
+
if (recursionCount > types_1.maxTypeRecursionCount) {
|
254
|
+
return 0;
|
255
|
+
}
|
256
|
+
recursionCount++;
|
245
257
|
if (a.category !== b.category) {
|
246
258
|
return b.category - a.category;
|
247
259
|
}
|
@@ -331,7 +343,29 @@ function compareTypes(a, b) {
|
|
331
343
|
// Sort by class name.
|
332
344
|
const aName = a.details.name;
|
333
345
|
const bName = b.details.name;
|
334
|
-
|
346
|
+
if (aName < bName) {
|
347
|
+
return -1;
|
348
|
+
}
|
349
|
+
else if (aName > bName) {
|
350
|
+
return 1;
|
351
|
+
}
|
352
|
+
// Sort by type argument count.
|
353
|
+
const aTypeArgCount = a.typeArguments ? a.typeArguments.length : 0;
|
354
|
+
const bTypeArgCount = bClass.typeArguments ? bClass.typeArguments.length : 0;
|
355
|
+
if (aTypeArgCount < bTypeArgCount) {
|
356
|
+
return -1;
|
357
|
+
}
|
358
|
+
else if (aTypeArgCount > bTypeArgCount) {
|
359
|
+
return 1;
|
360
|
+
}
|
361
|
+
// Sort by type argument.
|
362
|
+
for (let i = 0; i < aTypeArgCount; i++) {
|
363
|
+
const typeComparison = compareTypes(a.typeArguments[i], bClass.typeArguments[i], recursionCount);
|
364
|
+
if (typeComparison !== 0) {
|
365
|
+
return typeComparison;
|
366
|
+
}
|
367
|
+
}
|
368
|
+
return 0;
|
335
369
|
}
|
336
370
|
case 8 /* Module */: {
|
337
371
|
const aName = a.moduleName;
|
@@ -991,7 +1025,7 @@ exports.lookUpClassMember = lookUpClassMember;
|
|
991
1025
|
// If skipMroClass is defined, all MRO classes up to and including that class
|
992
1026
|
// are skipped.
|
993
1027
|
function* getClassMemberIterator(classType, memberName, flags = 0 /* Default */, skipMroClass) {
|
994
|
-
const declaredTypesOnly = (flags &
|
1028
|
+
const declaredTypesOnly = (flags & 32 /* DeclaredTypesOnly */) !== 0;
|
995
1029
|
let skippedUndeclaredType = false;
|
996
1030
|
if ((0, types_1.isClass)(classType)) {
|
997
1031
|
let classFlags = 0 /* Default */;
|
@@ -1006,7 +1040,7 @@ function* getClassMemberIterator(classType, memberName, flags = 0 /* Default */,
|
|
1006
1040
|
if (flags & 4 /* SkipObjectBaseClass */) {
|
1007
1041
|
classFlags = classFlags | 2 /* SkipObjectBaseClass */;
|
1008
1042
|
}
|
1009
|
-
if (flags &
|
1043
|
+
if (flags & 64 /* SkipTypeBaseClass */) {
|
1010
1044
|
classFlags = classFlags | 4 /* SkipTypeBaseClass */;
|
1011
1045
|
}
|
1012
1046
|
const classItr = getClassIterator(classType, classFlags, skipMroClass);
|
@@ -1055,39 +1089,41 @@ function* getClassMemberIterator(classType, memberName, flags = 0 /* Default */,
|
|
1055
1089
|
}
|
1056
1090
|
}
|
1057
1091
|
// Next look at class members.
|
1058
|
-
|
1059
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
1063
|
-
|
1064
|
-
|
1065
|
-
|
1066
|
-
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
1070
|
-
|
1071
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
1075
|
-
|
1092
|
+
if ((flags & 16 /* SkipClassVariables */) === 0) {
|
1093
|
+
const symbol = memberFields.get(memberName);
|
1094
|
+
if (symbol && symbol.isClassMember()) {
|
1095
|
+
const hasDeclaredType = symbol.hasTypedDeclarations();
|
1096
|
+
if (!declaredTypesOnly || hasDeclaredType) {
|
1097
|
+
let isInstanceMember = symbol.isInstanceMember();
|
1098
|
+
let isClassMember = true;
|
1099
|
+
// For data classes and typed dicts, variables that are declared
|
1100
|
+
// within the class are treated as instance variables. This distinction
|
1101
|
+
// is important in cases where a variable is a callable type because
|
1102
|
+
// we don't want to bind it to the instance like we would for a
|
1103
|
+
// class member.
|
1104
|
+
const isDataclass = types_1.ClassType.isDataClass(specializedMroClass);
|
1105
|
+
const isTypedDict = types_1.ClassType.isTypedDictClass(specializedMroClass);
|
1106
|
+
if (hasDeclaredType && (isDataclass || isTypedDict)) {
|
1107
|
+
const decls = symbol.getDeclarations();
|
1108
|
+
if (decls.length > 0 && decls[0].type === 1 /* Variable */) {
|
1109
|
+
isInstanceMember = true;
|
1110
|
+
isClassMember = isDataclass;
|
1111
|
+
}
|
1076
1112
|
}
|
1113
|
+
const cm = {
|
1114
|
+
symbol,
|
1115
|
+
isInstanceMember,
|
1116
|
+
isClassMember,
|
1117
|
+
isClassVar: symbol.isClassVar(),
|
1118
|
+
classType: specializedMroClass,
|
1119
|
+
isTypeDeclared: hasDeclaredType,
|
1120
|
+
skippedUndeclaredType,
|
1121
|
+
};
|
1122
|
+
yield cm;
|
1123
|
+
}
|
1124
|
+
else {
|
1125
|
+
skippedUndeclaredType = true;
|
1077
1126
|
}
|
1078
|
-
const cm = {
|
1079
|
-
symbol,
|
1080
|
-
isInstanceMember,
|
1081
|
-
isClassMember,
|
1082
|
-
isClassVar: symbol.isClassVar(),
|
1083
|
-
classType: specializedMroClass,
|
1084
|
-
isTypeDeclared: hasDeclaredType,
|
1085
|
-
skippedUndeclaredType,
|
1086
|
-
};
|
1087
|
-
yield cm;
|
1088
|
-
}
|
1089
|
-
else {
|
1090
|
-
skippedUndeclaredType = true;
|
1091
1127
|
}
|
1092
1128
|
}
|
1093
1129
|
}
|
@@ -1335,7 +1371,8 @@ function specializeClassType(type) {
|
|
1335
1371
|
const typeVarContext = new typeVarContext_1.TypeVarContext(getTypeVarScopeId(type));
|
1336
1372
|
const typeParams = types_1.ClassType.getTypeParameters(type);
|
1337
1373
|
typeParams.forEach((typeParam) => {
|
1338
|
-
|
1374
|
+
var _a;
|
1375
|
+
typeVarContext.setTypeVarType(typeParam, applySolvedTypeVars((_a = typeParam.details.defaultType) !== null && _a !== void 0 ? _a : types_1.UnknownType.create(), typeVarContext));
|
1339
1376
|
});
|
1340
1377
|
return applySolvedTypeVars(type, typeVarContext);
|
1341
1378
|
}
|
@@ -1788,6 +1825,12 @@ function containsAnyOrUnknown(type, recurse) {
|
|
1788
1825
|
}
|
1789
1826
|
visitFunction(type) {
|
1790
1827
|
if (this._recurse) {
|
1828
|
+
// A function with a "..." type is effectively an "Any".
|
1829
|
+
if (types_1.FunctionType.shouldSkipArgsKwargsCompatibilityCheck(type)) {
|
1830
|
+
this.anyOrUnknownType = this.anyOrUnknownType
|
1831
|
+
? preserveUnknown(this.anyOrUnknownType, types_1.AnyType.create())
|
1832
|
+
: types_1.AnyType.create();
|
1833
|
+
}
|
1791
1834
|
super.visitFunction(type);
|
1792
1835
|
}
|
1793
1836
|
}
|
@@ -2461,11 +2504,10 @@ class TypeVarTransformer {
|
|
2461
2504
|
return type;
|
2462
2505
|
}
|
2463
2506
|
let replacementType = type;
|
2464
|
-
// Recursively transform the results, but ensure that we don't replace
|
2465
|
-
// same
|
2507
|
+
// Recursively transform the results, but ensure that we don't replace any
|
2508
|
+
// type variables in the same scope recursively by setting it the scope in the
|
2466
2509
|
// _pendingTypeVarTransformations set.
|
2467
|
-
|
2468
|
-
if (!this._pendingTypeVarTransformations.has(typeVarName)) {
|
2510
|
+
if (!this._isTypeVarScopePending(type.scopeId)) {
|
2469
2511
|
if (type.details.isParamSpec) {
|
2470
2512
|
if (!type.paramSpecAccess) {
|
2471
2513
|
const paramSpecValue = this.transformParamSpec(type, recursionCount);
|
@@ -2477,9 +2519,13 @@ class TypeVarTransformer {
|
|
2477
2519
|
else {
|
2478
2520
|
replacementType = (_b = this.transformTypeVar(type, recursionCount)) !== null && _b !== void 0 ? _b : type;
|
2479
2521
|
if (!this._isTransformingTypeArg) {
|
2480
|
-
|
2522
|
+
if (type.scopeId) {
|
2523
|
+
this._pendingTypeVarTransformations.add(type.scopeId);
|
2524
|
+
}
|
2481
2525
|
replacementType = this.apply(replacementType, recursionCount);
|
2482
|
-
|
2526
|
+
if (type.scopeId) {
|
2527
|
+
this._pendingTypeVarTransformations.delete(type.scopeId);
|
2528
|
+
}
|
2483
2529
|
}
|
2484
2530
|
// If we're transforming a variadic type variable that was in a union,
|
2485
2531
|
// expand the union types.
|
@@ -2682,8 +2728,7 @@ class TypeVarTransformer {
|
|
2682
2728
|
}
|
2683
2729
|
}
|
2684
2730
|
else {
|
2685
|
-
|
2686
|
-
if (!this._pendingTypeVarTransformations.has(typeParamName)) {
|
2731
|
+
if (!this._isTypeVarScopePending(typeParam.scopeId)) {
|
2687
2732
|
const transformedType = this.transformTypeVar(typeParam, recursionCount);
|
2688
2733
|
replacementType = transformedType !== null && transformedType !== void 0 ? transformedType : typeParam;
|
2689
2734
|
if (replacementType !== typeParam) {
|
@@ -2857,6 +2902,9 @@ class TypeVarTransformer {
|
|
2857
2902
|
return newFunctionType;
|
2858
2903
|
});
|
2859
2904
|
}
|
2905
|
+
_isTypeVarScopePending(typeVarScopeId) {
|
2906
|
+
return !!typeVarScopeId && this._pendingTypeVarTransformations.has(typeVarScopeId);
|
2907
|
+
}
|
2860
2908
|
}
|
2861
2909
|
// For a TypeVar with a default type, validates whether the default type is using
|
2862
2910
|
// any other TypeVars that are not currently in scope.
|
@@ -2947,16 +2995,6 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
|
|
2947
2995
|
// don't transform that type variable.
|
2948
2996
|
if (typeVar.scopeId && this._typeVarContext.hasSolveForScope(typeVar.scopeId)) {
|
2949
2997
|
let replacement = signatureContext.getTypeVarType(typeVar, !!this._options.useNarrowBoundOnly);
|
2950
|
-
// If the type is unknown, see if there's a known wide bound that we can use.
|
2951
|
-
if (replacement &&
|
2952
|
-
(0, types_1.isUnknown)(replacement) &&
|
2953
|
-
!this._options.useNarrowBoundOnly &&
|
2954
|
-
this._options.unknownIfNotFound) {
|
2955
|
-
const entry = signatureContext.getTypeVar(typeVar);
|
2956
|
-
if (entry === null || entry === void 0 ? void 0 : entry.wideBound) {
|
2957
|
-
replacement = entry === null || entry === void 0 ? void 0 : entry.wideBound;
|
2958
|
-
}
|
2959
|
-
}
|
2960
2998
|
// If there was no narrow bound but there is a wide bound that
|
2961
2999
|
// contains literals or a TypeVar, we'll use the wide bound even if
|
2962
3000
|
// "useNarrowBoundOnly" is specified.
|
@@ -2994,7 +3032,10 @@ class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
|
|
2994
3032
|
});
|
2995
3033
|
}
|
2996
3034
|
}
|
2997
|
-
if ((0, types_1.isTypeVar)(replacement) &&
|
3035
|
+
if ((0, types_1.isTypeVar)(replacement) &&
|
3036
|
+
typeVar.isVariadicInUnion &&
|
3037
|
+
replacement.details.isVariadic &&
|
3038
|
+
!replacement.isVariadicInUnion) {
|
2998
3039
|
return types_1.TypeVarType.cloneForUnpacked(replacement, /* isInUnion */ true);
|
2999
3040
|
}
|
3000
3041
|
return replacement;
|