@zzzen/pyright-internal 1.2.0-dev.20250209 → 1.2.0-dev.20250216

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 (108) hide show
  1. package/dist/analyzer/checker.d.ts +1 -1
  2. package/dist/analyzer/checker.js +30 -84
  3. package/dist/analyzer/checker.js.map +1 -1
  4. package/dist/analyzer/constraintTracker.d.ts +2 -2
  5. package/dist/analyzer/constraintTracker.js +11 -5
  6. package/dist/analyzer/constraintTracker.js.map +1 -1
  7. package/dist/analyzer/constructors.js +2 -2
  8. package/dist/analyzer/constructors.js.map +1 -1
  9. package/dist/analyzer/importResolver.d.ts +1 -1
  10. package/dist/analyzer/program.d.ts +1 -0
  11. package/dist/analyzer/program.js +4 -1
  12. package/dist/analyzer/program.js.map +1 -1
  13. package/dist/analyzer/protocols.js +26 -11
  14. package/dist/analyzer/protocols.js.map +1 -1
  15. package/dist/analyzer/service.d.ts +1 -0
  16. package/dist/analyzer/service.js +3 -1
  17. package/dist/analyzer/service.js.map +1 -1
  18. package/dist/analyzer/sourceFile.d.ts +10 -0
  19. package/dist/analyzer/sourceFile.js +5 -0
  20. package/dist/analyzer/sourceFile.js.map +1 -1
  21. package/dist/analyzer/sourceFileInfoUtils.d.ts +1 -0
  22. package/dist/analyzer/sourceFileInfoUtils.js +12 -11
  23. package/dist/analyzer/sourceFileInfoUtils.js.map +1 -1
  24. package/dist/analyzer/typeEvaluator.js +146 -42
  25. package/dist/analyzer/typeEvaluator.js.map +1 -1
  26. package/dist/analyzer/typeEvaluatorTypes.d.ts +1 -0
  27. package/dist/analyzer/typeGuards.js +20 -3
  28. package/dist/analyzer/typeGuards.js.map +1 -1
  29. package/dist/backgroundAnalysisBase.d.ts +2 -2
  30. package/dist/backgroundAnalysisBase.js +14 -13
  31. package/dist/backgroundAnalysisBase.js.map +1 -1
  32. package/dist/backgroundThreadBase.d.ts +6 -2
  33. package/dist/backgroundThreadBase.js +7 -1
  34. package/dist/backgroundThreadBase.js.map +1 -1
  35. package/dist/common/fileSystem.d.ts +2 -0
  36. package/dist/common/fileSystem.js.map +1 -1
  37. package/dist/common/languageServerInterface.d.ts +0 -24
  38. package/dist/common/languageServerInterface.js.map +1 -1
  39. package/dist/common/realFileSystem.d.ts +2 -0
  40. package/dist/common/realFileSystem.js +8 -0
  41. package/dist/common/realFileSystem.js.map +1 -1
  42. package/dist/common/serviceKeys.d.ts +1 -1
  43. package/dist/common/serviceProviderExtensions.d.ts +1 -1
  44. package/dist/common/serviceProviderExtensions.js +2 -2
  45. package/dist/common/serviceProviderExtensions.js.map +1 -1
  46. package/dist/common/uri/uriMap.d.ts +17 -0
  47. package/dist/common/uri/uriMap.js +76 -0
  48. package/dist/common/uri/uriMap.js.map +1 -0
  49. package/dist/languageServerBase.d.ts +2 -1
  50. package/dist/languageServerBase.js +2 -0
  51. package/dist/languageServerBase.js.map +1 -1
  52. package/dist/languageService/completionProvider.js +1 -1
  53. package/dist/languageService/completionProvider.js.map +1 -1
  54. package/dist/languageService/referencesProvider.js +9 -2
  55. package/dist/languageService/referencesProvider.js.map +1 -1
  56. package/dist/localization/localize.d.ts +0 -4
  57. package/dist/localization/localize.js +0 -1
  58. package/dist/localization/localize.js.map +1 -1
  59. package/dist/localization/package.nls.cs.json +7 -7
  60. package/dist/localization/package.nls.de.json +7 -7
  61. package/dist/localization/package.nls.en-us.json +0 -4
  62. package/dist/localization/package.nls.es.json +7 -7
  63. package/dist/localization/package.nls.fr.json +7 -7
  64. package/dist/localization/package.nls.it.json +7 -7
  65. package/dist/localization/package.nls.ja.json +7 -7
  66. package/dist/localization/package.nls.ko.json +7 -7
  67. package/dist/localization/package.nls.pl.json +7 -7
  68. package/dist/localization/package.nls.pt-br.json +7 -7
  69. package/dist/localization/package.nls.qps-ploc.json +3 -3
  70. package/dist/localization/package.nls.ru.json +7 -7
  71. package/dist/localization/package.nls.tr.json +7 -7
  72. package/dist/localization/package.nls.zh-cn.json +7 -7
  73. package/dist/localization/package.nls.zh-tw.json +7 -7
  74. package/dist/partialStubService.d.ts +26 -0
  75. package/dist/partialStubService.js +138 -0
  76. package/dist/partialStubService.js.map +1 -0
  77. package/dist/pyrightFileSystem.d.ts +1 -21
  78. package/dist/pyrightFileSystem.js +7 -137
  79. package/dist/pyrightFileSystem.js.map +1 -1
  80. package/dist/readonlyAugmentedFileSystem.d.ts +7 -4
  81. package/dist/readonlyAugmentedFileSystem.js +124 -60
  82. package/dist/readonlyAugmentedFileSystem.js.map +1 -1
  83. package/dist/server.js +3 -1
  84. package/dist/server.js.map +1 -1
  85. package/dist/tests/completions.test.js +23 -0
  86. package/dist/tests/completions.test.js.map +1 -1
  87. package/dist/tests/fourslash/rename.typeParams.fourslash.d.ts +1 -0
  88. package/dist/tests/fourslash/rename.typeParams.fourslash.js +27 -0
  89. package/dist/tests/fourslash/rename.typeParams.fourslash.js.map +1 -0
  90. package/dist/tests/harness/fourslash/testState.js +3 -1
  91. package/dist/tests/harness/fourslash/testState.js.map +1 -1
  92. package/dist/tests/harness/vfs/filesystem.d.ts +2 -0
  93. package/dist/tests/harness/vfs/filesystem.js +5 -2
  94. package/dist/tests/harness/vfs/filesystem.js.map +1 -1
  95. package/dist/tests/importResolver.test.js +8 -2
  96. package/dist/tests/importResolver.test.js.map +1 -1
  97. package/dist/tests/pyrightFileSystem.test.js +15 -8
  98. package/dist/tests/pyrightFileSystem.test.js.map +1 -1
  99. package/dist/tests/typeEvaluator4.test.js +2 -2
  100. package/dist/tests/typeEvaluator6.test.js +4 -0
  101. package/dist/tests/typeEvaluator6.test.js.map +1 -1
  102. package/dist/tests/typeEvaluator7.test.js +1 -1
  103. package/dist/tests/typeEvaluator8.test.js +1 -1
  104. package/dist/tests/typeEvaluator8.test.js.map +1 -1
  105. package/dist/types.d.ts +26 -0
  106. package/dist/types.js +3 -0
  107. package/dist/types.js.map +1 -0
  108. package/package.json +1 -1
