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

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 (141) hide show
  1. package/dist/analyzer/binder.d.ts +1 -3
  2. package/dist/analyzer/binder.js +27 -37
  3. package/dist/analyzer/binder.js.map +1 -1
  4. package/dist/analyzer/checker.d.ts +1 -3
  5. package/dist/analyzer/checker.js +325 -381
  6. package/dist/analyzer/checker.js.map +1 -1
  7. package/dist/analyzer/commentUtils.js +7 -7
  8. package/dist/analyzer/commentUtils.js.map +1 -1
  9. package/dist/analyzer/constraintSolver.js +23 -30
  10. package/dist/analyzer/constraintSolver.js.map +1 -1
  11. package/dist/analyzer/constructorTransform.js +10 -11
  12. package/dist/analyzer/constructorTransform.js.map +1 -1
  13. package/dist/analyzer/constructors.d.ts +3 -3
  14. package/dist/analyzer/constructors.js +12 -14
  15. package/dist/analyzer/constructors.js.map +1 -1
  16. package/dist/analyzer/dataClasses.js +15 -15
  17. package/dist/analyzer/dataClasses.js.map +1 -1
  18. package/dist/analyzer/decorators.d.ts +1 -2
  19. package/dist/analyzer/decorators.js +4 -1
  20. package/dist/analyzer/decorators.js.map +1 -1
  21. package/dist/analyzer/enums.d.ts +4 -2
  22. package/dist/analyzer/enums.js +109 -50
  23. package/dist/analyzer/enums.js.map +1 -1
  24. package/dist/analyzer/functionTransform.js +1 -2
  25. package/dist/analyzer/functionTransform.js.map +1 -1
  26. package/dist/analyzer/importResolver.js +3 -3
  27. package/dist/analyzer/namedTuples.js +8 -7
  28. package/dist/analyzer/namedTuples.js.map +1 -1
  29. package/dist/analyzer/operations.js +15 -18
  30. package/dist/analyzer/operations.js.map +1 -1
  31. package/dist/analyzer/parseTreeUtils.d.ts +1 -1
  32. package/dist/analyzer/parseTreeUtils.js.map +1 -1
  33. package/dist/analyzer/patternMatching.js +22 -19
  34. package/dist/analyzer/patternMatching.js.map +1 -1
  35. package/dist/analyzer/program.js +17 -3
  36. package/dist/analyzer/program.js.map +1 -1
  37. package/dist/analyzer/properties.js +8 -8
  38. package/dist/analyzer/properties.js.map +1 -1
  39. package/dist/analyzer/protocols.js +14 -14
  40. package/dist/analyzer/protocols.js.map +1 -1
  41. package/dist/analyzer/service.js +14 -14
  42. package/dist/analyzer/service.js.map +1 -1
  43. package/dist/analyzer/sourceFile.js +12 -12
  44. package/dist/analyzer/sourceFile.js.map +1 -1
  45. package/dist/analyzer/typeEvaluator.js +820 -748
  46. package/dist/analyzer/typeEvaluator.js.map +1 -1
  47. package/dist/analyzer/typeEvaluatorTypes.d.ts +8 -8
  48. package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
  49. package/dist/analyzer/typeGuards.js +2 -2
  50. package/dist/analyzer/typeGuards.js.map +1 -1
  51. package/dist/analyzer/typePrinter.js +3 -4
  52. package/dist/analyzer/typePrinter.js.map +1 -1
  53. package/dist/analyzer/typeUtils.d.ts +4 -2
  54. package/dist/analyzer/typeUtils.js +6 -0
  55. package/dist/analyzer/typeUtils.js.map +1 -1
  56. package/dist/analyzer/typedDicts.js +30 -34
  57. package/dist/analyzer/typedDicts.js.map +1 -1
  58. package/dist/analyzer/types.d.ts +5 -10
  59. package/dist/analyzer/types.js +12 -39
  60. package/dist/analyzer/types.js.map +1 -1
  61. package/dist/backgroundThreadBase.js +4 -4
  62. package/dist/backgroundThreadBase.js.map +1 -1
  63. package/dist/common/commandLineOptions.d.ts +1 -0
  64. package/dist/common/commandLineOptions.js.map +1 -1
  65. package/dist/common/configOptions.d.ts +1 -0
  66. package/dist/common/configOptions.js +13 -11
  67. package/dist/common/configOptions.js.map +1 -1
  68. package/dist/common/core.d.ts +1 -1
  69. package/dist/common/core.js.map +1 -1
  70. package/dist/common/uri/baseUri.d.ts +7 -2
  71. package/dist/common/uri/baseUri.js +47 -24
  72. package/dist/common/uri/baseUri.js.map +1 -1
  73. package/dist/common/uri/emptyUri.d.ts +6 -4
  74. package/dist/common/uri/emptyUri.js +14 -9
  75. package/dist/common/uri/emptyUri.js.map +1 -1
  76. package/dist/common/uri/fileUri.d.ts +12 -4
  77. package/dist/common/uri/fileUri.js +59 -9
  78. package/dist/common/uri/fileUri.js.map +1 -1
  79. package/dist/common/uri/uri.d.ts +5 -1
  80. package/dist/common/uri/uri.js.map +1 -1
  81. package/dist/common/uri/uriUtils.js +3 -3
  82. package/dist/common/uri/webUri.d.ts +6 -1
  83. package/dist/common/uri/webUri.js +52 -12
  84. package/dist/common/uri/webUri.js.map +1 -1
  85. package/dist/languageServerBase.d.ts +1 -0
  86. package/dist/languageServerBase.js +1 -0
  87. package/dist/languageServerBase.js.map +1 -1
  88. package/dist/languageService/analyzerServiceExecutor.js +2 -0
  89. package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
  90. package/dist/languageService/completionProvider.js.map +1 -1
  91. package/dist/localization/localize.d.ts +5 -5
  92. package/dist/localization/localize.js +6 -3
  93. package/dist/localization/localize.js.map +1 -1
  94. package/dist/localization/package.nls.cs.json +34 -8
  95. package/dist/localization/package.nls.de.json +34 -8
  96. package/dist/localization/package.nls.en-us.json +8 -7
  97. package/dist/localization/package.nls.es.json +34 -8
  98. package/dist/localization/package.nls.fr.json +34 -8
  99. package/dist/localization/package.nls.it.json +34 -8
  100. package/dist/localization/package.nls.ja.json +34 -8
  101. package/dist/localization/package.nls.ko.json +34 -8
  102. package/dist/localization/package.nls.pl.json +34 -8
  103. package/dist/localization/package.nls.pt-br.json +34 -8
  104. package/dist/localization/package.nls.qps-ploc.json +32 -6
  105. package/dist/localization/package.nls.ru.json +34 -8
  106. package/dist/localization/package.nls.tr.json +34 -8
  107. package/dist/localization/package.nls.zh-cn.json +34 -8
  108. package/dist/localization/package.nls.zh-tw.json +34 -8
  109. package/dist/parser/parser.d.ts +1 -1
  110. package/dist/parser/parser.js +201 -201
  111. package/dist/parser/parser.js.map +1 -1
  112. package/dist/pyright.js +13 -11
  113. package/dist/pyright.js.map +1 -1
  114. package/dist/pyrightFileSystem.js +2 -2
  115. package/dist/server.js +7 -5
  116. package/dist/server.js.map +1 -1
  117. package/dist/tests/config.test.js +4 -4
  118. package/dist/tests/filesystem.test.js +2 -2
  119. package/dist/tests/fourSlashParser.test.js +1 -1
  120. package/dist/tests/harness/fourslash/testLanguageService.js +2 -0
  121. package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
  122. package/dist/tests/harness/fourslash/testState.js +1 -0
  123. package/dist/tests/harness/fourslash/testState.js.map +1 -1
  124. package/dist/tests/ipythonMode.test.js +10 -10
  125. package/dist/tests/ipythonMode.test.js.map +1 -1
  126. package/dist/tests/localizer.test.js +2 -2
  127. package/dist/tests/localizer.test.js.map +1 -1
  128. package/dist/tests/typeEvaluator1.test.js +3 -3
  129. package/dist/tests/typeEvaluator2.test.js +8 -4
  130. package/dist/tests/typeEvaluator2.test.js.map +1 -1
  131. package/dist/tests/typeEvaluator3.test.js +18 -6
  132. package/dist/tests/typeEvaluator3.test.js.map +1 -1
  133. package/dist/tests/typeEvaluator4.test.js +2 -2
  134. package/dist/tests/typeEvaluator5.test.js +4 -0
  135. package/dist/tests/typeEvaluator5.test.js.map +1 -1
  136. package/dist/tests/uri.test.js +65 -8
  137. package/dist/tests/uri.test.js.map +1 -1
  138. package/dist/workspaceFactory.d.ts +1 -0
  139. package/dist/workspaceFactory.js +1 -0
  140. package/dist/workspaceFactory.js.map +1 -1
  141. package/package.json +1 -1
@@ -54,6 +54,7 @@ const constructors_1 = require("./constructors");
54
54
  const declaration_1 = require("./declaration");
55
55
  const declarationUtils_1 = require("./declarationUtils");
56
56
  const deprecatedSymbols_1 = require("./deprecatedSymbols");
57
+ const enums_1 = require("./enums");
57
58
  const importResolver_1 = require("./importResolver");
58
59
  const importStatementUtils_1 = require("./importStatementUtils");
59
60
  const parameterUtils_1 = require("./parameterUtils");
@@ -102,7 +103,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
102
103
  console.log(`Code complexity of module ${this._fileInfo.fileUri.toUserVisibleString()} is ${codeComplexity.toString()}`);
103
104
  }
104
105
  if (codeComplexity > typeEvaluator_1.maxCodeComplexity) {
105
- this._evaluator.addDiagnosticForTextRange(this._fileInfo, this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.codeTooComplexToAnalyze(), { start: 0, length: 0 });
106
+ this._evaluator.addDiagnosticForTextRange(this._fileInfo, this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.codeTooComplexToAnalyze(), { start: 0, length: 0 });
106
107
  }
107
108
  this._walkStatementsAndReportUnreachable(this._moduleNode.statements);
108
109
  // Mark symbols accessed by __all__ as accessed.
@@ -162,7 +163,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
162
163
  !types_1.ClassType.isBuiltIn(baseClassType, 'Protocol') &&
163
164
  !types_1.ClassType.isBuiltIn(baseClassType, 'Generic')) {
164
165
  if (!types_1.ClassType.isProtocolClass(baseClassType)) {
165
- this._evaluator.addError(localize_1.Localizer.Diagnostic.protocolBaseClass().format({
166
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.protocolBaseClass().format({
166
167
  classType: classTypeResult.classType.details.name,
167
168
  baseType: baseClassType.details.name,
168
169
  }), arg.valueExpression);
@@ -188,8 +189,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
188
189
  this._validateInstanceVariableInitialization(node, classTypeResult.classType);
189
190
  this._validateFinalClassNotAbstract(classTypeResult.classType, node);
190
191
  this._validateDataClassPostInit(classTypeResult.classType, node);
191
- this._validateProtocolCompatibility(classTypeResult.classType, node);
192
- this._reportDuplicateEnumMembers(classTypeResult.classType);
192
+ this._validateEnumMembers(classTypeResult.classType, node);
193
193
  if (types_1.ClassType.isTypedDictClass(classTypeResult.classType)) {
194
194
  this._validateTypedDictClassSuite(node.suite);
195
195
  }
@@ -208,7 +208,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
208
208
  }
209
209
  if (!this._fileInfo.diagnosticRuleSet.analyzeUnannotatedFunctions && !this._fileInfo.isStubFile) {
210
210
  if (ParseTreeUtils.isUnannotatedFunction(node)) {
211
- this._evaluator.addInformation(localize_1.Localizer.Diagnostic.unannotatedFunctionSkipped().format({ name: node.name.value }), node.name);
211
+ this._evaluator.addInformation(localize_1.LocMessage.unannotatedFunctionSkipped().format({ name: node.name.value }), node.name);
212
212
  }
213
213
  }
214
214
  const functionTypeResult = this._evaluator.getTypeOfFunction(node);
@@ -242,7 +242,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
242
242
  }
243
243
  }
244
244
  if (param.name && param.category === 0 /* ParameterCategory.Simple */ && sawParamSpecArgs) {
245
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.namedParamAfterParamSpecArgs().format({ name: param.name.value }), param.name);
245
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.namedParamAfterParamSpecArgs().format({ name: param.name.value }), param.name);
246
246
  }
247
247
  // Allow unknown and missing param types if the param is named '_'.
248
248
  if (param.name && param.name.value !== '_') {
@@ -254,14 +254,14 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
254
254
  ((0, types_1.isTypeVar)(paramType) &&
255
255
  paramType.details.isSynthesized &&
256
256
  !paramType.details.isSynthesizedSelf)) {
257
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnknownParameterType, diagnosticRules_1.DiagnosticRule.reportUnknownParameterType, localize_1.Localizer.Diagnostic.paramTypeUnknown().format({ paramName: param.name.value }), param.name);
257
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnknownParameterType, localize_1.LocMessage.paramTypeUnknown().format({ paramName: param.name.value }), param.name);
258
258
  }
259
259
  else if ((0, typeUtils_1.isPartlyUnknown)(paramType)) {
260
260
  const diagAddendum = new diagnostic_1.DiagnosticAddendum();
261
- diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.paramType().format({
261
+ diagAddendum.addMessage(localize_1.LocAddendum.paramType().format({
262
262
  paramType: this._evaluator.printType(paramType, { expandTypeAlias: true }),
263
263
  }));
264
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnknownParameterType, diagnosticRules_1.DiagnosticRule.reportUnknownParameterType, localize_1.Localizer.Diagnostic.paramTypePartiallyUnknown().format({
264
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnknownParameterType, localize_1.LocMessage.paramTypePartiallyUnknown().format({
265
265
  paramName: param.name.value,
266
266
  }) + diagAddendum.getString(), param.name);
267
267
  }
@@ -277,7 +277,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
277
277
  }
278
278
  }
279
279
  if (!hasAnnotation && this._fileInfo.diagnosticRuleSet.reportMissingParameterType !== 'none') {
280
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportMissingParameterType, diagnosticRules_1.DiagnosticRule.reportMissingParameterType, localize_1.Localizer.Diagnostic.paramAnnotationMissing().format({ name: param.name.value }), param.name);
280
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportMissingParameterType, localize_1.LocMessage.paramAnnotationMissing().format({ name: param.name.value }), param.name);
281
281
  }
282
282
  }
283
283
  }
@@ -294,7 +294,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
294
294
  }
295
295
  });
296
296
  if (overlappingEntries.size > 0) {
297
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.overlappingKeywordArgs().format({
297
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.overlappingKeywordArgs().format({
298
298
  names: [...overlappingEntries.values()].join(', '),
299
299
  }), (_a = node.parameters[kwargsIndex].typeAnnotation) !== null && _a !== void 0 ? _a : node.parameters[kwargsIndex]);
300
300
  }
@@ -310,13 +310,13 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
310
310
  return false;
311
311
  });
312
312
  if (paramSpecParams.length === 1 && paramSpecParams[0].typeAnnotation) {
313
- this._evaluator.addError(localize_1.Localizer.Diagnostic.paramSpecArgsKwargsUsage(), paramSpecParams[0].typeAnnotation);
313
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.paramSpecArgsKwargsUsage(), paramSpecParams[0].typeAnnotation);
314
314
  }
315
315
  // If this is a stub, ensure that the return type is specified.
316
316
  if (this._fileInfo.isStubFile) {
317
317
  const returnAnnotation = node.returnTypeAnnotation || ((_b = node.functionAnnotationComment) === null || _b === void 0 ? void 0 : _b.returnTypeAnnotation);
318
318
  if (!returnAnnotation) {
319
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnknownParameterType, diagnosticRules_1.DiagnosticRule.reportUnknownParameterType, localize_1.Localizer.Diagnostic.returnTypeUnknown(), node.name);
319
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnknownParameterType, localize_1.LocMessage.returnTypeUnknown(), node.name);
320
320
  }
321
321
  }
322
322
  if (containingClassNode) {
@@ -344,7 +344,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
344
344
  paramType.details.declaredVariance === 3 /* Variance.Covariant */ &&
345
345
  !paramType.details.isSynthesized &&
346
346
  !exemptMethods.some((name) => name === functionTypeResult.functionType.details.name)) {
347
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.paramTypeCovariant(), annotationNode);
347
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.paramTypeCovariant(), annotationNode);
348
348
  }
349
349
  }
350
350
  }
@@ -356,7 +356,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
356
356
  this.walk(node.functionAnnotationComment);
357
357
  if (this._fileInfo.diagnosticRuleSet.reportTypeCommentUsage !== 'none' &&
358
358
  this._fileInfo.executionEnvironment.pythonVersion >= pythonVersion_1.PythonVersion.V3_5) {
359
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportTypeCommentUsage, diagnosticRules_1.DiagnosticRule.reportTypeCommentUsage, localize_1.Localizer.Diagnostic.typeCommentDeprecated(), node.functionAnnotationComment);
359
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportTypeCommentUsage, localize_1.LocMessage.typeCommentDeprecated(), node.functionAnnotationComment);
360
360
  }
361
361
  }
362
362
  this.walkMultiple(node.decorators);
@@ -371,7 +371,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
371
371
  console.log(`Code complexity of function ${node.name.value} is ${codeComplexity.toString()}`);
372
372
  }
373
373
  if (isTooComplexToAnalyze) {
374
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.codeTooComplexToAnalyze(), node.name);
374
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.codeTooComplexToAnalyze(), node.name);
375
375
  }
376
376
  else {
377
377
  this.walk(node.suite);
@@ -390,7 +390,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
390
390
  this._reportDeprecatedClassProperty(node, functionTypeResult);
391
391
  // If this is not a method, @final is disallowed.
392
392
  if (!containingClassNode && types_1.FunctionType.isFinal(functionTypeResult.functionType)) {
393
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.finalNonMethod().format({ name: node.name.value }), node.name);
393
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.finalNonMethod().format({ name: node.name.value }), node.name);
394
394
  }
395
395
  }
396
396
  // If we're at the module level within a stub file, report a diagnostic
@@ -399,7 +399,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
399
399
  if (this._fileInfo.isStubFile && node.name.value === '__getattr__') {
400
400
  const scope = (0, scopeUtils_1.getScopeForNode)(node);
401
401
  if ((scope === null || scope === void 0 ? void 0 : scope.type) === 3 /* ScopeType.Module */) {
402
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportIncompleteStub, diagnosticRules_1.DiagnosticRule.reportIncompleteStub, localize_1.Localizer.Diagnostic.stubUsesGetAttr(), node.name);
402
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportIncompleteStub, localize_1.LocMessage.stubUsesGetAttr(), node.name);
403
403
  }
404
404
  }
405
405
  this._scopedNodes.push(node);
@@ -432,10 +432,10 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
432
432
  const paramType = this._evaluator.getType(param.name);
