@zzzen/pyright-internal 1.2.0-dev.20240121 → 1.2.0-dev.20240128

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 (38) hide show
  1. package/dist/analyzer/binder.js +2 -2
  2. package/dist/analyzer/binder.js.map +1 -1
  3. package/dist/analyzer/checker.js +24 -24
  4. package/dist/analyzer/checker.js.map +1 -1
  5. package/dist/analyzer/constructorTransform.js +8 -8
  6. package/dist/analyzer/constructorTransform.js.map +1 -1
  7. package/dist/analyzer/constructors.js +1 -1
  8. package/dist/analyzer/constructors.js.map +1 -1
  9. package/dist/analyzer/dataClasses.js +1 -1
  10. package/dist/analyzer/dataClasses.js.map +1 -1
  11. package/dist/analyzer/decorators.js +1 -1
  12. package/dist/analyzer/decorators.js.map +1 -1
  13. package/dist/analyzer/enums.js +0 -10
  14. package/dist/analyzer/enums.js.map +1 -1
  15. package/dist/analyzer/namedTuples.js +4 -4
  16. package/dist/analyzer/namedTuples.js.map +1 -1
  17. package/dist/analyzer/operations.js +8 -8
  18. package/dist/analyzer/operations.js.map +1 -1
  19. package/dist/analyzer/typeEvaluator.js +79 -74
  20. package/dist/analyzer/typeEvaluator.js.map +1 -1
  21. package/dist/analyzer/typeUtils.js +7 -6
  22. package/dist/analyzer/typeUtils.js.map +1 -1
  23. package/dist/analyzer/typedDicts.js +5 -5
  24. package/dist/analyzer/typedDicts.js.map +1 -1
  25. package/dist/common/configOptions.d.ts +16 -0
  26. package/dist/common/configOptions.js +80 -0
  27. package/dist/common/configOptions.js.map +1 -1
  28. package/dist/common/diagnosticRules.d.ts +16 -0
  29. package/dist/common/diagnosticRules.js +16 -0
  30. package/dist/common/diagnosticRules.js.map +1 -1
  31. package/dist/localization/localize.d.ts +0 -1
  32. package/dist/localization/localize.js +0 -1
  33. package/dist/localization/localize.js.map +1 -1
  34. package/dist/localization/package.nls.en-us.json +0 -1
  35. package/dist/tests/typeEvaluator1.test.js +3 -3
  36. package/dist/tests/typeEvaluator3.test.js +1 -1
  37. package/dist/tests/typeEvaluator4.test.js +1 -1
  38. package/package.json +1 -1
@@ -494,7 +494,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
494
494
  visitFor(node) {
495
495
  this._evaluator.evaluateTypesForStatement(node);
496
496
  if (node.typeComment) {
497
- this._evaluator.addDiagnosticForTextRange(this._fileInfo, this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.annotationNotSupported(), node.typeComment);
497
+ this._evaluator.addDiagnosticForTextRange(this._fileInfo, this._fileInfo.diagnosticRuleSet.reportInvalidTypeForm, diagnosticRules_1.DiagnosticRule.reportInvalidTypeForm, localize_1.LocMessage.annotationNotSupported(), node.typeComment);
498
498
  }
499
499
  return true;
500
500
  }
@@ -534,7 +534,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
534
534
  this._evaluator.evaluateTypesForStatement(item);
535
535
  });
536
536
  if (node.typeComment) {
537
- this._evaluator.addDiagnosticForTextRange(this._fileInfo, this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.annotationNotSupported(), node.typeComment);
537
+ this._evaluator.addDiagnosticForTextRange(this._fileInfo, this._fileInfo.diagnosticRuleSet.reportInvalidTypeForm, diagnosticRules_1.DiagnosticRule.reportInvalidTypeForm, localize_1.LocMessage.annotationNotSupported(), node.typeComment);
538
538
  }
539
539
  return true;
540
540
  }
@@ -611,7 +611,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
611
611
  if (returnTypeResult.expectedTypeDiagAddendum) {
612
612
  diagAddendum = returnTypeResult.expectedTypeDiagAddendum;
613
613
  }
