@zzzen/pyright-internal 1.2.0-dev.20230115 → 1.2.0-dev.20230129

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 (103) hide show
  1. package/dist/analyzer/binder.js +1 -1
  2. package/dist/analyzer/binder.js.map +1 -1
  3. package/dist/analyzer/checker.d.ts +1 -1
  4. package/dist/analyzer/checker.js +51 -38
  5. package/dist/analyzer/checker.js.map +1 -1
  6. package/dist/analyzer/constraintSolver.js +7 -6
  7. package/dist/analyzer/constraintSolver.js.map +1 -1
  8. package/dist/analyzer/enums.js +1 -1
  9. package/dist/analyzer/enums.js.map +1 -1
  10. package/dist/analyzer/importResolver.d.ts +2 -1
  11. package/dist/analyzer/importResolver.js +6 -1
  12. package/dist/analyzer/importResolver.js.map +1 -1
  13. package/dist/analyzer/importResult.d.ts +1 -0
  14. package/dist/analyzer/parseTreeUtils.d.ts +1 -0
  15. package/dist/analyzer/parseTreeUtils.js +70 -11
  16. package/dist/analyzer/parseTreeUtils.js.map +1 -1
  17. package/dist/analyzer/patternMatching.js +1 -1
  18. package/dist/analyzer/patternMatching.js.map +1 -1
  19. package/dist/analyzer/program.d.ts +3 -2
  20. package/dist/analyzer/program.js +19 -6
  21. package/dist/analyzer/program.js.map +1 -1
  22. package/dist/analyzer/regions.js +8 -12
  23. package/dist/analyzer/regions.js.map +1 -1
  24. package/dist/analyzer/service.js +1 -1
  25. package/dist/analyzer/service.js.map +1 -1
  26. package/dist/analyzer/sourceFile.d.ts +2 -2
  27. package/dist/analyzer/sourceFile.js +2 -2
  28. package/dist/analyzer/sourceFile.js.map +1 -1
  29. package/dist/analyzer/typeEvaluator.js +120 -24
  30. package/dist/analyzer/typeEvaluator.js.map +1 -1
  31. package/dist/analyzer/typeEvaluatorTypes.d.ts +0 -1
  32. package/dist/analyzer/typeGuards.js +5 -3
  33. package/dist/analyzer/typeGuards.js.map +1 -1
  34. package/dist/analyzer/typePrinter.js +32 -12
  35. package/dist/analyzer/typePrinter.js.map +1 -1
  36. package/dist/analyzer/typeUtils.d.ts +1 -0
  37. package/dist/analyzer/typeUtils.js +51 -4
  38. package/dist/analyzer/typeUtils.js.map +1 -1
  39. package/dist/analyzer/typedDicts.js +6 -2
  40. package/dist/analyzer/typedDicts.js.map +1 -1
  41. package/dist/analyzer/types.d.ts +5 -2
  42. package/dist/analyzer/types.js +29 -5
  43. package/dist/analyzer/types.js.map +1 -1
  44. package/dist/backgroundThreadBase.js +1 -0
  45. package/dist/backgroundThreadBase.js.map +1 -1
  46. package/dist/common/configOptions.d.ts +5 -0
  47. package/dist/common/configOptions.js +19 -1
  48. package/dist/common/configOptions.js.map +1 -1
  49. package/dist/common/envVarUtils.js +30 -7
  50. package/dist/common/envVarUtils.js.map +1 -1
  51. package/dist/languageServerBase.d.ts +2 -1
  52. package/dist/languageServerBase.js.map +1 -1
  53. package/dist/languageService/completionProvider.js +4 -11
  54. package/dist/languageService/completionProvider.js.map +1 -1
  55. package/dist/languageService/hoverProvider.d.ts +3 -1
  56. package/dist/languageService/hoverProvider.js +34 -32
  57. package/dist/languageService/hoverProvider.js.map +1 -1
  58. package/dist/languageService/indentationUtils.js +54 -43
  59. package/dist/languageService/indentationUtils.js.map +1 -1
  60. package/dist/languageService/tooltipUtils.d.ts +5 -1
  61. package/dist/languageService/tooltipUtils.js +60 -3
  62. package/dist/languageService/tooltipUtils.js.map +1 -1
  63. package/dist/localization/package.nls.en-us.json +1 -1
  64. package/dist/parser/parseNodes.js +0 -1
  65. package/dist/parser/parseNodes.js.map +1 -1
  66. package/dist/parser/stringTokenUtils.js +1 -1
  67. package/dist/parser/stringTokenUtils.js.map +1 -1
  68. package/dist/server.js +2 -0
  69. package/dist/server.js.map +1 -1
  70. package/dist/tests/fourslash/completions.commitChars.fourslash.js +23 -1
  71. package/dist/tests/fourslash/completions.commitChars.fourslash.js.map +1 -1
  72. package/dist/tests/fourslash/findDefinitions.namespaceImport.fourslash.js +2 -2
  73. package/dist/tests/fourslash/findDefinitions.namespaceImport.fourslash.js.map +1 -1
  74. package/dist/tests/fourslash/hover.formatted.fourslash.d.ts +1 -0
  75. package/dist/tests/fourslash/hover.formatted.fourslash.js +45 -0
  76. package/dist/tests/fourslash/hover.formatted.fourslash.js.map +1 -0
  77. package/dist/tests/fourslash/hover.overloadedFunction.fourslash.d.ts +1 -0
  78. package/dist/tests/fourslash/hover.overloadedFunction.fourslash.js +23 -0
  79. package/dist/tests/fourslash/hover.overloadedFunction.fourslash.js.map +1 -0
  80. package/dist/tests/harness/fourslash/testLanguageService.js +1 -0
  81. package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
  82. package/dist/tests/harness/fourslash/testState.d.ts +0 -10
  83. package/dist/tests/harness/fourslash/testState.js +15 -68
  84. package/dist/tests/harness/fourslash/testState.js.map +1 -1
  85. package/dist/tests/harness/fourslash/testStateUtils.d.ts +12 -0
  86. package/dist/tests/harness/fourslash/testStateUtils.js +98 -0
  87. package/dist/tests/harness/fourslash/testStateUtils.js.map +1 -0
  88. package/dist/tests/indentationUtils.test.js +51 -0
  89. package/dist/tests/indentationUtils.test.js.map +1 -1
  90. package/dist/tests/pathUtils.test.js +10 -0
  91. package/dist/tests/pathUtils.test.js.map +1 -1
  92. package/dist/tests/signatureHelp.test.d.ts +1 -0
  93. package/dist/tests/signatureHelp.test.js +73 -0
  94. package/dist/tests/signatureHelp.test.js.map +1 -0
  95. package/dist/tests/typeEvaluator1.test.js +12 -0
  96. package/dist/tests/typeEvaluator1.test.js.map +1 -1
  97. package/dist/tests/typeEvaluator2.test.js +4 -0
  98. package/dist/tests/typeEvaluator2.test.js.map +1 -1
  99. package/dist/tests/typeEvaluator3.test.js +9 -1
  100. package/dist/tests/typeEvaluator3.test.js.map +1 -1
  101. package/dist/tests/typeEvaluator4.test.js +10 -0
  102. package/dist/tests/typeEvaluator4.test.js.map +1 -1
  103. package/package.json +1 -1
