@zzzen/pyright-internal 1.2.0-dev.20240107 → 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 (245) 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 +2 -2
  5. package/dist/analyzer/checker.js +345 -351
  6. package/dist/analyzer/checker.js.map +1 -1
  7. package/dist/analyzer/codeFlowEngine.js +2 -2
  8. package/dist/analyzer/codeFlowEngine.js.map +1 -1
  9. package/dist/analyzer/commentUtils.js +7 -7
  10. package/dist/analyzer/commentUtils.js.map +1 -1
  11. package/dist/analyzer/constraintSolver.js +29 -30
  12. package/dist/analyzer/constraintSolver.js.map +1 -1
  13. package/dist/analyzer/constructorTransform.js +10 -11
  14. package/dist/analyzer/constructorTransform.js.map +1 -1
  15. package/dist/analyzer/constructors.d.ts +3 -3
  16. package/dist/analyzer/constructors.js +12 -14
  17. package/dist/analyzer/constructors.js.map +1 -1
  18. package/dist/analyzer/dataClasses.js +17 -17
  19. package/dist/analyzer/dataClasses.js.map +1 -1
  20. package/dist/analyzer/decorators.d.ts +1 -2
  21. package/dist/analyzer/decorators.js +13 -10
  22. package/dist/analyzer/decorators.js.map +1 -1
  23. package/dist/analyzer/enums.d.ts +4 -2
  24. package/dist/analyzer/enums.js +109 -50
  25. package/dist/analyzer/enums.js.map +1 -1
  26. package/dist/analyzer/functionTransform.js +1 -2
  27. package/dist/analyzer/functionTransform.js.map +1 -1
  28. package/dist/analyzer/importResolver.d.ts +2 -2
  29. package/dist/analyzer/importResolver.js +96 -27
  30. package/dist/analyzer/importResolver.js.map +1 -1
  31. package/dist/analyzer/namedTuples.js +8 -7
  32. package/dist/analyzer/namedTuples.js.map +1 -1
  33. package/dist/analyzer/operations.js +19 -21
  34. package/dist/analyzer/operations.js.map +1 -1
  35. package/dist/analyzer/parseTreeUtils.d.ts +1 -1
  36. package/dist/analyzer/parseTreeUtils.js +37 -0
  37. package/dist/analyzer/parseTreeUtils.js.map +1 -1
  38. package/dist/analyzer/patternMatching.js +26 -23
  39. package/dist/analyzer/patternMatching.js.map +1 -1
  40. package/dist/analyzer/program.js +18 -4
  41. package/dist/analyzer/program.js.map +1 -1
  42. package/dist/analyzer/properties.js +8 -8
  43. package/dist/analyzer/properties.js.map +1 -1
  44. package/dist/analyzer/protocols.js +37 -30
  45. package/dist/analyzer/protocols.js.map +1 -1
  46. package/dist/analyzer/service.d.ts +1 -1
  47. package/dist/analyzer/service.js +21 -20
  48. package/dist/analyzer/service.js.map +1 -1
  49. package/dist/analyzer/sourceFile.d.ts +2 -2
  50. package/dist/analyzer/sourceFile.js +17 -17
  51. package/dist/analyzer/sourceFile.js.map +1 -1
  52. package/dist/analyzer/sourceFileInfoUtils.js +1 -1
  53. package/dist/analyzer/sourceFileInfoUtils.js.map +1 -1
  54. package/dist/analyzer/typeEvaluator.js +1042 -875
  55. package/dist/analyzer/typeEvaluator.js.map +1 -1
  56. package/dist/analyzer/typeEvaluatorTypes.d.ts +12 -11
  57. package/dist/analyzer/typeEvaluatorTypes.js +2 -4
  58. package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
  59. package/dist/analyzer/typeGuards.js +16 -11
  60. package/dist/analyzer/typeGuards.js.map +1 -1
  61. package/dist/analyzer/typePrinter.js +3 -4
  62. package/dist/analyzer/typePrinter.js.map +1 -1
  63. package/dist/analyzer/typeUtils.d.ts +5 -2
  64. package/dist/analyzer/typeUtils.js +19 -0
  65. package/dist/analyzer/typeUtils.js.map +1 -1
  66. package/dist/analyzer/typedDicts.js +30 -34
  67. package/dist/analyzer/typedDicts.js.map +1 -1
  68. package/dist/analyzer/types.d.ts +12 -13
  69. package/dist/analyzer/types.js +49 -61
  70. package/dist/analyzer/types.js.map +1 -1
  71. package/dist/backgroundAnalysisBase.d.ts +12 -11
  72. package/dist/backgroundAnalysisBase.js +60 -64
  73. package/dist/backgroundAnalysisBase.js.map +1 -1
  74. package/dist/backgroundThreadBase.d.ts +6 -5
  75. package/dist/backgroundThreadBase.js +63 -60
  76. package/dist/backgroundThreadBase.js.map +1 -1
  77. package/dist/commands/quickActionCommand.js +1 -1
  78. package/dist/commands/quickActionCommand.js.map +1 -1
  79. package/dist/common/cancellationUtils.d.ts +6 -3
  80. package/dist/common/cancellationUtils.js +29 -5
  81. package/dist/common/cancellationUtils.js.map +1 -1
  82. package/dist/common/commandLineOptions.d.ts +1 -0
  83. package/dist/common/commandLineOptions.js.map +1 -1
  84. package/dist/common/commandUtils.d.ts +2 -0
  85. package/dist/common/commandUtils.js +24 -0
  86. package/dist/common/commandUtils.js.map +1 -0
  87. package/dist/common/configOptions.d.ts +1 -0
  88. package/dist/common/configOptions.js +13 -11
  89. package/dist/common/configOptions.js.map +1 -1
  90. package/dist/common/core.d.ts +1 -1
  91. package/dist/common/core.js.map +1 -1
  92. package/dist/common/extensibility.d.ts +7 -6
  93. package/dist/common/extensibility.js.map +1 -1
  94. package/dist/common/fileBasedCancellationUtils.js +19 -13
  95. package/dist/common/fileBasedCancellationUtils.js.map +1 -1
  96. package/dist/common/fullAccessHost.d.ts +1 -1
  97. package/dist/common/fullAccessHost.js +2 -2
  98. package/dist/common/fullAccessHost.js.map +1 -1
  99. package/dist/common/host.d.ts +2 -2
  100. package/dist/common/host.js.map +1 -1
  101. package/dist/common/realFileSystem.js +8 -8
  102. package/dist/common/realFileSystem.js.map +1 -1
  103. package/dist/common/serviceProvider.js +8 -1
  104. package/dist/common/serviceProvider.js.map +1 -1
  105. package/dist/common/uri/baseUri.d.ts +11 -3
  106. package/dist/common/uri/baseUri.js +54 -25
  107. package/dist/common/uri/baseUri.js.map +1 -1
  108. package/dist/common/uri/emptyUri.d.ts +9 -4
  109. package/dist/common/uri/emptyUri.js +22 -8
  110. package/dist/common/uri/emptyUri.js.map +1 -1
  111. package/dist/common/uri/fileUri.d.ts +14 -4
  112. package/dist/common/uri/fileUri.js +65 -9
  113. package/dist/common/uri/fileUri.js.map +1 -1
  114. package/dist/common/uri/memoization.js +1 -1
  115. package/dist/common/uri/memoization.js.map +1 -1
  116. package/dist/common/uri/uri.d.ts +9 -2
  117. package/dist/common/uri/uri.js +5 -2
  118. package/dist/common/uri/uri.js.map +1 -1
  119. package/dist/common/uri/uriUtils.d.ts +2 -0
  120. package/dist/common/uri/uriUtils.js +21 -4
  121. package/dist/common/uri/uriUtils.js.map +1 -1
  122. package/dist/common/uri/webUri.d.ts +8 -1
  123. package/dist/common/uri/webUri.js +59 -13
  124. package/dist/common/uri/webUri.js.map +1 -1
  125. package/dist/common/workspaceEditUtils.d.ts +6 -5
  126. package/dist/common/workspaceEditUtils.js +18 -17
  127. package/dist/common/workspaceEditUtils.js.map +1 -1
  128. package/dist/languageServerBase.d.ts +2 -0
  129. package/dist/languageServerBase.js +29 -25
  130. package/dist/languageServerBase.js.map +1 -1
  131. package/dist/languageService/analyzerServiceExecutor.d.ts +1 -2
  132. package/dist/languageService/analyzerServiceExecutor.js +8 -5
  133. package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
  134. package/dist/languageService/autoImporter.js +3 -3
  135. package/dist/languageService/autoImporter.js.map +1 -1
  136. package/dist/languageService/callHierarchyProvider.js +9 -7
  137. package/dist/languageService/callHierarchyProvider.js.map +1 -1
  138. package/dist/languageService/codeActionProvider.js +3 -2
  139. package/dist/languageService/codeActionProvider.js.map +1 -1
  140. package/dist/languageService/completionProvider.d.ts +2 -4
  141. package/dist/languageService/completionProvider.js +14 -18
  142. package/dist/languageService/completionProvider.js.map +1 -1
  143. package/dist/languageService/documentSymbolProvider.js +5 -4
  144. package/dist/languageService/documentSymbolProvider.js.map +1 -1
  145. package/dist/languageService/navigationUtils.js +2 -1
  146. package/dist/languageService/navigationUtils.js.map +1 -1
  147. package/dist/languageService/renameProvider.js +2 -2
  148. package/dist/languageService/renameProvider.js.map +1 -1
  149. package/dist/languageService/workspaceSymbolProvider.js +2 -1
  150. package/dist/languageService/workspaceSymbolProvider.js.map +1 -1
  151. package/dist/localization/localize.d.ts +10 -9
  152. package/dist/localization/localize.js +9 -5
  153. package/dist/localization/localize.js.map +1 -1
  154. package/dist/localization/package.nls.cs.json +50 -9
  155. package/dist/localization/package.nls.de.json +51 -10
  156. package/dist/localization/package.nls.en-us.json +11 -9
  157. package/dist/localization/package.nls.es.json +51 -10
  158. package/dist/localization/package.nls.fr.json +50 -9
  159. package/dist/localization/package.nls.it.json +51 -10
  160. package/dist/localization/package.nls.ja.json +51 -10
  161. package/dist/localization/package.nls.ko.json +51 -10
  162. package/dist/localization/package.nls.pl.json +51 -10
  163. package/dist/localization/package.nls.pt-br.json +51 -10
  164. package/dist/localization/package.nls.qps-ploc.json +51 -10
  165. package/dist/localization/package.nls.ru.json +50 -9
  166. package/dist/localization/package.nls.tr.json +51 -10
  167. package/dist/localization/package.nls.zh-cn.json +51 -10
  168. package/dist/localization/package.nls.zh-tw.json +51 -10
  169. package/dist/parser/parser.d.ts +1 -4
  170. package/dist/parser/parser.js +201 -201
  171. package/dist/parser/parser.js.map +1 -1
  172. package/dist/parser/tokenizer.d.ts +2 -4
  173. package/dist/parser/tokenizer.js +5 -6
  174. package/dist/parser/tokenizer.js.map +1 -1
  175. package/dist/parser/tokenizerTypes.d.ts +2 -2
  176. package/dist/parser/tokenizerTypes.js.map +1 -1
  177. package/dist/pyright.js +11 -9
  178. package/dist/pyright.js.map +1 -1
  179. package/dist/pyrightFileSystem.js +2 -2
  180. package/dist/server.js +7 -5
  181. package/dist/server.js.map +1 -1
  182. package/dist/tests/chainedSourceFiles.test.js +8 -8
  183. package/dist/tests/chainedSourceFiles.test.js.map +1 -1
  184. package/dist/tests/completions.test.js +3 -3
  185. package/dist/tests/completions.test.js.map +1 -1
  186. package/dist/tests/config.test.js +14 -6
  187. package/dist/tests/config.test.js.map +1 -1
  188. package/dist/tests/filesystem.test.js +6 -6
  189. package/dist/tests/filesystem.test.js.map +1 -1
  190. package/dist/tests/fourSlashParser.test.js +23 -9
  191. package/dist/tests/fourSlashParser.test.js.map +1 -1
  192. package/dist/tests/fourslash/rename.multipleDecl.fourslash.d.ts +1 -1
  193. package/dist/tests/harness/fourslash/fourSlashParser.js +4 -0
  194. package/dist/tests/harness/fourslash/fourSlashParser.js.map +1 -1
  195. package/dist/tests/harness/fourslash/fourSlashTypes.d.ts +3 -0
  196. package/dist/tests/harness/fourslash/fourSlashTypes.js.map +1 -1
  197. package/dist/tests/harness/fourslash/testLanguageService.js +2 -0
  198. package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
  199. package/dist/tests/harness/fourslash/testState.d.ts +13 -0
  200. package/dist/tests/harness/fourslash/testState.js +14 -8
  201. package/dist/tests/harness/fourslash/testState.js.map +1 -1
  202. package/dist/tests/harness/vfs/factory.d.ts +1 -1
  203. package/dist/tests/harness/vfs/factory.js +4 -4
  204. package/dist/tests/harness/vfs/factory.js.map +1 -1
  205. package/dist/tests/importStatementUtils.test.js +1 -1
  206. package/dist/tests/importStatementUtils.test.js.map +1 -1
  207. package/dist/tests/ipythonMode.test.js +21 -22
  208. package/dist/tests/ipythonMode.test.js.map +1 -1
  209. package/dist/tests/localizer.test.js +2 -2
  210. package/dist/tests/localizer.test.js.map +1 -1
  211. package/dist/tests/serialization.test.d.ts +2 -0
  212. package/dist/tests/serialization.test.js +88 -0
  213. package/dist/tests/serialization.test.js.map +1 -0
  214. package/dist/tests/service.test.js +1 -1
  215. package/dist/tests/service.test.js.map +1 -1
  216. package/dist/tests/signatureHelp.test.js +2 -3
  217. package/dist/tests/signatureHelp.test.js.map +1 -1
  218. package/dist/tests/sourceFile.test.js +3 -3
  219. package/dist/tests/sourceFile.test.js.map +1 -1
  220. package/dist/tests/sourceMapperUtils.test.js +2 -2
  221. package/dist/tests/sourceMapperUtils.test.js.map +1 -1
  222. package/dist/tests/testState.test.js +1 -1
  223. package/dist/tests/testState.test.js.map +1 -1
  224. package/dist/tests/testStateUtils.js +2 -2
  225. package/dist/tests/testStateUtils.js.map +1 -1
  226. package/dist/tests/textEditUtil.test.js +1 -2
  227. package/dist/tests/textEditUtil.test.js.map +1 -1
  228. package/dist/tests/typeEvaluator1.test.js +15 -3
  229. package/dist/tests/typeEvaluator1.test.js.map +1 -1
  230. package/dist/tests/typeEvaluator2.test.js +12 -8
  231. package/dist/tests/typeEvaluator2.test.js.map +1 -1
  232. package/dist/tests/typeEvaluator3.test.js +24 -6
  233. package/dist/tests/typeEvaluator3.test.js.map +1 -1
  234. package/dist/tests/typeEvaluator4.test.js +5 -5
  235. package/dist/tests/typeEvaluator4.test.js.map +1 -1
  236. package/dist/tests/typeEvaluator5.test.js +4 -0
  237. package/dist/tests/typeEvaluator5.test.js.map +1 -1
  238. package/dist/tests/uri.test.js +95 -15
  239. package/dist/tests/uri.test.js.map +1 -1
  240. package/dist/tests/workspaceEditUtils.test.js +8 -8
  241. package/dist/tests/workspaceEditUtils.test.js.map +1 -1
  242. package/dist/workspaceFactory.d.ts +1 -0
  243. package/dist/workspaceFactory.js +2 -1
  244. package/dist/workspaceFactory.js.map +1 -1
  245. package/package.json +2 -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
  }
