@zzzen/pyright-internal 1.2.0-dev.20230326 → 1.2.0-dev.20230402

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 (127) hide show
  1. package/dist/analyzer/cacheManager.js +1 -1
  2. package/dist/analyzer/checker.js +44 -24
  3. package/dist/analyzer/checker.js.map +1 -1
  4. package/dist/analyzer/constraintSolver.js +4 -1
  5. package/dist/analyzer/constraintSolver.js.map +1 -1
  6. package/dist/analyzer/constructorTransform.js +4 -3
  7. package/dist/analyzer/constructorTransform.js.map +1 -1
  8. package/dist/analyzer/declarationUtils.d.ts +8 -0
  9. package/dist/analyzer/declarationUtils.js +147 -1
  10. package/dist/analyzer/declarationUtils.js.map +1 -1
  11. package/dist/analyzer/importStatementUtils.js +1 -1
  12. package/dist/analyzer/parameterUtils.d.ts +25 -1
  13. package/dist/analyzer/parameterUtils.js +182 -1
  14. package/dist/analyzer/parameterUtils.js.map +1 -1
  15. package/dist/analyzer/patternMatching.js +37 -2
  16. package/dist/analyzer/patternMatching.js.map +1 -1
  17. package/dist/analyzer/program.js +32 -13
  18. package/dist/analyzer/program.js.map +1 -1
  19. package/dist/analyzer/properties.js +13 -13
  20. package/dist/analyzer/properties.js.map +1 -1
  21. package/dist/analyzer/protocols.js +3 -2
  22. package/dist/analyzer/protocols.js.map +1 -1
  23. package/dist/analyzer/pythonPathUtils.js +1 -1
  24. package/dist/analyzer/regions.js +4 -4
  25. package/dist/analyzer/regions.js.map +1 -1
  26. package/dist/analyzer/service.js +13 -8
  27. package/dist/analyzer/service.js.map +1 -1
  28. package/dist/analyzer/sourceFile.js +1 -1
  29. package/dist/analyzer/sourceFileInfoUtils.js +1 -1
  30. package/dist/analyzer/sourceMapper.js +1 -1
  31. package/dist/analyzer/sourceMapperUtils.d.ts +0 -8
  32. package/dist/analyzer/sourceMapperUtils.js +18 -25
  33. package/dist/analyzer/sourceMapperUtils.js.map +1 -1
  34. package/dist/analyzer/staticExpressions.js +2 -2
  35. package/dist/analyzer/symbolUtils.js +1 -1
  36. package/dist/analyzer/testWalker.js +3 -0
  37. package/dist/analyzer/testWalker.js.map +1 -1
  38. package/dist/analyzer/tracePrinter.js +1 -1
  39. package/dist/analyzer/typeEvaluator.js +84 -55
  40. package/dist/analyzer/typeEvaluator.js.map +1 -1
  41. package/dist/analyzer/typeEvaluatorTypes.d.ts +3 -3
  42. package/dist/analyzer/typeEvaluatorTypes.js +0 -1
  43. package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
  44. package/dist/analyzer/typeEvaluatorWithTracker.js +3 -5
  45. package/dist/analyzer/typeEvaluatorWithTracker.js.map +1 -1
  46. package/dist/analyzer/typeGuards.js +182 -159
  47. package/dist/analyzer/typeGuards.js.map +1 -1
  48. package/dist/analyzer/typeUtils.d.ts +2 -25
  49. package/dist/analyzer/typeUtils.js +39 -187
  50. package/dist/analyzer/typeUtils.js.map +1 -1
  51. package/dist/analyzer/typeVarContext.js +6 -2
  52. package/dist/analyzer/typeVarContext.js.map +1 -1
  53. package/dist/analyzer/typedDicts.js +2 -1
  54. package/dist/analyzer/typedDicts.js.map +1 -1
  55. package/dist/common/diagnosticSink.js +1 -1
  56. package/dist/common/envVarUtils.js +7 -7
  57. package/dist/common/envVarUtils.js.map +1 -1
  58. package/dist/common/fileBasedCancellationUtils.js +1 -1
  59. package/dist/common/host.js +1 -1
  60. package/dist/common/lspUtils.js +1 -1
  61. package/dist/common/pathConsts.d.ts +1 -0
  62. package/dist/common/pathConsts.js +2 -1
  63. package/dist/common/pathConsts.js.map +1 -1
  64. package/dist/common/progressReporter.js +4 -1
  65. package/dist/common/progressReporter.js.map +1 -1
  66. package/dist/common/pythonVersion.js +1 -2
  67. package/dist/common/pythonVersion.js.map +1 -1
  68. package/dist/common/realFileSystem.js +1 -1
  69. package/dist/common/textEditTracker.js +1 -1
  70. package/dist/common/workspaceEditUtils.js +1 -1
  71. package/dist/languageService/analyzerServiceExecutor.js +2 -2
  72. package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
  73. package/dist/languageService/autoImporter.d.ts +1 -1
  74. package/dist/languageService/autoImporter.js +6 -3
  75. package/dist/languageService/autoImporter.js.map +1 -1
  76. package/dist/languageService/callHierarchyProvider.d.ts +7 -3
  77. package/dist/languageService/callHierarchyProvider.js +38 -6
  78. package/dist/languageService/callHierarchyProvider.js.map +1 -1
  79. package/dist/languageService/completionProvider.d.ts +1 -0
  80. package/dist/languageService/completionProvider.js +29 -10
  81. package/dist/languageService/completionProvider.js.map +1 -1
  82. package/dist/languageService/completionProviderUtils.js +2 -2
  83. package/dist/languageService/completionProviderUtils.js.map +1 -1
  84. package/dist/languageService/documentSymbolProvider.js +1 -2
  85. package/dist/languageService/documentSymbolProvider.js.map +1 -1
  86. package/dist/languageService/importSorter.js +1 -1
  87. package/dist/languageService/indentationUtils.js +2 -1
  88. package/dist/languageService/indentationUtils.js.map +1 -1
  89. package/dist/languageService/tooltipUtils.js +2 -2
  90. package/dist/localization/localize.d.ts +0 -3
  91. package/dist/localization/localize.js +0 -1
  92. package/dist/localization/localize.js.map +1 -1
  93. package/dist/localization/package.nls.en-us.json +0 -1
  94. package/dist/tests/checker.test.js +1 -1
  95. package/dist/tests/checker.test.js.map +1 -1
  96. package/dist/tests/completions.test.js +3 -2
  97. package/dist/tests/completions.test.js.map +1 -1
  98. package/dist/tests/fourslash/fourslash.d.ts +5 -0
  99. package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedFunction.fourslash.d.ts +1 -0
  100. package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedFunction.fourslash.js +34 -0
  101. package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedFunction.fourslash.js.map +1 -0
  102. package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedVariable.fourslash.d.ts +1 -0
  103. package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedVariable.fourslash.js +19 -0
  104. package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedVariable.fourslash.js.map +1 -0
  105. package/dist/tests/fourslash/showcallhierarchy.incomingCalls.function.fourslash.d.ts +1 -0
  106. package/dist/tests/fourslash/showcallhierarchy.incomingCalls.function.fourslash.js +39 -0
  107. package/dist/tests/fourslash/showcallhierarchy.incomingCalls.function.fourslash.js.map +1 -0
  108. package/dist/tests/harness/fourslash/testState.d.ts +5 -0
  109. package/dist/tests/harness/fourslash/testState.js +21 -0
  110. package/dist/tests/harness/fourslash/testState.js.map +1 -1
  111. package/dist/tests/typeEvaluator1.test.js +4 -0
  112. package/dist/tests/typeEvaluator1.test.js.map +1 -1
  113. package/dist/tests/typeEvaluator2.test.js +4 -0
  114. package/dist/tests/typeEvaluator2.test.js.map +1 -1
  115. package/dist/tests/typeEvaluator3.test.js +4 -0
  116. package/dist/tests/typeEvaluator3.test.js.map +1 -1
  117. package/dist/tests/typeEvaluator4.test.js +43 -115
  118. package/dist/tests/typeEvaluator4.test.js.map +1 -1
  119. package/dist/tests/typeEvaluator5.test.js +1 -5
  120. package/dist/tests/typeEvaluator5.test.js.map +1 -1
  121. package/dist/workspaceFactory.d.ts +1 -0
  122. package/dist/workspaceFactory.js +20 -10
  123. package/dist/workspaceFactory.js.map +1 -1
  124. package/package.json +1 -1
  125. package/dist/analyzer/aliasDeclarationUtils.d.ts +0 -9
  126. package/dist/analyzer/aliasDeclarationUtils.js +0 -157
  127. package/dist/analyzer/aliasDeclarationUtils.js.map +0 -1