614
- this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.returnTypeMismatch().format({
614
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportReturnType, localize_1.LocMessage.returnTypeMismatch().format({
615
615
  exprType: this._evaluator.printType(returnType),
616
616
  returnType: this._evaluator.printType(declaredReturnType),
617
617
  }) + diagAddendum.getString(), (_b = node.returnExpression) !== null && _b !== void 0 ? _b : node, (_c = returnTypeResult.expectedTypeDiagAddendum) === null || _c === void 0 ? void 0 : _c.getEffectiveTextRange());
@@ -1513,7 +1513,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1513
1513
  const errorMessage = node.isAsync
1514
1514
  ? localize_1.LocMessage.generatorAsyncReturnType()
1515
1515
  : localize_1.LocMessage.generatorSyncReturnType();
1516
- this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, errorMessage.format({ yieldType: this._evaluator.printType(types_1.AnyType.create()) }) +
1516
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeForm, errorMessage.format({ yieldType: this._evaluator.printType(types_1.AnyType.create()) }) +
1517
1517
  diagAddendum.getString(), (_a = node.returnTypeAnnotation) !== null && _a !== void 0 ? _a : node.name);
1518
1518
  }
1519
1519
  }
@@ -1729,12 +1729,12 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1729
1729
  }
1730
1730
  });
1731
1731
  if (staticMethodCount > 0 && staticMethodCount < functionType.overloads.length) {
1732
- this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.overloadStaticMethodInconsistent().format({
1732
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInconsistentOverload, localize_1.LocMessage.overloadStaticMethodInconsistent().format({
1733
1733
  name: node.name.value,
1734
1734
  }), (_c = (_b = (_a = functionType.overloads[0]) === null || _a === void 0 ? void 0 : _a.details.declaration) === null || _b === void 0 ? void 0 : _b.node.name) !== null && _c !== void 0 ? _c : node.name);
1735
1735
  }
1736
1736
  if (classMethodCount > 0 && classMethodCount < functionType.overloads.length) {
1737
- this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.overloadClassMethodInconsistent().format({
1737
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInconsistentOverload, localize_1.LocMessage.overloadClassMethodInconsistent().format({
1738
1738
  name: node.name.value,
1739
1739
  }), (_f = (_e = (_d = functionType.overloads[0]) === null || _d === void 0 ? void 0 : _d.details.declaration) === null || _e === void 0 ? void 0 : _e.node.name) !== null && _f !== void 0 ? _f : node.name);
1740
1740
  }
@@ -2047,7 +2047,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2047
2047
  : [];
2048
2048
  if (overloadedFunctions.length === 1) {
2049
2049
  // There should never be a single overload.
2050
- this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.singleOverload().format({ name }), primaryDecl.node.name);
2050
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInconsistentOverload, localize_1.LocMessage.singleOverload().format({ name }), primaryDecl.node.name);
2051
2051
  }
2052
2052
  // If the file is not a stub and this is the first overload,
2053
2053
  // verify that there is an implementation.
@@ -2079,7 +2079,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2079
2079
  // If this is a method within a protocol class, don't require that
2080
2080
  // there is an implementation.
2081
2081
  if (!exemptMissingImplementation) {
2082
- this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.overloadWithoutImplementation().format({
2082
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportNoOverloadImplementation, localize_1.LocMessage.overloadWithoutImplementation().format({
2083
2083
  name: primaryDecl.node.name.value,
2084
2084
  }), primaryDecl.node.name);
2085
2085
  }
@@ -2091,7 +2091,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2091
2091
  const diag = new diagnostic_1.DiagnosticAddendum();
2092
2092
  if (!this._isLegalOverloadImplementation(overload, implementationFunction, diag)) {
2093
2093
  if (implementationFunction.details.declaration) {
2094
- const diagnostic = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.overloadImplementationMismatch().format({
2094
+ const diagnostic = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInconsistentOverload, localize_1.LocMessage.overloadImplementationMismatch().format({
2095
2095
  name,
2096
2096
  index: index + 1,
2097
2097
  }) + diag.getString(), implementationFunction.details.declaration.node.name);
@@ -2171,7 +2171,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2171
2171
  if (typeAliasDecl && decls.length > 1) {
2172
2172
  decls.forEach((decl) => {
2173
2173
  if (decl !== typeAliasDecl) {
2174
- this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typeAliasRedeclared().format({ name }), decl.node);
2174
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportRedeclaration, localize_1.LocMessage.typeAliasRedeclared().format({ name }), decl.node);
2175
2175
  }
2176
2176
  });
2177
2177
  }
@@ -2279,7 +2279,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2279
2279
  duplicateIsOk = true;
2280
2280
  }
2281
2281
  if (!duplicateIsOk) {
2282
- const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.obscuredClassDeclaration().format({ name }), otherDecl.node.name);
2282
+ const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportRedeclaration, localize_1.LocMessage.obscuredClassDeclaration().format({ name }), otherDecl.node.name);
2283
2283
  addPrimaryDeclInfo(diag);