@@ -1954,18 +1960,19 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1954
1960
  else if ((0, types_1.isClassInstance)(exceptionType)) {
1955
1961
  const iterableType = (_b = (_a = this._evaluator.getTypeOfIterator({ type: exceptionType }, /* isAsync */ false, errorNode)) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : types_1.UnknownType.create();
1956
1962
  resultingExceptionType = (0, typeUtils_1.mapSubtypes)(iterableType, (subtype) => {
1963
+ subtype = this._evaluator.makeTopLevelTypeVarsConcrete(subtype);
1957
1964
  if ((0, types_1.isAnyOrUnknown)(subtype) || (0, types_1.isNever)(subtype)) {
1958
1965
  return subtype;
1959
1966
  }
1960
1967
  if ((0, types_1.isInstantiableClass)(subtype)) {
1961
1968
  if (!derivesFromBaseException(subtype)) {
1962
- diagAddendum.addMessage(localize_1.Localizer.Diagnostic.exceptionTypeIncorrect().format({
1969
+ diagAddendum.addMessage(localize_1.LocMessage.exceptionTypeIncorrect().format({
1963
1970
  type: this._evaluator.printType(exceptionType),
1964
1971
  }));
1965
1972
  }
1966
1973
  return types_1.ClassType.cloneAsInstance(subtype);
1967
1974
  }
1968
- diagAddendum.addMessage(localize_1.Localizer.Diagnostic.exceptionTypeIncorrect().format({
1975
+ diagAddendum.addMessage(localize_1.LocMessage.exceptionTypeIncorrect().format({
1969
1976
  type: this._evaluator.printType(exceptionType),
1970
1977
  }));
1971
1978
  return types_1.UnknownType.create();
@@ -1973,7 +1980,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1973
1980
  }
1974
1981
  }
1975
1982
  if (!diagAddendum.isEmpty()) {
1976
- this._evaluator.addError(localize_1.Localizer.Diagnostic.exceptionTypeNotClass().format({
1983
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.exceptionTypeNotClass().format({
1977
1984
  type: this._evaluator.printType(exceptionType),
1978
1985
  }), errorNode);
1979
1986
  }
@@ -1990,7 +1997,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
1990
1997
  }
1991
1998
  nodes.forEach((node) => {
1992
1999
  if (!moduleScope.symbolTable.has(node.value)) {
1993
- 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);
1994
2001
  }
1995
2002
  });
1996
2003
  }
@@ -2040,7 +2047,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2040
2047
  : [];
2041
2048
  if (overloadedFunctions.length === 1) {
2042
2049
  // There should never be a single overload.
2043
- 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);
2044
2051
  }
2045
2052
  // If the file is not a stub and this is the first overload,
2046
2053
  // verify that there is an implementation.
@@ -2072,7 +2079,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2072
2079
  // If this is a method within a protocol class, don't require that
2073
2080
  // there is an implementation.
2074
2081
  if (!exemptMissingImplementation) {
2075
- 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({
2076
2083
  name: primaryDecl.node.name.value,
2077
2084
  }), primaryDecl.node.name);
2078
2085
  }
@@ -2084,12 +2091,12 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2084
2091
  const diag = new diagnostic_1.DiagnosticAddendum();
2085
2092
  if (!this._isLegalOverloadImplementation(overload, implementationFunction, diag)) {
2086
2093
  if (implementationFunction.details.declaration) {
2087
- 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({
2088
2095
  name,
2089
2096
  index: index + 1,
2090
2097
  }) + diag.getString(), implementationFunction.details.declaration.node.name);
2091
2098
  if (diagnostic && overload.details.declaration) {
2092
- 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);
2093
2100
  }
2094
2101
  }
2095
2102
  }
@@ -2109,7 +2116,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2109
2116
  decls.forEach((decl) => {
2110
2117
  if (this._evaluator.isFinalVariableDeclaration(decl)) {
2111
2118
  if (sawFinal) {
2112
- 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);
2113
2120
  }
2114
2121
  sawFinal = true;
2115
2122
  }
@@ -2120,7 +2127,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2120
2127
  // the assignment is within an `__init__` method, so ignore class
2121
2128
  // scopes here.
2122
2129
  if (scopeType !== 2 /* ScopeType.Class */) {
2123
- 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);
2124
2131
  }
2125
2132
  }
2126
2133
  sawAssignment = true;
@@ -2152,7 +2159,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2152
2159
  }
2153
2160
  }
2154
2161
  if (!isImplicitlyAssigned && !isProtocolClass) {
2155
- 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);
2156
2163
  }
2157
2164
  }
2158
2165
  }
@@ -2164,7 +2171,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2164
2171
  if (typeAliasDecl && decls.length > 1) {
2165
2172
  decls.forEach((decl) => {
2166
2173
  if (decl !== typeAliasDecl) {
2167
- 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);
2168
2175
  }
2169
2176
  });
2170
2177
  }
@@ -2220,26 +2227,26 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2220
2227
  let primaryDeclInfo;
2221
2228
  if (primaryDecl.type === 5 /* DeclarationType.Function */) {
2222
2229
  if (primaryDecl.isMethod) {
2223
- primaryDeclInfo = localize_1.Localizer.DiagnosticAddendum.seeMethodDeclaration();
2230
+ primaryDeclInfo = localize_1.LocAddendum.seeMethodDeclaration();
2224
2231
  }
2225
2232
  else {
2226
- primaryDeclInfo = localize_1.Localizer.DiagnosticAddendum.seeFunctionDeclaration();
2233
+ primaryDeclInfo = localize_1.LocAddendum.seeFunctionDeclaration();
2227
2234
  }
2228
2235
  }
2229
2236
  else if (primaryDecl.type === 6 /* DeclarationType.Class */) {
2230
- primaryDeclInfo = localize_1.Localizer.DiagnosticAddendum.seeClassDeclaration();
2237
+ primaryDeclInfo = localize_1.LocAddendum.seeClassDeclaration();
2231
2238
  }
2232
2239
  else if (primaryDecl.type === 2 /* DeclarationType.Parameter */) {
2233
- primaryDeclInfo = localize_1.Localizer.DiagnosticAddendum.seeParameterDeclaration();
2240
+ primaryDeclInfo = localize_1.LocAddendum.seeParameterDeclaration();
2234
2241
  }