@@ -9,6 +9,7 @@
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.isUserCode = isUserCode;
11
11
  exports.collectImportedByCells = collectImportedByCells;
12
+ exports.collectImportedByRecursively = collectImportedByRecursively;
12
13
  exports.verifyNoCyclesInChainedFiles = verifyNoCyclesInChainedFiles;
13
14
  exports.createChainedByList = createChainedByList;
14
15
  const debug_1 = require("../common/debug");
@@ -25,9 +26,19 @@ function collectImportedByCells(program, fileInfo) {
25
26
  // `semantic tokens` or `checkers`.
26
27
  _parseAllOpenCells(program);
27
28
  const importedByCells = new Set();
28
- _collectImportedByCells(fileInfo, importedByCells);
29
+ collectImportedByRecursively(fileInfo, importedByCells);
29
30
  return importedByCells;
30
31
  }
32
+ function collectImportedByRecursively(fileInfo, importedBy) {
33
+ fileInfo.importedBy.forEach((dep) => {
34
+ if (importedBy.has(dep)) {
35
+ // Already visited.
36
+ return;
37
+ }
38
+ importedBy.add(dep);
39
+ collectImportedByRecursively(dep, importedBy);
40
+ });
41
+ }
31
42
  function verifyNoCyclesInChainedFiles(program, fileInfo) {
32
43
  let nextChainedFile = fileInfo.chainedSourceFile;
33
44
  if (!nextChainedFile) {
@@ -80,14 +91,4 @@ function _parseAllOpenCells(program) {
80
91
  program.handleMemoryHighUsage();
81
92
  }
82
93
  }
83
- function _collectImportedByCells(fileInfo, importedByCells) {
84
- fileInfo.importedBy.forEach((dep) => {
85
- if (importedByCells.has(dep)) {
86
- // Already visited.
87
- return;
88
- }
89
- importedByCells.add(dep);
90
- _collectImportedByCells(dep, importedByCells);
91
- });
92
- }
93
94
  //# sourceMappingURL=sourceFileInfoUtils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"sourceFileInfoUtils.js","sourceRoot":"","sources":["../../../../../src/analyzer/sourceFileInfoUtils.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;AAOH,gCAEC;AAED,wDAWC;AAED,oEAqBC;AAED,kDA+BC;AA5ED,2CAAuC;AAEvC,uDAAoD;AACpD,6CAA2C;AAE3C,SAAgB,UAAU,CAAC,QAAoC;IAC3D,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,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;IAC1C,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;IAE1C,MAAM,aAAa,GAAqB,CAAC,QAAQ,CAAC,CAAC;IACnD,IAAI,OAAO,GAA+B,QAAQ,CAAC;IACnD,OAAO,OAAO,EAAE,CAAC;QACb,IAAI,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YACvB,IAAA,YAAI,EACA,OAAO,CAAC,eAAe,CAAC,MAAM,CAAC,yBAAW,CAAC,kBAAkB,CAAC,EAAE,cAAc,CAAC,OAAO,EAAE,OAAO,CAAC;gBAC5F,mCAAmC,CAC1C,CAAC;QACN,CAAC;QACD,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAErB,OAAO,GAAG,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC3B,IAAI,OAAO,EAAE,CAAC;YACV,aAAa,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC;IACL,CAAC;IAED,OAAO,aAAoB,CAAC;AAChC,CAAC;AAED,SAAS,kBAAkB,CAAC,OAAoB;IAC5C,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,qBAAqB,EAAE,EAAE,CAAC;QACjD,IAAI,IAAI,CAAC,UAAU,CAAC,cAAc,EAAE,KAAK,wBAAW,CAAC,QAAQ,EAAE,CAAC;YAC5D,SAAS;QACb,CAAC;QAED,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC;QAClD,OAAO,CAAC,qBAAqB,EAAE,CAAC;IACpC,CAAC;AACL,CAAC"}
@@ -2554,6 +2554,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
2554
2554
  sourceEntryTypes.splice(unboundedIndex, 0, typeToReplicate);
2555
2555
  }