2284
2284
  }
2285
2285
  }
@@ -2312,7 +2312,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2312
2312
  duplicateIsOk = true;
2313
2313
  }
2314
2314
  if (!duplicateIsOk) {
2315
- const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, otherDecl.isMethod
2315
+ const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportRedeclaration, otherDecl.isMethod
2316
2316
  ? localize_1.LocMessage.obscuredMethodDeclaration().format({ name })
2317
2317
  : localize_1.LocMessage.obscuredFunctionDeclaration().format({ name }), otherDecl.node.name);
2318
2318
  addPrimaryDeclInfo(diag);
@@ -2328,7 +2328,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2328
2328
  }
2329
2329
  if (!duplicateIsOk) {
2330
2330
  const message = localize_1.LocMessage.obscuredParameterDeclaration();
2331
- const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, message.format({ name }), otherDecl.node.name);
2331
+ const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportRedeclaration, message.format({ name }), otherDecl.node.name);
2332
2332
  addPrimaryDeclInfo(diag);
2333
2333
  }
2334
2334
  }
@@ -2349,14 +2349,14 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2349
2349
  duplicateIsOk = true;
2350
2350
  }
2351
2351
  if (!duplicateIsOk) {
2352
- const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.obscuredVariableDeclaration().format({ name }), otherDecl.node);
2352
+ const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportRedeclaration, localize_1.LocMessage.obscuredVariableDeclaration().format({ name }), otherDecl.node);
2353
2353
  addPrimaryDeclInfo(diag);
2354
2354
  }
2355
2355
  }
2356
2356
  }
2357
2357
  }
2358
2358
  else if (otherDecl.type === 4 /* DeclarationType.TypeAlias */) {
2359
- const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.obscuredTypeAliasDeclaration().format({ name }), otherDecl.node.name);
2359
+ const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportRedeclaration, localize_1.LocMessage.obscuredTypeAliasDeclaration().format({ name }), otherDecl.node.name);
2360
2360
  addPrimaryDeclInfo(diag);
2361
2361
  }
2362
2362
  }
@@ -2547,7 +2547,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2547
2547
  }
2548
2548
  });
2549
2549
  if (!isValidType) {
2550
- this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, isInstanceCheck
2550
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportArgumentType, isInstanceCheck
2551
2551
  ? localize_1.LocMessage.isInstanceInvalidType().format({
2552
2552
  type: this._evaluator.printType(arg1Type),
2553
2553
  }) + diag.getString()
@@ -3030,7 +3030,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3030
3030
  this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnboundVariable, localize_1.LocMessage.symbolIsUnbound().format({ name: node.value }), node);
3031
3031
  }
3032
3032
  else if ((0, types_1.isPossiblyUnbound)(type)) {
3033
- this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnboundVariable, localize_1.LocMessage.symbolIsPossiblyUnbound().format({ name: node.value }), node);
3033
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportPossiblyUnboundVariable, localize_1.LocMessage.symbolIsPossiblyUnbound().format({ name: node.value }), node);
3034
3034
  }
3035
3035
  }
3036
3036
  }
@@ -3324,7 +3324,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3324
3324
  if (!ParseTreeUtils.isSuiteEmpty(node.suite) &&
3325
3325
  !types_1.FunctionType.isOverloaded(functionType) &&
3326
3326
  !types_1.FunctionType.isAsync(functionType)) {
3327
- this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.noReturnReturnsNone(), returnAnnotation);
3327
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportReturnType, localize_1.LocMessage.noReturnReturnsNone(), returnAnnotation);
3328
3328
  }
3329
3329
  }
