@zzzen/pyright-internal 1.2.0-dev.20240811 → 1.2.0-dev.20240818

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 (62) hide show
  1. package/dist/analyzer/analyzerFileInfo.js +1 -1
  2. package/dist/analyzer/analyzerFileInfo.js.map +1 -1
  3. package/dist/analyzer/checker.js +4 -4
  4. package/dist/analyzer/checker.js.map +1 -1
  5. package/dist/analyzer/constraintSolver.js +2 -2
  6. package/dist/analyzer/constraintSolver.js.map +1 -1
  7. package/dist/analyzer/dataClasses.js +1 -1
  8. package/dist/analyzer/dataClasses.js.map +1 -1
  9. package/dist/analyzer/enums.js +1 -1
  10. package/dist/analyzer/enums.js.map +1 -1
  11. package/dist/analyzer/importResolver.js +3 -3
  12. package/dist/analyzer/importResolver.js.map +1 -1
  13. package/dist/analyzer/operations.js +136 -117
  14. package/dist/analyzer/operations.js.map +1 -1
  15. package/dist/analyzer/protocols.js +29 -20
  16. package/dist/analyzer/protocols.js.map +1 -1
  17. package/dist/analyzer/pythonPathUtils.js +2 -1
  18. package/dist/analyzer/pythonPathUtils.js.map +1 -1
  19. package/dist/analyzer/staticExpressions.js +9 -9
  20. package/dist/analyzer/staticExpressions.js.map +1 -1
  21. package/dist/analyzer/tuples.js +3 -3
  22. package/dist/analyzer/tuples.js.map +1 -1
  23. package/dist/analyzer/typeEvaluator.js +75 -71
  24. package/dist/analyzer/typeEvaluator.js.map +1 -1
  25. package/dist/analyzer/typeUtils.d.ts +2 -1
  26. package/dist/analyzer/typeUtils.js +15 -4
  27. package/dist/analyzer/typeUtils.js.map +1 -1
  28. package/dist/analyzer/types.js +3 -0
  29. package/dist/analyzer/types.js.map +1 -1
  30. package/dist/backgroundThreadBase.js +0 -7
  31. package/dist/backgroundThreadBase.js.map +1 -1
  32. package/dist/common/fullAccessHost.js +1 -1
  33. package/dist/common/fullAccessHost.js.map +1 -1
  34. package/dist/common/pythonVersion.d.ts +17 -20
  35. package/dist/common/pythonVersion.js +81 -85
  36. package/dist/common/pythonVersion.js.map +1 -1
  37. package/dist/languageService/completionProvider.js +2 -2
  38. package/dist/languageService/completionProvider.js.map +1 -1
  39. package/dist/localization/localize.d.ts +4 -4
  40. package/dist/localization/localize.js +2 -2
  41. package/dist/localization/localize.js.map +1 -1
  42. package/dist/localization/package.nls.cs.json +0 -2
  43. package/dist/localization/package.nls.de.json +0 -2
  44. package/dist/localization/package.nls.en-us.json +2 -2
  45. package/dist/localization/package.nls.es.json +0 -2
  46. package/dist/localization/package.nls.fr.json +0 -2
  47. package/dist/localization/package.nls.it.json +0 -2
  48. package/dist/localization/package.nls.ja.json +0 -2
  49. package/dist/localization/package.nls.ko.json +0 -2
  50. package/dist/localization/package.nls.pl.json +0 -2
  51. package/dist/localization/package.nls.pt-br.json +0 -2
  52. package/dist/localization/package.nls.qps-ploc.json +0 -2
  53. package/dist/localization/package.nls.ru.json +0 -2
  54. package/dist/localization/package.nls.tr.json +0 -2
  55. package/dist/localization/package.nls.zh-cn.json +0 -2
  56. package/dist/localization/package.nls.zh-tw.json +0 -2
  57. package/dist/parser/parser.js +32 -23
  58. package/dist/parser/parser.js.map +1 -1
  59. package/dist/tests/typeEvaluator4.test.js +4 -0
  60. package/dist/tests/typeEvaluator4.test.js.map +1 -1
  61. package/dist/tests/typeEvaluator7.test.js +2 -2
  62. package/package.json +1 -1
