@zzzen/pyright-internal 1.2.0-dev.20220807 → 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 (63) hide show
  1. package/dist/analyzer/binder.js +0 -1
  2. package/dist/analyzer/binder.js.map +1 -1
  3. package/dist/analyzer/codeFlowEngine.js +9 -2
  4. package/dist/analyzer/codeFlowEngine.js.map +1 -1
  5. package/dist/analyzer/docStringConversion.js +8 -7
  6. package/dist/analyzer/docStringConversion.js.map +1 -1
  7. package/dist/analyzer/importResolver.js +2 -2
  8. package/dist/analyzer/importResolver.js.map +1 -1
  9. package/dist/analyzer/importResult.d.ts +2 -1
  10. package/dist/analyzer/packageTypeVerifier.js +26 -13
  11. package/dist/analyzer/packageTypeVerifier.js.map +1 -1
  12. package/dist/analyzer/program.d.ts +5 -1
  13. package/dist/analyzer/program.js +24 -3
  14. package/dist/analyzer/program.js.map +1 -1
  15. package/dist/analyzer/service.d.ts +4 -1
  16. package/dist/analyzer/service.js +2 -1
  17. package/dist/analyzer/service.js.map +1 -1
  18. package/dist/analyzer/typeEvaluator.js +46 -20
  19. package/dist/analyzer/typeEvaluator.js.map +1 -1
  20. package/dist/analyzer/typeEvaluatorTypes.d.ts +8 -0
  21. package/dist/analyzer/typeEvaluatorWithTracker.js +1 -0
  22. package/dist/analyzer/typeEvaluatorWithTracker.js.map +1 -1
  23. package/dist/analyzer/typeUtils.js +99 -58
  24. package/dist/analyzer/typeUtils.js.map +1 -1
  25. package/dist/languageServerBase.d.ts +6 -5
  26. package/dist/languageServerBase.js +27 -17
  27. package/dist/languageServerBase.js.map +1 -1
  28. package/dist/languageService/analyzerServiceExecutor.js +4 -2
  29. package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
  30. package/dist/languageService/codeActionProvider.js +1 -1
  31. package/dist/languageService/codeActionProvider.js.map +1 -1
  32. package/dist/languageService/completionProvider.js +3 -48
  33. package/dist/languageService/completionProvider.js.map +1 -1
  34. package/dist/languageService/hoverProvider.js +5 -8
  35. package/dist/languageService/hoverProvider.js.map +1 -1
  36. package/dist/languageService/signatureHelpProvider.js +3 -3
  37. package/dist/languageService/signatureHelpProvider.js.map +1 -1
  38. package/dist/languageService/tooltipUtils.d.ts +3 -2
  39. package/dist/languageService/tooltipUtils.js +30 -15
  40. package/dist/languageService/tooltipUtils.js.map +1 -1
  41. package/dist/pyright.js +3 -0
  42. package/dist/pyright.js.map +1 -1
  43. package/dist/server.js +3 -3
  44. package/dist/server.js.map +1 -1
  45. package/dist/tests/checker.test.js +1 -1
  46. package/dist/tests/docStringConversion.test.js +21 -21
  47. package/dist/tests/fourslash/completions.variableDocStrings.fourslash.js +15 -2
  48. package/dist/tests/fourslash/completions.variableDocStrings.fourslash.js.map +1 -1
  49. package/dist/tests/fourslash/hover.docstring.links.fourslash.js +1 -1
  50. package/dist/tests/fourslash/hover.docstring.links.fourslash.js.map +1 -1
  51. package/dist/tests/fourslash/hover.variable.docString.fourslash.js +12 -7
  52. package/dist/tests/fourslash/hover.variable.docString.fourslash.js.map +1 -1
  53. package/dist/tests/harness/fourslash/testLanguageService.js +4 -2
  54. package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
  55. package/dist/tests/harness/fourslash/testState.js +5 -3
  56. package/dist/tests/harness/fourslash/testState.js.map +1 -1
  57. package/dist/tests/typeEvaluator2.test.js +8 -0
  58. package/dist/tests/typeEvaluator2.test.js.map +1 -1
  59. package/dist/tests/typeEvaluator3.test.js +1 -1
  60. package/dist/tests/typeEvaluator4.test.js +1 -1
  61. package/dist/workspaceMap.js +18 -15
  62. package/dist/workspaceMap.js.map +1 -1
  63. package/package.json +1 -1
@@ -2856,7 +2856,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
2856
2856
  // cannot be used in this location.
