@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.
Files changed (191) hide show
  1. package/dist/analyzer/binder.js +4 -1
  2. package/dist/analyzer/binder.js.map +1 -1
  3. package/dist/analyzer/checker.js +40 -14
  4. package/dist/analyzer/checker.js.map +1 -1
  5. package/dist/analyzer/codeFlowEngine.js +1 -2
  6. package/dist/analyzer/codeFlowEngine.js.map +1 -1
  7. package/dist/analyzer/constraintSolver.js +5 -0
  8. package/dist/analyzer/constraintSolver.js.map +1 -1
  9. package/dist/analyzer/constructors.js +16 -7
  10. package/dist/analyzer/constructors.js.map +1 -1
  11. package/dist/analyzer/declarationUtils.js +2 -0
  12. package/dist/analyzer/declarationUtils.js.map +1 -1
  13. package/dist/analyzer/decorators.js +16 -1
  14. package/dist/analyzer/decorators.js.map +1 -1
  15. package/dist/analyzer/deprecatedSymbols.js +13 -2
  16. package/dist/analyzer/deprecatedSymbols.js.map +1 -1
  17. package/dist/analyzer/importResolver.d.ts +6 -4
  18. package/dist/analyzer/importResolver.js +20 -18
  19. package/dist/analyzer/importResolver.js.map +1 -1
  20. package/dist/analyzer/namedTuples.js +1 -1
  21. package/dist/analyzer/namedTuples.js.map +1 -1
  22. package/dist/analyzer/packageTypeVerifier.d.ts +3 -3
  23. package/dist/analyzer/packageTypeVerifier.js +8 -11
  24. package/dist/analyzer/packageTypeVerifier.js.map +1 -1
  25. package/dist/analyzer/parentDirectoryCache.js +1 -1
  26. package/dist/analyzer/parentDirectoryCache.js.map +1 -1
  27. package/dist/analyzer/program.d.ts +9 -22
  28. package/dist/analyzer/program.js +117 -105
  29. package/dist/analyzer/program.js.map +1 -1
  30. package/dist/analyzer/protocols.js +3 -1
  31. package/dist/analyzer/protocols.js.map +1 -1
  32. package/dist/analyzer/pythonPathUtils.js +10 -8
  33. package/dist/analyzer/pythonPathUtils.js.map +1 -1
  34. package/dist/analyzer/service.d.ts +6 -3
  35. package/dist/analyzer/service.js +40 -20
  36. package/dist/analyzer/service.js.map +1 -1
  37. package/dist/analyzer/sourceFile.d.ts +6 -4
  38. package/dist/analyzer/sourceFile.js +9 -16
  39. package/dist/analyzer/sourceFile.js.map +1 -1
  40. package/dist/analyzer/sourceFileInfo.d.ts +62 -0
  41. package/dist/analyzer/sourceFileInfo.js +145 -0
  42. package/dist/analyzer/sourceFileInfo.js.map +1 -0
  43. package/dist/analyzer/sourceMapper.d.ts +1 -1
  44. package/dist/analyzer/typeDocStringUtils.js +1 -1
  45. package/dist/analyzer/typeEvaluator.js +361 -262
  46. package/dist/analyzer/typeEvaluator.js.map +1 -1
  47. package/dist/analyzer/typeEvaluatorTypes.d.ts +10 -8
  48. package/dist/analyzer/typeEvaluatorTypes.js +11 -8
  49. package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
  50. package/dist/analyzer/typeGuards.js +116 -20
  51. package/dist/analyzer/typeGuards.js.map +1 -1
  52. package/dist/analyzer/typeUtils.d.ts +6 -4
  53. package/dist/analyzer/typeUtils.js +104 -63
  54. package/dist/analyzer/typeUtils.js.map +1 -1
  55. package/dist/analyzer/typeWalker.js +1 -1
  56. package/dist/analyzer/typeWalker.js.map +1 -1
  57. package/dist/analyzer/types.d.ts +1 -0
  58. package/dist/analyzer/types.js +8 -0
  59. package/dist/analyzer/types.js.map +1 -1
  60. package/dist/backgroundAnalysis.d.ts +1 -2
  61. package/dist/backgroundAnalysis.js +2 -2
  62. package/dist/backgroundAnalysis.js.map +1 -1
  63. package/dist/backgroundAnalysisBase.d.ts +1 -2
  64. package/dist/backgroundAnalysisBase.js +4 -4
  65. package/dist/backgroundAnalysisBase.js.map +1 -1
  66. package/dist/backgroundThreadBase.d.ts +1 -1
  67. package/dist/backgroundThreadBase.js +1 -0
  68. package/dist/backgroundThreadBase.js.map +1 -1
  69. package/dist/common/commandLineOptions.d.ts +1 -0
  70. package/dist/common/commandLineOptions.js.map +1 -1
  71. package/dist/common/configOptions.d.ts +4 -1
  72. package/dist/common/configOptions.js +18 -5
  73. package/dist/common/configOptions.js.map +1 -1
  74. package/dist/common/console.d.ts +3 -0
  75. package/dist/common/console.js +8 -1
  76. package/dist/common/console.js.map +1 -1
  77. package/dist/common/extensibility.d.ts +10 -1
  78. package/dist/common/extensibility.js.map +1 -1
  79. package/dist/common/fileSystem.d.ts +3 -0
  80. package/dist/common/fileSystem.js +8 -1
  81. package/dist/common/fileSystem.js.map +1 -1
  82. package/dist/common/pathUtils.d.ts +2 -15
  83. package/dist/common/pathUtils.js +9 -84
  84. package/dist/common/pathUtils.js.map +1 -1
  85. package/dist/common/realFileSystem.js +22 -13
  86. package/dist/common/realFileSystem.js.map +1 -1
  87. package/dist/common/serviceProvider.d.ts +1 -4
  88. package/dist/common/serviceProvider.js +4 -4
  89. package/dist/common/serviceProvider.js.map +1 -1
  90. package/dist/common/serviceProviderExtensions.d.ts +10 -4
  91. package/dist/common/serviceProviderExtensions.js +43 -1
  92. package/dist/common/serviceProviderExtensions.js.map +1 -1
  93. package/dist/languageServerBase.d.ts +9 -9
  94. package/dist/languageServerBase.js +5 -4
  95. package/dist/languageServerBase.js.map +1 -1
  96. package/dist/languageService/analyzerServiceExecutor.js +3 -2
  97. package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
  98. package/dist/languageService/completionProvider.d.ts +7 -5
  99. package/dist/languageService/completionProvider.js +190 -176
  100. package/dist/languageService/completionProvider.js.map +1 -1
  101. package/dist/languageService/completionProviderUtils.d.ts +1 -1
  102. package/dist/languageService/completionProviderUtils.js +1 -1
  103. package/dist/languageService/completionProviderUtils.js.map +1 -1
  104. package/dist/localization/localize.d.ts +14 -0
  105. package/dist/localization/localize.js +8 -0
  106. package/dist/localization/localize.js.map +1 -1
  107. package/dist/localization/package.nls.cs.json +26 -17
  108. package/dist/localization/package.nls.de.json +26 -17
  109. package/dist/localization/package.nls.en-us.json +9 -2
  110. package/dist/localization/package.nls.es.json +26 -17
  111. package/dist/localization/package.nls.fr.json +26 -17
  112. package/dist/localization/package.nls.it.json +26 -17
  113. package/dist/localization/package.nls.ja.json +26 -17
  114. package/dist/localization/package.nls.ko.json +26 -17
  115. package/dist/localization/package.nls.pl.json +26 -17
  116. package/dist/localization/package.nls.pt-br.json +26 -17
  117. package/dist/localization/package.nls.qps-ploc.json +14 -5
  118. package/dist/localization/package.nls.ru.json +26 -17
  119. package/dist/localization/package.nls.tr.json +26 -17
  120. package/dist/localization/package.nls.zh-cn.json +26 -17
  121. package/dist/localization/package.nls.zh-tw.json +26 -17
  122. package/dist/pyright.js +6 -4
  123. package/dist/pyright.js.map +1 -1
  124. package/dist/server.d.ts +2 -2
  125. package/dist/server.js +8 -10
  126. package/dist/server.js.map +1 -1
  127. package/dist/tests/chainedSourceFiles.test.js +4 -1
  128. package/dist/tests/chainedSourceFiles.test.js.map +1 -1
  129. package/dist/tests/checker.test.js +11 -11
  130. package/dist/tests/checker.test.js.map +1 -1
  131. package/dist/tests/completions.test.js +57 -0
  132. package/dist/tests/completions.test.js.map +1 -1
  133. package/dist/tests/config.test.js +28 -22
  134. package/dist/tests/config.test.js.map +1 -1
  135. package/dist/tests/fourslash/completions.dictionary.keys.complex.fourslash.js +5 -5
  136. package/dist/tests/fourslash/completions.dictionary.keys.complex.fourslash.js.map +1 -1
  137. package/dist/tests/fourslash/completions.dictionary.keys.expression.fourslash.js +11 -9
  138. package/dist/tests/fourslash/completions.dictionary.keys.expression.fourslash.js.map +1 -1
  139. package/dist/tests/fourslash/completions.dictionary.keys.literalTypes.fourslash.js +14 -14
  140. package/dist/tests/fourslash/completions.dictionary.keys.literalTypes.fourslash.js.map +1 -1
  141. package/dist/tests/fourslash/completions.dictionary.keys.simple.fourslash.js +12 -12
  142. package/dist/tests/fourslash/completions.dictionary.keys.simple.fourslash.js.map +1 -1
  143. package/dist/tests/fourslash/completions.dictionary.keys.stringLiterals.fourslash.js +9 -9
  144. package/dist/tests/fourslash/completions.dictionary.keys.stringLiterals.fourslash.js.map +1 -1
  145. package/dist/tests/fourslash/completions.dictionary.keys.symbols.fourslash.js +3 -3
  146. package/dist/tests/fourslash/completions.dictionary.keys.symbols.fourslash.js.map +1 -1
  147. package/dist/tests/fourslash/completions.fstring.stringLiteral.fourslash.js +3 -3
  148. package/dist/tests/fourslash/completions.fstring.stringLiteral.fourslash.js.map +1 -1
  149. package/dist/tests/fourslash/completions.indexer.keys.getitem.fourslash.js +4 -4
  150. package/dist/tests/fourslash/completions.indexer.keys.getitem.fourslash.js.map +1 -1
  151. package/dist/tests/fourslash/fourslash.d.ts +1 -0
  152. package/dist/tests/fourslash/missingModuleSource.fourslash.js +4 -1
  153. package/dist/tests/fourslash/missingModuleSource.fourslash.js.map +1 -1
  154. package/dist/tests/harness/fourslash/testLanguageService.js +4 -1
  155. package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
  156. package/dist/tests/harness/fourslash/testState.Consts.d.ts +1 -0
  157. package/dist/tests/harness/fourslash/testState.Consts.js +2 -0
  158. package/dist/tests/harness/fourslash/testState.Consts.js.map +1 -1
  159. package/dist/tests/harness/fourslash/testState.d.ts +2 -0
  160. package/dist/tests/harness/fourslash/testState.js +9 -2
  161. package/dist/tests/harness/fourslash/testState.js.map +1 -1
  162. package/dist/tests/harness/vfs/filesystem.js +10 -6
  163. package/dist/tests/harness/vfs/filesystem.js.map +1 -1
  164. package/dist/tests/importResolver.test.js +14 -9
  165. package/dist/tests/importResolver.test.js.map +1 -1
  166. package/dist/tests/localizer.test.js +1 -1
  167. package/dist/tests/localizer.test.js.map +1 -1
  168. package/dist/tests/pathUtils.test.js +13 -21
  169. package/dist/tests/pathUtils.test.js.map +1 -1
  170. package/dist/tests/service.test.js +55 -0
  171. package/dist/tests/service.test.js.map +1 -1
  172. package/dist/tests/sourceFile.test.js +4 -2
  173. package/dist/tests/sourceFile.test.js.map +1 -1
  174. package/dist/tests/testState.test.js +1 -1
  175. package/dist/tests/testState.test.js.map +1 -1
  176. package/dist/tests/testUtils.js +3 -5
  177. package/dist/tests/testUtils.js.map +1 -1
  178. package/dist/tests/typeEvaluator1.test.js +2 -2
  179. package/dist/tests/typeEvaluator2.test.js +5 -1
  180. package/dist/tests/typeEvaluator2.test.js.map +1 -1
  181. package/dist/tests/typeEvaluator3.test.js +8 -4
  182. package/dist/tests/typeEvaluator3.test.js.map +1 -1
  183. package/dist/tests/typeEvaluator4.test.js +4 -0
  184. package/dist/tests/typeEvaluator4.test.js.map +1 -1
  185. package/dist/tests/typeEvaluator5.test.js +1 -1
  186. package/dist/tests/workspaceEditUtils.test.js +24 -20
  187. package/dist/tests/workspaceEditUtils.test.js.map +1 -1
  188. package/dist/workspaceFactory.d.ts +1 -0
  189. package/dist/workspaceFactory.js +7 -4
  190. package/dist/workspaceFactory.js.map +1 -1
  191. 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"] = 16] = "DeclaredTypesOnly";