@@ -46,7 +46,6 @@ const textRange_1 = require("../common/textRange");
46
46
  const localize_1 = require("../localization/localize");
47
47
  const parseNodes_1 = require("../parser/parseNodes");
48
48
  const parser_1 = require("../parser/parser");
49
- const DeclarationUtils = __importStar(require("./aliasDeclarationUtils"));
50
49
  const analyzerFileInfo_1 = require("./analyzerFileInfo");
51
50
  const AnalyzerNodeInfo = __importStar(require("./analyzerNodeInfo"));
52
51
  const codeFlowEngine_1 = require("./codeFlowEngine");
@@ -58,6 +57,7 @@ const declarationUtils_1 = require("./declarationUtils");
58
57
  const enums_1 = require("./enums");
59
58
  const functionTransform_1 = require("./functionTransform");
60
59
  const namedTuples_1 = require("./namedTuples");
60
+ const parameterUtils_1 = require("./parameterUtils");
61
61
  const ParseTreeUtils = __importStar(require("./parseTreeUtils"));
62
62
  const patternMatching_1 = require("./patternMatching");
63
63
  const properties_1 = require("./properties");
@@ -930,7 +930,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
930
930
  if (types_1.ClassType.isBuiltIn(subtype, 'LiteralString')) {
931
931
  // Handle "LiteralString" specially.
932
932
  if (strClassType && (0, types_1.isInstantiableClass)(strClassType)) {
933
- return types_1.ClassType.cloneAsInstance(strClassType);
933
+ let strInstance = types_1.ClassType.cloneAsInstance(strClassType);
934
+ if (subtype.condition) {
935
+ strInstance = types_1.TypeBase.cloneForCondition(strInstance, (0, typeUtils_1.getTypeCondition)(subtype));
936
+ }
937
+ return strInstance;
934
938
  }
935
939
  }
