@zzzen/pyright-internal 1.2.0-dev.20231126 → 1.2.0-dev.20231203

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 (95) hide show
  1. package/dist/analyzer/binder.js +3 -0
  2. package/dist/analyzer/binder.js.map +1 -1
  3. package/dist/analyzer/checker.d.ts +4 -1
  4. package/dist/analyzer/checker.js +146 -9
  5. package/dist/analyzer/checker.js.map +1 -1
  6. package/dist/analyzer/codeFlowEngine.js +7 -0
  7. package/dist/analyzer/codeFlowEngine.js.map +1 -1
  8. package/dist/analyzer/commentUtils.js +7 -0
  9. package/dist/analyzer/commentUtils.js.map +1 -1
  10. package/dist/analyzer/constraintSolver.js +11 -0
  11. package/dist/analyzer/constraintSolver.js.map +1 -1
  12. package/dist/analyzer/constructors.js +2 -1
  13. package/dist/analyzer/constructors.js.map +1 -1
  14. package/dist/analyzer/dataClasses.js +57 -46
  15. package/dist/analyzer/dataClasses.js.map +1 -1
  16. package/dist/analyzer/operations.js +16 -14
  17. package/dist/analyzer/operations.js.map +1 -1
  18. package/dist/analyzer/protocols.js +27 -13
  19. package/dist/analyzer/protocols.js.map +1 -1
  20. package/dist/analyzer/typeEvaluator.js +126 -129
  21. package/dist/analyzer/typeEvaluator.js.map +1 -1
  22. package/dist/analyzer/typeEvaluatorTypes.d.ts +1 -1
  23. package/dist/analyzer/typeEvaluatorTypes.js +1 -1
  24. package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
  25. package/dist/analyzer/typeUtils.d.ts +1 -1
  26. package/dist/analyzer/typeUtils.js +16 -12
  27. package/dist/analyzer/typeUtils.js.map +1 -1
  28. package/dist/analyzer/typeVarContext.d.ts +2 -0
  29. package/dist/analyzer/typeVarContext.js +27 -0
  30. package/dist/analyzer/typeVarContext.js.map +1 -1
  31. package/dist/analyzer/typedDicts.js +2 -32
  32. package/dist/analyzer/typedDicts.js.map +1 -1
  33. package/dist/analyzer/types.d.ts +3 -8
  34. package/dist/analyzer/types.js +9 -16
  35. package/dist/analyzer/types.js.map +1 -1
  36. package/dist/commands/commandController.js +1 -2
  37. package/dist/commands/commandController.js.map +1 -1
  38. package/dist/commands/commands.d.ts +0 -1
  39. package/dist/commands/commands.js +0 -1
  40. package/dist/commands/commands.js.map +1 -1
  41. package/dist/common/configOptions.d.ts +1 -0
  42. package/dist/common/configOptions.js +91 -3
  43. package/dist/common/configOptions.js.map +1 -1
  44. package/dist/common/diagnostic.d.ts +0 -4
  45. package/dist/common/diagnostic.js.map +1 -1
  46. package/dist/languageService/codeActionProvider.js +0 -14
  47. package/dist/languageService/codeActionProvider.js.map +1 -1
  48. package/dist/languageService/quickActions.d.ts +1 -2
  49. package/dist/languageService/quickActions.js +0 -80
  50. package/dist/languageService/quickActions.js.map +1 -1
  51. package/dist/localization/localize.d.ts +12 -9
  52. package/dist/localization/localize.js +6 -4
  53. package/dist/localization/localize.js.map +1 -1
  54. package/dist/localization/package.nls.cs.json +0 -4
  55. package/dist/localization/package.nls.de.json +0 -4
  56. package/dist/localization/package.nls.en-us.json +7 -5
  57. package/dist/localization/package.nls.es.json +2 -6
  58. package/dist/localization/package.nls.fr.json +0 -4
  59. package/dist/localization/package.nls.it.json +0 -4
  60. package/dist/localization/package.nls.ja.json +0 -4
  61. package/dist/localization/package.nls.ko.json +0 -4
  62. package/dist/localization/package.nls.pl.json +0 -4
  63. package/dist/localization/package.nls.pt-br.json +0 -4
  64. package/dist/localization/package.nls.qps-ploc.json +0 -4
  65. package/dist/localization/package.nls.ru.json +0 -4
  66. package/dist/localization/package.nls.tr.json +0 -4
  67. package/dist/localization/package.nls.zh-cn.json +0 -4
  68. package/dist/localization/package.nls.zh-tw.json +0 -4
  69. package/dist/pyrightFileSystem.js +1 -1
  70. package/dist/pyrightFileSystem.js.map +1 -1
  71. package/dist/readonlyAugmentedFileSystem.d.ts +1 -1
  72. package/dist/readonlyAugmentedFileSystem.js +15 -5
  73. package/dist/readonlyAugmentedFileSystem.js.map +1 -1
  74. package/dist/server.js +1 -1
  75. package/dist/server.js.map +1 -1
  76. package/dist/tests/checker.test.js +8 -0
  77. package/dist/tests/checker.test.js.map +1 -1
  78. package/dist/tests/fourslash/fourslash.d.ts +1 -2
  79. package/dist/tests/harness/fourslash/testState.Consts.d.ts +1 -2
  80. package/dist/tests/harness/fourslash/testState.Consts.js +0 -1
  81. package/dist/tests/harness/fourslash/testState.Consts.js.map +1 -1
  82. package/dist/tests/harness/fourslash/testState.js +1 -1
  83. package/dist/tests/harness/fourslash/testState.js.map +1 -1
  84. package/dist/tests/pyrightFileSystem.test.js +48 -1
  85. package/dist/tests/pyrightFileSystem.test.js.map +1 -1
  86. package/dist/tests/typeEvaluator1.test.js +8 -5
  87. package/dist/tests/typeEvaluator1.test.js.map +1 -1
  88. package/dist/tests/typeEvaluator2.test.js +3 -3
  89. package/dist/tests/typeEvaluator3.test.js +12 -9
  90. package/dist/tests/typeEvaluator3.test.js.map +1 -1
  91. package/dist/tests/typeEvaluator4.test.js +6 -2
  92. package/dist/tests/typeEvaluator4.test.js.map +1 -1
  93. package/dist/tests/typeEvaluator5.test.js +8 -4
  94. package/dist/tests/typeEvaluator5.test.js.map +1 -1
  95. package/package.json +1 -1