2556
2556
  }
2557
+ if (sourceEntryTypes.length > targetTypes.length) {
2558
+ // Remove elements to make the count match the target count.
2559
+ sourceEntryTypes.splice(unboundedIndex, 1);
2560
+ }
2557
2561
  }
2558
2562
  // If there's an unpack operator in the target and we have too many source elements,
2559
2563
  // combine them to assign to the unpacked target.
@@ -7500,7 +7504,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
7500
7504
  }
7501
7505
  else {
7502
7506
  let tooManyPositionals = false;
7503
- if (foundUnpackedListArg && argList[argIndex].argCategory === 1 /* ArgCategory.UnpackedList */) {
7507
+ if (argList[argIndex].argCategory === 1 /* ArgCategory.UnpackedList */) {
7504
7508
  // If this is an unpacked iterable, we will conservatively assume that it
7505
7509
  // might have zero iterations unless we can tell from its type that it
7506
7510
  // definitely has at least one iterable value.
@@ -7512,9 +7516,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
7512
7516
  argType.priv.tupleTypeArgs.length > 0) {
7513
7517
  tooManyPositionals = true;
7514
7518
  }
7515
- else {
7516
- matchedUnpackedListOfUnknownLength = true;
7517
- }
7518
7519
  }
7519
7520
  else {
7520
7521
  tooManyPositionals = true;
@@ -7603,6 +7604,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
7603
7604
  listElementType = getTypeOfIterator({ type: argType, isIncomplete: argTypeResult.isIncomplete },
7604
7605
  /* isAsync */ false, errorNode,
7605
7606
  /* emitNotIterableError */ false)?.type;
7607
+ if (paramInfo.param.category === 1 /* ParamCategory.ArgsList */) {
7608
+ matchedUnpackedListOfUnknownLength = true;
7609
+ }
7606
7610
  }
7607
7611
  const funcArg = listElementType
7608
7612
  ? {
@@ -8107,25 +8111,20 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
8107
8111
  const param = paramInfo.param;
8108
8112
  if (param.category === 0 /* ParamCategory.Simple */ && param.name) {
8109
8113
  const entry = paramMap.get(param.name);
8110
- if (entry && entry.argsNeeded === 0 && entry.argsReceived === 0) {
8111
- const defaultArgType = paramInfo.defaultType;
8112
- if (defaultArgType &&
8113
- !(0, typeUtils_1.isEllipsisType)(defaultArgType) &&
8114
- (0, typeUtils_1.requiresSpecialization)(paramInfo.declaredType)) {
8115
- validateArgTypeParams.push({
8116
- paramCategory: param.category,
8117
- paramType: paramInfo.type,
8118
- requiresTypeVarMatching: true,
8119
- argument: {
8120
- argCategory: 0 /* ArgCategory.Simple */,
8121
- typeResult: { type: defaultArgType },
8122
- },
8123
- isDefaultArg: true,
8124
- errorNode,
8125
- paramName: param.name,
8126
- isParamNameSynthesized: types_1.FunctionParam.isNameSynthesized(param),
8127
- });
8128
- }
8114
+ if (entry && entry.argsNeeded === 0 && entry.argsReceived === 0 && paramInfo.defaultType) {
8115
+ validateArgTypeParams.push({
8116
+ paramCategory: param.category,
8117
+ paramType: paramInfo.type,
8118
+ requiresTypeVarMatching: true,
8119
+ argument: {
8120
+ argCategory: 0 /* ArgCategory.Simple */,
8121
+ typeResult: { type: paramInfo.defaultType },
8122
+ },
8123
+ isDefaultArg: true,
8124
+ errorNode,
8125
+ paramName: param.name,
8126
+ isParamNameSynthesized: types_1.FunctionParam.isNameSynthesized(param),
8127
+ });
8129
8128
  }
8130
8129
  }
8131
8130
  });
@@ -8200,10 +8199,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
8200
8199
  }