433
433
  if (paramType) {
434
434
  if ((0, types_1.isUnknown)(paramType)) {
435
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnknownLambdaType, diagnosticRules_1.DiagnosticRule.reportUnknownLambdaType, localize_1.Localizer.Diagnostic.paramTypeUnknown().format({ paramName: param.name.value }), param.name);
435
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnknownLambdaType, localize_1.LocMessage.paramTypeUnknown().format({ paramName: param.name.value }), param.name);
436
436
  }
437
437
  else if ((0, typeUtils_1.isPartlyUnknown)(paramType)) {
438
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnknownLambdaType, diagnosticRules_1.DiagnosticRule.reportUnknownLambdaType, localize_1.Localizer.Diagnostic.paramTypePartiallyUnknown().format({ paramName: param.name.value }), param.name);
438
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnknownLambdaType, localize_1.LocMessage.paramTypePartiallyUnknown().format({ paramName: param.name.value }), param.name);
439
439
  }
440
440
  }
441
441
  }
@@ -443,10 +443,10 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
443
443
  const returnType = this._evaluator.getType(node.expression);
444
444
  if (returnType) {
445
445
  if ((0, types_1.isUnknown)(returnType)) {
446
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnknownLambdaType, diagnosticRules_1.DiagnosticRule.reportUnknownLambdaType, localize_1.Localizer.Diagnostic.lambdaReturnTypeUnknown(), node.expression);
446
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnknownLambdaType, localize_1.LocMessage.lambdaReturnTypeUnknown(), node.expression);
447
447
  }
448
448
  else if ((0, typeUtils_1.isPartlyUnknown)(returnType)) {
449
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnknownLambdaType, diagnosticRules_1.DiagnosticRule.reportUnknownLambdaType, localize_1.Localizer.Diagnostic.lambdaReturnTypePartiallyUnknown().format({
449
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnknownLambdaType, localize_1.LocMessage.lambdaReturnTypePartiallyUnknown().format({
450
450
  returnType: this._evaluator.printType(returnType, { expandTypeAlias: true }),
451
451
  }), node.expression);
452
452
  }
@@ -465,11 +465,11 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
465
465
  const isRevealTypeCall = node.leftExpression.nodeType === 38 /* ParseNodeType.Name */ && node.leftExpression.value === 'reveal_type';
466
466
  const returnType = this._evaluator.getType(node);
467
467
  if (!isRevealTypeCall && returnType && this._isTypeValidForUnusedValueTest(returnType)) {
468
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnusedCallResult, diagnosticRules_1.DiagnosticRule.reportUnusedCallResult, localize_1.Localizer.Diagnostic.unusedCallResult().format({
468
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnusedCallResult, localize_1.LocMessage.unusedCallResult().format({
469
469
  type: this._evaluator.printType(returnType),
470
470
  }), node);
471
471
  if ((0, types_1.isClassInstance)(returnType) && types_1.ClassType.isBuiltIn(returnType, 'Coroutine')) {
472
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnusedCoroutine, diagnosticRules_1.DiagnosticRule.reportUnusedCoroutine, localize_1.Localizer.Diagnostic.unusedCoroutine(), node);
472
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnusedCoroutine, localize_1.LocMessage.unusedCoroutine(), node);
473
473
  }
474
474
  }
475
475
  }
@@ -483,7 +483,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
483
483
  node.expression.nodeType === 9 /* ParseNodeType.Call */) {
484
484
  const returnType = this._evaluator.getType(node);
485
485
  if (returnType && this._isTypeValidForUnusedValueTest(returnType)) {
486
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnusedCallResult, diagnosticRules_1.DiagnosticRule.reportUnusedCallResult, localize_1.Localizer.Diagnostic.unusedCallResult().format({
486
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnusedCallResult, localize_1.LocMessage.unusedCallResult().format({
487
487
  type: this._evaluator.printType(returnType),
488
488
  }), node);
489
489
  }
@@ -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.Localizer.Diagnostic.annotationNotSupported(), node.typeComment);
497
+ this._evaluator.addDiagnosticForTextRange(this._fileInfo, this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.annotationNotSupported(), node.typeComment);
498
498
  }
499
499
  return true;
500
500
  }
@@ -534,13 +534,14 @@ 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.Localizer.Diagnostic.annotationNotSupported(), node.typeComment);
537
+ this._evaluator.addDiagnosticForTextRange(this._fileInfo, this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.annotationNotSupported(), node.typeComment);
538
538
  }
539
539
  return true;
540
540
  }
541
541
  visitReturn(node) {
542
542
  var _a, _b, _c, _d, _e;
543
543
  let returnTypeResult;
544
+ let returnType;
544
545
  const enclosingFunctionNode = ParseTreeUtils.getEnclosingFunction(node);
545
546
  const declaredReturnType = enclosingFunctionNode
546
547
  ? this._evaluator.getFunctionDeclaredReturnType(enclosingFunctionNode)
@@ -552,24 +553,29 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
552
553
  // There is no return expression, so "None" is assumed.
553
554
  returnTypeResult = { type: this._evaluator.getNoneType() };
554
555
  }
556
+ returnType = returnTypeResult.type;
557
+ // If this type is a special form, use the special form instead.
558
+ if (returnType.specialForm) {
559
+ returnType = returnType.specialForm;
560
+ }
555
561
  // If the enclosing function is async and a generator, the return
556
562
  // statement is not allowed to have an argument. A syntax error occurs
557
563
  // at runtime in this case.
558
564
  if ((enclosingFunctionNode === null || enclosingFunctionNode === void 0 ? void 0 : enclosingFunctionNode.isAsync) && node.returnExpression) {
559
565
  const functionDecl = AnalyzerNodeInfo.getDeclaration(enclosingFunctionNode);
560
566
  if ((functionDecl === null || functionDecl === void 0 ? void 0 : functionDecl.type) === 5 /* DeclarationType.Function */ && functionDecl.isGenerator) {
561
- this._evaluator.addError(localize_1.Localizer.Diagnostic.returnInAsyncGenerator(), node.returnExpression);
567
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.returnInAsyncGenerator(), node.returnExpression);
562
568
  }
563
569
  }
564
570
  if (this._evaluator.isNodeReachable(node, /* sourceNode */ undefined) && enclosingFunctionNode) {
565
571
  if (declaredReturnType) {
566
572
  if ((0, types_1.isNever)(declaredReturnType)) {
567
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.noReturnContainsReturn(), node);
573
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.noReturnContainsReturn(), node);
568
574
  }
569
575
  else {
570
576
  let diagAddendum = new diagnostic_1.DiagnosticAddendum();
571
577
  let returnTypeMatches = false;
572
- if (this._evaluator.assignType(declaredReturnType, returnTypeResult.type, diagAddendum, new typeVarContext_1.TypeVarContext(),
578
+ if (this._evaluator.assignType(declaredReturnType, returnType, diagAddendum, new typeVarContext_1.TypeVarContext(),
573
579
  /* srcTypeVarContext */ undefined, 128 /* AssignTypeFlags.AllowBoolTypeGuard */)) {
574
580
  returnTypeMatches = true;
575
581
  }
@@ -591,7 +597,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
591
597
  }
592
598
  if (!typeVarContext.isEmpty()) {
593
599
  const adjustedReturnType = (0, typeUtils_1.applySolvedTypeVars)(declaredReturnType, typeVarContext);
594
- if (this._evaluator.assignType(adjustedReturnType, returnTypeResult.type, diagAddendum,
600
+ if (this._evaluator.assignType(adjustedReturnType, returnType, diagAddendum,
595
601
  /* destTypeVarContext */ undefined,
596
602
  /* srcTypeVarContext */ undefined, 128 /* AssignTypeFlags.AllowBoolTypeGuard */)) {
597
603
  returnTypeMatches = true;
@@ -605,19 +611,19 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
605
611
  if (returnTypeResult.expectedTypeDiagAddendum) {
606
612
  diagAddendum = returnTypeResult.expectedTypeDiagAddendum;
607
613
  }
608
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.returnTypeMismatch().format({
609
- exprType: this._evaluator.printType(returnTypeResult.type),
614
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.returnTypeMismatch().format({
615
+ exprType: this._evaluator.printType(returnType),
610
616
  returnType: this._evaluator.printType(declaredReturnType),
611
617
  }) + diagAddendum.getString(), (_b = node.returnExpression) !== null && _b !== void 0 ? _b : node, (_c = returnTypeResult.expectedTypeDiagAddendum) === null || _c === void 0 ? void 0 : _c.getEffectiveTextRange());
612
618
  }
613
619
  }
614
620
  }
615
- if ((0, types_1.isUnknown)(returnTypeResult.type)) {
616
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnknownVariableType, diagnosticRules_1.DiagnosticRule.reportUnknownVariableType, localize_1.Localizer.Diagnostic.returnTypeUnknown(), (_d = node.returnExpression) !== null && _d !== void 0 ? _d : node);
621
+ if ((0, types_1.isUnknown)(returnType)) {
622
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnknownVariableType, localize_1.LocMessage.returnTypeUnknown(), (_d = node.returnExpression) !== null && _d !== void 0 ? _d : node);
617
623
  }
618
- else if ((0, typeUtils_1.isPartlyUnknown)(returnTypeResult.type)) {
619
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnknownVariableType, diagnosticRules_1.DiagnosticRule.reportUnknownVariableType, localize_1.Localizer.Diagnostic.returnTypePartiallyUnknown().format({
620
- returnType: this._evaluator.printType(returnTypeResult.type, { expandTypeAlias: true }),
624
+ else if ((0, typeUtils_1.isPartlyUnknown)(returnType)) {
625
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnknownVariableType, localize_1.LocMessage.returnTypePartiallyUnknown().format({
626
+ returnType: this._evaluator.printType(returnType, { expandTypeAlias: true }),
621
627
  }), (_e = node.returnExpression) !== null && _e !== void 0 ? _e : node);
622
628
  }
623
629
  }
@@ -672,20 +678,20 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
672
678
  if (!(0, types_1.isAnyOrUnknown)(subtype) && !(0, typeUtils_1.isNoneInstance)(subtype)) {
673
679
  if ((0, types_1.isClass)(subtype)) {
674
680
  if (!(0, typeUtils_1.derivesFromClassRecursive)(subtype, baseExceptionType, /* ignoreUnknown */ false)) {
675
- diagAddendum.addMessage(localize_1.Localizer.Diagnostic.exceptionTypeIncorrect().format({
681
+ diagAddendum.addMessage(localize_1.LocMessage.exceptionTypeIncorrect().format({
676
682
  type: this._evaluator.printType(subtype),
677
683
  }));
678
684
  }
679
685
  }
680
686
  else {
681
- diagAddendum.addMessage(localize_1.Localizer.Diagnostic.exceptionTypeIncorrect().format({
687
+ diagAddendum.addMessage(localize_1.LocMessage.exceptionTypeIncorrect().format({
682
688
  type: this._evaluator.printType(subtype),
683
689
  }));
684
690
  }
685
691
  }
686
692
  });
687
693
  if (!diagAddendum.isEmpty()) {
688
- this._evaluator.addError(localize_1.Localizer.Diagnostic.expectedExceptionObj() + diagAddendum.getString(), node.valueExpression);
694
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.expectedExceptionObj() + diagAddendum.getString(), node.valueExpression);
689
695
  }
690
696
  }
691
697
  }
@@ -714,7 +720,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
714
720
  if ((0, typeUtils_1.isTupleClass)(type) && type.tupleTypeArguments) {
715
721
  if (type.tupleTypeArguments.length > 0) {
716
722
  if (!(0, typeUtils_1.isUnboundedTupleClass)(type)) {
717
- this._evaluator.addDiagnosticForTextRange(this._fileInfo, this._fileInfo.diagnosticRuleSet.reportAssertAlwaysTrue, diagnosticRules_1.DiagnosticRule.reportAssertAlwaysTrue, localize_1.Localizer.Diagnostic.assertAlwaysTrue(), node.testExpression);
723
+ this._evaluator.addDiagnosticForTextRange(this._fileInfo, this._fileInfo.diagnosticRuleSet.reportAssertAlwaysTrue, diagnosticRules_1.DiagnosticRule.reportAssertAlwaysTrue, localize_1.LocMessage.assertAlwaysTrue(), node.testExpression);
718
724
  }
719
725
  }
720
726
  }
@@ -727,7 +733,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
727
733
  this._evaluator.getType(node.typeAnnotationComment);
728
734
  if (this._fileInfo.diagnosticRuleSet.reportTypeCommentUsage !== 'none' &&
729
735
  this._fileInfo.executionEnvironment.pythonVersion >= pythonVersion_1.PythonVersion.V3_6) {
730
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportTypeCommentUsage, diagnosticRules_1.DiagnosticRule.reportTypeCommentUsage, localize_1.Localizer.Diagnostic.typeCommentDeprecated(), node.typeAnnotationComment);
736
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportTypeCommentUsage, localize_1.LocMessage.typeCommentDeprecated(), node.typeAnnotationComment);
731
737
  }
732
738
  }
733
739
  // If this isn't a class or global scope, explicit type aliases are not allowed.
@@ -739,7 +745,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
739
745
  if (scope.type !== 2 /* ScopeType.Class */ &&
740
746
  scope.type !== 3 /* ScopeType.Module */ &&
741
747
  scope.type !== 4 /* ScopeType.Builtin */) {
742
- this._evaluator.addError(localize_1.Localizer.Diagnostic.typeAliasNotInModuleOrClass(), node.leftExpression.typeAnnotation);
748
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typeAliasNotInModuleOrClass(), node.leftExpression.typeAnnotation);
743
749
  }
744
750
  }
745
751
  }
@@ -778,7 +784,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
778
784
  typeof subscriptType.literalValue === 'number') {
779
785
  if ((subscriptType.literalValue >= 0 && subscriptType.literalValue >= tupleLength) ||
780
786
  (subscriptType.literalValue < 0 && subscriptType.literalValue + tupleLength < 0)) {
781
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.tupleIndexOutOfRange().format({
787
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.tupleIndexOutOfRange().format({
782
788
  index: subscriptType.literalValue,
783
789
  type: this._evaluator.printType(subtype),
784
790
  }), node);
@@ -865,14 +871,14 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
865
871
  }
866
872
  unescapedResult.unescapeErrors.forEach((error) => {
867
873
  if (error.errorType === 0 /* UnescapeErrorType.InvalidEscapeSequence */) {
868
- this._evaluator.addDiagnosticForTextRange(this._fileInfo, this._fileInfo.diagnosticRuleSet.reportInvalidStringEscapeSequence, diagnosticRules_1.DiagnosticRule.reportInvalidStringEscapeSequence, localize_1.Localizer.Diagnostic.stringUnsupportedEscape(), { start: start + error.offset, length: error.length });
874
+ this._evaluator.addDiagnosticForTextRange(this._fileInfo, this._fileInfo.diagnosticRuleSet.reportInvalidStringEscapeSequence, diagnosticRules_1.DiagnosticRule.reportInvalidStringEscapeSequence, localize_1.LocMessage.stringUnsupportedEscape(), { start: start + error.offset, length: error.length });
869
875
  }
870
876
  });
871
877
  // Prior to Python 3.12, it was not allowed to include a slash in an f-string.
872
878
  if (fStringContainers.length > 0) {
873
879
  const escapeOffset = token.escapedValue.indexOf('\\');
874
880
  if (escapeOffset >= 0) {
875
- this._evaluator.addDiagnosticForTextRange(this._fileInfo, 'error', '', localize_1.Localizer.Diagnostic.formatStringEscape(), { start, length: 1 });
881
+ this._evaluator.addDiagnosticForTextRange(this._fileInfo, this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.formatStringEscape(), { start, length: 1 });
876
882
  }
877
883
  }
878
884
  });
@@ -881,7 +887,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
881
887
  if (fStringContainers.length > 0) {
882
888
  const quoteTypeMask = 1 /* StringTokenFlags.SingleQuote */ | 2 /* StringTokenFlags.DoubleQuote */ | 4 /* StringTokenFlags.Triplicate */;
883
889
  if (fStringContainers.some((fStringContainer) => (fStringContainer.token.flags & quoteTypeMask) === (stringNode.token.flags & quoteTypeMask))) {
884
- this._evaluator.addError(localize_1.Localizer.Diagnostic.formatStringNestedQuote(), stringNode);
890
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.formatStringNestedQuote(), stringNode);
885
891
  }
886
892
  }
887
893
  }
@@ -889,7 +895,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
889
895
  this._evaluator.getType(node);
890
896
  }
891
897
  if (node.strings.length > 1 && !node.isParenthesized) {
892
- this._evaluator.addDiagnosticForTextRange(this._fileInfo, this._fileInfo.diagnosticRuleSet.reportImplicitStringConcatenation, diagnosticRules_1.DiagnosticRule.reportImplicitStringConcatenation, localize_1.Localizer.Diagnostic.implicitStringConcat(), node);
898
+ this._evaluator.addDiagnosticForTextRange(this._fileInfo, this._fileInfo.diagnosticRuleSet.reportImplicitStringConcatenation, diagnosticRules_1.DiagnosticRule.reportImplicitStringConcatenation, localize_1.LocMessage.implicitStringConcat(), node);
893
899
  }
894
900
  return true;
895
901
  }
@@ -964,7 +970,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
964
970
  node.module.nameParts.length === 1 &&
965
971
  node.module.nameParts[0].value === '__future__') {
966
972
  if (!ParseTreeUtils.isValidLocationForFutureImport(node)) {
967
- this._evaluator.addError(localize_1.Localizer.Diagnostic.futureImportLocationNotAllowed(), node);
973
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.futureImportLocationNotAllowed(), node);
968
974
  }
969
975
  }
970
976
  this._conditionallyReportShadowedImport(node);
@@ -980,7 +986,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
980
986
  importInfo.isImportFound &&
981
987
  importInfo.importType !== 2 /* ImportType.Local */ &&
982
988
  !this._fileInfo.isStubFile) {
983
- this._evaluator.addDiagnosticForTextRange(this._fileInfo, this._fileInfo.diagnosticRuleSet.reportWildcardImportFromLibrary, diagnosticRules_1.DiagnosticRule.reportWildcardImportFromLibrary, localize_1.Localizer.Diagnostic.wildcardLibraryImport(), node.wildcardToken || node);
989
+ this._evaluator.addDiagnosticForTextRange(this._fileInfo, this._fileInfo.diagnosticRuleSet.reportWildcardImportFromLibrary, diagnosticRules_1.DiagnosticRule.reportWildcardImportFromLibrary, localize_1.LocMessage.wildcardLibraryImport(), node.wildcardToken || node);
984
990
  }
985
991
  }
986
992
  return true;
@@ -1043,7 +1049,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1043
1049
  const scope = (0, scopeUtils_1.getScopeForNode)(node);
