@zzzen/pyright-internal 1.2.0-dev.20230319 → 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 (142) hide show
  1. package/dist/analyzer/cacheManager.js +1 -1
  2. package/dist/analyzer/checker.js +52 -26
  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/dataClasses.js +10 -0
  9. package/dist/analyzer/dataClasses.js.map +1 -1
  10. package/dist/analyzer/declarationUtils.d.ts +8 -0
  11. package/dist/analyzer/declarationUtils.js +147 -1
  12. package/dist/analyzer/declarationUtils.js.map +1 -1
  13. package/dist/analyzer/importStatementUtils.js +1 -1
  14. package/dist/analyzer/parameterUtils.d.ts +25 -1
  15. package/dist/analyzer/parameterUtils.js +182 -1
  16. package/dist/analyzer/parameterUtils.js.map +1 -1
  17. package/dist/analyzer/patternMatching.js +55 -5
  18. package/dist/analyzer/patternMatching.js.map +1 -1
  19. package/dist/analyzer/program.js +40 -26
  20. package/dist/analyzer/program.js.map +1 -1
  21. package/dist/analyzer/properties.js +13 -13
  22. package/dist/analyzer/properties.js.map +1 -1
  23. package/dist/analyzer/protocols.js +21 -5
  24. package/dist/analyzer/protocols.js.map +1 -1
  25. package/dist/analyzer/pythonPathUtils.js +1 -1
  26. package/dist/analyzer/regions.js +4 -4
  27. package/dist/analyzer/regions.js.map +1 -1
  28. package/dist/analyzer/service.js +16 -22
  29. package/dist/analyzer/service.js.map +1 -1
  30. package/dist/analyzer/sourceFile.js +1 -1
  31. package/dist/analyzer/sourceFileInfoUtils.js +1 -1
  32. package/dist/analyzer/sourceMapper.js +1 -1
  33. package/dist/analyzer/sourceMapperUtils.d.ts +0 -8
  34. package/dist/analyzer/sourceMapperUtils.js +18 -25
  35. package/dist/analyzer/sourceMapperUtils.js.map +1 -1
  36. package/dist/analyzer/staticExpressions.js +2 -2
  37. package/dist/analyzer/symbolUtils.js +1 -1
  38. package/dist/analyzer/testWalker.js +3 -0
  39. package/dist/analyzer/testWalker.js.map +1 -1
  40. package/dist/analyzer/tracePrinter.js +1 -1
  41. package/dist/analyzer/typeEvaluator.js +187 -87
  42. package/dist/analyzer/typeEvaluator.js.map +1 -1
  43. package/dist/analyzer/typeEvaluatorTypes.d.ts +3 -3
  44. package/dist/analyzer/typeEvaluatorTypes.js +0 -1
  45. package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
  46. package/dist/analyzer/typeEvaluatorWithTracker.js +3 -5
  47. package/dist/analyzer/typeEvaluatorWithTracker.js.map +1 -1
  48. package/dist/analyzer/typeGuards.js +182 -159
  49. package/dist/analyzer/typeGuards.js.map +1 -1
  50. package/dist/analyzer/typeUtils.d.ts +2 -25
  51. package/dist/analyzer/typeUtils.js +59 -188
  52. package/dist/analyzer/typeUtils.js.map +1 -1
  53. package/dist/analyzer/typeVarContext.js +6 -2
  54. package/dist/analyzer/typeVarContext.js.map +1 -1
  55. package/dist/analyzer/typedDicts.js +2 -1
  56. package/dist/analyzer/typedDicts.js.map +1 -1
  57. package/dist/analyzer/types.d.ts +1 -0
  58. package/dist/analyzer/types.js.map +1 -1
  59. package/dist/common/configOptions.js +1 -1
  60. package/dist/common/configOptions.js.map +1 -1
  61. package/dist/common/diagnosticSink.js +1 -1
  62. package/dist/common/envVarUtils.js +7 -7
  63. package/dist/common/envVarUtils.js.map +1 -1
  64. package/dist/common/fileBasedCancellationUtils.js +5 -1
  65. package/dist/common/fileBasedCancellationUtils.js.map +1 -1
  66. package/dist/common/host.js +1 -1
  67. package/dist/common/lspUtils.js +1 -1
  68. package/dist/common/pathConsts.d.ts +1 -0
  69. package/dist/common/pathConsts.js +2 -1
  70. package/dist/common/pathConsts.js.map +1 -1
  71. package/dist/common/progressReporter.js +4 -1
  72. package/dist/common/progressReporter.js.map +1 -1
  73. package/dist/common/pythonVersion.js +1 -2
  74. package/dist/common/pythonVersion.js.map +1 -1
  75. package/dist/common/realFileSystem.js +1 -1
  76. package/dist/common/textEditTracker.js +1 -1
  77. package/dist/common/workspaceEditUtils.js +1 -1
  78. package/dist/languageServerBase.js +2 -2
  79. package/dist/languageServerBase.js.map +1 -1
  80. package/dist/languageService/analyzerServiceExecutor.js +2 -2
  81. package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
  82. package/dist/languageService/autoImporter.d.ts +1 -1
  83. package/dist/languageService/autoImporter.js +6 -3
  84. package/dist/languageService/autoImporter.js.map +1 -1
  85. package/dist/languageService/callHierarchyProvider.d.ts +7 -3
  86. package/dist/languageService/callHierarchyProvider.js +38 -6
  87. package/dist/languageService/callHierarchyProvider.js.map +1 -1
  88. package/dist/languageService/completionProvider.d.ts +1 -0
  89. package/dist/languageService/completionProvider.js +30 -11
  90. package/dist/languageService/completionProvider.js.map +1 -1
  91. package/dist/languageService/completionProviderUtils.js +2 -2
  92. package/dist/languageService/completionProviderUtils.js.map +1 -1
  93. package/dist/languageService/documentSymbolProvider.js +1 -2
  94. package/dist/languageService/documentSymbolProvider.js.map +1 -1
  95. package/dist/languageService/hoverProvider.js +1 -1
  96. package/dist/languageService/hoverProvider.js.map +1 -1
  97. package/dist/languageService/importSorter.js +1 -1
  98. package/dist/languageService/indentationUtils.js +2 -1
  99. package/dist/languageService/indentationUtils.js.map +1 -1
  100. package/dist/languageService/signatureHelpProvider.js +9 -7
  101. package/dist/languageService/signatureHelpProvider.js.map +1 -1
  102. package/dist/languageService/tooltipUtils.js +2 -2
  103. package/dist/localization/localize.d.ts +0 -3
  104. package/dist/localization/localize.js +0 -1
  105. package/dist/localization/localize.js.map +1 -1
  106. package/dist/localization/package.nls.en-us.json +0 -1
  107. package/dist/tests/checker.test.js +1 -1
  108. package/dist/tests/checker.test.js.map +1 -1
  109. package/dist/tests/completions.test.js +41 -0
  110. package/dist/tests/completions.test.js.map +1 -1
  111. package/dist/tests/fourslash/fourslash.d.ts +5 -0
  112. package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedFunction.fourslash.d.ts +1 -0
  113. package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedFunction.fourslash.js +34 -0
  114. package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedFunction.fourslash.js.map +1 -0
  115. package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedVariable.fourslash.d.ts +1 -0
  116. package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedVariable.fourslash.js +19 -0
  117. package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedVariable.fourslash.js.map +1 -0
  118. package/dist/tests/fourslash/showcallhierarchy.incomingCalls.function.fourslash.d.ts +1 -0
  119. package/dist/tests/fourslash/showcallhierarchy.incomingCalls.function.fourslash.js +39 -0
  120. package/dist/tests/fourslash/showcallhierarchy.incomingCalls.function.fourslash.js.map +1 -0
  121. package/dist/tests/harness/fourslash/testState.d.ts +5 -0
  122. package/dist/tests/harness/fourslash/testState.js +21 -0
  123. package/dist/tests/harness/fourslash/testState.js.map +1 -1
  124. package/dist/tests/hoverProvider.test.js +50 -0
  125. package/dist/tests/hoverProvider.test.js.map +1 -1
  126. package/dist/tests/typeEvaluator1.test.js +8 -0
  127. package/dist/tests/typeEvaluator1.test.js.map +1 -1
  128. package/dist/tests/typeEvaluator2.test.js +13 -1
  129. package/dist/tests/typeEvaluator2.test.js.map +1 -1
  130. package/dist/tests/typeEvaluator3.test.js +9 -1
  131. package/dist/tests/typeEvaluator3.test.js.map +1 -1
  132. package/dist/tests/typeEvaluator4.test.js +48 -116
  133. package/dist/tests/typeEvaluator4.test.js.map +1 -1
  134. package/dist/tests/typeEvaluator5.test.js +1 -5
  135. package/dist/tests/typeEvaluator5.test.js.map +1 -1
  136. package/dist/workspaceFactory.d.ts +1 -0
  137. package/dist/workspaceFactory.js +20 -10
  138. package/dist/workspaceFactory.js.map +1 -1
  139. package/package.json +1 -1
  140. package/dist/analyzer/aliasDeclarationUtils.d.ts +0 -9
  141. package/dist/analyzer/aliasDeclarationUtils.js +0 -142
  142. 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 */);