@@ -735,15 +735,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
735
735
  }
736
736
  }
737
737
  }
738
- function reportInvalidUseOfPep695TypeAlias(type, node) {
739
- var _a;
740
- // PEP 695 type aliases cannot be used as instantiable classes.
741
- if (((_a = type.typeAliasInfo) === null || _a === void 0 ? void 0 : _a.name) && type.typeAliasInfo.isPep695Syntax && types_1.TypeBase.isSpecialForm(type)) {
742
- addDiagnostic(AnalyzerNodeInfo.getFileInfo(node).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.typeAliasNotAllowed().format({ name: type.typeAliasInfo.name }), node);
743
- return true;
744
- }
745
- return false;
746
- }
747
738
  function validateTypeIsInstantiable(typeResult, flags, node) {
748
739
  var _a;
749
740
  // If the type is incomplete, don't log any diagnostics yet.
@@ -770,7 +761,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
770
761
  }
771
762
  function getTypeOfAwaitOperator(node, flags, inferenceContext) {
772
763
  const effectiveExpectedType = inferenceContext
773
- ? createAwaitableReturnType(node, inferenceContext.expectedType, /* isGenerator */ false)
764
+ ? createAwaitableReturnType(node, inferenceContext.expectedType,
765
+ /* isGenerator */ false,
766
+ /* useCoroutine */ false)
774
767
  : undefined;
775
768
  const exprTypeResult = getTypeOfExpression(node.expression, flags, (0, typeUtils_1.makeInferenceContext)(effectiveExpectedType));
776
769
  const typeResult = {
@@ -2484,9 +2477,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
2484
2477
  types_1.FunctionType.addDefaultParameters(concreteFunction);
2485
2478
  return types_1.FunctionType.cloneForParamSpec(subtype, concreteFunction);
2486
2479
  }
2487
- // If this is a TypeVarTuple *Ts, convert it to an unpacked tuple
2488
- // *tuple[*Ts].
2489
- if ((0, types_1.isVariadicTypeVar)(subtype)) {
2480
+ if ((0, types_1.isTypeVar)(subtype) && subtype.details.isVariadic) {
2490
2481
  // If it's in a union, convert to type or object.
2491
2482
  if (subtype.isVariadicInUnion) {
2492
2483
  if (types_1.TypeBase.isInstantiable(subtype)) {
@@ -2499,11 +2490,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
2499
2490
  }
2500
2491
  return types_1.AnyType.create();
2501
2492
  }
2502
- if (tupleClassType && (0, types_1.isInstantiableClass)(tupleClassType)) {
2503
- return (0, typeUtils_1.convertToInstance)((0, typeUtils_1.specializeTupleClass)(tupleClassType, [{ type: subtype, isUnbounded: false }],
2504
- /* isTypeArgumentExplicit */ true,
2505
- /* isUnpackedTuple */ true));
2506
- }
2493
+ return subtype;
2507
2494
  }
2508
2495
  if ((0, types_1.isTypeVar)(subtype) && !subtype.details.recursiveTypeAliasName) {
2509
2496
  // If this is a recursive type alias placeholder
@@ -2555,7 +2542,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
2555
2542
  isConstrainedTypeVar: false,
2556
2543
  },
2557
2544
  ]);
2558
- return types_1.AnyType.create();
2559
2545
  }
2560
2546
  return subtype;
2561
2547
  });
@@ -2591,7 +2577,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
2591
2577
  if (typeCondition && typeCondition.length > 0) {
2592
2578
  transformedType = (0, typeUtils_1.addConditionToType)(transformedType, typeCondition);
2593
2579
  }
2594
- newSubtypes.push(transformedType);
2580
+ // This code path can often produce many duplicate subtypes. We can
2581
+ // reduce the cost of the combineTypes call below by filtering out these
2582
+ // duplicates proactively.
2583
+ if (newSubtypes.length === 0 ||
2584
+ !(0, types_1.isTypeSame)(transformedType, newSubtypes[newSubtypes.length - 1])) {
2585
+ newSubtypes.push(transformedType);
2586
+ }
2595
2587
  }
2596
2588
  return undefined;
2597
2589
  }, sortSubtypes);
@@ -2873,6 +2865,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
2873
2865
  }
2874
2866
  }
