@zzzen/pyright-internal 1.2.0-dev.20241006 → 1.2.0-dev.20241013

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 (63) hide show
  1. package/dist/analyzer/binder.js +1 -2
  2. package/dist/analyzer/binder.js.map +1 -1
  3. package/dist/analyzer/constraintSolver.js +11 -6
  4. package/dist/analyzer/constraintSolver.js.map +1 -1
  5. package/dist/analyzer/constraintTracker.d.ts +1 -0
  6. package/dist/analyzer/constraintTracker.js +7 -1
  7. package/dist/analyzer/constraintTracker.js.map +1 -1
  8. package/dist/analyzer/constructors.js +10 -8
  9. package/dist/analyzer/constructors.js.map +1 -1
  10. package/dist/analyzer/dataClasses.js +69 -19
  11. package/dist/analyzer/dataClasses.js.map +1 -1
  12. package/dist/analyzer/parameterUtils.d.ts +2 -1
  13. package/dist/analyzer/parameterUtils.js +2 -1
  14. package/dist/analyzer/parameterUtils.js.map +1 -1
  15. package/dist/analyzer/patternMatching.js +2 -2
  16. package/dist/analyzer/patternMatching.js.map +1 -1
  17. package/dist/analyzer/protocols.js +68 -26
  18. package/dist/analyzer/protocols.js.map +1 -1
  19. package/dist/analyzer/tuples.js +2 -2
  20. package/dist/analyzer/tuples.js.map +1 -1
  21. package/dist/analyzer/typeEvaluator.js +79 -53
  22. package/dist/analyzer/typeEvaluator.js.map +1 -1
  23. package/dist/analyzer/typePrinter.js +5 -7
  24. package/dist/analyzer/typePrinter.js.map +1 -1
  25. package/dist/analyzer/typeUtils.d.ts +2 -0
  26. package/dist/analyzer/typeUtils.js +81 -9
  27. package/dist/analyzer/typeUtils.js.map +1 -1
  28. package/dist/analyzer/types.d.ts +9 -4
  29. package/dist/analyzer/types.js +35 -4
  30. package/dist/analyzer/types.js.map +1 -1
  31. package/dist/common/pythonVersion.js +1 -1
  32. package/dist/languageService/completionProvider.d.ts +2 -2
  33. package/dist/languageService/completionProvider.js +11 -6
  34. package/dist/languageService/completionProvider.js.map +1 -1
  35. package/dist/localization/package.nls.cs.json +1 -0
  36. package/dist/localization/package.nls.de.json +1 -0
  37. package/dist/localization/package.nls.es.json +1 -0
  38. package/dist/localization/package.nls.fr.json +1 -0
  39. package/dist/localization/package.nls.it.json +1 -0
  40. package/dist/localization/package.nls.ja.json +1 -0
  41. package/dist/localization/package.nls.ko.json +1 -0
  42. package/dist/localization/package.nls.pl.json +1 -0
  43. package/dist/localization/package.nls.pt-br.json +1 -0
  44. package/dist/localization/package.nls.qps-ploc.json +1 -0
  45. package/dist/localization/package.nls.ru.json +1 -0
  46. package/dist/localization/package.nls.tr.json +1 -0
  47. package/dist/localization/package.nls.zh-cn.json +1 -0
  48. package/dist/localization/package.nls.zh-tw.json +1 -0
  49. package/dist/tests/fourslash/findDefinitions.dataclasses.converter.fourslash.d.ts +1 -0
  50. package/dist/tests/fourslash/findDefinitions.dataclasses.converter.fourslash.js +40 -0
  51. package/dist/tests/fourslash/findDefinitions.dataclasses.converter.fourslash.js.map +1 -0
  52. package/dist/tests/typeEvaluator1.test.js +1 -0
  53. package/dist/tests/typeEvaluator1.test.js.map +1 -1
  54. package/dist/tests/typeEvaluator3.test.js +1 -1
  55. package/dist/tests/typeEvaluator4.test.js +3 -2
  56. package/dist/tests/typeEvaluator4.test.js.map +1 -1
  57. package/dist/tests/typeEvaluator6.test.js +3 -3
  58. package/dist/tests/typeEvaluator6.test.js.map +1 -1
  59. package/dist/tests/typeEvaluator7.test.js +11 -2
  60. package/dist/tests/typeEvaluator7.test.js.map +1 -1
  61. package/dist/tests/typeEvaluator8.test.js +4 -0
  62. package/dist/tests/typeEvaluator8.test.js.map +1 -1
  63. package/package.json +1 -1