2857
2857
  function validateTypeVarUsage(node, type, flags) {
2858
2858
  var _a;
2859
- 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)) {
2860
2860
  const scopedTypeVarInfo = findScopedTypeVar(node, type);
2861
2861
  type = scopedTypeVarInfo.type;
2862
2862
  if ((flags & 2048 /* DisallowTypeVarsWithScopeId */) !== 0 && type.scopeId !== undefined) {
@@ -3239,12 +3239,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3239
3239
  }
3240
3240
  }
3241
3241
  else {
3242
- // Handle the special case of LiteralString.
3243
- if (types_1.ClassType.isBuiltIn(baseType, 'LiteralString') &&
3244
- strClassType &&
3245
- (0, types_1.isInstantiableClass)(strClassType)) {
3246
- baseType = types_1.ClassType.cloneAsInstance(strClassType);
3247
- }
3248
3242
  // Handle the special case of 'name' and 'value' members within an enum.
3249
3243
  const enumMemberResult = (0, enums_1.getTypeOfEnumMember)(evaluatorInterface, node, baseType, memberName, isIncomplete);
3250
3244
  if (enumMemberResult) {
@@ -5442,7 +5436,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
5442
5436
  // Is this a union type? If so, we can expand it.
5443
5437
  const argType = contextFreeArgTypes[indexToExpand];
5444
5438
  if ((0, types_1.isUnion)(argType)) {
5445
- 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);
5446
5444
  break;
5447
5445
  }
5448
5446
  indexToExpand++;
@@ -7678,7 +7676,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7678
7676
  /* declaredMetaclass */ undefined, arg1Type.details.effectiveMetaclass);
7679
7677
  arg1Type.tupleTypeArguments.forEach((typeArg) => {
7680
7678
  const specializedType = makeTopLevelTypeVarsConcrete(typeArg.type);
7681
- 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'))) {
7682
7682
  classType.details.baseClasses.push(specializedType);
7683
7683
  }
7684
7684
  else {
@@ -8350,12 +8350,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8350
8350
  if ((0, types_1.isAnyOrUnknown)(subtype)) {
8351
8351
  return subtype;
8352
8352
  }
8353
- if ((0, types_1.isClassInstance)(subtype) &&
8354
- types_1.ClassType.isBuiltIn(subtype, 'LiteralString') &&
8355
- strClassType &&
8356
- (0, types_1.isInstantiableClass)(strClassType)) {
8357
- return handleSubtype(types_1.ClassType.cloneAsInstance(strClassType));
8358
- }
8359
8353
  if ((0, types_1.isClassInstance)(subtype) || (0, types_1.isInstantiableClass)(subtype) || (0, types_1.isTypeVar)(subtype)) {
8360
8354
  return handleSubtype(subtype);
8361
8355
  }
@@ -8576,6 +8570,21 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8576
8570
  if ((0, types_1.isAnyOrUnknown)(unexpandedType)) {
8577
8571
  addUnknown = false;
8578
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
+ }
8579
8588
  else {
8580
8589
  // Verify that the type supports the `keys` and `__getitem__` methods.
8581
8590
  // This protocol is defined in the _typeshed stub. If we can't find
@@ -10002,6 +10011,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
10002
10011
  return cachedType;
10003
10012
  }
10004
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
+ }
10005
10020
  writeTypeCache(node, specialType, 0 /* None */, /* isIncomplete */ false);
10006
10021
  return specialType;
10007
10022
  }
@@ -15375,11 +15390,21 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15375
15390
  // For all remaining source subtypes, attempt to find a dest subtype
15376
15391
  // whose primary type matches.
15377
15392
  if (!isIncompatible) {
15378
- [...remainingSrcSubtypes].forEach((srcSubtype) => {
15379
- const destTypeIndex = remainingDestSubtypes.findIndex((destSubtype) => (0, types_1.isClass)(srcSubtype) &&
15380
- (0, types_1.isClass)(destSubtype) &&
15381
- types_1.TypeBase.isInstance(srcSubtype) === types_1.TypeBase.isInstance(destSubtype) &&
15382
- 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
+ });
15383
15408
  if (destTypeIndex >= 0) {
15384
15409
  if (!assignType(remainingDestSubtypes[destTypeIndex], srcSubtype, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), destTypeVarContext, srcTypeVarContext, flags, recursionCount)) {
15385
15410
  isIncompatible = true;
@@ -17023,6 +17048,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17023
17048
  removeFalsinessFromType,
17024
17049
  verifyRaiseExceptionType,
17025
17050
  verifyDeleteExpression,
17051
+ validateOverloadedFunctionArguments,
17026
17052
  isAfterNodeReachable,
17027
17053
  isNodeReachable,
17028
17054
  isAsymmetricDescriptorAssignment,