2235
2242
  else if (primaryDecl.type === 1 /* DeclarationType.Variable */) {
2236
- primaryDeclInfo = localize_1.Localizer.DiagnosticAddendum.seeVariableDeclaration();
2243
+ primaryDeclInfo = localize_1.LocAddendum.seeVariableDeclaration();
2237
2244
  }
2238
2245
  else if (primaryDecl.type === 4 /* DeclarationType.TypeAlias */) {
2239
- primaryDeclInfo = localize_1.Localizer.DiagnosticAddendum.seeTypeAliasDeclaration();
2246
+ primaryDeclInfo = localize_1.LocAddendum.seeTypeAliasDeclaration();
2240
2247
  }
2241
2248
  else {
2242
- primaryDeclInfo = localize_1.Localizer.DiagnosticAddendum.seeDeclaration();
2249
+ primaryDeclInfo = localize_1.LocAddendum.seeDeclaration();
2243
2250
  }
2244
2251
  const addPrimaryDeclInfo = (diag) => {
2245
2252
  if (diag) {
@@ -2272,7 +2279,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2272
2279
  duplicateIsOk = true;
2273
2280
  }
2274
2281
  if (!duplicateIsOk) {
2275
- 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);
2276
2283
  addPrimaryDeclInfo(diag);
2277
2284
  }
2278
2285
  }
@@ -2305,9 +2312,9 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2305
2312
  duplicateIsOk = true;
2306
2313
  }
2307
2314
  if (!duplicateIsOk) {
2308
- const diag = this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, otherDecl.isMethod
2309
- ? localize_1.Localizer.Diagnostic.obscuredMethodDeclaration().format({ name })
2310
- : 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);
2311
2318
  addPrimaryDeclInfo(diag);
2312
2319
  }
2313
2320
  }
@@ -2320,8 +2327,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2320
2327
  duplicateIsOk = true;
2321
2328
  }
2322
2329
  if (!duplicateIsOk) {
2323
- const message = localize_1.Localizer.Diagnostic.obscuredParameterDeclaration();
2324
- 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);
2325
2332
  addPrimaryDeclInfo(diag);
2326
2333
  }
2327
2334
  }
@@ -2342,14 +2349,14 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2342
2349
  duplicateIsOk = true;
2343
2350
  }
2344
2351
  if (!duplicateIsOk) {
2345
- 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);
2346
2353
  addPrimaryDeclInfo(diag);
2347
2354
  }
2348
2355
  }
2349
2356
  }
2350
2357
  }
2351
2358
  else if (otherDecl.type === 4 /* DeclarationType.TypeAlias */) {
2352
- 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);
2353
2360
  addPrimaryDeclInfo(diag);
2354
2361
  }
2355
2362
  }
@@ -2403,8 +2410,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2403
2410
  const multipartName = nameParts.map((np) => np.value).join('.');
2404
2411
  let textRange = { start: nameParts[0].start, length: nameParts[0].length };
2405
2412
  textRange = textRange_1.TextRange.extend(textRange, nameParts[nameParts.length - 1]);
2406
- this._fileInfo.diagnosticSink.addUnusedCodeWithTextRange(localize_1.Localizer.Diagnostic.unaccessedSymbol().format({ name: multipartName }), textRange, { action: "pyright.unusedImport" /* Commands.unusedImport */ });
2407
- 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);
2408
2415
  return;
2409
2416
  }
2410
2417
  }
@@ -2422,7 +2429,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2422
2429
  }
2423
2430
  }
2424
2431
  if (nameNode) {
2425
- message = localize_1.Localizer.Diagnostic.unaccessedImport().format({ name: nameNode.value });
2432
+ message = localize_1.LocMessage.unaccessedImport().format({ name: nameNode.value });
2426
2433
  }
2427
2434
  break;
2428
2435
  case 4 /* DeclarationType.TypeAlias */:
@@ -2452,7 +2459,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2452
2459
  }
2453
2460
  if (nameNode) {
2454
2461
  rule = diagnosticRules_1.DiagnosticRule.reportUnusedVariable;
2455
- message = localize_1.Localizer.Diagnostic.unaccessedVariable().format({ name: nameNode.value });
2462
+ message = localize_1.LocMessage.unaccessedVariable().format({ name: nameNode.value });
2456
2463
  }
2457
2464
  break;
2458
2465
  case 6 /* DeclarationType.Class */:
@@ -2467,7 +2474,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2467
2474
  diagnosticLevel = this._fileInfo.diagnosticRuleSet.reportUnusedClass;
2468
2475
  nameNode = decl.node.name;
2469
2476
  rule = diagnosticRules_1.DiagnosticRule.reportUnusedClass;
2470
- message = localize_1.Localizer.Diagnostic.unaccessedClass().format({ name: nameNode.value });
2477
+ message = localize_1.LocMessage.unaccessedClass().format({ name: nameNode.value });
2471
2478
  break;
2472
2479
  case 5 /* DeclarationType.Function */:
2473
2480
  if (!isPrivate) {
@@ -2481,7 +2488,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2481
2488
  diagnosticLevel = this._fileInfo.diagnosticRuleSet.reportUnusedFunction;
2482
2489
  nameNode = decl.node.name;
2483
2490
  rule = diagnosticRules_1.DiagnosticRule.reportUnusedFunction;
2484
- message = localize_1.Localizer.Diagnostic.unaccessedFunction().format({ name: nameNode.value });
2491
+ message = localize_1.LocMessage.unaccessedFunction().format({ name: nameNode.value });
2485
2492
  break;
2486
2493
  case 3 /* DeclarationType.TypeParameter */:
2487
2494
  // Never report a diagnostic for an unused TypeParameter.
@@ -2496,9 +2503,9 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2496
2503
  }
2497
2504
  const action = rule === diagnosticRules_1.DiagnosticRule.reportUnusedImport ? { action: "pyright.unusedImport" /* Commands.unusedImport */ } : undefined;
2498
2505
  if (nameNode) {
2499
- this._fileInfo.diagnosticSink.addUnusedCodeWithTextRange(localize_1.Localizer.Diagnostic.unaccessedSymbol().format({ name: nameNode.value }), nameNode, action);
2500
- if (rule !== undefined && message) {
2501
- 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);
2502
2509
  }
2503
2510
  }
2504
2511
  }
@@ -2540,11 +2547,11 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2540
2547
  }
2541
2548
  });
