@zzzen/pyright-internal 1.2.0-dev.20220724 → 1.2.0-dev.20220814

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 (126) hide show
  1. package/dist/analyzer/binder.js +0 -1
  2. package/dist/analyzer/binder.js.map +1 -1
  3. package/dist/analyzer/checker.js +15 -9
  4. package/dist/analyzer/checker.js.map +1 -1
  5. package/dist/analyzer/codeFlowEngine.js +13 -7
  6. package/dist/analyzer/codeFlowEngine.js.map +1 -1
  7. package/dist/analyzer/constraintSolver.js +9 -14
  8. package/dist/analyzer/constraintSolver.js.map +1 -1
  9. package/dist/analyzer/docStringConversion.js +8 -7
  10. package/dist/analyzer/docStringConversion.js.map +1 -1
  11. package/dist/analyzer/enums.d.ts +13 -0
  12. package/dist/analyzer/enums.js +207 -0
  13. package/dist/analyzer/enums.js.map +1 -0
  14. package/dist/analyzer/importResolver.js +2 -2
  15. package/dist/analyzer/importResolver.js.map +1 -1
  16. package/dist/analyzer/importResult.d.ts +2 -1
  17. package/dist/analyzer/importStatementUtils.d.ts +7 -1
  18. package/dist/analyzer/importStatementUtils.js +28 -9
  19. package/dist/analyzer/importStatementUtils.js.map +1 -1
  20. package/dist/analyzer/packageTypeVerifier.js +26 -13
  21. package/dist/analyzer/packageTypeVerifier.js.map +1 -1
  22. package/dist/analyzer/parseTreeUtils.js +5 -0
  23. package/dist/analyzer/parseTreeUtils.js.map +1 -1
  24. package/dist/analyzer/patternMatching.js +2 -2
  25. package/dist/analyzer/patternMatching.js.map +1 -1
  26. package/dist/analyzer/program.d.ts +7 -3
  27. package/dist/analyzer/program.js +34 -12
  28. package/dist/analyzer/program.js.map +1 -1
  29. package/dist/analyzer/properties.js +1 -1
  30. package/dist/analyzer/properties.js.map +1 -1
  31. package/dist/analyzer/service.d.ts +6 -2
  32. package/dist/analyzer/service.js +6 -3
  33. package/dist/analyzer/service.js.map +1 -1
  34. package/dist/analyzer/sourceFile.d.ts +3 -1
  35. package/dist/analyzer/sourceFile.js +6 -0
  36. package/dist/analyzer/sourceFile.js.map +1 -1
  37. package/dist/analyzer/typeEvaluator.js +254 -271
  38. package/dist/analyzer/typeEvaluator.js.map +1 -1
  39. package/dist/analyzer/typeEvaluatorTypes.d.ts +11 -1
  40. package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
  41. package/dist/analyzer/typeEvaluatorWithTracker.js +2 -0
  42. package/dist/analyzer/typeEvaluatorWithTracker.js.map +1 -1
  43. package/dist/analyzer/typeGuards.js +1 -1
  44. package/dist/analyzer/typeGuards.js.map +1 -1
  45. package/dist/analyzer/typePrinter.js +8 -4
  46. package/dist/analyzer/typePrinter.js.map +1 -1
  47. package/dist/analyzer/typeUtils.d.ts +2 -3
  48. package/dist/analyzer/typeUtils.js +104 -78
  49. package/dist/analyzer/typeUtils.js.map +1 -1
  50. package/dist/analyzer/types.d.ts +6 -1
  51. package/dist/analyzer/types.js +34 -32
  52. package/dist/analyzer/types.js.map +1 -1
  53. package/dist/commands/commandResult.js +1 -1
  54. package/dist/commands/commandResult.js.map +1 -1
  55. package/dist/common/workspaceEditUtils.d.ts +1 -0
  56. package/dist/common/workspaceEditUtils.js +10 -6
  57. package/dist/common/workspaceEditUtils.js.map +1 -1
  58. package/dist/languageServerBase.d.ts +6 -4
  59. package/dist/languageServerBase.js +29 -17
  60. package/dist/languageServerBase.js.map +1 -1
  61. package/dist/languageService/analyzerServiceExecutor.js +4 -2
  62. package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
  63. package/dist/languageService/autoImporter.d.ts +23 -17
  64. package/dist/languageService/autoImporter.js +42 -30
  65. package/dist/languageService/autoImporter.js.map +1 -1
  66. package/dist/languageService/codeActionProvider.js +1 -1
  67. package/dist/languageService/codeActionProvider.js.map +1 -1
  68. package/dist/languageService/completionProvider.d.ts +2 -1
  69. package/dist/languageService/completionProvider.js +8 -50
  70. package/dist/languageService/completionProvider.js.map +1 -1
  71. package/dist/languageService/hoverProvider.js +5 -8
  72. package/dist/languageService/hoverProvider.js.map +1 -1
  73. package/dist/languageService/importAdder.d.ts +2 -1
  74. package/dist/languageService/importAdder.js +9 -3
  75. package/dist/languageService/importAdder.js.map +1 -1
  76. package/dist/languageService/quickActions.js +1 -1
  77. package/dist/languageService/quickActions.js.map +1 -1
  78. package/dist/languageService/renameModuleProvider.js +2 -2
  79. package/dist/languageService/renameModuleProvider.js.map +1 -1
  80. package/dist/languageService/signatureHelpProvider.js +3 -3
  81. package/dist/languageService/signatureHelpProvider.js.map +1 -1
  82. package/dist/languageService/tooltipUtils.d.ts +3 -2
  83. package/dist/languageService/tooltipUtils.js +30 -15
  84. package/dist/languageService/tooltipUtils.js.map +1 -1
  85. package/dist/parser/parser.d.ts +1 -0
  86. package/dist/parser/parser.js +9 -2
  87. package/dist/parser/parser.js.map +1 -1
  88. package/dist/pyright.js +3 -0
  89. package/dist/pyright.js.map +1 -1
  90. package/dist/server.js +3 -3
  91. package/dist/server.js.map +1 -1
  92. package/dist/tests/chainedSourceFiles.test.js +2 -0
  93. package/dist/tests/chainedSourceFiles.test.js.map +1 -1
  94. package/dist/tests/checker.test.js +1 -1
  95. package/dist/tests/docStringConversion.test.js +21 -21
  96. package/dist/tests/fourslash/completions.commitChars.fourslash.js +12 -0
  97. package/dist/tests/fourslash/completions.commitChars.fourslash.js.map +1 -1
  98. package/dist/tests/fourslash/completions.variableDocStrings.fourslash.js +15 -2
  99. package/dist/tests/fourslash/completions.variableDocStrings.fourslash.js.map +1 -1
  100. package/dist/tests/fourslash/hover.docstring.links.fourslash.js +1 -1
  101. package/dist/tests/fourslash/hover.docstring.links.fourslash.js.map +1 -1
  102. package/dist/tests/fourslash/hover.init.fourslash.js +2 -2
  103. package/dist/tests/fourslash/hover.init.fourslash.js.map +1 -1
  104. package/dist/tests/fourslash/hover.variable.docString.fourslash.js +12 -7
  105. package/dist/tests/fourslash/hover.variable.docString.fourslash.js.map +1 -1
  106. package/dist/tests/harness/fourslash/fourSlashParser.js +5 -1
  107. package/dist/tests/harness/fourslash/fourSlashParser.js.map +1 -1
  108. package/dist/tests/harness/fourslash/testLanguageService.js +4 -2
  109. package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
  110. package/dist/tests/harness/fourslash/testState.js +12 -9
  111. package/dist/tests/harness/fourslash/testState.js.map +1 -1
  112. package/dist/tests/importAdder.test.js +17 -2
  113. package/dist/tests/importAdder.test.js.map +1 -1
  114. package/dist/tests/testState.test.js +1 -1
  115. package/dist/tests/testState.test.js.map +1 -1
  116. package/dist/tests/typeEvaluator1.test.js +5 -1
  117. package/dist/tests/typeEvaluator1.test.js.map +1 -1
  118. package/dist/tests/typeEvaluator2.test.js +8 -0
  119. package/dist/tests/typeEvaluator2.test.js.map +1 -1
  120. package/dist/tests/typeEvaluator3.test.js +13 -1
  121. package/dist/tests/typeEvaluator3.test.js.map +1 -1
  122. package/dist/tests/typeEvaluator4.test.js +5 -1
  123. package/dist/tests/typeEvaluator4.test.js.map +1 -1
  124. package/dist/workspaceMap.js +18 -15
  125. package/dist/workspaceMap.js.map +1 -1
  126. package/package.json +2 -2
@@ -55,6 +55,7 @@ const constraintSolver_1 = require("./constraintSolver");
55
55
  const constructorTransform_1 = require("./constructorTransform");
56
56
  const dataClasses_1 = require("./dataClasses");
57
57
  const declarationUtils_1 = require("./declarationUtils");
58
+ const enums_1 = require("./enums");
58
59
  const functionTransform_1 = require("./functionTransform");
59
60
  const namedTuples_1 = require("./namedTuples");
60
61
  const ParseTreeUtils = __importStar(require("./parseTreeUtils"));
@@ -217,7 +218,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
217
218
  const asymmetricDescriptorAssignmentCache = new Set();
