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

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 (593) hide show
  1. package/dist/analyzer/analysis.js +4 -1
  2. package/dist/analyzer/analysis.js.map +1 -1
  3. package/dist/analyzer/analyzerFileInfo.js.map +1 -1
  4. package/dist/analyzer/analyzerNodeInfo.js.map +1 -1
  5. package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
  6. package/dist/analyzer/binder.js +1 -0
  7. package/dist/analyzer/binder.js.map +1 -1
  8. package/dist/analyzer/cacheManager.js.map +1 -1
  9. package/dist/analyzer/checker.d.ts +1 -2
  10. package/dist/analyzer/checker.js +251 -121
  11. package/dist/analyzer/checker.js.map +1 -1
  12. package/dist/analyzer/circularDependency.js.map +1 -1
  13. package/dist/analyzer/codeFlowEngine.js +29 -3
  14. package/dist/analyzer/codeFlowEngine.js.map +1 -1
  15. package/dist/analyzer/codeFlowTypes.js.map +1 -1
  16. package/dist/analyzer/codeFlowUtils.js.map +1 -1
  17. package/dist/analyzer/commentUtils.js.map +1 -1
  18. package/dist/analyzer/constraintSolver.d.ts +2 -2
  19. package/dist/analyzer/constraintSolver.js +28 -6
  20. package/dist/analyzer/constraintSolver.js.map +1 -1
  21. package/dist/analyzer/constructorTransform.js.map +1 -1
  22. package/dist/analyzer/constructors.js.map +1 -1
  23. package/dist/analyzer/dataClasses.js +6 -6
  24. package/dist/analyzer/dataClasses.js.map +1 -1
  25. package/dist/analyzer/declaration.js.map +1 -1
  26. package/dist/analyzer/declarationUtils.js.map +1 -1
  27. package/dist/analyzer/decorators.js +6 -6
  28. package/dist/analyzer/decorators.js.map +1 -1
  29. package/dist/analyzer/deprecatedSymbols.js.map +1 -1
  30. package/dist/analyzer/docStringConversion.js.map +1 -1
  31. package/dist/analyzer/docStringUtils.js.map +1 -1
  32. package/dist/analyzer/enums.d.ts +4 -1
  33. package/dist/analyzer/enums.js +30 -16
  34. package/dist/analyzer/enums.js.map +1 -1
  35. package/dist/analyzer/functionTransform.js.map +1 -1
  36. package/dist/analyzer/importResolver.js +12 -4
  37. package/dist/analyzer/importResolver.js.map +1 -1
  38. package/dist/analyzer/importResult.js.map +1 -1
  39. package/dist/analyzer/importStatementUtils.js +2 -0
  40. package/dist/analyzer/importStatementUtils.js.map +1 -1
  41. package/dist/analyzer/namedTuples.js +1 -1
  42. package/dist/analyzer/namedTuples.js.map +1 -1
  43. package/dist/analyzer/operations.js +6 -0
  44. package/dist/analyzer/operations.js.map +1 -1
  45. package/dist/analyzer/packageTypeReport.js.map +1 -1
  46. package/dist/analyzer/packageTypeVerifier.js.map +1 -1
  47. package/dist/analyzer/parameterUtils.d.ts +1 -0
  48. package/dist/analyzer/parameterUtils.js +16 -2
  49. package/dist/analyzer/parameterUtils.js.map +1 -1
  50. package/dist/analyzer/parentDirectoryCache.js.map +1 -1
  51. package/dist/analyzer/parseTreeCleaner.js.map +1 -1
  52. package/dist/analyzer/parseTreeUtils.d.ts +1 -0
  53. package/dist/analyzer/parseTreeUtils.js +4 -3
  54. package/dist/analyzer/parseTreeUtils.js.map +1 -1
  55. package/dist/analyzer/parseTreeWalker.js.map +1 -1
  56. package/dist/analyzer/patternMatching.js +90 -61
  57. package/dist/analyzer/patternMatching.js.map +1 -1
  58. package/dist/analyzer/program.d.ts +1 -1
  59. package/dist/analyzer/program.js +2 -2
  60. package/dist/analyzer/program.js.map +1 -1
  61. package/dist/analyzer/properties.js +2 -2
  62. package/dist/analyzer/properties.js.map +1 -1
  63. package/dist/analyzer/protocols.js.map +1 -1
  64. package/dist/analyzer/pyTypedUtils.js.map +1 -1
  65. package/dist/analyzer/pythonPathUtils.js.map +1 -1
  66. package/dist/analyzer/scope.js.map +1 -1
  67. package/dist/analyzer/scopeUtils.js.map +1 -1
  68. package/dist/analyzer/service.js.map +1 -1
  69. package/dist/analyzer/sourceFile.js +4 -4
  70. package/dist/analyzer/sourceFile.js.map +1 -1
  71. package/dist/analyzer/sourceFileInfo.js +1 -1
  72. package/dist/analyzer/sourceFileInfo.js.map +1 -1
  73. package/dist/analyzer/sourceFileInfoUtils.js.map +1 -1
  74. package/dist/analyzer/sourceMapper.js.map +1 -1
  75. package/dist/analyzer/sourceMapperUtils.js.map +1 -1
  76. package/dist/analyzer/staticExpressions.js.map +1 -1
  77. package/dist/analyzer/symbol.js.map +1 -1
  78. package/dist/analyzer/symbolNameUtils.js.map +1 -1
  79. package/dist/analyzer/symbolUtils.js.map +1 -1
  80. package/dist/analyzer/testWalker.js.map +1 -1
  81. package/dist/analyzer/tracePrinter.js.map +1 -1
  82. package/dist/analyzer/typeCacheUtils.js.map +1 -1
  83. package/dist/analyzer/typeDocStringUtils.js.map +1 -1
  84. package/dist/analyzer/typeEvaluator.js +433 -334
  85. package/dist/analyzer/typeEvaluator.js.map +1 -1
  86. package/dist/analyzer/typeEvaluatorTypes.d.ts +1 -0
  87. package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
  88. package/dist/analyzer/typeEvaluatorWithTracker.js.map +1 -1
  89. package/dist/analyzer/typeGuards.js +10 -5
  90. package/dist/analyzer/typeGuards.js.map +1 -1
  91. package/dist/analyzer/typePrinter.js +1 -1
  92. package/dist/analyzer/typePrinter.js.map +1 -1
  93. package/dist/analyzer/typeStubWriter.js.map +1 -1
  94. package/dist/analyzer/typeUtils.d.ts +0 -1
  95. package/dist/analyzer/typeUtils.js +22 -8
  96. package/dist/analyzer/typeUtils.js.map +1 -1
  97. package/dist/analyzer/typeVarContext.d.ts +2 -2
  98. package/dist/analyzer/typeVarContext.js +10 -4
  99. package/dist/analyzer/typeVarContext.js.map +1 -1
  100. package/dist/analyzer/typeWalker.js.map +1 -1
  101. package/dist/analyzer/typedDicts.d.ts +6 -3
  102. package/dist/analyzer/typedDicts.js +292 -65
  103. package/dist/analyzer/typedDicts.js.map +1 -1
  104. package/dist/analyzer/types.d.ts +38 -26
  105. package/dist/analyzer/types.js +99 -72
  106. package/dist/analyzer/types.js.map +1 -1
  107. package/dist/backgroundAnalysis.js.map +1 -1
  108. package/dist/backgroundAnalysisBase.js.map +1 -1
  109. package/dist/backgroundThreadBase.js.map +1 -1
  110. package/dist/commands/commandController.js.map +1 -1
  111. package/dist/commands/commandResult.js.map +1 -1
  112. package/dist/commands/commands.js.map +1 -1
  113. package/dist/commands/createTypeStub.js.map +1 -1
  114. package/dist/commands/dumpFileDebugInfoCommand.js +18 -18
  115. package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
  116. package/dist/commands/quickActionCommand.js.map +1 -1
  117. package/dist/commands/restartServer.js.map +1 -1
  118. package/dist/common/cancellationUtils.d.ts +6 -1
  119. package/dist/common/cancellationUtils.js +18 -4
  120. package/dist/common/cancellationUtils.js.map +1 -1
  121. package/dist/common/charCodes.js.map +1 -1
  122. package/dist/common/chokidarFileWatcherProvider.js.map +1 -1
  123. package/dist/common/collectionUtils.js.map +1 -1
  124. package/dist/common/commandLineOptions.js.map +1 -1
  125. package/dist/common/commandUtils.js.map +1 -1
  126. package/dist/common/configOptions.js.map +1 -1
  127. package/dist/common/console.js.map +1 -1
  128. package/dist/common/core.js.map +1 -1
  129. package/dist/common/crypto.js.map +1 -1
  130. package/dist/common/debug.js.map +1 -1
  131. package/dist/common/deferred.js.map +1 -1
  132. package/dist/common/diagnostic.js.map +1 -1
  133. package/dist/common/diagnosticRules.js.map +1 -1
  134. package/dist/common/diagnosticSink.js.map +1 -1
  135. package/dist/common/editAction.js.map +1 -1
  136. package/dist/common/envVarUtils.d.ts +2 -1
  137. package/dist/common/envVarUtils.js +5 -1
  138. package/dist/common/envVarUtils.js.map +1 -1
  139. package/dist/common/extensibility.js.map +1 -1
  140. package/dist/common/extensions.js.map +1 -1
  141. package/dist/common/fileBasedCancellationUtils.js.map +1 -1
  142. package/dist/common/fileSystem.js.map +1 -1
  143. package/dist/common/fileWatcher.js.map +1 -1
  144. package/dist/common/fullAccessHost.js +1 -1
  145. package/dist/common/fullAccessHost.js.map +1 -1
  146. package/dist/common/host.js.map +1 -1
  147. package/dist/common/logTracker.js.map +1 -1
  148. package/dist/common/lspUtils.js.map +1 -1
  149. package/dist/common/memUtils.js.map +1 -1
  150. package/dist/common/pathConsts.js.map +1 -1
  151. package/dist/common/pathUtils.js.map +1 -1
  152. package/dist/common/positionUtils.js.map +1 -1
  153. package/dist/common/progressReporter.js.map +1 -1
  154. package/dist/common/pythonVersion.js.map +1 -1
  155. package/dist/common/realFileSystem.js +1 -1
  156. package/dist/common/realFileSystem.js.map +1 -1
  157. package/dist/common/serviceProvider.js.map +1 -1
  158. package/dist/common/serviceProviderExtensions.js.map +1 -1
  159. package/dist/common/stringUtils.js.map +1 -1
  160. package/dist/common/textEditTracker.js.map +1 -1
  161. package/dist/common/textRange.js.map +1 -1
  162. package/dist/common/textRangeCollection.js.map +1 -1
  163. package/dist/common/timing.js.map +1 -1
  164. package/dist/common/uri/baseUri.d.ts +2 -0
  165. package/dist/common/uri/baseUri.js +7 -7
  166. package/dist/common/uri/baseUri.js.map +1 -1
  167. package/dist/common/uri/emptyUri.d.ts +2 -0
  168. package/dist/common/uri/emptyUri.js +6 -0
  169. package/dist/common/uri/emptyUri.js.map +1 -1
  170. package/dist/common/uri/fileUri.d.ts +6 -4
  171. package/dist/common/uri/fileUri.js +18 -9
  172. package/dist/common/uri/fileUri.js.map +1 -1
  173. package/dist/common/uri/memoization.js.map +1 -1
  174. package/dist/common/uri/uri.d.ts +8 -0
  175. package/dist/common/uri/uri.js +16 -7
  176. package/dist/common/uri/uri.js.map +1 -1
  177. package/dist/common/uri/uriUtils.js.map +1 -1
  178. package/dist/common/uri/webUri.d.ts +3 -1
  179. package/dist/common/uri/webUri.js +21 -8
  180. package/dist/common/uri/webUri.js.map +1 -1
  181. package/dist/common/workspaceEditUtils.js.map +1 -1
  182. package/dist/languageServerBase.js.map +1 -1
  183. package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
  184. package/dist/languageService/autoImporter.d.ts +1 -0
  185. package/dist/languageService/autoImporter.js +3 -1
  186. package/dist/languageService/autoImporter.js.map +1 -1
  187. package/dist/languageService/callHierarchyProvider.js.map +1 -1
  188. package/dist/languageService/codeActionProvider.js.map +1 -1
  189. package/dist/languageService/completionProvider.js +11 -3
  190. package/dist/languageService/completionProvider.js.map +1 -1
  191. package/dist/languageService/completionProviderUtils.js.map +1 -1
  192. package/dist/languageService/definitionProvider.js.map +1 -1
  193. package/dist/languageService/documentHighlightProvider.js.map +1 -1
  194. package/dist/languageService/documentSymbolCollector.js.map +1 -1
  195. package/dist/languageService/documentSymbolProvider.js.map +1 -1
  196. package/dist/languageService/hoverProvider.js +1 -1
  197. package/dist/languageService/hoverProvider.js.map +1 -1
  198. package/dist/languageService/importSorter.js.map +1 -1
  199. package/dist/languageService/navigationUtils.js.map +1 -1
  200. package/dist/languageService/quickActions.js.map +1 -1
  201. package/dist/languageService/referencesProvider.js +11 -1
  202. package/dist/languageService/referencesProvider.js.map +1 -1
  203. package/dist/languageService/renameProvider.js.map +1 -1
  204. package/dist/languageService/signatureHelpProvider.js.map +1 -1
  205. package/dist/languageService/symbolIndexer.js.map +1 -1
  206. package/dist/languageService/tooltipUtils.js.map +1 -1
  207. package/dist/languageService/workspaceSymbolProvider.js.map +1 -1
  208. package/dist/localization/localize.d.ts +45 -3
  209. package/dist/localization/localize.js +16 -3
  210. package/dist/localization/localize.js.map +1 -1
  211. package/dist/localization/package.nls.cs.json +15 -9
  212. package/dist/localization/package.nls.de.json +17 -11
  213. package/dist/localization/package.nls.en-us.json +25 -12
  214. package/dist/localization/package.nls.es.json +16 -10
  215. package/dist/localization/package.nls.fr.json +16 -10
  216. package/dist/localization/package.nls.it.json +16 -10
  217. package/dist/localization/package.nls.ja.json +17 -11
  218. package/dist/localization/package.nls.ko.json +14 -8
  219. package/dist/localization/package.nls.pl.json +14 -8
  220. package/dist/localization/package.nls.pt-br.json +17 -11
  221. package/dist/localization/package.nls.qps-ploc.json +12 -6
  222. package/dist/localization/package.nls.ru.json +17 -11
  223. package/dist/localization/package.nls.tr.json +16 -10
  224. package/dist/localization/package.nls.zh-cn.json +17 -11
  225. package/dist/localization/package.nls.zh-tw.json +17 -11
  226. package/dist/nodeMain.js.map +1 -1
  227. package/dist/nodeServer.js.map +1 -1
  228. package/dist/parser/characterStream.js.map +1 -1
  229. package/dist/parser/characters.js.map +1 -1
  230. package/dist/parser/parseNodes.js.map +1 -1
  231. package/dist/parser/parser.js.map +1 -1
  232. package/dist/parser/stringTokenUtils.js.map +1 -1
  233. package/dist/parser/tokenizer.js.map +1 -1
  234. package/dist/parser/tokenizerTypes.js.map +1 -1
  235. package/dist/parser/unicode.js.map +1 -1
  236. package/dist/pprof/profiler.js.map +1 -1
  237. package/dist/pyright.js.map +1 -1
  238. package/dist/pyrightFileSystem.js.map +1 -1
  239. package/dist/readonlyAugmentedFileSystem.js.map +1 -1
  240. package/dist/server.d.ts +2 -1
  241. package/dist/server.js +9 -7
  242. package/dist/server.js.map +1 -1
  243. package/dist/tests/cacheManager.test.js.map +1 -1
  244. package/dist/tests/chainedSourceFiles.test.js.map +1 -1
  245. package/dist/tests/checker.test.js +0 -4
  246. package/dist/tests/checker.test.js.map +1 -1
  247. package/dist/tests/classDeclaration.test.js.map +1 -1
  248. package/dist/tests/collectionUtils.test.js.map +1 -1
  249. package/dist/tests/common.test.js.map +1 -1
  250. package/dist/tests/completions.test.js +23 -0
  251. package/dist/tests/completions.test.js.map +1 -1
  252. package/dist/tests/config.test.js +1 -2
  253. package/dist/tests/config.test.js.map +1 -1
  254. package/dist/tests/debug.test.js.map +1 -1
  255. package/dist/tests/deferred.test.js.map +1 -1
  256. package/dist/tests/diagnosticOverrides.test.js.map +1 -1
  257. package/dist/tests/diagnostics.test.js.map +1 -1
  258. package/dist/tests/docStringConversion.test.js.map +1 -1
  259. package/dist/tests/docStringUtils.test.js.map +1 -1
  260. package/dist/tests/documentSymbolCollector.test.js.map +1 -1
  261. package/dist/tests/envVarUtils.test.d.ts +1 -0
  262. package/dist/tests/envVarUtils.test.js +130 -0
  263. package/dist/tests/envVarUtils.test.js.map +1 -0
  264. package/dist/tests/filesystem.test.js.map +1 -1
  265. package/dist/tests/fourSlashParser.test.js.map +1 -1
  266. package/dist/tests/fourSlashRunner.test.js.map +1 -1
  267. package/dist/tests/fourslash/completions.autoimport.Lib.Found.Type.fourslash.js.map +1 -1
  268. package/dist/tests/fourslash/completions.autoimport.Lib.Found.duplication.fourslash.js.map +1 -1
  269. package/dist/tests/fourslash/completions.autoimport.Lib.NotFound.fourslash.js.map +1 -1
  270. package/dist/tests/fourslash/completions.autoimport.disabled.fourslash.js.map +1 -1
  271. package/dist/tests/fourslash/completions.autoimport.duplicates.fourslash.js.map +1 -1
  272. package/dist/tests/fourslash/completions.autoimport.fourslash.js.map +1 -1
  273. package/dist/tests/fourslash/completions.autoimport.fromImport.fourslash.js.map +1 -1
  274. package/dist/tests/fourslash/completions.autoimport.lib.alias.fourslash.js.map +1 -1
  275. package/dist/tests/fourslash/completions.autoimport.plainText.fourslash.js.map +1 -1
  276. package/dist/tests/fourslash/completions.autoimport.shadow.fourslash.js.map +1 -1
  277. package/dist/tests/fourslash/completions.autoimport.submodule.fourslash.js.map +1 -1
  278. package/dist/tests/fourslash/completions.autoimport.topLevel.fourslash.js.map +1 -1
  279. package/dist/tests/fourslash/completions.builtinDocstrings.fourslash.js.map +1 -1
  280. package/dist/tests/fourslash/completions.builtinOverride.fourslash.js.map +1 -1
  281. package/dist/tests/fourslash/completions.call.stringLiteral.fourslash.js.map +1 -1
  282. package/dist/tests/fourslash/completions.call.typedDict.fourslash.js.map +1 -1
  283. package/dist/tests/fourslash/completions.call.typedDict.list.fourslash.js.map +1 -1
  284. package/dist/tests/fourslash/completions.call.typedDict.states.fourslash.js.map +1 -1
  285. package/dist/tests/fourslash/completions.classVariable.fourslash.js.map +1 -1
  286. package/dist/tests/fourslash/completions.comment.fourslash.js.map +1 -1
  287. package/dist/tests/fourslash/completions.declNames.class.fourslash.js.map +1 -1
  288. package/dist/tests/fourslash/completions.declNames.exception.fourslash.js.map +1 -1
  289. package/dist/tests/fourslash/completions.declNames.for.fourslash.js.map +1 -1
  290. package/dist/tests/fourslash/completions.declNames.importAlias.fourslash.js.map +1 -1
  291. package/dist/tests/fourslash/completions.declNames.lambda.fourslash.js.map +1 -1
  292. package/dist/tests/fourslash/completions.declNames.method.fourslash.js.map +1 -1
  293. package/dist/tests/fourslash/completions.declNames.overload.fourslash.js.map +1 -1
  294. package/dist/tests/fourslash/completions.declNames.topLevelOverload.fourslash.js.map +1 -1
  295. package/dist/tests/fourslash/completions.dictionary.keys.complex.fourslash.js.map +1 -1
  296. package/dist/tests/fourslash/completions.dictionary.keys.expression.fourslash.js.map +1 -1
  297. package/dist/tests/fourslash/completions.dictionary.keys.literalTypes.fourslash.js.map +1 -1
  298. package/dist/tests/fourslash/completions.dictionary.keys.simple.fourslash.js.map +1 -1
  299. package/dist/tests/fourslash/completions.dictionary.keys.stringLiterals.fourslash.js.map +1 -1
  300. package/dist/tests/fourslash/completions.dictionary.keys.symbols.fourslash.js.map +1 -1
  301. package/dist/tests/fourslash/completions.dunderNew.Inheritance.fourslash.js.map +1 -1
  302. package/dist/tests/fourslash/completions.dunderNew.fourslash.js.map +1 -1
  303. package/dist/tests/fourslash/completions.enums.members.fourslash.js.map +1 -1
  304. package/dist/tests/fourslash/completions.errorNodes.fourslash.js.map +1 -1
  305. package/dist/tests/fourslash/completions.excluded.fourslash.js.map +1 -1
  306. package/dist/tests/fourslash/completions.fourslash.js.map +1 -1
  307. package/dist/tests/fourslash/completions.fstring.fourslash.js.map +1 -1
  308. package/dist/tests/fourslash/completions.fstring.stringLiteral.fourslash.js.map +1 -1
  309. package/dist/tests/fourslash/completions.fuzzyMatching.fourslash.js.map +1 -1
  310. package/dist/tests/fourslash/completions.importDunderNames.fourslash.js.map +1 -1
  311. package/dist/tests/fourslash/completions.importInterimFile.fourslash.disabled.js.map +1 -1
  312. package/dist/tests/fourslash/completions.importPrivateNoPytyped.fourslash.js.map +1 -1
  313. package/dist/tests/fourslash/completions.importPytyped.fourslash.js.map +1 -1
  314. package/dist/tests/fourslash/completions.importPytypedLocal.fourslash.js.map +1 -1
  315. package/dist/tests/fourslash/completions.importSubmodule.fourslash.js.map +1 -1
  316. package/dist/tests/fourslash/completions.importsDuplicates.fourslash.js.map +1 -1
  317. package/dist/tests/fourslash/completions.inList.fourslash.js.map +1 -1
  318. package/dist/tests/fourslash/completions.included.fourslash.js.map +1 -1
  319. package/dist/tests/fourslash/completions.indexer.keys.getitem.fourslash.js.map +1 -1
  320. package/dist/tests/fourslash/completions.inherited.function.docFromStub.fourslash.js.map +1 -1
  321. package/dist/tests/fourslash/completions.inherited.overload.docFromScrWithStub.fourslash.js.map +1 -1
  322. package/dist/tests/fourslash/completions.inherited.overload.docFromStub.fourslash.js.map +1 -1
  323. package/dist/tests/fourslash/completions.inherited.property.docFromSrc.fourslash.js.map +1 -1
  324. package/dist/tests/fourslash/completions.inherited.property.docFromStub.fourslash.js.map +1 -1
  325. package/dist/tests/fourslash/completions.keywords.pythonVersion.fourslash.js.map +1 -1
  326. package/dist/tests/fourslash/completions.libCodeAndStub.fourslash.js.map +1 -1
  327. package/dist/tests/fourslash/completions.libCodeNoStub.fourslash.js.map +1 -1
  328. package/dist/tests/fourslash/completions.libStub.fourslash.js.map +1 -1
  329. package/dist/tests/fourslash/completions.literals.fourslash.js.map +1 -1
  330. package/dist/tests/fourslash/completions.localCode.fourslash.js.map +1 -1
  331. package/dist/tests/fourslash/completions.moduleContext.UnknownMemberOnInstance.fourslash.js.map +1 -1
  332. package/dist/tests/fourslash/completions.moduleContext.UnknownStaticFunctionOnClass.fourslash.js.map +1 -1
  333. package/dist/tests/fourslash/completions.moduleContext.libCodeNoStub.fourslash.js.map +1 -1
  334. package/dist/tests/fourslash/completions.overloads.fourslash.js.map +1 -1
  335. package/dist/tests/fourslash/completions.override.default.fourslash.js.map +1 -1
  336. package/dist/tests/fourslash/completions.override.default.importStub.js.map +1 -1
  337. package/dist/tests/fourslash/completions.override.default.imported.fourslash.js.map +1 -1
  338. package/dist/tests/fourslash/completions.override.default.stub.fourslash.js.map +1 -1
  339. package/dist/tests/fourslash/completions.override.fourslash.js.map +1 -1
  340. package/dist/tests/fourslash/completions.override.property.fourslash.js.map +1 -1
  341. package/dist/tests/fourslash/completions.override.property.stub.fourslash.js.map +1 -1
  342. package/dist/tests/fourslash/completions.override.staticAndClassmethod.fourslash.js.map +1 -1
  343. package/dist/tests/fourslash/completions.override.stub.fourslash.js.map +1 -1
  344. package/dist/tests/fourslash/completions.override2.fourslash.js.map +1 -1
  345. package/dist/tests/fourslash/completions.parameters.fourslash.js.map +1 -1
  346. package/dist/tests/fourslash/completions.params.fourslash.js.map +1 -1
  347. package/dist/tests/fourslash/completions.parentFolder.fourslash.js.map +1 -1
  348. package/dist/tests/fourslash/completions.parentFolders.fourslash.js.map +1 -1
  349. package/dist/tests/fourslash/completions.plainText.fourslash.js.map +1 -1
  350. package/dist/tests/fourslash/completions.private.fourslash.js.map +1 -1
  351. package/dist/tests/fourslash/completions.property.fourslash.js.map +1 -1
  352. package/dist/tests/fourslash/completions.propertyDocStrings.fourslash.js.map +1 -1
  353. package/dist/tests/fourslash/completions.self.fourslash.js.map +1 -1
  354. package/dist/tests/fourslash/completions.stringLiteral.escape.fourslash.js.map +1 -1
  355. package/dist/tests/fourslash/completions.stringLiteral.fourslash.js.map +1 -1
  356. package/dist/tests/fourslash/completions.triggers.fourslash.js.map +1 -1
  357. package/dist/tests/fourslash/completions.typeAlias.fourslash.js.map +1 -1
  358. package/dist/tests/fourslash/completions.typeshed.fourslash.js.map +1 -1
  359. package/dist/tests/fourslash/completions.vardecls.fourslash.js.map +1 -1
  360. package/dist/tests/fourslash/completions.variableDocStrings.fourslash.js.map +1 -1
  361. package/dist/tests/fourslash/completions.wildcardimports.fourslash.js.map +1 -1
  362. package/dist/tests/fourslash/completions.with.fourslash.js.map +1 -1
  363. package/dist/tests/fourslash/diagnostics.missingModuleSource.fourslash.js.map +1 -1
  364. package/dist/tests/fourslash/findDefinitions.builtinClass.fourslash.js.map +1 -1
  365. package/dist/tests/fourslash/findDefinitions.classes.fourslash.js.map +1 -1
  366. package/dist/tests/fourslash/findDefinitions.definitionFilter.preferSource.fourslash.js.map +1 -1
  367. package/dist/tests/fourslash/findDefinitions.definitionFilter.preferSource.onlyStubs.js.map +1 -1
  368. package/dist/tests/fourslash/findDefinitions.definitionFilter.preferStub.fourslash.js.map +1 -1
  369. package/dist/tests/fourslash/findDefinitions.definitionFilter.preferStub.onlySource.fourslash.js.map +1 -1
  370. package/dist/tests/fourslash/findDefinitions.fields.fourslash.js.map +1 -1
  371. package/dist/tests/fourslash/findDefinitions.functions.fourslash.js.map +1 -1
  372. package/dist/tests/fourslash/findDefinitions.methods.fourslash.js.map +1 -1
  373. package/dist/tests/fourslash/findDefinitions.modules.fourslash.js.map +1 -1
  374. package/dist/tests/fourslash/findDefinitions.namespaceImport.fourslash.js.map +1 -1
  375. package/dist/tests/fourslash/findDefinitions.namespaceImportWithInit.fourslash.js.map +1 -1
  376. package/dist/tests/fourslash/findDefinitions.overloads.fourslash.js.map +1 -1
  377. package/dist/tests/fourslash/findDefinitions.parameters.fourslash.js.map +1 -1
  378. package/dist/tests/fourslash/findDefinitions.sourceAndStub.function.fourslash.js.map +1 -1
  379. package/dist/tests/fourslash/findDefinitions.sourceAndStub.innerClass.fourslash.js.map +1 -1
  380. package/dist/tests/fourslash/findDefinitions.sourceAndStub.innerClassMethod.fourslash.js.map +1 -1
  381. package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClass.fourslash.js.map +1 -1
  382. package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassMethod.fourslash.js.map +1 -1
  383. package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadOnly.fourslash.js.map +1 -1
  384. package/dist/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadWrite.fourslash.js.map +1 -1
  385. package/dist/tests/fourslash/findDefinitions.sourceOnly.class.fourslash.js.map +1 -1
  386. package/dist/tests/fourslash/findDefinitions.sourceOnly.function1.fourslash.js.map +1 -1
  387. package/dist/tests/fourslash/findDefinitions.sourceOnly.function2.fourslash.js.map +1 -1
  388. package/dist/tests/fourslash/findDefinitions.sourceOnly.relativeImport1.fourslash.js.map +1 -1
  389. package/dist/tests/fourslash/findDefinitions.sourceOnly.relativeImport2.fourslash.js.map +1 -1
  390. package/dist/tests/fourslash/findDefinitions.stubOnly.fourslash.js.map +1 -1
  391. package/dist/tests/fourslash/findDefinitions.stubPackages.fourslash.js.map +1 -1
  392. package/dist/tests/fourslash/findDefinitions.typedDict.keys.fourslash.js.map +1 -1
  393. package/dist/tests/fourslash/findDefinitions.variables.fourslash.js.map +1 -1
  394. package/dist/tests/fourslash/findDefinitions.wildcardimports.fourslash.js.map +1 -1
  395. package/dist/tests/fourslash/findTypeDefinitions.builtinClass.fourslash.js.map +1 -1
  396. package/dist/tests/fourslash/findTypeDefinitions.classes.fourslash.js.map +1 -1
  397. package/dist/tests/fourslash/findTypeDefinitions.unions.fourslash.js.map +1 -1
  398. package/dist/tests/fourslash/findallreferences.classPropertyReadWrite.js.map +1 -1
  399. package/dist/tests/fourslash/findallreferences.fourslash.js.map +1 -1
  400. package/dist/tests/fourslash/findallreferences.importalias.fourslash.js.map +1 -1
  401. package/dist/tests/fourslash/findallreferences.invokedFromLibrary.fourslash.js.map +1 -1
  402. package/dist/tests/fourslash/findallreferences.module.nested.fourslash.js.map +1 -1
  403. package/dist/tests/fourslash/findallreferences.modules.duplicated.fourslash.js.map +1 -1
  404. package/dist/tests/fourslash/findallreferences.modules.fourslash.js.map +1 -1
  405. package/dist/tests/fourslash/findallreferences.modules.shadow.fourslash.js.map +1 -1
  406. package/dist/tests/fourslash/findallreferences.openFiles.fourslash.js.map +1 -1
  407. package/dist/tests/fourslash/findallreferences.parameter.fourslash.js.map +1 -1
  408. package/dist/tests/fourslash/findallreferences.sourceAndStub.class.fourslash.js.map +1 -1
  409. package/dist/tests/fourslash/findallreferences.sourceAndStub.classMethod.fourslash.js.map +1 -1
  410. package/dist/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadOnly.fourslash.js.map +1 -1
  411. package/dist/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadWrite.fourslash.skip.js.map +1 -1
  412. package/dist/tests/fourslash/findallreferences.sourceAndStub.function.fourslash.js.map +1 -1
  413. package/dist/tests/fourslash/findallreferences.variable.fourslash.js.map +1 -1
  414. package/dist/tests/fourslash/fourslash.js.map +1 -1
  415. package/dist/tests/fourslash/highlightreferences.attributes.fourslash.js.map +1 -1
  416. package/dist/tests/fourslash/hover.async.fourslash.js.map +1 -1
  417. package/dist/tests/fourslash/hover.builtinDocstrings.fourslash.js.map +1 -1
  418. package/dist/tests/fourslash/hover.class.docString.fourslash.js.map +1 -1
  419. package/dist/tests/fourslash/hover.classNoInit.fourslash.js.map +1 -1
  420. package/dist/tests/fourslash/hover.docFromSrc.fourslash.js.map +1 -1
  421. package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module1.fourslash.js.map +1 -1
  422. package/dist/tests/fourslash/hover.docFromSrc.pkg-vs-module2.fourslash.js.map +1 -1
  423. package/dist/tests/fourslash/hover.docFromSrc.relativeImport1.fourslash.js.map +1 -1
  424. package/dist/tests/fourslash/hover.docFromSrc.relativeImport2.fourslash.js.map +1 -1
  425. package/dist/tests/fourslash/hover.docFromSrc.relativeImport3.fourslash.js.map +1 -1
  426. package/dist/tests/fourslash/hover.docFromSrc.stringFormat.fourslash.js.map +1 -1
  427. package/dist/tests/fourslash/hover.docFromSrc.stubs-package.fourslash.js.map +1 -1
  428. package/dist/tests/fourslash/hover.docFromSrc.typeshed.fourslash.js.map +1 -1
  429. package/dist/tests/fourslash/hover.docstring.alias.fourslash.js.map +1 -1
  430. package/dist/tests/fourslash/hover.docstring.links.fourslash.js.map +1 -1
  431. package/dist/tests/fourslash/hover.docstring.overloads.fourslash.js.map +1 -1
  432. package/dist/tests/fourslash/hover.docstring.parameter.fourslash.js.map +1 -1
  433. package/dist/tests/fourslash/hover.docstring.split.fourslash.js.map +1 -1
  434. package/dist/tests/fourslash/hover.dunderNew.basic.fourslash.js.map +1 -1
  435. package/dist/tests/fourslash/hover.dunderNew.inheritance.fourslash.js.map +1 -1
  436. package/dist/tests/fourslash/hover.dunderNew.inheritance2.fourslash.js.map +1 -1
  437. package/dist/tests/fourslash/hover.dunderNew.overloads.fourslash.js.map +1 -1
  438. package/dist/tests/fourslash/hover.dunderNew.withInit.fourslash.js.map +1 -1
  439. package/dist/tests/fourslash/hover.formatted.fourslash.js.map +1 -1
  440. package/dist/tests/fourslash/hover.fourslash.js.map +1 -1
  441. package/dist/tests/fourslash/hover.import.django.view.fourslash.js.map +1 -1
  442. package/dist/tests/fourslash/hover.import.fourslash.js.map +1 -1
  443. package/dist/tests/fourslash/hover.inferred.fourslash.js.map +1 -1
  444. package/dist/tests/fourslash/hover.inherited.docFromSrc.fourslash.js.map +1 -1
  445. package/dist/tests/fourslash/hover.inherited.docFromSrcWithStub.fourslash.js.map +1 -1
  446. package/dist/tests/fourslash/hover.inherited.docFromStub.fourslash.js.map +1 -1
  447. package/dist/tests/fourslash/hover.inherited.overload.docFromSrcWithStub.fourslash.js.map +1 -1
  448. package/dist/tests/fourslash/hover.inherited.overload.docFromStub.fourslash.js.map +1 -1
  449. package/dist/tests/fourslash/hover.inherited.property.docFromSrcWithStub.fourslash.js.map +1 -1
  450. package/dist/tests/fourslash/hover.inherited.property.docFromStub.fourslash.js.map +1 -1
  451. package/dist/tests/fourslash/hover.init.fourslash.js.map +1 -1
  452. package/dist/tests/fourslash/hover.libCodeAndStub.fourslash.js.map +1 -1
  453. package/dist/tests/fourslash/hover.libCodeNoStub.fourslash.js.map +1 -1
  454. package/dist/tests/fourslash/hover.libStub.fourslash.js.map +1 -1
  455. package/dist/tests/fourslash/hover.optionalAliasParameter.fourslash.js.map +1 -1
  456. package/dist/tests/fourslash/hover.overloadedFunction.fourslash.js.map +1 -1
  457. package/dist/tests/fourslash/hover.plainText.fourslash.js.map +1 -1
  458. package/dist/tests/fourslash/hover.slots.fourslash.js.map +1 -1
  459. package/dist/tests/fourslash/hover.typedDict.key.fourslash.js.map +1 -1
  460. package/dist/tests/fourslash/hover.unpackedTypedDict.key.fourslash.js.map +1 -1
  461. package/dist/tests/fourslash/hover.variable.docString.fourslash.js.map +1 -1
  462. package/dist/tests/fourslash/hover.wildcardimports.fourslash.js.map +1 -1
  463. package/dist/tests/fourslash/import.multipart.fourslash.js.map +1 -1
  464. package/dist/tests/fourslash/import.publicSymbols.fourslash.js.map +1 -1
  465. package/dist/tests/fourslash/import.pytyped.dunderAll.fourslash.js.map +1 -1
  466. package/dist/tests/fourslash/import.pytyped.privateSymbols.fourslash.js.map +1 -1
  467. package/dist/tests/fourslash/import.pytyped.typeCheckingBasic.fourslash.js.map +1 -1
  468. package/dist/tests/fourslash/import.pytyped.typeCheckingOff.fourslash.js.map +1 -1
  469. package/dist/tests/fourslash/import.wildcard.fourslash.js.map +1 -1
  470. package/dist/tests/fourslash/importnotresolved.fourslash.js.map +1 -1
  471. package/dist/tests/fourslash/missingModuleSource.disablingInStrictMode.fourslash.js.map +1 -1
  472. package/dist/tests/fourslash/missingModuleSource.fourslash.js.map +1 -1
  473. package/dist/tests/fourslash/missingTypeStub.codeAction.fourslash.js.map +1 -1
  474. package/dist/tests/fourslash/missingTypeStub.command.multipart.fourslash.js.map +1 -1
  475. package/dist/tests/fourslash/missingTypeStub.command.singlefile.fourslash.js.map +1 -1
  476. package/dist/tests/fourslash/missingTypeStub.command.singlepart.fourslash.js.map +1 -1
  477. package/dist/tests/fourslash/missingTypeStub.command.trycatchImport.fourslash.js.map +1 -1
  478. package/dist/tests/fourslash/missingTypeStub.fourslash.js.map +1 -1
  479. package/dist/tests/fourslash/missingTypeStub.invokeCodeAction.fourslash.js.map +1 -1
  480. package/dist/tests/fourslash/noerrors.fourslash.js.map +1 -1
  481. package/dist/tests/fourslash/orderImports1.command.fourslash.js.map +1 -1
  482. package/dist/tests/fourslash/orderImports2.command.fourslash.js.map +1 -1
  483. package/dist/tests/fourslash/rename.externallyHidden.fourslash.js.map +1 -1
  484. package/dist/tests/fourslash/rename.externallyHidden.params.fourslash.js.map +1 -1
  485. package/dist/tests/fourslash/rename.fourslash.js.map +1 -1
  486. package/dist/tests/fourslash/rename.function.untitledFile.fourslash.js.map +1 -1
  487. package/dist/tests/fourslash/rename.init.fourslash.js.map +1 -1
  488. package/dist/tests/fourslash/rename.library.fourslash.js.map +1 -1
  489. package/dist/tests/fourslash/rename.library.sourceAndStub.fourslash.js.map +1 -1
  490. package/dist/tests/fourslash/rename.multipleDecl.fourslash.d.ts +1 -1
  491. package/dist/tests/fourslash/rename.multipleDecl.fourslash.js.map +1 -1
  492. package/dist/tests/fourslash/rename.parens.fourslash.js.map +1 -1
  493. package/dist/tests/fourslash/rename.sourceAndStub.fourslash.js.map +1 -1
  494. package/dist/tests/fourslash/rename.string.excluded.fourslash.js.map +1 -1
  495. package/dist/tests/fourslash/rename.string.fourslash.js.map +1 -1
  496. package/dist/tests/fourslash/shadowedImports.fourslash.js.map +1 -1
  497. package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedFunction.fourslash.js.map +1 -1
  498. package/dist/tests/fourslash/showcallhierarchy.incomingCalls.aliasedVariable.fourslash.js.map +1 -1
  499. package/dist/tests/fourslash/showcallhierarchy.incomingCalls.function.fourslash.js.map +1 -1
  500. package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.aliasedFunction1.fourslash.js.map +1 -1
  501. package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.aliasedFunction2.fourslash.js.map +1 -1
  502. package/dist/tests/fourslash/showcallhierarchy.outgoingCalls.function.fourslash.js.map +1 -1
  503. package/dist/tests/fourslash/signature.builtinDocstrings.fourslash.js.map +1 -1
  504. package/dist/tests/fourslash/signature.complicated.fourslash.js.map +1 -1
  505. package/dist/tests/fourslash/signature.cornercases.fourslash.js.map +1 -1
  506. package/dist/tests/fourslash/signature.docstrings.fourslash.js.map +1 -1
  507. package/dist/tests/fourslash/signature.docstrings.overloaded.fourslash.js.map +1 -1
  508. package/dist/tests/fourslash/signature.docstrings.wildcardimports.fourslash.js.map +1 -1
  509. package/dist/tests/fourslash/signature.dunderNew.fourslash.js.map +1 -1
  510. package/dist/tests/fourslash/signature.overload.fourslash.js.map +1 -1
  511. package/dist/tests/fourslash/signature.simple.fourslash.js.map +1 -1
  512. package/dist/tests/fourslash/typeVerifier.fourslash.js.map +1 -1
  513. package/dist/tests/harness/fourslash/fourSlashParser.js.map +1 -1
  514. package/dist/tests/harness/fourslash/fourSlashTypes.js.map +1 -1
  515. package/dist/tests/harness/fourslash/runner.js +1 -1
  516. package/dist/tests/harness/fourslash/runner.js.map +1 -1
  517. package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
  518. package/dist/tests/harness/fourslash/testState.Consts.js.map +1 -1
  519. package/dist/tests/harness/fourslash/testState.d.ts +0 -13
  520. package/dist/tests/harness/fourslash/testState.js +11 -0
  521. package/dist/tests/harness/fourslash/testState.js.map +1 -1
  522. package/dist/tests/harness/fourslash/testStateUtils.js.map +1 -1
  523. package/dist/tests/harness/fourslash/workspaceEditTestUtils.js.map +1 -1
  524. package/dist/tests/harness/testAccessHost.js.map +1 -1
  525. package/dist/tests/harness/testHost.js.map +1 -1
  526. package/dist/tests/harness/utils.js.map +1 -1
  527. package/dist/tests/harness/vfs/factory.js.map +1 -1
  528. package/dist/tests/harness/vfs/filesystem.js.map +1 -1
  529. package/dist/tests/harness/vfs/pathValidation.js.map +1 -1
  530. package/dist/tests/hoverProvider.test.js.map +1 -1
  531. package/dist/tests/importResolver.test.js.map +1 -1
  532. package/dist/tests/importStatementUtils.test.js +8 -0
  533. package/dist/tests/importStatementUtils.test.js.map +1 -1
  534. package/dist/tests/ipythonMode.test.js.map +1 -1
  535. package/dist/tests/languageServer.test.d.ts +1 -0
  536. package/dist/tests/languageServer.test.js +137 -0
  537. package/dist/tests/languageServer.test.js.map +1 -0
  538. package/dist/tests/localizer.test.js.map +1 -1
  539. package/dist/tests/logger.test.js.map +1 -1
  540. package/dist/tests/lsp/customLsp.d.ts +112 -0
  541. package/dist/tests/lsp/customLsp.js +67 -0
  542. package/dist/tests/lsp/customLsp.js.map +1 -0
  543. package/dist/tests/lsp/languageServer.d.ts +1 -0
  544. package/dist/tests/lsp/languageServer.js +326 -0
  545. package/dist/tests/lsp/languageServer.js.map +1 -0
  546. package/dist/tests/lsp/languageServerTestUtils.d.ts +100 -0
  547. package/dist/tests/lsp/languageServerTestUtils.js +803 -0
  548. package/dist/tests/lsp/languageServerTestUtils.js.map +1 -0
  549. package/dist/tests/lsp/main.d.ts +1 -0
  550. package/dist/tests/lsp/main.js +12 -0
  551. package/dist/tests/lsp/main.js.map +1 -0
  552. package/dist/tests/lsp/webpack.testserver.config.d.ts +4 -0
  553. package/dist/tests/lsp/webpack.testserver.config.js +64 -0
  554. package/dist/tests/lsp/webpack.testserver.config.js.map +1 -0
  555. package/dist/tests/parseTreeUtils.test.js.map +1 -1
  556. package/dist/tests/parser.test.js.map +1 -1
  557. package/dist/tests/pathUtils.test.js.map +1 -1
  558. package/dist/tests/positionUtils.test.js.map +1 -1
  559. package/dist/tests/pyrightFileSystem.test.js.map +1 -1
  560. package/dist/tests/serialization.test.js.map +1 -1
  561. package/dist/tests/service.test.js.map +1 -1
  562. package/dist/tests/signatureHelp.test.js.map +1 -1
  563. package/dist/tests/sourceFile.test.js.map +1 -1
  564. package/dist/tests/sourceMapperUtils.test.js.map +1 -1
  565. package/dist/tests/stringUtils.test.js.map +1 -1
  566. package/dist/tests/symbolNameUtils.test.js.map +1 -1
  567. package/dist/tests/testState.test.js.map +1 -1
  568. package/dist/tests/testStateUtils.js.map +1 -1
  569. package/dist/tests/testUtils.js.map +1 -1
  570. package/dist/tests/textEditUtil.test.js.map +1 -1
  571. package/dist/tests/textRange.test.js.map +1 -1
  572. package/dist/tests/tokenizer.test.js.map +1 -1
  573. package/dist/tests/typeEvaluator1.test.js +21 -5
  574. package/dist/tests/typeEvaluator1.test.js.map +1 -1
  575. package/dist/tests/typeEvaluator2.test.js +8 -4
  576. package/dist/tests/typeEvaluator2.test.js.map +1 -1
  577. package/dist/tests/typeEvaluator3.test.js +5 -9
  578. package/dist/tests/typeEvaluator3.test.js.map +1 -1
  579. package/dist/tests/typeEvaluator4.test.js +1 -1
  580. package/dist/tests/typeEvaluator4.test.js.map +1 -1
  581. package/dist/tests/typeEvaluator5.test.js +43 -1
  582. package/dist/tests/typeEvaluator5.test.js.map +1 -1
  583. package/dist/tests/typePrinter.test.js.map +1 -1
  584. package/dist/tests/uri.test.js +74 -26
  585. package/dist/tests/uri.test.js.map +1 -1
  586. package/dist/tests/workspaceEditUtils.test.js.map +1 -1
  587. package/dist/tests/zipfs.test.js.map +1 -1
  588. package/dist/workspaceFactory.js +2 -1
  589. package/dist/workspaceFactory.js.map +1 -1
  590. package/package.json +23 -15
  591. package/dist/analyzer/regions.d.ts +0 -11
  592. package/dist/analyzer/regions.js +0 -62
  593. package/dist/analyzer/regions.js.map +0 -1