@@ -205,6 +205,10 @@ 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
+ // In certain loops, it's possible to construct arbitrarily-deep containers
209
+ // (tuples, lists, sets, or dicts) which can lead to infinite type analysis.
210
+ // This limits the depth.
211
+ const maxInferredContainerDepth = 8;
208
212
  // Maximum recursion amount when comparing two recursive type aliases.
209
213
  // Increasing this can greatly increase the time required to evaluate
210
214
  // two recursive type aliases that have the same definition. Decreasing
@@ -1065,6 +1069,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
1065
1069
  return returnType;
1066
1070
  }
1067
1071
  function canBeFalsy(type, recursionCount = 0) {
1072
+ type = makeTopLevelTypeVarsConcrete(type);
1068
1073
  if (recursionCount > types_1.maxTypeRecursionCount) {
1069
1074
  return true;
1070
1075
  }
@@ -1132,6 +1137,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
1132
1137
  }
1133
1138
  }
1134
1139
  function canBeTruthy(type, recursionCount = 0) {
1140
+ type = makeTopLevelTypeVarsConcrete(type);
1135
1141
  if (recursionCount > types_1.maxTypeRecursionCount) {
1136
1142
  return true;
1137
1143
  }
@@ -1200,16 +1206,17 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
1200
1206
  // and return only the "None".
1201
1207
  function removeTruthinessFromType(type) {
1202
1208
  return (0, typeUtils_1.mapSubtypes)(type, (subtype) => {
1203
- if ((0, types_1.isClassInstance)(subtype)) {
1204
- if (subtype.literalValue !== undefined) {
1209
+ const concreteSubtype = makeTopLevelTypeVarsConcrete(subtype);
1210
+ if ((0, types_1.isClassInstance)(concreteSubtype)) {
1211
+ if (concreteSubtype.literalValue !== undefined) {
1205
1212
  // If the object is already definitely falsy, it's fine to
1206
1213
  // include, otherwise it should be removed.
1207
- return !subtype.literalValue ? subtype : undefined;
1214
+ return !concreteSubtype.literalValue ? subtype : undefined;
1208
1215
  }
1209
1216
  // If the object is a bool, make it "false", since
1210
1217
  // "true" is a truthy value.
1211
- if (types_1.ClassType.isBuiltIn(subtype, 'bool')) {
1212
- return types_1.ClassType.cloneWithLiteral(subtype, /* value */ false);
1218
+ if (types_1.ClassType.isBuiltIn(concreteSubtype, 'bool')) {
1219
+ return types_1.ClassType.cloneWithLiteral(concreteSubtype, /* value */ false);
1213
1220
  }
1214
1221
  }
1215
1222
  // If it's possible for the type to be falsy, include it.
@@ -1225,16 +1232,17 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
1225
1232
  // and return only the "int".
1226
1233
  function removeFalsinessFromType(type) {
1227
1234
  return (0, typeUtils_1.mapSubtypes)(type, (subtype) => {
1228
- if ((0, types_1.isClassInstance)(subtype)) {
1229
- if (subtype.literalValue !== undefined) {
1235
+ const concreteSubtype = makeTopLevelTypeVarsConcrete(subtype);
1236
+ if ((0, types_1.isClassInstance)(concreteSubtype)) {
1237
+ if (concreteSubtype.literalValue !== undefined) {
1230
1238
  // If the object is already definitely truthy, it's fine to
1231
1239
  // include, otherwise it should be removed.
1232
- return subtype.literalValue ? subtype : undefined;
1240
+ return concreteSubtype.literalValue ? subtype : undefined;
1233
1241
  }
1234
1242
  // If the object is a bool, make it "true", since
1235
1243
  // "false" is a falsy value.
1236
- if (types_1.ClassType.isBuiltIn(subtype, 'bool')) {
1237
- return types_1.ClassType.cloneWithLiteral(subtype, /* value */ true);
1244
+ if (types_1.ClassType.isBuiltIn(concreteSubtype, 'bool')) {
1245
+ return types_1.ClassType.cloneWithLiteral(concreteSubtype, /* value */ true);
1238
1246
  }
1239
1247
  }
1240
1248
  // If it's possible for the type to be truthy, include it.
@@ -4997,6 +5005,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
4997
5005
  return { type: types_1.UnknownType.create() };
4998
5006
  }
4999
5007
  const type = (0, typeUtils_1.convertToInstance)((0, typeUtils_1.specializeTupleClass)(tupleClassType, buildTupleTypesList(entryTypeResults)));
5008
+ if (isIncomplete) {
5009
+ if ((0, typeUtils_1.getContainerDepth)(type) > maxInferredContainerDepth) {
5010
+ return { type: types_1.UnknownType.create() };
5011
+ }
5012
+ }
5000
5013
  return { type, isIncomplete };
5001
5014
  }
5002
5015
  function buildTupleTypesList(entryTypeResults) {
@@ -5404,12 +5417,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
5404
5417
  const matchedOverloads = [];
5405
5418
  let isTypeIncomplete = false;
5406
5419
  const overloadsUsedForCall = [];
5420
+ let isDefinitiveMatchFound = false;
5407
5421
  for (let expandedTypesIndex = 0; expandedTypesIndex < expandedArgTypes.length; expandedTypesIndex++) {
5408
5422
  let matchedOverload;
5409
5423
  const argTypeOverride = expandedArgTypes[expandedTypesIndex];
5410
5424
  const hasArgTypeOverride = argTypeOverride.some((a) => a !== undefined);
5411
5425
  const possibleMatchResults = [];
5412
- let isDefinitiveMatchFound = false;
5426
+ isDefinitiveMatchFound = false;
5413
5427
  for (let overloadIndex = 0; overloadIndex < argParamMatches.length; overloadIndex++) {
5414
5428
  const overload = argParamMatches[overloadIndex].overload;
5415
5429
  let matchResults = argParamMatches[overloadIndex];
@@ -5496,7 +5510,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
5496
5510
  // resulting type var context back into the caller's type var context.
5497
5511
  // Use the type var context from the last matched overload because it
5498
5512
  // includes the type var solutions for all earlier matched overloads.
5499
- if (typeVarContext) {
5513
+ if (typeVarContext && isDefinitiveMatchFound) {
5500
5514
  typeVarContext.copyFromClone(matchedOverloads[matchedOverloads.length - 1].typeVarContext);
5501
5515
  }
5502
5516
  // And run through the first expanded argument list one more time to
@@ -8275,6 +8289,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8275
8289
  const leftExpression = node.leftExpression;
8276
8290
  let rightExpression = node.rightExpression;
8277
8291
  let isIncomplete = false;
8292
+ let typeErrors = false;
8278
8293
  // If this is a comparison and the left expression is also a comparison,
8279
8294
  // we need to change the behavior to accommodate python's "chained
8280
8295
  // comparisons" feature.
@@ -8429,6 +8444,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8429
8444
  const isTupleAddAllowed = !(0, types_1.isUnion)(leftType);
8430
8445
  let type = validateBinaryOperation(node.operator, { type: leftType, isIncomplete: leftTypeResult.isIncomplete }, { type: rightType, isIncomplete: rightTypeResult.isIncomplete }, node, inferenceContext, diag, { isLiteralMathAllowed, isTupleAddAllowed });
8431
8446
  if (!diag.isEmpty() || !type) {
8447
+ typeErrors = true;
8432
8448
  if (!isIncomplete) {
8433
8449
  const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
8434
8450
  if (isLeftOptionalType && diag.getMessages().length === 1) {
@@ -8450,7 +8466,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8450
8466
  }
8451
8467
  type = types_1.UnknownType.create();
8452
8468
  }
8453
- return { type, isIncomplete };
8469
+ return { type, isIncomplete, typeErrors };
8454
8470
  }
8455
8471
  function customMetaclassSupportsMethod(type, methodName) {
8456
8472
  if (!(0, types_1.isInstantiableClass)(type)) {
@@ -9048,6 +9064,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
9048
9064
  /* includeSubclasses */ undefined,
9049
9065
  /* TupleTypeArguments */ undefined, isEmptyContainer))
9050
9066
  : types_1.UnknownType.create();
9067
+ if (isIncomplete) {
9068
+ if ((0, typeUtils_1.getContainerDepth)(type) > maxInferredContainerDepth) {
9069
+ return { type: types_1.UnknownType.create() };
9070
+ }
9071
+ }
9051
9072
  return { type, isIncomplete };
9052
9073
  }
9053
9074
  function getKeyAndValueTypesFromDictionary(node, keyTypes, valueTypes, forceStrictInference, expectedKeyType, expectedValueType, expectedTypedDictEntries, expectedDiagAddendum) {
@@ -9330,6 +9351,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
9330
9351
  /* includeSubclasses */ undefined,
9331
9352
  /* TupleTypeArguments */ undefined, isEmptyContainer))
9332
9353
  : types_1.UnknownType.create();
9354
+ if (isIncomplete) {
9355
+ if ((0, typeUtils_1.getContainerDepth)(type) > maxInferredContainerDepth) {
9356
+ return { type: types_1.UnknownType.create() };
9357
+ }
9358
+ }
9333
9359
  return { type, isIncomplete, typeErrors };
9334
9360
  }
9335
9361
  function verifySetEntryOrDictKeyIsHashable(entry, type, isDictKey) {
@@ -10959,6 +10985,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
10959
10985
  let protocolTypeParameters;
10960
10986
  const initSubclassArgs = [];
10961
10987
  let metaclassNode;
10988
+ let isMetaclassDeferred = false;
10962
10989
  let exprFlags = 128 /* ExpectingType */ |
10963
10990
  1024 /* AllowGenericClassType */ |
10964
10991
  262144 /* DisallowNakedGeneric */ |
@@ -10990,14 +11017,16 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
10990
11017
  argType = types_1.UnknownType.create();
10991
11018
  }
10992
11019
  else {
10993
- if (types_1.ClassType.isPartiallyEvaluated(argType)) {
11020
+ if (types_1.ClassType.isPartiallyEvaluated(argType) ||
11021
+ argType.details.mro.some((t) => (0, types_1.isClass)(t) && types_1.ClassType.isPartiallyEvaluated(t))) {
10994
11022
  // If the base class is partially evaluated, install a callback
10995
11023
  // so we can fix up this class (e.g. compute the MRO) when the
10996
11024
  // dependent class is completed.
10997
11025
  classTypeHooks.push({
10998
11026
  dependency: argType,
10999
- callback: () => completeClassTypeDeferred(classType, node.name),
11027
+ callback: () => completeClassTypeDeferred(classType, node, node.name),
11000
11028
  });
11029
+ isMetaclassDeferred = true;
11001
11030
  }
11002
11031
  if (types_1.ClassType.isBuiltIn(argType, 'Protocol')) {
11003
11032
  if (!fileInfo.isStubFile &&
@@ -11377,6 +11406,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11377
11406
  if (types_1.ClassType.isBuiltIn(classType, 'UnionType')) {
11378
11407
  unionType = types_1.ClassType.cloneAsInstance(classType);
11379
11408
  }
11409
+ // Validate that arguments passed to `__init_subclass__` are of the correct type.
11410
+ // Defer this if the metaclass calculation is deferred.
11411
+ if (!isMetaclassDeferred) {
11412
+ validateInitSubclassArgs(node, classType);
11413
+ }
11380
11414
  return { classType, decoratedType };
11381
11415
  }
11382
11416
  // Determines whether the type parameters has a default that refers to another
@@ -11517,6 +11551,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11517
11551
  effectiveMetaclass = baseClassMeta ? types_1.UnknownType.create() : undefined;
11518
11552
  break;
11519
11553
  }
11554
+ if (types_1.ClassType.isEnumClass(baseClass)) {
11555
+ classType.details.flags |= 1048576 /* EnumClass */;
11556
+ }
11520
11557
  }
11521
11558
  else {
11522
11559
  // If one of the base classes is unknown, then the effective
@@ -11647,15 +11684,29 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11647
11684
  }
11648
11685
  // Recomputes the MRO and effective metaclass for the class after dependent
11649
11686
  // classes have been fully constructed.
11650
- function completeClassTypeDeferred(type, errorNode) {
11687
+ function completeClassTypeDeferred(type, node, errorNode) {
11651
11688
  // Recompute the MRO linearization.
11652
11689
  if (!(0, typeUtils_1.computeMroLinearization)(type)) {
11653
11690
  addError(localize_1.Localizer.Diagnostic.methodOrdering(), errorNode);
11654
11691
  }
11655
11692
  // Recompute the effective metaclass.
11656
11693
  computeEffectiveMetaclass(type, errorNode);
11694
+ validateInitSubclassArgs(node, type);
11657
11695
  }
11658
- function validateInitSubclassArgs(node, classType, argList) {
11696
+ function validateInitSubclassArgs(node, classType) {
11697
+ // Collect arguments that will be passed to the `__init_subclass__`
11698
+ // method described in PEP 487 and validate it.
11699
+ const argList = [];
11700
+ node.arguments.forEach((arg) => {
11701
+ if (arg.name && arg.name.value !== 'metaclass') {
11702
+ argList.push({
11703
+ argumentCategory: 0 /* Simple */,
11704
+ node: arg,
11705
+ name: arg.name,
11706
+ valueExpression: arg.valueExpression,
11707
+ });
11708
+ }
11709
+ });
11659
11710
  const errorNode = argList.length > 0 ? argList[0].node.name : node.name;
11660
11711
  const initSubclassMethodInfo = getTypeOfClassMemberName(errorNode, classType,
11661
11712
  /* isAccessedThroughObject */ false, '__init_subclass__', { method: 'get' },
@@ -13208,6 +13259,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
13208
13259
  nodeToEvaluate = argumentNode.parent;
13209
13260
  continue;
13210
13261
  }
13262
+ if (argumentNode.parent.nodeType === 10 /* Class */) {
13263
+ // If this is an argument node within a class declaration,
13264
+ // evaluate the full class declaration node.
13265
+ getTypeOfClass(argumentNode.parent);
13266
+ return;
13267
+ }
13211
13268
  }
13212
13269
  let parent = nodeToEvaluate.parent;
13213
13270
  if (!parent) {
@@ -14809,6 +14866,17 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
14809
14866
  }
14810
14867
  });
14811
14868
  }
14869
+ else {
14870
+ // Handle the case where there are multiple imports — one of them in
14871
+ // a try block and one or more in except blocks. In this case, we'll
14872
+ // use the one in the try block rather than the excepts.
14873
+ if (decls.length > 1 && decls.every((decl) => decl.type === 8 /* Alias */)) {
14874
+ const nonExceptDecls = decls.filter((decl) => decl.type === 8 /* Alias */ && !decl.isInExceptSuite);
14875
+ if (nonExceptDecls.length === 1) {
14876
+ declIndexToConsider = decls.findIndex((decl) => decl === nonExceptDecls[0]);
14877
+ }
14878
+ }
14879
+ }
14812
14880
  let sawExplicitTypeAlias = false;
14813
14881
  decls.forEach((decl, index) => {
14814
14882
  var _a, _b;
@@ -16164,7 +16232,23 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16164
16232
  if ((0, types_1.isOverloadedFunction)(destType)) {
16165
16233
  const overloadDiag = diag === null || diag === void 0 ? void 0 : diag.createAddendum();
16166
16234
  // All overloads in the dest must be assignable.
16167
- const isAssignable = types_1.OverloadedFunctionType.getOverloads(destType).every((destOverload) => {
16235
+ const destOverloads = types_1.OverloadedFunctionType.getOverloads(destType);
16236
+ // If the source is also an overload with the same number of overloads,
16237
+ // there's a good chance that there's a one-to-one mapping. Try this
16238
+ // first before using an n^2 algorithm.
16239
+ if ((0, types_1.isOverloadedFunction)(srcType)) {
16240
+ const srcOverloads = types_1.OverloadedFunctionType.getOverloads(srcType);
16241
+ if (destOverloads.length === srcOverloads.length) {
16242
+ if (destOverloads.every((destOverload, index) => {
16243
+ const srcOverload = srcOverloads[index];
16244
+ return assignType(destOverload, srcOverload,
16245
+ /* diag */ undefined, destTypeVarContext !== null && destTypeVarContext !== void 0 ? destTypeVarContext : new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(destOverload)), srcTypeVarContext, flags, recursionCount);
16246
+ })) {
16247
+ return true;
16248
+ }
16249
+ }
16250
+ }
16251
+ const isAssignable = destOverloads.every((destOverload) => {
16168
16252
  if (destTypeVarContext) {
16169
16253
  destTypeVarContext.addSolveForScope((0, typeUtils_1.getTypeVarScopeId)(destOverload));
16170
16254
  }
@@ -16549,6 +16633,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16549
16633
  if (constructorFunction.specializedTypes) {
16550
16634
  constructorFunction.specializedTypes.returnType = objectType;
16551
16635
  }
16636
+ if (!constructorFunction.details.docString && classType.details.docString) {
16637
+ constructorFunction.details.docString = classType.details.docString;
16638
+ }
16552
16639
  }
16553
16640
  return constructorFunction;
16554
16641
  };
@@ -16577,10 +16664,17 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16577
16664
  if (newInfo) {
16578
16665
  const newType = getTypeOfMember(newInfo);
16579
16666
  const convertNewToConstructor = (newSubtype) => {
16580
- return bindFunctionToClassOrObject(classType, newSubtype,
16667
+ let constructorFunction = bindFunctionToClassOrObject(classType, newSubtype,
16581
16668
  /* memberClass */ undefined,
16582
16669
  /* errorNode */ undefined, recursionCount,
16583
16670
  /* treatConstructorAsClassMember */ true);
16671
+ if (constructorFunction) {
16672
+ constructorFunction = types_1.FunctionType.clone(constructorFunction);
16673
+ if (!constructorFunction.details.docString && classType.details.docString) {
16674
+ constructorFunction.details.docString = classType.details.docString;
16675
+ }
16676
+ }
16677
+ return constructorFunction;
16584
16678
  };
16585
16679
  if ((0, types_1.isFunction)(newType)) {
16586
16680
  return convertNewToConstructor(newType);
@@ -16606,6 +16700,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16606
16700
  const constructorFunction = types_1.FunctionType.createSynthesizedInstance('__new__', 1 /* ConstructorMethod */);
16607
16701
  constructorFunction.details.declaredReturnType = types_1.ClassType.cloneAsInstance(classType);
16608
16702
  types_1.FunctionType.addDefaultParameters(constructorFunction);
16703
+ if (!constructorFunction.details.docString && classType.details.docString) {
16704
+ constructorFunction.details.docString = classType.details.docString;
16705
+ }
16609
16706
  return constructorFunction;
16610
16707
  }
16611
16708
  // If the class is a protocol and it has a `__call__` method but no other methods
@@ -17772,10 +17869,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17772
17869
  types_1.OverloadedFunctionType.addOverload(newOverloadType, boundMethod);
17773
17870
  }
17774
17871
  });
17775
- if (newOverloadType.overloads.length === 1) {
17776
- return newOverloadType.overloads[0];
17777
- }
17778
- else if (newOverloadType.overloads.length === 0) {
17872
+ if (types_1.OverloadedFunctionType.getOverloads(newOverloadType).length === 0) {
17779
17873
  // No overloads matched, so rebind with the errorNode
17780
17874
  // to report the error(s) to the user.
17781
17875
  if (errorNode) {
@@ -17785,6 +17879,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17785
17879
  }
17786
17880
  return undefined;
17787
17881
  }
17882
+ else if (newOverloadType.overloads.length === 1) {
17883
+ return newOverloadType.overloads[0];
17884
+ }
17788
17885
  return newOverloadType;
17789
17886
  }
17790
17887
  return memberType;
@@ -17976,7 +18073,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17976
18073
  narrowConstrainedTypeVar,
17977
18074
  assignType,
17978
18075
  validateOverrideMethod,
17979
- validateInitSubclassArgs,
17980
18076
  assignTypeToExpression,
17981
18077
  assignClassToSelf,
17982
18078
  getTypedDictClassType,