1044
1050
  if (scope) {
1045
1051
  if (scope.type !== 2 /* ScopeType.Class */ && scope.type !== 3 /* ScopeType.Module */ && scope.type !== 4 /* ScopeType.Builtin */) {
1046
- this._evaluator.addError(localize_1.Localizer.Diagnostic.typeAliasStatementBadScope(), node.name);
1052
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typeAliasStatementBadScope(), node.name);
1047
1053
  }
1048
1054
  }
1049
1055
  return true;
@@ -1102,7 +1108,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1102
1108
  return;
1103
1109
  }
1104
1110
  // Type stub found, but source is missing.
1105
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportMissingModuleSource, diagnosticRules_1.DiagnosticRule.reportMissingModuleSource, localize_1.Localizer.Diagnostic.importSourceResolveFailure().format({
1111
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportMissingModuleSource, localize_1.LocMessage.importSourceResolveFailure().format({
1106
1112
  importName: importResult.importName,
1107
1113
  venv: this._fileInfo.executionEnvironment.name,
1108
1114
  }), node);
@@ -1133,14 +1139,14 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1133
1139
  }
1134
1140
  // All other types are problematic.
1135
1141
  isTypeBool = false;
1136
- diag.addMessage(localize_1.Localizer.DiagnosticAddendum.conditionalRequiresBool().format({
1142
+ diag.addMessage(localize_1.LocAddendum.conditionalRequiresBool().format({
1137
1143
  operandType: this._evaluator.printType(expandedSubtype),
1138
1144
  boolReturnType: this._evaluator.printType(boolReturnType),
1139
1145
  }));
1140
1146
  return undefined;
1141
1147
  });
1142
1148
  if (!isTypeBool) {
1143
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.conditionalOperandInvalid().format({
1149
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.conditionalOperandInvalid().format({
1144
1150
  type: this._evaluator.printType(operandType),
1145
1151
  }) + diag.getString(), node);
1146
1152
  }
@@ -1172,10 +1178,10 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1172
1178
  }
1173
1179
  });
1174
1180
  if (isExprFunction) {
1175
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnnecessaryComparison, diagnosticRules_1.DiagnosticRule.reportUnnecessaryComparison, localize_1.Localizer.Diagnostic.functionInConditionalExpression(), expression);
1181
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnnecessaryComparison, localize_1.LocMessage.functionInConditionalExpression(), expression);
1176
1182
  }
1177
1183
  if (isCoroutine) {
1178
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnnecessaryComparison, diagnosticRules_1.DiagnosticRule.reportUnnecessaryComparison, localize_1.Localizer.Diagnostic.coroutineInConditionalExpression(), expression);
1184
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnnecessaryComparison, localize_1.LocMessage.coroutineInConditionalExpression(), expression);
1179
1185
  }
1180
1186
  }
1181
1187
  _reportUnusedExpression(node) {
@@ -1214,7 +1220,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1214
1220
  reportAsUnused = false;
1215
1221
  }
1216
1222
  if (reportAsUnused) {
1217
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnusedExpression, diagnosticRules_1.DiagnosticRule.reportUnusedExpression, localize_1.Localizer.Diagnostic.unusedExpression(), node);
1223
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnusedExpression, localize_1.LocMessage.unusedExpression(), node);
1218
1224
  }
1219
1225
  }
1220
1226
  _validateExhaustiveMatch(node) {
@@ -1227,11 +1233,11 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1227
1233
  });
1228
1234
  if (narrowedTypeResult && !(0, types_1.isNever)(narrowedTypeResult.type)) {
1229
1235
  const diagAddendum = new diagnostic_1.DiagnosticAddendum();
1230
- diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.matchIsNotExhaustiveType().format({
1236
+ diagAddendum.addMessage(localize_1.LocAddendum.matchIsNotExhaustiveType().format({
1231
1237
  type: this._evaluator.printType(narrowedTypeResult.type),
1232
1238
  }));
1233
- diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.matchIsNotExhaustiveHint());
1234
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportMatchNotExhaustive, diagnosticRules_1.DiagnosticRule.reportMatchNotExhaustive, localize_1.Localizer.Diagnostic.matchIsNotExhaustive() + diagAddendum.getString(), node.subjectExpression);
1239
+ diagAddendum.addMessage(localize_1.LocAddendum.matchIsNotExhaustiveHint());
1240
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportMatchNotExhaustive, localize_1.LocMessage.matchIsNotExhaustive() + diagAddendum.getString(), node.subjectExpression);
1235
1241
  }
1236
1242
  }
1237
1243
  _suppressUnboundCheck(callback) {
@@ -1247,7 +1253,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1247
1253
  _validateIllegalDefaultParamInitializer(node) {
1248
1254
  if (this._fileInfo.diagnosticRuleSet.reportCallInDefaultInitializer !== 'none') {
1249
1255
  if (ParseTreeUtils.isWithinDefaultParamInitializer(node) && !this._fileInfo.isStubFile) {
1250
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportCallInDefaultInitializer, diagnosticRules_1.DiagnosticRule.reportCallInDefaultInitializer, localize_1.Localizer.Diagnostic.defaultValueContainsCall(), node);
1256
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallInDefaultInitializer, localize_1.LocMessage.defaultValueContainsCall(), node);
1251
1257
  }
1252
1258
  }
1253
1259
  }
@@ -1260,7 +1266,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1260
1266
  leftType.aliasName) {
1261
1267
  const nonInstantiable = ['List', 'Set', 'Dict', 'Tuple'];
1262
1268
  if (nonInstantiable.some((name) => name === leftType.aliasName)) {
1263
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.collectionAliasInstantiation().format({
1269
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.collectionAliasInstantiation().format({
1264
1270
  type: leftType.aliasName,
1265
1271
  alias: leftType.details.name,
1266
1272
  }), node.leftExpression);
@@ -1285,10 +1291,10 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1285
1291
  if ((0, types_1.isNever)(narrowedType)) {
1286
1292
  const getMessage = () => {
1287
1293
  return node.operator === 41 /* OperatorType.In */
1288
- ? localize_1.Localizer.Diagnostic.containmentAlwaysFalse()
1289
- : localize_1.Localizer.Diagnostic.containmentAlwaysTrue();
1294
+ ? localize_1.LocMessage.containmentAlwaysFalse()
1295
+ : localize_1.LocMessage.containmentAlwaysTrue();
1290
1296
  };
1291
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnnecessaryContains, diagnosticRules_1.DiagnosticRule.reportUnnecessaryContains, getMessage().format({
1297
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnnecessaryContains, getMessage().format({
1292
1298
  leftType: this._evaluator.printType(leftType, { expandTypeAlias: true }),
1293
1299
  rightType: this._evaluator.printType(elementType, { expandTypeAlias: true }),
1294
1300
  }), node);
@@ -1314,11 +1320,11 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1314
1320
  });
1315
1321
  const getMessage = () => {
1316
1322
  return node.operator === 39 /* OperatorType.Is */
1317
- ? localize_1.Localizer.Diagnostic.comparisonAlwaysFalse()
1318
- : localize_1.Localizer.Diagnostic.comparisonAlwaysTrue();
1323
+ ? localize_1.LocMessage.comparisonAlwaysFalse()
1324
+ : localize_1.LocMessage.comparisonAlwaysTrue();
1319
1325
  };
1320
1326
  if (!foundMatchForNone) {
1321
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnnecessaryComparison, diagnosticRules_1.DiagnosticRule.reportUnnecessaryComparison, getMessage().format({
1327
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnnecessaryComparison, getMessage().format({
1322
1328
  leftType: this._evaluator.printType(leftType, { expandTypeAlias: true }),
1323
1329
  rightType: this._evaluator.printType(rightType),
1324
1330
  }), node);
@@ -1345,8 +1351,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1345
1351
  }
1346
1352
  const getMessage = () => {
1347
1353
  return node.operator === 12 /* OperatorType.Equals */
1348
- ? localize_1.Localizer.Diagnostic.comparisonAlwaysFalse()
1349
- : localize_1.Localizer.Diagnostic.comparisonAlwaysTrue();
1354
+ ? localize_1.LocMessage.comparisonAlwaysFalse()
1355
+ : localize_1.LocMessage.comparisonAlwaysTrue();
1350
1356
  };
1351
1357
  // Check for the special case where the LHS and RHS are both literals.
1352
1358
  if ((0, typeUtils_1.isLiteralTypeOrUnion)(rightType) && (0, typeUtils_1.isLiteralTypeOrUnion)(leftType)) {
@@ -1358,7 +1364,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1358
1364
  }
1359
1365
  });
1360
1366
  if (!isPossiblyTrue) {
1361
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnnecessaryComparison, diagnosticRules_1.DiagnosticRule.reportUnnecessaryComparison, getMessage().format({
1367
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnnecessaryComparison, getMessage().format({
1362
1368
  leftType: this._evaluator.printType(leftType, { expandTypeAlias: true }),
1363
1369
  rightType: this._evaluator.printType(rightType, { expandTypeAlias: true }),
1364
1370
  }), node);
@@ -1385,7 +1391,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1385
1391
  if (!isComparable) {
1386
1392
  const leftTypeText = this._evaluator.printType(leftType, { expandTypeAlias: true });
1387
1393
  const rightTypeText = this._evaluator.printType(rightType, { expandTypeAlias: true });
1388
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnnecessaryComparison, diagnosticRules_1.DiagnosticRule.reportUnnecessaryComparison, getMessage().format({
1394
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnnecessaryComparison, getMessage().format({
1389
1395
  leftType: leftTypeText,
1390
1396
  rightType: rightTypeText,
1391
1397
  }), node);
@@ -1505,9 +1511,9 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1505
1511
  const diagAddendum = new diagnostic_1.DiagnosticAddendum();
1506
1512
  if (!this._evaluator.assignType(declaredReturnType, specializedGenerator, diagAddendum)) {
1507
1513
  const errorMessage = node.isAsync
1508
- ? localize_1.Localizer.Diagnostic.generatorAsyncReturnType()
1509
- : localize_1.Localizer.Diagnostic.generatorSyncReturnType();
1510
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, errorMessage.format({ yieldType: this._evaluator.printType(types_1.AnyType.create()) }) +
1514
+ ? localize_1.LocMessage.generatorAsyncReturnType()
1515
+ : localize_1.LocMessage.generatorSyncReturnType();
1516
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, errorMessage.format({ yieldType: this._evaluator.printType(types_1.AnyType.create()) }) +
1511
1517
  diagAddendum.getString(), (_a = node.returnTypeAnnotation) !== null && _a !== void 0 ? _a : node.name);
1512
1518
  }
1513
1519
  }
@@ -1655,10 +1661,10 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1655
1661
  altTypeText = '"object"';
1656
1662
  }
1657
1663
  const diag = new diagnostic_1.DiagnosticAddendum();
1658
- diag.addMessage(localize_1.Localizer.DiagnosticAddendum.typeVarUnnecessarySuggestion().format({
1664
+ diag.addMessage(localize_1.LocAddendum.typeVarUnnecessarySuggestion().format({
1659
1665
  type: altTypeText,
1660
1666
  }));
1661
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportInvalidTypeVarUse, diagnosticRules_1.DiagnosticRule.reportInvalidTypeVarUse, localize_1.Localizer.Diagnostic.typeVarUsedOnlyOnce().format({
1667
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeVarUse, localize_1.LocMessage.typeVarUsedOnlyOnce().format({
1662
1668
  name: usage.nodes[0].value,
1663
1669
  }) + diag.getString(), usage.nodes[0]);
1664
1670
  }
@@ -1686,8 +1692,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1686
1692
  usage.paramTypeUsageCount === usage.paramTypeWithEllipsisUsageCount &&
1687
1693
  !skipUnsolvableTypeVarCheck) {
1688
1694
  const diag = new diagnostic_1.DiagnosticAddendum();
1689
- diag.addMessage(localize_1.Localizer.DiagnosticAddendum.typeVarUnsolvableRemedy());
1690
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportInvalidTypeVarUse, diagnosticRules_1.DiagnosticRule.reportInvalidTypeVarUse, localize_1.Localizer.Diagnostic.typeVarPossiblyUnsolvable().format({
1695
+ diag.addMessage(localize_1.LocAddendum.typeVarUnsolvableRemedy());
1696
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeVarUse, localize_1.LocMessage.typeVarPossiblyUnsolvable().format({
1691
1697
  name: usage.nodes[0].value,
1692
1698
  param: (_a = usage.paramWithEllipsis) !== null && _a !== void 0 ? _a : '',
1693
1699
  }) + diag.getString(), usage.nodes[0]);
@@ -1701,8 +1707,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1701
1707
  usage.paramTypeUsageCount === usage.paramTypeWithEllipsisUsageCount &&
1702
1708
  !usage.isExempt) {
1703
1709
  const diag = new diagnostic_1.DiagnosticAddendum();
1704
- diag.addMessage(localize_1.Localizer.DiagnosticAddendum.typeVarUnsolvableRemedy());
1705
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportInvalidTypeVarUse, diagnosticRules_1.DiagnosticRule.reportInvalidTypeVarUse, localize_1.Localizer.Diagnostic.typeVarPossiblyUnsolvable().format({
1710
+ diag.addMessage(localize_1.LocAddendum.typeVarUnsolvableRemedy());
1711
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeVarUse, localize_1.LocMessage.typeVarPossiblyUnsolvable().format({
1706
1712
  name: usage.nodes[0].value,
1707
1713
  param: (_a = usage.paramWithEllipsis) !== null && _a !== void 0 ? _a : '',
1708
1714
  }) + diag.getString(), usage.nodes[0]);
@@ -1723,12 +1729,12 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1723
1729
  }
1724
1730
  });
1725
1731
  if (staticMethodCount > 0 && staticMethodCount < functionType.overloads.length) {
1726
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.overloadStaticMethodInconsistent().format({
1732
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.overloadStaticMethodInconsistent().format({
1727
1733
  name: node.name.value,
1728
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);
1729
1735
  }
1730
1736
  if (classMethodCount > 0 && classMethodCount < functionType.overloads.length) {
1731
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.overloadClassMethodInconsistent().format({
1737
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.overloadClassMethodInconsistent().format({
1732
1738
  name: node.name.value,
1733
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);
1734
1740
  }
@@ -1738,7 +1744,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1738
1744
  for (let i = 0; i < prevOverloads.length; i++) {
1739
1745
  const prevOverload = prevOverloads[i];
1740
1746
  if (this._isOverlappingOverload(functionType, prevOverload, /* partialOverlap */ false)) {
1741
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportOverlappingOverload, diagnosticRules_1.DiagnosticRule.reportOverlappingOverload, localize_1.Localizer.Diagnostic.overlappingOverload().format({
1747
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportOverlappingOverload, localize_1.LocMessage.overlappingOverload().format({
1742
1748
  name: node.name.value,
1743
1749
  obscured: prevOverloads.length + 1,
1744
1750
  obscuredBy: i + 1,
@@ -1757,7 +1763,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1757
1763
  /* diag */ undefined, new typeVarContext_1.TypeVarContext(),
1758
1764
  /* srcTypeVarContext */ undefined, 8 /* AssignTypeFlags.SkipSolveTypeVars */ | 1024 /* AssignTypeFlags.IgnoreTypeVarScope */)) {
1759
1765
  const altNode = this._findNodeForOverload(node, prevOverload);
1760
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportOverlappingOverload, diagnosticRules_1.DiagnosticRule.reportOverlappingOverload, localize_1.Localizer.Diagnostic.overloadReturnTypeMismatch().format({
1766
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportOverlappingOverload, localize_1.LocMessage.overloadReturnTypeMismatch().format({
1761
1767
  name: node.name.value,
1762
1768
  newIndex: prevOverloads.length + 1,
1763
1769
  prevIndex: i + 1,
@@ -1816,7 +1822,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1816
1822
  const returnDiag = new diagnostic_1.DiagnosticAddendum();
1817
1823
  if (!(0, types_1.isNever)(overloadReturnType) &&
1818
1824
  !this._evaluator.assignType(implementationReturnType, overloadReturnType, returnDiag.createAddendum(), implTypeVarContext, overloadTypeVarContext, 8 /* AssignTypeFlags.SkipSolveTypeVars */)) {
1819
- returnDiag.addMessage(localize_1.Localizer.DiagnosticAddendum.functionReturnTypeMismatch().format({
1825
+ returnDiag.addMessage(localize_1.LocAddendum.functionReturnTypeMismatch().format({
1820
1826
  sourceType: this._evaluator.printType(overloadReturnType),
1821
1827
  destType: this._evaluator.printType(implementationReturnType),
1822
1828
  }));
@@ -1863,7 +1869,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1863
1869
  case 53 /* ParseNodeType.Try */:
1864
1870
  case 58 /* ParseNodeType.With */: {
1865
1871
  // These are not allowed.
1866
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportInvalidStubStatement, diagnosticRules_1.DiagnosticRule.reportInvalidStubStatement, localize_1.Localizer.Diagnostic.invalidStubStatement(), statement);
1872
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidStubStatement, localize_1.LocMessage.invalidStubStatement(), statement);
1867
1873
  break;
1868
1874
  }
1869
1875
  case 47 /* ParseNodeType.StatementList */: {
@@ -1922,7 +1928,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1922
1928
  }
1923
1929
  }
1924
1930
  if (!isValid) {
1925
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportInvalidStubStatement, diagnosticRules_1.DiagnosticRule.reportInvalidStubStatement, localize_1.Localizer.Diagnostic.invalidStubStatement(), substatement);
1931
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidStubStatement, localize_1.LocMessage.invalidStubStatement(), substatement);
1926
1932
  }
1927
1933
  }
1928
1934
  }
@@ -1945,7 +1951,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1945
1951
  else {
1946
1952
  if ((0, types_1.isInstantiableClass)(exceptionType)) {
1947
1953
  if (!derivesFromBaseException(exceptionType)) {
1948
- diagAddendum.addMessage(localize_1.Localizer.Diagnostic.exceptionTypeIncorrect().format({
1954
+ diagAddendum.addMessage(localize_1.LocMessage.exceptionTypeIncorrect().format({
1949
1955
  type: this._evaluator.printType(exceptionType),
1950
1956
  }));
1951
1957
  }
@@ -1960,13 +1966,13 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1960
1966
  }
1961
1967
  if ((0, types_1.isInstantiableClass)(subtype)) {
1962
1968
  if (!derivesFromBaseException(subtype)) {
1963
- diagAddendum.addMessage(localize_1.Localizer.Diagnostic.exceptionTypeIncorrect().format({
1969
+ diagAddendum.addMessage(localize_1.LocMessage.exceptionTypeIncorrect().format({
1964
1970
  type: this._evaluator.printType(exceptionType),
1965
1971
  }));
1966
1972
  }
1967
1973
  return types_1.ClassType.cloneAsInstance(subtype);
1968
1974
  }
1969
- diagAddendum.addMessage(localize_1.Localizer.Diagnostic.exceptionTypeIncorrect().format({
1975
+ diagAddendum.addMessage(localize_1.LocMessage.exceptionTypeIncorrect().format({
1970
1976
  type: this._evaluator.printType(exceptionType),
1971
1977
  }));
1972
1978
  return types_1.UnknownType.create();
@@ -1974,7 +1980,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1974
1980
  }
1975
1981
  }
1976
1982
  if (!diagAddendum.isEmpty()) {
1977
- this._evaluator.addError(localize_1.Localizer.Diagnostic.exceptionTypeNotClass().format({
1983
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.exceptionTypeNotClass().format({
1978
1984
  type: this._evaluator.printType(exceptionType),
1979
1985
  }), errorNode);
1980
1986
  }
@@ -1991,7 +1997,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1991
1997
  }
1992
1998
  nodes.forEach((node) => {
1993
1999
  if (!moduleScope.symbolTable.has(node.value)) {
1994
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnsupportedDunderAll, diagnosticRules_1.DiagnosticRule.reportUnsupportedDunderAll, localize_1.Localizer.Diagnostic.dunderAllSymbolNotPresent().format({ name: node.value }), node);
2000
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnsupportedDunderAll, localize_1.LocMessage.dunderAllSymbolNotPresent().format({ name: node.value }), node);
1995
2001
  }
1996
2002
  });
1997
2003
  }
@@ -2041,7 +2047,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2041
2047
  : [];
2042
2048
  if (overloadedFunctions.length === 1) {
2043
2049
  // There should never be a single overload.
2044
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.singleOverload().format({ name }), primaryDecl.node.name);
2050
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.singleOverload().format({ name }), primaryDecl.node.name);
2045
2051
  }
2046
2052
  // If the file is not a stub and this is the first overload,
2047
2053
  // verify that there is an implementation.
@@ -2073,7 +2079,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2073
2079
  // If this is a method within a protocol class, don't require that
2074
2080
  // there is an implementation.
2075
2081
  if (!exemptMissingImplementation) {
2076
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.overloadWithoutImplementation().format({
2082
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.overloadWithoutImplementation().format({
2077
2083
  name: primaryDecl.node.name.value,
2078
2084
  }), primaryDecl.node.name);
2079
2085
  }
@@ -2085,12 +2091,12 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2085
2091
  const diag = new diagnostic_1.DiagnosticAddendum();
2086
2092
  if (!this._isLegalOverloadImplementation(overload, implementationFunction, diag)) {
2087
2093
  if (implementationFunction.details.declaration) {
2088
- const diagnostic = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.overloadImplementationMismatch().format({
2094
+ const diagnostic = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.overloadImplementationMismatch().format({
2089
2095
  name,
2090
2096
  index: index + 1,
2091
2097
  }) + diag.getString(), implementationFunction.details.declaration.node.name);
2092
2098
  if (diagnostic && overload.details.declaration) {
2093
- diagnostic.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.overloadSignature(), (_b = (_a = overload.details.declaration) === null || _a === void 0 ? void 0 : _a.uri) !== null && _b !== void 0 ? _b : primaryDecl.uri, (_d = (_c = overload.details.declaration) === null || _c === void 0 ? void 0 : _c.range) !== null && _d !== void 0 ? _d : primaryDecl.range);
2099
+ diagnostic.addRelatedInfo(localize_1.LocAddendum.overloadSignature(), (_b = (_a = overload.details.declaration) === null || _a === void 0 ? void 0 : _a.uri) !== null && _b !== void 0 ? _b : primaryDecl.uri, (_d = (_c = overload.details.declaration) === null || _c === void 0 ? void 0 : _c.range) !== null && _d !== void 0 ? _d : primaryDecl.range);
2094
2100
  }
2095
2101
  }
2096
2102
  }
@@ -2110,7 +2116,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2110
2116
  decls.forEach((decl) => {
2111
2117
  if (this._evaluator.isFinalVariableDeclaration(decl)) {
2112
2118
  if (sawFinal) {
2113
- this._evaluator.addError(localize_1.Localizer.Diagnostic.finalRedeclaration().format({ name }), decl.node);
2119
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.finalRedeclaration().format({ name }), decl.node);
2114
2120
  }
2115
2121
  sawFinal = true;
2116
2122
  }
@@ -2121,7 +2127,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2121
2127
  // the assignment is within an `__init__` method, so ignore class
2122
2128
  // scopes here.
2123
2129
  if (scopeType !== 2 /* ScopeType.Class */) {
2124
- this._evaluator.addError(localize_1.Localizer.Diagnostic.finalReassigned().format({ name }), decl.node);
2130
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.finalReassigned().format({ name }), decl.node);
2125
2131
  }
2126
2132
  }
2127
2133
  sawAssignment = true;
@@ -2153,7 +2159,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2153
2159
  }
2154
2160
  }
2155
2161
  if (!isImplicitlyAssigned && !isProtocolClass) {
2156
- this._evaluator.addError(localize_1.Localizer.Diagnostic.finalUnassigned().format({ name }), firstDecl.node);
2162
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.finalUnassigned().format({ name }), firstDecl.node);
2157
2163
  }
2158
2164
  }
2159
2165
  }
@@ -2165,7 +2171,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2165
2171
  if (typeAliasDecl && decls.length > 1) {
2166
2172
  decls.forEach((decl) => {
2167
2173
  if (decl !== typeAliasDecl) {
2168
- this._evaluator.addError(localize_1.Localizer.Diagnostic.typeAliasRedeclared().format({ name }), decl.node);
2174
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typeAliasRedeclared().format({ name }), decl.node);
2169
2175
  }
2170
2176
  });
2171
2177
  }
@@ -2221,26 +2227,26 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2221
2227
  let primaryDeclInfo;
2222
2228
  if (primaryDecl.type === 5 /* DeclarationType.Function */) {
2223
2229
  if (primaryDecl.isMethod) {
2224
- primaryDeclInfo = localize_1.Localizer.DiagnosticAddendum.seeMethodDeclaration();
2230
+ primaryDeclInfo = localize_1.LocAddendum.seeMethodDeclaration();
2225
2231
  }
2226
2232
  else {
2227
- primaryDeclInfo = localize_1.Localizer.DiagnosticAddendum.seeFunctionDeclaration();
2233
+ primaryDeclInfo = localize_1.LocAddendum.seeFunctionDeclaration();
2228
2234
  }
2229
2235
  }
2230
2236
  else if (primaryDecl.type === 6 /* DeclarationType.Class */) {
2231
- primaryDeclInfo = localize_1.Localizer.DiagnosticAddendum.seeClassDeclaration();
2237
+ primaryDeclInfo = localize_1.LocAddendum.seeClassDeclaration();
2232
2238
  }
2233
2239
  else if (primaryDecl.type === 2 /* DeclarationType.Parameter */) {
2234
- primaryDeclInfo = localize_1.Localizer.DiagnosticAddendum.seeParameterDeclaration();
2240
+ primaryDeclInfo = localize_1.LocAddendum.seeParameterDeclaration();
2235
2241
  }
2236
2242
  else if (primaryDecl.type === 1 /* DeclarationType.Variable */) {
2237
- primaryDeclInfo = localize_1.Localizer.DiagnosticAddendum.seeVariableDeclaration();
2243
+ primaryDeclInfo = localize_1.LocAddendum.seeVariableDeclaration();
2238
2244
  }
2239
2245
  else if (primaryDecl.type === 4 /* DeclarationType.TypeAlias */) {
2240
- primaryDeclInfo = localize_1.Localizer.DiagnosticAddendum.seeTypeAliasDeclaration();
2246
+ primaryDeclInfo = localize_1.LocAddendum.seeTypeAliasDeclaration();
2241
2247
  }
2242
2248
  else {
2243
- primaryDeclInfo = localize_1.Localizer.DiagnosticAddendum.seeDeclaration();
2249
+ primaryDeclInfo = localize_1.LocAddendum.seeDeclaration();
2244
2250
  }
2245
2251
  const addPrimaryDeclInfo = (diag) => {
2246
2252
  if (diag) {
@@ -2273,7 +2279,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2273
2279
  duplicateIsOk = true;
2274
2280
  }
2275
2281
  if (!duplicateIsOk) {
2276
- const diag = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.obscuredClassDeclaration().format({ name }), otherDecl.node.name);
2282
+ const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.obscuredClassDeclaration().format({ name }), otherDecl.node.name);
2277
2283
  addPrimaryDeclInfo(diag);
2278
2284
  }
2279
2285
  }
@@ -2306,9 +2312,9 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2306
2312
  duplicateIsOk = true;
2307
2313
  }
2308
2314
  if (!duplicateIsOk) {
2309
- const diag = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, otherDecl.isMethod
2310
- ? localize_1.Localizer.Diagnostic.obscuredMethodDeclaration().format({ name })
2311
- : localize_1.Localizer.Diagnostic.obscuredFunctionDeclaration().format({ name }), otherDecl.node.name);
2315
+ const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, otherDecl.isMethod
2316
+ ? localize_1.LocMessage.obscuredMethodDeclaration().format({ name })
2317
+ : localize_1.LocMessage.obscuredFunctionDeclaration().format({ name }), otherDecl.node.name);
2312
2318
  addPrimaryDeclInfo(diag);
2313
2319
  }
2314
2320
  }
@@ -2321,8 +2327,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2321
2327
  duplicateIsOk = true;
2322
2328
  }
2323
2329
  if (!duplicateIsOk) {
2324
- const message = localize_1.Localizer.Diagnostic.obscuredParameterDeclaration();
2325
- const diag = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, message.format({ name }), otherDecl.node.name);
2330
+ const message = localize_1.LocMessage.obscuredParameterDeclaration();
2331
+ const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, message.format({ name }), otherDecl.node.name);
2326
2332
  addPrimaryDeclInfo(diag);
2327
2333
  }
2328
2334
  }
@@ -2343,14 +2349,14 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2343
2349
  duplicateIsOk = true;
2344
2350
  }
2345
2351
  if (!duplicateIsOk) {
2346
- const diag = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.obscuredVariableDeclaration().format({ name }), otherDecl.node);
2352
+ const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.obscuredVariableDeclaration().format({ name }), otherDecl.node);
2347
2353
  addPrimaryDeclInfo(diag);
2348
2354
  }
2349
2355
  }
2350
2356
  }