2542
2549
  if (!isValidType) {
2543
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, isInstanceCheck
2544
- ? localize_1.Localizer.Diagnostic.isInstanceInvalidType().format({
2550
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, isInstanceCheck
2551
+ ? localize_1.LocMessage.isInstanceInvalidType().format({
2545
2552
  type: this._evaluator.printType(arg1Type),
2546
2553
  }) + diag.getString()
2547
- : localize_1.Localizer.Diagnostic.isSubclassInvalidType().format({
2554
+ : localize_1.LocMessage.isSubclassInvalidType().format({
2548
2555
  type: this._evaluator.printType(arg1Type),
2549
2556
  }) + diag.getString(), node.arguments[1]);
2550
2557
  }
@@ -2553,16 +2560,19 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2553
2560
  if (!isInstanceCheck) {
2554
2561
  const diag = new diagnostic_1.DiagnosticAddendum();
2555
2562
  (0, typeUtils_1.doForEachSubtype)(arg1Type, (arg1Subtype) => {
2556
- if ((0, types_1.isInstantiableClass)(arg1Subtype) &&
2557
- types_1.ClassType.isProtocolClass(arg1Subtype) &&
2558
- !(0, protocols_1.isMethodOnlyProtocol)(arg1Subtype)) {
2559
- diag.addMessage(localize_1.Localizer.DiagnosticAddendum.dataProtocolUnsupported().format({
2560
- name: arg1Subtype.details.name,
2561
- }));
2563
+ if ((0, types_1.isClassInstance)(arg1Subtype) &&
2564
+ types_1.ClassType.isTupleClass(arg1Subtype) &&
2565
+ arg1Subtype.tupleTypeArguments) {
2566
+ arg1Subtype.tupleTypeArguments.forEach((typeArg) => {
2567
+ this._validateNotDataProtocol(typeArg.type, diag);
2568
+ });
2569
+ }
2570
+ else {
2571
+ this._validateNotDataProtocol(arg1Subtype, diag);
2562
2572
  }
2563
2573
  });
2564
2574
  if (!diag.isEmpty()) {
2565
- 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]);
2566
2576
  }
2567
2577
  }
2568
2578
  // If this call is within an assert statement, we won't check whether
@@ -2720,12 +2730,12 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2720
2730
  // If arg1IncludesSubclasses is true, it contains a Type[X] class rather than X. A Type[X]
2721
2731
  // could be a subclass of X, so the "unnecessary isinstance check" may be legit.
2722
2732
  if (!arg1IncludesSubclasses && (0, types_1.isTypeSame)(filteredType, arg0Type, { ignorePseudoGeneric: true })) {
2723
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportUnnecessaryIsInstance, diagnosticRules_1.DiagnosticRule.reportUnnecessaryIsInstance, isInstanceCheck
2724
- ? localize_1.Localizer.Diagnostic.unnecessaryIsInstanceAlways().format({
2733
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportUnnecessaryIsInstance, isInstanceCheck
2734
+ ? localize_1.LocMessage.unnecessaryIsInstanceAlways().format({
2725
2735
  testType: this._evaluator.printType(arg0Type),
2726
2736
  classType: this._evaluator.printType(getTestType()),
2727
2737
  })
2728
- : localize_1.Localizer.Diagnostic.unnecessaryIsSubclassAlways().format({
2738
+ : localize_1.LocMessage.unnecessaryIsSubclassAlways().format({
2729
2739
  testType: this._evaluator.printType(arg0Type),
2730
2740
  classType: this._evaluator.printType(getTestType()),
2731
2741
  }), node);
@@ -2741,14 +2751,14 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2741
2751
  if ((0, types_1.isClassInstance)(testSubtype)) {
2742
2752
  if ((0, protocols_1.isProtocolUnsafeOverlap)(this._evaluator, protocol, testSubtype)) {
2743
2753
  isUnsafeOverlap = true;
2744
- diag.addMessage(localize_1.Localizer.DiagnosticAddendum.protocolUnsafeOverlap().format({
2754
+ diag.addMessage(localize_1.LocAddendum.protocolUnsafeOverlap().format({
2745
2755
  name: testSubtype.details.name,
2746
2756
  }));
2747
2757
  }
2748
2758
  }
2749
2759
  });
2750
2760
  if (isUnsafeOverlap) {
2751
- 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({
2752
2762
  name: protocol.details.name,
2753
2763
  }) + diag.getString(), errorNode);
2754
2764
  }
@@ -2761,6 +2771,11 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2761
2771
  (0, typeUtils_1.doForEachSubtype)(type, (subtype) => {
2762
2772
  subtype = this._evaluator.makeTopLevelTypeVarsConcrete(subtype);
2763
2773
  subtype = (0, typeUtils_1.transformPossibleRecursiveTypeAlias)(subtype);
2774
+ if (subtype.specialForm && types_1.ClassType.isBuiltIn(subtype.specialForm, 'TypeAliasType')) {
2775
+ diag.addMessage(localize_1.LocAddendum.typeAliasInstanceCheck());
2776
+ isSupported = false;
2777
+ return;
2778
+ }
2764
2779
  switch (subtype.category) {
2765
2780
  case 2 /* TypeCategory.Any */:
2766
2781
  case 1 /* TypeCategory.Unknown */:
@@ -2768,17 +2783,17 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2768
2783
  break;
2769
2784
  case 6 /* TypeCategory.Class */:
2770
2785
  if ((0, typeUtils_1.isNoneInstance)(subtype)) {
2771
- diag.addMessage(localize_1.Localizer.DiagnosticAddendum.noneNotAllowed());
2786
+ diag.addMessage(localize_1.LocAddendum.noneNotAllowed());
2772
2787
  isSupported = false;
2773
2788
  }
2774
2789
  else if (types_1.ClassType.isTypedDictClass(subtype)) {
2775
- diag.addMessage(localize_1.Localizer.DiagnosticAddendum.typedDictClassNotAllowed());
2790
+ diag.addMessage(localize_1.LocAddendum.typedDictClassNotAllowed());
2776
2791
  isSupported = false;
2777
2792
  }
2778
2793
  else if (subtype.isTypeArgumentExplicit && !subtype.includeSubclasses) {
2779
2794
  // If it's a class, make sure that it has not been given explicit
2780
2795
  // type arguments. This will result in a TypeError exception.
2781
- diag.addMessage(localize_1.Localizer.DiagnosticAddendum.genericClassNotAllowed());
2796
+ diag.addMessage(localize_1.LocAddendum.genericClassNotAllowed());
2782
2797
  isSupported = false;
2783
2798
  }
2784
2799
  else if (types_1.ClassType.isProtocolClass(subtype) &&
@@ -2787,28 +2802,35 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2787
2802
  // According to PEP 544, protocol classes cannot be used as the right-hand
2788
2803
  // argument to isinstance or issubclass unless they are annotated as
2789
2804
  // "runtime checkable".
2790
- diag.addMessage(localize_1.Localizer.DiagnosticAddendum.protocolRequiresRuntimeCheckable());
2805
+ diag.addMessage(localize_1.LocAddendum.protocolRequiresRuntimeCheckable());
2791
2806
  isSupported = false;
2792
2807
  }
2793
2808
  else if (types_1.ClassType.isNewTypeClass(subtype)) {
2794
- diag.addMessage(localize_1.Localizer.DiagnosticAddendum.newTypeClassNotAllowed());
2809
+ diag.addMessage(localize_1.LocAddendum.newTypeClassNotAllowed());
2795
2810
  isSupported = false;
2796
2811
  }
2797
2812
  break;
2798
2813
  case 4 /* TypeCategory.Function */:
2799
2814
  if (!types_1.TypeBase.isInstantiable(subtype) || subtype.isCallableWithTypeArgs) {
2800
- diag.addMessage(localize_1.Localizer.DiagnosticAddendum.genericClassNotAllowed());
2815
+ diag.addMessage(localize_1.LocAddendum.genericClassNotAllowed());
2801
2816
  isSupported = false;
2802
2817
  }
2803
2818
  break;
2804
2819
  case 9 /* TypeCategory.TypeVar */:
2805
- diag.addMessage(localize_1.Localizer.DiagnosticAddendum.typeVarNotAllowed());
2820
+ diag.addMessage(localize_1.LocAddendum.typeVarNotAllowed());
2806
2821
  isSupported = false;
2807
2822
  break;
2808
2823
  }
2809
2824
  });
2810
2825
  return isSupported;
2811
2826
  }
2827
+ _validateNotDataProtocol(type, diag) {
2828
+ if ((0, types_1.isInstantiableClass)(type) && types_1.ClassType.isProtocolClass(type) && !(0, protocols_1.isMethodOnlyProtocol)(type)) {
2829
+ diag.addMessage(localize_1.LocAddendum.dataProtocolUnsupported().format({
2830
+ name: type.details.name,
2831
+ }));
2832
+ }
2833
+ }
2812
2834
  _isSymbolPrivate(nameValue, scopeType) {
2813
2835
  // All variables within the scope of a function or a list
2814
2836
  // comprehension are considered private.
@@ -2831,30 +2853,30 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2831
2853
  !types_1.ClassType.isClassProperty(functionTypeResult.decoratedType)) {
2832
2854
  return;
2833
2855
  }
2834
- this._reportDeprecatedDiagnostic(node.name, localize_1.Localizer.Diagnostic.classPropertyDeprecated());
2856
+ this._reportDeprecatedDiagnostic(node.name, localize_1.LocMessage.classPropertyDeprecated());
2835
2857
  }
2836
2858
  _reportDeprecatedUseForMemberAccess(node, info) {
2837
2859
  let errorMessage;
2838
2860
  if (info.accessType === 'property') {
2839
2861
  if (info.accessMethod === 'get') {
2840
- errorMessage = localize_1.Localizer.Diagnostic.deprecatedPropertyGetter().format({ name: node.value });
2862
+ errorMessage = localize_1.LocMessage.deprecatedPropertyGetter().format({ name: node.value });
2841
2863
  }
2842
2864
  else if (info.accessMethod === 'set') {
2843
- errorMessage = localize_1.Localizer.Diagnostic.deprecatedPropertySetter().format({ name: node.value });
2865
+ errorMessage = localize_1.LocMessage.deprecatedPropertySetter().format({ name: node.value });
2844
2866
  }
2845
2867
  else {
2846
- errorMessage = localize_1.Localizer.Diagnostic.deprecatedPropertyDeleter().format({ name: node.value });
2868
+ errorMessage = localize_1.LocMessage.deprecatedPropertyDeleter().format({ name: node.value });
2847
2869
  }
2848
2870
  }
2849
2871
  else if (info.accessType === 'descriptor') {
2850
2872
  if (info.accessMethod === 'get') {
2851
- errorMessage = localize_1.Localizer.Diagnostic.deprecatedDescriptorGetter().format({ name: node.value });
2873
+ errorMessage = localize_1.LocMessage.deprecatedDescriptorGetter().format({ name: node.value });
2852
2874
  }
2853
2875
  else if (info.accessMethod === 'set') {
2854
- errorMessage = localize_1.Localizer.Diagnostic.deprecatedDescriptorSetter().format({ name: node.value });
2876
+ errorMessage = localize_1.LocMessage.deprecatedDescriptorSetter().format({ name: node.value });
2855
2877
  }
2856
2878
  else {
2857
- errorMessage = localize_1.Localizer.Diagnostic.deprecatedDescriptorDeleter().format({ name: node.value });
2879
+ errorMessage = localize_1.LocMessage.deprecatedDescriptorDeleter().format({ name: node.value });
2858
2880
  }
2859
2881
  }
2860
2882
  if (errorMessage) {
@@ -2874,13 +2896,13 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2874
2896
  const containingClass = ParseTreeUtils.getEnclosingClass(functionType.details.declaration.node,
2875
2897
  /* stopAtFunction */ true);
2876
2898
  if (containingClass) {
2877
- return localize_1.Localizer.Diagnostic.deprecatedMethod().format({
2899
+ return localize_1.LocMessage.deprecatedMethod().format({
2878
2900
  name: functionType.details.name || '<anonymous>',
2879
2901
  className: containingClass.name.value,
2880
2902
  });
2881
2903
  }
2882
2904
  }
2883
- return localize_1.Localizer.Diagnostic.deprecatedFunction().format({
2905
+ return localize_1.LocMessage.deprecatedFunction().format({
2884
2906
  name: functionType.details.name,
2885
2907
  });
2886
2908
  }
@@ -2911,7 +2933,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2911
2933
  }
2912
2934
  else if ((0, types_1.isInstantiableClass)(type) && overload.details.name === '__init__') {
2913
2935
  deprecatedMessage = overload.details.deprecatedMessage;
2914
- errorMessage = localize_1.Localizer.Diagnostic.deprecatedConstructor().format({
2936
+ errorMessage = localize_1.LocMessage.deprecatedConstructor().format({
2915
2937
  name: type.details.name,
2916
2938
  });
2917
2939
  }
@@ -2925,7 +2947,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2925
2947
  subtype.details.deprecatedMessage !== undefined &&
2926
2948
  node.value === subtype.details.name) {
2927
2949
  deprecatedMessage = subtype.details.deprecatedMessage;
2928
- errorMessage = localize_1.Localizer.Diagnostic.deprecatedClass().format({ name: subtype.details.name });
2950
+ errorMessage = localize_1.LocMessage.deprecatedClass().format({ name: subtype.details.name });
2929
2951
  }
2930
2952
  else {
2931
2953
  // See if this is part of a call to a constructor.
@@ -2968,13 +2990,13 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2968
2990
  if (this._fileInfo.executionEnvironment.pythonVersion >= deprecatedForm.version) {
2969
2991
  if (!deprecatedForm.typingImportOnly || isImportFromTyping) {
2970
2992
  if (this._fileInfo.diagnosticRuleSet.reportDeprecated === 'none') {
2971
- this._evaluator.addDeprecated(localize_1.Localizer.Diagnostic.deprecatedType().format({
2993
+ this._evaluator.addDeprecated(localize_1.LocMessage.deprecatedType().format({
2972
2994
  version: (0, pythonVersion_1.versionToString)(deprecatedForm.version),
2973
2995
  replacement: deprecatedForm.replacementText,
2974
2996
  }), node);
2975
2997
  }
2976
2998
  else {
2977
- 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({
2978
3000
  version: (0, pythonVersion_1.versionToString)(deprecatedForm.version),
2979
3001
  replacement: deprecatedForm.replacementText,
2980
3002
  }), node);
@@ -2994,7 +3016,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
2994
3016
  this._evaluator.addDeprecated(diagnosticMessage + diag.getString(), node);
2995
3017
  }
2996
3018
  else {
2997
- 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);
2998
3020
  }
2999
3021
  }
3000
3022
  _reportUnboundName(node) {
@@ -3005,10 +3027,10 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3005
3027
  const type = this._evaluator.getType(node);
3006
3028
  if (type) {
3007
3029
  if ((0, types_1.isUnbound)(type)) {
3008
- 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);
3009
3031
  }
3010
3032
  else if ((0, types_1.isPossiblyUnbound)(type)) {
3011
- 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);
3012
3034
  }
3013
3035
  }
3014
3036
  }
@@ -3029,7 +3051,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3029
3051
  this._importResolver.isStdlibModule(desc, this._fileInfo.executionEnvironment) &&
3030
3052
  this._sourceMapper.isUserCode(this._fileInfo.fileUri)) {
3031
3053
  // This means the user has a module that is overwriting the stdlib module.
3032
- 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({
3033
3055
  name: moduleName,
3034
3056
  path: this._fileInfo.fileUri.toUserVisibleString(),
3035
3057
  }), this._moduleNode);
@@ -3080,7 +3102,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3080
3102
  paths.forEach((p) => {
3081
3103
  if (!p.startsWith(stdlibPath) && !(0, sourceMapper_1.isStubFile)(p) && this._sourceMapper.isUserCode(p)) {
3082
3104
  // This means the user has a module that is overwriting the stdlib module.
3083
- 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({
3084
3106
  name: nameParts.join('.'),
3085
3107
  path: p.toUserVisibleString(),
3086
3108
  }), node);
@@ -3184,10 +3206,10 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3184
3206
  }
3185
3207
  if (classNode && !ParseTreeUtils.isNodeContainedWithin(node, classNode)) {
3186
3208
  if (isProtectedAccess) {
3187
- 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);
3188
3210
  }
3189
3211
  else {
3190
- 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);
3191
3213
  }
3192
3214
  }
3193
3215
  }
@@ -3195,18 +3217,8 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3195
3217
  // enum class that has already defined values.
3196
3218
  _validateEnumClassOverride(node, classType) {
3197
3219
  classType.details.baseClasses.forEach((baseClass, index) => {
3198
- if ((0, types_1.isClass)(baseClass) && types_1.ClassType.isEnumClass(baseClass)) {
3199
- // Determine whether the base enum class defines an enumerated value.
3200
- let baseEnumDefinesValue = false;
3201
- baseClass.details.fields.forEach((symbol) => {
3202
- const symbolType = this._evaluator.getEffectiveTypeOfSymbol(symbol);
3203
- if ((0, types_1.isClassInstance)(symbolType) && types_1.ClassType.isSameGenericClass(symbolType, baseClass)) {
3204
- baseEnumDefinesValue = true;
3205
- }
3206
- });
3207
- if (baseEnumDefinesValue) {
3208
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.enumClassOverride().format({ name: baseClass.details.name }), node.arguments[index]);
3209
- }
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]);
3210
3222
  }
3211
3223
  });
3212
3224
  }
@@ -3215,7 +3227,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3215
3227
  // strings, and "pass" statements or ellipses.
3216
3228
  _validateTypedDictClassSuite(suiteNode) {
3217
3229
  const emitBadStatementError = (node) => {
3218
- this._evaluator.addError(localize_1.Localizer.Diagnostic.typedDictBadVar(), node);
3230
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.typedDictBadVar(), node);
3219
3231
  };
3220
3232
  suiteNode.statements.forEach((statement) => {
3221
3233
  if (!AnalyzerNodeInfo.isCodeUnreachable(statement)) {
@@ -3256,7 +3268,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3256
3268
  }
3257
3269
  }
3258
3270
  if (paramCount < 1) {
3259
- 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);
3260
3272
  }
3261
3273
  }
3262
3274
  _validateDunderSignatures(node, functionType, isMethod) {
@@ -3268,7 +3280,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3268
3280
  const declaredReturnType = functionType.details.declaredReturnType;
3269
3281
  if (returnAnnotation && declaredReturnType) {
3270
3282
  if (!(0, typeUtils_1.isNoneInstance)(declaredReturnType) && !(0, types_1.isNever)(declaredReturnType)) {
3271
- 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);
3272
3284
  }
3273
3285
  }
3274
3286
  else {
@@ -3276,7 +3288,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3276
3288
  if (!(0, types_1.isNever)(inferredReturnType) &&
3277
3289
  !(0, typeUtils_1.isNoneInstance)(inferredReturnType) &&
3278
3290
  !(0, types_1.isAnyOrUnknown)(inferredReturnType)) {
3279
- 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);
3280
3292
  }
3281
3293
  }
3282
3294
  }