936
940
  }
@@ -2153,7 +2157,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
2153
2157
  }
2154
2158
  }
2155
2159
  }
2156
- const setTypeResult = getTypeOfMemberAccessWithBaseType(target, baseTypeResult, { method: 'set', setType: type, setErrorNode: srcExpr, setExpectedTypeDiag: expectedTypeDiagAddendum }, 0 /* None */);
2160
+ const setTypeResult = getTypeOfMemberAccessWithBaseType(target, baseTypeResult, {
2161
+ method: 'set',
2162
+ setType: { type, isIncomplete: isTypeIncomplete },
2163
+ setErrorNode: srcExpr,
2164
+ setExpectedTypeDiag: expectedTypeDiagAddendum,
2165
+ }, 0 /* None */);
2157
2166
  if (setTypeResult.isAsymmetricDescriptor) {
2158
2167
  setAsymmetricDescriptorAssignment(target);
2159
2168
  }
@@ -2340,7 +2349,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
2340
2349
  // used as type arguments in other types) with their concrete form.
2341
2350
  // If conditionFilter is specified and the TypeVar is a constrained
2342
2351
  // TypeVar, only the conditions that match the filter will be included.
2343
- function makeTopLevelTypeVarsConcrete(type, conditionFilter) {
2352
+ function makeTopLevelTypeVarsConcrete(type, makeParamSpecsConcrete = false, conditionFilter) {
2344
2353
  return (0, typeUtils_1.mapSubtypes)(type, (subtype) => {
2345
2354
  if ((0, types_1.isParamSpec)(subtype)) {
2346
2355
  if (subtype.paramSpecAccess === 'args') {
@@ -2365,6 +2374,16 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
2365
2374
  return types_1.UnknownType.create();
2366
2375
  }
2367
2376
  }
2377
+ // If this is a function that contains only a ParamSpec (no additional
2378
+ // parameters), convert it to a concrete type of (*args: Any, **kwargs: Any).
2379
+ if (makeParamSpecsConcrete &&
2380
+ (0, types_1.isFunction)(subtype) &&
2381
+ subtype.details.parameters.length === 0 &&
2382
+ subtype.details.paramSpec) {
2383
+ const concreteFunction = types_1.FunctionType.createInstance('', '', '', 64 /* SynthesizedMethod */ | 32768 /* SkipArgsKwargsCompatibilityCheck */);
2384
+ types_1.FunctionType.addDefaultParameters(concreteFunction);
2385
+ return types_1.FunctionType.cloneForParamSpec(subtype, concreteFunction);
2386
+ }
2368
2387
  // If this is a TypeVarTuple *Ts, convert it to an unpacked tuple
2369
2388
  // *tuple[*Ts].
2370
2389
  if ((0, types_1.isVariadicTypeVar)(subtype)) {
@@ -2557,7 +2576,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
2557
2576
  const baseTypeResult = getTypeOfExpression(target.baseExpression, 2 /* DoNotSpecialize */);
2558
2577
  getTypeOfIndexWithBaseType(target, baseTypeResult, {
2559
2578
  method: 'set',
2560
- setType: type,
2579
+ setType: { type, isIncomplete: isTypeIncomplete },
2561
2580
  setErrorNode: srcExpr,
2562
2581
  setExpectedTypeDiag: expectedTypeDiagAddendum,
2563
2582
  }, 0 /* None */);
@@ -3770,12 +3789,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3770
3789
  type = descriptorResult.type;
3771
3790
  if (usage.method === 'set' && usage.setType) {
3772
3791
  // Verify that the assigned type is compatible.
3773
- if (!assignType(type, usage.setType, diag === null || diag === void 0 ? void 0 : diag.createAddendum())) {
3774
- diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.memberAssignment().format({
3775
- type: printType(usage.setType),
3776
- name: memberName,
3777
- classType: printObjectTypeForClass(classType),
3778
- }));
3792
+ if (!assignType(type, usage.setType.type, diag === null || diag === void 0 ? void 0 : diag.createAddendum())) {
3793
+ if (!usage.setType.isIncomplete) {
3794
+ diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.memberAssignment().format({
3795
+ type: printType(usage.setType.type),
3796
+ name: memberName,
3797
+ classType: printObjectTypeForClass(classType),
3798
+ }));
3799
+ }
3779
3800
  return undefined;
3780
3801
  }
3781
3802
  if ((0, types_1.isInstantiableClass)(memberInfo.classType) &&
@@ -3825,7 +3846,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3825
3846
  let isTypeValid = true;
3826
3847
  let isAsymmetricDescriptor = false;
3827
3848
  type = (0, typeUtils_1.mapSubtypes)(type, (subtype) => {
3828
- var _a;
3849
+ var _a, _b, _c;
3829
3850
  const concreteSubtype = makeTopLevelTypeVarsConcrete(subtype);
3830
3851
  const isClassMember = !memberInfo || memberInfo.isClassMember;
3831
3852
  if ((0, types_1.isClass)(concreteSubtype) && isClassMember) {
@@ -3910,7 +3931,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3910
3931
  // Provide "value" argument.
3911
3932
  argList.push({
3912
3933
  argumentCategory: 0 /* Simple */,
3913
- typeResult: { type: (_a = usage.setType) !== null && _a !== void 0 ? _a : types_1.UnknownType.create() },
3934
+ typeResult: {
3935
+ type: (_b = (_a = usage.setType) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : types_1.UnknownType.create(),
3936
+ isIncomplete: !!((_c = usage.setType) === null || _c === void 0 ? void 0 : _c.isIncomplete),
3937
+ },
3914
3938
  });
3915
3939
  }
3916
3940
  if (types_1.ClassType.isPropertyClass(lookupClass) &&
@@ -3980,11 +4004,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3980
4004
  if (usage.method === 'set') {
3981
4005
  if (usage.setType &&
3982
4006
  (0, types_1.isFunction)(boundMethodType) &&
3983
- boundMethodType.details.parameters.length >= 2) {
4007
+ boundMethodType.details.parameters.length >= 2 &&
4008
+ !usage.setType.isIncomplete) {
3984
4009
  const setterType = types_1.FunctionType.getEffectiveParameterType(boundMethodType, 1);
3985
4010
  diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.typeIncompatible().format({
3986
4011
  destType: printType(setterType),
3987
- sourceType: printType(usage.setType),
4012
+ sourceType: printType(usage.setType.type),
3988
4013
  }));
3989
4014
  }
3990
4015
  else if ((0, types_1.isOverloadedFunction)(boundMethodType)) {
@@ -4154,7 +4179,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
4154
4179
  }
4155
4180
  // Applies the __getattr__, __setattr__ or __delattr__ method if present.
4156
4181
  function applyAttributeAccessOverride(classType, errorNode, usage, memberName) {
4157
- var _a, _b, _c;
4182
+ var _a, _b, _c, _d, _e;
4158
4183
  const getAttributeAccessMember = (name) => {
4159
4184
  var _a;
4160
4185
  // See if the class has a "__getattribute__" or "__getattr__" method.
@@ -4194,7 +4219,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
4194
4219
  argList.push({
4195
4220
  // Provide "value" argument.
4196
4221
  argumentCategory: 0 /* Simple */,
4197
- typeResult: { type: (_b = usage.setType) !== null && _b !== void 0 ? _b : types_1.UnknownType.create() },
4222
+ typeResult: {
4223
+ type: (_c = (_b = usage.setType) === null || _b === void 0 ? void 0 : _b.type) !== null && _c !== void 0 ? _c : types_1.UnknownType.create(),
4224
+ isIncomplete: !!((_d = usage.setType) === null || _d === void 0 ? void 0 : _d.isIncomplete),
4225
+ },
4198
4226
  });
4199
4227
  }
4200
4228
  if ((0, types_1.isFunction)(accessMemberType) || (0, types_1.isOverloadedFunction)(accessMemberType)) {
@@ -4203,7 +4231,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
4203
4231
  const typeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(boundMethodType));
4204
4232
  const callResult = validateCallArguments(errorNode, argList, { type: boundMethodType }, typeVarContext,
4205
4233
  /* skipUnknownArgCheck */ true);
4206
- return (_c = callResult.returnType) !== null && _c !== void 0 ? _c : types_1.UnknownType.create();
4234
+ return (_e = callResult.returnType) !== null && _e !== void 0 ? _e : types_1.UnknownType.create();
4207
4235
  }
4208
4236
  }
4209
4237
  }
@@ -4783,7 +4811,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
4783
4811
  }
4784
4812
  }
4785
4813
  function getTypeOfIndexedObjectOrClass(node, baseType, usage) {
4786
- var _a, _b, _c;
4814
+ var _a, _b, _c, _d, _e, _f;
4787
4815
  // Handle index operations for TypedDict classes specially.
4788
4816
  if ((0, types_1.isClassInstance)(baseType) && types_1.ClassType.isTypedDictClass(baseType)) {
4789
4817
  const typeFromTypedDict = (0, typedDicts_1.getTypeOfIndexedTypedDict)(evaluatorInterface, node, baseType, usage);
@@ -4924,15 +4952,19 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
4924
4952
  },
4925
4953
  ];
4926
4954
  if (usage.method === 'set') {
4927
- let setType = usage.setType || types_1.AnyType.create();
4955
+ let setType = (_d = (_c = usage.setType) === null || _c === void 0 ? void 0 : _c.type) !== null && _d !== void 0 ? _d : types_1.AnyType.create();
4928
4956
  // Expand constrained type variables.
4929
4957
  if ((0, types_1.isTypeVar)(setType) && setType.details.constraints.length > 0) {
4930
4958
  const conditionFilter = (0, types_1.isClassInstance)(baseType) ? baseType.condition : undefined;
4931
- setType = makeTopLevelTypeVarsConcrete(setType, conditionFilter);
4959
+ setType = makeTopLevelTypeVarsConcrete(setType,
4960
+ /* makeParamSpecsConcrete */ undefined, conditionFilter);
4932
4961
  }
4933
4962
  argList.push({
4934
4963
  argumentCategory: 0 /* Simple */,
4935
- typeResult: { type: setType, isIncomplete: isPositionalIndexTypeIncomplete },
4964
+ typeResult: {
4965
+ type: setType,
4966
+ isIncomplete: !!((_e = usage.setType) === null || _e === void 0 ? void 0 : _e.isIncomplete),
4967
+ },
4936
4968
  });
4937
4969
  }
4938
4970
  keywordArgs.forEach((arg) => {
@@ -4981,7 +5013,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
4981
5013
  }
4982
5014
  callResult = validateCallArguments(node, argList, { type: itemMethodType });
4983
5015
  return {
4984
- type: (_c = callResult.returnType) !== null && _c !== void 0 ? _c : types_1.UnknownType.create(),
5016
+ type: (_f = callResult.returnType) !== null && _f !== void 0 ? _f : types_1.UnknownType.create(),
4985
5017
  isIncomplete: !!callResult.isTypeIncomplete,
4986
5018
  };
4987
5019
  }
@@ -6704,7 +6736,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
6704
6736
  // This logic is based on PEP 3102: https://www.python.org/dev/peps/pep-3102/
6705
6737
  function matchFunctionArgumentsToParameters(errorNode, argList, typeResult, overloadIndex) {
6706
6738
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
6707
- const paramDetails = (0, typeUtils_1.getParameterListDetails)(typeResult.type);
6739
+ const paramDetails = (0, parameterUtils_1.getParameterListDetails)(typeResult.type);
6708
6740
  let argIndex = 0;
6709
6741
  let matchedUnpackedListOfUnknownLength = false;
6710
6742
  let reportedArgError = false;
@@ -6720,7 +6752,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
6720
6752
  paramMap.set(param.name, {
6721
6753
  argsNeeded: param.category === 0 /* Simple */ && !param.hasDefault ? 1 : 0,
6722
6754
  argsReceived: 0,
6723
- isPositionalOnly: paramInfo.source === typeUtils_1.ParameterSource.PositionOnly,
6755
+ isPositionalOnly: paramInfo.source === parameterUtils_1.ParameterSource.PositionOnly,
6724
6756
  });
6725
6757
  }
6726
6758
  });
@@ -11615,7 +11647,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11615
11647
  }
11616
11648
  // The scope for this class becomes the "fields" for the corresponding type.
11617
11649
  const innerScope = ScopeUtils.getScopeForNode(node.suite);
11618
- classType.details.fields = (innerScope === null || innerScope === void 0 ? void 0 : innerScope.symbolTable) || new Map();
11650
+ classType.details.fields = (innerScope === null || innerScope === void 0 ? void 0 : innerScope.symbolTable)
11651
+ ? new Map(innerScope.symbolTable)
11652
+ : new Map();
11619
11653
  // Determine whether the class's instance variables are constrained
11620
11654
  // to those defined by __slots__. We need to do this prior to dataclass
11621
11655
  // processing because dataclasses can implicitly add to the slots
@@ -12115,7 +12149,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
12115
12149
  if (newMethodMember) {
12116
12150
  const newMethodType = getTypeOfMember(newMethodMember);
12117
12151
  if ((0, types_1.isFunction)(newMethodType)) {
12118
- const paramListDetails = (0, typeUtils_1.getParameterListDetails)(newMethodType);
12152
+ const paramListDetails = (0, parameterUtils_1.getParameterListDetails)(newMethodType);
12119
12153
  if (paramListDetails.firstKeywordOnlyIndex !== undefined) {
12120
12154
  // Build a map of the keyword-only parameters.
12121
12155
  const paramMap = new Map();
@@ -15260,10 +15294,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15260
15294
  // resolves aliases through local renames ("as" clauses found in import statements).
15261
15295
  function resolveAliasDeclaration(declaration, resolveLocalNames, allowExternallyHiddenAccess = false) {
15262
15296
  var _a;
15263
- return (_a = DeclarationUtils.resolveAliasDeclaration(importLookup, declaration, resolveLocalNames, allowExternallyHiddenAccess)) === null || _a === void 0 ? void 0 : _a.declaration;
15297
+ return (_a = (0, declarationUtils_1.resolveAliasDeclaration)(importLookup, declaration, resolveLocalNames, allowExternallyHiddenAccess)) === null || _a === void 0 ? void 0 : _a.declaration;
15264
15298
  }
15265
15299
  function resolveAliasDeclarationWithInfo(declaration, resolveLocalNames, allowExternallyHiddenAccess = false) {
15266
- return DeclarationUtils.resolveAliasDeclaration(importLookup, declaration, resolveLocalNames, allowExternallyHiddenAccess);
15300
+ return (0, declarationUtils_1.resolveAliasDeclaration)(importLookup, declaration, resolveLocalNames, allowExternallyHiddenAccess);
15267
15301
  }
15268
15302
  // Returns the type of the symbol. If the type is explicitly declared, that type
15269
15303
  // is returned. If not, the type is inferred from assignments to the symbol. All
@@ -15610,6 +15644,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15610
15644
  if (types_1.FunctionType.isStubDefinition(type)) {
15611
15645
  return types_1.UnknownType.create();
15612
15646
  }
15647
+ // Don't infer the return type for an overloaded function (unless it's synthesized,
15648
+ // which is needed for proper operation of the __get__ method in properties).
15649
+ if (types_1.FunctionType.isOverloaded(type) && !types_1.FunctionType.isSynthesizedMethod(type)) {
15650
+ return types_1.UnknownType.create();
15651
+ }
15613
15652
  // If the return type has already been lazily evaluated,
15614
15653
  // don't bother computing it again.
15615
15654
  if (type.inferredReturnType) {
@@ -16086,17 +16125,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16086
16125
  }
16087
16126
  }
16088
16127
  else {
16089
- if (srcUnboundedIndex >= 0) {
16090
- // PEP 646 allows an indeterminate tuple type to be assigned to
16091
- // a determinate tuple type if it's associated with a TypeVarTuple.
16092
- if (!destType.isUnpacked) {
16093
- diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.tupleSizeMismatchIndeterminate().format({
16094
- expected: destTypeArgs.length,
16095
- }));
16096
- return false;
16097
- }
16098
- }
16099
- else {
16128
+ if (srcUnboundedIndex < 0) {
16100
16129
  diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.tupleSizeMismatch().format({
16101
16130
  expected: destTypeArgs.length,
16102
16131
  received: srcTypeArgs.length,
@@ -16357,7 +16386,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16357
16386
  // Before performing any other checks, see if the dest type is a
16358
16387
  // TypeVar that we are attempting to match.
16359
16388
  if ((0, types_1.isTypeVar)(destType)) {
16360
- if ((0, types_1.isTypeSame)(destType, srcType)) {
16389
+ if ((0, typeUtils_1.isTypeVarSame)(destType, srcType)) {
16361
16390
  if (destType.scopeId && (destTypeVarContext === null || destTypeVarContext === void 0 ? void 0 : destTypeVarContext.hasSolveForScope(destType.scopeId))) {
16362
16391
  return (0, constraintSolver_1.assignTypeToTypeVar)(evaluatorInterface, destType, srcType, diag, destTypeVarContext, flags, recursionCount);
16363
16392
  }
@@ -17384,7 +17413,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17384
17413
  if (srcDetails.params.length < destDetails.argsIndex) {
17385
17414
  return;
17386
17415
  }
17387
- let srcLastToPackIndex = srcDetails.params.findIndex((p, i) => i >= destDetails.argsIndex && p.source === typeUtils_1.ParameterSource.KeywordOnly);
17416
+ let srcLastToPackIndex = srcDetails.params.findIndex((p, i) => i >= destDetails.argsIndex && p.source === parameterUtils_1.ParameterSource.KeywordOnly);
17388
17417
  if (srcLastToPackIndex < 0) {
17389
17418
  srcLastToPackIndex = srcDetails.params.length;
17390
17419
  }
@@ -17433,7 +17462,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17433
17462
  },
17434
17463
  type: srcPositionalsType,
17435
17464
  index: -1,
17436
- source: typeUtils_1.ParameterSource.PositionOnly,
17465
+ source: parameterUtils_1.ParameterSource.PositionOnly,
17437
17466
  },
17438
17467
  ...srcDetails.params.slice(destDetails.argsIndex + srcPositionalsToPack.length, srcDetails.params.length),
17439
17468
  ];
@@ -17441,9 +17470,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17441
17470
  srcDetails.argsIndex = argsIndex >= 0 ? argsIndex : undefined;
17442
17471
  const kwargsIndex = srcDetails.params.findIndex((param) => param.param.category === 2 /* VarArgDictionary */);
17443
17472
  srcDetails.kwargsIndex = kwargsIndex >= 0 ? kwargsIndex : undefined;
17444
- const firstKeywordOnlyIndex = srcDetails.params.findIndex((param) => param.source === typeUtils_1.ParameterSource.KeywordOnly);
17473
+ const firstKeywordOnlyIndex = srcDetails.params.findIndex((param) => param.source === parameterUtils_1.ParameterSource.KeywordOnly);
17445
17474
  srcDetails.firstKeywordOnlyIndex = firstKeywordOnlyIndex >= 0 ? firstKeywordOnlyIndex : undefined;
17446
- srcDetails.positionOnlyParamCount = Math.max(0, srcDetails.params.findIndex((p) => p.source !== typeUtils_1.ParameterSource.PositionOnly ||
17475
+ srcDetails.positionOnlyParamCount = Math.max(0, srcDetails.params.findIndex((p) => p.source !== parameterUtils_1.ParameterSource.PositionOnly ||
17447
17476
  p.param.category !== 0 /* Simple */ ||
17448
17477
  p.param.hasDefault));
17449
17478
  }
@@ -17455,8 +17484,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17455
17484
  flags &= ~32 /* SkipFunctionReturnTypeCheck */;
17456
17485
  destType = (0, typeUtils_1.removeParamSpecVariadicsFromFunction)(destType);
17457
17486
  srcType = (0, typeUtils_1.removeParamSpecVariadicsFromFunction)(srcType);
17458
- const destParamDetails = (0, typeUtils_1.getParameterListDetails)(destType);
17459
- const srcParamDetails = (0, typeUtils_1.getParameterListDetails)(srcType);
17487
+ const destParamDetails = (0, parameterUtils_1.getParameterListDetails)(destType);
17488
+ const srcParamDetails = (0, parameterUtils_1.getParameterListDetails)(srcType);
17460
17489
  adjustSourceParamDetailsForDestVariadic(srcParamDetails, destParamDetails);
17461
17490
  const targetIncludesParamSpec = (flags & 2 /* ReverseTypeVarMatching */) !== 0
17462
17491
  ? !!srcType.details.paramSpec
@@ -17475,7 +17504,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17475
17504
  const destParamName = (_e = destParam.param.name) !== null && _e !== void 0 ? _e : '';
17476
17505
  const srcParamName = (_f = srcParam.param.name) !== null && _f !== void 0 ? _f : '';
17477
17506
  if (destParamName && !(0, symbolNameUtils_1.isPrivateOrProtectedName)(destParamName) && !(0, symbolNameUtils_1.isPrivateOrProtectedName)(srcParamName)) {
17478
- const isDestPositionalOnly = destParam.source === typeUtils_1.ParameterSource.PositionOnly;
17507
+ const isDestPositionalOnly = destParam.source === parameterUtils_1.ParameterSource.PositionOnly;
17479
17508
  if (!isDestPositionalOnly &&
17480
17509
  destParam.param.category !== 1 /* VarArgList */ &&
17481
17510
  srcParam.param.category !== 1 /* VarArgList */ &&
@@ -17570,7 +17599,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17570
17599
  if (!assignFunctionParameter(destParamType, srcArgsType, paramIndex, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), destTypeVarContext, srcTypeVarContext, flags, recursionCount)) {
17571
17600
  canAssign = false;
17572
17601
  }
17573
- if (destParamDetails.params[paramIndex].source !== typeUtils_1.ParameterSource.PositionOnly &&
17602
+ if (destParamDetails.params[paramIndex].source !== parameterUtils_1.ParameterSource.PositionOnly &&
17574
17603
  srcParamDetails.kwargsIndex === undefined) {
17575
17604
  diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.namedParamMissingInSource().format({
17576
17605
  name: (_g = destParamDetails.params[paramIndex].param.name) !== null && _g !== void 0 ? _g : '',
@@ -18017,8 +18046,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
18017
18046
  }
18018
18047
  function validateOverrideMethodInternal(baseMethod, overrideMethod, diag, enforceParamNames) {
18019
18048
  var _a, _b;
18020
- const baseParamDetails = (0, typeUtils_1.getParameterListDetails)(baseMethod);
18021
- const overrideParamDetails = (0, typeUtils_1.getParameterListDetails)(overrideMethod);
18049
+ const baseParamDetails = (0, parameterUtils_1.getParameterListDetails)(baseMethod);
18050
+ const overrideParamDetails = (0, parameterUtils_1.getParameterListDetails)(overrideMethod);
18022
18051
  let canOverride = true;
18023
18052
  // Verify that we're not overriding a static, class or instance method with
18024
18053
  // an incompatible type.
@@ -18097,12 +18126,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
18097
18126
  const overrideParam = overrideParamDetails.params[i].param;
18098
18127
  if (i >= baseParamDetails.positionOnlyParamCount &&
18099
18128
  !(0, symbolNameUtils_1.isPrivateOrProtectedName)(baseParam.name || '') &&
18100
- baseParamDetails.params[i].source !== typeUtils_1.ParameterSource.PositionOnly &&
18129
+ baseParamDetails.params[i].source !== parameterUtils_1.ParameterSource.PositionOnly &&
18101
18130
  baseParam.category === 0 /* Simple */ &&
18102
18131
  baseParam.name !== overrideParam.name) {
18103
18132
  if (overrideParam.category === 0 /* Simple */) {
18104
18133
  if (enforceParamNames) {
18105
- if (overrideParamDetails.params[i].source === typeUtils_1.ParameterSource.PositionOnly) {
18134
+ if (overrideParamDetails.params[i].source === parameterUtils_1.ParameterSource.PositionOnly) {
18106
18135
  diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideParamNamePositionOnly().format({
18107
18136
  index: i + 1,
18108
18137
  baseName: baseParam.name || '*',
@@ -18174,9 +18203,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
18174
18203
  }
18175
18204
  }
18176
18205
  // Now check any keyword-only parameters.
18177
- const baseKwOnlyParams = baseParamDetails.params.filter((paramInfo) => paramInfo.source === typeUtils_1.ParameterSource.KeywordOnly &&
18206
+ const baseKwOnlyParams = baseParamDetails.params.filter((paramInfo) => paramInfo.source === parameterUtils_1.ParameterSource.KeywordOnly &&
18178
18207
  paramInfo.param.category === 0 /* Simple */);
18179
- const overrideWkOnlyParams = overrideParamDetails.params.filter((paramInfo) => paramInfo.source === typeUtils_1.ParameterSource.KeywordOnly &&
18208
+ const overrideWkOnlyParams = overrideParamDetails.params.filter((paramInfo) => paramInfo.source === parameterUtils_1.ParameterSource.KeywordOnly &&
18180
18209
  paramInfo.param.category === 0 /* Simple */);
18181
18210
  baseKwOnlyParams.forEach((paramInfo) => {
18182
18211
  var _a, _b, _c;