8201
8200
  let relevance = 0;
8202
8201
  if (matchedUnpackedListOfUnknownLength) {
8203
- // Lower the relevance if we made assumptions about the length
8202
+ // Increase the relevance if we made assumptions about the length
8204
8203
  // of an unpacked argument. This will favor overloads that
8205
8204
  // associate this case with a *args parameter.
8206
- relevance--;
8205
+ relevance++;
8207
8206
  }
8208
8207
  // Special-case the builtin isinstance and issubclass functions.
8209
8208
  if (types_1.FunctionType.isBuiltIn(overload, ['isinstance', 'issubclass']) && validateArgTypeParams.length === 2) {
@@ -16899,13 +16898,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
16899
16898
  if (!(0, typedDicts_1.assignTypedDictToTypedDict)(evaluatorInterface, destType, srcType, diag, constraints, flags, recursionCount)) {
16900
16899
  return false;
16901
16900
  }
16902
- if (types_1.ClassType.isFinal(destType) !== types_1.ClassType.isFinal(srcType)) {
16903
- diag?.addMessage(localize_1.LocAddendum.typedDictFinalMismatch().format({
16904
- sourceType: printType((0, typeUtils_1.convertToInstance)(srcType)),
16905
- destType: printType((0, typeUtils_1.convertToInstance)(destType)),
16906
- }));
16907
- return false;
16908
- }
16909
16901
  // If invariance is being enforced, the two TypedDicts must be assignable to each other.
16910
16902
  if ((flags & 1 /* AssignTypeFlags.Invariant */) !== 0) {
16911
16903
  return (0, typedDicts_1.assignTypedDictToTypedDict)(evaluatorInterface, srcType, destType,
@@ -17791,7 +17783,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
17791
17783
  const typeVarSignatures = [];
17792
17784
  overloads.forEach((overload) => {
17793
17785
  const overloadScopeId = (0, typeUtils_1.getTypeVarScopeId)(overload) ?? '';
17794
- const constraintsClone = constraints?.cloneWithSignature(overloadScopeId);
17786
+ const constraintsClone = constraints?.cloneWithSignature([overloadScopeId]);
17795
17787
  if (assignType(destType, overload, /* diag */ undefined, constraintsClone, flags, recursionCount)) {
17796
17788
  filteredOverloads.push(overload);
17797
17789
  if (constraintsClone) {
@@ -17950,6 +17942,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
17950
17942
  if ((0, types_1.isTypeSame)(srcType, destType, {}, recursionCount)) {
17951
17943
  return true;
17952
17944
  }
17945
+ if ((flags & 16 /* AssignTypeFlags.OverloadOverlap */) !== 0 &&
17946
+ srcType.priv.subtypes.some((subtype) => (0, types_1.isAnyOrUnknown)(subtype))) {
17947
+ return false;
17948
+ }
17953
17949
  // Sort the subtypes so we have a deterministic order for unions.
17954
17950
  let sortedSrcTypes = (0, typeUtils_1.sortTypes)(srcType.priv.subtypes);
17955
17951
  let matchedSomeSubtypes = false;
@@ -18196,6 +18192,95 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
18196
18192
  /* diag */ undefined,
18197
18193
  /* constraints */ undefined, 0 /* AssignTypeFlags.Default */, recursionCount));
18198
18194
  }
18195
+ // Determines whether the two types are potentially comparable -- i.e.
18196
+ // their types overlap in such a way that it makes sense for them to
18197
+ // be compared with an == or != operator.
18198
+ function isTypeComparable(leftType, rightType) {
18199
+ if ((0, types_1.isAnyOrUnknown)(leftType) || (0, types_1.isAnyOrUnknown)(rightType)) {
18200
+ return true;
18201
+ }
18202
+ if ((0, types_1.isNever)(leftType) || (0, types_1.isNever)(rightType)) {
18203
+ return false;
18204
+ }
18205
+ if ((0, types_1.isModule)(leftType) || (0, types_1.isModule)(rightType)) {
18206
+ return (0, types_1.isTypeSame)(leftType, rightType, { ignoreConditions: true });
18207
+ }
18208
+ const isLeftCallable = (0, types_1.isFunction)(leftType) || (0, types_1.isOverloaded)(leftType);
18209
+ const isRightCallable = (0, types_1.isFunction)(rightType) || (0, types_1.isOverloaded)(rightType);
18210
+ if (isLeftCallable !== isRightCallable) {
18211
+ return false;
18212
+ }
18213
+ if ((0, types_1.isInstantiableClass)(leftType) || ((0, types_1.isClassInstance)(leftType) && types_1.ClassType.isBuiltIn(leftType, 'type'))) {
18214
+ if ((0, types_1.isInstantiableClass)(rightType) ||
18215
+ ((0, types_1.isClassInstance)(rightType) && types_1.ClassType.isBuiltIn(rightType, 'type'))) {
18216
+ const genericLeftType = types_1.ClassType.specialize(leftType, /* typeArgs */ undefined);
18217
+ const genericRightType = types_1.ClassType.specialize(rightType, /* typeArgs */ undefined);
18218
+ if (assignType(genericLeftType, genericRightType) || assignType(genericRightType, genericLeftType)) {
18219
+ return true;
18220
+ }
18221
+ }
18222
+ // Does the class have an operator overload for eq?
18223
+ const metaclass = leftType.shared.effectiveMetaclass;
18224
+ if (metaclass && (0, types_1.isClass)(metaclass)) {
18225
+ if ((0, typeUtils_1.lookUpClassMember)(metaclass, '__eq__', 4 /* MemberAccessFlags.SkipObjectBaseClass */)) {
18226
+ return true;
18227
+ }
18228
+ }
18229
+ return false;
18230
+ }
18231
+ if ((0, types_1.isClassInstance)(leftType)) {
18232
+ if ((0, types_1.isClass)(rightType)) {
18233
+ const genericLeftType = types_1.ClassType.specialize(leftType, /* typeArgs */ undefined);
18234
+ const genericRightType = types_1.ClassType.specialize(rightType, /* typeArgs */ undefined);
18235
+ if (assignType(genericLeftType, genericRightType) || assignType(genericRightType, genericLeftType)) {
18236
+ return true;
18237
+ }
18238
+ // Assume that if the types are disjoint and built-in classes that they
18239
+ // will never be comparable.
18240
+ if (types_1.ClassType.isBuiltIn(leftType) && types_1.ClassType.isBuiltIn(rightType) && types_1.TypeBase.isInstance(rightType)) {
18241
+ // We need to be careful with bool and int literals because
18242
+ // they are comparable under certain circumstances.
18243
+ let boolType;
18244
+ let intType;
18245
+ if (types_1.ClassType.isBuiltIn(leftType, 'bool') && types_1.ClassType.isBuiltIn(rightType, 'int')) {
18246
+ boolType = leftType;
18247
+ intType = rightType;
18248
+ }
18249
+ else if (types_1.ClassType.isBuiltIn(rightType, 'bool') && types_1.ClassType.isBuiltIn(leftType, 'int')) {
18250
+ boolType = rightType;
18251
+ intType = leftType;
18252
+ }
18253
+ if (boolType && intType) {
18254
+ const intVal = intType.priv?.literalValue;
18255
+ if (intVal === undefined) {
18256
+ return true;
18257
+ }
18258
+ if (intVal !== 0 && intVal !== 1) {
18259
+ return false;
18260
+ }
18261
+ const boolVal = boolType.priv?.literalValue;
18262
+ if (boolVal === undefined) {
18263
+ return true;
18264
+ }
18265
+ return boolVal === (intVal === 1);
18266
+ }
18267
+ return false;
18268
+ }
18269
+ }
18270
+ // Does the class have an operator overload for eq?
18271
+ const eqMethod = (0, typeUtils_1.lookUpClassMember)(types_1.ClassType.cloneAsInstantiable(leftType), '__eq__', 4 /* MemberAccessFlags.SkipObjectBaseClass */);
18272
+ if (eqMethod) {
18273
+ // If this is a synthesized method for a dataclass, we can assume
18274
+ // that other dataclass types will not be comparable.
18275
+ if (types_1.ClassType.isDataClass(leftType) && eqMethod.symbol.getSynthesizedType()) {
18276
+ return false;
18277
+ }
18278
+ return true;
18279
+ }
18280
+ return false;
18281
+ }
18282
+ return true;
18283
+ }
18199
18284
  function assignToUnionType(destType, srcType, diag, constraints, flags, recursionCount) {
18200
18285
  // If we need to enforce invariance, the source needs to be compatible
18201
18286
  // with all subtypes in the dest, unless those subtypes are subclasses
@@ -18378,17 +18463,26 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
18378
18463
  for (const mroClass of objType.shared.mro) {
18379
18464
  if ((0, types_1.isClass)(mroClass) && types_1.ClassType.isProtocolClass(mroClass)) {
18380
18465
  for (const field of types_1.ClassType.getSymbolTable(mroClass)) {
18381
- if (field[0] !== '__call__' && !field[1].isIgnoredForProtocolMatch()) {
18382
- let fieldIsPartOfFunction = false;
18383
- if (prefetched?.functionClass && (0, types_1.isClass)(prefetched.functionClass)) {
18384
- if (types_1.ClassType.getSymbolTable(prefetched.functionClass).has(field[0])) {
18385
- fieldIsPartOfFunction = true;
18386
- }
18387
- }
18388
- if (!fieldIsPartOfFunction) {
18389
- return undefined;
18466
+ const fieldName = field[0];
18467
+ const fieldSymbol = field[1];
18468
+ // We're expecting a __call__ method. We will also ignore a
18469
+ // __slots__ definition, which is (by convention) ignored for
18470
+ // protocol matching.
18471
+ if (fieldName === '__call__' || fieldName === '__slots__') {
18472
+ continue;
18473
+ }
18474
+ if (fieldSymbol.isIgnoredForProtocolMatch()) {
18475
+ continue;
18476
+ }
18477
+ let fieldIsPartOfFunction = false;
18478
+ if (prefetched?.functionClass && (0, types_1.isClass)(prefetched.functionClass)) {
18479
+ if (types_1.ClassType.getSymbolTable(prefetched.functionClass).has(field[0])) {
18480
+ fieldIsPartOfFunction = true;
18390
18481
  }
18391
18482
  }
18483
+ if (!fieldIsPartOfFunction) {
18484
+ return undefined;
18485
+ }
18392
18486
  }
18393
18487
  }
18394
18488
  }
@@ -18539,6 +18633,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
18539
18633
  const destPositionalCount = destParamDetails.firstKeywordOnlyIndex ?? destParamDetails.params.length;
18540
18634
  const srcPositionalCount = srcParamDetails.firstKeywordOnlyIndex ?? srcParamDetails.params.length;
18541
18635
  const positionalsToMatch = Math.min(destPositionalCount, srcPositionalCount);
18636
+ const skippedPosParamIndices = [];
18542
18637
  // Match positional parameters.
18543
18638
  for (let paramIndex = 0; paramIndex < positionalsToMatch; paramIndex++) {
18544
18639
  if (paramIndex === 0 &&
@@ -18550,6 +18645,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
18550
18645
  }
18551
18646
  // Skip over the *args parameter since it's handled separately below.
18552
18647
  if (paramIndex === destParamDetails.argsIndex) {
18648
+ if (!(0, types_1.isUnpackedTypeVarTuple)(destParamDetails.params[destParamDetails.argsIndex].type)) {
18649
+ skippedPosParamIndices.push(paramIndex);
18650
+ }
18553
18651
  continue;
18554
18652
  }
18555
18653
  const destParam = destParamDetails.params[paramIndex];
@@ -18642,7 +18740,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
18642
18740
  canAssign = false;
18643
18741
  }
18644
18742
  if (destPositionalCount < srcPositionalCount && !targetIncludesParamSpec) {
18743
+ // Add any remaining positional parameter indices to the list that
18744
+ // need to be validated.
18645
18745
  for (let i = destPositionalCount; i < srcPositionalCount; i++) {
18746
+ skippedPosParamIndices.push(i);
18747
+ }
18748
+ for (const i of skippedPosParamIndices) {
18646
18749
  // If the dest has an *args parameter, make sure it can accept the remaining
18647
18750
  // positional arguments in the source.
18648
18751
  if (destParamDetails.argsIndex !== undefined) {
@@ -20104,6 +20207,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
20104
20207
  getCallSignatureInfo,
20105
20208
  getAbstractSymbols,
20106
20209
  narrowConstrainedTypeVar,
20210
+ isTypeComparable,
20107
20211
  assignType,
20108
20212
  validateOverrideMethod,
20109
20213
  validateCallArgs,