42
+ ClassMemberLookupFlags[ClassMemberLookupFlags["DeclaredTypesOnly"] = 32] = "DeclaredTypesOnly";
40
43
  // Skip the 'type' base class in particular.
41
- ClassMemberLookupFlags[ClassMemberLookupFlags["SkipTypeBaseClass"] = 32] = "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
- for (let i = 0; i < type.subtypes.length; i++) {
204
- const subtype = type.subtypes[i];
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 = type.subtypes.slice(0, i);
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 < type.subtypes.length; i++) {
217
- accumulateSubtype(callback(type.subtypes[i]));
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
- return aName < bName ? -1 : aName === bName ? 0 : 1;
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 & 16 /* DeclaredTypesOnly */) !== 0;
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 & 32 /* SkipTypeBaseClass */) {
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
- const symbol = memberFields.get(memberName);
1059
- if (symbol && symbol.isClassMember()) {
1060
- const hasDeclaredType = symbol.hasTypedDeclarations();
1061
- if (!declaredTypesOnly || hasDeclaredType) {
1062
- let isInstanceMember = symbol.isInstanceMember();
1063
- let isClassMember = true;
1064
- // For data classes and typed dicts, variables that are declared
1065
- // within the class are treated as instance variables. This distinction
1066
- // is important in cases where a variable is a callable type because
1067
- // we don't want to bind it to the instance like we would for a
1068
- // class member.
1069
- const isDataclass = types_1.ClassType.isDataClass(specializedMroClass);
1070
- const isTypedDict = types_1.ClassType.isTypedDictClass(specializedMroClass);
1071
- if (hasDeclaredType && (isDataclass || isTypedDict)) {
1072
- const decls = symbol.getDeclarations();
1073
- if (decls.length > 0 && decls[0].type === 1 /* Variable */) {
1074
- isInstanceMember = true;
1075
- isClassMember = isDataclass;
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
- typeVarContext.setTypeVarType(typeParam, types_1.UnknownType.create());
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 the
2465
- // same type variable recursively by setting it in the
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
- const typeVarName = types_1.TypeVarType.getNameWithScope(type);
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
- this._pendingTypeVarTransformations.add(typeVarName);
2522
+ if (type.scopeId) {
2523
+ this._pendingTypeVarTransformations.add(type.scopeId);
2524
+ }
2481
2525
  replacementType = this.apply(replacementType, recursionCount);
2482
- this._pendingTypeVarTransformations.delete(typeVarName);
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
- const typeParamName = types_1.TypeVarType.getNameWithScope(typeParam);
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) && typeVar.isVariadicInUnion && !replacement.isVariadicInUnion) {
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;