@@ -266,7 +266,7 @@ class Parser {
266
266
  // type_alias_stmt: "type" name [type_param_seq] = expr
267
267
  _parseTypeAliasStatement() {
268
268
  const typeToken = this._getKeywordToken(35 /* KeywordType.Type */);
269
- if (!this._parseOptions.isStubFile && this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_12)) {
269
+ if (!this._parseOptions.isStubFile && pythonVersion_1.PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion_1.pythonVersion3_12)) {
270
270
  this._addSyntaxError(localize_1.LocMessage.typeAliasStatementIllegal(), typeToken);
271
271
  }
272
272
  const nameToken = this._getTokenIfIdentifier();
@@ -348,7 +348,8 @@ class Parser {
348
348
  if (this._consumeTokenIfOperator(2 /* OperatorType.Assign */)) {
349
349
  defaultExpression = this._parseExpression(
350
350
  /* allowUnpack */ typeParamCategory === parseNodes_1.TypeParamKind.TypeVarTuple);
351
- if (!this._parseOptions.isStubFile && this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_13)) {
351
+ if (!this._parseOptions.isStubFile &&
352
+ pythonVersion_1.PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion_1.pythonVersion3_13)) {
352
353
  this._addSyntaxError(localize_1.LocMessage.typeVarDefaultIllegal(), defaultExpression);
353
354
  }
354
355
  }
@@ -456,7 +457,7 @@ class Parser {
456
457
  }
457
458
  }
458
459
  // This feature requires Python 3.10.
459
- if (this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_10)) {
460
+ if (pythonVersion_1.PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion_1.pythonVersion3_10)) {
460
461
  this._addSyntaxError(localize_1.LocMessage.matchIncompatible(), matchToken);
461
462
  }
462
463
  // Validate that only the last entry uses an irrefutable pattern.