2351
2357
  }
2352
2358
  else if (otherDecl.type === 4 /* DeclarationType.TypeAlias */) {
2353
- const diag = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.obscuredTypeAliasDeclaration().format({ name }), otherDecl.node.name);
2359
+ const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.obscuredTypeAliasDeclaration().format({ name }), otherDecl.node.name);
2354
2360
  addPrimaryDeclInfo(diag);
2355
2361
  }
2356
2362
  }
@@ -2404,8 +2410,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2404
2410
  const multipartName = nameParts.map((np) => np.value).join('.');
2405
2411
  let textRange = { start: nameParts[0].start, length: nameParts[0].length };
2406
2412
  textRange = textRange_1.TextRange.extend(textRange, nameParts[nameParts.length - 1]);
2407
- this._fileInfo.diagnosticSink.addUnusedCodeWithTextRange(localize_1.Localizer.Diagnostic.unaccessedSymbol().format({ name: multipartName }), textRange, { action: "pyright.unusedImport" /* Commands.unusedImport */ });
2408
- this._evaluator.addDiagnosticForTextRange(this._fileInfo, this._fileInfo.diagnosticRuleSet.reportUnusedImport, diagnosticRules_1.DiagnosticRule.reportUnusedImport, localize_1.Localizer.Diagnostic.unaccessedImport().format({ name: multipartName }), textRange);
2413
+ this._fileInfo.diagnosticSink.addUnusedCodeWithTextRange(localize_1.LocMessage.unaccessedSymbol().format({ name: multipartName }), textRange, { action: "pyright.unusedImport" /* Commands.unusedImport */ });
2414
+ this._evaluator.addDiagnosticForTextRange(this._fileInfo, this._fileInfo.diagnosticRuleSet.reportUnusedImport, diagnosticRules_1.DiagnosticRule.reportUnusedImport, localize_1.LocMessage.unaccessedImport().format({ name: multipartName }), textRange);
2409
2415
  return;
2410
2416
  }
2411
2417
  }
@@ -2423,7 +2429,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2423
2429
  }
2424
2430
  }
2425
2431
  if (nameNode) {
2426
- message = localize_1.Localizer.Diagnostic.unaccessedImport().format({ name: nameNode.value });
2432
+ message = localize_1.LocMessage.unaccessedImport().format({ name: nameNode.value });
2427
2433
  }
2428
2434
  break;
2429
2435
  case 4 /* DeclarationType.TypeAlias */:
@@ -2453,7 +2459,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2453
2459
  }
2454
2460
  if (nameNode) {
2455
2461
  rule = diagnosticRules_1.DiagnosticRule.reportUnusedVariable;
2456
- message = localize_1.Localizer.Diagnostic.unaccessedVariable().format({ name: nameNode.value });
2462
+ message = localize_1.LocMessage.unaccessedVariable().format({ name: nameNode.value });
2457
2463
  }
2458
2464
  break;
2459
2465
  case 6 /* DeclarationType.Class */:
@@ -2468,7 +2474,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2468
2474
  diagnosticLevel = this._fileInfo.diagnosticRuleSet.reportUnusedClass;
2469
2475
  nameNode = decl.node.name;
2470
2476
  rule = diagnosticRules_1.DiagnosticRule.reportUnusedClass;
2471
- message = localize_1.Localizer.Diagnostic.unaccessedClass().format({ name: nameNode.value });
2477
+ message = localize_1.LocMessage.unaccessedClass().format({ name: nameNode.value });
2472
2478
  break;
2473
2479
  case 5 /* DeclarationType.Function */:
2474
2480
  if (!isPrivate) {
@@ -2482,7 +2488,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2482
2488
  diagnosticLevel = this._fileInfo.diagnosticRuleSet.reportUnusedFunction;
2483
2489
  nameNode = decl.node.name;
2484
2490
  rule = diagnosticRules_1.DiagnosticRule.reportUnusedFunction;
2485
- message = localize_1.Localizer.Diagnostic.unaccessedFunction().format({ name: nameNode.value });
2491
+ message = localize_1.LocMessage.unaccessedFunction().format({ name: nameNode.value });
2486
2492
  break;
2487
2493
  case 3 /* DeclarationType.TypeParameter */:
2488
2494
  // Never report a diagnostic for an unused TypeParameter.
@@ -2497,9 +2503,9 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2497
2503
  }
2498
2504
  const action = rule === diagnosticRules_1.DiagnosticRule.reportUnusedImport ? { action: "pyright.unusedImport" /* Commands.unusedImport */ } : undefined;
2499
2505
  if (nameNode) {
2500
- this._fileInfo.diagnosticSink.addUnusedCodeWithTextRange(localize_1.Localizer.Diagnostic.unaccessedSymbol().format({ name: nameNode.value }), nameNode, action);
2501
- if (rule !== undefined && message) {
2502
- this._evaluator.addDiagnostic(diagnosticLevel, rule, message, nameNode);
2506
+ this._fileInfo.diagnosticSink.addUnusedCodeWithTextRange(localize_1.LocMessage.unaccessedSymbol().format({ name: nameNode.value }), nameNode, action);
2507
+ if (rule !== undefined && message && diagnosticLevel !== 'none') {
2508
+ this._evaluator.addDiagnostic(rule, message, nameNode);
2503
2509
  }
2504
2510
  }
2505
2511
  }
@@ -2541,11 +2547,11 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2541
2547
  }
2542
2548
  });
2543
2549
  if (!isValidType) {
2544
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, isInstanceCheck
2545
- ? localize_1.Localizer.Diagnostic.isInstanceInvalidType().format({
2550
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, isInstanceCheck
2551
+ ? localize_1.LocMessage.isInstanceInvalidType().format({
2546
2552
  type: this._evaluator.printType(arg1Type),
2547
2553
  }) + diag.getString()
2548
- : localize_1.Localizer.Diagnostic.isSubclassInvalidType().format({
2554
+ : localize_1.LocMessage.isSubclassInvalidType().format({
2549
2555
  type: this._evaluator.printType(arg1Type),
2550
2556
  }) + diag.getString(), node.arguments[1]);
2551
2557
  }
@@ -2566,7 +2572,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2566
2572
  }
2567
2573
  });
2568
2574
  if (!diag.isEmpty()) {
2569
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.dataProtocolInSubclassCheck(), node.arguments[1]);
2575
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.dataProtocolInSubclassCheck(), node.arguments[1]);
2570
2576
  }
2571
2577
  }
2572
2578
  // If this call is within an assert statement, we won't check whether
@@ -2724,12 +2730,12 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2724
2730
  // If arg1IncludesSubclasses is true, it contains a Type[X] class rather than X. A Type[X]
2725
2731
  // could be a subclass of X, so the "unnecessary isinstance check" may be legit.