@@ -3517,6 +3536,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3517
3536
  }
3518
3537
  }
3519
3538
  }
3539
+ // If the field was not found and the module type is marked
3540
+ // such that all fields should be Any/Unknown, return that type.
3541
+ if (!type && baseType.notPresentFieldType) {
3542
+ type = baseType.notPresentFieldType;
3543
+ }
3520
3544
  if (!type) {
3521
3545
  if (!isIncomplete) {
3522
3546
  addDiagnostic(fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.moduleUnknownMember().format({
@@ -3659,7 +3683,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3659
3683
  return { type, isIncomplete, isAsymmetricDescriptor, isRequired, isNotRequired };
3660
3684
  }
3661
3685
  function getTypeOfClassMemberName(errorNode, classType, isAccessedThroughObject, memberName, usage, diag, flags, bindToType) {
3662
- var _a, _b, _c;
3686
+ var _a, _b;
3663
3687
  let classLookupFlags = 0 /* Default */;
3664
3688
  if (flags & 1 /* AccessClassMembersOnly */) {
3665
3689
  classLookupFlags |= 8 /* SkipInstanceVariables */;
@@ -3700,10 +3724,27 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3700
3724
  if (containingClassType &&
3701
3725
  (0, types_1.isInstantiableClass)(containingClassType) &&
3702
3726
  types_1.ClassType.isSameGenericClass(containingClassType, classType)) {
3703
- type = (_c = (_b = getDeclaredTypeOfSymbol(memberInfo.symbol)) === null || _b === void 0 ? void 0 : _b.type) !== null && _c !== void 0 ? _c : types_1.UnknownType.create();
3727
+ type = (_b = getDeclaredTypeOfSymbol(memberInfo.symbol)) === null || _b === void 0 ? void 0 : _b.type;
3704
3728
  if (type && (0, types_1.isInstantiableClass)(memberInfo.classType)) {
3705
3729
  type = (0, typeUtils_1.partiallySpecializeType)(type, memberInfo.classType);
3706
3730
  }
3731
+ // If we're setting a class variable via a write through an object,
3732
+ // this is normally considered a type violation. But it is allowed
3733
+ // if the class variable is a descriptor object. In this case, we will
3734
+ // clear the flag that causes an error to be generated.
3735
+ if (usage.method === 'set' && memberInfo.symbol.isClassVar() && isAccessedThroughObject) {
3736
+ const selfClass = bindToType || memberName === '__new__' ? undefined : classType;
3737
+ const typeResult = getTypeOfMemberInternal(memberInfo, selfClass);
3738
+ if (typeResult) {
3739
+ if ((0, typeUtils_1.isDescriptorInstance)(typeResult.type, /* requireSetter */ true)) {
3740
+ type = typeResult.type;
3741
+ flags &= 8 /* DisallowClassVarWrites */;
3742
+ }
3743
+ }
3744
+ }
3745
+ if (!type) {
3746
+ type = types_1.UnknownType.create();
3747
+ }
3707
3748
  }
3708
3749
  }
3709
3750
  }
@@ -3748,12 +3789,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3748
3789
  type = descriptorResult.type;
3749
3790
  if (usage.method === 'set' && usage.setType) {
3750
3791
  // Verify that the assigned type is compatible.
3751
- if (!assignType(type, usage.setType, diag === null || diag === void 0 ? void 0 : diag.createAddendum())) {
3752
- diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.memberAssignment().format({
3753
- type: printType(usage.setType),
3754
- name: memberName,
3755
- classType: printObjectTypeForClass(classType),
3756
- }));
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
+ }
3757
3800
  return undefined;
3758
3801
  }
3759
3802
  if ((0, types_1.isInstantiableClass)(memberInfo.classType) &&
@@ -3803,7 +3846,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3803
3846
  let isTypeValid = true;
3804
3847
  let isAsymmetricDescriptor = false;
3805
3848
  type = (0, typeUtils_1.mapSubtypes)(type, (subtype) => {
3806
- var _a;
3849
+ var _a, _b, _c;
3807
3850
  const concreteSubtype = makeTopLevelTypeVarsConcrete(subtype);
3808
3851
  const isClassMember = !memberInfo || memberInfo.isClassMember;
3809
3852
  if ((0, types_1.isClass)(concreteSubtype) && isClassMember) {
@@ -3888,7 +3931,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3888
3931
  // Provide "value" argument.
3889
3932
  argList.push({
3890
3933
  argumentCategory: 0 /* Simple */,
3891
- 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
+ },
3892
3938
  });
3893
3939
  }
3894
3940
  if (types_1.ClassType.isPropertyClass(lookupClass) &&
@@ -3958,11 +4004,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3958
4004
  if (usage.method === 'set') {
3959
4005
  if (usage.setType &&
3960
4006
  (0, types_1.isFunction)(boundMethodType) &&
3961
- boundMethodType.details.parameters.length >= 2) {
4007
+ boundMethodType.details.parameters.length >= 2 &&
4008
+ !usage.setType.isIncomplete) {
3962
4009
  const setterType = types_1.FunctionType.getEffectiveParameterType(boundMethodType, 1);
3963
4010
  diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.typeIncompatible().format({
3964
4011
  destType: printType(setterType),
3965
- sourceType: printType(usage.setType),
4012
+ sourceType: printType(usage.setType.type),
3966
4013
  }));
3967
4014
  }
3968
4015
  else if ((0, types_1.isOverloadedFunction)(boundMethodType)) {
@@ -4132,7 +4179,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
4132
4179
  }
4133
4180
  // Applies the __getattr__, __setattr__ or __delattr__ method if present.
4134
4181
  function applyAttributeAccessOverride(classType, errorNode, usage, memberName) {
4135
- var _a, _b, _c;
4182
+ var _a, _b, _c, _d, _e;
4136
4183
  const getAttributeAccessMember = (name) => {
4137
4184
  var _a;
4138
4185
  // See if the class has a "__getattribute__" or "__getattr__" method.
@@ -4172,7 +4219,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
4172
4219
  argList.push({
4173
4220
  // Provide "value" argument.
4174
4221
  argumentCategory: 0 /* Simple */,
4175
- 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
+ },
4176
4226
  });
4177
4227
  }
4178
4228
  if ((0, types_1.isFunction)(accessMemberType) || (0, types_1.isOverloadedFunction)(accessMemberType)) {
@@ -4181,7 +4231,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
4181
4231
  const typeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(boundMethodType));
4182
4232
  const callResult = validateCallArguments(errorNode, argList, { type: boundMethodType }, typeVarContext,
4183
4233
  /* skipUnknownArgCheck */ true);
4184
- 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();
4185
4235
  }
4186
4236
  }
4187
4237
  }
@@ -4468,18 +4518,16 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
4468
4518
  typeArgType = types_1.UnknownType.create();
4469
4519
  }
4470
4520
  if ((flags & 16384 /* EnforceTypeVarVarianceConsistency */) !== 0) {
4471
- if ((0, types_1.isTypeVar)(typeArgType)) {
4472
- const usageVariances = inferTypeParameterVarianceForTypeAlias(baseType);
4473
- if (usageVariances && index < usageVariances.length) {
4474
- const usageVariance = usageVariances[index];
4475
- if (!(0, typeUtils_1.isVarianceOfTypeArgumentCompatible)(typeArgType, usageVariance)) {
4476
- const messageDiag = diag.createAddendum();
4477
- messageDiag.addMessage(localize_1.Localizer.DiagnosticAddendum.varianceMismatchForTypeAlias().format({
4478
- typeVarName: printType(typeArgType),
4479
- typeAliasParam: printType(typeParameters[index]),
4480
- }));
4481
- messageDiag.addTextRange(typeArgs[index].node);
4482
- }
4521
+ const usageVariances = inferTypeParameterVarianceForTypeAlias(baseType);
4522
+ if (usageVariances && index < usageVariances.length) {
4523
+ const usageVariance = usageVariances[index];
4524
+ if (!(0, typeUtils_1.isVarianceOfTypeArgumentCompatible)(typeArgType, usageVariance)) {
4525
+ const messageDiag = diag.createAddendum();
4526
+ messageDiag.addMessage(localize_1.Localizer.DiagnosticAddendum.varianceMismatchForTypeAlias().format({
4527
+ typeVarName: printType(typeArgType),
4528
+ typeAliasParam: printType(typeParameters[index]),
4529
+ }));
4530
+ messageDiag.addTextRange(typeArgs[index].node);
4483
4531
  }
4484
4532
  }
4485
4533
  }
@@ -4723,9 +4771,19 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
4723
4771
  // the type alias' type parameters?
4724
4772
  subtype.typeArguments.forEach((typeArg, classParamIndex) => {
4725
4773
  var _a;
4726
- if (classParamIndex < subtype.details.typeParameters.length) {
4774
+ if ((0, typeUtils_1.isTupleClass)(subtype)) {
4775
+ updateUsageVarianceForType(typeArg, 3 /* Covariant */);
4776
+ }
4777
+ else if (classParamIndex < subtype.details.typeParameters.length) {
4727
4778
  const classTypeParam = subtype.details.typeParameters[classParamIndex];
4728
- updateUsageVarianceForType(typeArg, (_a = classTypeParam.computedVariance) !== null && _a !== void 0 ? _a : classTypeParam.details.declaredVariance);
4779
+ if ((0, types_1.isUnpackedClass)(typeArg) && typeArg.tupleTypeArguments) {
4780
+ typeArg.tupleTypeArguments.forEach((tupleTypeArg) => {
4781
+ updateUsageVarianceForType(tupleTypeArg.type, 2 /* Invariant */);
4782
+ });
4783
+ }
4784
+ else {
4785
+ updateUsageVarianceForType(typeArg, (_a = classTypeParam.computedVariance) !== null && _a !== void 0 ? _a : classTypeParam.details.declaredVariance);
4786
+ }
4729
4787
  }
4730
4788
  });
4731
4789
  }
@@ -4753,7 +4811,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
4753
4811
  }
4754
4812
  }
4755
4813
  function getTypeOfIndexedObjectOrClass(node, baseType, usage) {
4756
- var _a, _b, _c;
4814
+ var _a, _b, _c, _d, _e, _f;
4757
4815
  // Handle index operations for TypedDict classes specially.
4758
4816
  if ((0, types_1.isClassInstance)(baseType) && types_1.ClassType.isTypedDictClass(baseType)) {
4759
4817
  const typeFromTypedDict = (0, typedDicts_1.getTypeOfIndexedTypedDict)(evaluatorInterface, node, baseType, usage);
@@ -4894,15 +4952,19 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
4894
4952
  },
4895
4953
  ];
4896
4954
  if (usage.method === 'set') {
4897
- 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();
4898
4956
  // Expand constrained type variables.
4899
4957
  if ((0, types_1.isTypeVar)(setType) && setType.details.constraints.length > 0) {
4900
4958
  const conditionFilter = (0, types_1.isClassInstance)(baseType) ? baseType.condition : undefined;
4901
- setType = makeTopLevelTypeVarsConcrete(setType, conditionFilter);
4959
+ setType = makeTopLevelTypeVarsConcrete(setType,
4960
+ /* makeParamSpecsConcrete */ undefined, conditionFilter);
4902
4961
  }
4903
4962
  argList.push({
4904
4963
  argumentCategory: 0 /* Simple */,
4905
- typeResult: { type: setType, isIncomplete: isPositionalIndexTypeIncomplete },
4964
+ typeResult: {
4965
+ type: setType,
4966
+ isIncomplete: !!((_e = usage.setType) === null || _e === void 0 ? void 0 : _e.isIncomplete),
4967
+ },
4906
4968
  });
4907
4969
  }
4908
4970
  keywordArgs.forEach((arg) => {
@@ -4951,7 +5013,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
4951
5013
  }
4952
5014
  callResult = validateCallArguments(node, argList, { type: itemMethodType });
4953
5015
  return {
4954
- 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(),
4955
5017
  isIncomplete: !!callResult.isTypeIncomplete,
4956
5018
  };
4957
5019
  }
@@ -6276,7 +6338,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
6276
6338
  }
6277
6339
  let returnType = mapSubtypesExpandTypeVars(callTypeResult.type,
6278
6340
  /* conditionFilter */ undefined, (expandedSubtype, unexpandedSubtype) => {
6279
- var _a, _b, _c, _d, _e, _f;
6341
+ var _a, _b, _c, _d, _e, _f, _g;
6280
6342
  switch (expandedSubtype.category) {
6281
6343
  case 1 /* Unknown */:
6282
6344
  case 2 /* Any */: {
@@ -6462,7 +6524,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
6462
6524
  return types_1.AnyType.create();
6463
6525
  }
6464
6526
  if ((0, types_1.isClass)(unexpandedSubtype) && (0, enums_1.isKnownEnumType)(className)) {
6465
- return (0, enums_1.createEnumType)(errorNode, expandedSubtype, argList);
6527
+ return (_d = (0, enums_1.createEnumType)(errorNode, expandedSubtype, argList)) !== null && _d !== void 0 ? _d : types_1.UnknownType.create();
6466
6528
  }
6467
6529
  if (className === 'TypedDict') {
6468
6530
  return (0, typedDicts_1.createTypedDictType)(evaluatorInterface, errorNode, expandedSubtype, argList);
@@ -6547,9 +6609,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
6547
6609
  return returnType;
6548
6610
  }
6549
6611
  else {
6550
- const memberType = (_d = getTypeOfObjectMember(errorNode, expandedSubtype, '__call__',
6612
+ const memberType = (_e = getTypeOfObjectMember(errorNode, expandedSubtype, '__call__',
6551
6613
  /* usage */ undefined,
6552
- /* diag */ undefined, 64 /* SkipAttributeAccessOverride */)) === null || _d === void 0 ? void 0 : _d.type;
6614
+ /* diag */ undefined, 64 /* SkipAttributeAccessOverride */)) === null || _e === void 0 ? void 0 : _e.type;
6553
6615
  if (memberType) {
6554
6616
  const functionResult = validateCallArguments(errorNode, argList, { type: memberType }, typeVarContext, skipUnknownArgCheck, inferenceContext, recursionCount);
6555
6617
  overloadsUsedForCall.push(...functionResult.overloadsUsedForCall);
@@ -6564,7 +6626,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
6564
6626
  // will instantiate an object of type T.
6565
6627
  return (0, typeUtils_1.convertToInstance)(unexpandedSubtype);
6566
6628
  }
6567
- return (_e = functionResult.returnType) !== null && _e !== void 0 ? _e : types_1.UnknownType.create();
6629
+ return (_f = functionResult.returnType) !== null && _f !== void 0 ? _f : types_1.UnknownType.create();
6568
6630
  }
6569
6631
  if (!memberType || !(0, types_1.isAnyOrUnknown)(memberType)) {
6570
6632
  addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.objectNotCallable().format({
@@ -6601,7 +6663,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
6601
6663
  if (callResult.argumentErrors) {
6602
6664
  argumentErrors = true;
6603
6665
  }
6604
- return (_f = callResult.returnType) !== null && _f !== void 0 ? _f : types_1.UnknownType.create();
6666
+ return (_g = callResult.returnType) !== null && _g !== void 0 ? _g : types_1.UnknownType.create();
6605
6667
  }
6606
6668
  case 8 /* Module */: {
6607
6669
  addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.moduleNotCallable(), errorNode);
@@ -6674,7 +6736,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
6674
6736
  // This logic is based on PEP 3102: https://www.python.org/dev/peps/pep-3102/
6675
6737
  function matchFunctionArgumentsToParameters(errorNode, argList, typeResult, overloadIndex) {
6676
6738
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
6677
- const paramDetails = (0, typeUtils_1.getParameterListDetails)(typeResult.type);
6739
+ const paramDetails = (0, parameterUtils_1.getParameterListDetails)(typeResult.type);
6678
6740
  let argIndex = 0;
6679
6741
  let matchedUnpackedListOfUnknownLength = false;
6680
6742
  let reportedArgError = false;
@@ -6690,7 +6752,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
6690
6752
  paramMap.set(param.name, {
6691
6753
  argsNeeded: param.category === 0 /* Simple */ && !param.hasDefault ? 1 : 0,
6692
6754
  argsReceived: 0,
6693
- isPositionalOnly: paramInfo.source === typeUtils_1.ParameterSource.PositionOnly,
6755
+ isPositionalOnly: paramInfo.source === parameterUtils_1.ParameterSource.PositionOnly,
6694
6756
  });
6695
6757
  }
6696
6758
  });
@@ -7048,7 +7110,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7048
7110
  // Now consume any keyword arguments.
7049
7111
  while (argIndex < argList.length) {
7050
7112
  if (argList[argIndex].argumentCategory === 2 /* UnpackedDictionary */) {
7051
- // Verify that the type used in this expression is a Mapping[str, T].
7113
+ // Verify that the type used in this expression is a SupportsKeysAndGetItem[str, T].
7052
7114
  const argType = getTypeOfArgument(argList[argIndex]).type;
7053
7115
  if ((0, types_1.isAnyOrUnknown)(argType)) {
7054
7116
  unpackedDictionaryArgType = argType;
@@ -7132,7 +7194,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7132
7194
  }
7133
7195
  }
7134
7196
  else {
7135
- const mappingType = getTypingType(errorNode, 'Mapping');
7197
+ let mappingType = getTypeshedType(errorNode, 'SupportsKeysAndGetItem');
7198
+ if (!mappingType) {
7199
+ mappingType = getTypingType(errorNode, 'Mapping');
7200
+ }
7136
7201
  const strObjType = getBuiltInObject(errorNode, 'str');
7137
7202
  if (mappingType &&
7138
7203
  (0, types_1.isInstantiableClass)(mappingType) &&
@@ -7708,7 +7773,24 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7708
7773
  specializedReturnType.typeArguments &&
7709
7774
  specializedReturnType.typeArguments.length > 0) {
7710
7775
  if (boolClassType && (0, types_1.isInstantiableClass)(boolClassType)) {
7711
- specializedReturnType = types_1.ClassType.cloneAsInstance(types_1.ClassType.cloneForTypeGuard(boolClassType, specializedReturnType.typeArguments[0], types_1.ClassType.isBuiltIn(specializedReturnType, 'StrictTypeGuard')));
7776
+ let typeGuardType = specializedReturnType.typeArguments[0];
7777
+ // If the first argument is a simple (non-constrained) TypeVar,
7778
+ // associate that TypeVar with the resulting TypeGuard type.
7779
+ if (argResults.length > 0) {
7780
+ const arg0Type = argResults[0].argType;
7781
+ if ((0, types_1.isTypeVar)(arg0Type) &&
7782
+ !arg0Type.details.isParamSpec &&
7783
+ arg0Type.details.constraints.length === 0) {
7784
+ typeGuardType = (0, typeUtils_1.addConditionToType)(typeGuardType, [
7785
+ {
7786
+ typeVarName: types_1.TypeVarType.getNameWithScope(arg0Type),
7787
+ constraintIndex: 0,
7788
+ isConstrainedTypeVar: false,
7789
+ },
7790
+ ]);
7791
+ }
7792
+ }
7793
+ specializedReturnType = types_1.ClassType.cloneAsInstance(types_1.ClassType.cloneForTypeGuard(boolClassType, typeGuardType, types_1.ClassType.isBuiltIn(specializedReturnType, 'StrictTypeGuard')));
7712
7794
  }
7713
7795
  }
7714
7796
  specializedReturnType = adjustCallableReturnType(specializedReturnType);
@@ -11565,7 +11647,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11565
11647
  }
11566
11648
  // The scope for this class becomes the "fields" for the corresponding type.
11567
11649
  const innerScope = ScopeUtils.getScopeForNode(node.suite);
11568
- 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();
11569
11653
  // Determine whether the class's instance variables are constrained
11570
11654
  // to those defined by __slots__. We need to do this prior to dataclass
11571
11655
  // processing because dataclasses can implicitly add to the slots
@@ -12065,7 +12149,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
12065
12149
  if (newMethodMember) {
12066
12150
  const newMethodType = getTypeOfMember(newMethodMember);
12067
12151
  if ((0, types_1.isFunction)(newMethodType)) {
12068
- const paramListDetails = (0, typeUtils_1.getParameterListDetails)(newMethodType);
12152
+ const paramListDetails = (0, parameterUtils_1.getParameterListDetails)(newMethodType);
12069
12153
  if (paramListDetails.firstKeywordOnlyIndex !== undefined) {
12070
12154
  // Build a map of the keyword-only parameters.
12071
12155
  const paramMap = new Map();
@@ -14989,8 +15073,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
14989
15073
  moduleType.fields = lookupResults.symbolTable;
14990
15074
  moduleType.docString = lookupResults.docString;
14991
15075
  }
14992
- else if (!loaderActions.implicitImports) {
14993
- return evaluatorOptions.evaluateUnknownImportsAsAny ? types_1.AnyType.create() : types_1.UnknownType.create();
15076
+ else {
15077
+ // Note that all module attributes that are not found in the
15078
+ // symbol table should be treated as Any or Unknown rather than
15079
+ // as an error.
15080
+ moduleType.notPresentFieldType = evaluatorOptions.evaluateUnknownImportsAsAny
15081
+ ? types_1.AnyType.create()
15082
+ : types_1.UnknownType.create();
14994
15083
  }
14995
15084
  }
14996
15085
  if (loaderActions.implicitImports) {
@@ -15205,10 +15294,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15205
15294
  // resolves aliases through local renames ("as" clauses found in import statements).
15206
15295
  function resolveAliasDeclaration(declaration, resolveLocalNames, allowExternallyHiddenAccess = false) {
15207
15296
  var _a;
15208
- 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;
15209
15298
  }
15210
15299
  function resolveAliasDeclarationWithInfo(declaration, resolveLocalNames, allowExternallyHiddenAccess = false) {
15211
- return DeclarationUtils.resolveAliasDeclaration(importLookup, declaration, resolveLocalNames, allowExternallyHiddenAccess);
15300
+ return (0, declarationUtils_1.resolveAliasDeclaration)(importLookup, declaration, resolveLocalNames, allowExternallyHiddenAccess);
15212
15301
  }
15213
15302
  // Returns the type of the symbol. If the type is explicitly declared, that type
15214
15303
  // is returned. If not, the type is inferred from assignments to the symbol. All
@@ -15312,6 +15401,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15312
15401
  if (sawExplicitTypeAlias) {
15313
15402
  considerDecl = false;
15314
15403
  }
15404
+ // If the symbol is explicitly marked as a ClassVar, consider only the
15405
+ // declarations that assign to it from within the class body, not through
15406
+ // a member access expression.
15407
+ if (symbol.isClassVar() && decl.type === 1 /* Variable */ && decl.isDefinedByMemberAccess) {
15408
+ considerDecl = false;
15409
+ }
15315
15410
  if (usageNode !== undefined) {
15316
15411
  if (decl.type !== 8 /* Alias */) {
15317
15412
  // Is the declaration in the same execution scope as the "usageNode" node?
@@ -15549,6 +15644,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15549
15644
  if (types_1.FunctionType.isStubDefinition(type)) {
15550
15645
  return types_1.UnknownType.create();
15551
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
+ }
15552
15652
  // If the return type has already been lazily evaluated,
15553
15653
  // don't bother computing it again.
15554
15654
  if (type.inferredReturnType) {
@@ -16025,17 +16125,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16025
16125
  }
16026
16126
  }
16027
16127
  else {
16028
- if (srcUnboundedIndex >= 0) {
16029
- // PEP 646 allows an indeterminate tuple type to be assigned to
16030
- // a determinate tuple type if it's associated with a TypeVarTuple.
16031
- if (!destType.isUnpacked) {
16032
- diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.tupleSizeMismatchIndeterminate().format({
16033
- expected: destTypeArgs.length,
16034
- }));
16035
- return false;
16036
- }
16037
- }
16038
- else {
16128
+ if (srcUnboundedIndex < 0) {
16039
16129
  diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.tupleSizeMismatch().format({
16040
16130
  expected: destTypeArgs.length,
16041
16131
  received: srcTypeArgs.length,
@@ -16296,7 +16386,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16296
16386
  // Before performing any other checks, see if the dest type is a
16297
16387
  // TypeVar that we are attempting to match.
16298
16388
  if ((0, types_1.isTypeVar)(destType)) {
16299
- if ((0, types_1.isTypeSame)(destType, srcType)) {
16389
+ if ((0, typeUtils_1.isTypeVarSame)(destType, srcType)) {
16300
16390
  if (destType.scopeId && (destTypeVarContext === null || destTypeVarContext === void 0 ? void 0 : destTypeVarContext.hasSolveForScope(destType.scopeId))) {
16301
16391
  return (0, constraintSolver_1.assignTypeToTypeVar)(evaluatorInterface, destType, srcType, diag, destTypeVarContext, flags, recursionCount);
16302
16392
  }
@@ -17128,6 +17218,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17128
17218
  if (!constructorFunction.details.docString && classType.details.docString) {
17129
17219
  constructorFunction.details.docString = classType.details.docString;
17130
17220
  }
17221
+ constructorFunction.details.flags &= ~4 /* StaticMethod */;
17131
17222
  }
17132
17223
  return constructorFunction;
17133
17224
  };
@@ -17165,6 +17256,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17165
17256
  if (!constructorFunction.details.docString && classType.details.docString) {
17166
17257
  constructorFunction.details.docString = classType.details.docString;
17167
17258
  }
17259
+ constructorFunction.details.flags &= ~(4 /* StaticMethod */ | 1 /* ConstructorMethod */);
17168
17260
  }
17169
17261
  return constructorFunction;
17170
17262
  };
@@ -17189,7 +17281,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17189
17281
  }
17190
17282
  }
17191
17283
  // Return a generic constructor.
17192
- const constructorFunction = types_1.FunctionType.createSynthesizedInstance('__new__', 1 /* ConstructorMethod */);
17284
+ const constructorFunction = types_1.FunctionType.createSynthesizedInstance('__new__', 0 /* None */);
17193
17285
  constructorFunction.details.declaredReturnType = types_1.ClassType.cloneAsInstance(classType);
17194
17286
  types_1.FunctionType.addDefaultParameters(constructorFunction);
17195
17287
  if (!constructorFunction.details.docString && classType.details.docString) {
@@ -17321,7 +17413,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17321
17413
  if (srcDetails.params.length < destDetails.argsIndex) {
17322
17414
  return;
17323
17415
  }
17324
- 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);
17325
17417
  if (srcLastToPackIndex < 0) {
17326
17418
  srcLastToPackIndex = srcDetails.params.length;
17327
17419
  }
@@ -17370,7 +17462,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17370
17462
  },
17371
17463
  type: srcPositionalsType,
17372
17464
  index: -1,
17373
- source: typeUtils_1.ParameterSource.PositionOnly,
17465
+ source: parameterUtils_1.ParameterSource.PositionOnly,
17374
17466
  },
17375
17467
  ...srcDetails.params.slice(destDetails.argsIndex + srcPositionalsToPack.length, srcDetails.params.length),
17376
17468
  ];
@@ -17378,9 +17470,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17378
17470
  srcDetails.argsIndex = argsIndex >= 0 ? argsIndex : undefined;
17379
17471
  const kwargsIndex = srcDetails.params.findIndex((param) => param.param.category === 2 /* VarArgDictionary */);
17380
17472
  srcDetails.kwargsIndex = kwargsIndex >= 0 ? kwargsIndex : undefined;
17381
- 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);
17382
17474
  srcDetails.firstKeywordOnlyIndex = firstKeywordOnlyIndex >= 0 ? firstKeywordOnlyIndex : undefined;
17383
- 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 ||
17384
17476
  p.param.category !== 0 /* Simple */ ||
17385
17477
  p.param.hasDefault));
17386
17478
  }
@@ -17392,8 +17484,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17392
17484
  flags &= ~32 /* SkipFunctionReturnTypeCheck */;
17393
17485
  destType = (0, typeUtils_1.removeParamSpecVariadicsFromFunction)(destType);
17394
17486
  srcType = (0, typeUtils_1.removeParamSpecVariadicsFromFunction)(srcType);
17395
- const destParamDetails = (0, typeUtils_1.getParameterListDetails)(destType);
17396
- const srcParamDetails = (0, typeUtils_1.getParameterListDetails)(srcType);
17487
+ const destParamDetails = (0, parameterUtils_1.getParameterListDetails)(destType);
17488
+ const srcParamDetails = (0, parameterUtils_1.getParameterListDetails)(srcType);
17397
17489
  adjustSourceParamDetailsForDestVariadic(srcParamDetails, destParamDetails);
17398
17490
  const targetIncludesParamSpec = (flags & 2 /* ReverseTypeVarMatching */) !== 0
17399
17491
  ? !!srcType.details.paramSpec
@@ -17412,7 +17504,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17412
17504
  const destParamName = (_e = destParam.param.name) !== null && _e !== void 0 ? _e : '';
17413
17505
  const srcParamName = (_f = srcParam.param.name) !== null && _f !== void 0 ? _f : '';
17414
17506
  if (destParamName && !(0, symbolNameUtils_1.isPrivateOrProtectedName)(destParamName) && !(0, symbolNameUtils_1.isPrivateOrProtectedName)(srcParamName)) {
17415
- const isDestPositionalOnly = destParam.source === typeUtils_1.ParameterSource.PositionOnly;
17507
+ const isDestPositionalOnly = destParam.source === parameterUtils_1.ParameterSource.PositionOnly;
17416
17508
  if (!isDestPositionalOnly &&
17417
17509
  destParam.param.category !== 1 /* VarArgList */ &&
17418
17510
  srcParam.param.category !== 1 /* VarArgList */ &&
@@ -17507,7 +17599,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17507
17599
  if (!assignFunctionParameter(destParamType, srcArgsType, paramIndex, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), destTypeVarContext, srcTypeVarContext, flags, recursionCount)) {
17508
17600
  canAssign = false;
17509
17601
  }
17510
- if (destParamDetails.params[paramIndex].source !== typeUtils_1.ParameterSource.PositionOnly &&
17602
+ if (destParamDetails.params[paramIndex].source !== parameterUtils_1.ParameterSource.PositionOnly &&
17511
17603
  srcParamDetails.kwargsIndex === undefined) {
17512
17604
  diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.namedParamMissingInSource().format({
17513
17605
  name: (_g = destParamDetails.params[paramIndex].param.name) !== null && _g !== void 0 ? _g : '',
@@ -17902,12 +17994,20 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17902
17994
  return narrowedSubtype;
17903
17995
  });
17904
17996
  // If the result of narrowing is Any, stick with the declared (unnarrowed) type.
17905
- // If the result of narrowing is an Unknown that is complete, stick with Unknown.
17906
- // If it's incomplete, propagate the incomplete type for the benefit of
17907
- // code flow analysis.
17908
- if ((0, types_1.isAnyOrUnknown)(assignedType) && !(0, typeUtils_1.isIncompleteUnknown)(assignedType)) {
17997
+ // If the result of narrowing is an Unknown that is incomplete, propagate the
17998
+ // incomplete type for the benefit of code flow analysis.
17999
+ // If the result of narrowing is a complete Unknown, combine the Unknown type
18000
+ // with the declared type. In strict mode, this will retain the "unknown type"
18001
+ // diagnostics while still providing reasonable completion suggestions.
18002
+ if ((0, types_1.isAny)(narrowedType)) {
17909
18003
  return declaredType;
17910
18004
  }
18005
+ else if ((0, typeUtils_1.isIncompleteUnknown)(narrowedType)) {
18006
+ return narrowedType;
18007
+ }
18008
+ else if ((0, types_1.isUnknown)(narrowedType)) {
18009
+ return (0, types_1.combineTypes)([narrowedType, declaredType]);
18010
+ }
17911
18011
  return narrowedType;
17912
18012
  }
17913
18013
  function validateOverrideMethod(baseMethod, overrideMethod, diag, enforceParamNames = true) {
@@ -17946,8 +18046,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17946
18046
  }
17947
18047
  function validateOverrideMethodInternal(baseMethod, overrideMethod, diag, enforceParamNames) {
17948
18048
  var _a, _b;
17949
- const baseParamDetails = (0, typeUtils_1.getParameterListDetails)(baseMethod);
17950
- const overrideParamDetails = (0, typeUtils_1.getParameterListDetails)(overrideMethod);
18049
+ const baseParamDetails = (0, parameterUtils_1.getParameterListDetails)(baseMethod);
18050
+ const overrideParamDetails = (0, parameterUtils_1.getParameterListDetails)(overrideMethod);
17951
18051
  let canOverride = true;
17952
18052
  // Verify that we're not overriding a static, class or instance method with
17953
18053
  // an incompatible type.
@@ -18026,12 +18126,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
18026
18126
  const overrideParam = overrideParamDetails.params[i].param;
18027
18127
  if (i >= baseParamDetails.positionOnlyParamCount &&
18028
18128
  !(0, symbolNameUtils_1.isPrivateOrProtectedName)(baseParam.name || '') &&
18029
- baseParamDetails.params[i].source !== typeUtils_1.ParameterSource.PositionOnly &&
18129
+ baseParamDetails.params[i].source !== parameterUtils_1.ParameterSource.PositionOnly &&
18030
18130
  baseParam.category === 0 /* Simple */ &&
18031
18131
  baseParam.name !== overrideParam.name) {
18032
18132
  if (overrideParam.category === 0 /* Simple */) {
18033
18133
  if (enforceParamNames) {
18034
- if (overrideParamDetails.params[i].source === typeUtils_1.ParameterSource.PositionOnly) {
18134
+ if (overrideParamDetails.params[i].source === parameterUtils_1.ParameterSource.PositionOnly) {
18035
18135
  diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideParamNamePositionOnly().format({
18036
18136
  index: i + 1,
18037
18137
  baseName: baseParam.name || '*',
@@ -18103,9 +18203,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
18103
18203
  }
18104
18204
  }
18105
18205
  // Now check any keyword-only parameters.
18106
- 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 &&
18107
18207
  paramInfo.param.category === 0 /* Simple */);
18108
- 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 &&
18109
18209
  paramInfo.param.category === 0 /* Simple */);
18110
18210
  baseKwOnlyParams.forEach((paramInfo) => {
18111
18211
  var _a, _b, _c;