@@ -1109,7 +1109,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
1109
1109
  }
1110
1110
  }
1111
1111
  return (0, typeUtils_1.mapSubtypes)(type, (subtype) => {
1112
- var _a;
1113
1112
  if ((0, types_1.isClass)(subtype)) {
1114
1113
  if (subtype.priv.literalValue !== undefined) {
1115
1114
  subtype = types_1.ClassType.cloneWithLiteral(subtype, /* value */ undefined);
@@ -1118,9 +1117,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
1118
1117
  // Handle "LiteralString" specially.
1119
1118
  if (strClass && (0, types_1.isInstantiableClass)(strClass)) {
1120
1119
  let strInstance = types_1.ClassType.cloneAsInstance(strClass);
1121
- if ((_a = subtype.props) === null || _a === void 0 ? void 0 : _a.condition) {
1122
- strInstance = types_1.TypeBase.cloneForCondition(strInstance, (0, typeUtils_1.getTypeCondition)(subtype));
1123
- }
1120
+ strInstance = types_1.TypeBase.cloneForCondition(strInstance, (0, typeUtils_1.getTypeCondition)(subtype));
1124
1121
  return strInstance;
1125
1122
  }
1126
1123
  }
@@ -1554,10 +1551,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
1554
1551
  return undefined;
1555
1552
  }
1556
1553
  function getBoundMagicMethod(classType, memberName, selfType, diag, recursionCount = 0) {
1557
- if (recursionCount > types_1.maxTypeRecursionCount) {
1558
- return undefined;
1559
- }
1560
- recursionCount++;
1561
1554
  const boundMethodResult = getTypeOfBoundMember(
1562
1555
  /* errorNode */ undefined, classType, memberName,
1563
1556
  /* usage */ undefined, diag, 16 /* MemberAccessFlags.SkipInstanceMembers */ | 512 /* MemberAccessFlags.SkipAttributeAccessOverride */, selfType, recursionCount);
@@ -1568,6 +1561,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
1568
1561
  return boundMethodResult.type;
1569
1562
  }
1570
1563
  if ((0, types_1.isClassInstance)(boundMethodResult.type)) {
1564
+ if (recursionCount > types_1.maxTypeRecursionCount) {
1565
+ return undefined;
1566
+ }
1567
+ recursionCount++;
1571
1568
  return getBoundMagicMethod(boundMethodResult.type, '__call__', selfType !== null && selfType !== void 0 ? selfType : types_1.ClassType.cloneAsInstance(classType), diag, recursionCount);
1572
1569
  }
1573
1570
  if ((0, types_1.isAnyOrUnknown)(boundMethodResult.type)) {
@@ -2308,7 +2305,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
2308
2305
  const isTypeAlias = !!declaredType && (0, types_1.isClassInstance)(declaredType) && types_1.ClassType.isBuiltIn(declaredType, 'TypeAlias');
2309
2306
  if (declaredType && !isTypeAlias) {
2310
2307
  let diagAddendum = new diagnostic_1.DiagnosticAddendum();
2311
- if (!assignType(declaredType, typeResult.type, diagAddendum)) {
2308
+ const liveScopeIds = ParseTreeUtils.getTypeVarScopesForNode(nameNode);
2309
+ const boundDeclaredType = (0, typeUtils_1.makeTypeVarsBound)(declaredType, liveScopeIds);
2310
+ const srcType = (0, typeUtils_1.makeTypeVarsBound)(typeResult.type, liveScopeIds);
2311
+ if (!assignType(boundDeclaredType, srcType, diagAddendum)) {
2312
2312
  // If there was an expected type mismatch, use that diagnostic
2313
2313
  // addendum because it will be more informative.
2314
2314
  if (expectedTypeDiagAddendum) {
@@ -2714,6 +2714,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
2714
2714
  useBoundTypeVars: types_1.TypeVarType.isBound(subtype),
2715
2715
  });
2716
2716
  }
2717
+ if (subtype.priv.isUnpacked && (0, types_1.isClass)(boundType)) {
2718
+ boundType = types_1.ClassType.cloneForUnpacked(boundType);
2719
+ }
2717
2720
  boundType = types_1.TypeBase.isInstantiable(subtype) ? (0, typeUtils_1.convertToInstantiable)(boundType) : boundType;
2718
2721
  return (0, typeUtils_1.addConditionToType)(boundType, [{ typeVar: subtype, constraintIndex: 0 }]);
2719
2722
  }
@@ -2890,11 +2893,15 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
2890
2893
  break;
2891
2894
  }
2892
2895
  case 54 /* ParseNodeType.TypeAnnotation */: {
2893
- const annotationType = getTypeOfAnnotation(target.d.annotation, {
2896
+ let annotationType = getTypeOfAnnotation(target.d.annotation, {
2894
2897
  varTypeAnnotation: true,
2895
2898
  allowFinal: ParseTreeUtils.isFinalAllowedForAssignmentTarget(target.d.valueExpr),
2896
2899
  allowClassVar: ParseTreeUtils.isClassVarAllowedForAssignmentTarget(target.d.valueExpr),
2897
2900
  });
2901
+ if (annotationType) {
2902
+ const liveScopeIds = ParseTreeUtils.getTypeVarScopesForNode(target);
2903
+ annotationType = (0, typeUtils_1.makeTypeVarsBound)(annotationType, liveScopeIds);
2904
+ }
2898
2905
  // Handle a bare "Final" or "ClassVar" in a special manner.
2899
2906
  const isBareFinalOrClassVar = (0, types_1.isClassInstance)(annotationType) &&
2900
2907
  (types_1.ClassType.isBuiltIn(annotationType, 'Final') || types_1.ClassType.isBuiltIn(annotationType, 'ClassVar'));
@@ -3143,6 +3150,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
3143
3150
  if ((flags & 256 /* EvalFlags.TypeExpression */) !== 0) {
3144
3151
  type = validateSymbolIsTypeExpression(node, type, !!effectiveTypeInfo.includesVariableDecl);
3145
3152
  }
3153
+ if ((0, types_1.isTypeVar)(type) && !type.shared.isSynthesized) {
3154
+ type = validateTypeVarUsage(node, type, flags);
3155
+ }
3146
3156
  // Add TypeForm details if appropriate.
3147
3157
  type = addTypeFormForSymbol(node, type, flags, !!effectiveTypeInfo.includesVariableDecl);
3148
3158
  }
@@ -3156,7 +3166,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
3156
3166
  type = types_1.UnknownType.create();
3157
3167
  }
3158
3168
  }
3159
- if ((0, types_1.isParamSpec)(type)) {
3169
+ if ((0, types_1.isParamSpec)(type) && type.priv.scopeId) {
3160
3170
  if (flags & 32 /* EvalFlags.NoParamSpec */) {
3161
3171
  addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeForm, localize_1.LocMessage.paramSpecContext(), node);
3162
3172
  type = types_1.UnknownType.create();
@@ -3173,9 +3183,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
3173
3183
  }
3174
3184
  }
3175
3185
  }
3176
- if ((0, types_1.isTypeVar)(type) && !type.shared.isSynthesized) {
3177
- type = validateTypeVarUsage(node, type, flags);
3178
- }
3179
3186
  return { type, isIncomplete };
3180
3187
  }