2726
2732
  if (!arg1IncludesSubclasses && (0, types_1.isTypeSame)(filteredType, arg0Type, { ignorePseudoGeneric: true })) {
2727
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnnecessaryIsInstance, diagnosticRules_1.DiagnosticRule.reportUnnecessaryIsInstance, isInstanceCheck
2728
- ? localize_1.Localizer.Diagnostic.unnecessaryIsInstanceAlways().format({
2733
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnnecessaryIsInstance, isInstanceCheck
2734
+ ? localize_1.LocMessage.unnecessaryIsInstanceAlways().format({
2729
2735
  testType: this._evaluator.printType(arg0Type),
2730
2736
  classType: this._evaluator.printType(getTestType()),
2731
2737
  })
2732
- : localize_1.Localizer.Diagnostic.unnecessaryIsSubclassAlways().format({
2738
+ : localize_1.LocMessage.unnecessaryIsSubclassAlways().format({
2733
2739
  testType: this._evaluator.printType(arg0Type),
2734
2740
  classType: this._evaluator.printType(getTestType()),
2735
2741
  }), node);
@@ -2745,14 +2751,14 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2745
2751
  if ((0, types_1.isClassInstance)(testSubtype)) {
2746
2752
  if ((0, protocols_1.isProtocolUnsafeOverlap)(this._evaluator, protocol, testSubtype)) {
2747
2753
  isUnsafeOverlap = true;
2748
- diag.addMessage(localize_1.Localizer.DiagnosticAddendum.protocolUnsafeOverlap().format({
2754
+ diag.addMessage(localize_1.LocAddendum.protocolUnsafeOverlap().format({
2749
2755
  name: testSubtype.details.name,
2750
2756
  }));
2751
2757
  }
2752
2758
  }
2753
2759
  });
2754
2760
  if (isUnsafeOverlap) {
2755
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.protocolUnsafeOverlap().format({
2761
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.protocolUnsafeOverlap().format({
2756
2762
  name: protocol.details.name,
2757
2763
  }) + diag.getString(), errorNode);
2758
2764
  }
@@ -2766,7 +2772,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2766
2772
  subtype = this._evaluator.makeTopLevelTypeVarsConcrete(subtype);
2767
2773
  subtype = (0, typeUtils_1.transformPossibleRecursiveTypeAlias)(subtype);
2768
2774
  if (subtype.specialForm && types_1.ClassType.isBuiltIn(subtype.specialForm, 'TypeAliasType')) {
2769
- diag.addMessage(localize_1.Localizer.DiagnosticAddendum.typeAliasInstanceCheck());
2775
+ diag.addMessage(localize_1.LocAddendum.typeAliasInstanceCheck());
2770
2776
  isSupported = false;
2771
2777
  return;
2772
2778
  }
@@ -2777,17 +2783,17 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2777
2783
  break;
2778
2784
  case 6 /* TypeCategory.Class */:
2779
2785
  if ((0, typeUtils_1.isNoneInstance)(subtype)) {
2780
- diag.addMessage(localize_1.Localizer.DiagnosticAddendum.noneNotAllowed());
2786
+ diag.addMessage(localize_1.LocAddendum.noneNotAllowed());
2781
2787
  isSupported = false;
2782
2788
  }
2783
2789
  else if (types_1.ClassType.isTypedDictClass(subtype)) {
2784
- diag.addMessage(localize_1.Localizer.DiagnosticAddendum.typedDictClassNotAllowed());
2790
+ diag.addMessage(localize_1.LocAddendum.typedDictClassNotAllowed());
2785
2791
  isSupported = false;
2786
2792
  }
2787
2793
  else if (subtype.isTypeArgumentExplicit && !subtype.includeSubclasses) {
2788
2794
  // If it's a class, make sure that it has not been given explicit
2789
2795
  // type arguments. This will result in a TypeError exception.
2790
- diag.addMessage(localize_1.Localizer.DiagnosticAddendum.genericClassNotAllowed());
2796
+ diag.addMessage(localize_1.LocAddendum.genericClassNotAllowed());
2791
2797
  isSupported = false;
2792
2798
  }
2793
2799
  else if (types_1.ClassType.isProtocolClass(subtype) &&
@@ -2796,22 +2802,22 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2796
2802
  // According to PEP 544, protocol classes cannot be used as the right-hand
2797
2803
  // argument to isinstance or issubclass unless they are annotated as
2798
2804
  // "runtime checkable".
2799
- diag.addMessage(localize_1.Localizer.DiagnosticAddendum.protocolRequiresRuntimeCheckable());
2805
+ diag.addMessage(localize_1.LocAddendum.protocolRequiresRuntimeCheckable());
2800
2806
  isSupported = false;
2801
2807
  }
2802
2808
  else if (types_1.ClassType.isNewTypeClass(subtype)) {
2803
- diag.addMessage(localize_1.Localizer.DiagnosticAddendum.newTypeClassNotAllowed());
2809
+ diag.addMessage(localize_1.LocAddendum.newTypeClassNotAllowed());
2804
2810
  isSupported = false;
2805
2811
  }
2806
2812
  break;
2807
2813
  case 4 /* TypeCategory.Function */:
2808
2814
  if (!types_1.TypeBase.isInstantiable(subtype) || subtype.isCallableWithTypeArgs) {
2809
- diag.addMessage(localize_1.Localizer.DiagnosticAddendum.genericClassNotAllowed());
2815
+ diag.addMessage(localize_1.LocAddendum.genericClassNotAllowed());
2810
2816
  isSupported = false;
2811
2817
  }
2812
2818
  break;
2813
2819
  case 9 /* TypeCategory.TypeVar */:
2814
- diag.addMessage(localize_1.Localizer.DiagnosticAddendum.typeVarNotAllowed());
2820
+ diag.addMessage(localize_1.LocAddendum.typeVarNotAllowed());
2815
2821
  isSupported = false;
2816
2822
  break;
2817
2823
  }
@@ -2820,7 +2826,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2820
2826
  }
2821
2827
  _validateNotDataProtocol(type, diag) {
2822
2828
  if ((0, types_1.isInstantiableClass)(type) && types_1.ClassType.isProtocolClass(type) && !(0, protocols_1.isMethodOnlyProtocol)(type)) {
2823
- diag.addMessage(localize_1.Localizer.DiagnosticAddendum.dataProtocolUnsupported().format({
2829
+ diag.addMessage(localize_1.LocAddendum.dataProtocolUnsupported().format({
2824
2830
  name: type.details.name,
2825
2831
  }));
2826
2832
  }
@@ -2847,30 +2853,30 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2847
2853
  !types_1.ClassType.isClassProperty(functionTypeResult.decoratedType)) {
2848
2854
  return;
2849
2855
  }
2850
- this._reportDeprecatedDiagnostic(node.name, localize_1.Localizer.Diagnostic.classPropertyDeprecated());
2856
+ this._reportDeprecatedDiagnostic(node.name, localize_1.LocMessage.classPropertyDeprecated());
2851
2857
  }
2852
2858
  _reportDeprecatedUseForMemberAccess(node, info) {
2853
2859
  let errorMessage;
2854
2860
  if (info.accessType === 'property') {
2855
2861
  if (info.accessMethod === 'get') {
2856
- errorMessage = localize_1.Localizer.Diagnostic.deprecatedPropertyGetter().format({ name: node.value });
2862
+ errorMessage = localize_1.LocMessage.deprecatedPropertyGetter().format({ name: node.value });
2857
2863
  }
2858
2864
  else if (info.accessMethod === 'set') {
2859
- errorMessage = localize_1.Localizer.Diagnostic.deprecatedPropertySetter().format({ name: node.value });
2865
+ errorMessage = localize_1.LocMessage.deprecatedPropertySetter().format({ name: node.value });
2860
2866
  }
2861
2867
  else {
2862
- errorMessage = localize_1.Localizer.Diagnostic.deprecatedPropertyDeleter().format({ name: node.value });
2868
+ errorMessage = localize_1.LocMessage.deprecatedPropertyDeleter().format({ name: node.value });
2863
2869
  }
2864
2870
  }
2865
2871
  else if (info.accessType === 'descriptor') {
2866
2872
  if (info.accessMethod === 'get') {
2867
- errorMessage = localize_1.Localizer.Diagnostic.deprecatedDescriptorGetter().format({ name: node.value });
2873
+ errorMessage = localize_1.LocMessage.deprecatedDescriptorGetter().format({ name: node.value });
2868
2874
  }
2869
2875
  else if (info.accessMethod === 'set') {
2870
- errorMessage = localize_1.Localizer.Diagnostic.deprecatedDescriptorSetter().format({ name: node.value });
2876
+ errorMessage = localize_1.LocMessage.deprecatedDescriptorSetter().format({ name: node.value });
2871
2877
  }
2872
2878
  else {
2873
- errorMessage = localize_1.Localizer.Diagnostic.deprecatedDescriptorDeleter().format({ name: node.value });
2879
+ errorMessage = localize_1.LocMessage.deprecatedDescriptorDeleter().format({ name: node.value });
2874
2880
  }
2875
2881
  }
2876
2882
  if (errorMessage) {
@@ -2890,13 +2896,13 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2890
2896
  const containingClass = ParseTreeUtils.getEnclosingClass(functionType.details.declaration.node,
2891
2897
  /* stopAtFunction */ true);
2892
2898
  if (containingClass) {
2893
- return localize_1.Localizer.Diagnostic.deprecatedMethod().format({
2899
+ return localize_1.LocMessage.deprecatedMethod().format({
2894
2900
  name: functionType.details.name || '<anonymous>',
2895
2901
  className: containingClass.name.value,
2896
2902
  });
2897
2903
  }
2898
2904
  }
2899
- return localize_1.Localizer.Diagnostic.deprecatedFunction().format({
2905
+ return localize_1.LocMessage.deprecatedFunction().format({
2900
2906
  name: functionType.details.name,
2901
2907
  });
2902
2908
  }
@@ -2927,7 +2933,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2927
2933
  }
2928
2934
  else if ((0, types_1.isInstantiableClass)(type) && overload.details.name === '__init__') {
2929
2935
  deprecatedMessage = overload.details.deprecatedMessage;
2930
- errorMessage = localize_1.Localizer.Diagnostic.deprecatedConstructor().format({
2936
+ errorMessage = localize_1.LocMessage.deprecatedConstructor().format({
2931
2937
  name: type.details.name,
2932
2938
  });
2933
2939
  }
@@ -2941,7 +2947,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2941
2947
  subtype.details.deprecatedMessage !== undefined &&
2942
2948
  node.value === subtype.details.name) {
2943
2949
  deprecatedMessage = subtype.details.deprecatedMessage;
2944
- errorMessage = localize_1.Localizer.Diagnostic.deprecatedClass().format({ name: subtype.details.name });
2950
+ errorMessage = localize_1.LocMessage.deprecatedClass().format({ name: subtype.details.name });
2945
2951
  }
2946
2952
  else {
2947
2953
  // See if this is part of a call to a constructor.
@@ -2984,13 +2990,13 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2984
2990
  if (this._fileInfo.executionEnvironment.pythonVersion >= deprecatedForm.version) {
2985
2991
  if (!deprecatedForm.typingImportOnly || isImportFromTyping) {
2986
2992
  if (this._fileInfo.diagnosticRuleSet.reportDeprecated === 'none') {
2987
- this._evaluator.addDeprecated(localize_1.Localizer.Diagnostic.deprecatedType().format({
2993
+ this._evaluator.addDeprecated(localize_1.LocMessage.deprecatedType().format({
2988
2994
  version: (0, pythonVersion_1.versionToString)(deprecatedForm.version),
2989
2995
  replacement: deprecatedForm.replacementText,
2990
2996
  }), node);
2991
2997
  }
2992
2998
  else {
2993
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportDeprecated, diagnosticRules_1.DiagnosticRule.reportDeprecated, localize_1.Localizer.Diagnostic.deprecatedType().format({
2999
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportDeprecated, localize_1.LocMessage.deprecatedType().format({
2994
3000
  version: (0, pythonVersion_1.versionToString)(deprecatedForm.version),
2995
3001
  replacement: deprecatedForm.replacementText,
2996
3002
  }), node);
@@ -3010,7 +3016,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3010
3016
  this._evaluator.addDeprecated(diagnosticMessage + diag.getString(), node);
3011
3017
  }
3012
3018
  else {
3013
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportDeprecated, diagnosticRules_1.DiagnosticRule.reportDeprecated, diagnosticMessage + diag.getString(), node);
3019
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportDeprecated, diagnosticMessage + diag.getString(), node);
3014
3020
  }
3015
3021
  }
3016
3022
  _reportUnboundName(node) {
@@ -3021,10 +3027,10 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3021
3027
  const type = this._evaluator.getType(node);
3022
3028
  if (type) {
3023
3029
  if ((0, types_1.isUnbound)(type)) {
3024
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnboundVariable, diagnosticRules_1.DiagnosticRule.reportUnboundVariable, localize_1.Localizer.Diagnostic.symbolIsUnbound().format({ name: node.value }), node);
3030
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnboundVariable, localize_1.LocMessage.symbolIsUnbound().format({ name: node.value }), node);
3025
3031
  }
3026
3032
  else if ((0, types_1.isPossiblyUnbound)(type)) {
3027
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnboundVariable, diagnosticRules_1.DiagnosticRule.reportUnboundVariable, localize_1.Localizer.Diagnostic.symbolIsPossiblyUnbound().format({ name: node.value }), node);
3033
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnboundVariable, localize_1.LocMessage.symbolIsPossiblyUnbound().format({ name: node.value }), node);
3028
3034
  }
3029
3035
  }
3030
3036
  }
@@ -3045,7 +3051,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3045
3051
  this._importResolver.isStdlibModule(desc, this._fileInfo.executionEnvironment) &&
3046
3052
  this._sourceMapper.isUserCode(this._fileInfo.fileUri)) {
3047
3053
  // This means the user has a module that is overwriting the stdlib module.
3048
- const diag = this._evaluator.addDiagnosticForTextRange(this._fileInfo, this._fileInfo.diagnosticRuleSet.reportShadowedImports, diagnosticRules_1.DiagnosticRule.reportShadowedImports, localize_1.Localizer.Diagnostic.stdlibModuleOverridden().format({
3054
+ const diag = this._evaluator.addDiagnosticForTextRange(this._fileInfo, this._fileInfo.diagnosticRuleSet.reportShadowedImports, diagnosticRules_1.DiagnosticRule.reportShadowedImports, localize_1.LocMessage.stdlibModuleOverridden().format({
3049
3055
  name: moduleName,
3050
3056
  path: this._fileInfo.fileUri.toUserVisibleString(),
3051
3057
  }), this._moduleNode);
@@ -3096,7 +3102,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3096
3102
  paths.forEach((p) => {
3097
3103
  if (!p.startsWith(stdlibPath) && !(0, sourceMapper_1.isStubFile)(p) && this._sourceMapper.isUserCode(p)) {
3098
3104
  // This means the user has a module that is overwriting the stdlib module.
3099
- const diag = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportShadowedImports, diagnosticRules_1.DiagnosticRule.reportShadowedImports, localize_1.Localizer.Diagnostic.stdlibModuleOverridden().format({
3105
+ const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportShadowedImports, localize_1.LocMessage.stdlibModuleOverridden().format({
3100
3106
  name: nameParts.join('.'),
3101
3107
  path: p.toUserVisibleString(),
3102
3108
  }), node);
@@ -3200,10 +3206,10 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3200
3206
  }
3201
3207
  if (classNode && !ParseTreeUtils.isNodeContainedWithin(node, classNode)) {
3202
3208
  if (isProtectedAccess) {
3203
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportPrivateUsage, diagnosticRules_1.DiagnosticRule.reportPrivateUsage, localize_1.Localizer.Diagnostic.protectedUsedOutsideOfClass().format({ name: nameValue }), node);
3209
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportPrivateUsage, localize_1.LocMessage.protectedUsedOutsideOfClass().format({ name: nameValue }), node);
3204
3210
  }
3205
3211
  else {
3206
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportPrivateUsage, diagnosticRules_1.DiagnosticRule.reportPrivateUsage, localize_1.Localizer.Diagnostic.privateUsedOutsideOfClass().format({ name: nameValue }), node);
3212
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportPrivateUsage, localize_1.LocMessage.privateUsedOutsideOfClass().format({ name: nameValue }), node);
3207
3213
  }
3208
3214
  }
3209
3215
  }
@@ -3211,18 +3217,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3211
3217
  // enum class that has already defined values.
3212
3218
  _validateEnumClassOverride(node, classType) {
3213
3219
  classType.details.baseClasses.forEach((baseClass, index) => {
3214
- if ((0, types_1.isClass)(baseClass) && types_1.ClassType.isEnumClass(baseClass)) {
3215
- // Determine whether the base enum class defines an enumerated value.
3216
- let baseEnumDefinesValue = false;
3217
- baseClass.details.fields.forEach((symbol) => {
3218
- const symbolType = this._evaluator.getEffectiveTypeOfSymbol(symbol);
3219
- if ((0, types_1.isClassInstance)(symbolType) && types_1.ClassType.isSameGenericClass(symbolType, baseClass)) {
3220
- baseEnumDefinesValue = true;
3221
- }
3222
- });
3223
- if (baseEnumDefinesValue) {
3224
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.enumClassOverride().format({ name: baseClass.details.name }), node.arguments[index]);
3225
- }
3220
+ if ((0, types_1.isClass)(baseClass) && (0, enums_1.isEnumClassWithMembers)(this._evaluator, baseClass)) {
3221
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.enumClassOverride().format({ name: baseClass.details.name }), node.arguments[index]);
3226
3222
  }
3227
3223
  });
3228
3224
  }
@@ -3231,7 +3227,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3231
3227
  // strings, and "pass" statements or ellipses.
3232
3228
  _validateTypedDictClassSuite(suiteNode) {
3233
3229
  const emitBadStatementError = (node) => {
3234
- this._evaluator.addError(localize_1.Localizer.Diagnostic.typedDictBadVar(), node);
3230
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typedDictBadVar(), node);
3235
3231
  };
3236
3232
  suiteNode.statements.forEach((statement) => {
3237
3233
  if (!AnalyzerNodeInfo.isCodeUnreachable(statement)) {
@@ -3272,7 +3268,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3272
3268
  }
3273
3269
  }
3274
3270
  if (paramCount < 1) {
3275
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.typeGuardParamCount(), node.name);
3271
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typeGuardParamCount(), node.name);
3276
3272
  }
3277
3273
  }
3278
3274
  _validateDunderSignatures(node, functionType, isMethod) {
@@ -3284,7 +3280,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3284
3280
  const declaredReturnType = functionType.details.declaredReturnType;
3285
3281
  if (returnAnnotation && declaredReturnType) {
3286
3282
  if (!(0, typeUtils_1.isNoneInstance)(declaredReturnType) && !(0, types_1.isNever)(declaredReturnType)) {
3287
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.initMustReturnNone(), returnAnnotation);
3283
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.initMustReturnNone(), returnAnnotation);
3288
3284
  }
3289
3285
  }
3290
3286
  else {
@@ -3292,7 +3288,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3292
3288
  if (!(0, types_1.isNever)(inferredReturnType) &&
3293
3289
  !(0, typeUtils_1.isNoneInstance)(inferredReturnType) &&
3294
3290
  !(0, types_1.isAnyOrUnknown)(inferredReturnType)) {
3295
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.initMustReturnNone(), node.name);
3291
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.initMustReturnNone(), node.name);
3296
3292
  }
3297
3293
  }
3298
3294
  }
@@ -3328,7 +3324,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3328
3324
  if (!ParseTreeUtils.isSuiteEmpty(node.suite) &&
3329
3325
  !types_1.FunctionType.isOverloaded(functionType) &&
3330
3326
  !types_1.FunctionType.isAsync(functionType)) {
3331
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.noReturnReturnsNone(), returnAnnotation);
3327
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.noReturnReturnsNone(), returnAnnotation);
3332
3328
  }
3333
3329
  }
3334
3330
  else if (!types_1.FunctionType.isAbstractMethod(functionType)) {
@@ -3341,7 +3337,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3341
3337
  // an abstract method or a protocol method and don't require that
3342
3338
  // the return type matches. This check can also be skipped for an overload.
3343
3339
  if (!ParseTreeUtils.isSuiteEmpty(node.suite) && !types_1.FunctionType.isOverloaded(functionType)) {
3344
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.returnMissing().format({
3340
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.returnMissing().format({
3345
3341
  returnType: this._evaluator.printType(declaredReturnType),
3346
3342
  }) + diagAddendum.getString(), returnAnnotation);
3347
3343
  }
@@ -3358,20 +3354,22 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3358
3354
  _validateReturnTypeIsNotContravariant(returnType, errorNode) {
3359
3355
  let isContraTypeVar = false;
3360
3356
  (0, typeUtils_1.doForEachSubtype)(returnType, (subtype) => {
3361
- if ((0, types_1.isTypeVar)(subtype) && subtype.details.declaredVariance === 4 /* Variance.Contravariant */) {
3357
+ if ((0, types_1.isTypeVar)(subtype) &&
3358
+ subtype.details.declaredVariance === 4 /* Variance.Contravariant */ &&
3359
+ subtype.scopeType === 0 /* TypeVarScopeType.Class */) {
3362
3360
  isContraTypeVar = true;
3363
3361
  }
3364
3362
  });
3365
3363
  if (isContraTypeVar) {
3366
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.returnTypeContravariant(), errorNode);
3364
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.returnTypeContravariant(), errorNode);
3367
3365
  }
3368
3366
  }
3369
3367
  _reportUnknownReturnResult(node, returnType) {
3370
3368
  if ((0, types_1.isUnknown)(returnType)) {
3371
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnknownParameterType, diagnosticRules_1.DiagnosticRule.reportUnknownParameterType, localize_1.Localizer.Diagnostic.returnTypeUnknown(), node.name);
3369
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnknownParameterType, localize_1.LocMessage.returnTypeUnknown(), node.name);
3372
3370
  }
3373
3371
  else if ((0, typeUtils_1.isPartlyUnknown)(returnType)) {
3374
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnknownParameterType, diagnosticRules_1.DiagnosticRule.reportUnknownParameterType, localize_1.Localizer.Diagnostic.returnTypePartiallyUnknown().format({
3372
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnknownParameterType, localize_1.LocMessage.returnTypePartiallyUnknown().format({
3375
3373
  returnType: this._evaluator.printType(returnType, { expandTypeAlias: true }),
3376
3374
  }), node.name);
3377
3375
  }
@@ -3386,94 +3384,83 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3386
3384
  this._evaluator.isFinalVariable(parentSymbol.symbol) &&
3387
3385
  !SymbolNameUtils.isPrivateName(name)) {
3388
3386
  const decl = localSymbol.getDeclarations()[0];
3389
- this._evaluator.addError(localize_1.Localizer.Diagnostic.finalRedeclarationBySubclass().format({
3387
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.finalRedeclarationBySubclass().format({
3390
3388
  name,
3391
3389
  className: parentSymbol.classType.details.name,
3392
3390
  }), decl.node);
3393
3391
  }
3394
3392
  });
3395
3393
  }