@@ -1222,7 +1223,8 @@ class Parser {
1222
1223
  forSuite = this._parseLoopSuite();
1223
1224
  // Versions of Python earlier than 3.9 didn't allow unpack operators if the
1224
1225
  // tuple wasn't enclosed in parentheses.
1225
- if (this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_9) && !this._parseOptions.isStubFile) {
1226
+ if (pythonVersion_1.PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion_1.pythonVersion3_9) &&
1227
+ !this._parseOptions.isStubFile) {
1226
1228
  if (seqExpr.nodeType === 52 /* ParseNodeType.Tuple */ && !seqExpr.d.hasParens) {
1227
1229
  let sawStar = false;
1228
1230
  seqExpr.d.items.forEach((expr) => {
@@ -1361,7 +1363,8 @@ class Parser {
1361
1363
  const possibleStarToken = this._peekToken();
1362
1364
  let isExceptGroup = false;
1363
1365
  if (this._consumeTokenIfOperator(26 /* OperatorType.Multiply */)) {
1364
- if (this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_11) && !this._parseOptions.isStubFile) {
1366
+ if (pythonVersion_1.PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion_1.pythonVersion3_11) &&
1367
+ !this._parseOptions.isStubFile) {
1365
1368
  this._addSyntaxError(localize_1.LocMessage.exceptionGroupIncompatible(), possibleStarToken);
1366
1369
  }
1367
1370
  isExceptGroup = true;
@@ -1441,7 +1444,8 @@ class Parser {
1441
1444
  const possibleOpenBracket = this._peekToken();
1442
1445
  if (possibleOpenBracket.type === 15 /* TokenType.OpenBracket */) {
1443
1446
  typeParameters = this._parseTypeParameterList();
1444
- if (!this._parseOptions.isStubFile && this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_12)) {
1447
+ if (!this._parseOptions.isStubFile &&
1448
+ pythonVersion_1.PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion_1.pythonVersion3_12)) {
1445
1449
  this._addSyntaxError(localize_1.LocMessage.functionTypeParametersIllegal(), typeParameters);
1446
1450
  }
1447
1451
  }
@@ -1633,7 +1637,8 @@ class Parser {
1633
1637
  starCount = 2;
1634
1638
  }
1635
1639
  else if (this._consumeTokenIfOperator(10 /* OperatorType.Divide */)) {
1636
- if (this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_8) && !this._parseOptions.isStubFile) {
1640
+ if (pythonVersion_1.PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion_1.pythonVersion3_8) &&
1641
+ !this._parseOptions.isStubFile) {
1637
1642
  this._addSyntaxError(localize_1.LocMessage.positionOnlyIncompatible(), firstToken);
1638
1643
  }
1639
1644
  slashCount = 1;
@@ -1723,7 +1728,7 @@ class Parser {
1723
1728
  }
1724
1729
  if (isParenthesizedWithItemList) {
1725
1730
  this._consumeTokenIfType(13 /* TokenType.OpenParenthesis */);
1726
- if (this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_9)) {
1731
+ if (pythonVersion_1.PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion_1.pythonVersion3_9)) {
1727
1732
  this._addSyntaxError(localize_1.LocMessage.parenthesizedContextManagerIllegal(), possibleParen);
1728
1733
  }
1729
1734
  }
@@ -1816,7 +1821,7 @@ class Parser {
1816
1821
  const expression = this._parseTestExpression(/* allowAssignmentExpression */ true);
1817
1822
  // Versions of Python prior to 3.9 support a limited set of
1818
1823
  // expression forms.
1819
- if (this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_9)) {
1824
+ if (pythonVersion_1.PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion_1.pythonVersion3_9)) {
1820
1825
  let isSupportedExpressionForm = false;
1821
1826
  if (this._isNameOrMemberAccessExpression(expression)) {
1822
1827
  isSupportedExpressionForm = true;
@@ -1857,7 +1862,8 @@ class Parser {
1857
1862
  const possibleOpenBracket = this._peekToken();
1858
1863
  if (possibleOpenBracket.type === 15 /* TokenType.OpenBracket */) {
1859
1864
  typeParameters = this._parseTypeParameterList();
1860
- if (!this._parseOptions.isStubFile && this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_12)) {
1865
+ if (!this._parseOptions.isStubFile &&
1866
+ pythonVersion_1.PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion_1.pythonVersion3_12)) {
1861
1867
  this._addSyntaxError(localize_1.LocMessage.classTypeParametersIllegal(), typeParameters);
1862
1868
  }
1863
1869
  }
@@ -2250,7 +2256,7 @@ class Parser {
2250
2256
  const yieldToken = this._getKeywordToken(38 /* KeywordType.Yield */);
2251
2257
  const nextToken = this._peekToken();
2252
2258
  if (this._consumeTokenIfKeyword(18 /* KeywordType.From */)) {
2253
- if (this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_3)) {
2259
+ if (pythonVersion_1.PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion_1.pythonVersion3_3)) {
2254
2260
  this._addSyntaxError(localize_1.LocMessage.yieldFromIllegal(), nextToken);
2255
2261
  }
2256
2262
  return parseNodes_1.YieldFromNode.create(yieldToken, this._parseTestExpression(/* allowAssignmentExpression */ false));
@@ -2492,7 +2498,7 @@ class Parser {
2492
2498
  if (!this._assignmentExpressionsAllowed || disallowAssignmentExpression) {
2493
2499
  this._addSyntaxError(localize_1.LocMessage.walrusNotAllowed(), walrusToken);
2494
2500
  }
2495
- if (this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_8)) {
2501
+ if (pythonVersion_1.PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion_1.pythonVersion3_8)) {
2496
2502
  this._addSyntaxError(localize_1.LocMessage.walrusIllegal(), walrusToken);
2497
2503
  }
2498
2504
  const rightExpr = this._parseTestExpression(/* allowAssignmentExpression */ false);
@@ -2740,7 +2746,7 @@ class Parser {
2740
2746
  let awaitToken;
2741
2747
  if (this._peekKeywordType() === 4 /* KeywordType.Await */) {
2742
2748
  awaitToken = this._getKeywordToken(4 /* KeywordType.Await */);
2743
- if (this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_5)) {
2749
+ if (pythonVersion_1.PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion_1.pythonVersion3_5)) {
2744
2750
  this._addSyntaxError(localize_1.LocMessage.awaitIllegal(), awaitToken);
2745
2751
  }
2746
2752
  }
@@ -2894,7 +2900,8 @@ class Parser {
2894
2900
  this._tokenIndex = startOfSubscriptIndex;
2895
2901
  valueExpr = this._parseTestExpression(/* allowAssignmentExpression */ true);
2896
2902
  // Python 3.10 and newer allow assignment expressions to be used inside of a subscript.
2897
- if (!this._parseOptions.isStubFile && this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_10)) {
2903
+ if (!this._parseOptions.isStubFile &&
2904
+ pythonVersion_1.PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion_1.pythonVersion3_10)) {
2898
2905
  this._addSyntaxError(localize_1.LocMessage.assignmentExprInSubscript(), valueExpr);
2899
2906
  }
2900
2907
  }
@@ -2917,7 +2924,7 @@ class Parser {
2917
2924
  if (argType !== 0 /* ArgCategory.Simple */) {
2918
2925
  const unpackListAllowed = this._parseOptions.isStubFile ||
2919
2926
  this._isParsingQuotedText ||
2920
- this._getLanguageVersion().isGreaterOrEqualTo(pythonVersion_1.pythonVersion3_11);
2927
+ pythonVersion_1.PythonVersion.isGreaterOrEqualTo(this._getLanguageVersion(), pythonVersion_1.pythonVersion3_11);
2921
2928
  if (argType === 1 /* ArgCategory.UnpackedList */ && !unpackListAllowed) {
2922
2929
  this._addSyntaxError(localize_1.LocMessage.unpackedSubscriptIllegal(), argNode);
2923
2930
  }
@@ -2957,7 +2964,8 @@ class Parser {
2957
2964
  }
2958
2965
  if (nextTokenType !== 10 /* TokenType.Colon */) {
2959
2966
  // Python 3.10 and newer allow assignment expressions to be used inside of a subscript.
2960
- const allowAssignmentExpression = this._parseOptions.isStubFile || this._getLanguageVersion().isGreaterOrEqualTo(pythonVersion_1.pythonVersion3_10);
2967
+ const allowAssignmentExpression = this._parseOptions.isStubFile ||
2968
+ pythonVersion_1.PythonVersion.isGreaterOrEqualTo(this._getLanguageVersion(), pythonVersion_1.pythonVersion3_10);
2961
2969
  sliceExpressions[sliceIndex] = this._parseTestExpression(allowAssignmentExpression);
2962
2970
  }
2963
2971
  sliceIndex++;
@@ -3046,7 +3054,7 @@ class Parser {
3046
3054
  if (nameExpr.nodeType === 38 /* ParseNodeType.Name */ &&
3047
3055
  (this._peekTokenType() === 12 /* TokenType.Comma */ || this._peekTokenType() === 14 /* TokenType.CloseParenthesis */)) {
3048
3056
  nameNode = parseNodes_1.NameNode.create(nameExpr.d.token);
3049
- if (this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_14)) {
3057
+ if (pythonVersion_1.PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion_1.pythonVersion3_14)) {
3050
3058
  this._addSyntaxError(localize_1.LocMessage.keywordArgShortcutIllegal(), assignmentToken);
3051
3059
  valueExpr = parseNodes_1.ErrorNode.create(assignmentToken, 14 /* ErrorExpressionCategory.MissingKeywordArgValue */);
3052
3060
  }
@@ -3298,7 +3306,7 @@ class Parser {
3298
3306
  keyExpression = this._parseTestOrStarExpression(/* allowAssignmentExpression */ true);
3299
3307
  // Allow walrus operators in this context only for Python 3.10 and newer.
3300
3308
  // Older versions of Python generated a syntax error in this context.
3301
- let isWalrusAllowed = this._getLanguageVersion().isGreaterOrEqualTo(pythonVersion_1.pythonVersion3_10);
3309
+ let isWalrusAllowed = pythonVersion_1.PythonVersion.isGreaterOrEqualTo(this._getLanguageVersion(), pythonVersion_1.pythonVersion3_10);
3302
3310
  if (this._consumeTokenIfType(10 /* TokenType.Colon */)) {
3303
3311
  valueExpression = this._parseTestExpression(/* allowAssignmentExpression */ false);
3304
3312
  isWalrusAllowed = false;
@@ -3465,7 +3473,8 @@ class Parser {
3465
3473
  if (this._consumeTokenIfType(10 /* TokenType.Colon */)) {
3466
3474
  annotationExpr = this._parseTypeAnnotation();
3467
3475
  leftExpr = parseNodes_1.TypeAnnotationNode.create(leftExpr, annotationExpr);
3468
- if (!this._parseOptions.isStubFile && this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_6)) {
3476
+ if (!this._parseOptions.isStubFile &&
3477
+ pythonVersion_1.PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion_1.pythonVersion3_6)) {
3469
3478
  this._addSyntaxError(localize_1.LocMessage.varAnnotationIllegal(), annotationExpr);
3470
3479
  }
3471
3480
  if (!this._consumeTokenIfOperator(2 /* OperatorType.Assign */)) {
@@ -3599,7 +3608,7 @@ class Parser {
3599
3608
  allowUnpack &&
3600
3609
  !this._parseOptions.isStubFile &&
3601
3610
  !this._isParsingQuotedText &&
3602
- this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_11)) {
3611
+ pythonVersion_1.PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion_1.pythonVersion3_11)) {
3603
3612
  this._addSyntaxError(localize_1.LocMessage.unpackedSubscriptIllegal(), startToken);
3604
3613
  }
3605
3614
  let result = this._parseTestExpression(/* allowAssignmentExpression */ false);
@@ -3617,7 +3626,7 @@ class Parser {
3617
3626
  this._addSyntaxError(localize_1.LocMessage.stringNonAsciiBytes(), stringToken);
3618
3627
  }
3619
3628
  if (stringToken.flags & 64 /* StringTokenFlags.Format */) {
3620
- if (this._getLanguageVersion().isLessThan(pythonVersion_1.pythonVersion3_6)) {
3629
+ if (pythonVersion_1.PythonVersion.isLessThan(this._getLanguageVersion(), pythonVersion_1.pythonVersion3_6)) {
3621
3630
  this._addSyntaxError(localize_1.LocMessage.formatStringIllegal(), stringToken);
3622
3631
  }
3623
3632
  if (stringToken.flags & 32 /* StringTokenFlags.Bytes */) {
@@ -3715,7 +3724,7 @@ class Parser {
3715
3724
  if (nextToken.type === 9 /* TokenType.Operator */ &&
3716
3725
  nextToken.operatorType === 2 /* OperatorType.Assign */) {
3717
3726
  // This feature requires Python 3.8 or newer.
3718
- if (this._parseOptions.pythonVersion.isLessThan(pythonVersion_1.pythonVersion3_8)) {
3727
+ if (pythonVersion_1.PythonVersion.isLessThan(this._parseOptions.pythonVersion, pythonVersion_1.pythonVersion3_8)) {
3719
3728
  this._addSyntaxError(localize_1.LocMessage.formatStringDebuggingIllegal(), nextToken);
3720
3729
  }
3721
3730
  this._getNextToken();
@@ -3916,7 +3925,7 @@ class Parser {
3916
3925
  if (possibleTupleExpr.d.hasParens) {
3917
3926
  return;
3918
3927
  }
3919
- if (this._parseOptions.pythonVersion.isGreaterOrEqualTo(pythonVersion)) {
3928
+ if (pythonVersion_1.PythonVersion.isGreaterOrEqualTo(this._parseOptions.pythonVersion, pythonVersion)) {
3920
3929
  return;
3921
3930
  }
3922
3931
  for (const expr of possibleTupleExpr.d.items) {