2875
2867
  function getTypeOfName(node, flags) {
2868
+ var _a;
2876
2869
  const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
2877
2870
  const name = node.value;
2878
2871
  let symbol;
@@ -3024,9 +3017,15 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3024
3017
  if ((flags & 256 /* EvaluatorFlags.ExpectingTypeAnnotation */) === 0) {
3025
3018
  reportUseOfTypeCheckOnly(type, node);
3026
3019
  }
3027
- if ((flags & 16777216 /* EvaluatorFlags.DisallowPep695TypeAlias */) !== 0) {
3028
- if (reportInvalidUseOfPep695TypeAlias(type, node)) {
3029
- type = types_1.UnknownType.create();
3020
+ if ((flags & 16777216 /* EvaluatorFlags.TreatPep695TypeAliasAsObject */) !== 0) {
3021
+ if (((_a = type.typeAliasInfo) === null || _a === void 0 ? void 0 : _a.name) && type.typeAliasInfo.isPep695Syntax && types_1.TypeBase.isSpecialForm(type)) {
3022
+ const typeAliasType = getTypingType(node, 'TypeAliasType');
3023
+ if (typeAliasType && (0, types_1.isInstantiableClass)(typeAliasType)) {
3024
+ type = types_1.ClassType.cloneAsInstance(typeAliasType);
3025
+ }
3026
+ else {
3027
+ type = types_1.UnknownType.create();
3028
+ }
3030
3029
  }
3031
3030
  }
3032
3031
  if ((flags & 128 /* EvaluatorFlags.ExpectingInstantiableType */) !== 0) {
@@ -3470,7 +3469,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3470
3469
  // cases where a type is passed as an argument (e.g. "defaultdict(list)").
3471
3470
  // It can also come up in cases like "isinstance(x, (list, dict))".
3472
3471
  // We need to check for functions as well to handle Callable.
3473
- if ((0, types_1.isInstantiableClass)(typeResult.type) || (0, types_1.isFunction)(typeResult.type)) {
3472
+ if ((0, types_1.isInstantiableClass)(typeResult.type) ||
3473
+ ((0, types_1.isFunction)(typeResult.type) && types_1.TypeBase.isSpecialForm(typeResult.type))) {
3474
3474
  const argNode = ParseTreeUtils.getParentNodeOfType(node, 1 /* ParseNodeType.Argument */);
3475
3475
  if (argNode && ((_a = argNode === null || argNode === void 0 ? void 0 : argNode.parent) === null || _a === void 0 ? void 0 : _a.nodeType) === 9 /* ParseNodeType.Call */) {
3476
3476
  skipPartialUnknownCheck = true;
@@ -3486,7 +3486,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3486
3486
  }
3487
3487
  function getTypeOfMemberAccessWithBaseType(node, baseTypeResult, usage, flags) {
3488
3488
  var _a, _b;
3489
- let baseType = baseTypeResult.type;
3489
+ let baseType = (0, typeUtils_1.transformPossibleRecursiveTypeAlias)(baseTypeResult.type);
3490
3490
  const memberName = node.memberName.value;
3491
3491
  let diag = new diagnostic_1.DiagnosticAddendum();
3492
3492
  const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
@@ -4071,7 +4071,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
4071
4071
  if (types_1.ClassType.isClassProperty(concreteMemberType)) {
4072
4072
  // Handle "class properties" as a special case. We need to pass
4073
4073
  // the class rather than the object instance in this case.
4074
- objArgType = classType;
4074
+ objArgType = isAccessedThroughObject ? types_1.ClassType.cloneAsInstantiable(classType) : classType;
4075
4075
  }
4076
4076
  else if (isAccessedThroughObject) {
4077
4077
  objArgType = selfType !== null && selfType !== void 0 ? selfType : types_1.ClassType.cloneAsInstance(classType);
@@ -4357,7 +4357,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
4357
4357
  }
4358
4358
  }
4359
4359
  }
4360
- const indexTypeResult = getTypeOfIndexWithBaseType(node, baseTypeResult, { method: 'get' }, flags & ~16777216 /* EvaluatorFlags.DisallowPep695TypeAlias */);
4360
+ const indexTypeResult = getTypeOfIndexWithBaseType(node, baseTypeResult, { method: 'get' }, flags & ~16777216 /* EvaluatorFlags.TreatPep695TypeAliasAsObject */);
4361
4361
  if ((0, codeFlowTypes_1.isCodeFlowSupportedForReference)(node)) {
4362
4362
  // We limit type narrowing for index expressions to built-in types that are
4363
4363
  // known to have symmetric __getitem__ and __setitem__ methods (i.e. the value
@@ -6913,7 +6913,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
6913
6913
  tooManyPositionals = true;
6914
6914
  }
6915
6915
  if (tooManyPositionals) {
6916
- if (!isDiagnosticSuppressedForNode(errorNode)) {
6916
+ if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
6917
6917
  addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, positionParamLimitIndex === 1
6918
6918
  ? localize_1.Localizer.Diagnostic.argPositionalExpectedOne()
6919
6919
  : localize_1.Localizer.Diagnostic.argPositionalExpectedCount().format({
@@ -6946,7 +6946,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
6946
6946
  if ((0, types_1.isTypeVar)(argTypeResult.type) &&
6947
6947
  argTypeResult.type.paramSpecAccess === 'args' &&
6948
6948
  paramDetails.params[paramIndex].param.category !== 1 /* ParameterCategory.ArgsList */) {
6949
- if (!isDiagnosticSuppressedForNode(errorNode)) {
6949
+ if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
6950
6950
  addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, positionParamLimitIndex === 1
6951
6951
  ? localize_1.Localizer.Diagnostic.argPositionalExpectedOne()
6952
6952
  : localize_1.Localizer.Diagnostic.argPositionalExpectedCount().format({
@@ -7013,7 +7013,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7013
7013
  // It's not allowed to use unpacked arguments with a variadic *args
7014
7014
  // parameter unless the argument is a variadic arg as well.
7015
7015
  if (isParamVariadic && !isArgCompatibleWithVariadic) {
7016
- if (!isDiagnosticSuppressedForNode(errorNode)) {
7016
+ if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7017
7017
  addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.unpackedArgWithVariadicParam(), argList[argIndex].valueExpression || errorNode);
7018
7018
  }
7019
7019
  reportedArgError = true;
@@ -7070,7 +7070,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7070
7070
  : 0 /* ParameterCategory.Simple */;
7071
7071
  if (remainingArgCount <= remainingParamCount) {
7072
7072
  if (remainingArgCount < remainingParamCount) {
7073
- if (!isDiagnosticSuppressedForNode(errorNode)) {
7073
+ if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7074
7074
  // Have we run out of arguments and still have parameters left to fill?
7075
7075
  addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, remainingArgCount === 1
7076
7076
  ? localize_1.Localizer.Diagnostic.argMorePositionalExpectedOne()
@@ -7153,7 +7153,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7153
7153
  argsRemainingCount--;
7154
7154
  }
7155
7155
  if (argsRemainingCount > 0) {
7156
- if (!isDiagnosticSuppressedForNode(errorNode)) {
7156
+ if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7157
7157
  addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, argsRemainingCount === 1
7158
7158
  ? localize_1.Localizer.Diagnostic.argMorePositionalExpectedOne()
7159
7159
  : localize_1.Localizer.Diagnostic.argMorePositionalExpectedCount().format({
@@ -7235,7 +7235,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7235
7235
  }
7236
7236
  });
7237
7237
  if (!diag.isEmpty()) {
7238
- if (!isDiagnosticSuppressedForNode(errorNode)) {
7238
+ if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7239
7239
  addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.unpackedTypedDictArgument() + diag.getString(), argList[argIndex].valueExpression || errorNode);
7240
7240
  }
7241
7241
  reportedArgError = true;
@@ -7296,7 +7296,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7296
7296
  });
7297
7297
  }
7298
7298
  if (!isValidMappingType) {
7299
- if (!isDiagnosticSuppressedForNode(errorNode)) {
7299
+ if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7300
7300
  addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet
7301
7301
  .reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.unpackedDictArgumentNotMapping(), argList[argIndex].valueExpression || errorNode);
7302
7302
  }
@@ -7318,7 +7318,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7318
7318
  const paramEntry = paramMap.get(paramNameValue);
7319
7319
  if (paramEntry && !paramEntry.isPositionalOnly) {
7320
7320
  if (paramEntry.argsReceived > 0) {
7321
- addDiagnostic(AnalyzerNodeInfo.getFileInfo(paramName).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.paramAlreadyAssigned().format({ name: paramNameValue }), paramName);
7321
+ if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7322
+ addDiagnostic(AnalyzerNodeInfo.getFileInfo(paramName).diagnosticRuleSet
7323
+ .reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.paramAlreadyAssigned().format({ name: paramNameValue }), paramName);
7324
+ }
7322
7325
  reportedArgError = true;
7323
7326
  }
7324
7327
  else {
@@ -7360,7 +7363,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7360
7363
  trySetActive(argList[argIndex], paramDetails.params[paramDetails.kwargsIndex].param);
7361
7364
  }
7362
7365
  else {
7363
- addDiagnostic(AnalyzerNodeInfo.getFileInfo(paramName).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.paramNameMissing().format({ name: paramName.value }), paramName);
7366
+ if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7367
+ addDiagnostic(AnalyzerNodeInfo.getFileInfo(paramName).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.paramNameMissing().format({ name: paramName.value }), paramName);
7368
+ }
7364
7369
  reportedArgError = true;
7365
7370
  }
7366
7371
  }
@@ -7369,9 +7374,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7369
7374
  paramSpecArgList.push(argList[argIndex]);
7370
7375
  }
7371
7376
  else {
7372
- if (!isDiagnosticSuppressedForNode(errorNode)) {
7373
- const fileInfo = AnalyzerNodeInfo.getFileInfo(errorNode);
7374
- addDiagnostic(fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, positionParamLimitIndex === 1
7377
+ if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7378
+ addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, positionParamLimitIndex === 1
7375
7379
  ? localize_1.Localizer.Diagnostic.argPositionalExpectedOne()
7376
7380
  : localize_1.Localizer.Diagnostic.argPositionalExpectedCount().format({
7377
7381
  expected: positionParamLimitIndex,
@@ -7447,9 +7451,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7447
7451
  if (unassignedParams.length > 0) {
7448
7452
  if (!isDiagnosticSuppressedForNode(errorNode)) {
7449
7453
  const missingParamNames = unassignedParams.map((p) => `"${p}"`).join(', ');
7450
- addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, unassignedParams.length === 1
7451
- ? localize_1.Localizer.Diagnostic.argMissingForParam().format({ name: missingParamNames })
7452
- : localize_1.Localizer.Diagnostic.argMissingForParams().format({ names: missingParamNames }), errorNode);
7454
+ if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7455
+ addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, unassignedParams.length === 1
7456
+ ? localize_1.Localizer.Diagnostic.argMissingForParam().format({ name: missingParamNames })
7457
+ : localize_1.Localizer.Diagnostic.argMissingForParams().format({ names: missingParamNames }), errorNode);
7458
+ }
7453
7459
  }
7454
7460
  reportedArgError = true;
7455
7461
  }
@@ -7515,14 +7521,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7515
7521
  if (containsVariadicTypeVar &&
7516
7522
  argParam.argument.argumentCategory !== 1 /* ArgumentCategory.UnpackedList */ &&
7517
7523
  !argParam.mapsToVarArgList) {
7518
- if (!isDiagnosticSuppressedForNode(errorNode)) {
7524
+ if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7519
7525
  addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet
7520
7526
  .reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.typeVarTupleMustBeUnpacked(), (_a = argParam.argument.valueExpression) !== null && _a !== void 0 ? _a : errorNode);
7521
7527
  }
7522
7528
  reportedArgError = true;
7523
7529
  }
7524
7530
  return {
7525
- type: stripLiteralValue(argType),
7531
+ type: argType,
7526
7532
  isUnbounded: argParam.argument.argumentCategory === 1 /* ArgumentCategory.UnpackedList */,
7527
7533
  };
7528
7534
  });
@@ -8179,7 +8185,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8179
8185
  8 /* EvaluatorFlags.EvaluateStringLiteralAsType */ |
8180
8186
  32 /* EvaluatorFlags.DisallowParamSpec */ |
8181
8187
  64 /* EvaluatorFlags.DisallowTypeVarTuple */ |
8182
- 16777216 /* EvaluatorFlags.DisallowPep695TypeAlias */
8188
+ 16777216 /* EvaluatorFlags.TreatPep695TypeAliasAsObject */
8183
8189
  : 2 /* EvaluatorFlags.DoNotSpecialize */;
8184
8190
  const exprTypeResult = getTypeOfExpression(argParam.argument.valueExpression, flags, (0, typeUtils_1.makeInferenceContext)(expectedType, !!(typeResult === null || typeResult === void 0 ? void 0 : typeResult.isIncomplete), signatureTracker));
8185
8191
  argType = exprTypeResult.type;
@@ -8377,21 +8383,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8377
8383
  const diagAddendum = getDiagAddendum();
8378
8384
  addDiagnostic(fileInfo.diagnosticRuleSet.reportUnknownArgumentType, diagnosticRules_1.DiagnosticRule.reportUnknownArgumentType, localize_1.Localizer.Diagnostic.argTypeUnknown() + diagAddendum.getString(), argParam.errorNode);
8379
8385
  }
8380
- else if ((0, typeUtils_1.isPartlyUnknown)(simplifiedType, /* allowUnknownTypeArgsForClasses */ true)) {
8381
- let suppressPartialUnknown = false;
8382
- // Don't report an error if the type is a partially-specialized
8383
- // class. This comes up frequently in cases where a type is passed
8384
- // as an argument (e.g. "defaultdict(list)").
8385
- if ((0, types_1.isInstantiableClass)(simplifiedType)) {
8386
- suppressPartialUnknown = true;
8387
- }
8386
+ else if ((0, typeUtils_1.isPartlyUnknown)(simplifiedType)) {
8388
8387
  // If the parameter type is also partially unknown, don't report
8389
8388
  // the error because it's likely that the partially-unknown type
8390
8389
  // arose due to bidirectional type matching.
8391
- if ((0, typeUtils_1.isPartlyUnknown)(argParam.paramType)) {
8392
- suppressPartialUnknown = true;
8393
- }
8394
- if (!suppressPartialUnknown) {
8390
+ if (!(0, typeUtils_1.isPartlyUnknown)(argParam.paramType)) {
8395
8391
  const diagAddendum = getDiagAddendum();
8396
8392
  diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.argumentType().format({
8397
8393
  type: printType(simplifiedType, { expandTypeAlias: true }),
@@ -9655,6 +9651,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
9655
9651
  paramType = getTypeOfExpression(param.defaultValue, undefined, inferenceContext).type;
9656
9652
  }
9657
9653
  }
9654
+ else if (param.defaultValue) {
9655
+ // If there is no inference context but we have a default value,
9656
+ // use the default value to infer the parameter's type.
9657
+ paramType = inferParameterTypeFromDefaultValue(param.defaultValue);
9658
+ }
9658
9659
  if (param.name) {
9659
9660
  writeTypeCache(param.name, { type: transformVariadicParamType(node, param.category, paramType !== null && paramType !== void 0 ? paramType : types_1.UnknownType.create()) }, 0 /* EvaluatorFlags.None */);
9660
9661
  }
@@ -10266,7 +10267,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
10266
10267
  });
10267
10268
  return types_1.ClassType.cloneForSpecialization(classType, convertedTypeArgs, /* isTypeArgumentExplicit */ true);
10268
10269
  }
10269
- function createSelfType(classType, errorNode, typeArgs) {
10270
+ function createSelfType(classType, errorNode, typeArgs, flags) {
10270
10271
  var _a;
10271
10272
  const fileInfo = AnalyzerNodeInfo.getFileInfo(errorNode);
10272
10273
  // Self doesn't support any type arguments.
@@ -10278,7 +10279,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
10278
10279
  const enclosingClass = ParseTreeUtils.getEnclosingClass(errorNode);
10279
10280
  const enclosingClassTypeResult = enclosingClass ? getTypeOfClass(enclosingClass) : undefined;
10280
10281
  if (!enclosingClassTypeResult) {
10281
- addDiagnostic(fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.selfTypeContext(), errorNode);
10282
+ if ((flags & 256 /* EvaluatorFlags.ExpectingTypeAnnotation */) !== 0) {
10283
+ addDiagnostic(fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.selfTypeContext(), errorNode);
10284
+ }
10282
10285
  return types_1.UnknownType.create();
10283
10286
  }
10284
10287
  const enclosingFunction = ParseTreeUtils.getEnclosingFunction(errorNode);
@@ -11168,7 +11171,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11168
11171
  2048 /* EvaluatorFlags.DisallowTypeVarsWithScopeId */ |
11169
11172
  8192 /* EvaluatorFlags.AssociateTypeVarsWithCurrentScope */ |
11170
11173
  16384 /* EvaluatorFlags.EnforceTypeVarVarianceConsistency */ |
11171
- 16777216 /* EvaluatorFlags.DisallowPep695TypeAlias */;
11174
+ 16777216 /* EvaluatorFlags.TreatPep695TypeAliasAsObject */;
11172
11175
  if (fileInfo.isStubFile) {
11173
11176
  exprFlags |= 4 /* EvaluatorFlags.AllowForwardReferences */;
11174
11177
  }
@@ -11271,10 +11274,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11271
11274
  classType.details.flags |= 1048576 /* ClassTypeFlags.EnumClass */;
11272
11275
  }
11273
11276
  // Determine if the class is abstract. Protocol classes support abstract methods
11274
- // even though they don't derive from the ABCMeta class. We'll exclude built-in
11275
- // protocol classes because these are known not to contain any abstract methods
11276
- // and getAbstractMethods causes problems because of dependencies on some of these
11277
- // built-in protocol classes.
11277
+ // because they are constructed by the _ProtocolMeta metaclass, which derives
11278
+ // from ABCMeta. We'll exclude built-in protocol classes because these are known
11279
+ // not to contain any abstract methods and getAbstractMethods causes problems
11280
+ // because of dependencies on some of these built-in protocol classes.
11278
11281
  if (types_1.ClassType.supportsAbstractMethods(argType) ||
11279
11282
  (types_1.ClassType.isProtocolClass(argType) && !types_1.ClassType.isBuiltIn(argType))) {
11280
11283
  classType.details.flags |= 1024 /* ClassTypeFlags.SupportsAbstractMethods */;
@@ -11972,6 +11975,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11972
11975
  // function declaration falls within an unreachable code block.
11973
11976
  return undefined;
11974
11977
  }
11978
+ if (types_1.FunctionType.isPartiallyEvaluated(functionType)) {
11979
+ return { functionType, decoratedType: functionType };
11980
+ }
11975
11981
  }
11976
11982
  else {
11977
11983
  functionType = getTypeOfFunctionPredecorated(node);
@@ -12128,7 +12134,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
12128
12134
  node.parameters.forEach((param, index) => {
12129
12135
  let paramType;
12130
12136
  let annotatedType;
12131
- let isNoneWithoutOptional = false;
12132
12137
  let paramTypeNode;
12133
12138
  if (param.name) {
12134
12139
  if (index === 0 && isFirstParamClsOrSelf) {
@@ -12176,7 +12181,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
12176
12181
  const adjustedAnnotatedType = adjustParameterAnnotatedType(param, annotatedType);
12177
12182
  if (adjustedAnnotatedType !== annotatedType) {
12178
12183
  annotatedType = adjustedAnnotatedType;
12179
- isNoneWithoutOptional = true;
12180
12184
  }
12181
12185
  }
12182
12186
  let defaultValueType;
@@ -12205,17 +12209,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
12205
12209
  }
12206
12210
  }
12207
12211
  if (!assignType(annotatedType, defaultValueType, diagAddendum, typeVarContext)) {
12208
- const diag = addDiagnostic(fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.paramAssignmentMismatch().format({
12212
+ addDiagnostic(fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.paramAssignmentMismatch().format({
12209
12213
  sourceType: printType(defaultValueType),
12210
12214
  paramType: printType(annotatedType),
12211
12215
  }) + diagAddendum.getString(), param.defaultValue);
12212
- if (isNoneWithoutOptional && paramTypeNode) {
12213
- const addOptionalAction = {
12214
- action: "pyright.addoptionalforparam" /* Commands.addMissingOptionalToParam */,
12215
- offsetOfTypeNode: paramTypeNode.start + 1,
12216
- };
12217
- diag === null || diag === void 0 ? void 0 : diag.addAction(addOptionalAction);
12218
- }
12219
12216
  }
12220
12217
  }
12221
12218
  paramType = annotatedType;
@@ -12474,43 +12471,46 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
12474
12471
  // type from this information.
12475
12472
  const paramValueExpr = functionNode.parameters[paramIndex].defaultValue;
12476
12473
  if (paramValueExpr) {
12477
- const defaultValueType = getTypeOfExpression(paramValueExpr, 1 /* EvaluatorFlags.ConvertEllipsisToAny */).type;
12478
- let inferredParamType;
12479
- // Is the default value a "None" or an instance of some private class (one
12480
- // whose name starts with an underscore)? If so, we will assume that the
12481
- // value is a singleton sentinel. The actual supported type is going to be
12482
- // a union of this type and Unknown.
12483
- if ((0, typeUtils_1.isNoneInstance)(defaultValueType) ||
12484
- ((0, types_1.isClassInstance)(defaultValueType) && (0, symbolNameUtils_1.isPrivateOrProtectedName)(defaultValueType.details.name))) {
12485
- inferredParamType = (0, types_1.combineTypes)([defaultValueType, types_1.UnknownType.create()]);
12474
+ return inferParameterTypeFromDefaultValue(paramValueExpr);
12475
+ }
12476
+ return undefined;
12477
+ }
12478
+ function inferParameterTypeFromDefaultValue(paramValueExpr) {
12479
+ const defaultValueType = getTypeOfExpression(paramValueExpr, 1 /* EvaluatorFlags.ConvertEllipsisToAny */).type;
12480
+ let inferredParamType;
12481
+ // Is the default value a "None" or an instance of some private class (one
12482
+ // whose name starts with an underscore)? If so, we will assume that the
12483
+ // value is a singleton sentinel. The actual supported type is going to be
12484
+ // a union of this type and Unknown.
12485
+ if ((0, typeUtils_1.isNoneInstance)(defaultValueType) ||
12486
+ ((0, types_1.isClassInstance)(defaultValueType) && (0, symbolNameUtils_1.isPrivateOrProtectedName)(defaultValueType.details.name))) {
12487
+ inferredParamType = (0, types_1.combineTypes)([defaultValueType, types_1.UnknownType.create()]);
12488
+ }
12489
+ else {
12490
+ let skipInference = false;
12491
+ if ((0, types_1.isFunction)(defaultValueType) || (0, types_1.isOverloadedFunction)(defaultValueType)) {
12492
+ // Do not infer parameter types that use a lambda or another function as a
12493
+ // default value. We're likely to generate false positives in this case.
12494
+ // It's not clear whether parameters should be positional-only or not.
12495
+ skipInference = true;
12486
12496
  }
12487
- else {
12488
- let skipInference = false;
12489
- if ((0, types_1.isFunction)(defaultValueType) || (0, types_1.isOverloadedFunction)(defaultValueType)) {
12490
- // Do not infer parameter types that use a lambda or another function as a
12491
- // default value. We're likely to generate false positives in this case.
12492
- // It's not clear whether parameters should be positional-only or not.
12493
- skipInference = true;
12494
- }
12495
- else if ((0, types_1.isClassInstance)(defaultValueType) &&
12496
- types_1.ClassType.isBuiltIn(defaultValueType, ['tuple', 'list', 'set', 'dict'])) {
12497
- // Do not infer certain types like tuple because it's likely to be
12498
- // more restrictive (narrower) than intended.
12499
- skipInference = true;
12500
- }
12501
- if (!skipInference) {
12502
- inferredParamType = stripLiteralValue(defaultValueType);
12503
- }
12497
+ else if ((0, types_1.isClassInstance)(defaultValueType) &&
12498
+ types_1.ClassType.isBuiltIn(defaultValueType, ['tuple', 'list', 'set', 'dict'])) {
12499
+ // Do not infer certain types like tuple because it's likely to be
12500
+ // more restrictive (narrower) than intended.
12501
+ skipInference = true;
12504
12502
  }
12505
- if (inferredParamType) {
12506
- const fileInfo = AnalyzerNodeInfo.getFileInfo(functionNode);
12507
- if (fileInfo.isInPyTypedPackage && !fileInfo.isStubFile) {
12508
- inferredParamType = types_1.TypeBase.cloneForAmbiguousType(inferredParamType);
12509
- }
12503
+ if (!skipInference) {
12504
+ inferredParamType = stripLiteralValue(defaultValueType);
12510
12505
  }
12511
- return inferredParamType;
12512
12506
  }
12513
- return undefined;
12507
+ if (inferredParamType) {
12508
+ const fileInfo = AnalyzerNodeInfo.getFileInfo(paramValueExpr);
12509
+ if (fileInfo.isInPyTypedPackage && !fileInfo.isStubFile) {
12510
+ inferredParamType = types_1.TypeBase.cloneForAmbiguousType(inferredParamType);
12511
+ }
12512
+ }
12513
+ return inferredParamType;
12514
12514
  }
12515
12515
  // Transforms the parameter type based on its category. If it's a simple parameter,
12516
12516
  // no transform is applied. If it's a var-arg or keyword-arg parameter, the type
@@ -12565,7 +12565,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
12565
12565
  }
12566
12566
  return awaitableFunctionType;
12567
12567
  }
12568
- function createAwaitableReturnType(node, returnType, isGenerator) {
12568
+ function createAwaitableReturnType(node, returnType, isGenerator, useCoroutine = true) {
12569
12569
  let awaitableReturnType;
12570
12570
  if ((0, types_1.isClassInstance)(returnType)) {
12571
12571
  if (types_1.ClassType.isBuiltIn(returnType)) {
@@ -12593,10 +12593,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
12593
12593
  }
12594
12594
  }
12595
12595
  if (!awaitableReturnType || !isGenerator) {
12596
- // Wrap in a Coroutine, which is a subclass of Awaitable.
12597
- const coroutineType = getTypingType(node, 'Coroutine');
12598
- if (coroutineType && (0, types_1.isInstantiableClass)(coroutineType)) {
12599
- awaitableReturnType = types_1.ClassType.cloneAsInstance(types_1.ClassType.cloneForSpecialization(coroutineType, [types_1.AnyType.create(), types_1.AnyType.create(), returnType],
12596
+ // Wrap in either an Awaitable or a Coroutine, which is a subclass of Awaitable.
12597
+ const awaitableType = getTypingType(node, useCoroutine ? 'Coroutine' : 'Awaitable');
12598
+ if (awaitableType && (0, types_1.isInstantiableClass)(awaitableType)) {
12599
+ awaitableReturnType = types_1.ClassType.cloneAsInstance(types_1.ClassType.cloneForSpecialization(awaitableType, useCoroutine ? [types_1.AnyType.create(), types_1.AnyType.create(), returnType] : [returnType],
12600
12600
  /* isTypeArgumentExplicit */ true));
12601
12601
  }
12602
12602
  else {
@@ -13765,7 +13765,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
13765
13765
  break;
13766
13766
  }
13767
13767
  case 'Self': {
13768
- return { type: createSelfType(classType, errorNode, typeArgs) };
13768
+ return { type: createSelfType(classType, errorNode, typeArgs, flags) };
13769
13769
  }
13770
13770
  case 'LiteralString': {
13771
13771
  return { type: createSpecialType(classType, typeArgs, 0) };
@@ -15775,6 +15775,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15775
15775
  srcTypeArgs.splice(srcUnboundedIndex, 0, { type: typeToReplicate, isUnbounded: true });
15776
15776
  }
15777
15777
  }
15778
+ // Remove any optional parameters from the end of the two lists until the lengths match.
15779
+ while (srcTypeArgs.length > destTypeArgs.length && srcTypeArgs[srcTypeArgs.length - 1].isOptional) {
15780
+ srcTypeArgs.splice(srcTypeArgs.length - 1, 1);
15781
+ }
15782
+ while (destTypeArgs.length > srcTypeArgs.length && destTypeArgs[destTypeArgs.length - 1].isOptional) {
15783
+ destTypeArgs.splice(destTypeArgs.length - 1, 1);
15784
+ }
15778
15785
  const srcArgsToCapture = srcTypeArgs.length - destTypeArgs.length + 1;
15779
15786
  if (destUnboundedIndex >= 0 && srcArgsToCapture >= 0) {
15780
15787
  // If the dest contains a variadic element, determine which source
@@ -16313,14 +16320,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16313
16320
  typeTypeArg = types_1.UnknownType.create();
16314
16321
  }
16315
16322
  if ((0, types_1.isAnyOrUnknown)(typeTypeArg)) {
16316
- if ((0, types_1.isClassInstance)(destType) && types_1.ClassType.isBuiltIn(expandedSrcType, 'type')) {
16323
+ if ((0, typeUtils_1.isEffectivelyInstantiable)(destType)) {
16317
16324
  return true;
16318
16325
  }
16319
- return types_1.TypeBase.isInstantiable(destType);
16320
16326
  }
16321
- const instantiableType = (0, typeUtils_1.convertToInstantiable)(typeTypeArg);
16322
- if ((0, types_1.isClassInstance)(typeTypeArg) || (0, types_1.isTypeVar)(typeTypeArg)) {
16323
- if (assignType(destType, instantiableType, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), destTypeVarContext, srcTypeVarContext, flags, recursionCount)) {
16327
+ else if ((0, types_1.isClassInstance)(typeTypeArg) || (0, types_1.isTypeVar)(typeTypeArg)) {
16328
+ if (assignType(destType, (0, typeUtils_1.convertToInstantiable)(typeTypeArg), diag === null || diag === void 0 ? void 0 : diag.createAddendum(), destTypeVarContext, srcTypeVarContext, flags, recursionCount)) {
16324
16329
  return true;
16325
16330
  }
16326
16331
  diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.typeAssignmentMismatch().format(printSrcDestTypes(srcType, destType)));
@@ -17020,15 +17025,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17020
17025
  specializedSrcType = (0, typeUtils_1.applySolvedTypeVars)(srcType, srcTypeVarContext);
17021
17026
  }
17022
17027
  }
17023
- // Handle the special case where the source is a Self type and the
17024
- // destination is not.
17025
- if (!(0, types_1.isTypeVar)(specializedDestType) || !specializedDestType.details.isSynthesizedSelf) {
17026
- if ((0, types_1.isTypeVar)(specializedSrcType) &&
17027
- specializedSrcType.details.isSynthesizedSelf &&
17028
- specializedSrcType.details.boundType) {
17029
- specializedSrcType = (0, typeUtils_1.applySolvedTypeVars)(specializedSrcType.details.boundType, new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(specializedSrcType)), { unknownIfNotFound: true });
17030
- }
17031
- }
17032
17028
  if (!assignType(specializedSrcType, specializedDestType, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), srcTypeVarContext, destTypeVarContext, flags, recursionCount)) {
17033
17029
  // There are cases involving lambdas where the parameter types are type
17034
17030
  // variables and match exactly but fail the assignment check because the
@@ -17089,7 +17085,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17089
17085
  }
17090
17086
  }
17091
17087
  else {
17092
- srcTupleTypes.push({ type: entry.type, isUnbounded: false });
17088
+ srcTupleTypes.push({ type: entry.type, isUnbounded: false, isOptional: entry.param.hasDefault });
17093
17089
  }
17094
17090
  });
17095
17091
  if (srcTupleTypes.length !== 1 || !(0, types_1.isVariadicTypeVar)(srcTupleTypes[0].type)) {
@@ -18118,7 +18114,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
18118
18114
  let bestConstraintSoFar;
18119
18115
  // Try to find the best (narrowest) match among the constraints.
18120
18116
  for (const constraint of constraints) {
18121
- if (assignType(constraint, effectiveSrcType)) {
18117
+ // Don't allow Never as a type argument.
18118
+ if (assignType(constraint, effectiveSrcType) && !(0, types_1.isNever)(effectiveSrcType)) {
18122
18119
  if (!bestConstraintSoFar || assignType(bestConstraintSoFar, constraint)) {
18123
18120
  bestConstraintSoFar = constraint;
18124
18121
  }