@@ -3312,7 +3324,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3312
3324
  if (!ParseTreeUtils.isSuiteEmpty(node.suite) &&
3313
3325
  !types_1.FunctionType.isOverloaded(functionType) &&
3314
3326
  !types_1.FunctionType.isAsync(functionType)) {
3315
- 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);
3316
3328
  }
3317
3329
  }
3318
3330
  else if (!types_1.FunctionType.isAbstractMethod(functionType)) {
@@ -3325,7 +3337,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3325
3337
  // an abstract method or a protocol method and don't require that
3326
3338
  // the return type matches. This check can also be skipped for an overload.
3327
3339
  if (!ParseTreeUtils.isSuiteEmpty(node.suite) && !types_1.FunctionType.isOverloaded(functionType)) {
3328
- 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({
3329
3341
  returnType: this._evaluator.printType(declaredReturnType),
3330
3342
  }) + diagAddendum.getString(), returnAnnotation);
3331
3343
  }
@@ -3342,20 +3354,22 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3342
3354
  _validateReturnTypeIsNotContravariant(returnType, errorNode) {
3343
3355
  let isContraTypeVar = false;
3344
3356
  (0, typeUtils_1.doForEachSubtype)(returnType, (subtype) => {
3345
- 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 */) {
3346
3360
  isContraTypeVar = true;
3347
3361
  }
3348
3362
  });
3349
3363
  if (isContraTypeVar) {
3350
- 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);
3351
3365
  }
3352
3366
  }
3353
3367
  _reportUnknownReturnResult(node, returnType) {
3354
3368
  if ((0, types_1.isUnknown)(returnType)) {
3355
- 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);
3356
3370
  }
3357
3371
  else if ((0, typeUtils_1.isPartlyUnknown)(returnType)) {
3358
- 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({
3359
3373
  returnType: this._evaluator.printType(returnType, { expandTypeAlias: true }),
3360
3374
  }), node.name);
3361
3375
  }
@@ -3370,96 +3384,83 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3370
3384
  this._evaluator.isFinalVariable(parentSymbol.symbol) &&
3371
3385
  !SymbolNameUtils.isPrivateName(name)) {
3372
3386
  const decl = localSymbol.getDeclarations()[0];
3373
- this._evaluator.addError(localize_1.Localizer.Diagnostic.finalRedeclarationBySubclass().format({
3387
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.finalRedeclarationBySubclass().format({
3374
3388
  name,
3375
3389
  className: parentSymbol.classType.details.name,
3376
3390
  }), decl.node);
3377
3391
  }
3378
3392
  });
3379
3393
  }
3380
- _reportDuplicateEnumMembers(classType) {
3394
+ // Validates that the values associated with enum members are type compatible.
3395
+ // Also looks for duplicate values.
3396
+ _validateEnumMembers(classType, node) {
3381
3397
  if (!types_1.ClassType.isEnumClass(classType) || types_1.ClassType.isBuiltIn(classType)) {
3382
3398
  return;
3383
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 */);
3384
3406
  classType.details.fields.forEach((symbol, name) => {
3407
+ var _a;
3385
3408
  // Enum members don't have type annotations.
3386
3409
  if (symbol.getTypedDeclarations().length > 0) {
3387
3410
  return;
3388
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.
3389
3420
  const decls = symbol.getDeclarations();
3390
3421
  if (decls.length >= 2 && decls[0].type === 1 /* DeclarationType.Variable */) {
3391
- const symbolType = this._evaluator.getEffectiveTypeOfSymbol(symbol);
3392
- // Is this symbol a literal instance of the enum class?
3393
- if ((0, types_1.isClassInstance)(symbolType) &&
3394
- types_1.ClassType.isSameGenericClass(symbolType, classType) &&
3395
- symbolType.literalValue !== undefined) {
3396
- this._evaluator.addError(localize_1.Localizer.Diagnostic.duplicateEnumMember().format({ name }), decls[1].node);
3397
- }
3422
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.duplicateEnumMember().format({ name }), decls[1].node);
3423
+ return;
3398
3424
  }
3399
- });
3400
- }
3401
- // If a non-protocol class explicitly inherits from a protocol class and does
3402
- // not explicit derive from ABC, this method verifies that any class or instance
3403
- // variables declared but not assigned in the protocol class are implemented in
3404
- // the subclass. It also checks that any empty functions declared in the protocol
3405
- // are implemented in the subclass.
3406
- _validateProtocolCompatibility(classType, errorNode) {
3407
- if (types_1.ClassType.isProtocolClass(classType)) {
3408
- return;
3409
- }
3410
- // If a class derives from ABC, exempt it from this check. This is used for
3411
- // mixins that derive from a protocol but do not directly implement all
3412
- // of the protocol's methods.
3413
- if (classType.details.mro.some((mroClass) => (0, types_1.isClass)(mroClass) && types_1.ClassType.isBuiltIn(mroClass, 'ABC'))) {
3414
- return;
3415
- }
3416
- const diagAddendum = new diagnostic_1.DiagnosticAddendum();
3417
- const isSymbolImplemented = (name) => {
3418
- return classType.details.mro.some((mroClass) => {
3419
- return (0, types_1.isClass)(mroClass) && !types_1.ClassType.isProtocolClass(mroClass) && mroClass.details.fields.has(name);
3420
- });
3421
- };
3422
- classType.details.baseClasses.forEach((baseClass) => {
3423
- if (!(0, types_1.isClass)(baseClass) || !types_1.ClassType.isProtocolClass(baseClass)) {
3425
+ if (decls[0].type !== 1 /* DeclarationType.Variable */) {
3424
3426
  return;
3425
3427
  }
3426
- const protocolSymbols = (0, typeUtils_1.getProtocolSymbols)(baseClass);
3427
- protocolSymbols.forEach((member, name) => {
3428
- const decls = member.symbol.getDeclarations();
3429
- if (decls.length === 0 || !(0, types_1.isClass)(member.classType)) {
3430
- return;
3431
- }
3432
- if (decls[0].type === 1 /* DeclarationType.Variable */) {
3433
- // If none of the declarations involve assignments, assume it's
3434
- // not implemented in the protocol.
3435
- if (!decls.some((decl) => decl.type === 1 /* DeclarationType.Variable */ && !!decl.inferredTypeSource)) {
3436
- // This is a variable declaration that is not implemented in the
3437
- // protocol base class. Make sure it's implemented in the derived class.
3438
- if (!isSymbolImplemented(name)) {
3439
- diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.missingProtocolMember().format({
3440
- name,
3441
- classType: member.classType.details.name,
3442
- }));
3443
- }
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);
3444
3450
  }
3445
3451
  }
3446
- else if (decls[0].type === 5 /* DeclarationType.Function */) {
3447
- if (decls.every((decl) => decl.type !== 5 /* DeclarationType.Function */ || ParseTreeUtils.isSuiteEmpty(decl.node.suite))) {
3448
- if (!decls[0].uri.hasExtension('.pyi')) {
3449
- if (!isSymbolImplemented(name)) {
3450
- diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.missingProtocolMember().format({
3451
- name,
3452
- classType: member.classType.details.name,
3453
- }));
3454
- }
3455
- }
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);
3456
3460
  }
3457
3461
  }
3458
- });
3462
+ }
3459
3463
  });
3460
- if (!diagAddendum.isEmpty()) {
3461
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.missingProtocolMembers() + diagAddendum.getString(), errorNode.name);
3462
- }
3463
3464
  }
3464
3465
  // If a class is a dataclass with a `__post_init__` method, verify that its
3465
3466
  // signature is correct.
@@ -3506,7 +3507,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3506
3507
  // We expect to see one param for "self" plus one for each of the InitVars.
3507
3508
  const expectedParamCount = initOnlySymbolMap.size + 1;
3508
3509
  if (expectedParamCount < nonDefaultParams.length || expectedParamCount > paramListDetails.params.length) {
3509
- 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);
3510
3511
  }
3511
3512
  // Verify that the parameter types match.