3330
3330
  else if (!types_1.FunctionType.isAbstractMethod(functionType)) {
@@ -3337,7 +3337,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3337
3337
  // an abstract method or a protocol method and don't require that
3338
3338
  // the return type matches. This check can also be skipped for an overload.
3339
3339
  if (!ParseTreeUtils.isSuiteEmpty(node.suite) && !types_1.FunctionType.isOverloaded(functionType)) {
3340
- this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.returnMissing().format({
3340
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportReturnType, localize_1.LocMessage.returnMissing().format({
3341
3341
  returnType: this._evaluator.printType(declaredReturnType),
3342
3342
  }) + diagAddendum.getString(), returnAnnotation);
3343
3343
  }
@@ -3456,7 +3456,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3456
3456
  if (!(0, types_1.isClassInstance)(assignedValueType) ||
3457
3457
  !types_1.ClassType.isSameGenericClass(assignedValueType, classType)) {
3458
3458
  if (!this._evaluator.assignType(declaredValueType, assignedValueType, diag)) {
3459
- this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typeAssignmentMismatch().format(this._evaluator.printSrcDestTypes(assignedValueType, declaredValueType)) + diag.getString(), errorNode);
3459
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportAssignmentType, localize_1.LocMessage.typeAssignmentMismatch().format(this._evaluator.printSrcDestTypes(assignedValueType, declaredValueType)) + diag.getString(), errorNode);
3460
3460
  }
3461
3461
  }
3462
3462
  }
@@ -4160,7 +4160,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4160
4160
  overloads.forEach((overload) => {
4161
4161
  var _a, _b;
4162
4162
  if (types_1.FunctionType.isFinal(overload) && ((_a = overload.details.declaration) === null || _a === void 0 ? void 0 : _a.node)) {
4163
- this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.overloadFinalInconsistencyImpl().format({
4163
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInconsistentOverload, localize_1.LocMessage.overloadFinalInconsistencyImpl().format({
4164
4164
  name: overload.details.name,
4165
4165
  }), (_b = (0, declarationUtils_1.getNameNodeForDeclaration)(overload.details.declaration)) !== null && _b !== void 0 ? _b : overload.details.declaration.node);
4166
4166
  }
@@ -4172,7 +4172,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4172
4172
  overloads.slice(1).forEach((overload, index) => {
4173
4173
  var _a, _b;
4174
4174
  if (types_1.FunctionType.isFinal(overload) && ((_a = overload.details.declaration) === null || _a === void 0 ? void 0 : _a.node)) {
4175
- this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.overloadFinalInconsistencyNoImpl().format({
4175
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInconsistentOverload, localize_1.LocMessage.overloadFinalInconsistencyNoImpl().format({
4176
4176
  name: overload.details.name,
4177
4177
  index: index + 2,
4178
4178
  }), (_b = (0, declarationUtils_1.getNameNodeForDeclaration)(overload.details.declaration)) !== null && _b !== void 0 ? _b : overload.details.declaration.node);
@@ -4851,7 +4851,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4851
4851
  const errorMessage = enclosingFunctionNode.isAsync
4852
4852
  ? localize_1.LocMessage.generatorAsyncReturnType()
4853
4853
  : localize_1.LocMessage.generatorSyncReturnType();
4854
- this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, errorMessage.format({ yieldType: this._evaluator.printType(yieldType) }) +
4854
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportReturnType, errorMessage.format({ yieldType: this._evaluator.printType(yieldType) }) +
4855
4855
  ((_a = expectedDiagAddendum === null || expectedDiagAddendum === void 0 ? void 0 : expectedDiagAddendum.getString()) !== null && _a !== void 0 ? _a : diagAddendum.getString()), (_b = node.expression) !== null && _b !== void 0 ? _b : node, (_d = (_c = expectedDiagAddendum === null || expectedDiagAddendum === void 0 ? void 0 : expectedDiagAddendum.getEffectiveTextRange()) !== null && _c !== void 0 ? _c : node.expression) !== null && _d !== void 0 ? _d : node);
4856
4856
  }
4857
4857
  }
@@ -4918,7 +4918,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4918
4918
  });
4919
4919
  // Were all of the exception types overridden?
4920
4920
  if (typesOfThisExcept.length > 0 && typesOfThisExcept.length === overriddenExceptionCount) {
4921
- this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.unreachableExcept() + diagAddendum.getString(), except.typeExpression);
4921
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnusedExcept, localize_1.LocMessage.unreachableExcept() + diagAddendum.getString(), except.typeExpression);
4922
4922
  this._evaluator.addUnreachableCode(except, except.exceptSuite);
4923
4923
  }
4924
4924
  }