@@ -198,6 +198,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
198
198
  let dictClassType;
199
199
  let typedDictClassType;
200
200
  let typedDictPrivateClassType;
201
+ let supportsKeysAndGetItemProtocolType;
201
202
  let mappingType;
202
203
  let printExpressionSpaceCount = 0;
203
204
  let incompleteGenerationCount = 0;
@@ -466,7 +467,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
466
467
  functionObj = getBuiltInObject(node, 'function');
467
468
  unionClassType = getTypesType(node, 'UnionType');
468
469
  if (unionClassType && (0, types_1.isClass)(unionClassType)) {
469
- unionClassType.details.flags |= 1073741824 /* ClassTypeFlags.SpecialFormClass */;
470
+ unionClassType.details.flags |= -2147483648 /* ClassTypeFlags.SpecialFormClass */;
470
471
  }
471
472
  // Initialize and cache "Collection" to break a cyclical dependency
472
473
  // that occurs when resolving tuple below.
@@ -483,10 +484,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
483
484
  typedDictClassType = getTypingType(node, 'TypedDict');
484
485
  typedDictPrivateClassType = getTypingType(node, '_TypedDict');
485
486
  awaitableProtocolType = getTypingType(node, 'Awaitable');
486
- mappingType = getTypeshedType(node, 'SupportsKeysAndGetItem');
487
- if (!mappingType) {
487
+ mappingType = getTypingType(node, 'Mapping');
488
+ supportsKeysAndGetItemProtocolType = getTypeshedType(node, 'SupportsKeysAndGetItem');
489
+ if (!supportsKeysAndGetItemProtocolType) {
488
490
  // Fall back on 'Mapping' if 'SupportsKeysAndGetItem' is not available.
489
- mappingType = getTypingType(node, 'Mapping');
491
+ supportsKeysAndGetItemProtocolType = mappingType;
490
492
  }
491
493
  // Wire up the `Any` class to the special-form version of our internal AnyType.
492
494
  const objectClass = getBuiltInType(node, 'object');
@@ -494,7 +496,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
494
496
  (0, types_1.isInstantiableClass)(objectClass) &&
495
497
  typeClassType &&
496
498
  (0, types_1.isInstantiableClass)(typeClassType)) {
497
- const anyClass = types_1.ClassType.createInstantiable('Any', 'typing.Any', 'typing', uri_1.Uri.empty(), 1 /* ClassTypeFlags.BuiltInClass */,
499
+ const anyClass = types_1.ClassType.createInstantiable('Any', 'typing.Any', 'typing', uri_1.Uri.empty(), 1 /* ClassTypeFlags.BuiltInClass */ | -2147483648 /* ClassTypeFlags.SpecialFormClass */,
498
500
  /* typeSourceId */ -1,
499
501
  /* declaredMetaclass */ undefined,
500
502
  /* effectiveMetaclass */ typeClassType);
@@ -1002,11 +1004,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
1002
1004
  function stripLiteralValue(type) {
1003
1005
  var _a, _b, _c;
1004
1006
  // Handle the not-uncommon case where the type is a union that consists
1005
- // only of literal str or literal int values.
1007
+ // only of literal values.
1006
1008
  if ((0, types_1.isUnion)(type) && type.subtypes.length > 0) {
1007
- if (((_a = type.literalStrMap) === null || _a === void 0 ? void 0 : _a.size) === type.subtypes.length ||
1008
- ((_b = type.literalIntMap) === null || _b === void 0 ? void 0 : _b.size) === type.subtypes.length ||
1009
- ((_c = type.literalEnumMap) === null || _c === void 0 ? void 0 : _c.size) === type.subtypes.length) {
1009
+ if (((_a = type.literalInstances.literalStrMap) === null || _a === void 0 ? void 0 : _a.size) === type.subtypes.length ||
1010
+ ((_b = type.literalInstances.literalIntMap) === null || _b === void 0 ? void 0 : _b.size) === type.subtypes.length ||
1011
+ ((_c = type.literalInstances.literalEnumMap) === null || _c === void 0 ? void 0 : _c.size) === type.subtypes.length) {
1010
1012
  return stripLiteralValue(type.subtypes[0]);
1011
1013
  }
1012
1014
  }
@@ -1392,7 +1394,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
1392
1394
  // an instance of a class. Limit access to metaclass instance members
1393
1395
  // in this case.
1394
1396
  if (!objectTypeIsInstantiable) {
1395
- effectiveFlags |= 32 /* MemberAccessFlags.SkipClassMembers */ | 512 /* MemberAccessFlags.SkipAttributeAccessOverride */;
1397
+ effectiveFlags |=
1398
+ 32 /* MemberAccessFlags.SkipClassMembers */ |
1399
+ 512 /* MemberAccessFlags.SkipAttributeAccessOverride */ |
1400
+ 8 /* MemberAccessFlags.SkipTypeBaseClass */;
1396
1401
  effectiveFlags &= ~16 /* MemberAccessFlags.SkipInstanceMembers */;
1397
1402
  }
1398
1403
  const metaclassDiag = diag ? new diagnostic_1.DiagnosticAddendum() : undefined;
@@ -1579,7 +1584,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
1579
1584
  // If the function includes a `**kwargs: Unpack[TypedDict]` parameter, the
1580
1585
  // parameter is expanded to include individual keyword args.
1581
1586
  function expandTypedKwargs(functionType) {
1582
- var _a;
1587
+ var _a, _b;
1583
1588
  const kwargsIndex = functionType.details.parameters.findIndex((param) => param.category === 2 /* ParameterCategory.KwargsDict */);
1584
1589
  if (kwargsIndex < 0) {
1585
1590
  return functionType;
@@ -1589,7 +1594,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
1589
1594
  if (!(0, types_1.isClassInstance)(kwargsType) || !types_1.ClassType.isTypedDictClass(kwargsType) || !kwargsType.isUnpacked) {
1590
1595
  return functionType;
1591
1596
  }
1592
- const tdEntries = (_a = kwargsType.typedDictNarrowedEntries) !== null && _a !== void 0 ? _a : kwargsType.details.typedDictEntries;
1597
+ const tdEntries = (_a = kwargsType.typedDictNarrowedEntries) !== null && _a !== void 0 ? _a : (_b = kwargsType.details.typedDictEntries) === null || _b === void 0 ? void 0 : _b.knownItems;
1593
1598
  if (!tdEntries) {
1594
1599
  return functionType;
1595
1600
  }
@@ -1779,8 +1784,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
1779
1784
  let isValidIterator = true;
1780
1785
  let type = (0, typeUtils_1.transformPossibleRecursiveTypeAlias)(typeResult.type);
1781
1786
  type = makeTopLevelTypeVarsConcrete(type);
1782
- if ((0, typeUtils_1.isOptionalType)(type)) {
1783
- if (!typeResult.isIncomplete && emitNotIterableError) {
1787
+ type = (0, types_1.removeUnbound)(type);
1788
+ if ((0, typeUtils_1.isOptionalType)(type) && emitNotIterableError) {
1789
+ if (!typeResult.isIncomplete) {
1784
1790
  addDiagnostic(diagnosticRules_1.DiagnosticRule.reportOptionalIterable, localize_1.LocMessage.noneNotIterable(), errorNode);
1785
1791
  }
1786
1792
  type = (0, typeUtils_1.removeNoneFromUnion)(type);
@@ -2418,15 +2424,16 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
2418
2424
  });
2419
2425
  // Have we accounted for all of the targets and sources? If not, we have a size mismatch.
2420
2426
  if (sourceEntryTypes.length !== targetExpressions.length) {
2421
- const expectedEntryCount = unpackIndex >= 0 ? targetExpressions.length - 1 : targetExpressions.length;
2422
2427
  const subDiag = diagAddendum.createAddendum();
2423
2428
  subDiag.addMessage((target.nodeType === 31 /* ParseNodeType.List */
2424
2429
  ? localize_1.LocAddendum.listAssignmentMismatch()
2425
2430
  : localize_1.LocAddendum.tupleAssignmentMismatch()).format({
2426
2431
  type: printType(subtype),
2427
2432
  }));
2428
- subDiag.createAddendum().addMessage(localize_1.LocAddendum.tupleSizeMismatch().format({
2429
- expected: expectedEntryCount,
2433
+ subDiag.createAddendum().addMessage((unpackIndex >= 0
2434
+ ? localize_1.LocAddendum.tupleSizeMismatchIndeterminateDest()
2435
+ : localize_1.LocAddendum.tupleSizeMismatch()).format({
2436
+ expected: unpackIndex >= 0 ? targetExpressions.length - 1 : targetExpressions.length,
2430
2437
  received: sourceEntryTypes.length,
2431
2438
  }));
2432
2439
  }
@@ -2493,11 +2500,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
2493
2500
  var _a, _b;
2494
2501
  if ((0, types_1.isParamSpec)(subtype)) {
2495
2502
  if (subtype.paramSpecAccess === 'args') {
2496
- if (tupleClassType &&
2497
- (0, types_1.isInstantiableClass)(tupleClassType) &&
2498
- objectType &&
2499
- (0, types_1.isClassInstance)(objectType)) {
2500
- return types_1.ClassType.cloneAsInstance((0, typeUtils_1.specializeTupleClass)(tupleClassType, [{ type: objectType, isUnbounded: true }]));
2503
+ if (objectType && (0, types_1.isClassInstance)(objectType)) {
2504
+ return makeTupleObject([{ type: objectType, isUnbounded: true }]);
2501
2505
  }
2502
2506
  return types_1.UnknownType.create();
2503
2507
  }
@@ -3282,9 +3286,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3282
3286
  defaultType = (0, typeUtils_1.applySolvedTypeVars)(param, typeVarContext, { unknownIfNotFound: true });
3283
3287
  }
3284
3288
  else if (param.details.isVariadic && tupleClassType && (0, types_1.isInstantiableClass)(tupleClassType)) {
3285
- defaultType = types_1.ClassType.cloneForUnpacked((0, typeUtils_1.specializeTupleClass)(types_1.ClassType.cloneAsInstance(tupleClassType), [
3286
- { type: types_1.UnknownType.create(), isUnbounded: true },
3287
- ]));
3289
+ defaultType = makeTupleObject([{ type: types_1.UnknownType.create(), isUnbounded: true }],
3290
+ /* isUnpackedTuple */ true);
3288
3291
  }
3289
3292
  else {
3290
3293
  defaultType = types_1.UnknownType.create();
@@ -3904,18 +3907,18 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3904
3907
  else {
3905
3908
  resultType = subtype;
3906
3909
  }
3907
- // If this is a "set" operation, we have a bit more work to do.
3908
- if (usage.method !== 'set') {
3910
+ // If this is a "set" or "delete" operation, we have a bit more work to do.
3911
+ if (usage.method === 'get') {
3909
3912
  return resultType;
3910
3913
  }
3911
- // Check for an attempt to overwrite a ClassVar member from an instance.
3914
+ // Check for an attempt to overwrite or delete a ClassVar member from an instance.
3912
3915
  if (!isDescriptorApplied &&
3913
3916
  (memberInfo === null || memberInfo === void 0 ? void 0 : memberInfo.symbol.isClassVar()) &&
3914
3917
  (flags & 128 /* MemberAccessFlags.DisallowClassVarWrites */) !== 0) {
3915
3918
  diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocAddendum.memberSetClassVar().format({ name: memberName }));
3916
3919
  isDescriptorError = true;
3917
3920
  }
3918
- // Check for an attempt to overwrite a final member variable.
3921
+ // Check for an attempt to overwrite or delete a final member variable.
3919
3922
  const finalVarTypeDecl = memberInfo === null || memberInfo === void 0 ? void 0 : memberInfo.symbol.getDeclarations().find((decl) => isFinalVariableDeclaration(decl));
3920
3923
  if (finalVarTypeDecl &&
3921
3924
  errorNode &&
@@ -3928,7 +3931,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3928
3931
  isDescriptorError = true;
3929
3932
  }
3930
3933
  }
3931
- // Check for an attempt to overwrite an instance variable that is
3934
+ // Check for an attempt to overwrite or delete an instance variable that is
3932
3935
  // read-only (e.g. in a named tuple).
3933
3936
  if ((memberInfo === null || memberInfo === void 0 ? void 0 : memberInfo.isInstanceMember) &&
3934
3937
  (0, types_1.isClass)(memberInfo.classType) &&
@@ -4444,55 +4447,49 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
4444
4447
  // param somewhere in the list?
4445
4448
  if (variadicIndex >= 0) {
4446
4449
  const variadicTypeVar = typeParameters[variadicIndex];
4447
- if (tupleClassType && (0, types_1.isInstantiableClass)(tupleClassType)) {
4448
- if (variadicIndex < typeArgs.length) {
4449
- const variadicTypeResults = typeArgs.slice(variadicIndex, variadicIndex + 1 + typeArgs.length - typeParameters.length);
4450
- // If the type args consist of a lone variadic type variable, don't wrap it in a tuple.
4451
- if (variadicTypeResults.length === 1 && (0, types_1.isVariadicTypeVar)(variadicTypeResults[0].type)) {
4452
- validateVariadicTypeVarIsUnpacked(variadicTypeResults[0].type, variadicTypeResults[0].node);
4453
- }
4454
- else {
4455
- variadicTypeResults.forEach((arg, index) => {
4456
- validateTypeArg(arg, {
4457
- allowEmptyTuple: index === 0,
4458
- allowVariadicTypeVar: true,
4459
- allowUnpackedTuples: true,
4460
- });
4450
+ if (variadicIndex < typeArgs.length) {
4451
+ const variadicTypeResults = typeArgs.slice(variadicIndex, variadicIndex + 1 + typeArgs.length - typeParameters.length);
4452
+ // If the type args consist of a lone variadic type variable, don't wrap it in a tuple.
4453
+ if (variadicTypeResults.length === 1 && (0, types_1.isVariadicTypeVar)(variadicTypeResults[0].type)) {
4454
+ validateVariadicTypeVarIsUnpacked(variadicTypeResults[0].type, variadicTypeResults[0].node);
4455
+ }
4456
+ else {
4457
+ variadicTypeResults.forEach((arg, index) => {
4458
+ validateTypeArg(arg, {
4459
+ allowEmptyTuple: index === 0,
4460
+ allowVariadicTypeVar: true,
4461
+ allowUnpackedTuples: true,
4461
4462
  });
4462
- const variadicTypes = [];
4463
- if (variadicTypeResults.length !== 1 || !variadicTypeResults[0].isEmptyTupleShorthand) {
4464
- variadicTypeResults.forEach((typeResult) => {
4465
- if ((0, types_1.isUnpackedClass)(typeResult.type) && typeResult.type.tupleTypeArguments) {
4466
- (0, collectionUtils_1.appendArray)(variadicTypes, typeResult.type.tupleTypeArguments);
4467
- }
4468
- else {
4469
- variadicTypes.push({
4470
- type: (0, typeUtils_1.convertToInstance)(typeResult.type),
4471
- isUnbounded: false,
4472
- });
4473
- }
4474
- });
4475
- }
4476
- const tupleObject = (0, typeUtils_1.convertToInstance)((0, typeUtils_1.specializeTupleClass)(tupleClassType, variadicTypes,
4477
- /* isTypeArgumentExplicit */ true,
4478
- /* isUnpackedTuple */ true));
4479
- typeArgs = [
4480
- ...typeArgs.slice(0, variadicIndex),
4481
- { node: typeArgs[variadicIndex].node, type: tupleObject },
4482
- ...typeArgs.slice(variadicIndex + 1 + typeArgs.length - typeParameters.length, typeArgs.length),
4483
- ];
4484
- }
4485
- }
4486
- else if (!variadicTypeVar.details.defaultType) {
4487
- // Add an empty tuple that maps to the TypeVarTuple type parameter.
4488
- typeArgs.push({
4489
- node: errorNode,
4490
- type: (0, typeUtils_1.convertToInstance)((0, typeUtils_1.specializeTupleClass)(tupleClassType, [],
4491
- /* isTypeArgumentExplicit */ true,
4492
- /* isUnpackedTuple */ true)),
4493
4463
  });
4464
+ const variadicTypes = [];
4465
+ if (variadicTypeResults.length !== 1 || !variadicTypeResults[0].isEmptyTupleShorthand) {
4466
+ variadicTypeResults.forEach((typeResult) => {
4467
+ if ((0, types_1.isUnpackedClass)(typeResult.type) && typeResult.type.tupleTypeArguments) {
4468
+ (0, collectionUtils_1.appendArray)(variadicTypes, typeResult.type.tupleTypeArguments);
4469
+ }
4470
+ else {
4471
+ variadicTypes.push({
4472
+ type: (0, typeUtils_1.convertToInstance)(typeResult.type),
4473
+ isUnbounded: false,
4474
+ });
4475
+ }
4476
+ });
4477
+ }
4478
+ const tupleObject = makeTupleObject(variadicTypes, /* isUnpackedTuple */ true);
4479
+ typeArgs = [
4480
+ ...typeArgs.slice(0, variadicIndex),
4481
+ { node: typeArgs[variadicIndex].node, type: tupleObject },
4482
+ ...typeArgs.slice(variadicIndex + 1 + typeArgs.length - typeParameters.length, typeArgs.length),
4483
+ ];
4494
4484
  }
4495
4485
  }
4486
+ else if (!variadicTypeVar.details.defaultType) {
4487
+ // Add an empty tuple that maps to the TypeVarTuple type parameter.
4488
+ typeArgs.push({
4489
+ node: errorNode,
4490
+ type: makeTupleObject([], /* isUnpackedTuple */ true),
4491
+ });
4492
+ }
4496
4493
  }
4497
4494
  return typeArgs;
4498
4495
  }
@@ -4936,11 +4933,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
4936
4933
  }
4937
4934
  });
4938
4935
  }
4939
- function makeTupleObject(entryTypes, isUnspecifiedLength = false) {
4936
+ function makeTupleObject(typeArgs, isUnpackedTuple = false) {
4940
4937
  if (tupleClassType && (0, types_1.isInstantiableClass)(tupleClassType)) {
4941
- return (0, typeUtils_1.convertToInstance)((0, typeUtils_1.specializeTupleClass)(tupleClassType, entryTypes.map((t) => {
4942
- return { type: t, isUnbounded: isUnspecifiedLength };
4943
- })));
4938
+ return (0, typeUtils_1.convertToInstance)((0, typeUtils_1.specializeTupleClass)(tupleClassType, typeArgs, /* isTypeArgumentExplicit */ true, isUnpackedTuple));
4944
4939
  }
4945
4940
  return types_1.UnknownType.create();
4946
4941
  }
@@ -5032,17 +5027,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
5032
5027
  }
5033
5028
  else if (positionalArgs.length === 0 && unpackedListArgs.length === 0) {
5034
5029
  // Handle the case where there are no positionals provided but there are keywords.
5035
- positionalIndexType =
5036
- tupleClassType && (0, types_1.isInstantiableClass)(tupleClassType)
5037
- ? (0, typeUtils_1.convertToInstance)((0, typeUtils_1.specializeTupleClass)(tupleClassType, []))
5038
- : types_1.UnknownType.create();
5030
+ positionalIndexType = makeTupleObject([]);
5039
5031
  }
5040
5032
  else {
5041
5033
  // Package up all of the positionals into a tuple.
5042
- const tupleEntries = [];
5034
+ const tupleTypeArgs = [];
5043
5035
  positionalArgs.forEach((arg) => {
5044
5036
  const typeResult = getTypeOfExpression(arg.valueExpression);
5045
- tupleEntries.push(typeResult.type);
5037
+ tupleTypeArgs.push({ type: typeResult.type, isUnbounded: false });
5046
5038
  if (typeResult.isIncomplete) {
5047
5039
  isPositionalIndexTypeIncomplete = true;
5048
5040
  }
@@ -5054,9 +5046,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
5054
5046
  isPositionalIndexTypeIncomplete = true;
5055
5047
  }
5056
5048
  const iterableType = (_b = (_a = getTypeOfIterator(typeResult, /* isAsync */ false, arg.valueExpression)) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : types_1.UnknownType.create();
5057
- tupleEntries.push(iterableType);
5049
+ tupleTypeArgs.push({ type: iterableType, isUnbounded: true });
5058
5050
  });
5059
- positionalIndexType = makeTupleObject(tupleEntries, unpackedListArgs.length > 0);
5051
+ positionalIndexType = makeTupleObject(tupleTypeArgs);
5060
5052
  }
5061
5053
  let argList = [
5062
5054
  {
@@ -5101,7 +5093,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
5101
5093
  // which type to use.
5102
5094
  if (keywordArgs.length === 0 && unpackedDictArgs.length === 0 && positionalArgs.length === 1) {
5103
5095
  useSpeculativeMode(node, () => {
5104
- callResult = validateCallArguments(node, argList, { type: itemMethodType });
5096
+ callResult = validateCallArguments(node, argList, { type: itemMethodType },
5097
+ /* typeVarContext */ undefined,
5098
+ /* skipUnknownArgCheck */ true);
5105
5099
  if (callResult.argumentErrors) {
5106
5100
  // If the object supports "__index__" magic method, convert
5107
5101
  // the index to an int and try again.
@@ -5124,7 +5118,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
5124
5118
  }
5125
5119
  });
5126
5120
  }
5127
- callResult = validateCallArguments(node, argList, { type: itemMethodType });
5121
+ callResult = validateCallArguments(node, argList, { type: itemMethodType },
5122
+ /* typeVarContext */ undefined,
5123
+ /* skipUnknownArgCheck */ true);
5128
5124
  return {
5129
5125
  type: (_d = callResult.returnType) !== null && _d !== void 0 ? _d : types_1.UnknownType.create(),
5130
5126
  isIncomplete: !!callResult.isTypeIncomplete,
@@ -5144,7 +5140,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
5144
5140
  return undefined;
5145
5141
  }
5146
5142
  const slicedTypeArgs = tupleTypeArgs.slice(startValue, endValue);
5147
- return types_1.ClassType.cloneAsInstance((0, typeUtils_1.specializeTupleClass)(tupleType, slicedTypeArgs));
5143
+ return makeTupleObject(slicedTypeArgs);
5148
5144
  }
5149
5145
  function getTupleSliceParameter(expression, defaultValue, tupleTypeArgs) {
5150
5146
  let value = defaultValue;
@@ -5412,8 +5408,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
5412
5408
  const entryTypeResults = node.expressions.map((expr, index) => getTypeOfExpression(expr,
5413
5409
  /* flags */ undefined, (0, typeUtils_1.makeInferenceContext)(index < expectedTypes.length ? expectedTypes[index] : undefined, inferenceContext.isTypeIncomplete, inferenceContext.signatureTracker)));
5414
5410
  const isIncomplete = entryTypeResults.some((result) => result.isIncomplete);
5415
- const type = (0, typeUtils_1.convertToInstance)((0, typeUtils_1.specializeTupleClass)(tupleClassType, buildTupleTypesList(entryTypeResults),
5416
- /* isTypeArgumentExplicit */ true));
5411
+ const type = makeTupleObject(buildTupleTypesList(entryTypeResults));
5417
5412
  // Copy any expected type diag addenda for precision error reporting.
5418
5413
  let expectedTypeDiagAddendum;
5419
5414
  if (entryTypeResults.some((result) => result.expectedTypeDiagAddendum)) {
@@ -5429,10 +5424,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
5429
5424
  function getTypeOfTupleInferred(node) {
5430
5425
  const entryTypeResults = node.expressions.map((expr) => getTypeOfExpression(expr));
5431
5426
  const isIncomplete = entryTypeResults.some((result) => result.isIncomplete);
5432
- if (!tupleClassType || !(0, types_1.isInstantiableClass)(tupleClassType)) {
5433
- return { type: types_1.UnknownType.create() };
5434
- }
5435
- const type = (0, typeUtils_1.convertToInstance)((0, typeUtils_1.specializeTupleClass)(tupleClassType, buildTupleTypesList(entryTypeResults)));
5427
+ const type = makeTupleObject(buildTupleTypesList(entryTypeResults));
5436
5428
  if (isIncomplete) {
5437
5429
  if ((0, typeUtils_1.getContainerDepth)(type) > maxInferredContainerDepth) {
5438
5430
  return { type: types_1.UnknownType.create() };
@@ -5889,10 +5881,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
5889
5881
  // If the bind-to type is a protocol, don't use the effective target class.
5890
5882
  // This pattern is used for mixins, where the mixin type is a protocol class
5891
5883
  // that is used to decorate the "self" or "cls" parameter.
5884
+ let isProtocolClass = false;
5892
5885
  if (bindToType &&
5893
5886
  types_1.ClassType.isProtocolClass(bindToType) &&
5894
5887
  effectiveTargetClass &&
5895
5888
  !types_1.ClassType.isSameGenericClass(bindToType, effectiveTargetClass)) {
5889
+ isProtocolClass = true;
5896
5890
  effectiveTargetClass = undefined;
5897
5891
  }
5898
5892
  const lookupResults = bindToType
@@ -5901,6 +5895,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
5901
5895
  let resultType;
5902
5896
  if (lookupResults && (0, types_1.isInstantiableClass)(lookupResults.classType)) {
5903
5897
  resultType = lookupResults.classType;
5898
+ if (isProtocolClass) {
5899
+ // If the bindToType is a protocol class, set the "include subclasses" flag
5900
+ // so we don't enforce that called methods are implemented within the protocol.
5901
+ resultType = types_1.ClassType.cloneIncludeSubclasses(resultType);
5902
+ }
5904
5903
  }
5905
5904
  else if (effectiveTargetClass &&
5906
5905
  !(0, types_1.isAnyOrUnknown)(effectiveTargetClass) &&
@@ -6416,7 +6415,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
6416
6415
  if (callTypeResult.type.specialForm) {
6417
6416
  const exprNode = errorNode.nodeType === 9 /* ParseNodeType.Call */ ? errorNode.leftExpression : errorNode;
6418
6417
  addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.objectNotCallable().format({
6419
- type: printType(callTypeResult.type, { expandTypeAlias: true }),
6418
+ type: printType(callTypeResult.type.specialForm, { expandTypeAlias: true }),
6420
6419
  }), exprNode);
6421
6420
  return { returnType: types_1.UnknownType.create(), argumentErrors: true, overloadsUsedForCall };
6422
6421
  }
@@ -6873,7 +6872,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
6873
6872
  function evaluateCastCall(argList, errorNode) {
6874
6873
  // Verify that the cast is necessary.
6875
6874
  const castToType = getTypeOfArgumentExpectingType(argList[0], { enforceTypeAnnotationRules: true }).type;
6876
- const castFromType = getTypeOfArgument(argList[1]).type;
6875
+ let castFromType = getTypeOfArgument(argList[1]).type;
6876
+ if (castFromType.specialForm) {
6877
+ castFromType = castFromType.specialForm;
6878
+ }
6877
6879
  if (types_1.TypeBase.isInstantiable(castToType) && !(0, types_1.isUnknown)(castToType)) {
6878
6880
  if ((0, types_1.isTypeSame)((0, typeUtils_1.convertToInstance)(castToType), castFromType, {
6879
6881
  ignorePseudoGeneric: true,
@@ -6906,7 +6908,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
6906
6908
  argumentCategory: 1 /* ArgumentCategory.UnpackedList */,
6907
6909
  valueExpression: undefined,
6908
6910
  typeResult: {
6909
- type: (0, typeUtils_1.specializeTupleClass)(combinedArgType, [tupleTypeArg]),
6911
+ type: makeTupleObject([tupleTypeArg]),
6910
6912
  },
6911
6913
  });
6912
6914
  }
@@ -6934,7 +6936,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
6934
6936
  // validation is left to the caller.
6935
6937
  // This logic is based on PEP 3102: https://www.python.org/dev/peps/pep-3102/
6936
6938
  function matchFunctionArgumentsToParameters(errorNode, argList, typeResult, overloadIndex) {
6937
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
6939
+ var _a, _b, _c, _d, _e, _f, _g, _h;
6938
6940
  const paramDetails = (0, parameterUtils_1.getParameterListDetails)(typeResult.type);
6939
6941
  let argIndex = 0;
6940
6942
  let matchedUnpackedListOfUnknownLength = false;
@@ -7162,10 +7164,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7162
7164
  listElementType = undefined;
7163
7165
  }
7164
7166
  else {
7165
- listElementType =
7166
- (_e = (_d = getTypeOfIterator({ type: argType, isIncomplete: argTypeResult.isIncomplete },
7167
- /* isAsync */ false, errorNode,
7168
- /* emitNotIterableError */ false)) === null || _d === void 0 ? void 0 : _d.type) !== null && _e !== void 0 ? _e : types_1.UnknownType.create();
7167
+ listElementType = (_d = getTypeOfIterator({ type: argType, isIncomplete: argTypeResult.isIncomplete },
7168
+ /* isAsync */ false, errorNode,
7169
+ /* emitNotIterableError */ false)) === null || _d === void 0 ? void 0 : _d.type;
7169
7170
  if (paramDetails.params[paramIndex].param.category !== 1 /* ParameterCategory.ArgsList */) {
7170
7171
  matchedUnpackedListOfUnknownLength = true;
7171
7172
  }
@@ -7175,8 +7176,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7175
7176
  argumentCategory: 0 /* ArgumentCategory.Simple */,
7176
7177
  typeResult: { type: listElementType, isIncomplete: argTypeResult.isIncomplete },
7177
7178
  }
7178
- : undefined;
7179
- if (funcArg && argTypeResult.isIncomplete) {
7179
+ : { ...argList[argIndex] };
7180
+ if (argTypeResult.isIncomplete) {
7180
7181
  isTypeIncomplete = true;
7181
7182
  }
7182
7183
  // It's not allowed to use unpacked arguments with a variadic *args
@@ -7197,7 +7198,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7197
7198
  paramType,
7198
7199
  requiresTypeVarMatching: (0, typeUtils_1.requiresSpecialization)(paramType),
7199
7200
  argument: funcArg,
7200
- errorNode: (_f = argList[argIndex].valueExpression) !== null && _f !== void 0 ? _f : errorNode,
7201
+ errorNode: (_e = argList[argIndex].valueExpression) !== null && _e !== void 0 ? _e : errorNode,
7201
7202
  paramName,
7202
7203
  isParamNameSynthesized: paramDetails.params[paramIndex].param.isNameSynthesized,
7203
7204
  mapsToVarArgList: isParamVariadic && remainingArgCount > remainingParamCount,
@@ -7349,7 +7350,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7349
7350
  // keys are present.
7350
7351
  const typedDictEntries = (0, typedDicts_1.getTypedDictMembersForClass)(evaluatorInterface, argType);
7351
7352
  const diag = new diagnostic_1.DiagnosticAddendum();
7352
- typedDictEntries.forEach((entry, name) => {
7353
+ typedDictEntries.knownItems.forEach((entry, name) => {
7353
7354
  const paramEntry = paramMap.get(name);
7354
7355
  if (paramEntry && !paramEntry.isPositionalOnly) {
7355
7356
  if (paramEntry.argsReceived > 0) {
@@ -7426,20 +7427,20 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7426
7427
  }
7427
7428
  else {
7428
7429
  const strObjType = getBuiltInObject(errorNode, 'str');
7429
- if (mappingType &&
7430
- (0, types_1.isInstantiableClass)(mappingType) &&
7430
+ if (supportsKeysAndGetItemProtocolType &&
7431
+ (0, types_1.isInstantiableClass)(supportsKeysAndGetItemProtocolType) &&
7431
7432
  strObjType &&
7432
7433
  (0, types_1.isClassInstance)(strObjType)) {
7433
- const mappingTypeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(mappingType));
7434
+ const mappingTypeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(supportsKeysAndGetItemProtocolType));
7434
7435
  let isValidMappingType = false;
7435
7436
  // If this was a TypeVar (e.g. for pseudo-generic classes),
7436
7437
  // don't emit this error.
7437
7438
  if ((0, types_1.isTypeVar)(argType)) {
7438
7439
  isValidMappingType = true;
7439
7440
  }
7440
- else if (assignType(types_1.ClassType.cloneAsInstance(mappingType), argType,
7441
+ else if (assignType(types_1.ClassType.cloneAsInstance(supportsKeysAndGetItemProtocolType), argType,
7441
7442
  /* diag */ undefined, mappingTypeVarContext)) {
7442
- const specializedMapping = (0, typeUtils_1.applySolvedTypeVars)(mappingType, mappingTypeVarContext);
7443
+ const specializedMapping = (0, typeUtils_1.applySolvedTypeVars)(supportsKeysAndGetItemProtocolType, mappingTypeVarContext);
7443
7444
  const typeArgs = specializedMapping.typeArguments;
7444
7445
  if (typeArgs && typeArgs.length >= 2) {
7445
7446
  if (assignType(strObjType, typeArgs[0])) {
@@ -7501,7 +7502,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7501
7502
  paramType,
7502
7503
  requiresTypeVarMatching: (0, typeUtils_1.requiresSpecialization)(paramType),
7503
7504
  argument: argList[argIndex],
7504
- errorNode: (_g = argList[argIndex].valueExpression) !== null && _g !== void 0 ? _g : errorNode,
7505
+ errorNode: (_f = argList[argIndex].valueExpression) !== null && _f !== void 0 ? _f : errorNode,
7505
7506
  paramName: paramNameValue,
7506
7507
  });
7507
7508
  trySetActive(argList[argIndex], paramDetails.params[paramInfoIndex].param);
@@ -7517,7 +7518,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7517
7518
  paramType,
7518
7519
  requiresTypeVarMatching: (0, typeUtils_1.requiresSpecialization)(paramType),
7519
7520
  argument: argList[argIndex],
7520
- errorNode: (_h = argList[argIndex].valueExpression) !== null && _h !== void 0 ? _h : errorNode,
7521
+ errorNode: (_g = argList[argIndex].valueExpression) !== null && _g !== void 0 ? _g : errorNode,
7521
7522
  paramName: paramNameValue,
7522
7523
  });
7523
7524
  // Remember that this parameter has already received a value.
@@ -7567,7 +7568,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7567
7568
  requiresTypeVarMatching: false,
7568
7569
  argument: argList[argIndex],
7569
7570
  argType: (0, types_1.isParamSpec)(argType) ? undefined : types_1.AnyType.create(),
7570
- errorNode: (_j = argList[argIndex].valueExpression) !== null && _j !== void 0 ? _j : errorNode,
7571
+ errorNode: (_h = argList[argIndex].valueExpression) !== null && _h !== void 0 ? _h : errorNode,
7571
7572
  });
7572
7573
  }
7573
7574
  }
@@ -7649,6 +7650,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7649
7650
  argumentCategory: 0 /* ArgumentCategory.Simple */,
7650
7651
  typeResult: { type: defaultArgType },
7651
7652
  },
7653
+ isDefaultArg: true,
7652
7654
  errorNode,
7653
7655
  paramName: param.name,
7654
7656
  isParamNameSynthesized: param.isNameSynthesized,
@@ -7675,61 +7677,57 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7675
7677
  const paramType = paramDetails.params[paramDetails.argsIndex].type;
7676
7678
  const variadicArgs = validateArgTypeParams.filter((argParam) => argParam.mapsToVarArgList);
7677
7679
  if ((0, types_1.isVariadicTypeVar)(paramType) && !paramType.isVariadicInUnion) {
7678
- if (tupleClassType && (0, types_1.isInstantiableClass)(tupleClassType)) {
7679
- const tupleTypeArgs = variadicArgs.map((argParam) => {
7680
- var _a;
7681
- const argType = getTypeOfArgument(argParam.argument).type;
7682
- const containsVariadicTypeVar = (0, types_1.isUnpackedVariadicTypeVar)(argType) ||
7683
- ((0, types_1.isClassInstance)(argType) &&
7684
- (0, typeUtils_1.isTupleClass)(argType) &&
7685
- argType.tupleTypeArguments &&
7686
- argType.tupleTypeArguments.length === 1 &&
7687
- (0, types_1.isUnpackedVariadicTypeVar)(argType.tupleTypeArguments[0].type));
7688
- if (containsVariadicTypeVar &&
7689
- argParam.argument.argumentCategory !== 1 /* ArgumentCategory.UnpackedList */ &&
7690
- !argParam.mapsToVarArgList) {
7691
- if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7692
- addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.typeVarTupleMustBeUnpacked(), (_a = argParam.argument.valueExpression) !== null && _a !== void 0 ? _a : errorNode);
7693
- }
7694
- reportedArgError = true;
7680
+ const tupleTypeArgs = variadicArgs.map((argParam) => {
7681
+ var _a;
7682
+ const argType = getTypeOfArgument(argParam.argument).type;
7683
+ const containsVariadicTypeVar = (0, types_1.isUnpackedVariadicTypeVar)(argType) ||
7684
+ ((0, types_1.isClassInstance)(argType) &&
7685
+ (0, typeUtils_1.isTupleClass)(argType) &&
7686
+ argType.tupleTypeArguments &&
7687
+ argType.tupleTypeArguments.length === 1 &&
7688
+ (0, types_1.isUnpackedVariadicTypeVar)(argType.tupleTypeArguments[0].type));
7689
+ if (containsVariadicTypeVar &&
7690
+ argParam.argument.argumentCategory !== 1 /* ArgumentCategory.UnpackedList */ &&
7691
+ !argParam.mapsToVarArgList) {
7692
+ if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7693
+ addDiagnostic(diagnosticRules_1.DiagnosticRule.reportCallIssue, localize_1.LocMessage.typeVarTupleMustBeUnpacked(), (_a = argParam.argument.valueExpression) !== null && _a !== void 0 ? _a : errorNode);
7695
7694
  }
7696
- return {
7697
- type: argType,
7698
- isUnbounded: argParam.argument.argumentCategory === 1 /* ArgumentCategory.UnpackedList */,
7699
- };
7700
- });
7701
- let specializedTuple;
7702
- if (tupleTypeArgs.length === 1 &&
7703
- !tupleTypeArgs[0].isUnbounded &&
7704
- ((0, types_1.isUnpackedClass)(tupleTypeArgs[0].type) || (0, types_1.isVariadicTypeVar)(tupleTypeArgs[0].type))) {
7705
- // If there is a single unpacked tuple or unpacked variadic type variable
7706
- // (including an unpacked TypeVarTuple union) within this tuple,
7707
- // simplify the type.
7708
- specializedTuple = tupleTypeArgs[0].type;
7709
- }
7710
- else {
7711
- specializedTuple = types_1.ClassType.cloneAsInstance((0, typeUtils_1.specializeTupleClass)(tupleClassType, tupleTypeArgs,
7712
- /* isTypeArgumentExplicit */ true,
7713
- /* isUnpackedTuple */ true));
7695
+ reportedArgError = true;
7714
7696
  }
7715
- const combinedArg = {
7716
- paramCategory: 1 /* ParameterCategory.ArgsList */,
7717
- paramType,
7718
- requiresTypeVarMatching: true,
7719
- argument: {
7720
- argumentCategory: 0 /* ArgumentCategory.Simple */,
7721
- typeResult: { type: specializedTuple },
7722
- },
7723
- errorNode,
7724
- paramName: paramDetails.params[paramDetails.argsIndex].param.name,
7725
- isParamNameSynthesized: paramDetails.params[paramDetails.argsIndex].param.isNameSynthesized,
7726
- mapsToVarArgList: true,
7697
+ return {
7698
+ type: argType,
7699
+ isUnbounded: argParam.argument.argumentCategory === 1 /* ArgumentCategory.UnpackedList */,
7727
7700
  };
7728
- validateArgTypeParams = [
7729
- ...validateArgTypeParams.filter((argParam) => !argParam.mapsToVarArgList),
7730
- combinedArg,
7731
- ];
7701
+ });
7702
+ let specializedTuple;
7703
+ if (tupleTypeArgs.length === 1 &&
7704
+ !tupleTypeArgs[0].isUnbounded &&
7705
+ ((0, types_1.isUnpackedClass)(tupleTypeArgs[0].type) || (0, types_1.isVariadicTypeVar)(tupleTypeArgs[0].type))) {
7706
+ // If there is a single unpacked tuple or unpacked variadic type variable
7707
+ // (including an unpacked TypeVarTuple union) within this tuple,
7708
+ // simplify the type.
7709
+ specializedTuple = tupleTypeArgs[0].type;
7732
7710
  }
7711
+ else {
7712
+ specializedTuple = makeTupleObject(tupleTypeArgs, /* isUnpackedTuple */ true);
7713
+ }
7714
+ const combinedArg = {
7715
+ paramCategory: 1 /* ParameterCategory.ArgsList */,
7716
+ paramType,
7717
+ requiresTypeVarMatching: true,
7718
+ argument: {
7719
+ argumentCategory: 0 /* ArgumentCategory.Simple */,
7720
+ typeResult: { type: specializedTuple },
7721
+ },
7722
+ errorNode,
7723
+ paramName: paramDetails.params[paramDetails.argsIndex].param.name,
7724
+ isParamNameSynthesized: paramDetails.params[paramDetails.argsIndex].param.isNameSynthesized,
7725
+ mapsToVarArgList: true,
7726
+ };
7727
+ validateArgTypeParams = [
7728
+ ...validateArgTypeParams.filter((argParam) => !argParam.mapsToVarArgList),
7729
+ combinedArg,
7730
+ ];
7733
7731
  }
7734
7732
  }
7735
7733
  }
@@ -8067,7 +8065,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8067
8065
  let specializedReturnType = (0, typeUtils_1.applySolvedTypeVars)(returnType, typeVarContext, {
8068
8066
  unknownIfNotFound,
8069
8067
  unknownExemptTypeVars: getUnknownExemptTypeVarsForReturnType(type, returnType),
8070
- useUnknownOverDefault: skipUnknownArgCheck,
8071
8068
  eliminateUnsolvedInUnions,
8072
8069
  applyInScopePlaceholders: true,
8073
8070
  });
@@ -8085,15 +8082,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8085
8082
  if ((0, types_1.isUnpackedClass)(specializedReturnType)) {
8086
8083
  specializedReturnType = types_1.ClassType.cloneForUnpacked(specializedReturnType, /* isUnpackedTuple */ false);
8087
8084
  }
8088
- // Handle 'TypeGuard' specially. We'll transform the return type into a 'bool'
8089
- // object with a type argument that reflects the narrowed type.
8085
+ // Handle 'TypeGuard' and 'TypeIs' specially. We'll transform the return type
8086
+ // into a 'bool' object with a type argument that reflects the narrowed type.
8090
8087
  if ((0, types_1.isClassInstance)(specializedReturnType) &&
8091
- types_1.ClassType.isBuiltIn(specializedReturnType, 'TypeGuard') &&
8088
+ types_1.ClassType.isBuiltIn(specializedReturnType, ['TypeGuard', 'TypeIs']) &&
8092
8089
  specializedReturnType.typeArguments &&
8093
- specializedReturnType.typeArguments.length > 0 &&
8094
- (0, types_1.isClassInstance)(returnType) &&
8095
- returnType.typeArguments &&
8096
- returnType.typeArguments.length > 0) {
8090
+ specializedReturnType.typeArguments.length > 0) {
8097
8091
  if (boolClassType && (0, types_1.isInstantiableClass)(boolClassType)) {
8098
8092
  let typeGuardType = specializedReturnType.typeArguments[0];
8099
8093
  // If the first argument is a simple (non-constrained) TypeVar,
@@ -8108,21 +8102,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8108
8102
  ]);
8109
8103
  }
8110
8104
  }
8111
- let useStrictTypeGuardSemantics = false;
8112
- if (AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.enableExperimentalFeatures) {
8113
- // Determine the type of the first parameter.
8114
- const paramIndex = type.boundToType ? 1 : 0;
8115
- if (paramIndex < type.details.parameters.length) {
8116
- const paramType = types_1.FunctionType.getEffectiveParameterType(type, paramIndex);
8117
- // If the type guard meets the requirements that the first parameter
8118
- // type is a proper subtype of the return type, we can use strict
8119
- // type guard semantics.
8120
- if (assignType(paramType, returnType.typeArguments[0])) {
8121
- useStrictTypeGuardSemantics = true;
8122
- }
8123
- }
8124
- }
8125
- specializedReturnType = types_1.ClassType.cloneAsInstance(types_1.ClassType.cloneForTypeGuard(boolClassType, typeGuardType, useStrictTypeGuardSemantics));
8105
+ const useTypeIsSemantics = types_1.ClassType.isBuiltIn(specializedReturnType, 'TypeIs');
8106
+ specializedReturnType = types_1.ClassType.cloneAsInstance(types_1.ClassType.cloneForTypeGuard(boolClassType, typeGuardType, useTypeIsSemantics));
8126
8107
  }
8127
8108
  }
8128
8109
  specializedReturnType = adjustCallableReturnType(specializedReturnType, signatureTracker.getTrackedSignatures());
@@ -8400,6 +8381,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8400
8381
  isTypeIncomplete = true;
8401
8382
  }
8402
8383
  }
8384
+ // If the argument came from a parameter's default argument value,
8385
+ // we may need to specialize the type.
8386
+ if (argParam.isDefaultArg) {
8387
+ argType = (0, typeUtils_1.applySolvedTypeVars)(argType, typeVarContext);
8388
+ }
8403
8389
  }
8404
8390
  // If we're assigning to a var arg dictionary with a TypeVar type,
8405
8391
  // strip literals before performing the assignment. This is used in
@@ -8913,7 +8899,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8913
8899
  typeParamsExpr.expressions.map((expr) => {
8914
8900
  let entryType = getTypeOfExpression(expr, 128 /* EvaluatorFlags.ExpectingInstantiableType */ | 4096 /* EvaluatorFlags.AllowTypeVarsWithoutScopeId */).type;
8915
8901
  if ((0, types_1.isTypeVar)(entryType)) {
8916
- if (entryType.scopeId) {
8902
+ if (entryType.scopeId || entryType.isVariadicUnpacked) {
8917
8903
  isTypeParamListValid = false;
8918
8904
  }
8919
8905
  else {
@@ -9006,7 +8992,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
9006
8992
  addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.newTypeLiteral(), argList[1].node || errorNode);
9007
8993
  }
9008
8994
  let classFlags = baseClass.details.flags & ~(1 /* ClassTypeFlags.BuiltInClass */ | 2 /* ClassTypeFlags.SpecialBuiltIn */);
9009
- classFlags |= 4096 /* ClassTypeFlags.Final */ | 268435456 /* ClassTypeFlags.NewTypeClass */ | 536870912 /* ClassTypeFlags.ValidTypeAliasClass */;
8995
+ classFlags |= 8192 /* ClassTypeFlags.Final */ | 536870912 /* ClassTypeFlags.NewTypeClass */ | 1073741824 /* ClassTypeFlags.ValidTypeAliasClass */;
9010
8996
  const classType = types_1.ClassType.createInstantiable(className, ParseTreeUtils.getClassFullName(errorNode, fileInfo.moduleName, className), fileInfo.moduleName, fileInfo.fileUri, classFlags, ParseTreeUtils.getTypeSourceId(errorNode),
9011
8997
  /* declaredMetaclass */ undefined, baseClass.details.effectiveMetaclass);
9012
8998
  classType.details.baseClasses.push(isBaseClassAny ? types_1.AnyType.create() : baseClass);
@@ -9055,7 +9041,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
9055
9041
  if (!(0, types_1.isClassInstance)(arg1Type) || !(0, typeUtils_1.isTupleClass)(arg1Type) || arg1Type.tupleTypeArguments === undefined) {
9056
9042
  return undefined;
9057
9043
  }
9058
- const classType = types_1.ClassType.createInstantiable(className, ParseTreeUtils.getClassFullName(errorNode, fileInfo.moduleName, className), fileInfo.moduleName, fileInfo.fileUri, 536870912 /* ClassTypeFlags.ValidTypeAliasClass */, ParseTreeUtils.getTypeSourceId(errorNode),
9044
+ const classType = types_1.ClassType.createInstantiable(className, ParseTreeUtils.getClassFullName(errorNode, fileInfo.moduleName, className), fileInfo.moduleName, fileInfo.fileUri, 1073741824 /* ClassTypeFlags.ValidTypeAliasClass */, ParseTreeUtils.getTypeSourceId(errorNode),
9059
9045
  /* declaredMetaclass */ undefined, arg1Type.details.effectiveMetaclass);
9060
9046
  arg1Type.tupleTypeArguments.forEach((typeArg) => {
9061
9047
  const specializedType = makeTopLevelTypeVarsConcrete(typeArg.type);
@@ -9365,8 +9351,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
9365
9351
  (0, types_1.isClassInstance)(keyType) &&
9366
9352
  types_1.ClassType.isBuiltIn(keyType, 'str') &&
9367
9353
  (0, typeUtils_1.isLiteralType)(keyType) &&
9368
- expectedTypedDictEntries.has(keyType.literalValue)) {
9369
- const effectiveValueType = expectedTypedDictEntries.get(keyType.literalValue).valueType;
9354
+ expectedTypedDictEntries.knownItems.has(keyType.literalValue)) {
9355
+ const effectiveValueType = expectedTypedDictEntries.knownItems.get(keyType.literalValue).valueType;
9370
9356
  entryInferenceContext = (0, typeUtils_1.makeInferenceContext)(effectiveValueType);
9371
9357
  valueTypeResult = getTypeOfExpression(entryNode.valueExpression,
9372
9358
  /* flags */ undefined, entryInferenceContext);
@@ -9399,8 +9385,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
9399
9385
  else if (entryNode.nodeType === 16 /* ParseNodeType.DictionaryExpandEntry */) {
9400
9386
  let expectedType;
9401
9387
  if (expectedKeyType && expectedValueType) {
9402
- if (mappingType && (0, types_1.isInstantiableClass)(mappingType)) {
9403
- expectedType = types_1.ClassType.cloneAsInstance(types_1.ClassType.cloneForSpecialization(mappingType, [expectedKeyType, expectedValueType],
9388
+ if (supportsKeysAndGetItemProtocolType && (0, types_1.isInstantiableClass)(supportsKeysAndGetItemProtocolType)) {
9389
+ expectedType = types_1.ClassType.cloneAsInstance(types_1.ClassType.cloneForSpecialization(supportsKeysAndGetItemProtocolType, [expectedKeyType, expectedValueType],
9404
9390
  /* isTypeArgumentExplicit */ true));
9405
9391
  }
9406
9392
  }
@@ -9426,7 +9412,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
9426
9412
  const strObject = types_1.ClassType.cloneAsInstance(strClassType);
9427
9413
  const tdEntries = (0, typedDicts_1.getTypedDictMembersForClass)(evaluatorInterface, unexpandedType,
9428
9414
  /* allowNarrowed */ true);
9429
- tdEntries.forEach((entry, name) => {
9415
+ tdEntries.knownItems.forEach((entry, name) => {
9430
9416
  if (entry.isRequired || entry.isProvided) {
9431
9417
  keyTypes.push({ node: entryNode, type: types_1.ClassType.cloneWithLiteral(strObject, name) });
9432
9418
  valueTypes.push({ node: entryNode, type: entry.valueType });
@@ -9435,13 +9421,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
9435
9421
  addUnknown = false;
9436
9422
  }
9437
9423
  }
9438
- else if (mappingType && (0, types_1.isInstantiableClass)(mappingType)) {
9439
- const mappingTypeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(mappingType));
9440
- mappingType = (0, typeUtils_1.selfSpecializeClass)(mappingType);
9441
- if (assignType(types_1.ClassType.cloneAsInstance(mappingType), unexpandedType,
9424
+ else if (supportsKeysAndGetItemProtocolType &&
9425
+ (0, types_1.isInstantiableClass)(supportsKeysAndGetItemProtocolType)) {
9426
+ const mappingTypeVarContext = new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(supportsKeysAndGetItemProtocolType));
9427
+ supportsKeysAndGetItemProtocolType = (0, typeUtils_1.selfSpecializeClass)(supportsKeysAndGetItemProtocolType);
9428
+ if (assignType(types_1.ClassType.cloneAsInstance(supportsKeysAndGetItemProtocolType), unexpandedType,
9442
9429
  /* diag */ undefined, mappingTypeVarContext,
9443
9430
  /* srcTypeVarContext */ undefined, 256 /* AssignTypeFlags.RetainLiteralsForTypeVar */)) {
9444
- const specializedMapping = (0, typeUtils_1.applySolvedTypeVars)(mappingType, mappingTypeVarContext);
9431
+ const specializedMapping = (0, typeUtils_1.applySolvedTypeVars)(supportsKeysAndGetItemProtocolType, mappingTypeVarContext);
9445
9432
  const typeArgs = specializedMapping.typeArguments;
9446
9433
  if (typeArgs && typeArgs.length >= 2) {
9447
9434
  if (forceStrictInference || index < maxEntriesToUseForInference) {
@@ -9916,7 +9903,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
9916
9903
  }
9917
9904
  }
9918
9905
  }, {
9919
- dependentType: expectedType,
9906
+ dependentType: inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.expectedType,
9920
9907
  allowDiagnostics: !forceSpeculative && !isDiagnosticSuppressedForNode(node) && !(inferenceContext === null || inferenceContext === void 0 ? void 0 : inferenceContext.isTypeIncomplete),
9921
9908
  });
9922
9909
  // Mark the function type as no longer being evaluated.
@@ -10048,7 +10035,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
10048
10035
  if (!expectedValueOrElementType || !(0, typeUtils_1.containsLiteralType)(expectedValueOrElementType)) {
10049
10036
  valueType = stripLiteralValue(valueType);
10050
10037
  }
10051
- type = makeTupleObject([keyType, valueType]);
10038
+ type = makeTupleObject([
10039
+ { type: keyType, isUnbounded: false },
10040
+ { type: valueType, isUnbounded: false },
10041
+ ]);
10052
10042
  }
10053
10043
  else if (node.expression.nodeType === 16 /* ParseNodeType.DictionaryExpandEntry */) {
10054
10044
  // The parser should have reported an error in this case because it's not allowed.
@@ -10411,7 +10401,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
10411
10401
  }
10412
10402
  return type;
10413
10403
  }
10414
- // Creates a "TypeGuard" type. This is an alias for 'bool', which
10404
+ // Creates a "TypeGuard" and "TypeIs" type. This is an alias for 'bool', which
10415
10405
  // isn't a generic type and therefore doesn't have a typeParameter.
10416
10406
  // We'll abuse our internal types a bit by specializing it with
10417
10407
  // a type argument anyway.
@@ -10916,7 +10906,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
10916
10906
  if (isPep695Syntax || isPep695TypeVarType) {
10917
10907
  const typeAliasTypeClass = getTypingType(errorNode, 'TypeAliasType');
10918
10908
  if (typeAliasTypeClass && (0, types_1.isInstantiableClass)(typeAliasTypeClass)) {
10919
- typeAlias = types_1.TypeBase.cloneAsSpecialForm(typeAlias, typeAliasTypeClass);
10909
+ typeAlias = types_1.TypeBase.cloneAsSpecialForm(typeAlias, types_1.ClassType.cloneAsInstance(typeAliasTypeClass));
10920
10910
  }
10921
10911
  }
10922
10912
  return typeAlias;
@@ -10929,12 +10919,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
10929
10919
  /* declaredMetaclass */ undefined,
10930
10920
  /* effectiveMetaclass */ undefined);
10931
10921
  if (aliasMapEntry.isSpecialForm) {
10932
- specialClassType.details.flags |= 1073741824 /* ClassTypeFlags.SpecialFormClass */;
10922
+ specialClassType.details.flags |= -2147483648 /* ClassTypeFlags.SpecialFormClass */;
10933
10923
  }
10934
10924
  const specialBuiltInClassDeclaration = ((_a = AnalyzerNodeInfo.getDeclaration(node)) !== null && _a !== void 0 ? _a : (node.parent ? AnalyzerNodeInfo.getDeclaration(node.parent) : undefined));
10935
10925
  specialClassType.details.declaration = specialBuiltInClassDeclaration;
10936
10926
  if (fileInfo.isTypingExtensionsStubFile) {
10937
- specialClassType.details.flags |= 65536 /* ClassTypeFlags.TypingExtensionClass */;
10927
+ specialClassType.details.flags |= 131072 /* ClassTypeFlags.TypingExtensionClass */;
10938
10928
  }
10939
10929
  const baseClassName = aliasMapEntry.alias || 'object';
10940
10930
  let baseClass;
@@ -10954,7 +10944,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
10954
10944
  // cause the TypedDict to be marked as abstract.
10955
10945
  if ((0, types_1.isInstantiableClass)(baseClass) && types_1.ClassType.isBuiltIn(baseClass, '_TypedDict')) {
10956
10946
  baseClass = types_1.ClassType.cloneWithNewFlags(baseClass, baseClass.details.flags &
10957
- ~(1024 /* ClassTypeFlags.SupportsAbstractMethods */ | 134217728 /* ClassTypeFlags.TypeCheckOnly */));
10947
+ ~(2048 /* ClassTypeFlags.SupportsAbstractMethods */ | 268435456 /* ClassTypeFlags.TypeCheckOnly */));
10958
10948
  }
10959
10949
  }
10960
10950
  }
@@ -11010,6 +11000,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11010
11000
  ['Never', { alias: '', module: 'builtins', isSpecialForm: true }],
11011
11001
  ['LiteralString', { alias: '', module: 'builtins', isSpecialForm: true }],
11012
11002
  ['ReadOnly', { alias: '', module: 'builtins', isSpecialForm: true }],
11003
+ ['TypeIs', { alias: '', module: 'builtins', isSpecialForm: true }],
11013
11004
  ]);
11014
11005
  const aliasMapEntry = specialTypes.get(assignedName);
11015
11006
  if (aliasMapEntry) {
@@ -11168,9 +11159,19 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11168
11159
  }
11169
11160
  // If this is an enum, transform the type as required.
11170
11161
  rightHandType = srcType;
11171
- if (node.leftExpression.nodeType === 38 /* ParseNodeType.Name */ && !node.typeAnnotationComment) {
11162
+ let targetName;
11163
+ if (node.leftExpression.nodeType === 38 /* ParseNodeType.Name */) {
11164
+ targetName = node.leftExpression;
11165
+ }
11166
+ else if (node.leftExpression.nodeType === 54 /* ParseNodeType.TypeAnnotation */ &&
11167
+ node.leftExpression.valueExpression.nodeType === 38 /* ParseNodeType.Name */) {
11168
+ targetName = node.leftExpression.valueExpression;
11169
+ }
11170
+ if (targetName) {
11172
11171
  rightHandType =
11173
- (_a = (0, enums_1.transformTypeForPossibleEnumClass)(evaluatorInterface, node, node.leftExpression, () => rightHandType)) !== null && _a !== void 0 ? _a : rightHandType;
11172
+ (_a = (0, enums_1.transformTypeForPossibleEnumClass)(evaluatorInterface, node, targetName, () => {
11173
+ return { assignedType: rightHandType };
11174
+ })) !== null && _a !== void 0 ? _a : rightHandType;
11174
11175
  }
11175
11176
  if (typeAliasNameNode) {
11176
11177
  // If this was a speculative type alias, it becomes a real type alias
@@ -11328,17 +11329,17 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11328
11329
  fileInfo.isTypeshedStubFile) {
11329
11330
  classFlags |= 1 /* ClassTypeFlags.BuiltInClass */;
11330
11331
  if (fileInfo.isTypingExtensionsStubFile) {
11331
- classFlags |= 65536 /* ClassTypeFlags.TypingExtensionClass */;
11332
+ classFlags |= 131072 /* ClassTypeFlags.TypingExtensionClass */;
11332
11333
  }
11333
11334
  if (node.name.value === 'property') {
11334
- classFlags |= 2048 /* ClassTypeFlags.PropertyClass */;
11335
+ classFlags |= 4096 /* ClassTypeFlags.PropertyClass */;
11335
11336
  }
11336
11337
  if (node.name.value === 'tuple') {
11337
- classFlags |= 524288 /* ClassTypeFlags.TupleClass */;
11338
+ classFlags |= 1048576 /* ClassTypeFlags.TupleClass */;
11338
11339
  }
11339
11340
  }
11340
11341
  if (fileInfo.isStubFile) {
11341
- classFlags |= 8388608 /* ClassTypeFlags.DefinedInStub */;
11342
+ classFlags |= 16777216 /* ClassTypeFlags.DefinedInStub */;
11342
11343
  }
11343
11344
  const classType = types_1.ClassType.createInstantiable(node.name.value, ParseTreeUtils.getClassFullName(node, fileInfo.moduleName, node.name.value), fileInfo.moduleName, fileInfo.fileUri, classFlags,
11344
11345
  /* typeSourceId */ 0,
@@ -11361,7 +11362,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11361
11362
  if (classDecl && classSymbol) {
11362
11363
  setSymbolResolutionPartialType(classSymbol, classDecl, classType);
11363
11364
  }
11364
- classType.details.flags |= 131072 /* ClassTypeFlags.PartiallyEvaluated */;
11365
+ classType.details.flags |= 262144 /* ClassTypeFlags.PartiallyEvaluated */;
11365
11366
  classType.details.declaration = classDecl;
11366
11367
  try {
11367
11368
  writeTypeCache(node, { type: classType }, /* flags */ undefined);
@@ -11446,10 +11447,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11446
11447
  fileInfo.executionEnvironment.pythonVersion < pythonVersion_1.PythonVersion.V3_7) {
11447
11448
  addError(localize_1.LocMessage.protocolIllegal(), arg.valueExpression);
11448
11449
  }
11449
- classType.details.flags |= 8192 /* ClassTypeFlags.ProtocolClass */;
11450
+ classType.details.flags |= 16384 /* ClassTypeFlags.ProtocolClass */;
11450
11451
  }
11451
11452
  if (types_1.ClassType.isBuiltIn(argType, 'property')) {
11452
- classType.details.flags |= 2048 /* ClassTypeFlags.PropertyClass */;
11453
+ classType.details.flags |= 4096 /* ClassTypeFlags.PropertyClass */;
11453
11454
  }
11454
11455
  // If the class directly derives from NamedTuple (in Python 3.6 or
11455
11456
  // newer), it's considered a (read-only) dataclass.
@@ -11458,13 +11459,17 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11458
11459
  classType.details.flags |=
11459
11460
  4 /* ClassTypeFlags.DataClass */ |
11460
11461
  32 /* ClassTypeFlags.SkipSynthesizedDataClassEq */ |
11461
- 16777216 /* ClassTypeFlags.ReadOnlyInstanceVariables */;
11462
+ 33554432 /* ClassTypeFlags.ReadOnlyInstanceVariables */;
11462
11463
  }
11463
11464
  }
11464
11465
  // If the class directly derives from TypedDict or from a class that is
11465
11466
  // a TypedDict, it is considered a TypedDict.
11466
11467
  if (types_1.ClassType.isBuiltIn(argType, 'TypedDict') || types_1.ClassType.isTypedDictClass(argType)) {
11467
11468
  classType.details.flags |= 128 /* ClassTypeFlags.TypedDictClass */;
11469
+ // Propagate the "effectively closed" flag from base classes.
11470
+ if (types_1.ClassType.isTypedDictEffectivelyClosed(argType)) {
11471
+ classType.details.flags |= 512 /* ClassTypeFlags.TypedDictEffectivelyClosed */;
11472
+ }
11468
11473
  }
11469
11474
  // Validate that the class isn't deriving from itself, creating a
11470
11475
  // circular dependency.
@@ -11494,7 +11499,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11494
11499
  classType.details.baseClasses.push(argType);
11495
11500
  if ((0, types_1.isInstantiableClass)(argType)) {
11496
11501
  if (types_1.ClassType.isEnumClass(argType)) {
11497
- classType.details.flags |= 1048576 /* ClassTypeFlags.EnumClass */;
11502
+ classType.details.flags |= 2097152 /* ClassTypeFlags.EnumClass */;
11498
11503
  }
11499
11504
  // Determine if the class is abstract. Protocol classes support abstract methods
11500
11505
  // because they are constructed by the _ProtocolMeta metaclass, which derives
@@ -11503,10 +11508,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11503
11508
  // because of dependencies on some of these built-in protocol classes.
11504
11509
  if (types_1.ClassType.supportsAbstractMethods(argType) ||
11505
11510
  (types_1.ClassType.isProtocolClass(argType) && !types_1.ClassType.isBuiltIn(argType))) {
11506
- classType.details.flags |= 1024 /* ClassTypeFlags.SupportsAbstractMethods */;
11511
+ classType.details.flags |= 2048 /* ClassTypeFlags.SupportsAbstractMethods */;
11507
11512
  }
11508
11513
  if (types_1.ClassType.isPropertyClass(argType)) {
11509
- classType.details.flags |= 2048 /* ClassTypeFlags.PropertyClass */;
11514
+ classType.details.flags |= 4096 /* ClassTypeFlags.PropertyClass */;
11510
11515
  }
11511
11516
  if (types_1.ClassType.isFinal(argType)) {
11512
11517
  const className = printObjectTypeForClass(argType);
@@ -11548,7 +11553,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11548
11553
  }
11549
11554
  }
11550
11555
  else if (types_1.ClassType.isTypedDictClass(classType)) {
11551
- if (arg.name.value === 'total') {
11556
+ if (arg.name.value === 'total' || arg.name.value === 'closed') {
11552
11557
  // The "total" and "readonly" parameters apply only for TypedDict classes.
11553
11558
  // PEP 589 specifies that the parameter must be either True or False.
11554
11559
  const constArgValue = (0, staticExpressions_1.evaluateStaticBoolExpression)(arg.valueExpression, fileInfo.executionEnvironment, fileInfo.definedConstants);
@@ -11556,7 +11561,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11556
11561
  addError(localize_1.LocMessage.typedDictBoolParam().format({ name: arg.name.value }), arg.valueExpression);
11557
11562
  }
11558
11563
  else if (arg.name.value === 'total' && !constArgValue) {
11559
- classType.details.flags |= 256 /* ClassTypeFlags.CanOmitDictValues */;
11564
+ classType.details.flags |= 1024 /* ClassTypeFlags.CanOmitDictValues */;
11565
+ }
11566
+ else if (arg.name.value === 'closed' && constArgValue) {
11567
+ if (AnalyzerNodeInfo.getFileInfo(node).diagnosticRuleSet.enableExperimentalFeatures) {
11568
+ classType.details.flags |=
11569
+ 256 /* ClassTypeFlags.TypedDictMarkedClosed */ | 512 /* ClassTypeFlags.TypedDictEffectivelyClosed */;
11570
+ }
11560
11571
  }
11561
11572
  }
11562
11573
  else {
@@ -11677,7 +11688,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11677
11688
  param.category === 0 /* ParameterCategory.Simple */ &&
11678
11689
  !param.defaultValue);
11679
11690
  if (genericParams.length > 0) {
11680
- classType.details.flags |= 16384 /* ClassTypeFlags.PseudoGenericClass */;
11691
+ classType.details.flags |= 32768 /* ClassTypeFlags.PseudoGenericClass */;
11681
11692
  // Create a type parameter for each simple, named parameter
11682
11693
  // in the __init__ method.
11683
11694
  classType.details.typeParameters = genericParams.map((param) => {
@@ -11698,7 +11709,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11698
11709
  if (classType.details.typeParameters.length === 0 && !types_1.ClassType.isBuiltIn(classType, 'type')) {
11699
11710
  if (classType.details.baseClasses.some((baseClass) => (0, types_1.isInstantiableClass)(baseClass) && types_1.ClassType.hasCustomClassGetItem(baseClass)) ||
11700
11711
  classType.details.fields.has('__class_getitem__')) {
11701
- classType.details.flags |= 262144 /* ClassTypeFlags.HasCustomClassGetItem */;
11712
+ classType.details.flags |= 524288 /* ClassTypeFlags.HasCustomClassGetItem */;
11702
11713
  }
11703
11714
  }
11704
11715
  // Determine the effective metaclass.
@@ -11711,17 +11722,17 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11711
11722
  classType.details.declaredMetaclass = metaclassType;
11712
11723
  if ((0, types_1.isInstantiableClass)(metaclassType)) {
11713
11724
  if ((0, enums_1.isEnumMetaclass)(metaclassType)) {
11714
- classType.details.flags |= 1048576 /* ClassTypeFlags.EnumClass */;
11725
+ classType.details.flags |= 2097152 /* ClassTypeFlags.EnumClass */;
11715
11726
  }
11716
11727
  if (types_1.ClassType.isBuiltIn(metaclassType, 'ABCMeta')) {
11717
- classType.details.flags |= 1024 /* ClassTypeFlags.SupportsAbstractMethods */;
11728
+ classType.details.flags |= 2048 /* ClassTypeFlags.SupportsAbstractMethods */;
11718
11729
  }
11719
11730
  }
11720
11731
  }
11721
11732
  }
11722
11733
  const effectiveMetaclass = computeEffectiveMetaclass(classType, node.name);
11723
11734
  // Clear the "partially constructed" flag.
11724
- classType.details.flags &= ~131072 /* ClassTypeFlags.PartiallyEvaluated */;
11735
+ classType.details.flags &= ~262144 /* ClassTypeFlags.PartiallyEvaluated */;
11725
11736
  // Now determine the decorated type of the class.
11726
11737
  let decoratedType = classType;
11727
11738
  let foundUnknown = false;
@@ -11783,7 +11794,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11783
11794
  if (foundInvalidBaseClass) {
11784
11795
  addError(localize_1.LocMessage.typedDictBaseClass() + diag.getString(), node.name);
11785
11796
  }
11786
- (0, typedDicts_1.synthesizeTypedDictClassMethods)(evaluatorInterface, node, classType, (0, types_1.isClass)(decoratedType) && types_1.ClassType.isFinal(decoratedType));
11797
+ (0, typedDicts_1.synthesizeTypedDictClassMethods)(evaluatorInterface, node, classType);
11787
11798
  }
11788
11799
  // Synthesize dataclass methods.
11789
11800
  if (types_1.ClassType.isDataClass(classType)) {
@@ -12239,7 +12250,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
12239
12250
  }
12240
12251
  // In case this is an enum class and a method wrapped in an enum.member.
12241
12252
  decoratedType =
12242
- (_a = (0, enums_1.transformTypeForPossibleEnumClass)(evaluatorInterface, node, node.name, () => decoratedType)) !== null && _a !== void 0 ? _a : decoratedType;
12253
+ (_a = (0, enums_1.transformTypeForPossibleEnumClass)(evaluatorInterface, node, node.name, () => {
12254
+ return { assignedType: decoratedType };
12255
+ })) !== null && _a !== void 0 ? _a : decoratedType;
12243
12256
  // See if there are any overloads provided by previous function declarations.
12244
12257
  if ((0, types_1.isFunction)(decoratedType)) {
12245
12258
  decoratedType.details.deprecatedMessage = functionType.details.deprecatedMessage;
@@ -12454,8 +12467,15 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
12454
12467
  if (index >= firstNonClsSelfParamIndex) {
12455
12468
  let isImplicitPositionOnlyParam = false;
12456
12469
  if (param.category === 0 /* ParameterCategory.Simple */ && param.name) {
12457
- if ((0, symbolNameUtils_1.isPrivateName)(param.name.value)) {
12470
+ if ((0, symbolNameUtils_1.isPrivateName)(param.name.value) &&
12471
+ !node.parameters.some((p) => p.category === 0 /* ParameterCategory.Simple */ && !p.name)) {
12458
12472
  isImplicitPositionOnlyParam = true;
12473
+ // If the parameter name indicates an implicit position-only parameter
12474
+ // but we have already seen non-position-only parameters, report an error.
12475
+ if (!paramsArePositionOnly &&
12476
+ functionType.details.parameters.every((p) => p.category === 0 /* ParameterCategory.Simple */)) {
12477
+ addDiagnostic(diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.LocMessage.positionOnlyAfterNon(), param.name);
12478
+ }
12459
12479
  }
12460
12480
  }
12461
12481
  else {
@@ -12750,11 +12770,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
12750
12770
  if ((0, types_1.isUnpackedClass)(type)) {
12751
12771
  return types_1.ClassType.cloneForUnpacked(type, /* isUnpackedTuple */ false);
12752
12772
  }
12753
- if (tupleClassType && (0, types_1.isInstantiableClass)(tupleClassType)) {
12754
- return types_1.ClassType.cloneAsInstance((0, typeUtils_1.specializeTupleClass)(tupleClassType, [{ type, isUnbounded: !(0, types_1.isVariadicTypeVar)(type) }],
12755
- /* isTypeArgumentExplicit */ true));
12756
- }
12757
- return types_1.UnknownType.create();
12773
+ return makeTupleObject([{ type, isUnbounded: !(0, types_1.isVariadicTypeVar)(type) }]);
12758
12774
  }
12759
12775
  case 2 /* ParameterCategory.KwargsDict */: {
12760
12776
  // Leave a ParamSpec alone.
@@ -13978,7 +13994,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
13978
13994
  case 'Concatenate': {
13979
13995
  return { type: createConcatenateType(classType, errorNode, typeArgs, flags) };
13980
13996
  }
13981
- case 'TypeGuard': {
13997
+ case 'TypeGuard':
13998
+ case 'TypeIs': {
13982
13999
  return { type: createTypeGuardType(classType, errorNode, typeArgs, flags) };
13983
14000
  }
13984
14001
  case 'Unpack': {
@@ -14525,7 +14542,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
14525
14542
  // is a valid entry in the TypedDict to avoid resolving declarations for
14526
14543
  // synthesized symbols such as 'get'.
14527
14544
  if ((0, types_1.isClassInstance)(subtype) && types_1.ClassType.isTypedDictClass(subtype)) {
14528
- const entry = (_a = subtype.details.typedDictEntries) === null || _a === void 0 ? void 0 : _a.get(node.value);
14545
+ const entry = (_a = subtype.details.typedDictEntries) === null || _a === void 0 ? void 0 : _a.knownItems.get(node.value);
14529
14546
  if (entry) {
14530
14547
  const symbol = (_b = (0, typeUtils_1.lookUpObjectMember)(subtype, node.value)) === null || _b === void 0 ? void 0 : _b.symbol;
14531
14548
  if (symbol) {
@@ -14826,7 +14843,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
14826
14843
  const variableNode = (_c = ParseTreeUtils.getParentNodeOfType(declaration.node, 3 /* ParseNodeType.Assignment */)) !== null && _c !== void 0 ? _c : ParseTreeUtils.getParentNodeOfType(declaration.node, 54 /* ParseNodeType.TypeAnnotation */);
14827
14844
  if (variableNode) {
14828
14845
  declaredType =
14829
- (_d = (0, enums_1.transformTypeForPossibleEnumClass)(evaluatorInterface, variableNode, declaration.node, () => declaredType)) !== null && _d !== void 0 ? _d : declaredType;
14846
+ (_d = (0, enums_1.transformTypeForPossibleEnumClass)(evaluatorInterface, variableNode, declaration.node, () => {
14847
+ return { declaredType };
14848
+ })) !== null && _d !== void 0 ? _d : declaredType;
14830
14849
  }
14831
14850
  }
14832
14851
  if ((0, types_1.isClassInstance)(declaredType) && types_1.ClassType.isBuiltIn(declaredType, 'TypeAlias')) {
@@ -14891,7 +14910,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
14891
14910
  }
14892
14911
  }
14893
14912
  else {
14894
- const boundType = getTypeOfExpressionExpectingType(node.boundExpression).type;
14913
+ const boundType = getTypeOfExpressionExpectingType(node.boundExpression, {
14914
+ disallowProtocolAndTypedDict: true,
14915
+ }).type;
14895
14916
  if ((0, typeUtils_1.requiresSpecialization)(boundType, { ignorePseudoGeneric: true })) {
14896
14917
  addError(localize_1.LocMessage.typeVarConstraintGeneric(), node.boundExpression);
14897
14918
  }
@@ -15081,9 +15102,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15081
15102
  var _a, _b;
15082
15103
  (0, debug_1.assert)(resolvedDecl.inferredTypeSource !== undefined);
15083
15104
  const inferredTypeSource = resolvedDecl.inferredTypeSource;
15084
- return ((_b = (_a = evaluateTypeForSubnode(inferredTypeSource, () => {
15085
- evaluateTypesForStatement(inferredTypeSource);
15086
- })) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : types_1.UnknownType.create());
15105
+ return {
15106
+ assignedType: (_b = (_a = evaluateTypeForSubnode(inferredTypeSource, () => {
15107
+ evaluateTypesForStatement(inferredTypeSource);
15108
+ })) === null || _a === void 0 ? void 0 : _a.type) !== null && _b !== void 0 ? _b : types_1.UnknownType.create(),
15109
+ };
15087
15110
  });
15088
15111
  if (enumMemberType) {
15089
15112
  inferredType = enumMemberType;
@@ -15838,26 +15861,66 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15838
15861
  }
15839
15862
  // Handle typed dicts. They also use a form of structural typing for type
15840
15863
  // checking, as defined in PEP 589.
15841
- if (types_1.ClassType.isTypedDictClass(destType) &&
15842
- types_1.ClassType.isTypedDictClass(srcType) &&
15843
- !types_1.ClassType.isSameGenericClass(destType, srcType)) {
15844
- if (!(0, typedDicts_1.assignTypedDictToTypedDict)(evaluatorInterface, destType, srcType, diag, destTypeVarContext, flags, recursionCount)) {
15845
- return false;
15864
+ if (types_1.ClassType.isTypedDictClass(srcType)) {
15865
+ if (types_1.ClassType.isTypedDictClass(destType) && !types_1.ClassType.isSameGenericClass(destType, srcType)) {
15866
+ if (!(0, typedDicts_1.assignTypedDictToTypedDict)(evaluatorInterface, destType, srcType, diag, destTypeVarContext, flags, recursionCount)) {
15867
+ return false;
15868
+ }
15869
+ if (types_1.ClassType.isFinal(destType) !== types_1.ClassType.isFinal(srcType)) {
15870
+ diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocAddendum.typedDictFinalMismatch().format({
15871
+ sourceType: printType((0, typeUtils_1.convertToInstance)(srcType)),
15872
+ destType: printType((0, typeUtils_1.convertToInstance)(destType)),
15873
+ }));
15874
+ return false;
15875
+ }
15876
+ // If invariance is being enforced, the two TypedDicts must be assignable to each other.
15877
+ if ((flags & 1 /* AssignTypeFlags.EnforceInvariance */) !== 0) {
15878
+ return (0, typedDicts_1.assignTypedDictToTypedDict)(evaluatorInterface, srcType, destType,
15879
+ /* diag */ undefined,
15880
+ /* typeVarContext */ undefined, flags, recursionCount);
15881
+ }
15882
+ return true;
15846
15883
  }
15847
- if (types_1.ClassType.isFinal(destType) !== types_1.ClassType.isFinal(srcType)) {
15848
- diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocAddendum.typedDictFinalMismatch().format({
15849
- sourceType: printType((0, typeUtils_1.convertToInstance)(srcType)),
15850
- destType: printType((0, typeUtils_1.convertToInstance)(destType)),
15851
- }));
15852
- return false;
15884
+ // Handle some special cases where a TypedDict can act like
15885
+ // a Mapping[str, T] or a dict[str, T].
15886
+ if (types_1.ClassType.isBuiltIn(destType, 'Mapping')) {
15887
+ const mappingValueType = (0, typedDicts_1.getTypedDictMappingEquivalent)(evaluatorInterface, srcType);
15888
+ if (mappingValueType &&
15889
+ mappingType &&
15890
+ (0, types_1.isInstantiableClass)(mappingType) &&
15891
+ strClassType &&
15892
+ (0, types_1.isInstantiableClass)(strClassType)) {
15893
+ srcType = types_1.ClassType.cloneForSpecialization(mappingType, [types_1.ClassType.cloneAsInstance(strClassType), mappingValueType],
15894
+ /* isTypeArgumentExplicit */ true);
15895
+ }
15853
15896
  }
15854
- // If invariance is being enforced, the two TypedDicts must be assignable to each other.
15855
- if ((flags & 1 /* AssignTypeFlags.EnforceInvariance */) !== 0) {
15856
- return (0, typedDicts_1.assignTypedDictToTypedDict)(evaluatorInterface, srcType, destType,
15857
- /* diag */ undefined,
15858
- /* typeVarContext */ undefined, flags, recursionCount);
15897
+ else if (types_1.ClassType.isBuiltIn(destType, ['dict', 'MutableMapping'])) {
15898
+ const dictValueType = (0, typedDicts_1.getTypedDictDictEquivalent)(evaluatorInterface, srcType, recursionCount);
15899
+ if (dictValueType &&
15900
+ dictClassType &&
15901
+ (0, types_1.isInstantiableClass)(dictClassType) &&
15902
+ strClassType &&
15903
+ (0, types_1.isInstantiableClass)(strClassType)) {
15904
+ srcType = types_1.ClassType.cloneForSpecialization(dictClassType, [types_1.ClassType.cloneAsInstance(strClassType), dictValueType],
15905
+ /* isTypeArgumentExplicit */ true);
15906
+ }
15907
+ }
15908
+ }
15909
+ // See if the dest type is a TypedDict class and the source is a compatible dict.
15910
+ if (types_1.ClassType.isTypedDictClass(destType) && types_1.ClassType.isBuiltIn(srcType, 'dict')) {
15911
+ if (srcType.typeArguments &&
15912
+ srcType.typeArguments.length === 2 &&
15913
+ (0, types_1.isClassInstance)(srcType.typeArguments[0]) &&
15914
+ types_1.ClassType.isBuiltIn(srcType.typeArguments[0], 'str')) {
15915
+ const dictValueType = (0, typedDicts_1.getTypedDictDictEquivalent)(evaluatorInterface, destType, recursionCount);
15916
+ if (dictValueType &&
15917
+ assignType(dictValueType, srcType.typeArguments[1],
15918
+ /* diag */ undefined,
15919
+ /* destTypeVarContext */ undefined,
15920
+ /* srcTypeVarContext */ undefined, 1 /* AssignTypeFlags.EnforceInvariance */, recursionCount + 1)) {
15921
+ return true;
15922
+ }
15859
15923
  }
15860
- return true;
15861
15924
  }
15862
15925
  // Handle special-case type promotions.
15863
15926
  if (destType.includePromotions) {
@@ -16039,26 +16102,28 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16039
16102
  const destUnboundedOrVariadicIndex = destTypeArgs.findIndex((t) => t.isUnbounded || (0, types_1.isVariadicTypeVar)(t.type));
16040
16103
  const srcUnboundedIndex = srcTypeArgs.findIndex((t) => t.isUnbounded);
16041
16104
  const srcVariadicIndex = srcTypeArgs.findIndex((t) => (0, types_1.isVariadicTypeVar)(t.type));
16042
- let isSrcVariadicAny = false;
16043
- // If the src contains an unbounded type but the dest does not, it's incompatible.
16044
- if (srcUnboundedIndex >= 0 && destUnboundedOrVariadicIndex < 0) {
16045
- // Unless the source contains an [Any, ...].
16105
+ if (srcUnboundedIndex >= 0) {
16046
16106
  if ((0, types_1.isAnyOrUnknown)(srcTypeArgs[srcUnboundedIndex].type)) {
16047
- isSrcVariadicAny = true;
16107
+ // If the source contains an unbounded Any, expand it to match the dest length.
16108
+ const typeToReplicate = srcTypeArgs.length > 0 ? srcTypeArgs[srcUnboundedIndex].type : types_1.AnyType.create();
16109
+ while (srcTypeArgs.length < destTypeArgs.length) {
16110
+ srcTypeArgs.splice(srcUnboundedIndex, 0, { type: typeToReplicate, isUnbounded: true });
16111
+ }
16112
+ if (srcTypeArgs.length > destTypeArgs.length) {
16113
+ srcTypeArgs.splice(srcUnboundedIndex, 1);
16114
+ }
16048
16115
  }
16049
- else {
16116
+ else if (destUnboundedOrVariadicIndex < 0) {
16117
+ // If the source contains an unbounded type but the dest does not, it's incompatible.
16050
16118
  return false;
16051
16119
  }
16052
16120
  }
16053
- if (srcUnboundedIndex >= 0) {
16054
- // The source is unbounded, so expand the unbounded argument to try
16055
- // to make the source and dest arg counts match.
16056
- const typeToReplicate = srcTypeArgs.length > 0 ? srcTypeArgs[srcUnboundedIndex].type : types_1.AnyType.create();
16057
- while (srcTypeArgs.length < destTypeArgs.length) {
16058
- srcTypeArgs.splice(srcUnboundedIndex, 0, { type: typeToReplicate, isUnbounded: true });
16059
- }
16060
- if (isSrcVariadicAny && srcTypeArgs.length > destTypeArgs.length) {
16061
- srcTypeArgs.splice(srcUnboundedIndex, 1);
16121
+ // If the dest contains an unbounded Any, expand it to match the source length.
16122
+ if (destUnboundedOrVariadicIndex >= 0 &&
16123
+ destTypeArgs[destUnboundedOrVariadicIndex].isUnbounded &&
16124
+ (0, types_1.isAnyOrUnknown)(destTypeArgs[destUnboundedOrVariadicIndex].type)) {
16125
+ while (destTypeArgs.length < srcTypeArgs.length) {
16126
+ destTypeArgs.splice(destUnboundedOrVariadicIndex, 0, destTypeArgs[destUnboundedOrVariadicIndex]);
16062
16127
  }
16063
16128
  }
16064
16129
  // Remove any optional parameters from the end of the two lists until the lengths match.
@@ -16068,23 +16133,26 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16068
16133
  while (destTypeArgs.length > srcTypeArgs.length && destTypeArgs[destTypeArgs.length - 1].isOptional) {
16069
16134
  destTypeArgs.splice(destTypeArgs.length - 1, 1);
16070
16135
  }
16071
- if (srcVariadicIndex >= 0) {
16136
+ // If we're doing reverse type mappings and the source contains a variadic
16137
+ // TypeVar, we need to adjust the dest so the reverse type mapping assignment
16138
+ // can be performed.
16139
+ if ((flags & 2 /* AssignTypeFlags.ReverseTypeVarMatching */) !== 0) {
16072
16140
  const destArgsToCapture = destTypeArgs.length - srcTypeArgs.length + 1;
16073
- // If we're doing reverse type mappings and the source contains a variadic
16074
- // TypeVar, we need to adjust the dest so the reverse type mapping assignment
16075
- // can be performed.
16076
- if (destArgsToCapture >= 0 && (flags & 2 /* AssignTypeFlags.ReverseTypeVarMatching */) !== 0) {
16141
+ if (srcVariadicIndex >= 0 && destArgsToCapture >= 0) {
16077
16142
  // If the only removed arg from the dest type args is itself a variadic,
16078
16143
  // don't bother adjusting it.
16079
16144
  const skipAdjustment = destArgsToCapture === 1 && (0, types_1.isVariadicTypeVar)(destTypeArgs[srcVariadicIndex].type);
16080
16145
  if (!skipAdjustment && tupleClassType && (0, types_1.isInstantiableClass)(tupleClassType)) {
16081
16146
  const removedArgs = destTypeArgs.splice(srcVariadicIndex, destArgsToCapture);
16082
16147
  // Package up the remaining type arguments into a tuple object.
16083
- const variadicTuple = (0, typeUtils_1.convertToInstance)((0, typeUtils_1.specializeTupleClass)(tupleClassType, removedArgs.map((typeArg) => {
16084
- return { type: typeArg.type, isUnbounded: typeArg.isUnbounded };
16148
+ const variadicTuple = makeTupleObject(removedArgs.map((typeArg) => {
16149
+ return {
16150
+ type: typeArg.type,
16151
+ isUnbounded: typeArg.isUnbounded,
16152
+ isOptional: typeArg.isOptional,
16153
+ };
16085
16154
  }),
16086
- /* isTypeArgumentExplicit */ true,
16087
- /* isUnpackedTuple */ true));
16155
+ /* isUnpackedTuple */ true);
16088
16156
  destTypeArgs.splice(srcVariadicIndex, 0, {
16089
16157
  type: variadicTuple,
16090
16158
  isUnbounded: false,
@@ -16101,11 +16169,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16101
16169
  if (tupleClassType && (0, types_1.isInstantiableClass)(tupleClassType)) {
16102
16170
  const removedArgs = srcTypeArgs.splice(destUnboundedOrVariadicIndex, srcArgsToCapture);
16103
16171
  // Package up the remaining type arguments into a tuple object.
16104
- const variadicTuple = (0, typeUtils_1.convertToInstance)((0, typeUtils_1.specializeTupleClass)(tupleClassType, removedArgs.map((typeArg) => {
16105
- return { type: typeArg.type, isUnbounded: typeArg.isUnbounded };
16172
+ const variadicTuple = makeTupleObject(removedArgs.map((typeArg) => {
16173
+ return {
16174
+ type: typeArg.type,
16175
+ isUnbounded: typeArg.isUnbounded,
16176
+ isOptional: typeArg.isOptional,
16177
+ };
16106
16178
  }),
16107
- /* isTypeArgumentExplicit */ true,
16108
- /* isUnpackedTuple */ true));
16179
+ /* isUnpackedTuple */ true);
16109
16180
  srcTypeArgs.splice(destUnboundedOrVariadicIndex, 0, {
16110
16181
  type: variadicTuple,
16111
16182
  isUnbounded: false,
@@ -16113,18 +16184,27 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16113
16184
  }
16114
16185
  }
16115
16186
  else {
16116
- const removedArgTypes = srcTypeArgs
16117
- .splice(destUnboundedOrVariadicIndex, srcArgsToCapture)
16118
- .map((t) => {
16119
- if ((0, types_1.isTypeVar)(t.type) && (0, types_1.isUnpackedVariadicTypeVar)(t.type) && !t.type.isVariadicInUnion) {
16120
- return types_1.TypeVarType.cloneForUnpacked(t.type, /* isInUnion */ true);
16121
- }
16122
- return t.type;
16123
- });
16124
- srcTypeArgs.splice(destUnboundedOrVariadicIndex, 0, {
16125
- type: removedArgTypes.length > 0 ? (0, types_1.combineTypes)(removedArgTypes) : types_1.AnyType.create(),
16126
- isUnbounded: false,
16127
- });
16187
+ // If possible, package up the source entries that correspond to
16188
+ // the dest unbounded tuple. This isn't possible if the source contains
16189
+ // an unbounded tuple outside of this range.
16190
+ if (srcUnboundedIndex < 0 ||
16191
+ (srcUnboundedIndex >= destUnboundedOrVariadicIndex &&
16192
+ srcUnboundedIndex < destUnboundedOrVariadicIndex + srcArgsToCapture)) {
16193
+ const removedArgTypes = srcTypeArgs
16194
+ .splice(destUnboundedOrVariadicIndex, srcArgsToCapture)
16195
+ .map((t) => {
16196
+ if ((0, types_1.isTypeVar)(t.type) &&
16197
+ (0, types_1.isUnpackedVariadicTypeVar)(t.type) &&
16198
+ !t.type.isVariadicInUnion) {
16199
+ return types_1.TypeVarType.cloneForUnpacked(t.type, /* isInUnion */ true);
16200
+ }
16201
+ return t.type;
16202
+ });
16203
+ srcTypeArgs.splice(destUnboundedOrVariadicIndex, 0, {
16204
+ type: removedArgTypes.length > 0 ? (0, types_1.combineTypes)(removedArgTypes) : types_1.AnyType.create(),
16205
+ isUnbounded: false,
16206
+ });
16207
+ }
16128
16208
  }
16129
16209
  }
16130
16210
  }
@@ -16148,16 +16228,32 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16148
16228
  }
16149
16229
  }
16150
16230
  else {
16151
- if (srcTypeArgs.find((t) => t.isUnbounded)) {
16152
- diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocAddendum.tupleSizeIndeterminate().format({
16153
- expected: destTypeArgs.length,
16154
- }));
16231
+ const isDestIndeterminate = destTypeArgs.some((t) => t.isUnbounded || (0, types_1.isVariadicTypeVar)(t.type));
16232
+ if (srcTypeArgs.some((t) => t.isUnbounded || (0, types_1.isVariadicTypeVar)(t.type))) {
16233
+ if (isDestIndeterminate) {
16234
+ diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocAddendum.tupleSizeIndeterminateSrcDest().format({
16235
+ expected: destTypeArgs.length - 1,
16236
+ }));
16237
+ }
16238
+ else {
16239
+ diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocAddendum.tupleSizeIndeterminateSrc().format({
16240
+ expected: destTypeArgs.length,
16241
+ }));
16242
+ }
16155
16243
  }
16156
16244
  else {
16157
- diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocAddendum.tupleSizeMismatch().format({
16158
- expected: destTypeArgs.length,
16159
- received: srcTypeArgs.length,
16160
- }));
16245
+ if (isDestIndeterminate) {
16246
+ diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocAddendum.tupleSizeMismatchIndeterminateDest().format({
16247
+ expected: destTypeArgs.length - 1,
16248
+ received: srcTypeArgs.length,
16249
+ }));
16250
+ }
16251
+ else {
16252
+ diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocAddendum.tupleSizeMismatch().format({
16253
+ expected: destTypeArgs.length,
16254
+ received: srcTypeArgs.length,
16255
+ }));
16256
+ }
16161
16257
  }
16162
16258
  return false;
16163
16259
  }
@@ -16248,6 +16344,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16248
16344
  const typeParam = destType.details.typeParameters[i];
16249
16345
  const variance = types_1.TypeVarType.getVariance(typeParam);
16250
16346
  (0, constraintSolver_1.updateTypeVarType)(evaluatorInterface, destTypeVarContext, typeParam, variance !== 4 /* Variance.Contravariant */ ? typeArgType : undefined, variance !== 3 /* Variance.Covariant */ ? typeArgType : undefined,
16347
+ /* tupleTypes */ curSrcType.tupleTypeArguments,
16251
16348
  /* forceRetainLiterals */ true);
16252
16349
  }
16253
16350
  }
@@ -16595,7 +16692,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16595
16692
  }
16596
16693
  if ((0, types_1.isNever)(srcType)) {
16597
16694
  if ((flags & 1 /* AssignTypeFlags.EnforceInvariance */) !== 0) {
16598
- return (0, types_1.isNever)(destType);
16695
+ if ((0, types_1.isNever)(destType)) {
16696
+ return true;
16697
+ }
16698
+ diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.LocAddendum.typeAssignmentMismatch().format(printSrcDestTypes(srcType, destType)));
16699
+ return false;
16599
16700
  }
16600
16701
  const targetTypeVarContext = (flags & 2 /* AssignTypeFlags.ReverseTypeVarMatching */) === 0 ? destTypeVarContext : srcTypeVarContext;
16601
16702
  if (targetTypeVarContext) {
@@ -16728,7 +16829,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16728
16829
  return !isLiteral;
16729
16830
  }
16730
16831
  }
16731
- else if (types_1.ClassType.isBuiltIn(destType, 'TypeGuard')) {
16832
+ else if (types_1.ClassType.isBuiltIn(destType, ['TypeGuard', 'TypeIs'])) {
16732
16833
  // All the source to be a "bool".
16733
16834
  if ((originalFlags & 128 /* AssignTypeFlags.AllowBoolTypeGuard */) !== 0) {
16734
16835
  if ((0, types_1.isClassInstance)(srcType) && types_1.ClassType.isBuiltIn(srcType, 'bool')) {
@@ -17010,7 +17111,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17010
17111
  return false;
17011
17112
  });
17012
17113
  if (destTypeIndex >= 0) {
17013
- if (assignType(remainingDestSubtypes[destTypeIndex], srcSubtype, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), destTypeVarContext, srcTypeVarContext, flags, recursionCount)) {
17114
+ if (assignType(remainingDestSubtypes[destTypeIndex], srcSubtype,
17115
+ /* diag */ undefined, destTypeVarContext, srcTypeVarContext, flags, recursionCount)) {
17014
17116
  // Note that we have matched at least one subtype indicating
17015
17117
  // there is at least some overlap.
17016
17118
  matchedSomeSubtypes = true;
@@ -17459,15 +17561,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17459
17561
  }
17460
17562
  });
17461
17563
  if (srcTupleTypes.length !== 1 || !(0, types_1.isVariadicTypeVar)(srcTupleTypes[0].type)) {
17462
- let srcPositionalsType;
17463
- if (tupleClassType && (0, types_1.isInstantiableClass)(tupleClassType)) {
17464
- srcPositionalsType = (0, typeUtils_1.convertToInstance)((0, typeUtils_1.specializeTupleClass)(tupleClassType, srcTupleTypes,
17465
- /* isTypeArgumentExplicit */ true,
17466
- /* isUnpackedTuple */ true));
17467
- }
17468
- else {
17469
- srcPositionalsType = types_1.UnknownType.create();
17470
- }
17564
+ const srcPositionalsType = makeTupleObject(srcTupleTypes, /* isUnpackedTuple */ true);
17471
17565
  // Snip out the portion of the source positionals that map to the variadic
17472
17566
  // dest parameter and replace it with a single parameter that is typed as a
17473
17567
  // tuple containing the individual types of the replaced parameters.
@@ -17675,15 +17769,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17675
17769
  !types_1.FunctionType.shouldSkipArgsKwargsCompatibilityCheck(destType)) {
17676
17770
  let destArgsType = destParamDetails.params[destParamDetails.argsIndex].type;
17677
17771
  let srcArgsType = srcParamDetails.params[srcParamDetails.argsIndex].type;
17678
- if (tupleClassType && (0, types_1.isInstantiableClass)(tupleClassType)) {
17679
- if (!(0, types_1.isUnpacked)(destArgsType)) {
17680
- destArgsType = types_1.ClassType.cloneForUnpacked(types_1.ClassType.cloneAsInstance((0, typeUtils_1.specializeTupleClass)(tupleClassType, [{ type: destArgsType, isUnbounded: true }],
17681
- /* isTypeArgumentExplicit */ true)));
17682
- }
17683
- if (!(0, types_1.isUnpacked)(srcArgsType)) {
17684
- srcArgsType = types_1.ClassType.cloneForUnpacked(types_1.ClassType.cloneAsInstance((0, typeUtils_1.specializeTupleClass)(tupleClassType, [{ type: srcArgsType, isUnbounded: true }],
17685
- /* isTypeArgumentExplicit */ true)));
17686
- }
17772
+ if (!(0, types_1.isUnpacked)(destArgsType)) {
17773
+ destArgsType = makeTupleObject([{ type: destArgsType, isUnbounded: true }], /* isUnpackedTuple */ true);
17774
+ }
17775
+ if (!(0, types_1.isUnpacked)(srcArgsType)) {
17776
+ srcArgsType = makeTupleObject([{ type: srcArgsType, isUnbounded: true }], /* isUnpackedTuple */ true);
17687
17777
  }
17688
17778
  if (!assignFunctionParameter(destArgsType, srcArgsType, destParamDetails.params[destParamDetails.argsIndex].index, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), destTypeVarContext, srcTypeVarContext, flags, recursionCount)) {
17689
17779
  canAssign = false;
@@ -17917,10 +18007,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17917
18007
  isReturnTypeCompatible = true;
17918
18008
  }
17919
18009
  else {
17920
- // Handle the special case where the return type is a TypeGuard[T].
17921
- // This should also act as a bool, since that's its type at runtime.
18010
+ // Handle the special case where the return type is a TypeGuard[T]
18011
+ // or TypeIs[T]. This should also act as a bool, since that's its
18012
+ // type at runtime.
17922
18013
  if ((0, types_1.isClassInstance)(srcReturnType) &&
17923
- types_1.ClassType.isBuiltIn(srcReturnType, 'TypeGuard') &&
18014
+ types_1.ClassType.isBuiltIn(srcReturnType, ['TypeGuard', 'TypeIs']) &&
17924
18015
  boolClassType &&
17925
18016
  (0, types_1.isInstantiableClass)(boolClassType)) {
17926
18017
  if (assignType(destReturnType, types_1.ClassType.cloneAsInstance(boolClassType), returnDiag === null || returnDiag === void 0 ? void 0 : returnDiag.createAddendum(), destTypeVarContext, srcTypeVarContext, flags, recursionCount)) {
@@ -18012,6 +18103,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
18012
18103
  // we may be able to narrow the type based on the assignment.
18013
18104
  function narrowTypeBasedOnAssignment(node, declaredType, assignedType) {
18014
18105
  const narrowedType = (0, typeUtils_1.mapSubtypes)(assignedType, (assignedSubtype) => {
18106
+ // Handle the special case where the assigned type is a literal type.
18107
+ // Some types include very large unions of literal types, and we don't
18108
+ // want to use an n^2 loop to compare them.
18109
+ if ((0, types_1.isClass)(assignedSubtype) && (0, typeUtils_1.isLiteralType)(assignedSubtype)) {
18110
+ if ((0, types_1.isUnion)(declaredType) && types_1.UnionType.containsType(declaredType, assignedSubtype)) {
18111
+ return assignedSubtype;
18112
+ }
18113
+ }
18015
18114
  const narrowedSubtype = (0, typeUtils_1.mapSubtypes)(declaredType, (declaredSubtype) => {
18016
18115
  // We can't narrow "Any".
18017
18116
  if ((0, types_1.isAnyOrUnknown)(declaredSubtype)) {