3512
3513
  let paramIndex = 1;
@@ -3521,11 +3522,11 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3521
3522
  const paramType = types_1.FunctionType.getEffectiveParameterType(postInitType, paramListDetails.params[paramIndex].index);
3522
3523
  const assignTypeDiag = new diagnostic_1.DiagnosticAddendum();
3523
3524
  if (fieldType && !this._evaluator.assignType(paramType, fieldType, assignTypeDiag)) {
3524
- 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);
3525
3526
  if (diagnostic) {
3526
3527
  const fieldDecls = symbol.getTypedDeclarations();
3527
3528
  if (fieldDecls.length > 0) {
3528
- 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);
3529
3530
  }
3530
3531
  }
3531
3532
  }
@@ -3542,29 +3543,29 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3542
3543
  if (!types_1.ClassType.supportsAbstractMethods(classType)) {
3543
3544
  return;
3544
3545
  }
3545
- const abstractMethods = this._evaluator.getAbstractMethods(classType);
3546
- if (abstractMethods.length === 0) {
3546
+ const abstractSymbols = this._evaluator.getAbstractSymbols(classType);
3547
+ if (abstractSymbols.length === 0) {
3547
3548
  return;
3548
3549
  }
3549
3550
  const diagAddendum = new diagnostic_1.DiagnosticAddendum();
3550
3551
  const errorsToDisplay = 2;
3551
- abstractMethods.forEach((abstractMethod, index) => {
3552
+ abstractSymbols.forEach((abstractMethod, index) => {
3552
3553
  if (index === errorsToDisplay) {
3553
- diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.memberIsAbstractMore().format({
3554
- count: abstractMethods.length - errorsToDisplay,
3554
+ diagAddendum.addMessage(localize_1.LocAddendum.memberIsAbstractMore().format({
3555
+ count: abstractSymbols.length - errorsToDisplay,
3555
3556
  }));
3556
3557
  }
3557
3558
  else if (index < errorsToDisplay) {
3558
3559
  if ((0, types_1.isInstantiableClass)(abstractMethod.classType)) {
3559
3560
  const className = abstractMethod.classType.details.name;
3560
- diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.memberIsAbstract().format({
3561
+ diagAddendum.addMessage(localize_1.LocAddendum.memberIsAbstract().format({
3561
3562
  type: className,
3562
3563
  name: abstractMethod.symbolName,
3563
3564
  }));
3564
3565
  }
3565
3566
  }
3566
3567
  });
3567
- 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({
3568
3569
  type: classType.details.name,
3569
3570
  }) + diagAddendum.getString(), errorNode.name);
3570
3571
  }
@@ -3643,7 +3644,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3643
3644
  return;
3644
3645
  }
3645
3646
  // Report the variable as uninitialized only on the first decl.
3646
- 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);
3647
3648
  });
3648
3649
  // See if there are any variables from abstract base classes
3649
3650
  // that are not initialized.
@@ -3659,7 +3660,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3659
3660
  if (!decls.some((decl) => decl.type === 1 /* DeclarationType.Variable */ && !!decl.inferredTypeSource)) {
3660
3661
  // This is a variable declaration that is not implemented in the
3661
3662
  // protocol base class. Make sure it's implemented in the derived class.
3662
- diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.uninitializedAbstractVariable().format({
3663
+ diagAddendum.addMessage(localize_1.LocAddendum.uninitializedAbstractVariable().format({
3663
3664
  name,
3664
3665
  classType: member.classType.details.name,
3665
3666
  }));
@@ -3667,7 +3668,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3667
3668
  }
3668
3669
  });
3669
3670
  if (!diagAddendum.isEmpty()) {
3670
- 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 }) +
3671
3672
  diagAddendum.getString(), node.name);
3672
3673
  }
3673
3674
  }
@@ -3683,12 +3684,9 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3683
3684
  if (!(0, types_1.isInstantiableClass)(objectType)) {
3684
3685
  return;
3685
3686
  }
3686
- // Replace all of the type parameters with invariant TypeVars.
3687
- const updatedTypeParams = classType.details.typeParameters.map((typeParam) => types_1.TypeVarType.cloneAsInvariant(typeParam));
3688
- const updatedClassType = types_1.ClassType.cloneWithNewTypeParameters(classType, updatedTypeParams);
3689
3687
  const objectObject = types_1.ClassType.cloneAsInstance(objectType);
3690
3688
  const dummyTypeObject = types_1.ClassType.createInstantiable('__varianceDummy', '', '', uri_1.Uri.empty(), 0, 0, undefined, undefined);