3181
3188
  function addTypeFormForSymbol(node, type, flags, includesVarDecl) {
@@ -3231,7 +3238,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
3231
3238
  if ((0, typeUtils_1.isTypeAliasPlaceholder)(type)) {
3232
3239
  return true;
3233
3240
  }
3234
- if ((0, types_1.isTypeVar)(type) && !type.priv.scopeId) {
3241
+ if ((0, types_1.isTypeVar)(type)) {
3235
3242
  return true;
3236
3243
  }
3237
3244
  // Exempts class types that are created by calling NewType, NamedTuple, etc.
@@ -3470,7 +3477,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
3470
3477
  if (type.priv.scopeId && !scopedTypeVarInfo.foundInterveningClass) {
3471
3478
  return type;
3472
3479
  }
3473
- if (!type.shared.isSynthesized) {
3480
+ if (!type.shared.isSynthesized && (flags & 128 /* EvalFlags.InstantiableType */) !== 0) {
3474
3481
  const message = (0, types_1.isParamSpec)(type)
3475
3482
  ? localize_1.LocMessage.paramSpecNotUsedByOuterScope()
3476
3483
  : localize_1.LocMessage.typeVarNotUsedByOuterScope();
@@ -5559,7 +5566,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
5559
5566
  }
5560
5567
  else if ((options === null || options === void 0 ? void 0 : options.isAnnotatedClass) && argIndex > 0) {
5561
5568
  // If it's an Annotated[a, b, c], only the first index should be
5562
- // treated as a type.The others can be regular(non - type) objects.
5569
+ // treated as a type. The others can be regular (non-type) objects.
5563
5570
  adjFlags =
5564
5571
  32 /* EvalFlags.NoParamSpec */ | 64 /* EvalFlags.NoTypeVarTuple */ | 2 /* EvalFlags.NoSpecialize */ | 131072 /* EvalFlags.NoClassVar */;
5565
5572
  if ((0, analyzerFileInfo_1.isAnnotationEvaluationPostponed)(AnalyzerNodeInfo.getFileInfo(node))) {
@@ -5638,10 +5645,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
5638
5645
  if ((0, types_1.isTypeVar)(type)) {
5639
5646
  const upperBound = type.shared.boundType;
5640
5647
  if (upperBound && (0, types_1.isClassInstance)(upperBound) && (0, typeUtils_1.isTupleClass)(upperBound)) {
5641
- const concrete = makeTopLevelTypeVarsConcrete(type);
5642
- if ((0, types_1.isInstantiableClass)(concrete)) {
5643
- return types_1.ClassType.cloneForUnpacked(concrete);
5644
- }
5648
+ return types_1.TypeVarType.cloneForUnpacked(type);
5645
5649
  }
5646
5650
  return undefined;
5647
5651
  }
@@ -7216,7 +7220,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
7216
7220
  function evaluateCastCall(argList, errorNode) {
7217
7221
  var _a;
7218
7222
  // Verify that the cast is necessary.
7219
- const castToType = getTypeOfArgExpectingType(argList[0], { typeExpression: true }).type;
7223
+ let castToType = getTypeOfArgExpectingType(argList[0], { typeExpression: true }).type;
7224
+ const liveScopeIds = ParseTreeUtils.getTypeVarScopesForNode(errorNode);
7225
+ castToType = (0, typeUtils_1.makeTypeVarsBound)(castToType, liveScopeIds);
7220
7226
  let castFromType = getTypeOfArg(argList[1], /* inferenceContext */ undefined).type;
7221
7227
  if ((_a = castFromType.props) === null || _a === void 0 ? void 0 : _a.specialForm) {
7222
7228
  castFromType = castFromType.props.specialForm;
@@ -7449,7 +7455,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
7449
7455
  const paramInfo = paramDetails.params[paramIndex];
7450
7456
  const paramType = paramInfo.type;
7451
7457
  const paramName = paramInfo.param.name;
7452
- const isParamVariadic = paramInfo.param.category === 1 /* ParamCategory.ArgsList */ && (0, types_1.isTypeVarTuple)(paramType);
7458
+ const isParamVariadic = paramInfo.param.category === 1 /* ParamCategory.ArgsList */ && (0, types_1.isUnpacked)(paramType);
7453
7459
  if (argList[argIndex].argCategory === 1 /* ArgCategory.UnpackedList */) {
7454
7460
  let isArgCompatibleWithVariadic = false;
7455
7461
  const argTypeResult = getTypeOfArg(argList[argIndex], /* inferenceContext */ undefined);
@@ -7581,7 +7587,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
7581
7587
  paramType.priv.tupleTypeArgs.length > 0) {
7582
7588
  effectiveParamType = paramType.priv.tupleTypeArgs[0].type;
7583
7589
  }
7584
- paramCategory = (0, types_1.isTypeVarTuple)(effectiveParamType) ? 1 /* ParamCategory.ArgsList */ : 0 /* ParamCategory.Simple */;
7590
+ paramCategory = (0, types_1.isUnpacked)(effectiveParamType) ? 1 /* ParamCategory.ArgsList */ : 0 /* ParamCategory.Simple */;
7585
7591
  if (remainingArgCount <= remainingParamCount) {
7586
7592
  if (remainingArgCount < remainingParamCount) {
7587
7593
  if (!canSkipDiagnosticForNode(errorNode) && !isTypeIncomplete) {
@@ -8060,7 +8066,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
8060
8066
  !isTypeVarTupleFullyMatched) {
8061
8067
  const paramType = paramDetails.params[paramDetails.argsIndex].type;
8062
8068
  const variadicArgs = validateArgTypeParams.filter((argParam) => argParam.mapsToVarArgList);
8063
- if ((0, types_1.isTypeVarTuple)(paramType) && !paramType.priv.isInUnion) {
8069
+ if ((0, types_1.isUnpacked)(paramType) && (!(0, types_1.isTypeVarTuple)(paramType) || !paramType.priv.isInUnion)) {
8064
8070
  const tupleTypeArgs = variadicArgs.map((argParam) => {
8065
8071
  var _a;
8066
8072
  const argType = getTypeOfArg(argParam.argument, /* inferenceContext */ undefined).type;
@@ -8084,20 +8090,18 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
8084
8090
  };
8085
8091
  });
8086
8092
  let specializedTuple;
8087
- if (tupleTypeArgs.length === 1 &&
8088
- !tupleTypeArgs[0].isUnbounded &&
8089
- ((0, types_1.isUnpackedClass)(tupleTypeArgs[0].type) || (0, types_1.isTypeVarTuple)(tupleTypeArgs[0].type))) {
8090
- // If there is a single unpacked tuple or unpacked variadic type variable
8091
- // (including an unpacked TypeVarTuple union) within this tuple,
8092
- // simplify the type.
8093
- specializedTuple = tupleTypeArgs[0].type;
8093
+ if (tupleTypeArgs.length === 1 && !tupleTypeArgs[0].isUnbounded) {
8094
+ const entryType = tupleTypeArgs[0].type;
8095
+ if ((0, types_1.isUnpacked)(entryType)) {
8096
+ specializedTuple = (0, typeUtils_1.makePacked)(entryType);
8097
+ }
8094
8098
  }
8095
- else {
8096
- specializedTuple = (0, tuples_1.makeTupleObject)(evaluatorInterface, tupleTypeArgs, /* isUnpacked */ true);
8099
+ if (!specializedTuple) {
8100
+ specializedTuple = (0, tuples_1.makeTupleObject)(evaluatorInterface, tupleTypeArgs, /* isUnpacked */ false);
8097
8101
  }
8098
8102
  const combinedArg = {
8099
- paramCategory: 1 /* ParamCategory.ArgsList */,
8100
- paramType,
8103
+ paramCategory: 0 /* ParamCategory.Simple */,
8104
+ paramType: (0, typeUtils_1.makePacked)(paramType),
8101
8105
  requiresTypeVarMatching: true,
8102
8106
  argument: {
8103
8107
  argCategory: 0 /* ArgCategory.Simple */,
@@ -8423,7 +8427,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
8423
8427
  }
8424
8428
  // If the final return type is an unpacked tuple, turn it into a normal (unpacked) tuple.
8425
8429
  if ((0, types_1.isUnpackedClass)(specializedReturnType)) {
8426
- specializedReturnType = types_1.ClassType.cloneForUnpacked(specializedReturnType, /* isUnpacked */ false);
8430
+ specializedReturnType = types_1.ClassType.cloneForPacked(specializedReturnType);
8427
8431
  }
8428
8432
  const liveTypeVarScopes = ParseTreeUtils.getTypeVarScopesForNode(errorNode);
8429
8433
  specializedReturnType = adjustCallableReturnType(errorNode, specializedReturnType, liveTypeVarScopes);
@@ -10690,16 +10694,23 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
10690
10694
  // As per the specification, we support None, int, bool, str, bytes literals
10691
10695
  // plus enum values.
10692
10696
  const literalTypes = [];
10697
+ let isValidTypeForm = true;
10693
10698
  for (const item of node.d.items) {
10694
10699
  let type;
10695
10700
  const itemExpr = item.d.valueExpr;
10696
10701
  if (item.d.argCategory !== 0 /* ArgCategory.Simple */) {
10697
- addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeForm, localize_1.LocMessage.unpackedArgInTypeArgument(), itemExpr);
10698
- type = types_1.UnknownType.create();
10702
+ if ((flags & 256 /* EvalFlags.TypeExpression */) !== 0) {
10703
+ addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeForm, localize_1.LocMessage.unpackedArgInTypeArgument(), itemExpr);
10704
+ type = types_1.UnknownType.create();
10705
+ isValidTypeForm = false;
10706
+ }
10699
10707
  }
10700
10708
  else if (item.d.name) {
10701
- addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeForm, localize_1.LocMessage.keywordArgInTypeArgument(), itemExpr);
10702
- type = types_1.UnknownType.create();
10709
+ if ((flags & 256 /* EvalFlags.TypeExpression */) !== 0) {
10710
+ addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeForm, localize_1.LocMessage.keywordArgInTypeArgument(), itemExpr);
10711
+ type = types_1.UnknownType.create();
10712
+ isValidTypeForm = false;
10713
+ }
10703
10714
  }
10704
10715
  else if (itemExpr.nodeType === 48 /* ParseNodeType.StringList */) {
10705
10716
  const isBytes = (itemExpr.d.strings[0].d.token.flags & 32 /* StringTokenFlags.Bytes */) !== 0;
@@ -10710,11 +10721,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
10710
10721
  else {
10711
10722
  type = cloneBuiltinClassWithLiteral(node, classType, 'str', value);
10712
10723
  }
10713
- itemExpr.d.strings.forEach((stringNode) => {
10714
- if ((stringNode.d.token.flags & 512 /* StringTokenFlags.NamedUnicodeEscape */) !== 0) {
10715
- addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeForm, localize_1.LocMessage.literalNamedUnicodeEscape(), stringNode);
10716
- }
10717
- });
10724
+ if ((flags & 256 /* EvalFlags.TypeExpression */) !== 0) {
10725
+ itemExpr.d.strings.forEach((stringNode) => {
10726
+ if ((stringNode.d.token.flags & 512 /* StringTokenFlags.NamedUnicodeEscape */) !== 0) {
10727
+ addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeForm, localize_1.LocMessage.literalNamedUnicodeEscape(), stringNode);
10728
+ isValidTypeForm = false;
10729
+ }
10730
+ });
10731
+ }
10718
10732
  }
10719
10733
  else if (itemExpr.nodeType === 40 /* ParseNodeType.Number */) {
10720
10734
  if (!itemExpr.d.isImaginary && itemExpr.d.isInteger) {
@@ -10770,6 +10784,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
10770
10784
  if ((flags & 256 /* EvalFlags.TypeExpression */) !== 0) {
10771
10785
  addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeForm, localize_1.LocMessage.literalUnsupportedType(), item);
10772
10786
  type = types_1.UnknownType.create();
10787
+ isValidTypeForm = false;
10773
10788
  }
10774
10789
  else {
10775
10790
  return types_1.ClassType.cloneAsInstance(classType);
@@ -10781,7 +10796,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
10781
10796
  if ((0, types_1.isUnion)(result) && unionTypeClass && (0, types_1.isInstantiableClass)(unionTypeClass)) {
10782
10797
  result = types_1.TypeBase.cloneAsSpecialForm(result, types_1.ClassType.cloneAsInstance(unionTypeClass));
10783
10798
  }
10784
- if (isTypeFormSupported(node)) {
10799
+ if (isTypeFormSupported(node) && isValidTypeForm) {
10785
10800
  result = types_1.TypeBase.cloneWithTypeForm(result, (0, typeUtils_1.convertToInstance)(result));
10786
10801
  }
10787
10802
  return result;
@@ -11641,8 +11656,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
11641
11656
  }
11642
11657
  }
11643
11658
  if (!rightHandType) {
11644
- // Determine whether there is a declared type.
11645
- const declaredType = getDeclaredTypeForExpression(node.d.leftExpr, { method: 'set' });
11646
11659
  let typeAliasNameNode;
11647
11660
  let typeAliasPlaceholder;
11648
11661
  let isSpeculativeTypeAlias = false;
@@ -11686,6 +11699,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
11686
11699
  writeTypeCache(node.d.leftExpr.d.valueExpr, { type: typeAliasPlaceholder }, /* flags */ undefined);
11687
11700
  }
11688
11701
  }
11702
+ let declaredType = getDeclaredTypeForExpression(node.d.leftExpr, { method: 'set' });
11703
+ if (declaredType) {
11704
+ const liveTypeVarScopes = ParseTreeUtils.getTypeVarScopesForNode(node);
11705
+ declaredType = (0, typeUtils_1.makeTypeVarsBound)(declaredType, liveTypeVarScopes);
11706
+ }
11689
11707
  const srcTypeResult = getTypeOfExpression(node.d.rightExpr, flags, (0, typeUtils_1.makeInferenceContext)(declaredType));
11690
11708
  rightHandType = srcTypeResult.type;
11691
11709
  expectedTypeDiagAddendum = srcTypeResult.expectedTypeDiagAddendum;
@@ -13328,7 +13346,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
13328
13346
  return type;
13329
13347
  }
13330
13348
  if ((0, types_1.isUnpackedClass)(type)) {
13331
- return types_1.ClassType.cloneForUnpacked(type, /* isUnpacked */ false);
13349
+ return types_1.ClassType.cloneForPacked(type);
13332
13350
  }
13333
13351
  return (0, tuples_1.makeTupleObject)(evaluatorInterface, [{ type, isUnbounded: !(0, types_1.isTypeVarTuple)(type) }]);
13334
13352
  }
@@ -15419,7 +15437,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
15419
15437
  if (paramDecl) {
15420
15438
  declarations.push(paramDecl);
15421
15439
  }
15422
- else if (types_1.ClassType.isDataClass(baseType) || types_1.ClassType.isTypedDictClass(baseType)) {
15440
+ else if (types_1.ClassType.isDataClass(baseType) ||
15441
+ types_1.ClassType.isTypedDictClass(baseType) ||
15442
+ types_1.ClassType.hasNamedTupleEntry(baseType, paramName)) {
15423
15443
  const lookupResults = (0, typeUtils_1.lookUpClassMember)(baseType, paramName);
15424
15444
  if (lookupResults) {
15425
15445
  (0, collectionUtils_1.appendArray)(declarations, lookupResults.symbol.getDeclarations());
@@ -17404,6 +17424,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
17404
17424
  }
17405
17425
  let concreteSrcType = makeTopLevelTypeVarsConcrete(srcType);
17406
17426
  if ((0, types_1.isClass)(concreteSrcType) && types_1.TypeBase.isInstance(concreteSrcType)) {
17427
+ // Handle the case where the source is an unpacked tuple.
17428
+ if (!destType.priv.isUnpacked &&
17429
+ concreteSrcType.priv.isUnpacked &&
17430
+ concreteSrcType.priv.tupleTypeArgs) {
17431
+ return assignType(destType, (0, typeUtils_1.combineTupleTypeArgs)(concreteSrcType.priv.tupleTypeArgs), diag, constraints, flags, recursionCount);
17432
+ }
17407
17433
  // Handle enum literals that are assignable to another (non-Enum) literal.
17408
17434
  // This can happen for IntEnum and StrEnum members.
17409
17435
  if (types_1.ClassType.isEnumClass(concreteSrcType) &&
@@ -18322,11 +18348,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions, wrapWithLogger) {
18322
18348
  const destParamName = (_c = destParam.param.name) !== null && _c !== void 0 ? _c : '';
18323
18349
  const srcParamName = (_d = srcParam.param.name) !== null && _d !== void 0 ? _d : '';
18324
18350
  if (destParamName) {
18325
- const isDestPositionalOnly = destParam.kind === parameterUtils_1.ParamKind.Positional;
18351
+ const isDestPositionalOnly = destParam.kind === parameterUtils_1.ParamKind.Positional || destParam.kind === parameterUtils_1.ParamKind.ExpandedArgs;
18326
18352
  if (!isDestPositionalOnly &&
18327
18353
  destParam.param.category !== 1 /* ParamCategory.ArgsList */ &&
18328
18354
  srcParam.param.category !== 1 /* ParamCategory.ArgsList */) {
18329
- if (srcParam.kind === parameterUtils_1.ParamKind.Positional) {
18355
+ if (srcParam.kind === parameterUtils_1.ParamKind.Positional || srcParam.kind === parameterUtils_1.ParamKind.ExpandedArgs) {
18330
18356
  diag === null || diag === void 0 ? void 0 : diag.createAddendum().addMessage(localize_1.LocAddendum.functionParamPositionOnly().format({
18331
18357
  name: destParamName,
18332
18358
  }));