218
219
  const speculativeTypeTracker = new typeCache_1.SpeculativeTypeTracker();
219
220
  const suppressedNodeStack = [];
220
- let functionRecursionMap = new Map();
221
+ let functionRecursionMap = new Set();
221
222
  let codeFlowAnalyzerCache = new Map();
222
223
  let typeCache = new Map();
223
224
  let effectiveTypeCache = new Map();
@@ -264,7 +265,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
264
265
  // circular references in complex data structures, so it fails
265
266
  // to clean up the objects if we don't help it out.
266
267
  function disposeEvaluator() {
267
- functionRecursionMap = new Map();
268
+ functionRecursionMap = new Set();
268
269
  codeFlowAnalyzerCache = new Map();
269
270
  typeCache = new Map();
270
271
  effectiveTypeCache = new Map();
@@ -798,23 +799,46 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
798
799
  }
799
800
  else {
800
801
  // Evaluate the format string expressions in this context.
801
- node.strings.forEach((str) => {
802
- if (str.nodeType === 27 /* FormatString */) {
803
- str.expressions.forEach((expr) => {
804
- getTypeOfExpression(expr);
805
- });
802
+ let isLiteralString = true;
803
+ let isIncomplete = false;
804
+ node.strings.forEach((expr) => {
805
+ const typeResult = getTypeOfString(expr);
806
+ if (typeResult.isIncomplete) {
807
+ isIncomplete = true;
808
+ }
809
+ let isExprLiteralString = false;
810
+ if ((0, types_1.isClassInstance)(typeResult.type)) {
811
+ if (types_1.ClassType.isBuiltIn(typeResult.type, 'str') && typeResult.type.literalValue !== undefined) {
812
+ isExprLiteralString = true;
813
+ }
814
+ else if (types_1.ClassType.isBuiltIn(typeResult === null || typeResult === void 0 ? void 0 : typeResult.type, 'LiteralString')) {
815
+ isExprLiteralString = true;
816
+ }
817
+ }
818
+ if (!isExprLiteralString) {
819
+ isLiteralString = false;
806
820
  }
807
821
  });
808
822
  const isBytes = (node.strings[0].token.flags & 32 /* Bytes */) !== 0;
809
823
  // Don't create a literal type if it's an f-string.
810
824
  if (node.strings.some((str) => str.nodeType === 27 /* FormatString */)) {
811
- typeResult = {
812
- type: getBuiltInObject(node, isBytes ? 'bytes' : 'str'),
813
- };
825
+ if (isLiteralString) {
826
+ const literalStringType = getTypingType(node, 'LiteralString');
827
+ if (literalStringType && (0, types_1.isInstantiableClass)(literalStringType)) {
828
+ typeResult = { type: types_1.ClassType.cloneAsInstance(literalStringType) };
829
+ }
830
+ }
831
+ if (!typeResult) {
832
+ typeResult = {
833
+ type: getBuiltInObject(node, isBytes ? 'bytes' : 'str'),
834
+ isIncomplete,
835
+ };
836
+ }
814
837
  }
815
838
  else {
816
839
  typeResult = {
817
840
  type: cloneBuiltinObjectWithLiteral(node, isBytes ? 'bytes' : 'str', node.strings.map((s) => s.value).join('')),
841
+ isIncomplete,
818
842
  };
819
843
  }
820
844
  }
@@ -825,9 +849,34 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
825
849
  let typeResult;
826
850
  // Don't create a literal type if it's an f-string.
827
851
  if (node.nodeType === 27 /* FormatString */) {
828
- typeResult = {
829
- type: getBuiltInObject(node, isBytes ? 'bytes' : 'str'),
830
- };
852
+ let isLiteralString = true;
853
+ // If all of the format expressions are of type LiteralString, then
854
+ // the resulting formatted string is also LiteralString.
855
+ node.expressions.forEach((expr) => {
856
+ const exprType = getTypeOfExpression(expr).type;
857
+ if (!(0, types_1.isClassInstance)(exprType)) {
858
+ isLiteralString = false;
859
+ return;
860
+ }
861
+ if (types_1.ClassType.isBuiltIn(exprType, 'LiteralString')) {
862
+ return;
863
+ }
864
+ if (types_1.ClassType.isBuiltIn(exprType, 'str') && exprType.literalValue !== undefined) {
865
+ return;
866
+ }
867
+ isLiteralString = false;
868
+ });
869
+ if (!isBytes && isLiteralString) {
870
+ const literalStringType = getTypingType(node, 'LiteralString');
871
+ if (literalStringType && (0, types_1.isInstantiableClass)(literalStringType)) {
872
+ typeResult = { type: types_1.ClassType.cloneAsInstance(literalStringType) };
873
+ }
874
+ }
875
+ if (!typeResult) {
876
+ typeResult = {
877
+ type: getBuiltInObject(node, isBytes ? 'bytes' : 'str'),
878
+ };
879
+ }
831
880
  }
832
881
  else {
833
882
  typeResult = {
@@ -836,6 +885,26 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
836
885
  }
837
886
  return typeResult;
838
887
  }
888
+ function stripLiteralValue(type) {
889
+ if ((0, types_1.isClass)(type)) {
890
+ if (type.literalValue !== undefined) {
891
+ type = types_1.ClassType.cloneWithLiteral(type, /* value */ undefined);
892
+ }
893
+ else if (types_1.ClassType.isBuiltIn(type, 'LiteralString')) {
894
+ // Handle "LiteralString" specially.
895
+ if (strClassType && (0, types_1.isInstantiableClass)(strClassType)) {
896
+ type = types_1.ClassType.cloneAsInstance(strClassType);
897
+ }
898
+ }
899
+ return type;
900
+ }
901
+ if ((0, types_1.isUnion)(type)) {
902
+ return (0, typeUtils_1.mapSubtypes)(type, (subtype) => {
903
+ return stripLiteralValue(subtype);
904
+ });
905
+ }
906
+ return type;
907
+ }
839
908
  function getTypeOfParameterAnnotation(paramTypeNode, paramCategory) {
840
909
  return getTypeOfAnnotation(paramTypeNode, {
841
910
  associateTypeVarsWithScope: true,
@@ -1164,6 +1233,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
1164
1233
  if (memberInfo) {
1165
1234
  return {
1166
1235
  type: memberInfo.type,
1236
+ classType: memberInfo.classType,
1167
1237
  isIncomplete: !!memberInfo.isTypeIncomplete,
1168
1238
  isAsymmetricDescriptor: memberInfo.isAsymmetricDescriptor,
1169
1239
  };
@@ -1903,7 +1973,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
1903
1973
  if (types_1.TypeBase.isInstance(destType) &&
1904
1974
  !(0, symbolNameUtils_1.isConstantName)(nameValue) &&
1905
1975
  !(0, symbolUtils_1.isFinalVariable)(symbolWithScope.symbol)) {
1906
- destType = (0, typeUtils_1.stripLiteralValue)(destType);
1976
+ destType = stripLiteralValue(destType);
1907
1977
  }
1908
1978
  }
1909
1979
  }
@@ -2090,7 +2160,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
2090
2160
  const removedEntries = sourceEntryTypes.splice(targetUnpackIndex, sourceEntryTypes.length - targetTypes.length + 1);
2091
2161
  let combinedTypes = (0, types_1.combineTypes)(removedEntries);
2092
2162
  if (target.nodeType === 31 /* List */) {
2093
- combinedTypes = (0, typeUtils_1.stripLiteralValue)(combinedTypes);
2163
+ combinedTypes = stripLiteralValue(combinedTypes);
2094
2164
  }
2095
2165
  sourceEntryTypes.splice(targetUnpackIndex, 0, combinedTypes);
2096
2166
  }
@@ -2786,7 +2856,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
2786
2856
  // cannot be used in this location.
2787
2857
  function validateTypeVarUsage(node, type, flags) {
2788
2858
  var _a;
2789
- if (types_1.TypeBase.isInstantiable(type) && !(0, typeUtils_1.isTypeAliasPlaceholder)(type)) {
2859
+ if (types_1.TypeBase.isInstantiable(type) && !type.scopeId && !(0, typeUtils_1.isTypeAliasPlaceholder)(type)) {
2790
2860
  const scopedTypeVarInfo = findScopedTypeVar(node, type);
2791
2861
  type = scopedTypeVarInfo.type;
2792
2862
  if ((flags & 2048 /* DisallowTypeVarsWithScopeId */) !== 0 && type.scopeId !== undefined) {
@@ -3169,29 +3239,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3169
3239
  }
3170
3240
  }
3171
3241
  else {
3172
- // Handle the special case of LiteralString.
3173
- if (types_1.ClassType.isBuiltIn(baseType, 'LiteralString') &&
3174
- strClassType &&
3175
- (0, types_1.isInstantiableClass)(strClassType)) {
3176
- baseType = types_1.ClassType.cloneAsInstance(strClassType);
3177
- }
3178
3242
  // Handle the special case of 'name' and 'value' members within an enum.
3179
- if (types_1.ClassType.isEnumClass(baseType)) {
3180
- const literalValue = baseType.literalValue;
3181
- if (literalValue instanceof types_1.EnumLiteral) {
3182
- if (memberName === 'name' || memberName === '_name_') {
3183
- const strClass = getBuiltInType(node, 'str');
3184
- if ((0, types_1.isInstantiableClass)(strClass)) {
3185
- return {
3186
- type: types_1.ClassType.cloneAsInstance(types_1.ClassType.cloneWithLiteral(strClass, literalValue.itemName)),
3187
- isIncomplete,
3188
- };
3189
- }
3190
- }
3191
- else if (memberName === 'value' || memberName === '_value_') {
3192
- return { type: literalValue.itemType, isIncomplete };
3193
- }
3194
- }
3243
+ const enumMemberResult = (0, enums_1.getTypeOfEnumMember)(evaluatorInterface, node, baseType, memberName, isIncomplete);
3244
+ if (enumMemberResult) {
3245
+ return enumMemberResult;
3195
3246
  }
3196
3247
  const typeResult = getTypeOfObjectMember(node.memberName, baseType, memberName, usage, diag,
3197
3248
  /* memberAccessFlags */ undefined, baseTypeResult.bindToType);
@@ -3451,7 +3502,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3451
3502
  // because that case is used for super() calls where we want
3452
3503
  // to leave the Self type generic (not specialized).
3453
3504
  const selfClass = bindToType ? undefined : classType;
3454
- const typeResult = getTypeOfMemberInternal(errorNode, memberInfo, selfClass);
3505
+ const typeResult = getTypeOfMemberInternal(memberInfo, selfClass);
3455
3506
  if (typeResult) {
3456
3507
  type = typeResult.type;
3457
3508
  if (typeResult.isIncomplete) {
@@ -4894,7 +4945,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
4894
4945
  return { type: types_1.UnknownType.create(/* isIncomplete */ true), isIncomplete: true };
4895
4946
  }
4896
4947
  const assertedType = (0, typeUtils_1.convertToInstance)(getTypeOfArgumentExpectingType(node.arguments[1]).type);
4897
- if (!(0, types_1.isTypeSame)(assertedType, arg0TypeResult.type)) {
4948
+ if (!(0, types_1.isTypeSame)(assertedType, arg0TypeResult.type, { treatAnySameAsUnknown: true })) {
4898
4949
  addDiagnostic(AnalyzerNodeInfo.getFileInfo(node).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.assertTypeTypeMismatch().format({
4899
4950
  expected: printType(assertedType),
4900
4951
  received: printType(arg0TypeResult.type),
@@ -5385,7 +5436,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
5385
5436
  // Is this a union type? If so, we can expand it.
5386
5437
  const argType = contextFreeArgTypes[indexToExpand];
5387
5438
  if ((0, types_1.isUnion)(argType)) {
5388
- unionToExpand = argType;
5439
+ unionToExpand = makeTopLevelTypeVarsConcrete(argType);
5440
+ break;
5441
+ }
5442
+ else if ((0, types_1.isTypeVar)(argType) && argType.details.constraints.length > 1) {
5443
+ unionToExpand = makeTopLevelTypeVarsConcrete(argType);
5389
5444
  break;
5390
5445
  }
5391
5446
  indexToExpand++;
@@ -5798,8 +5853,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
5798
5853
  const castToType = getTypeOfArgumentExpectingType(argList[0]).type;
5799
5854
  const castFromType = getTypeOfArgument(argList[1]).type;
5800
5855
  if ((0, types_1.isInstantiableClass)(castToType) && (0, types_1.isClassInstance)(castFromType)) {
5801
- if ((0, types_1.isTypeSame)(castToType, types_1.ClassType.cloneAsInstantiable(castFromType),
5802
- /* ignorePseudoGeneric */ true)) {
5856
+ if ((0, types_1.isTypeSame)(castToType, types_1.ClassType.cloneAsInstantiable(castFromType), {
5857
+ ignorePseudoGeneric: true,
5858
+ })) {
5803
5859
  addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.reportUnnecessaryCast, diagnosticRules_1.DiagnosticRule.reportUnnecessaryCast, localize_1.Localizer.Diagnostic.unnecessaryCast().format({
5804
5860
  type: printType(castFromType),
5805
5861
  }), errorNode);
@@ -5853,7 +5909,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
5853
5909
  if ((0, types_1.isClassInstance)(subtype) ||
5854
5910
  ((0, types_1.isTypeVar)(subtype) && types_1.TypeBase.isInstance(subtype)) ||
5855
5911
  (0, types_1.isNoneInstance)(subtype)) {
5856
- return (0, typeUtils_1.convertToInstantiable)((0, typeUtils_1.stripLiteralValue)(subtype));
5912
+ return (0, typeUtils_1.convertToInstantiable)(stripLiteralValue(subtype));
5857
5913
  }
5858
5914
  return types_1.AnyType.create();
5859
5915
  });
@@ -5892,18 +5948,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
5892
5948
  addDiagnostic(fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.typeNotIntantiable().format({ type: className }), errorNode);
5893
5949
  return types_1.AnyType.create();
5894
5950
  }
5895
- if (className === 'Enum' ||
5896
- className === 'IntEnum' ||
5897
- className === 'StrEnum' ||
5898
- className === 'Flag' ||
5899
- className === 'IntFlag') {
5900
- return createEnumType(errorNode, expandedSubtype, argList);
5951
+ if ((0, enums_1.isKnownEnumType)(className)) {
5952
+ return (0, enums_1.createEnumType)(errorNode, expandedSubtype, argList);
5901
5953
  }
5902
5954
  if (className === 'TypedDict') {
5903
5955
  return (0, typedDicts_1.createTypedDictType)(evaluatorInterface, errorNode, expandedSubtype, argList);
5904
5956
  }
5905
5957
  if (className === 'auto' && argList.length === 0) {
5906
- return getBuiltInObject(errorNode, 'int');
5958
+ return (0, enums_1.getEnumAutoValueType)(evaluatorInterface, errorNode);
5907
5959
  }
5908
5960
  }
5909
5961
  if (types_1.ClassType.supportsAbstractMethods(expandedSubtype)) {
@@ -6694,7 +6746,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
6694
6746
  reportedArgError = true;
6695
6747
  }
6696
6748
  return {
6697
- type: (0, typeUtils_1.stripLiteralValue)(argType),
6749
+ type: stripLiteralValue(argType),
6698
6750
  isUnbounded: argParam.argument.argumentCategory === 1 /* UnpackedList */,
6699
6751
  };
6700
6752
  });
@@ -6838,7 +6890,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
6838
6890
  type.strippedFirstParamType.typeArguments.forEach((typeArg, index) => {
6839
6891
  if (index < typeParams.length) {
6840
6892
  const typeParam = typeParams[index];
6841
- if (!(0, types_1.isTypeSame)(typeParam, typeArg, /* ignorePseudoGeneric */ true)) {
6893
+ if (!(0, types_1.isTypeSame)(typeParam, typeArg, { ignorePseudoGeneric: true })) {
6842
6894
  typeVarContext.setTypeVarType(typeParams[index], typeArg);
6843
6895
  }
6844
6896
  }
@@ -7231,7 +7283,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7231
7283
  // strip literals before performing the assignment. This is used in
7232
7284
  // places like a dict constructor.
7233
7285
  if (argParam.paramCategory === 2 /* VarArgDictionary */ && (0, types_1.isTypeVar)(argParam.paramType)) {
7234
- argType = (0, typeUtils_1.stripLiteralValue)(argType);
7286
+ argType = stripLiteralValue(argType);
7235
7287
  }
7236
7288
  // If there's a constraint filter, apply it to top-level type variables
7237
7289
  // if appropriate. This doesn't properly handle non-top-level constrained
@@ -7545,80 +7597,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7545
7597
  nameParts.push(moduleName);
7546
7598
  return nameParts.reverse().join('.');
7547
7599
  }
7548
- // Creates a new custom enum class with named values.
7549
- function createEnumType(errorNode, enumClass, argList) {
7550
- const fileInfo = AnalyzerNodeInfo.getFileInfo(errorNode);
7551
- let className = 'enum';
7552
- if (argList.length === 0) {
7553
- return undefined;
7554
- }
7555
- else {
7556
- const nameArg = argList[0];
7557
- if (nameArg.argumentCategory === 0 /* Simple */ &&
7558
- nameArg.valueExpression &&
7559
- nameArg.valueExpression.nodeType === 48 /* StringList */) {
7560
- className = nameArg.valueExpression.strings.map((s) => s.value).join('');
7561
- }
7562
- else {
7563
- return undefined;
7564
- }
7565
- }
7566
- const classType = types_1.ClassType.createInstantiable(className, ParseTreeUtils.getClassFullName(errorNode, fileInfo.moduleName, className), fileInfo.moduleName, fileInfo.filePath, 1048576 /* EnumClass */, ParseTreeUtils.getTypeSourceId(errorNode),
7567
- /* declaredMetaclass */ undefined, enumClass.details.effectiveMetaclass);
7568
- classType.details.baseClasses.push(enumClass);
7569
- (0, typeUtils_1.computeMroLinearization)(classType);
7570
- const classFields = classType.details.fields;
7571
- classFields.set('__class__', symbol_1.Symbol.createWithType(4 /* ClassMember */ | 64 /* IgnoredForProtocolMatch */, classType));
7572
- if (argList.length < 2) {
7573
- return undefined;
7574
- }
7575
- else {
7576
- const entriesArg = argList[1];
7577
- if (entriesArg.argumentCategory !== 0 /* Simple */ ||
7578
- !entriesArg.valueExpression ||
7579
- entriesArg.valueExpression.nodeType !== 48 /* StringList */) {
7580
- // Technically, the Enum constructor supports a bunch of different
7581
- // ways to specify the items: space-delimited string, a string
7582
- // iterator, an iterator of name/value tuples, and a dictionary
7583
- // of name/value pairs. We support only the simple space-delimited
7584
- // string here. For users who are interested in type checking, we
7585
- // recommend using the more standard class declaration syntax.
7586
- return undefined;
7587
- }
7588
- else {
7589
- const entries = entriesArg.valueExpression.strings
7590
- .map((s) => s.value)
7591
- .join('')
7592
- .split(' ');
7593
- entries.forEach((entryName) => {
7594
- entryName = entryName.trim();
7595
- if (entryName) {
7596
- const entryType = types_1.UnknownType.create();
7597
- const newSymbol = symbol_1.Symbol.createWithType(4 /* ClassMember */, entryType);
7598
- // We need to associate the declaration with a parse node.
7599
- // In this case it's just part of a string literal value.
7600
- // The definition provider won't necessarily take the
7601
- // user to the exact spot in the string, but it's close enough.
7602
- const stringNode = entriesArg.valueExpression;
7603
- (0, debug_1.assert)(stringNode.nodeType === 48 /* StringList */);
7604
- const fileInfo = AnalyzerNodeInfo.getFileInfo(errorNode);
7605
- const declaration = {
7606
- type: 1 /* Variable */,
7607
- node: stringNode,
7608
- isRuntimeTypeExpression: true,
7609
- path: fileInfo.filePath,
7610
- range: (0, positionUtils_1.convertOffsetsToRange)(stringNode.start, textRange_1.TextRange.getEnd(stringNode), fileInfo.lines),
7611
- moduleName: fileInfo.moduleName,
7612
- isInExceptSuite: false,
7613
- };
7614
- newSymbol.addDeclaration(declaration);
7615
- classFields.set(entryName, newSymbol);
7616
- }
7617
- });
7618
- }
7619
- }
7620
- return classType;
7621
- }
7622
7600
  // Implements the semantics of the NewType call as documented
7623
7601
  // in the Python specification: The static type checker will treat
7624
7602
  // the new type as if it were a subclass of the original type.
@@ -7698,7 +7676,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7698
7676
  /* declaredMetaclass */ undefined, arg1Type.details.effectiveMetaclass);
7699
7677
  arg1Type.tupleTypeArguments.forEach((typeArg) => {
7700
7678
  const specializedType = makeTopLevelTypeVarsConcrete(typeArg.type);
7701
- if ((0, types_1.isInstantiableClass)(specializedType) || (0, types_1.isAnyOrUnknown)(specializedType)) {
7679
+ if ((0, types_1.isInstantiableClass)(specializedType) ||
7680
+ (0, types_1.isAnyOrUnknown)(specializedType) ||
7681
+ ((0, types_1.isClassInstance)(specializedType) && types_1.ClassType.isBuiltIn(specializedType, 'type'))) {
7702
7682
  classType.details.baseClasses.push(specializedType);
7703
7683
  }
7704
7684
  else {
@@ -8370,12 +8350,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8370
8350
  if ((0, types_1.isAnyOrUnknown)(subtype)) {
8371
8351
  return subtype;
8372
8352
  }
8373
- if ((0, types_1.isClassInstance)(subtype) &&
8374
- types_1.ClassType.isBuiltIn(subtype, 'LiteralString') &&
8375
- strClassType &&
8376
- (0, types_1.isInstantiableClass)(strClassType)) {
8377
- return handleSubtype(types_1.ClassType.cloneAsInstance(strClassType));
8378
- }
8379
8353
  if ((0, types_1.isClassInstance)(subtype) || (0, types_1.isInstantiableClass)(subtype) || (0, types_1.isTypeVar)(subtype)) {
8380
8354
  return handleSubtype(subtype);
8381
8355
  }
@@ -8519,8 +8493,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8519
8493
  isIncomplete = true;
8520
8494
  }
8521
8495
  // Strip any literal values.
8522
- keyTypes = keyTypes.map((t) => (0, typeUtils_1.stripLiteralValue)(t));
8523
- valueTypes = valueTypes.map((t) => (0, typeUtils_1.stripLiteralValue)(t));
8496
+ keyTypes = keyTypes.map((t) => stripLiteralValue(t));
8497
+ valueTypes = valueTypes.map((t) => stripLiteralValue(t));
8524
8498
  keyType = keyTypes.length > 0 ? (0, types_1.combineTypes)(keyTypes) : fallbackType;
8525
8499
  // If the value type differs and we're not using "strict inference mode",
8526
8500
  // we need to back off because we can't properly represent the mappings
@@ -8532,7 +8506,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8532
8506
  valueType = (0, types_1.combineTypes)(valueTypes);
8533
8507
  }
8534
8508
  else {
8535
- valueType = (0, typeUtils_1.areTypesSame)(valueTypes, /* ignorePseudoGeneric */ true) ? valueTypes[0] : fallbackType;
8509
+ valueType = (0, typeUtils_1.areTypesSame)(valueTypes, { ignorePseudoGeneric: true }) ? valueTypes[0] : fallbackType;
8536
8510
  }
8537
8511
  }
8538
8512
  else {
@@ -8596,6 +8570,21 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8596
8570
  if ((0, types_1.isAnyOrUnknown)(unexpandedType)) {
8597
8571
  addUnknown = false;
8598
8572
  }
8573
+ else if ((0, types_1.isClassInstance)(unexpandedType) && types_1.ClassType.isTypedDictClass(unexpandedType)) {
8574
+ // Handle dictionary expansion for a TypedDict.
8575
+ if (strClassType && (0, types_1.isInstantiableClass)(strClassType)) {
8576
+ const strObject = types_1.ClassType.cloneAsInstance(strClassType);
8577
+ const tdEntries = (0, typedDicts_1.getTypedDictMembersForClass)(evaluatorInterface, unexpandedType,
8578
+ /* allowNarrowed */ true);
8579
+ tdEntries.forEach((entry, name) => {
8580
+ if (entry.isRequired || entry.isProvided) {
8581
+ keyTypes.push(types_1.ClassType.cloneWithLiteral(strObject, name));
8582
+ valueTypes.push(entry.valueType);
8583
+ }
8584
+ });
8585
+ addUnknown = false;
8586
+ }
8587
+ }
8599
8588
  else {
8600
8589
  // Verify that the type supports the `keys` and `__getitem__` methods.
8601
8590
  // This protocol is defined in the _typeshed stub. If we can't find
@@ -8687,6 +8676,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8687
8676
  const builtInClassName = node.nodeType === 31 /* List */ ? 'list' : 'set';
8688
8677
  expectedType = (0, typeUtils_1.transformPossibleRecursiveTypeAlias)(expectedType);
8689
8678
  let isIncomplete = false;
8679
+ let typeErrors = false;
8690
8680
  if (!(0, types_1.isClassInstance)(expectedType)) {
8691
8681
  return undefined;
8692
8682
  }
@@ -8716,6 +8706,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8716
8706
  if (entryTypeResult.isIncomplete) {
8717
8707
  isIncomplete = true;
8718
8708
  }
8709
+ if (entryTypeResult.typeErrors) {
8710
+ typeErrors = true;
8711
+ }
8719
8712
  });
8720
8713
  const isExpectedTypeListOrSet = (0, types_1.isClassInstance)(expectedType) && types_1.ClassType.isBuiltIn(expectedType, builtInClassName);
8721
8714
  const specializedEntryType = inferTypeArgFromExpectedType(expectedEntryType, entryTypes,
@@ -8724,13 +8717,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8724
8717
  return undefined;
8725
8718
  }
8726
8719
  const type = getBuiltInObject(node, builtInClassName, [specializedEntryType]);
8727
- return { type, isIncomplete };
8720
+ return { type, isIncomplete, typeErrors };
8728
8721
  }
8729
8722
  // Attempts to infer the type of a list or set statement with no "expected type".
8730
8723
  function getTypeOfListOrSetInferred(node, hasExpectedType) {
8731
8724
  const builtInClassName = node.nodeType === 31 /* List */ ? 'list' : 'set';
8732
8725
  let isEmptyContainer = false;
8733
8726
  let isIncomplete = false;
8727
+ let typeErrors = false;
8734
8728
  let entryTypes = [];
8735
8729
  node.entries.forEach((entry, index) => {
8736
8730
  let entryTypeResult;
@@ -8744,11 +8738,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8744
8738
  if (entryTypeResult.isIncomplete) {
8745
8739
  isIncomplete = true;
8746
8740
  }
8741
+ if (entryTypeResult.typeErrors) {
8742
+ typeErrors = true;
8743
+ }
8747
8744
  if (index < maxEntriesToUseForInference) {
8748
8745
  entryTypes.push(entryTypeResult.type);
8749
8746
  }
8750
8747
  });
8751
- entryTypes = entryTypes.map((t) => (0, typeUtils_1.stripLiteralValue)(t));
8748
+ entryTypes = entryTypes.map((t) => stripLiteralValue(t));
8752
8749
  let inferredEntryType = hasExpectedType ? types_1.AnyType.create() : types_1.UnknownType.create();
8753
8750
  if (entryTypes.length > 0) {
8754
8751
  const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
@@ -8761,7 +8758,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8761
8758
  }
8762
8759
  else {
8763
8760
  // Is the list or set homogeneous? If so, use stricter rules. Otherwise relax the rules.
8764
- inferredEntryType = (0, typeUtils_1.areTypesSame)(entryTypes, /* ignorePseudoGeneric */ true)
8761
+ inferredEntryType = (0, typeUtils_1.areTypesSame)(entryTypes, { ignorePseudoGeneric: true })
8765
8762
  ? entryTypes[0]
8766
8763
  : inferredEntryType;
8767
8764
  }
@@ -8776,7 +8773,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8776
8773
  /* includeSubclasses */ undefined,
8777
8774
  /* TupleTypeArguments */ undefined, isEmptyContainer))
8778
8775
  : types_1.UnknownType.create();
8779
- return { type, isIncomplete };
8776
+ return { type, isIncomplete, typeErrors };
8780
8777
  }
8781
8778
  function inferTypeArgFromExpectedType(expectedType, entryTypes, isNarrowable) {
8782
8779
  let targetTypeVar;
@@ -8806,7 +8803,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8806
8803
  if (useSynthesizedTypeVar) {
8807
8804
  typeVarContext.setTypeVarType(targetTypeVar, isNarrowable ? undefined : expectedType, expectedType);
8808
8805
  }
8809
- if (entryTypes.every((entryType) => assignType(targetTypeVar, (0, typeUtils_1.stripLiteralValue)(entryType), /* diag */ undefined, typeVarContext))) {
8806
+ if (entryTypes.every((entryType) => assignType(targetTypeVar, stripLiteralValue(entryType), /* diag */ undefined, typeVarContext))) {
8810
8807
  return (0, typeUtils_1.applySolvedTypeVars)(targetTypeVar, typeVarContext);
8811
8808
  }
8812
8809
  // Allocate a fresh typeVarContext before we try again with literals not stripped.
@@ -8824,12 +8821,16 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8824
8821
  getTypeOfExpression(node.testExpression);
8825
8822
  const typesToCombine = [];
8826
8823
  let isIncomplete = false;
8824
+ let typeErrors = false;
8827
8825
  if (isNodeReachable(node.ifExpression)) {
8828
8826
  const ifType = getTypeOfExpression(node.ifExpression, flags, expectedType);
8829
8827
  typesToCombine.push(ifType.type);
8830
8828
  if (ifType.isIncomplete) {
8831
8829
  isIncomplete = true;
8832
8830
  }
8831
+ if (ifType.typeErrors) {
8832
+ typeErrors = true;
8833
+ }
8833
8834
  }
8834
8835
  if (isNodeReachable(node.elseExpression)) {
8835
8836
  const elseType = getTypeOfExpression(node.elseExpression, flags, expectedType);
@@ -8837,8 +8838,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8837
8838
  if (elseType.isIncomplete) {
8838
8839
  isIncomplete = true;
8839
8840
  }
8841
+ if (elseType.typeErrors) {
8842
+ typeErrors = true;
8843
+ }
8840
8844
  }
8841
- return { type: (0, types_1.combineTypes)(typesToCombine), isIncomplete };
8845
+ return { type: (0, types_1.combineTypes)(typesToCombine), isIncomplete, typeErrors };
8842
8846
  }
8843
8847
  function getTypeOfYield(node) {
8844
8848
  let expectedYieldType;
@@ -9014,10 +9018,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
9014
9018
  }
9015
9019
  function getTypeOfListComprehension(node, expectedType) {
9016
9020
  let isIncomplete = false;
9021
+ let typeErrors = false;
9017
9022
  const elementTypeResult = getElementTypeFromListComprehension(node);
9018
9023
  if (elementTypeResult.isIncomplete) {
9019
9024
  isIncomplete = true;
9020
9025
  }
9026
+ if (elementTypeResult.typeErrors) {
9027
+ typeErrors = true;
9028
+ }
9021
9029
  const elementType = elementTypeResult.type;
9022
9030
  let isAsync = node.forIfNodes.some((comp) => {
9023
9031
  return ((comp.nodeType === 33 /* ListComprehensionFor */ && comp.isAsync) ||
@@ -9043,7 +9051,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
9043
9051
  : [elementType, types_1.NoneType.createInstance(), types_1.NoneType.createInstance()],
9044
9052
  /* isTypeArgumentExplicit */ true));
9045
9053
  }
9046
- return { type, isIncomplete };
9054
+ return { type, isIncomplete, typeErrors };
9047
9055
  }
9048
9056
  function reportPossibleUnknownAssignment(diagLevel, rule, target, type, errorNode, ignoreEmptyContainers) {
9049
9057
  // Don't bother if the feature is disabled.
@@ -9080,7 +9088,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
9080
9088
  if (iterableTypeResult.isIncomplete) {
9081
9089
  isIncomplete = true;
9082
9090
  }
9083
- const iterableType = (0, typeUtils_1.stripLiteralValue)(iterableTypeResult.type);
9091
+ const iterableType = stripLiteralValue(iterableTypeResult.type);
9084
9092
  const itemType = (_a = getTypeOfIterator(iterableType, !!node.isAsync, node.iterableExpression)) !== null && _a !== void 0 ? _a : types_1.UnknownType.create();
9085
9093
  const targetExpr = node.targetExpression;
9086
9094
  assignTypeToExpression(targetExpr, itemType, !!iterableTypeResult.isIncomplete, node.iterableExpression);
@@ -9100,6 +9108,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
9100
9108
  // as opposed to the entire list.
9101
9109
  function getElementTypeFromListComprehension(node, expectedValueOrElementType, expectedKeyType) {
9102
9110
  let isIncomplete = false;
9111
+ let typeErrors = false;
9103
9112
  // "Execute" the list comprehensions from start to finish.
9104
9113
  for (const forIfNode of node.forIfNodes) {
9105
9114
  if (evaluateListComprehensionForIf(forIfNode)) {
@@ -9114,18 +9123,24 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
9114
9123
  if (keyTypeResult.isIncomplete) {
9115
9124
  isIncomplete = true;
9116
9125
  }
9126
+ if (keyTypeResult.typeErrors) {
9127
+ typeErrors = true;
9128
+ }
9117
9129
  let keyType = keyTypeResult.type;
9118
9130
  if (!expectedKeyType || !(0, typeUtils_1.containsLiteralType)(expectedKeyType)) {
9119
- keyType = (0, typeUtils_1.stripLiteralValue)(keyType);
9131
+ keyType = stripLiteralValue(keyType);
9120
9132
  }
9121
9133
  const valueTypeResult = getTypeOfExpression(node.expression.valueExpression,
9122
9134
  /* flags */ undefined, expectedValueOrElementType);
9123
9135
  if (valueTypeResult.isIncomplete) {
9124
9136
  isIncomplete = true;
9125
9137
  }
9138
+ if (valueTypeResult.typeErrors) {
9139
+ typeErrors = true;
9140
+ }
9126
9141
  let valueType = valueTypeResult.type;
9127
9142
  if (!expectedValueOrElementType || !(0, typeUtils_1.containsLiteralType)(expectedValueOrElementType)) {
9128
- valueType = (0, typeUtils_1.stripLiteralValue)(valueType);
9143
+ valueType = stripLiteralValue(valueType);
9129
9144
  }
9130
9145
  type = makeTupleObject([keyType, valueType]);
9131
9146
  }
@@ -9139,9 +9154,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
9139
9154
  if (exprTypeResult.isIncomplete) {
9140
9155
  isIncomplete = true;
9141
9156
  }
9157
+ if (exprTypeResult.typeErrors) {
9158
+ typeErrors = true;
9159
+ }
9142
9160
  type = exprTypeResult.type;
9143
9161
  }
9144
- return { type, isIncomplete };
9162
+ return { type, isIncomplete, typeErrors };
9145
9163
  }
9146
9164
  function getTypeOfSlice(node) {
9147
9165
  // Evaluate the expressions to report errors and record symbol
@@ -9856,49 +9874,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
9856
9874
  }
9857
9875
  return createSpecialType(classType, typeArgs, /* paramLimit */ undefined, /* allowParamSpec */ true);
9858
9876
  }
9859
- function transformTypeForPossibleEnumClass(node, getValueType) {
9860
- var _a, _b, _c, _d;
9861
- // If the node is within a class that derives from the metaclass
9862
- // "EnumMeta", we need to treat assignments differently.
9863
- const enclosingClassNode = ParseTreeUtils.getEnclosingClass(node, /* stopAtFunction */ true);
9864
- if (enclosingClassNode) {
9865
- const enumClassInfo = getTypeOfClass(enclosingClassNode);
9866
- if (enumClassInfo && types_1.ClassType.isEnumClass(enumClassInfo.classType)) {
9867
- // In ".py" files, the transform applies only to members that are
9868
- // assigned within the class. In stub files, it applies to most variables
9869
- // even if they are not assigned. This unfortunate convention means
9870
- // there is no way in a stub to specify both enum members and instance
9871
- // variables used within each enum instance. Unless/until there is
9872
- // a change to this convention and all type checkers and stubs adopt
9873
- // it, we're stuck with this limitation.
9874
- let isMemberOfEnumeration = (((_a = node.parent) === null || _a === void 0 ? void 0 : _a.nodeType) === 3 /* Assignment */ && node.parent.leftExpression === node) ||
9875
- (((_b = node.parent) === null || _b === void 0 ? void 0 : _b.nodeType) === 54 /* TypeAnnotation */ &&
9876
- node.parent.valueExpression === node &&
9877
- ((_c = node.parent.parent) === null || _c === void 0 ? void 0 : _c.nodeType) === 3 /* Assignment */) ||
9878
- (AnalyzerNodeInfo.getFileInfo(node).isStubFile &&
9879
- ((_d = node.parent) === null || _d === void 0 ? void 0 : _d.nodeType) === 54 /* TypeAnnotation */ &&
9880
- node.parent.valueExpression === node);
9881
- // The spec specifically excludes names that start and end with a single underscore.
9882
- // This also includes dunder names.
9883
- if ((0, symbolNameUtils_1.isSingleDunderName)(node.value)) {
9884
- isMemberOfEnumeration = false;
9885
- }
9886
- // Specifically exclude "value" and "name". These are reserved by the enum metaclass.
9887
- if (node.value === 'name' || node.value === 'value') {
9888
- isMemberOfEnumeration = false;
9889
- }
9890
- const valueType = getValueType();
9891
- // The spec excludes descriptors.
9892
- if ((0, types_1.isClassInstance)(valueType) && valueType.details.fields.get('__get__')) {
9893
- isMemberOfEnumeration = false;
9894
- }
9895
- if (isMemberOfEnumeration) {
9896
- return types_1.ClassType.cloneAsInstance(types_1.ClassType.cloneWithLiteral(enumClassInfo.classType, new types_1.EnumLiteral(enumClassInfo.classType.details.name, node.value, valueType)));
9897
- }
9898
- }
9899
- }
9900
- return undefined;
9901
- }
9902
9877
  function transformTypeForTypeAlias(type, name, errorNode, typeParameters) {
9903
9878
  if (!types_1.TypeBase.isInstantiable(type)) {
9904
9879
  return type;
@@ -10036,6 +10011,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
10036
10011
  return cachedType;
10037
10012
  }
10038
10013
  const specialType = createSpecialBuiltInClass(node, assignedName, aliasMapEntry);
10014
+ // Handle 'LiteralString' specially because we want it to act as
10015
+ // though it derives from 'str'.
10016
+ if (assignedName === 'LiteralString') {
10017
+ specialType.details.baseClasses.push(strClassType !== null && strClassType !== void 0 ? strClassType : types_1.AnyType.create());
10018
+ (0, typeUtils_1.computeMroLinearization)(specialType);
10019
+ }
10039
10020
  writeTypeCache(node, specialType, 0 /* None */, /* isIncomplete */ false);
10040
10021
  return specialType;
10041
10022
  }
@@ -10188,7 +10169,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
10188
10169
  rightHandType = srcType;
10189
10170
  if (node.leftExpression.nodeType === 38 /* Name */ && !node.typeAnnotationComment) {
10190
10171
  rightHandType =
10191
- transformTypeForPossibleEnumClass(node.leftExpression, () => rightHandType) || rightHandType;
10172
+ (0, enums_1.transformTypeForPossibleEnumClass)(evaluatorInterface, node.leftExpression, () => rightHandType) || rightHandType;
10192
10173
  }
10193
10174
  if (typeAliasNameNode) {
10194
10175
  // Clear out the temporary types we wrote above.
@@ -10292,6 +10273,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
10292
10273
  const destTypeResult = getTypeOfAugmentedAssignment(node, /* expectedType */ undefined);
10293
10274
  writeTypeCache(node, destTypeResult.type, 0 /* None */, !!destTypeResult.isIncomplete);
10294
10275
  }
10276
+ function getPseudoGenericTypeVarName(paramName) {
10277
+ return `__type_of_${paramName}`;
10278
+ }
10295
10279
  function getTypeOfClass(node) {
10296
10280
  // Is this type already cached?
10297
10281
  const cachedClassType = readTypeCache(node.name, 0 /* None */);
@@ -10605,13 +10589,16 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
10605
10589
  const initParams = initDeclNode.parameters;
10606
10590
  if (initParams.length > 1 &&
10607
10591
  !initParams.some((param, index) => !!ParseTreeUtils.getTypeAnnotationForParameter(initDeclNode, index))) {
10608
- const genericParams = initParams.filter((param, index) => index > 0 && param.name && param.category === 0 /* Simple */);
10592
+ const genericParams = initParams.filter((param, index) => index > 0 &&
10593
+ param.name &&
10594
+ param.category === 0 /* Simple */ &&
10595
+ !param.defaultValue);
10609
10596
  if (genericParams.length > 0) {
10610
10597
  classType.details.flags |= 16384 /* PseudoGenericClass */;
10611
10598
  // Create a type parameter for each simple, named parameter
10612
10599
  // in the __init__ method.
10613
10600
  classType.details.typeParameters = genericParams.map((param) => {
10614
- const typeVar = types_1.TypeVarType.createInstance(`__type_of_${param.name.value}`);
10601
+ const typeVar = types_1.TypeVarType.createInstance(getPseudoGenericTypeVarName(param.name.value));
10615
10602
  typeVar.details.isSynthesized = true;
10616
10603
  typeVar.scopeId = getScopeIdForNode(initDeclNode);
10617
10604
  typeVar.details.boundType = types_1.UnknownType.create();
@@ -11145,7 +11132,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11145
11132
  types_1.ClassType.isPseudoGenericClass(containingClassType) &&
11146
11133
  node.name.value === '__init__';
11147
11134
  const paramTypes = [];
11148
- let typeParamIndex = 0;
11149
11135
  // Determine if the first parameter should be skipped for comment-based
11150
11136
  // function annotations.
11151
11137
  let firstCommentAnnotationIndex = 0;
@@ -11228,9 +11214,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11228
11214
  }
11229
11215
  }
11230
11216
  if (!annotatedType && addGenericParamTypes) {
11231
- if (index > 0 && param.category === 0 /* Simple */ && param.name) {
11232
- annotatedType = containingClassType.details.typeParameters[typeParamIndex];
11233
- typeParamIndex++;
11217
+ if (index > 0 && param.category === 0 /* Simple */ && param.name && !param.defaultValue) {
11218
+ const typeParamName = getPseudoGenericTypeVarName(param.name.value);
11219
+ annotatedType = containingClassType.details.typeParameters.find((param) => param.details.name === typeParamName);
11234
11220
  }
11235
11221
  }
11236
11222
  if (annotatedType) {
@@ -11519,7 +11505,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11519
11505
  // more restrictive (narrower) than intended.
11520
11506
  if (!(0, types_1.isClassInstance)(defaultValueType) ||
11521
11507
  !types_1.ClassType.isBuiltIn(defaultValueType, ['tuple', 'list', 'set', 'dict'])) {
11522
- inferredParamType = (0, typeUtils_1.stripLiteralValue)(defaultValueType);
11508
+ inferredParamType = stripLiteralValue(defaultValueType);
11523
11509
  }
11524
11510
  }
11525
11511
  if (inferredParamType) {
@@ -11864,12 +11850,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11864
11850
  if (inferredReturnType) {
11865
11851
  return { type: inferredReturnType, isIncomplete };
11866
11852
  }
11867
- if (functionRecursionMap.has(node.id) && functionRecursionMap.size < maxInferFunctionReturnRecursionCount) {
11853
+ if (functionRecursionMap.has(node.id) || functionRecursionMap.size >= maxInferFunctionReturnRecursionCount) {
11868
11854
  inferredReturnType = types_1.UnknownType.create();
11869
11855
  isIncomplete = true;
11870
11856
  }
11871
11857
  else {
11872
- functionRecursionMap.set(node.id, true);
11858
+ functionRecursionMap.add(node.id);
11873
11859
  try {
11874
11860
  let functionDecl;
11875
11861
  const decl = AnalyzerNodeInfo.getDeclaration(node);
@@ -12482,6 +12468,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
12482
12468
  // The left expression of a call or member access expression is not contextual.
12483
12469
  if (parent.nodeType === 9 /* Call */ || parent.nodeType === 35 /* MemberAccess */) {
12484
12470
  if (nodeToEvaluate === parent.leftExpression) {
12471
+ // Handle the special case where the LHS is a call to super().
12472
+ if (nodeToEvaluate.nodeType === 9 /* Call */ &&
12473
+ nodeToEvaluate.leftExpression.nodeType === 38 /* Name */ &&
12474
+ nodeToEvaluate.leftExpression.value === 'super') {
12475
+ nodeToEvaluate = parent;
12476
+ continue;
12477
+ }
12485
12478
  flags = 2 /* DoNotSpecialize */;
12486
12479
  break;
12487
12480
  }
@@ -12637,24 +12630,23 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
12637
12630
  return;
12638
12631
  }
12639
12632
  const containingClassNode = ParseTreeUtils.getEnclosingClass(functionNode, /* stopAtFunction */ true);
12640
- if (containingClassNode) {
12641
- const classInfo = getTypeOfClass(containingClassNode);
12642
- if (classInfo) {
12643
- // See if the function is a method in a child class. We may be able to
12644
- // infer the type of the parameter from a method of the same name in
12645
- // a parent class if it has an annotated type.
12646
- const functionFlags = getFunctionFlagsFromDecorators(functionNode, /* isInClass */ true);
12647
- const inferredParamType = inferParameterType(functionNode, functionFlags, paramIndex, classInfo.classType);
12648
- if (inferredParamType) {
12649
- writeTypeCache(node.name, transformVariadicParamType(node, node.category, inferredParamType), 0 /* None */,
12650
- /* isIncomplete */ false);
12651
- return;
12652
- }
12633
+ const classInfo = containingClassNode ? getTypeOfClass(containingClassNode) : undefined;
12634
+ if (classInfo &&
12635
+ types_1.ClassType.isPseudoGenericClass(classInfo === null || classInfo === void 0 ? void 0 : classInfo.classType) &&
12636
+ functionNode.name.value === '__init__') {
12637
+ const typeParamName = getPseudoGenericTypeVarName(node.name.value);
12638
+ const paramType = classInfo.classType.details.typeParameters.find((param) => param.details.name === typeParamName);
12639
+ if (paramType) {
12640
+ writeTypeCache(node.name, paramType, 0 /* None */, /* isIncomplete */ false);
12641
+ return;
12653
12642
  }
12654
12643
  }
12655
- // We weren't able to infer the input parameter type. Set its
12656
- // type to unknown.
12657
- writeTypeCache(node.name, transformVariadicParamType(node, node.category, types_1.UnknownType.create()), 0 /* None */,
12644
+ // See if the function is a method in a child class. We may be able to
12645
+ // infer the type of the parameter from a method of the same name in
12646
+ // a parent class if it has an annotated type.
12647
+ const functionFlags = getFunctionFlagsFromDecorators(functionNode, /* isInClass */ true);
12648
+ const inferredParamType = inferParameterType(functionNode, functionFlags, paramIndex, classInfo === null || classInfo === void 0 ? void 0 : classInfo.classType);
12649
+ writeTypeCache(node.name, transformVariadicParamType(node, node.category, inferredParamType !== null && inferredParamType !== void 0 ? inferredParamType : types_1.UnknownType.create()), 0 /* None */,
12658
12650
  /* isIncomplete */ false);
12659
12651
  }
12660
12652
  // Evaluates the types that are assigned within the statement that contains
@@ -13695,7 +13687,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
13695
13687
  // Apply enum transform if appropriate.
13696
13688
  if (declaration.node.nodeType === 38 /* Name */) {
13697
13689
  declaredType =
13698
- transformTypeForPossibleEnumClass(declaration.node, () => declaredType) || declaredType;
13690
+ (0, enums_1.transformTypeForPossibleEnumClass)(evaluatorInterface, declaration.node, () => declaredType) || declaredType;
13699
13691
  }
13700
13692
  if (typeAliasNode && typeAliasNode.valueExpression.nodeType === 38 /* Name */) {
13701
13693
  declaredType = transformTypeForTypeAlias(declaredType, typeAliasNode.valueExpression, declaration.node);
@@ -13826,7 +13818,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
13826
13818
  })) === null || _b === void 0 ? void 0 : _b.type;
13827
13819
  if (inferredType && resolvedDecl.node.nodeType === 38 /* Name */) {
13828
13820
  // See if this is an enum member. If so, we need to handle it as a special case.
13829
- const enumMemberType = transformTypeForPossibleEnumClass(resolvedDecl.node, () => {
13821
+ const enumMemberType = (0, enums_1.transformTypeForPossibleEnumClass)(evaluatorInterface, resolvedDecl.node, () => {
13830
13822
  var _a, _b;
13831
13823
  return ((_b = (_a = evaluateTypeForSubnode(resolvedDecl.inferredTypeSource, () => {
13832
13824
  evaluateTypesForStatement(resolvedDecl.inferredTypeSource);
@@ -14051,13 +14043,15 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
14051
14043
  let isConstant = decl.type === 1 /* Variable */ && !!decl.isConstant;
14052
14044
  // Treat enum values declared within an enum class as though they are const even
14053
14045
  // though they may not be named as such.
14054
- if ((0, types_1.isClassInstance)(type) && types_1.ClassType.isEnumClass(type) && isDeclInEnumClass(decl)) {
14046
+ if ((0, types_1.isClassInstance)(type) &&
14047
+ types_1.ClassType.isEnumClass(type) &&
14048
+ (0, enums_1.isDeclInEnumClass)(evaluatorInterface, decl)) {
14055
14049
  isConstant = true;
14056
14050
  }
14057
14051
  // If the symbol is constant, we can retain the literal
14058
14052
  // value. Otherwise, strip literal values to widen the type.
14059
14053
  if (types_1.TypeBase.isInstance(type) && !isExplicitTypeAlias && !isConstant && !isFinalVar) {
14060
- type = (0, typeUtils_1.stripLiteralValue)(type);
14054
+ type = stripLiteralValue(type);
14061
14055
  }
14062
14056
  }
14063
14057
  typesToCombine.push(type);
@@ -14178,17 +14172,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
14178
14172
  }
14179
14173
  return undefined;
14180
14174
  }
14181
- function isDeclInEnumClass(decl) {
14182
- const classNode = ParseTreeUtils.getEnclosingClass(decl.node, /* stopAtFunction */ true);
14183
- if (!classNode) {
14184
- return false;
14185
- }
14186
- const classInfo = getTypeOfClass(classNode);
14187
- if (!classInfo) {
14188
- return false;
14189
- }
14190
- return types_1.ClassType.isEnumClass(classInfo.classType);
14191
- }
14192
14175
  function inferReturnTypeIfNecessary(type) {
14193
14176
  if ((0, types_1.isFunction)(type)) {
14194
14177
  getFunctionEffectiveReturnType(type);
@@ -14443,7 +14426,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
14443
14426
  }
14444
14427
  return types_1.UnknownType.create();
14445
14428
  }
14446
- function getTypeOfMemberInternal(node, member, selfClass) {
14429
+ function getTypeOfMemberInternal(member, selfClass) {
14447
14430
  if ((0, types_1.isInstantiableClass)(member.classType)) {
14448
14431
  const typeResult = getEffectiveTypeOfSymbolForUsage(member.symbol);
14449
14432
  if (typeResult) {
@@ -14631,7 +14614,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
14631
14614
  const removedArgs = srcTypeArgs.splice(destVariadicIndex, srcArgsToCapture);
14632
14615
  // Package up the remaining type arguments into a tuple object.
14633
14616
  const variadicTuple = (0, typeUtils_1.convertToInstance)((0, typeUtils_1.specializeTupleClass)(tupleClassType, removedArgs.map((typeArg) => {
14634
- return { type: (0, typeUtils_1.stripLiteralValue)(typeArg.type), isUnbounded: false };
14617
+ return { type: stripLiteralValue(typeArg.type), isUnbounded: false };
14635
14618
  }),
14636
14619
  /* isTypeArgumentExplicit */ true,
14637
14620
  /* isUnpackedTuple */ true));
@@ -14968,9 +14951,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
14968
14951
  (0, typeUtils_1.isTupleClass)(srcType) &&
14969
14952
  srcType.tupleTypeArguments &&
14970
14953
  srcType.tupleTypeArguments.length === 1) {
14971
- if ((0, types_1.isTypeSame)(destType, srcType.tupleTypeArguments[0].type,
14972
- /* ignorePseudoGeneric */ undefined,
14973
- /* ignoreTypeFlags */ undefined, recursionCount)) {
14954
+ if ((0, types_1.isTypeSame)(destType, srcType.tupleTypeArguments[0].type, {}, recursionCount)) {
14974
14955
  return true;
14975
14956
  }
14976
14957
  }
@@ -15191,7 +15172,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15191
15172
  }
15192
15173
  }
15193
15174
  }
15194
- const concreteSrcType = makeTopLevelTypeVarsConcrete(srcType);
15175
+ let concreteSrcType = makeTopLevelTypeVarsConcrete(srcType);
15195
15176
  if ((0, types_1.isClass)(concreteSrcType) && types_1.TypeBase.isInstance(concreteSrcType)) {
15196
15177
  if (destType.literalValue !== undefined) {
15197
15178
  const srcLiteral = concreteSrcType.literalValue;
@@ -15204,15 +15185,18 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15204
15185
  }
15205
15186
  }
15206
15187
  // Handle LiteralString special form.
15207
- if (types_1.ClassType.isBuiltIn(destType, 'LiteralString') && types_1.ClassType.isBuiltIn(concreteSrcType, 'str')) {
15208
- if (concreteSrcType.literalValue !== undefined) {
15188
+ if (types_1.ClassType.isBuiltIn(destType, 'LiteralString')) {
15189
+ if (types_1.ClassType.isBuiltIn(concreteSrcType, 'str') && concreteSrcType.literalValue !== undefined) {
15190
+ return true;
15191
+ }
15192
+ else if (types_1.ClassType.isBuiltIn(concreteSrcType, 'LiteralString')) {
15209
15193
  return true;
15210
15194
  }
15211
15195
  }
15212
15196
  else if (types_1.ClassType.isBuiltIn(concreteSrcType, 'LiteralString') &&
15213
- types_1.ClassType.isBuiltIn(destType, 'str') &&
15214
- destType.literalValue === undefined) {
15215
- return true;
15197
+ strClassType &&
15198
+ (0, types_1.isInstantiableClass)(strClassType)) {
15199
+ concreteSrcType = types_1.ClassType.cloneAsInstance(strClassType);
15216
15200
  }
15217
15201
  if (!assignClass(types_1.ClassType.cloneAsInstantiable(destType), types_1.ClassType.cloneAsInstantiable(concreteSrcType), diag, destTypeVarContext, srcTypeVarContext, flags, recursionCount,
15218
15202
  /* reportErrorsUsingObjType */ true)) {
@@ -15365,9 +15349,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15365
15349
  function assignFromUnionType(destType, srcType, diag, destTypeVarContext, srcTypeVarContext, flags, recursionCount) {
15366
15350
  // Start by checking for an exact match. This is needed to handle unions
15367
15351
  // that contain recursive type aliases.
15368
- if ((0, types_1.isTypeSame)(srcType, destType,
15369
- /* ignorePseudoGeneric */ undefined,
15370
- /* ignoreTypeFlags */ undefined, recursionCount)) {
15352
+ if ((0, types_1.isTypeSame)(srcType, destType, {}, recursionCount)) {
15371
15353
  return true;
15372
15354
  }
15373
15355
  // Handle the case where the source and dest are both unions. Try
@@ -15396,9 +15378,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15396
15378
  remainingDestSubtypes.push(destSubtype);
15397
15379
  }
15398
15380
  else {
15399
- const srcTypeIndex = remainingSrcSubtypes.findIndex((srcSubtype) => (0, types_1.isTypeSame)(srcSubtype, destSubtype,
15400
- /* ignorePseudoGeneric */ undefined,
15401
- /* ignoreTypeFlags */ undefined, recursionCount));
15381
+ const srcTypeIndex = remainingSrcSubtypes.findIndex((srcSubtype) => (0, types_1.isTypeSame)(srcSubtype, destSubtype, {}, recursionCount));
15402
15382
  if (srcTypeIndex >= 0) {
15403
15383
  remainingSrcSubtypes.splice(srcTypeIndex, 1);
15404
15384
  }
@@ -15410,11 +15390,21 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15410
15390
  // For all remaining source subtypes, attempt to find a dest subtype
15411
15391
  // whose primary type matches.
15412
15392
  if (!isIncompatible) {
15413
- [...remainingSrcSubtypes].forEach((srcSubtype) => {
15414
- const destTypeIndex = remainingDestSubtypes.findIndex((destSubtype) => (0, types_1.isClass)(srcSubtype) &&
15415
- (0, types_1.isClass)(destSubtype) &&
15416
- types_1.TypeBase.isInstance(srcSubtype) === types_1.TypeBase.isInstance(destSubtype) &&
15417
- types_1.ClassType.isSameGenericClass(srcSubtype, destSubtype));
15393
+ (0, typeUtils_1.sortTypes)(remainingSrcSubtypes).forEach((srcSubtype) => {
15394
+ const destTypeIndex = remainingDestSubtypes.findIndex((destSubtype) => {
15395
+ if ((0, types_1.isClass)(srcSubtype) &&
15396
+ (0, types_1.isClass)(destSubtype) &&
15397
+ types_1.TypeBase.isInstance(srcSubtype) === types_1.TypeBase.isInstance(destSubtype) &&
15398
+ types_1.ClassType.isSameGenericClass(srcSubtype, destSubtype)) {
15399
+ return true;
15400
+ }
15401
+ if ((0, types_1.isFunction)(srcSubtype) || (0, types_1.isOverloadedFunction)(srcSubtype)) {
15402
+ if ((0, types_1.isFunction)(destSubtype) || (0, types_1.isOverloadedFunction)(destSubtype)) {
15403
+ return true;
15404
+ }
15405
+ }
15406
+ return false;
15407
+ });
15418
15408
  if (destTypeIndex >= 0) {
15419
15409
  if (!assignType(remainingDestSubtypes[destTypeIndex], srcSubtype, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), destTypeVarContext, srcTypeVarContext, flags, recursionCount)) {
15420
15410
  isIncompatible = true;
@@ -15600,7 +15590,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15600
15590
  // contents of the table.
15601
15591
  let typeVarContextScore = destTypeVarContextClone.getScore();
15602
15592
  // If the type matches exactly, prefer it over other types.
15603
- if ((0, types_1.isTypeSame)(subtype, (0, typeUtils_1.stripLiteralValue)(srcType))) {
15593
+ if ((0, types_1.isTypeSame)(subtype, stripLiteralValue(srcType))) {
15604
15594
  typeVarContextScore = Number.POSITIVE_INFINITY;
15605
15595
  }
15606
15596
  if (bestTypeVarContextScore === undefined ||
@@ -15645,9 +15635,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15645
15635
  // The srcType is assignable only if all of its subtypes are assignable.
15646
15636
  return !(0, types_1.findSubtype)(srcType, (srcSubtype) => {
15647
15637
  var _a;
15648
- if ((0, types_1.isTypeSame)(destType, srcSubtype,
15649
- /* ignorePseudoGeneric */ true,
15650
- /* ignoreTypeFlags */ undefined, recursionCount)) {
15638
+ if ((0, types_1.isTypeSame)(destType, srcSubtype, { ignorePseudoGeneric: true }, recursionCount)) {
15651
15639
  return false;
15652
15640
  }
15653
15641
  const destTypeVarName = types_1.TypeVarType.getNameWithScope(destType);
@@ -16323,9 +16311,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16323
16311
  // If there are any remaining parameters or the source doesn't include the
16324
16312
  // dest param spec itself, it is not assignable in this case.
16325
16313
  if (!srcParamSpec ||
16326
- !(0, types_1.isTypeSame)(srcParamSpec, destParamSpec,
16327
- /* ignorePseudoGeneric */ false,
16328
- /* ignoreTypeFlags */ true) ||
16314
+ !(0, types_1.isTypeSame)(srcParamSpec, destParamSpec, { ignoreTypeFlags: true }) ||
16329
16315
  remainingParams.length > 0) {
16330
16316
  canAssign = false;
16331
16317
  }
@@ -16723,9 +16709,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16723
16709
  }
16724
16710
  let effectiveSrcType = srcType;
16725
16711
  if ((0, types_1.isTypeVar)(srcType)) {
16726
- if ((0, types_1.isTypeSame)(srcType, destType,
16727
- /* ignorePseudoGeneric */ undefined,
16728
- /* ignoreTypeFlags */ undefined, recursionCount)) {
16712
+ if ((0, types_1.isTypeSame)(srcType, destType, {}, recursionCount)) {
16729
16713
  return srcType;
16730
16714
  }
16731
16715
  effectiveSrcType = makeTopLevelTypeVarsConcrete(srcType);
@@ -16937,9 +16921,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16937
16921
  if (firstParamType && memberType.details.parameters.length > 0) {
16938
16922
  const memberTypeFirstParam = memberType.details.parameters[0];
16939
16923
  const memberTypeFirstParamType = types_1.FunctionType.getEffectiveParameterType(memberType, 0);
16940
- // If the type has a literal associated with it, strip it now. This
16941
- // is needed to handle generic functions in the enum.Flag class.
16942
- const nonLiteralFirstParamType = (0, typeUtils_1.stripLiteralValue)(firstParamType);
16943
16924
  // Fill out the typeVarContext for the "self" or "cls" parameter.
16944
16925
  typeVarContext.addSolveForScope((0, typeUtils_1.getTypeVarScopeId)(memberType));
16945
16926
  const diag = new diagnostic_1.DiagnosticAddendum();
@@ -16953,11 +16934,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16953
16934
  // Instead, we'll assume it's assignable.
16954
16935
  if (!typeVarContext.isLocked()) {
16955
16936
  typeVarContext.setTypeVarType(memberTypeFirstParamType, types_1.TypeBase.isInstantiable(memberTypeFirstParamType)
16956
- ? (0, typeUtils_1.convertToInstance)(nonLiteralFirstParamType)
16957
- : nonLiteralFirstParamType);
16937
+ ? (0, typeUtils_1.convertToInstance)(firstParamType)
16938
+ : firstParamType);
16958
16939
  }
16959
16940
  }
16960
- else if (!assignType(memberTypeFirstParamType, nonLiteralFirstParamType, diag, typeVarContext,
16941
+ else if (!assignType(memberTypeFirstParamType, firstParamType, diag, typeVarContext,
16961
16942
  /* srcTypeVarContext */ undefined, 0 /* Default */, recursionCount)) {
16962
16943
  if (memberTypeFirstParam.name &&
16963
16944
  !memberTypeFirstParam.isNameSynthesized &&
@@ -17062,10 +17043,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17062
17043
  evaluateTypeOfParameter,
17063
17044
  canBeTruthy,
17064
17045
  canBeFalsy,
17046
+ stripLiteralValue,
17065
17047
  removeTruthinessFromType,
17066
17048
  removeFalsinessFromType,
17067
17049
  verifyRaiseExceptionType,
17068
17050
  verifyDeleteExpression,
17051
+ validateOverloadedFunctionArguments,
17069
17052
  isAfterNodeReachable,
17070
17053
  isNodeReachable,
17071
17054
  isAsymmetricDescriptorAssignment,