3691
- updatedTypeParams.forEach((param, paramIndex) => {
3689
+ classType.details.typeParameters.forEach((param, paramIndex) => {
3692
3690
  // Skip variadics and ParamSpecs.
3693
3691
  if (param.details.isVariadic || param.details.isParamSpec) {
3694
3692
  return;
@@ -3699,7 +3697,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3699
3697
  }
3700
3698
  // Replace all type arguments with a dummy type except for the
3701
3699
  // TypeVar of interest, which is replaced with an object instance.
3702
- const srcTypeArgs = updatedTypeParams.map((p, i) => {
3700
+ const srcTypeArgs = classType.details.typeParameters.map((p, i) => {
3703
3701
  if (p.details.isVariadic) {
3704
3702
  return p;
3705
3703
  }
@@ -3707,20 +3705,19 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3707
3705
  });
3708
3706
  // Replace all type arguments with a dummy type except for the
3709
3707
  // TypeVar of interest, which is replaced with itself.
3710
- const destTypeArgs = updatedTypeParams.map((p, i) => {
3708
+ const destTypeArgs = classType.details.typeParameters.map((p, i) => {
3711
3709
  return i === paramIndex || p.details.isVariadic ? p : dummyTypeObject;
3712
3710
  });
3713
- const srcType = types_1.ClassType.cloneForSpecialization(updatedClassType, srcTypeArgs,
3714
- /* isTypeArgumentExplicit */ true);
3715
- 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,
3716
3713
  /* isTypeArgumentExplicit */ true);
3717
- const isDestSubtypeOfSrc = this._evaluator.assignClassToSelf(srcType, destType);
3714
+ const isDestSubtypeOfSrc = this._evaluator.assignClassToSelf(srcType, destType, 3 /* Variance.Covariant */);
3718
3715
  let expectedVariance;
3719
3716
  if (isDestSubtypeOfSrc) {
3720
3717
  expectedVariance = 3 /* Variance.Covariant */;
3721
3718
  }
3722
3719
  else {
3723
- const isSrcSubtypeOfDest = this._evaluator.assignClassToSelf(destType, srcType);
3720
+ const isSrcSubtypeOfDest = this._evaluator.assignClassToSelf(destType, srcType, 4 /* Variance.Contravariant */);
3724
3721
  if (isSrcSubtypeOfDest) {
3725
3722
  expectedVariance = 4 /* Variance.Contravariant */;
3726
3723
  }
@@ -3731,24 +3728,24 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3731
3728
  if (expectedVariance !== classType.details.typeParameters[paramIndex].details.declaredVariance) {
3732
3729
  let message;
3733
3730
  if (expectedVariance === 3 /* Variance.Covariant */) {
3734
- message = localize_1.Localizer.Diagnostic.protocolVarianceCovariant().format({
3731
+ message = localize_1.LocMessage.protocolVarianceCovariant().format({
3735
3732
  variable: param.details.name,
3736
3733
  class: classType.details.name,
3737
3734
  });
3738
3735
  }
3739
3736
  else if (expectedVariance === 4 /* Variance.Contravariant */) {
3740
- message = localize_1.Localizer.Diagnostic.protocolVarianceContravariant().format({
3737
+ message = localize_1.LocMessage.protocolVarianceContravariant().format({
3741
3738
  variable: param.details.name,
3742
3739
  class: classType.details.name,
3743
3740
  });
3744
3741
  }
3745
3742
  else {
3746
- message = localize_1.Localizer.Diagnostic.protocolVarianceInvariant().format({
3743
+ message = localize_1.LocMessage.protocolVarianceInvariant().format({
3747
3744
  variable: param.details.name,
3748
3745
  class: classType.details.name,
3749
3746
  });
3750
3747
  }
3751
- 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);
3752
3749
  }
3753
3750
  });
3754
3751
  }
@@ -3773,7 +3770,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3773
3770
  !decl.isDefinedBySlots &&
3774
3771
  !decl.isDefinedByMemberAccess) {
3775
3772
  if (decl.node.nodeType === 38 /* ParseNodeType.Name */ && ParseTreeUtils.isWriteAccess(decl.node)) {
3776
- 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);
3777
3774
  }
3778
3775
  }
3779
3776
  });
@@ -3860,20 +3857,18 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3860
3857
  const diagAddendum = new diagnostic_1.DiagnosticAddendum();
3861
3858
  const initSignature = this._evaluator.printType(initMemberType);
3862
3859
  const newSignature = this._evaluator.printType(newMemberType);
3863
- diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.initMethodSignature().format({
3860
+ diagAddendum.addMessage(localize_1.LocAddendum.initMethodSignature().format({
3864
3861
  type: initSignature,
3865
3862
  }));
3866
- diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.newMethodSignature().format({
3863
+ diagAddendum.addMessage(localize_1.LocAddendum.newMethodSignature().format({
3867
3864
  type: newSignature,
3868
3865
  }));
3869
- 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({
3870
3867
  classType: this._evaluator.printType(types_1.ClassType.cloneAsInstance(displayOnInit ? initMethodResult.classType : newMethodResult.classType)),
3871
3868
  }) + diagAddendum.getString(), mainDeclNode);
3872
3869
  if (diagnostic) {
3873
3870
  const secondaryDecl = displayOnInit ? newDecl : initDecl;
3874
- diagnostic.addRelatedInfo((displayOnInit
3875
- ? localize_1.Localizer.DiagnosticAddendum.newMethodLocation()
3876
- : localize_1.Localizer.DiagnosticAddendum.initMethodLocation()).format({
3871
+ diagnostic.addRelatedInfo((displayOnInit ? localize_1.LocAddendum.newMethodLocation() : localize_1.LocAddendum.initMethodLocation()).format({
3877
3872
  type: this._evaluator.printType(types_1.ClassType.cloneAsInstance(displayOnInit ? newMethodResult.classType : initMethodResult.classType)),
3878
3873
  }), secondaryDecl.uri, secondaryDecl.range);
3879
3874
  }
@@ -3913,13 +3908,13 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3913
3908
  const diag = new diagnostic_1.DiagnosticAddendum();
3914
3909
  const baseClassObject = (0, typeUtils_1.convertToInstance)(baseClass);
3915
3910
  if ((0, types_1.isTypeSame)(baseClassObject, baseClassMroObject)) {
3916
- diag.addMessage(localize_1.Localizer.DiagnosticAddendum.baseClassIncompatible().format({
3911
+ diag.addMessage(localize_1.LocAddendum.baseClassIncompatible().format({
3917
3912
  baseClass: this._evaluator.printType(baseClassObject),
3918
3913
  type: this._evaluator.printType(matchingMroObject),
3919
3914
  }));
3920
3915
  }
3921
3916
  else {
3922
- diag.addMessage(localize_1.Localizer.DiagnosticAddendum.baseClassIncompatibleSubclass().format({
3917
+ diag.addMessage(localize_1.LocAddendum.baseClassIncompatibleSubclass().format({
3923
3918
  baseClass: this._evaluator.printType(baseClassObject),
3924
3919
  subclass: this._evaluator.printType(baseClassMroObject),
3925
3920
  type: this._evaluator.printType(matchingMroObject),
@@ -3934,8 +3929,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
3934
3929
  }
3935
3930
  }
3936
3931
  if (!diagAddendum.isEmpty()) {
3937
- this._evaluator.addDiagnostic(this._fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.baseClassIncompatible().format({ type: classType.details.name }) +
3938
- diagAddendum.getString(), errorNode);
3932
+ this._evaluator.addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.baseClassIncompatible().format({ type: classType.details.name }) + diagAddendum.getString(), errorNode);
3939
3933
  }
3940
3934
  }
3941
3935
  // Validates that any methods and variables in multiple base classes are
@@ -4040,7 +4034,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4040
4034
  /* enforceParamNameMatch */ true)) {
4041
4035
  const decl = overrideFunction.details.declaration;
4042
4036
  if (decl && decl.type === 5 /* DeclarationType.Function */) {
4043
- 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({
4044
4038
  classType: childClassType.details.name,
4045
4039
  name: memberName,
4046
4040
  }) + diagAddendum.getString(), errorNode);
@@ -4053,7 +4047,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4053
4047
  if (!(0, typeUtils_1.isProperty)(overrideType) && !(0, types_1.isAnyOrUnknown)(overrideType)) {
4054
4048
  const decls = overrideSymbol.getDeclarations();
4055
4049
  if (decls.length > 0) {
4056
- 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({
4057
4051
  classType: childClassType.details.name,
4058
4052
  name: memberName,
4059
4053
  }), errorNode);
@@ -4099,7 +4093,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4099
4093
  /* diag */ undefined,
4100
4094
  /* destTypeVarContext */ undefined,
4101
4095
  /* srcTypeVarContext */ undefined, isInvariant ? 1 /* AssignTypeFlags.EnforceInvariance */ : 0 /* AssignTypeFlags.Default */)) {
4102
- 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({
4103
4097
  classType: childClassType.details.name,
4104
4098
  name: memberName,
4105
4099
  }), errorNode);
@@ -4118,12 +4112,12 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4118
4112
  }
4119
4113
  if (!isRequiredCompatible) {
4120
4114
  const message = overrideTDEntry.isRequired
4121
- ? localize_1.Localizer.Diagnostic.typedDictFieldRequiredRedefinition
4122
- : localize_1.Localizer.Diagnostic.typedDictFieldNotRequiredRedefinition;
4123
- 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);
4124
4118
  }
4125
4119
  else if (!isReadOnlyCompatible) {
4126
- 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({
4127
4121
  name: memberName,
4128
4122
  }), errorNode);
4129
4123
  }
@@ -4132,11 +4126,11 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4132
4126
  }
4133
4127
  }
4134
4128
  if (diag && overrideDecl && overriddenDecl) {
4135
- diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.baseClassOverriddenType().format({
4129
+ diag.addRelatedInfo(localize_1.LocAddendum.baseClassOverriddenType().format({
4136
4130
  baseClass: this._evaluator.printType((0, typeUtils_1.convertToInstance)(overriddenClassAndSymbol.classType)),
4137
4131
  type: this._evaluator.printType(overriddenType),
4138
4132
  }), overriddenDecl.uri, overriddenDecl.range);
4139
- diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.baseClassOverridesType().format({
4133
+ diag.addRelatedInfo(localize_1.LocAddendum.baseClassOverridesType().format({
4140
4134
  baseClass: this._evaluator.printType((0, typeUtils_1.convertToInstance)(overrideClassAndSymbol.classType)),
4141
4135
  type: this._evaluator.printType(overrideType),
4142
4136
  }), overrideDecl.uri, overrideDecl.range);
@@ -4166,7 +4160,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4166
4160
  overloads.forEach((overload) => {
4167
4161
  var _a, _b;
4168
4162
  if (types_1.FunctionType.isFinal(overload) && ((_a = overload.details.declaration) === null || _a === void 0 ? void 0 : _a.node)) {
4169
- 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({
4170
4164
  name: overload.details.name,
4171
4165
  }), (_b = (0, declarationUtils_1.getNameNodeForDeclaration)(overload.details.declaration)) !== null && _b !== void 0 ? _b : overload.details.declaration.node);
4172
4166
  }
@@ -4178,7 +4172,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4178
4172
  overloads.slice(1).forEach((overload, index) => {
4179
4173
  var _a, _b;
4180
4174
  if (types_1.FunctionType.isFinal(overload) && ((_a = overload.details.declaration) === null || _a === void 0 ? void 0 : _a.node)) {
4181
- 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({
4182
4176
  name: overload.details.name,
4183
4177
  index: index + 2,
4184
4178
  }), (_b = (0, declarationUtils_1.getNameNodeForDeclaration)(overload.details.declaration)) !== null && _b !== void 0 ? _b : overload.details.declaration.node);
@@ -4268,7 +4262,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4268
4262
  return;
4269
4263
  }
4270
4264
  const funcNode = overrideFunction.details.declaration.node;
4271
- 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({
4272
4266
  name: funcNode.name.value,
4273
4267
  className: this._evaluator.printType((0, typeUtils_1.convertToInstance)(baseMember.classType)),
4274
4268
  }), funcNode.name);
@@ -4303,7 +4297,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4303
4297
  return;
4304
4298
  }
4305
4299
  const funcNode = overrideFunction.details.declaration.node;
4306
- 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);
4307
4301
  }
4308
4302
  _validateBaseClassOverride(baseClassAndSymbol, overrideSymbol, overrideType, childClassType, memberName) {
4309
4303
  var _a, _b, _c, _d, _e, _f, _g, _h;
@@ -4345,13 +4339,13 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4345
4339
  if (reportFinalMethodOverride) {
4346
4340
  const decl = (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(overrideSymbol);
4347
4341
  if (decl && decl.type === 5 /* DeclarationType.Function */) {
4348
- 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({
4349
4343
  name: memberName,
4350
4344
  className: baseClass.details.name,
4351
4345
  }), decl.node.name);
4352
4346
  const origDecl = (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(baseClassAndSymbol.symbol);
4353
4347
  if (diag && origDecl) {
4354
- diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.finalMethod(), origDecl.uri, origDecl.range);
4348
+ diag.addRelatedInfo(localize_1.LocAddendum.finalMethod(), origDecl.uri, origDecl.range);
4355
4349
  }
4356
4350
  }
4357
4351
  }
@@ -4372,13 +4366,13 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4372
4366
  ? overrideType.details.declaration
4373
4367
  : (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(overrideSymbol);
4374
4368
  if (decl) {
4375
- 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({
4376
4370
  name: memberName,
4377
4371
  className: baseClass.details.name,
4378
4372
  }) + diagAddendum.getString(), (_a = (0, declarationUtils_1.getNameNodeForDeclaration)(decl)) !== null && _a !== void 0 ? _a : decl.node);
4379
4373
  const origDecl = (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(baseClassAndSymbol.symbol);
4380
4374
  if (diag && origDecl) {
4381
- diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.overriddenMethod(), origDecl.uri, origDecl.range);
4375
+ diag.addRelatedInfo(localize_1.LocAddendum.overriddenMethod(), origDecl.uri, origDecl.range);
4382
4376
  }
4383
4377
  }
4384
4378
  }
@@ -4392,14 +4386,14 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4392
4386
  const decls = overrideSymbol.getDeclarations();
4393
4387
  if (decls.length > 0) {
4394
4388
  const lastDecl = decls[decls.length - 1];
4395
- 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({
4396
4390
  name: memberName,
4397
4391
  className: baseClass.details.name,
4398
4392
  type: this._evaluator.printType(overrideType),
4399
4393
  }), (_b = (0, declarationUtils_1.getNameNodeForDeclaration)(lastDecl)) !== null && _b !== void 0 ? _b : lastDecl.node);
4400
4394
  const origDecl = (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(baseClassAndSymbol.symbol);
4401
4395
  if (diag && origDecl) {
4402
- diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.overriddenMethod(), origDecl.uri, origDecl.range);
4396
+ diag.addRelatedInfo(localize_1.LocAddendum.overriddenMethod(), origDecl.uri, origDecl.range);
4403
4397
  }
4404
4398
  }
4405
4399
  }
@@ -4411,7 +4405,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4411
4405
  const decls = overrideSymbol.getDeclarations();
4412
4406
  if (decls.length > 0) {
4413
4407
  const lastDecl = decls[decls.length - 1];
4414
- 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({
4415
4409
  name: memberName,
4416
4410
  className: baseClass.details.name,
4417
4411
  }), (_c = (0, declarationUtils_1.getNameNodeForDeclaration)(lastDecl)) !== null && _c !== void 0 ? _c : lastDecl.node);
@@ -4436,19 +4430,19 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4436
4430
  if ((0, types_1.isFunction)(baseClassMethodType)) {
4437
4431
  if (!subclassPropMethod) {
4438
4432
  // The method is missing.
4439
- diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.propertyMethodMissing().format({
4433
+ diagAddendum.addMessage(localize_1.LocAddendum.propertyMethodMissing().format({
4440
4434
  name: methodName,
4441
4435
  }));
4442
4436
  const decls = overrideSymbol.getDeclarations();
4443
4437
  if (decls.length > 0) {
4444
4438
  const lastDecl = decls[decls.length - 1];
4445
- 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({
4446
4440
  name: memberName,
4447
4441
  className: baseClassType.details.name,
4448
4442
  }) + diagAddendum.getString(), (_a = (0, declarationUtils_1.getNameNodeForDeclaration)(lastDecl)) !== null && _a !== void 0 ? _a : lastDecl.node);
4449
4443
  const origDecl = baseClassMethodType.details.declaration;
4450
4444
  if (diag && origDecl) {
4451
- diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.overriddenMethod(), origDecl.uri, origDecl.range);
4445
+ diag.addRelatedInfo(localize_1.LocAddendum.overriddenMethod(), origDecl.uri, origDecl.range);
4452
4446
  }
4453
4447
  }
4454
4448
  }
@@ -4456,18 +4450,18 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4456
4450
  const subclassMethodType = (0, typeUtils_1.partiallySpecializeType)(subclassPropMethod, childClassType);
4457
4451
  if ((0, types_1.isFunction)(subclassMethodType)) {
4458
4452
  if (!this._evaluator.validateOverrideMethod(baseClassMethodType, subclassMethodType, childClassType, diagAddendum.createAddendum())) {
4459
- diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.propertyMethodIncompatible().format({
4453
+ diagAddendum.addMessage(localize_1.LocAddendum.propertyMethodIncompatible().format({
4460
4454
  name: methodName,
4461
4455
  }));
4462
4456
  const decl = subclassMethodType.details.declaration;
4463
4457
  if (decl && decl.type === 5 /* DeclarationType.Function */) {
4464
- 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({
4465
4459
  name: memberName,
4466
4460
  className: baseClassType.details.name,
4467
4461
  }) + diagAddendum.getString(), decl.node.name);
4468
4462
  const origDecl = baseClassMethodType.details.declaration;
4469
4463
  if (diag && origDecl) {
4470
- diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.overriddenMethod(), origDecl.uri, origDecl.range);
4464
+ diag.addRelatedInfo(localize_1.LocAddendum.overriddenMethod(), origDecl.uri, origDecl.range);
4471
4465
  }
4472
4466
  }
4473
4467
  }
@@ -4514,19 +4508,19 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4514
4508
  /* srcTypeVarContext */ undefined, isInvariant ? 1 /* AssignTypeFlags.EnforceInvariance */ : 0 /* AssignTypeFlags.Default */)) {
4515
4509
  if (isInvariant) {
4516
4510
  diagAddendum = new diagnostic_1.DiagnosticAddendum();
4517
- diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.overrideIsInvariant());
4518
- 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({
4519
4513
  overrideType: this._evaluator.printType(overrideType),
4520
4514
  baseType: this._evaluator.printType(baseType),
4521
4515
  }));
4522
4516
  }
4523
- 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({
4524
4518
  name: memberName,
4525
4519
  className: baseClass.details.name,
4526
4520
  }) + diagAddendum.getString(), (_d = (0, declarationUtils_1.getNameNodeForDeclaration)(lastDecl)) !== null && _d !== void 0 ? _d : lastDecl.node);
4527
4521
  const origDecl = (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(baseClassAndSymbol.symbol);
4528
4522
  if (diag && origDecl) {
4529
- diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.overriddenSymbol(), origDecl.uri, origDecl.range);
4523
+ diag.addRelatedInfo(localize_1.LocAddendum.overriddenSymbol(), origDecl.uri, origDecl.range);
4530
4524
  }
4531
4525
  }
4532
4526
  else if (overriddenTDEntry && overrideTDEntry) {
@@ -4542,14 +4536,14 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4542
4536
  }
4543
4537
  if (!isRequiredCompatible) {
4544
4538
  const message = overrideTDEntry.isRequired
4545
- ? localize_1.Localizer.Diagnostic.typedDictFieldRequiredRedefinition
4546
- : localize_1.Localizer.Diagnostic.typedDictFieldNotRequiredRedefinition;
4547
- 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);
4548
4542
  }
4549
4543
  // Make sure that the derived class isn't marking a previously writable
4550
4544
  // entry as read-only.
4551
4545
  if (!overriddenTDEntry.isReadOnly && overrideTDEntry.isReadOnly) {
4552
- 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({
4553
4547
  name: memberName,
4554
4548
  }), (_f = (0, declarationUtils_1.getNameNodeForDeclaration)(lastDecl)) !== null && _f !== void 0 ? _f : lastDecl.node);
4555
4549
  }
@@ -4558,12 +4552,12 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4558
4552
  const isBaseVarFinal = this._evaluator.isFinalVariable(baseClassAndSymbol.symbol);
4559
4553
  const overrideFinalVarDecl = decls.find((d) => this._evaluator.isFinalVariableDeclaration(d));
4560
4554
  if (!isBaseVarFinal && overrideFinalVarDecl) {
4561
- 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({
4562
4556
  name: memberName,
4563
4557
  className: baseClass.details.name,
4564
4558
  }), (_g = (0, declarationUtils_1.getNameNodeForDeclaration)(lastDecl)) !== null && _g !== void 0 ? _g : lastDecl.node);
4565
4559
  if (diag) {
4566
- diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.overriddenSymbol(), overrideFinalVarDecl.uri, overrideFinalVarDecl.range);
4560
+ diag.addRelatedInfo(localize_1.LocAddendum.overriddenSymbol(), overrideFinalVarDecl.uri, overrideFinalVarDecl.range);
4567
4561
  }
4568
4562
  }
4569
4563
  // Verify that a class variable isn't overriding an instance
@@ -4585,15 +4579,15 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4585
4579
  }
4586
4580
  if (isBaseClassVar !== isClassVar) {
4587
4581
  const unformattedMessage = overrideSymbol.isClassVar()
4588
- ? localize_1.Localizer.Diagnostic.classVarOverridesInstanceVar()
4589
- : localize_1.Localizer.Diagnostic.instanceVarOverridesClassVar();
4590
- 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({
4591
4585
  name: memberName,
4592
4586
  className: baseClass.details.name,
4593
4587
  }), (_h = (0, declarationUtils_1.getNameNodeForDeclaration)(lastDecl)) !== null && _h !== void 0 ? _h : lastDecl.node);
4594
4588
  const origDecl = (0, symbolUtils_1.getLastTypedDeclaredForSymbol)(baseClassAndSymbol.symbol);
4595
4589
  if (diag && origDecl) {
4596
- diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.overriddenSymbol(), origDecl.uri, origDecl.range);
4590
+ diag.addRelatedInfo(localize_1.LocAddendum.overriddenSymbol(), origDecl.uri, origDecl.range);
4597
4591
  }
4598
4592
  }
4599
4593
  }
@@ -4621,7 +4615,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4621
4615
  if (node.parameters.length === 0 ||
4622
4616
  !node.parameters[0].name ||
4623
4617
  !['cls', '_cls', '__cls', '__mcls', 'mcls', 'mcs', 'metacls'].some((name) => node.parameters[0].name.value === name)) {
4624
- 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);
4625
4619
  }