3396
- _reportDuplicateEnumMembers(classType) {
3394
+ // Validates that the values associated with enum members are type compatible.
3395
+ // Also looks for duplicate values.
3396
+ _validateEnumMembers(classType, node) {
3397
3397
  if (!types_1.ClassType.isEnumClass(classType) || types_1.ClassType.isBuiltIn(classType)) {
3398
3398
  return;
3399
3399
  }
3400
+ // Does the "_value_" field have a declared type? If so, we'll enforce it.
3401
+ const declaredValueType = (0, enums_1.getEnumDeclaredValueType)(this._evaluator, classType, /* declaredTypesOnly */ true);
3402
+ // Is there a custom "__new__" and/or "__init__" method? If so, we'll
3403
+ // verify that the signature of these calls is compatible with the values.
3404
+ const newMemberTypeResult = (0, constructors_1.getBoundNewMethod)(this._evaluator, node.name, classType, 2 /* MemberAccessFlags.SkipBaseClasses */);
3405
+ const initMemberTypeResult = (0, constructors_1.getBoundInitMethod)(this._evaluator, node.name, types_1.ClassType.cloneAsInstance(classType), 2 /* MemberAccessFlags.SkipBaseClasses */);
3400
3406
  classType.details.fields.forEach((symbol, name) => {
3407
+ var _a;
3401
3408
  // Enum members don't have type annotations.
3402
3409
  if (symbol.getTypedDeclarations().length > 0) {
3403
3410
  return;
3404
3411
  }
3412
+ const symbolType = this._evaluator.getEffectiveTypeOfSymbol(symbol);
3413
+ // Is this symbol a literal instance of the enum class?
3414
+ if (!(0, types_1.isClassInstance)(symbolType) ||
3415
+ !types_1.ClassType.isSameGenericClass(symbolType, classType) ||
3416
+ !(symbolType.literalValue instanceof types_1.EnumLiteral)) {
3417
+ return;
3418
+ }
3419
+ // Look for a duplicate assignment.
3405
3420
  const decls = symbol.getDeclarations();
3406
3421
  if (decls.length >= 2 && decls[0].type === 1 /* DeclarationType.Variable */) {
3407
- const symbolType = this._evaluator.getEffectiveTypeOfSymbol(symbol);
3408
- // Is this symbol a literal instance of the enum class?
3409
- if ((0, types_1.isClassInstance)(symbolType) &&
3410
- types_1.ClassType.isSameGenericClass(symbolType, classType) &&
3411
- symbolType.literalValue !== undefined) {
3412
- this._evaluator.addError(localize_1.Localizer.Diagnostic.duplicateEnumMember().format({ name }), decls[1].node);
3413
- }
3422
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.duplicateEnumMember().format({ name }), decls[1].node);
3423
+ return;
3414
3424
  }
3415
- });
3416
- }
3417
- // If a non-protocol class explicitly inherits from a protocol class and does
3418
- // not explicit derive from ABC, this method verifies that any class or instance
3419
- // variables declared but not assigned in the protocol class are implemented in
3420
- // the subclass. It also checks that any empty functions declared in the protocol
3421
- // are implemented in the subclass.
3422
- _validateProtocolCompatibility(classType, errorNode) {
3423
- if (types_1.ClassType.isProtocolClass(classType)) {
3424
- return;
3425
- }
3426
- // If a class derives from ABC, exempt it from this check. This is used for
3427
- // mixins that derive from a protocol but do not directly implement all
3428
- // of the protocol's methods.
3429
- if (classType.details.mro.some((mroClass) => (0, types_1.isClass)(mroClass) && types_1.ClassType.isBuiltIn(mroClass, 'ABC'))) {
3430
- return;
3431
- }
3432
- const diagAddendum = new diagnostic_1.DiagnosticAddendum();
3433
- const isSymbolImplemented = (name) => {
3434
- return classType.details.mro.some((mroClass) => {
3435
- return (0, types_1.isClass)(mroClass) && !types_1.ClassType.isProtocolClass(mroClass) && mroClass.details.fields.has(name);
3436
- });
3437
- };
3438
- classType.details.baseClasses.forEach((baseClass) => {
3439
- if (!(0, types_1.isClass)(baseClass) || !types_1.ClassType.isProtocolClass(baseClass)) {
3425
+ if (decls[0].type !== 1 /* DeclarationType.Variable */) {
3440
3426
  return;
3441
3427
  }
3442
- const protocolSymbols = (0, typeUtils_1.getProtocolSymbols)(baseClass);
3443
- protocolSymbols.forEach((member, name) => {
3444
- const decls = member.symbol.getDeclarations();
3445
- if (decls.length === 0 || !(0, types_1.isClass)(member.classType)) {
3446
- return;
3447
- }
3448
- if (decls[0].type === 1 /* DeclarationType.Variable */) {
3449
- // If none of the declarations involve assignments, assume it's
3450
- // not implemented in the protocol.
3451
- if (!decls.some((decl) => decl.type === 1 /* DeclarationType.Variable */ && !!decl.inferredTypeSource)) {
3452
- // This is a variable declaration that is not implemented in the
3453
- // protocol base class. Make sure it's implemented in the derived class.
3454
- if (!isSymbolImplemented(name)) {
3455
- diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.missingProtocolMember().format({
3456
- name,
3457
- classType: member.classType.details.name,
3458
- }));
3459
- }
3428
+ const declNode = decls[0].node;
3429
+ const assignedValueType = symbolType.literalValue.itemType;
3430
+ const assignmentNode = ParseTreeUtils.getParentNodeOfType(declNode, 3 /* ParseNodeType.Assignment */);
3431
+ const errorNode = (_a = assignmentNode === null || assignmentNode === void 0 ? void 0 : assignmentNode.rightExpression) !== null && _a !== void 0 ? _a : declNode;
3432
+ // Validate the __new__ and __init__ methods if present.
3433
+ if (newMemberTypeResult || initMemberTypeResult) {
3434
+ if (!(0, types_1.isAnyOrUnknown)(assignedValueType)) {
3435
+ // Construct an argument list. If the assigned type is a tuple, we'll
3436
+ // unpack it. Otherwise, only one argument is passed.
3437
+ const argList = [
3438
+ {
3439
+ argumentCategory: (0, types_1.isClassInstance)(assignedValueType) && (0, typeUtils_1.isTupleClass)(assignedValueType)
3440
+ ? 1 /* ArgumentCategory.UnpackedList */
3441
+ : 0 /* ArgumentCategory.Simple */,
3442
+ typeResult: { type: assignedValueType },
3443
+ },
3444
+ ];
3445
+ if (newMemberTypeResult) {
3446
+ this._evaluator.validateCallArguments(errorNode, argList, newMemberTypeResult);
3447
+ }
3448
+ if (initMemberTypeResult) {
3449
+ this._evaluator.validateCallArguments(errorNode, argList, initMemberTypeResult);
3460
3450
  }
3461
3451
  }
3462
- else if (decls[0].type === 5 /* DeclarationType.Function */) {
3463
- if (this._isUnimplementedProtocolMethod(member.symbol)) {
3464
- if (!isSymbolImplemented(name)) {
3465
- diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.missingProtocolMember().format({
3466
- name,
3467
- classType: member.classType.details.name,
3468
- }));
3469
- }
3452
+ }
3453
+ else if (declaredValueType) {
3454
+ const diag = new diagnostic_1.DiagnosticAddendum();
3455
+ // If the assigned value is already an instance of this enum class, skip this check.
3456
+ if (!(0, types_1.isClassInstance)(assignedValueType) ||
3457
+ !types_1.ClassType.isSameGenericClass(assignedValueType, classType)) {
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);
3470
3460
  }
3471
3461
  }
3472
- });
3462
+ }
3473
3463
  });
3474
- if (!diagAddendum.isEmpty()) {
3475
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.missingProtocolMembers() + diagAddendum.getString(), errorNode.name);
3476
- }
3477
3464
  }
3478
3465
  // If a class is a dataclass with a `__post_init__` method, verify that its
3479
3466
  // signature is correct.
@@ -3520,7 +3507,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3520
3507
  // We expect to see one param for "self" plus one for each of the InitVars.
3521
3508
  const expectedParamCount = initOnlySymbolMap.size + 1;
3522
3509
  if (expectedParamCount < nonDefaultParams.length || expectedParamCount > paramListDetails.params.length) {
3523
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.dataClassPostInitParamCount().format({ expected: initOnlySymbolMap.size }), postInitType.details.declaration.node.name);
3510
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.dataClassPostInitParamCount().format({ expected: initOnlySymbolMap.size }), postInitType.details.declaration.node.name);
3524
3511
  }
3525
3512
  // Verify that the parameter types match.
3526
3513
  let paramIndex = 1;
@@ -3535,11 +3522,11 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3535
3522
  const paramType = types_1.FunctionType.getEffectiveParameterType(postInitType, paramListDetails.params[paramIndex].index);
3536
3523
  const assignTypeDiag = new diagnostic_1.DiagnosticAddendum();
3537
3524
  if (fieldType && !this._evaluator.assignType(paramType, fieldType, assignTypeDiag)) {
3538
- const diagnostic = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.dataClassPostInitType().format({ fieldName }) + assignTypeDiag.getString(), param.typeAnnotation);
3525
+ const diagnostic = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.dataClassPostInitType().format({ fieldName }) + assignTypeDiag.getString(), param.typeAnnotation);
3539
3526
  if (diagnostic) {
3540
3527
  const fieldDecls = symbol.getTypedDeclarations();
3541
3528
  if (fieldDecls.length > 0) {
3542
- diagnostic.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.dataClassFieldLocation(), fieldDecls[0].uri, fieldDecls[0].range);
3529
+ diagnostic.addRelatedInfo(localize_1.LocAddendum.dataClassFieldLocation(), fieldDecls[0].uri, fieldDecls[0].range);
3543
3530
  }
3544
3531
  }
3545
3532
  }
@@ -3547,42 +3534,6 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3547
3534
  paramIndex++;
3548
3535
  });
3549
3536
  }
3550
- // Determine whether a method defined in a protocol should be considered
3551
- // "unimplemented". This is an under-specified part of the typing spec.
3552
- _isUnimplementedProtocolMethod(symbol) {
3553
- const symbolType = this._evaluator.getEffectiveTypeOfSymbol(symbol);
3554
- // Behavior differs between stub files and source files.
3555
- const decls = symbol.getDeclarations();
3556
- const isDeclaredInStubFile = decls.length > 0 && (0, sourceMapper_1.isStubFile)(decls[0].uri);
3557
- if ((0, types_1.isFunction)(symbolType)) {
3558
- const decl = symbolType.details.declaration;
3559
- if (decl) {
3560
- return isDeclaredInStubFile
3561
- ? types_1.FunctionType.isAbstractMethod(symbolType)
3562
- : ParseTreeUtils.isSuiteEmpty(decl.node.suite);
3563
- }
3564
- }
3565
- else if ((0, types_1.isOverloadedFunction)(symbolType)) {
3566
- // If an implementation is present and has an empty body, assume
3567
- // the function is unimplemented.
3568
- const impl = types_1.OverloadedFunctionType.getImplementation(symbolType);
3569
- if (impl) {
3570
- const decl = impl.details.declaration;
3571
- if (decl) {
3572
- return ParseTreeUtils.isSuiteEmpty(decl.node.suite);
3573
- }
3574
- return false;
3575
- }
3576
- if (isDeclaredInStubFile) {
3577
- // If no implementation was present, see if any of the overloads
3578
- // are marked as abstract.
3579
- const overloads = types_1.OverloadedFunctionType.getOverloads(symbolType);
3580
- return overloads.some((overload) => types_1.FunctionType.isAbstractMethod(overload));
3581
- }
3582
- return true;
3583
- }
3584
- return false;
3585
- }
3586
3537
  // If a class is marked final, it must implement all abstract methods,
3587
3538
  // otherwise it is of no use.
3588
3539
  _validateFinalClassNotAbstract(classType, errorNode) {
@@ -3592,29 +3543,29 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3592
3543
  if (!types_1.ClassType.supportsAbstractMethods(classType)) {
3593
3544
  return;
3594
3545
  }
3595
- const abstractMethods = this._evaluator.getAbstractMethods(classType);
3596
- if (abstractMethods.length === 0) {
3546
+ const abstractSymbols = this._evaluator.getAbstractSymbols(classType);
3547
+ if (abstractSymbols.length === 0) {
3597
3548
  return;
3598
3549
  }
3599
3550
  const diagAddendum = new diagnostic_1.DiagnosticAddendum();
3600
3551
  const errorsToDisplay = 2;
3601
- abstractMethods.forEach((abstractMethod, index) => {
3552
+ abstractSymbols.forEach((abstractMethod, index) => {
3602
3553
  if (index === errorsToDisplay) {
3603
- diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.memberIsAbstractMore().format({
3604
- count: abstractMethods.length - errorsToDisplay,
3554
+ diagAddendum.addMessage(localize_1.LocAddendum.memberIsAbstractMore().format({
3555
+ count: abstractSymbols.length - errorsToDisplay,
3605
3556
  }));
3606
3557
  }
3607
3558
  else if (index < errorsToDisplay) {
3608
3559
  if ((0, types_1.isInstantiableClass)(abstractMethod.classType)) {
3609
3560
  const className = abstractMethod.classType.details.name;
3610
- diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.memberIsAbstract().format({
3561
+ diagAddendum.addMessage(localize_1.LocAddendum.memberIsAbstract().format({
3611
3562
  type: className,
3612
3563
  name: abstractMethod.symbolName,
3613
3564
  }));
3614
3565
  }
3615
3566
  }
3616
3567
  });
3617
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.finalClassIsAbstract().format({
3568
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.finalClassIsAbstract().format({
3618
3569
  type: classType.details.name,
3619
3570
  }) + diagAddendum.getString(), errorNode.name);
3620
3571
  }
@@ -3693,7 +3644,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3693
3644
  return;
3694
3645
  }
3695
3646
  // Report the variable as uninitialized only on the first decl.
3696
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUninitializedInstanceVariable, diagnosticRules_1.DiagnosticRule.reportUninitializedInstanceVariable, localize_1.Localizer.Diagnostic.uninitializedInstanceVariable().format({ name: name }), decls[0].node);
3647
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUninitializedInstanceVariable, localize_1.LocMessage.uninitializedInstanceVariable().format({ name: name }), decls[0].node);
3697
3648
  });
3698
3649
  // See if there are any variables from abstract base classes
3699
3650
  // that are not initialized.
@@ -3709,7 +3660,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3709
3660
  if (!decls.some((decl) => decl.type === 1 /* DeclarationType.Variable */ && !!decl.inferredTypeSource)) {
3710
3661
  // This is a variable declaration that is not implemented in the
3711
3662
  // protocol base class. Make sure it's implemented in the derived class.
3712
- diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.uninitializedAbstractVariable().format({
3663
+ diagAddendum.addMessage(localize_1.LocAddendum.uninitializedAbstractVariable().format({
3713
3664
  name,
3714
3665
  classType: member.classType.details.name,
3715
3666
  }));
@@ -3717,7 +3668,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3717
3668
  }
3718
3669
  });
3719
3670
  if (!diagAddendum.isEmpty()) {
3720
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUninitializedInstanceVariable, diagnosticRules_1.DiagnosticRule.reportUninitializedInstanceVariable, localize_1.Localizer.Diagnostic.uninitializedAbstractVariables().format({ classType: classType.details.name }) +
3671
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUninitializedInstanceVariable, localize_1.LocMessage.uninitializedAbstractVariables().format({ classType: classType.details.name }) +
3721
3672
  diagAddendum.getString(), node.name);
3722
3673
  }
3723
3674
  }
@@ -3733,12 +3684,9 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3733
3684
  if (!(0, types_1.isInstantiableClass)(objectType)) {
3734
3685
  return;
3735
3686
  }
3736
- // Replace all of the type parameters with invariant TypeVars.
3737
- const updatedTypeParams = classType.details.typeParameters.map((typeParam) => types_1.TypeVarType.cloneAsInvariant(typeParam));
3738
- const updatedClassType = types_1.ClassType.cloneWithNewTypeParameters(classType, updatedTypeParams);
3739
3687
  const objectObject = types_1.ClassType.cloneAsInstance(objectType);
3740
3688
  const dummyTypeObject = types_1.ClassType.createInstantiable('__varianceDummy', '', '', uri_1.Uri.empty(), 0, 0, undefined, undefined);
3741
- updatedTypeParams.forEach((param, paramIndex) => {
3689
+ classType.details.typeParameters.forEach((param, paramIndex) => {
3742
3690
  // Skip variadics and ParamSpecs.
3743
3691
  if (param.details.isVariadic || param.details.isParamSpec) {
3744
3692
  return;
@@ -3749,7 +3697,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3749
3697
  }
3750
3698
  // Replace all type arguments with a dummy type except for the
3751
3699
  // TypeVar of interest, which is replaced with an object instance.
3752
- const srcTypeArgs = updatedTypeParams.map((p, i) => {
3700
+ const srcTypeArgs = classType.details.typeParameters.map((p, i) => {
3753
3701
  if (p.details.isVariadic) {
3754
3702
  return p;
3755
3703
  }
@@ -3757,20 +3705,19 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3757
3705
  });
3758
3706
  // Replace all type arguments with a dummy type except for the
3759
3707
  // TypeVar of interest, which is replaced with itself.
3760
- const destTypeArgs = updatedTypeParams.map((p, i) => {
3708
+ const destTypeArgs = classType.details.typeParameters.map((p, i) => {
3761
3709
  return i === paramIndex || p.details.isVariadic ? p : dummyTypeObject;
3762
3710
  });
3763
- const srcType = types_1.ClassType.cloneForSpecialization(updatedClassType, srcTypeArgs,
3764
- /* isTypeArgumentExplicit */ true);
3765
- const destType = types_1.ClassType.cloneForSpecialization(updatedClassType, destTypeArgs,
3711
+ const srcType = types_1.ClassType.cloneForSpecialization(classType, srcTypeArgs, /* isTypeArgumentExplicit */ true);
3712
+ const destType = types_1.ClassType.cloneForSpecialization(classType, destTypeArgs,
3766
3713
  /* isTypeArgumentExplicit */ true);
3767
- const isDestSubtypeOfSrc = this._evaluator.assignClassToSelf(srcType, destType);
3714
+ const isDestSubtypeOfSrc = this._evaluator.assignClassToSelf(srcType, destType, 3 /* Variance.Covariant */);
3768
3715
  let expectedVariance;
3769
3716
  if (isDestSubtypeOfSrc) {
3770
3717
  expectedVariance = 3 /* Variance.Covariant */;
3771
3718
  }
3772
3719
  else {
3773
- const isSrcSubtypeOfDest = this._evaluator.assignClassToSelf(destType, srcType);
3720
+ const isSrcSubtypeOfDest = this._evaluator.assignClassToSelf(destType, srcType, 4 /* Variance.Contravariant */);
3774
3721
  if (isSrcSubtypeOfDest) {
3775
3722
  expectedVariance = 4 /* Variance.Contravariant */;
3776
3723
  }
@@ -3781,24 +3728,24 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3781
3728
  if (expectedVariance !== classType.details.typeParameters[paramIndex].details.declaredVariance) {
3782
3729
  let message;
3783
3730
  if (expectedVariance === 3 /* Variance.Covariant */) {
3784
- message = localize_1.Localizer.Diagnostic.protocolVarianceCovariant().format({
3731
+ message = localize_1.LocMessage.protocolVarianceCovariant().format({
3785
3732
  variable: param.details.name,
3786
3733
  class: classType.details.name,
3787
3734
  });
3788
3735
  }
3789
3736
  else if (expectedVariance === 4 /* Variance.Contravariant */) {
3790
- message = localize_1.Localizer.Diagnostic.protocolVarianceContravariant().format({
3737
+ message = localize_1.LocMessage.protocolVarianceContravariant().format({
3791
3738
  variable: param.details.name,
3792
3739
  class: classType.details.name,
3793
3740
  });
3794
3741
  }
3795
3742
  else {
3796
- message = localize_1.Localizer.Diagnostic.protocolVarianceInvariant().format({
3743
+ message = localize_1.LocMessage.protocolVarianceInvariant().format({
3797
3744
  variable: param.details.name,
3798
3745
  class: classType.details.name,
3799
3746
  });
3800
3747
  }
3801
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportInvalidTypeVarUse, diagnosticRules_1.DiagnosticRule.reportInvalidTypeVarUse, message, errorNode.name);
3748
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInvalidTypeVarUse, message, errorNode.name);
3802
3749
  }
3803
3750
  });
3804
3751
  }
@@ -3823,7 +3770,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3823
3770
  !decl.isDefinedBySlots &&
3824
3771
  !decl.isDefinedByMemberAccess) {
3825
3772
  if (decl.node.nodeType === 38 /* ParseNodeType.Name */ && ParseTreeUtils.isWriteAccess(decl.node)) {
3826
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.slotsClassVarConflict().format({ name }), decl.node);
3773
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.slotsClassVarConflict().format({ name }), decl.node);
3827
3774
  }
3828
3775
  }
3829
3776
  });
@@ -3910,20 +3857,18 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3910
3857
  const diagAddendum = new diagnostic_1.DiagnosticAddendum();
3911
3858
  const initSignature = this._evaluator.printType(initMemberType);
3912
3859
  const newSignature = this._evaluator.printType(newMemberType);
3913
- diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.initMethodSignature().format({
3860
+ diagAddendum.addMessage(localize_1.LocAddendum.initMethodSignature().format({
3914
3861
  type: initSignature,
3915
3862
  }));
3916
- diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.newMethodSignature().format({
3863
+ diagAddendum.addMessage(localize_1.LocAddendum.newMethodSignature().format({
3917
3864
  type: newSignature,
3918
3865
  }));
3919
- const diagnostic = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportInconsistentConstructor, diagnosticRules_1.DiagnosticRule.reportInconsistentConstructor, localize_1.Localizer.Diagnostic.constructorParametersMismatch().format({
3866
+ const diagnostic = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportInconsistentConstructor, localize_1.LocMessage.constructorParametersMismatch().format({
3920
3867
  classType: this._evaluator.printType(types_1.ClassType.cloneAsInstance(displayOnInit ? initMethodResult.classType : newMethodResult.classType)),
3921
3868
  }) + diagAddendum.getString(), mainDeclNode);
3922
3869
  if (diagnostic) {
3923
3870
  const secondaryDecl = displayOnInit ? newDecl : initDecl;
3924
- diagnostic.addRelatedInfo((displayOnInit
3925
- ? localize_1.Localizer.DiagnosticAddendum.newMethodLocation()
3926
- : localize_1.Localizer.DiagnosticAddendum.initMethodLocation()).format({
3871
+ diagnostic.addRelatedInfo((displayOnInit ? localize_1.LocAddendum.newMethodLocation() : localize_1.LocAddendum.initMethodLocation()).format({
3927
3872
  type: this._evaluator.printType(types_1.ClassType.cloneAsInstance(displayOnInit ? newMethodResult.classType : initMethodResult.classType)),
3928
3873
  }), secondaryDecl.uri, secondaryDecl.range);
3929
3874
  }
@@ -3963,13 +3908,13 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3963
3908
  const diag = new diagnostic_1.DiagnosticAddendum();
3964
3909
  const baseClassObject = (0, typeUtils_1.convertToInstance)(baseClass);
3965
3910
  if ((0, types_1.isTypeSame)(baseClassObject, baseClassMroObject)) {
3966
- diag.addMessage(localize_1.Localizer.DiagnosticAddendum.baseClassIncompatible().format({
3911
+ diag.addMessage(localize_1.LocAddendum.baseClassIncompatible().format({
3967
3912
  baseClass: this._evaluator.printType(baseClassObject),
3968
3913
  type: this._evaluator.printType(matchingMroObject),
3969
3914
  }));
3970
3915
  }
3971
3916
  else {
3972
- diag.addMessage(localize_1.Localizer.DiagnosticAddendum.baseClassIncompatibleSubclass().format({
3917
+ diag.addMessage(localize_1.LocAddendum.baseClassIncompatibleSubclass().format({
3973
3918
  baseClass: this._evaluator.printType(baseClassObject),
3974
3919
  subclass: this._evaluator.printType(baseClassMroObject),
3975
3920
  type: this._evaluator.printType(matchingMroObject),
@@ -3984,8 +3929,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3984
3929
  }
3985
3930
  }
3986
3931
  if (!diagAddendum.isEmpty()) {
3987
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.baseClassIncompatible().format({ type: classType.details.name }) +
3988
- diagAddendum.getString(), errorNode);
3932
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.baseClassIncompatible().format({ type: classType.details.name }) + diagAddendum.getString(), errorNode);
3989
3933
  }
3990
3934
  }
3991
3935
  // Validates that any methods and variables in multiple base classes are
@@ -4090,7 +4034,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4090
4034
  /* enforceParamNameMatch */ true)) {
4091
4035
  const decl = overrideFunction.details.declaration;
4092
4036
  if (decl && decl.type === 5 /* DeclarationType.Function */) {
4093
- diag = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportIncompatibleMethodOverride, diagnosticRules_1.DiagnosticRule.reportIncompatibleMethodOverride, localize_1.Localizer.Diagnostic.baseClassMethodTypeIncompatible().format({
4037
+ diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportIncompatibleMethodOverride, localize_1.LocMessage.baseClassMethodTypeIncompatible().format({
4094
4038
  classType: childClassType.details.name,
4095
4039
  name: memberName,
4096
4040
  }) + diagAddendum.getString(), errorNode);
@@ -4103,7 +4047,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4103
4047
  if (!(0, typeUtils_1.isProperty)(overrideType) && !(0, types_1.isAnyOrUnknown)(overrideType)) {
4104
4048
  const decls = overrideSymbol.getDeclarations();
4105
4049
  if (decls.length > 0) {
4106
- diag = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportIncompatibleVariableOverride, diagnosticRules_1.DiagnosticRule.reportIncompatibleVariableOverride, localize_1.Localizer.Diagnostic.baseClassVariableTypeIncompatible().format({
4050
+ diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportIncompatibleVariableOverride, localize_1.LocMessage.baseClassVariableTypeIncompatible().format({
4107
4051
  classType: childClassType.details.name,
4108
4052
  name: memberName,
4109
4053
  }), errorNode);
@@ -4149,7 +4093,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4149
4093
  /* diag */ undefined,
4150
4094
  /* destTypeVarContext */ undefined,
4151
4095
  /* srcTypeVarContext */ undefined, isInvariant ? 1 /* AssignTypeFlags.EnforceInvariance */ : 0 /* AssignTypeFlags.Default */)) {
4152
- diag = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportIncompatibleVariableOverride, diagnosticRules_1.DiagnosticRule.reportIncompatibleVariableOverride, localize_1.Localizer.Diagnostic.baseClassVariableTypeIncompatible().format({
4096
+ diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportIncompatibleVariableOverride, localize_1.LocMessage.baseClassVariableTypeIncompatible().format({
4153
4097
  classType: childClassType.details.name,
4154
4098
  name: memberName,
4155
4099
  }), errorNode);
@@ -4168,12 +4112,12 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4168
4112
  }
4169
4113
  if (!isRequiredCompatible) {
4170
4114
  const message = overrideTDEntry.isRequired
4171
- ? localize_1.Localizer.Diagnostic.typedDictFieldRequiredRedefinition
4172
- : localize_1.Localizer.Diagnostic.typedDictFieldNotRequiredRedefinition;
4173
- diag = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportIncompatibleVariableOverride, diagnosticRules_1.DiagnosticRule.reportIncompatibleVariableOverride, message().format({ name: memberName }), errorNode);
4115
+ ? localize_1.LocMessage.typedDictFieldRequiredRedefinition
4116
+ : localize_1.LocMessage.typedDictFieldNotRequiredRedefinition;
4117
+ diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportIncompatibleVariableOverride, message().format({ name: memberName }), errorNode);
4174
4118
  }
4175
4119
  else if (!isReadOnlyCompatible) {
4176
- diag = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportIncompatibleVariableOverride, diagnosticRules_1.DiagnosticRule.reportIncompatibleVariableOverride, localize_1.Localizer.Diagnostic.typedDictFieldReadOnlyRedefinition().format({
4120
+ diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportIncompatibleVariableOverride, localize_1.LocMessage.typedDictFieldReadOnlyRedefinition().format({
4177
4121
  name: memberName,
4178
4122
  }), errorNode);
4179
4123
  }
@@ -4182,11 +4126,11 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4182
4126
  }
4183
4127
  }
4184
4128
  if (diag && overrideDecl && overriddenDecl) {
4185
- diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.baseClassOverriddenType().format({
4129
+ diag.addRelatedInfo(localize_1.LocAddendum.baseClassOverriddenType().format({
4186
4130
  baseClass: this._evaluator.printType((0, typeUtils_1.convertToInstance)(overriddenClassAndSymbol.classType)),
4187
4131
  type: this._evaluator.printType(overriddenType),
4188
4132
  }), overriddenDecl.uri, overriddenDecl.range);
4189
- diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.baseClassOverridesType().format({
4133
+ diag.addRelatedInfo(localize_1.LocAddendum.baseClassOverridesType().format({
4190
4134
  baseClass: this._evaluator.printType((0, typeUtils_1.convertToInstance)(overrideClassAndSymbol.classType)),
4191
4135
  type: this._evaluator.printType(overrideType),
4192
4136
  }), overrideDecl.uri, overrideDecl.range);
@@ -4216,7 +4160,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4216
4160
  overloads.forEach((overload) => {
4217
4161
  var _a, _b;
4218
4162
  if (types_1.FunctionType.isFinal(overload) && ((_a = overload.details.declaration) === null || _a === void 0 ? void 0 : _a.node)) {
4219
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.overloadFinalInconsistencyImpl().format({
4163
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.overloadFinalInconsistencyImpl().format({
4220
4164
  name: overload.details.name,
4221
4165
  }), (_b = (0, declarationUtils_1.getNameNodeForDeclaration)(overload.details.declaration)) !== null && _b !== void 0 ? _b : overload.details.declaration.node);
4222
4166
  }
@@ -4228,7 +4172,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4228
4172
  overloads.slice(1).forEach((overload, index) => {
4229
4173
  var _a, _b;
4230
4174
  if (types_1.FunctionType.isFinal(overload) && ((_a = overload.details.declaration) === null || _a === void 0 ? void 0 : _a.node)) {
4231
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.overloadFinalInconsistencyNoImpl().format({
4175
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.overloadFinalInconsistencyNoImpl().format({
4232
4176
  name: overload.details.name,
4233
4177
  index: index + 2,
4234
4178
  }), (_b = (0, declarationUtils_1.getNameNodeForDeclaration)(overload.details.declaration)) !== null && _b !== void 0 ? _b : overload.details.declaration.node);
@@ -4318,7 +4262,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4318
4262
  return;
4319
4263
  }
4320
4264
  const funcNode = overrideFunction.details.declaration.node;
4321
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportImplicitOverride, diagnosticRules_1.DiagnosticRule.reportImplicitOverride, localize_1.Localizer.Diagnostic.overrideDecoratorMissing().format({
4265
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportImplicitOverride, localize_1.LocMessage.overrideDecoratorMissing().format({
4322
4266
  name: funcNode.name.value,
4323
4267
  className: this._evaluator.printType((0, typeUtils_1.convertToInstance)(baseMember.classType)),
4324
4268
  }), funcNode.name);
@@ -4353,7 +4297,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4353
4297
  return;
4354
4298
  }
4355
4299
  const funcNode = overrideFunction.details.declaration.node;
4356
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.overriddenMethodNotFound().format({ name: funcNode.name.value }), funcNode.name);
4300
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.overriddenMethodNotFound().format({ name: funcNode.name.value }), funcNode.name);
4357
4301
  }
4358
4302
  _validateBaseClassOverride(baseClassAndSymbol, overrideSymbol, overrideType, childClassType, memberName) {
4359
4303
  var _a, _b, _c, _d, _e, _f, _g, _h;
@@ -4395,13 +4339,13 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4395
4339
  if (reportFinalMethodOverride) {
4396
4340
  const decl = (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(overrideSymbol);
4397
4341
  if (decl && decl.type === 5 /* DeclarationType.Function */) {
4398
- const diag = this._evaluator.addError(localize_1.Localizer.Diagnostic.finalMethodOverride().format({
4342
+ const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportIncompatibleMethodOverride, localize_1.LocMessage.finalMethodOverride().format({
4399
4343
  name: memberName,
4400
4344
  className: baseClass.details.name,
4401
4345
  }), decl.node.name);
4402
4346
  const origDecl = (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(baseClassAndSymbol.symbol);
4403
4347
  if (diag && origDecl) {
4404
- diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.finalMethod(), origDecl.uri, origDecl.range);
4348
+ diag.addRelatedInfo(localize_1.LocAddendum.finalMethod(), origDecl.uri, origDecl.range);
4405
4349
  }
4406
4350
  }
4407
4351
  }
@@ -4422,13 +4366,13 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4422
4366
  ? overrideType.details.declaration
4423
4367
  : (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(overrideSymbol);
4424
4368
  if (decl) {
4425
- const diag = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportIncompatibleMethodOverride, diagnosticRules_1.DiagnosticRule.reportIncompatibleMethodOverride, localize_1.Localizer.Diagnostic.incompatibleMethodOverride().format({
4369
+ const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportIncompatibleMethodOverride, localize_1.LocMessage.incompatibleMethodOverride().format({
4426
4370
  name: memberName,
4427
4371
  className: baseClass.details.name,
4428
4372
  }) + diagAddendum.getString(), (_a = (0, declarationUtils_1.getNameNodeForDeclaration)(decl)) !== null && _a !== void 0 ? _a : decl.node);
4429
4373
  const origDecl = (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(baseClassAndSymbol.symbol);
4430
4374
  if (diag && origDecl) {
4431
- diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.overriddenMethod(), origDecl.uri, origDecl.range);
4375
+ diag.addRelatedInfo(localize_1.LocAddendum.overriddenMethod(), origDecl.uri, origDecl.range);
4432
4376
  }
4433
4377
  }
4434
4378
  }
@@ -4442,14 +4386,14 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4442
4386
  const decls = overrideSymbol.getDeclarations();
4443
4387
  if (decls.length > 0) {
4444
4388
  const lastDecl = decls[decls.length - 1];
4445
- const diag = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportIncompatibleMethodOverride, diagnosticRules_1.DiagnosticRule.reportIncompatibleMethodOverride, localize_1.Localizer.Diagnostic.methodOverridden().format({
4389
+ const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportIncompatibleMethodOverride, localize_1.LocMessage.methodOverridden().format({
4446
4390
  name: memberName,
4447
4391
  className: baseClass.details.name,
4448
4392
  type: this._evaluator.printType(overrideType),
4449
4393
  }), (_b = (0, declarationUtils_1.getNameNodeForDeclaration)(lastDecl)) !== null && _b !== void 0 ? _b : lastDecl.node);
4450
4394
  const origDecl = (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(baseClassAndSymbol.symbol);
4451
4395
  if (diag && origDecl) {
4452
- diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.overriddenMethod(), origDecl.uri, origDecl.range);
4396
+ diag.addRelatedInfo(localize_1.LocAddendum.overriddenMethod(), origDecl.uri, origDecl.range);
4453
4397
  }
4454
4398
  }
4455
4399
  }
@@ -4461,7 +4405,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4461
4405
  const decls = overrideSymbol.getDeclarations();
4462
4406
  if (decls.length > 0) {
4463
4407
  const lastDecl = decls[decls.length - 1];
4464
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportIncompatibleMethodOverride, diagnosticRules_1.DiagnosticRule.reportIncompatibleMethodOverride, localize_1.Localizer.Diagnostic.propertyOverridden().format({
4408
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportIncompatibleMethodOverride, localize_1.LocMessage.propertyOverridden().format({
4465
4409
  name: memberName,
4466
4410
  className: baseClass.details.name,
4467
4411
  }), (_c = (0, declarationUtils_1.getNameNodeForDeclaration)(lastDecl)) !== null && _c !== void 0 ? _c : lastDecl.node);
@@ -4486,19 +4430,19 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4486
4430
  if ((0, types_1.isFunction)(baseClassMethodType)) {
4487
4431
  if (!subclassPropMethod) {
4488
4432
  // The method is missing.
4489
- diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.propertyMethodMissing().format({
4433
+ diagAddendum.addMessage(localize_1.LocAddendum.propertyMethodMissing().format({
4490
4434
  name: methodName,
4491
4435
  }));
4492
4436
  const decls = overrideSymbol.getDeclarations();
4493
4437
  if (decls.length > 0) {
4494
4438
  const lastDecl = decls[decls.length - 1];
4495
- const diag = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportIncompatibleMethodOverride, diagnosticRules_1.DiagnosticRule.reportIncompatibleMethodOverride, localize_1.Localizer.Diagnostic.propertyOverridden().format({
4439
+ const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportIncompatibleMethodOverride, localize_1.LocMessage.propertyOverridden().format({
4496
4440
  name: memberName,
4497
4441
  className: baseClassType.details.name,
4498
4442
  }) + diagAddendum.getString(), (_a = (0, declarationUtils_1.getNameNodeForDeclaration)(lastDecl)) !== null && _a !== void 0 ? _a : lastDecl.node);
4499
4443
  const origDecl = baseClassMethodType.details.declaration;
4500
4444
  if (diag && origDecl) {
4501
- diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.overriddenMethod(), origDecl.uri, origDecl.range);
4445
+ diag.addRelatedInfo(localize_1.LocAddendum.overriddenMethod(), origDecl.uri, origDecl.range);
4502
4446
  }
4503
4447
  }
4504
4448
  }
@@ -4506,18 +4450,18 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4506
4450
  const subclassMethodType = (0, typeUtils_1.partiallySpecializeType)(subclassPropMethod, childClassType);
4507
4451
  if ((0, types_1.isFunction)(subclassMethodType)) {
4508
4452
  if (!this._evaluator.validateOverrideMethod(baseClassMethodType, subclassMethodType, childClassType, diagAddendum.createAddendum())) {
4509
- diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.propertyMethodIncompatible().format({
4453
+ diagAddendum.addMessage(localize_1.LocAddendum.propertyMethodIncompatible().format({
4510
4454
  name: methodName,
4511
4455
  }));
4512
4456
  const decl = subclassMethodType.details.declaration;
4513
4457
  if (decl && decl.type === 5 /* DeclarationType.Function */) {
4514
- const diag = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportIncompatibleMethodOverride, diagnosticRules_1.DiagnosticRule.reportIncompatibleMethodOverride, localize_1.Localizer.Diagnostic.propertyOverridden().format({
4458
+ const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportIncompatibleMethodOverride, localize_1.LocMessage.propertyOverridden().format({
4515
4459
  name: memberName,
4516
4460
  className: baseClassType.details.name,
4517
4461
  }) + diagAddendum.getString(), decl.node.name);
4518
4462
  const origDecl = baseClassMethodType.details.declaration;
4519
4463
  if (diag && origDecl) {
4520
- diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.overriddenMethod(), origDecl.uri, origDecl.range);
4464
+ diag.addRelatedInfo(localize_1.LocAddendum.overriddenMethod(), origDecl.uri, origDecl.range);
4521
4465
  }
4522
4466
  }
4523
4467
  }
@@ -4564,19 +4508,19 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4564
4508
  /* srcTypeVarContext */ undefined, isInvariant ? 1 /* AssignTypeFlags.EnforceInvariance */ : 0 /* AssignTypeFlags.Default */)) {
4565
4509
  if (isInvariant) {
4566
4510
  diagAddendum = new diagnostic_1.DiagnosticAddendum();
4567
- diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideIsInvariant());
4568
- diagAddendum.createAddendum().addMessage(localize_1.Localizer.DiagnosticAddendum.overrideInvariantMismatch().format({
4511
+ diagAddendum.addMessage(localize_1.LocAddendum.overrideIsInvariant());
4512
+ diagAddendum.createAddendum().addMessage(localize_1.LocAddendum.overrideInvariantMismatch().format({
4569
4513
  overrideType: this._evaluator.printType(overrideType),
4570
4514
  baseType: this._evaluator.printType(baseType),
4571
4515
  }));
4572
4516
  }
4573
- const diag = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportIncompatibleVariableOverride, diagnosticRules_1.DiagnosticRule.reportIncompatibleVariableOverride, localize_1.Localizer.Diagnostic.symbolOverridden().format({
4517
+ const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportIncompatibleVariableOverride, localize_1.LocMessage.symbolOverridden().format({
4574
4518
  name: memberName,
4575
4519
  className: baseClass.details.name,
4576
4520
  }) + diagAddendum.getString(), (_d = (0, declarationUtils_1.getNameNodeForDeclaration)(lastDecl)) !== null && _d !== void 0 ? _d : lastDecl.node);
4577
4521
  const origDecl = (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(baseClassAndSymbol.symbol);
4578
4522
  if (diag && origDecl) {
4579
- diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.overriddenSymbol(), origDecl.uri, origDecl.range);
4523
+ diag.addRelatedInfo(localize_1.LocAddendum.overriddenSymbol(), origDecl.uri, origDecl.range);
4580
4524
  }
4581
4525
  }
4582
4526
  else if (overriddenTDEntry && overrideTDEntry) {
@@ -4592,14 +4536,14 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4592
4536
  }
4593
4537
  if (!isRequiredCompatible) {
4594
4538
  const message = overrideTDEntry.isRequired
4595
- ? localize_1.Localizer.Diagnostic.typedDictFieldRequiredRedefinition
4596
- : localize_1.Localizer.Diagnostic.typedDictFieldNotRequiredRedefinition;
4597
- this._evaluator.addDiagnostic(AnalyzerNodeInfo.getFileInfo(lastDecl.node).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, message().format({ name: memberName }), (_e = (0, declarationUtils_1.getNameNodeForDeclaration)(lastDecl)) !== null && _e !== void 0 ? _e : lastDecl.node);
4539
+ ? localize_1.LocMessage.typedDictFieldRequiredRedefinition
4540
+ : localize_1.LocMessage.typedDictFieldNotRequiredRedefinition;
4541
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, message().format({ name: memberName }), (_e = (0, declarationUtils_1.getNameNodeForDeclaration)(lastDecl)) !== null && _e !== void 0 ? _e : lastDecl.node);
4598
4542
  }
4599
4543
  // Make sure that the derived class isn't marking a previously writable
4600
4544
  // entry as read-only.
4601
4545
  if (!overriddenTDEntry.isReadOnly && overrideTDEntry.isReadOnly) {
4602
- this._evaluator.addDiagnostic(AnalyzerNodeInfo.getFileInfo(lastDecl.node).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.typedDictFieldReadOnlyRedefinition().format({
4546
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typedDictFieldReadOnlyRedefinition().format({
4603
4547
  name: memberName,
4604
4548
  }), (_f = (0, declarationUtils_1.getNameNodeForDeclaration)(lastDecl)) !== null && _f !== void 0 ? _f : lastDecl.node);
4605
4549
  }
@@ -4608,12 +4552,12 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4608
4552
  const isBaseVarFinal = this._evaluator.isFinalVariable(baseClassAndSymbol.symbol);
4609
4553
  const overrideFinalVarDecl = decls.find((d) => this._evaluator.isFinalVariableDeclaration(d));
4610
4554
  if (!isBaseVarFinal && overrideFinalVarDecl) {
4611
- const diag = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportIncompatibleVariableOverride, diagnosticRules_1.DiagnosticRule.reportIncompatibleVariableOverride, localize_1.Localizer.Diagnostic.variableFinalOverride().format({
4555
+ const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportIncompatibleVariableOverride, localize_1.LocMessage.variableFinalOverride().format({
4612
4556
  name: memberName,
4613
4557
  className: baseClass.details.name,
4614
4558
  }), (_g = (0, declarationUtils_1.getNameNodeForDeclaration)(lastDecl)) !== null && _g !== void 0 ? _g : lastDecl.node);
4615
4559
  if (diag) {
4616
- diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.overriddenSymbol(), overrideFinalVarDecl.uri, overrideFinalVarDecl.range);
4560
+ diag.addRelatedInfo(localize_1.LocAddendum.overriddenSymbol(), overrideFinalVarDecl.uri, overrideFinalVarDecl.range);
4617
4561
  }
4618
4562
  }
4619
4563
  // Verify that a class variable isn't overriding an instance
@@ -4635,15 +4579,15 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4635
4579
  }
4636
4580
  if (isBaseClassVar !== isClassVar) {
4637
4581
  const unformattedMessage = overrideSymbol.isClassVar()
4638
- ? localize_1.Localizer.Diagnostic.classVarOverridesInstanceVar()
4639
- : localize_1.Localizer.Diagnostic.instanceVarOverridesClassVar();
4640
- const diag = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportIncompatibleVariableOverride, diagnosticRules_1.DiagnosticRule.reportIncompatibleVariableOverride, unformattedMessage.format({
4582
+ ? localize_1.LocMessage.classVarOverridesInstanceVar()
4583
+ : localize_1.LocMessage.instanceVarOverridesClassVar();
4584
+ const diag = this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportIncompatibleVariableOverride, unformattedMessage.format({
4641
4585
  name: memberName,
4642
4586
  className: baseClass.details.name,
4643
4587
  }), (_h = (0, declarationUtils_1.getNameNodeForDeclaration)(lastDecl)) !== null && _h !== void 0 ? _h : lastDecl.node);
4644
4588
  const origDecl = (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(baseClassAndSymbol.symbol);
4645
4589
  if (diag && origDecl) {
4646
- diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.overriddenSymbol(), origDecl.uri, origDecl.range);
4590
+ diag.addRelatedInfo(localize_1.LocAddendum.overriddenSymbol(), origDecl.uri, origDecl.range);
4647
4591
  }
4648
4592
  }
4649
4593
  }
@@ -4671,7 +4615,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4671
4615
  if (node.parameters.length === 0 ||
4672
4616
  !node.parameters[0].name ||
4673
4617
  !['cls', '_cls', '__cls', '__mcls', 'mcls', 'mcs', 'metacls'].some((name) => node.parameters[0].name.value === name)) {
4674
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportSelfClsParameterName, diagnosticRules_1.DiagnosticRule.reportSelfClsParameterName, localize_1.Localizer.Diagnostic.newClsParam(), node.parameters.length > 0 ? node.parameters[0] : node.name);
4618
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportSelfClsParameterName, localize_1.LocMessage.newClsParam(), node.parameters.length > 0 ? node.parameters[0] : node.name);
4675
4619
  }
4676
4620
  if (classType) {
4677
4621
  this._validateClsSelfParameterType(functionType, classType, /* isCls */ true);
@@ -4685,7 +4629,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4685
4629
  if (node.parameters.length > 0 && node.parameters[0].name) {
4686
4630
  const paramName = node.parameters[0].name.value;
4687
4631
  if (paramName === 'self' || paramName === 'cls') {
4688
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportSelfClsParameterName, diagnosticRules_1.DiagnosticRule.reportSelfClsParameterName, localize_1.Localizer.Diagnostic.staticClsSelfParam(), node.parameters[0].name);
4632
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportSelfClsParameterName, localize_1.LocMessage.staticClsSelfParam(), node.parameters[0].name);
4689
4633
  }
4690
4634
  }
4691
4635
  }
@@ -4699,7 +4643,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4699
4643
  // cases in the stdlib pyi files.
4700
4644
  if (paramName !== 'cls') {
4701
4645
  if (!this._fileInfo.isStubFile || (!paramName.startsWith('_') && paramName !== 'metacls')) {
4702
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportSelfClsParameterName, diagnosticRules_1.DiagnosticRule.reportSelfClsParameterName, localize_1.Localizer.Diagnostic.classMethodClsParam(), node.parameters.length > 0 ? node.parameters[0] : node.name);
4646
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportSelfClsParameterName, localize_1.LocMessage.classMethodClsParam(), node.parameters.length > 0 ? node.parameters[0] : node.name);
4703
4647
  }
4704
4648
  }
4705
4649
  if (classType) {
@@ -4743,7 +4687,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4743
4687
  // a parameter that cannot be positional.
4744
4688
  const isPrivateName = SymbolNameUtils.isPrivateOrProtectedName(paramName);
4745
4689
  if (!isLegalMetaclassName && !isPrivateName) {
4746
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportSelfClsParameterName, diagnosticRules_1.DiagnosticRule.reportSelfClsParameterName, localize_1.Localizer.Diagnostic.instanceMethodSelfParam(), node.parameters.length > 0 ? node.parameters[0] : node.name);
4690
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportSelfClsParameterName, localize_1.LocMessage.instanceMethodSelfParam(), node.parameters.length > 0 ? node.parameters[0] : node.name);
4747
4691
  }
4748
4692
  }
4749
4693
  }
@@ -4800,7 +4744,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4800
4744
  callNodeWalker.walk(node.suite);
4801
4745
  // If we didn't find a call to at least one base class, report the problem.
4802
4746
  if (!foundCallOfMember) {
4803
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportMissingSuperCall, diagnosticRules_1.DiagnosticRule.reportMissingSuperCall, localize_1.Localizer.Diagnostic.missingSuperCall().format({
4747
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportMissingSuperCall, localize_1.LocMessage.missingSuperCall().format({
4804
4748
  methodName: methodType.details.name,
4805
4749
  }), node.name);
4806
4750
  }
@@ -4856,7 +4800,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4856
4800
  if (!this._evaluator.assignType(paramType, expectedType, /* diag */ undefined, typeVarContext)) {
4857
4801
  // We exempt Never from this check because it has a legitimate use in this case.
4858
4802
  if (!(0, types_1.isNever)(paramType)) {
4859
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.clsSelfParamTypeMismatch().format({
4803
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.clsSelfParamTypeMismatch().format({
4860
4804
  name: paramInfo.name,
4861
4805
  classType: this._evaluator.printType(expectedType),
4862
4806
  }), paramInfo.typeAnnotation);
@@ -4897,7 +4841,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4897
4841
  return;
4898
4842
  }
4899
4843
  if ((0, types_1.isNever)(declaredReturnType)) {
4900
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.noReturnContainsYield(), node);
4844
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.noReturnContainsYield(), node);
4901
4845
  return;
4902
4846
  }
4903
4847
  const generatorTypeArgs = [yieldType, sendType !== null && sendType !== void 0 ? sendType : types_1.UnknownType.create(), types_1.UnknownType.create()];
@@ -4905,9 +4849,9 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4905
4849
  const diagAddendum = new diagnostic_1.DiagnosticAddendum();
4906
4850
  if (!this._evaluator.assignType(declaredReturnType, specializedGenerator, diagAddendum)) {
4907
4851
  const errorMessage = enclosingFunctionNode.isAsync
4908
- ? localize_1.Localizer.Diagnostic.generatorAsyncReturnType()
4909
- : localize_1.Localizer.Diagnostic.generatorSyncReturnType();
4910
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, errorMessage.format({ yieldType: this._evaluator.printType(yieldType) }) +
4852
+ ? localize_1.LocMessage.generatorAsyncReturnType()
4853
+ : localize_1.LocMessage.generatorSyncReturnType();
4854
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, errorMessage.format({ yieldType: this._evaluator.printType(yieldType) }) +
4911
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);
4912
4856
  }
4913
4857
  }
@@ -4965,7 +4909,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4965
4909
  return (0, typeUtils_1.derivesFromClassRecursive)(thisExceptType, previousExceptType, /* ignoreUnknown */ true);
4966
4910
  });
4967
4911
  if (subtype) {
4968
- diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.unreachableExcept().format({
4912
+ diagAddendum.addMessage(localize_1.LocAddendum.unreachableExcept().format({
4969
4913
  exceptionType: this._evaluator.printType((0, typeUtils_1.convertToInstance)(thisExceptType)),
4970
4914
  parentType: this._evaluator.printType((0, typeUtils_1.convertToInstance)(subtype)),
4971
4915
  }));
@@ -4974,7 +4918,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4974
4918
  });
4975
4919
  // Were all of the exception types overridden?
4976
4920
  if (typesOfThisExcept.length > 0 && typesOfThisExcept.length === overriddenExceptionCount) {
4977
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.unreachableExcept() + diagAddendum.getString(), except.typeExpression);
4921
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.unreachableExcept() + diagAddendum.getString(), except.typeExpression);
4978
4922
  this._evaluator.addUnreachableCode(except, except.exceptSuite);
4979
4923
  }
4980
4924
  }
@@ -4992,7 +4936,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4992
4936
  if (!importFromAs.alias) {
4993
4937
  const prevImport = symbolMap.get(importFromAs.name.value);
4994
4938
  if (prevImport) {
4995
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportDuplicateImport, diagnosticRules_1.DiagnosticRule.reportDuplicateImport, localize_1.Localizer.Diagnostic.duplicateImport().format({ importName: importFromAs.name.value }), importFromAs.name);
4939
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportDuplicateImport, localize_1.LocMessage.duplicateImport().format({ importName: importFromAs.name.value }), importFromAs.name);
4996
4940
  }
4997
4941
  else {
4998
4942
  symbolMap.set(importFromAs.name.value, importFromAs);
@@ -5005,7 +4949,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
5005
4949
  if (!importStatement.subnode.alias) {
5006
4950
  const prevImport = importModuleMap.get(importStatement.moduleName);
5007
4951
  if (prevImport) {
5008
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportDuplicateImport, diagnosticRules_1.DiagnosticRule.reportDuplicateImport, localize_1.Localizer.Diagnostic.duplicateImport().format({ importName: importStatement.moduleName }), importStatement.subnode);
4952
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportDuplicateImport, localize_1.LocMessage.duplicateImport().format({ importName: importStatement.moduleName }), importStatement.subnode);
5009
4953
  }
5010
4954
  else {
5011
4955
  importModuleMap.set(importStatement.moduleName, importStatement.subnode);
@@ -5026,12 +4970,12 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
5026
4970
  regionStack.pop();
5027
4971
  }
5028
4972
  else {
5029
- this._addDiagnosticForRegionComment(regionComment, localize_1.Localizer.Diagnostic.unmatchedEndregionComment());
4973
+ this._addDiagnosticForRegionComment(regionComment, localize_1.LocMessage.unmatchedEndregionComment());
5030
4974
  }
5031
4975
  }
5032
4976
  });
5033
4977
  regionStack.forEach((regionComment) => {
5034
- this._addDiagnosticForRegionComment(regionComment, localize_1.Localizer.Diagnostic.unmatchedRegionComment());
4978
+ this._addDiagnosticForRegionComment(regionComment, localize_1.LocMessage.unmatchedRegionComment());
5035
4979
  });
5036
4980
  }
5037
4981
  _addDiagnosticForRegionComment(regionComment, message) {