4626
4620
  if (classType) {
4627
4621
  this._validateClsSelfParameterType(functionType, classType, /* isCls */ true);
@@ -4635,7 +4629,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4635
4629
  if (node.parameters.length > 0 && node.parameters[0].name) {
4636
4630
  const paramName = node.parameters[0].name.value;
4637
4631
  if (paramName === 'self' || paramName === 'cls') {
4638
- 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);
4639
4633
  }
4640
4634
  }
4641
4635
  }
@@ -4649,7 +4643,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4649
4643
  // cases in the stdlib pyi files.
4650
4644
  if (paramName !== 'cls') {
4651
4645
  if (!this._fileInfo.isStubFile || (!paramName.startsWith('_') && paramName !== 'metacls')) {
4652
- 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);
4653
4647
  }
4654
4648
  }
4655
4649
  if (classType) {
@@ -4693,7 +4687,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4693
4687
  // a parameter that cannot be positional.
4694
4688
  const isPrivateName = SymbolNameUtils.isPrivateOrProtectedName(paramName);
4695
4689
  if (!isLegalMetaclassName && !isPrivateName) {
4696
- 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);
4697
4691
  }
4698
4692
  }
4699
4693
  }
@@ -4750,7 +4744,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4750
4744
  callNodeWalker.walk(node.suite);
4751
4745
  // If we didn't find a call to at least one base class, report the problem.
4752
4746
  if (!foundCallOfMember) {
4753
- 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({
4754
4748
  methodName: methodType.details.name,
4755
4749
  }), node.name);
4756
4750
  }
@@ -4806,7 +4800,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4806
4800
  if (!this._evaluator.assignType(paramType, expectedType, /* diag */ undefined, typeVarContext)) {
4807
4801
  // We exempt Never from this check because it has a legitimate use in this case.
4808
4802
  if (!(0, types_1.isNever)(paramType)) {
4809
- 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({
4810
4804
  name: paramInfo.name,
4811
4805
  classType: this._evaluator.printType(expectedType),
4812
4806
  }), paramInfo.typeAnnotation);
@@ -4847,7 +4841,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4847
4841
  return;
4848
4842
  }
4849
4843
  if ((0, types_1.isNever)(declaredReturnType)) {
4850
- 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);
4851
4845
  return;
4852
4846
  }
4853
4847
  const generatorTypeArgs = [yieldType, sendType !== null && sendType !== void 0 ? sendType : types_1.UnknownType.create(), types_1.UnknownType.create()];
@@ -4855,9 +4849,9 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4855
4849
  const diagAddendum = new diagnostic_1.DiagnosticAddendum();
4856
4850
  if (!this._evaluator.assignType(declaredReturnType, specializedGenerator, diagAddendum)) {
4857
4851
  const errorMessage = enclosingFunctionNode.isAsync
4858
- ? localize_1.Localizer.Diagnostic.generatorAsyncReturnType()
4859
- : localize_1.Localizer.Diagnostic.generatorSyncReturnType();
4860
- 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) }) +
4861
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);
4862
4856
  }
4863
4857
  }
@@ -4915,7 +4909,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4915
4909
  return (0, typeUtils_1.derivesFromClassRecursive)(thisExceptType, previousExceptType, /* ignoreUnknown */ true);
4916
4910
  });
4917
4911
  if (subtype) {
4918
- diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.unreachableExcept().format({
4912
+ diagAddendum.addMessage(localize_1.LocAddendum.unreachableExcept().format({
4919
4913
  exceptionType: this._evaluator.printType((0, typeUtils_1.convertToInstance)(thisExceptType)),
4920
4914
  parentType: this._evaluator.printType((0, typeUtils_1.convertToInstance)(subtype)),
4921
4915
  }));
@@ -4924,7 +4918,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4924
4918
  });
4925
4919
  // Were all of the exception types overridden?
4926
4920
  if (typesOfThisExcept.length > 0 && typesOfThisExcept.length === overriddenExceptionCount) {
4927
- 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);
4928
4922
  this._evaluator.addUnreachableCode(except, except.exceptSuite);
4929
4923
  }
4930
4924
  }
@@ -4942,7 +4936,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4942
4936
  if (!importFromAs.alias) {
4943
4937
  const prevImport = symbolMap.get(importFromAs.name.value);
4944
4938
  if (prevImport) {
4945
- 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);
4946
4940
  }
4947
4941
  else {
4948
4942
  symbolMap.set(importFromAs.name.value, importFromAs);
@@ -4955,7 +4949,7 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4955
4949
  if (!importStatement.subnode.alias) {
4956
4950
  const prevImport = importModuleMap.get(importStatement.moduleName);
4957
4951
  if (prevImport) {
4958
- 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);
4959
4953
  }
4960
4954
  else {
4961
4955
  importModuleMap.set(importStatement.moduleName, importStatement.subnode);
@@ -4976,12 +4970,12 @@ class Checker extends parseTreeWalker_1.ParseTreeWalker {
4976
4970
  regionStack.pop();
4977
4971
  }
4978
4972
  else {
4979
- this._addDiagnosticForRegionComment(regionComment, localize_1.Localizer.Diagnostic.unmatchedEndregionComment());
4973
+ this._addDiagnosticForRegionComment(regionComment, localize_1.LocMessage.unmatchedEndregionComment());
4980
4974
  }
4981
4975
  }
4982
4976
  });
4983
4977
  regionStack.forEach((regionComment) => {
4984
- this._addDiagnosticForRegionComment(regionComment, localize_1.Localizer.Diagnostic.unmatchedRegionComment());
4978
+ this._addDiagnosticForRegionComment(regionComment, localize_1.LocMessage.unmatchedRegionComment());
4985
4979
  });
4986
4980
  }
4987
4981
  _addDiagnosticForRegionComment(regionComment, message) {