@zzzen/pyright-internal 1.2.0-dev.20231126 → 1.2.0-dev.20231210

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 (383) hide show
  1. package/dist/analyzer/analyzerFileInfo.d.ts +4 -3
  2. package/dist/analyzer/analyzerFileInfo.js.map +1 -1
  3. package/dist/analyzer/backgroundAnalysisProgram.d.ts +15 -14
  4. package/dist/analyzer/backgroundAnalysisProgram.js +38 -38
  5. package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
  6. package/dist/analyzer/binder.js +59 -52
  7. package/dist/analyzer/binder.js.map +1 -1
  8. package/dist/analyzer/checker.d.ts +4 -1
  9. package/dist/analyzer/checker.js +189 -42
  10. package/dist/analyzer/checker.js.map +1 -1
  11. package/dist/analyzer/circularDependency.d.ts +3 -2
  12. package/dist/analyzer/circularDependency.js.map +1 -1
  13. package/dist/analyzer/codeFlowEngine.js +36 -36
  14. package/dist/analyzer/codeFlowEngine.js.map +1 -1
  15. package/dist/analyzer/commentUtils.js +7 -0
  16. package/dist/analyzer/commentUtils.js.map +1 -1
  17. package/dist/analyzer/constraintSolver.js +14 -5
  18. package/dist/analyzer/constraintSolver.js.map +1 -1
  19. package/dist/analyzer/constructors.js +2 -1
  20. package/dist/analyzer/constructors.js.map +1 -1
  21. package/dist/analyzer/dataClasses.js +58 -47
  22. package/dist/analyzer/dataClasses.js.map +1 -1
  23. package/dist/analyzer/declaration.d.ts +5 -3
  24. package/dist/analyzer/declaration.js +3 -2
  25. package/dist/analyzer/declaration.js.map +1 -1
  26. package/dist/analyzer/declarationUtils.d.ts +3 -2
  27. package/dist/analyzer/declarationUtils.js +14 -12
  28. package/dist/analyzer/declarationUtils.js.map +1 -1
  29. package/dist/analyzer/enums.js +1 -1
  30. package/dist/analyzer/enums.js.map +1 -1
  31. package/dist/analyzer/importResolver.d.ts +29 -25
  32. package/dist/analyzer/importResolver.js +300 -301
  33. package/dist/analyzer/importResolver.js.map +1 -1
  34. package/dist/analyzer/importResult.d.ts +5 -4
  35. package/dist/analyzer/importResult.js.map +1 -1
  36. package/dist/analyzer/importStatementUtils.d.ts +5 -4
  37. package/dist/analyzer/importStatementUtils.js +23 -22
  38. package/dist/analyzer/importStatementUtils.js.map +1 -1
  39. package/dist/analyzer/namedTuples.js +3 -3
  40. package/dist/analyzer/namedTuples.js.map +1 -1
  41. package/dist/analyzer/operations.js +16 -14
  42. package/dist/analyzer/operations.js.map +1 -1
  43. package/dist/analyzer/packageTypeReport.d.ts +7 -6
  44. package/dist/analyzer/packageTypeReport.js +4 -4
  45. package/dist/analyzer/packageTypeReport.js.map +1 -1
  46. package/dist/analyzer/packageTypeVerifier.js +68 -64
  47. package/dist/analyzer/packageTypeVerifier.js.map +1 -1
  48. package/dist/analyzer/parentDirectoryCache.d.ts +7 -6
  49. package/dist/analyzer/parentDirectoryCache.js +9 -10
  50. package/dist/analyzer/parentDirectoryCache.js.map +1 -1
  51. package/dist/analyzer/parseTreeUtils.d.ts +1 -1
  52. package/dist/analyzer/parseTreeUtils.js +6 -3
  53. package/dist/analyzer/parseTreeUtils.js.map +1 -1
  54. package/dist/analyzer/patternMatching.js +79 -14
  55. package/dist/analyzer/patternMatching.js.map +1 -1
  56. package/dist/analyzer/program.d.ts +27 -26
  57. package/dist/analyzer/program.js +162 -156
  58. package/dist/analyzer/program.js.map +1 -1
  59. package/dist/analyzer/properties.js +3 -3
  60. package/dist/analyzer/properties.js.map +1 -1
  61. package/dist/analyzer/protocols.js +27 -13
  62. package/dist/analyzer/protocols.js.map +1 -1
  63. package/dist/analyzer/pyTypedUtils.d.ts +3 -2
  64. package/dist/analyzer/pyTypedUtils.js +4 -5
  65. package/dist/analyzer/pyTypedUtils.js.map +1 -1
  66. package/dist/analyzer/pythonPathUtils.d.ts +7 -6
  67. package/dist/analyzer/pythonPathUtils.js +21 -23
  68. package/dist/analyzer/pythonPathUtils.js.map +1 -1
  69. package/dist/analyzer/service.d.ts +24 -23
  70. package/dist/analyzer/service.js +187 -183
  71. package/dist/analyzer/service.js.map +1 -1
  72. package/dist/analyzer/sourceFile.d.ts +4 -5
  73. package/dist/analyzer/sourceFile.js +68 -56
  74. package/dist/analyzer/sourceFile.js.map +1 -1
  75. package/dist/analyzer/sourceFileInfoUtils.js +3 -3
  76. package/dist/analyzer/sourceFileInfoUtils.js.map +1 -1
  77. package/dist/analyzer/sourceMapper.d.ts +11 -10
  78. package/dist/analyzer/sourceMapper.js +59 -62
  79. package/dist/analyzer/sourceMapper.js.map +1 -1
  80. package/dist/analyzer/sourceMapperUtils.d.ts +2 -1
  81. package/dist/analyzer/sourceMapperUtils.js +2 -2
  82. package/dist/analyzer/sourceMapperUtils.js.map +1 -1
  83. package/dist/analyzer/tracePrinter.d.ts +3 -2
  84. package/dist/analyzer/tracePrinter.js +21 -23
  85. package/dist/analyzer/tracePrinter.js.map +1 -1
  86. package/dist/analyzer/typeDocStringUtils.d.ts +2 -1
  87. package/dist/analyzer/typeDocStringUtils.js +14 -17
  88. package/dist/analyzer/typeDocStringUtils.js.map +1 -1
  89. package/dist/analyzer/typeEvaluator.js +298 -231
  90. package/dist/analyzer/typeEvaluator.js.map +1 -1
  91. package/dist/analyzer/typeEvaluatorTypes.d.ts +1 -1
  92. package/dist/analyzer/typeEvaluatorTypes.js +1 -1
  93. package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
  94. package/dist/analyzer/typeGuards.js +3 -3
  95. package/dist/analyzer/typeGuards.js.map +1 -1
  96. package/dist/analyzer/typePrinter.d.ts +2 -0
  97. package/dist/analyzer/typePrinter.js +48 -8
  98. package/dist/analyzer/typePrinter.js.map +1 -1
  99. package/dist/analyzer/typeStubWriter.d.ts +2 -1
  100. package/dist/analyzer/typeStubWriter.js +2 -2
  101. package/dist/analyzer/typeStubWriter.js.map +1 -1
  102. package/dist/analyzer/typeUtils.d.ts +5 -3
  103. package/dist/analyzer/typeUtils.js +32 -17
  104. package/dist/analyzer/typeUtils.js.map +1 -1
  105. package/dist/analyzer/typeVarContext.d.ts +2 -0
  106. package/dist/analyzer/typeVarContext.js +27 -0
  107. package/dist/analyzer/typeVarContext.js.map +1 -1
  108. package/dist/analyzer/typedDicts.js +6 -36
  109. package/dist/analyzer/typedDicts.js.map +1 -1
  110. package/dist/analyzer/types.d.ts +8 -12
  111. package/dist/analyzer/types.js +13 -20
  112. package/dist/analyzer/types.js.map +1 -1
  113. package/dist/backgroundAnalysis.d.ts +1 -2
  114. package/dist/backgroundAnalysis.js +6 -4
  115. package/dist/backgroundAnalysis.js.map +1 -1
  116. package/dist/backgroundAnalysisBase.d.ts +22 -20
  117. package/dist/backgroundAnalysisBase.js +76 -55
  118. package/dist/backgroundAnalysisBase.js.map +1 -1
  119. package/dist/backgroundThreadBase.d.ts +1 -1
  120. package/dist/backgroundThreadBase.js +20 -11
  121. package/dist/backgroundThreadBase.js.map +1 -1
  122. package/dist/commands/commandController.js +1 -2
  123. package/dist/commands/commandController.js.map +1 -1
  124. package/dist/commands/commands.d.ts +0 -1
  125. package/dist/commands/commands.js +0 -1
  126. package/dist/commands/commands.js.map +1 -1
  127. package/dist/commands/createTypeStub.js +3 -2
  128. package/dist/commands/createTypeStub.js.map +1 -1
  129. package/dist/commands/dumpFileDebugInfoCommand.js +21 -20
  130. package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
  131. package/dist/commands/quickActionCommand.js +5 -5
  132. package/dist/commands/quickActionCommand.js.map +1 -1
  133. package/dist/common/configOptions.d.ts +15 -13
  134. package/dist/common/configOptions.js +120 -30
  135. package/dist/common/configOptions.js.map +1 -1
  136. package/dist/common/diagnostic.d.ts +6 -9
  137. package/dist/common/diagnostic.js +2 -2
  138. package/dist/common/diagnostic.js.map +1 -1
  139. package/dist/common/diagnosticSink.d.ts +2 -1
  140. package/dist/common/diagnosticSink.js.map +1 -1
  141. package/dist/common/editAction.d.ts +6 -5
  142. package/dist/common/editAction.js +2 -2
  143. package/dist/common/editAction.js.map +1 -1
  144. package/dist/common/envVarUtils.d.ts +2 -1
  145. package/dist/common/envVarUtils.js +20 -28
  146. package/dist/common/envVarUtils.js.map +1 -1
  147. package/dist/common/extensibility.d.ts +19 -19
  148. package/dist/common/extensibility.js.map +1 -1
  149. package/dist/common/fileSystem.d.ts +29 -28
  150. package/dist/common/fileWatcher.d.ts +3 -2
  151. package/dist/common/fileWatcher.js.map +1 -1
  152. package/dist/common/fullAccessHost.d.ts +8 -7
  153. package/dist/common/fullAccessHost.js +21 -16
  154. package/dist/common/fullAccessHost.js.map +1 -1
  155. package/dist/common/host.d.ts +7 -6
  156. package/dist/common/host.js +1 -1
  157. package/dist/common/host.js.map +1 -1
  158. package/dist/common/logTracker.d.ts +2 -1
  159. package/dist/common/logTracker.js +4 -4
  160. package/dist/common/logTracker.js.map +1 -1
  161. package/dist/common/pathUtils.d.ts +1 -28
  162. package/dist/common/pathUtils.js +17 -366
  163. package/dist/common/pathUtils.js.map +1 -1
  164. package/dist/common/realFileSystem.d.ts +7 -3
  165. package/dist/common/realFileSystem.js +78 -60
  166. package/dist/common/realFileSystem.js.map +1 -1
  167. package/dist/common/serviceProviderExtensions.d.ts +2 -1
  168. package/dist/common/serviceProviderExtensions.js +5 -2
  169. package/dist/common/serviceProviderExtensions.js.map +1 -1
  170. package/dist/common/textEditTracker.d.ts +2 -1
  171. package/dist/common/textEditTracker.js +28 -28
  172. package/dist/common/textEditTracker.js.map +1 -1
  173. package/dist/common/textRange.d.ts +2 -1
  174. package/dist/common/textRange.js.map +1 -1
  175. package/dist/common/uri/baseUri.d.ts +51 -0
  176. package/dist/common/uri/baseUri.js +194 -0
  177. package/dist/common/uri/baseUri.js.map +1 -0
  178. package/dist/common/uri/emptyUri.d.ts +32 -0
  179. package/dist/common/uri/emptyUri.js +122 -0
  180. package/dist/common/uri/emptyUri.js.map +1 -0
  181. package/dist/common/uri/fileUri.d.ts +36 -0
  182. package/dist/common/uri/fileUri.js +180 -0
  183. package/dist/common/uri/fileUri.js.map +1 -0
  184. package/dist/common/uri/memoization.d.ts +3 -0
  185. package/dist/common/uri/memoization.js +72 -0
  186. package/dist/common/uri/memoization.js.map +1 -0
  187. package/dist/common/uri/uri.d.ts +50 -0
  188. package/dist/common/uri/uri.js +104 -0
  189. package/dist/common/uri/uri.js.map +1 -0
  190. package/dist/common/uri/uriUtils.d.ts +39 -0
  191. package/dist/common/uri/uriUtils.js +362 -0
  192. package/dist/common/uri/uriUtils.js.map +1 -0
  193. package/dist/common/uri/webUri.d.ts +36 -0
  194. package/dist/common/uri/webUri.js +207 -0
  195. package/dist/common/uri/webUri.js.map +1 -0
  196. package/dist/common/workspaceEditUtils.d.ts +8 -8
  197. package/dist/common/workspaceEditUtils.js +34 -37
  198. package/dist/common/workspaceEditUtils.js.map +1 -1
  199. package/dist/languageServerBase.d.ts +19 -22
  200. package/dist/languageServerBase.js +91 -95
  201. package/dist/languageServerBase.js.map +1 -1
  202. package/dist/languageService/analyzerServiceExecutor.d.ts +2 -1
  203. package/dist/languageService/analyzerServiceExecutor.js +14 -16
  204. package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
  205. package/dist/languageService/autoImporter.d.ts +11 -9
  206. package/dist/languageService/autoImporter.js +45 -44
  207. package/dist/languageService/autoImporter.js.map +1 -1
  208. package/dist/languageService/callHierarchyProvider.d.ts +3 -2
  209. package/dist/languageService/callHierarchyProvider.js +23 -35
  210. package/dist/languageService/callHierarchyProvider.js.map +1 -1
  211. package/dist/languageService/codeActionProvider.d.ts +2 -1
  212. package/dist/languageService/codeActionProvider.js +8 -24
  213. package/dist/languageService/codeActionProvider.js.map +1 -1
  214. package/dist/languageService/completionProvider.d.ts +7 -6
  215. package/dist/languageService/completionProvider.js +32 -30
  216. package/dist/languageService/completionProvider.js.map +1 -1
  217. package/dist/languageService/completionProviderUtils.d.ts +2 -1
  218. package/dist/languageService/completionProviderUtils.js +1 -1
  219. package/dist/languageService/completionProviderUtils.js.map +1 -1
  220. package/dist/languageService/definitionProvider.d.ts +4 -3
  221. package/dist/languageService/definitionProvider.js +26 -24
  222. package/dist/languageService/definitionProvider.js.map +1 -1
  223. package/dist/languageService/documentHighlightProvider.d.ts +3 -2
  224. package/dist/languageService/documentHighlightProvider.js +3 -3
  225. package/dist/languageService/documentHighlightProvider.js.map +1 -1
  226. package/dist/languageService/documentSymbolCollector.js +8 -7
  227. package/dist/languageService/documentSymbolCollector.js.map +1 -1
  228. package/dist/languageService/documentSymbolProvider.d.ts +5 -4
  229. package/dist/languageService/documentSymbolProvider.js +9 -11
  230. package/dist/languageService/documentSymbolProvider.js.map +1 -1
  231. package/dist/languageService/hoverProvider.d.ts +4 -3
  232. package/dist/languageService/hoverProvider.js +6 -5
  233. package/dist/languageService/hoverProvider.js.map +1 -1
  234. package/dist/languageService/navigationUtils.d.ts +2 -1
  235. package/dist/languageService/navigationUtils.js +2 -3
  236. package/dist/languageService/navigationUtils.js.map +1 -1
  237. package/dist/languageService/quickActions.d.ts +2 -2
  238. package/dist/languageService/quickActions.js +3 -83
  239. package/dist/languageService/quickActions.js.map +1 -1
  240. package/dist/languageService/referencesProvider.d.ts +10 -9
  241. package/dist/languageService/referencesProvider.js +28 -28
  242. package/dist/languageService/referencesProvider.js.map +1 -1
  243. package/dist/languageService/renameProvider.d.ts +4 -3
  244. package/dist/languageService/renameProvider.js +17 -18
  245. package/dist/languageService/renameProvider.js.map +1 -1
  246. package/dist/languageService/signatureHelpProvider.d.ts +3 -2
  247. package/dist/languageService/signatureHelpProvider.js +4 -4
  248. package/dist/languageService/signatureHelpProvider.js.map +1 -1
  249. package/dist/languageService/symbolIndexer.d.ts +2 -1
  250. package/dist/languageService/symbolIndexer.js +1 -1
  251. package/dist/languageService/symbolIndexer.js.map +1 -1
  252. package/dist/languageService/tooltipUtils.js +10 -4
  253. package/dist/languageService/tooltipUtils.js.map +1 -1
  254. package/dist/languageService/workspaceSymbolProvider.d.ts +4 -3
  255. package/dist/languageService/workspaceSymbolProvider.js +10 -11
  256. package/dist/languageService/workspaceSymbolProvider.js.map +1 -1
  257. package/dist/localization/localize.d.ts +13 -9
  258. package/dist/localization/localize.js +7 -4
  259. package/dist/localization/localize.js.map +1 -1
  260. package/dist/localization/package.nls.cs.json +0 -4
  261. package/dist/localization/package.nls.de.json +0 -4
  262. package/dist/localization/package.nls.en-us.json +9 -6
  263. package/dist/localization/package.nls.es.json +2 -6
  264. package/dist/localization/package.nls.fr.json +0 -4
  265. package/dist/localization/package.nls.it.json +0 -4
  266. package/dist/localization/package.nls.ja.json +0 -4
  267. package/dist/localization/package.nls.ko.json +0 -4
  268. package/dist/localization/package.nls.pl.json +0 -4
  269. package/dist/localization/package.nls.pt-br.json +0 -4
  270. package/dist/localization/package.nls.qps-ploc.json +0 -4
  271. package/dist/localization/package.nls.ru.json +0 -4
  272. package/dist/localization/package.nls.tr.json +0 -4
  273. package/dist/localization/package.nls.zh-cn.json +0 -4
  274. package/dist/localization/package.nls.zh-tw.json +0 -4
  275. package/dist/pyright.js +18 -17
  276. package/dist/pyright.js.map +1 -1
  277. package/dist/pyrightFileSystem.d.ts +13 -13
  278. package/dist/pyrightFileSystem.js +39 -44
  279. package/dist/pyrightFileSystem.js.map +1 -1
  280. package/dist/readonlyAugmentedFileSystem.d.ts +29 -28
  281. package/dist/readonlyAugmentedFileSystem.js +68 -61
  282. package/dist/readonlyAugmentedFileSystem.js.map +1 -1
  283. package/dist/server.js +22 -21
  284. package/dist/server.js.map +1 -1
  285. package/dist/tests/chainedSourceFiles.test.js +39 -30
  286. package/dist/tests/chainedSourceFiles.test.js.map +1 -1
  287. package/dist/tests/checker.test.js +38 -29
  288. package/dist/tests/checker.test.js.map +1 -1
  289. package/dist/tests/completions.test.js +7 -3
  290. package/dist/tests/completions.test.js.map +1 -1
  291. package/dist/tests/config.test.js +24 -22
  292. package/dist/tests/config.test.js.map +1 -1
  293. package/dist/tests/documentSymbolCollector.test.js +3 -2
  294. package/dist/tests/documentSymbolCollector.test.js.map +1 -1
  295. package/dist/tests/filesystem.test.js +37 -35
  296. package/dist/tests/filesystem.test.js.map +1 -1
  297. package/dist/tests/fourSlashParser.test.js +4 -4
  298. package/dist/tests/fourSlashParser.test.js.map +1 -1
  299. package/dist/tests/fourslash/fourslash.d.ts +1 -2
  300. package/dist/tests/fourslash/hover.docstring.alias.fourslash.js +27 -11
  301. package/dist/tests/fourslash/hover.docstring.alias.fourslash.js.map +1 -1
  302. package/dist/tests/harness/fourslash/fourSlashParser.js +2 -2
  303. package/dist/tests/harness/fourslash/fourSlashParser.js.map +1 -1
  304. package/dist/tests/harness/fourslash/testLanguageService.d.ts +4 -5
  305. package/dist/tests/harness/fourslash/testLanguageService.js +9 -15
  306. package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
  307. package/dist/tests/harness/fourslash/testState.Consts.d.ts +1 -2
  308. package/dist/tests/harness/fourslash/testState.Consts.js +0 -1
  309. package/dist/tests/harness/fourslash/testState.Consts.js.map +1 -1
  310. package/dist/tests/harness/fourslash/testState.d.ts +4 -4
  311. package/dist/tests/harness/fourslash/testState.js +92 -52
  312. package/dist/tests/harness/fourslash/testState.js.map +1 -1
  313. package/dist/tests/harness/testAccessHost.d.ts +3 -2
  314. package/dist/tests/harness/testAccessHost.js +2 -1
  315. package/dist/tests/harness/testAccessHost.js.map +1 -1
  316. package/dist/tests/harness/testHost.js +13 -11
  317. package/dist/tests/harness/testHost.js.map +1 -1
  318. package/dist/tests/harness/vfs/factory.d.ts +3 -2
  319. package/dist/tests/harness/vfs/factory.js +5 -4
  320. package/dist/tests/harness/vfs/factory.js.map +1 -1
  321. package/dist/tests/harness/vfs/filesystem.d.ts +32 -31
  322. package/dist/tests/harness/vfs/filesystem.js +47 -49
  323. package/dist/tests/harness/vfs/filesystem.js.map +1 -1
  324. package/dist/tests/harness/vfs/pathValidation.js +1 -10
  325. package/dist/tests/harness/vfs/pathValidation.js.map +1 -1
  326. package/dist/tests/importResolver.test.js +81 -58
  327. package/dist/tests/importResolver.test.js.map +1 -1
  328. package/dist/tests/importStatementUtils.test.js +10 -9
  329. package/dist/tests/importStatementUtils.test.js.map +1 -1
  330. package/dist/tests/ipythonMode.test.js +12 -11
  331. package/dist/tests/ipythonMode.test.js.map +1 -1
  332. package/dist/tests/logger.test.js +2 -1
  333. package/dist/tests/logger.test.js.map +1 -1
  334. package/dist/tests/parseTreeUtils.test.js +2 -1
  335. package/dist/tests/parseTreeUtils.test.js.map +1 -1
  336. package/dist/tests/pathUtils.test.js +3 -138
  337. package/dist/tests/pathUtils.test.js.map +1 -1
  338. package/dist/tests/pyrightFileSystem.test.js +76 -25
  339. package/dist/tests/pyrightFileSystem.test.js.map +1 -1
  340. package/dist/tests/service.test.js +37 -42
  341. package/dist/tests/service.test.js.map +1 -1
  342. package/dist/tests/signatureHelp.test.js +3 -2
  343. package/dist/tests/signatureHelp.test.js.map +1 -1
  344. package/dist/tests/sourceFile.test.js +8 -7
  345. package/dist/tests/sourceFile.test.js.map +1 -1
  346. package/dist/tests/sourceMapperUtils.test.js +13 -6
  347. package/dist/tests/sourceMapperUtils.test.js.map +1 -1
  348. package/dist/tests/testState.test.js +13 -9
  349. package/dist/tests/testState.test.js.map +1 -1
  350. package/dist/tests/testStateUtils.d.ts +2 -5
  351. package/dist/tests/testStateUtils.js +27 -64
  352. package/dist/tests/testStateUtils.js.map +1 -1
  353. package/dist/tests/testUtils.d.ts +3 -5
  354. package/dist/tests/testUtils.js +15 -64
  355. package/dist/tests/testUtils.js.map +1 -1
  356. package/dist/tests/textEditUtil.test.js +4 -3
  357. package/dist/tests/textEditUtil.test.js.map +1 -1
  358. package/dist/tests/typeEvaluator1.test.js +23 -19
  359. package/dist/tests/typeEvaluator1.test.js.map +1 -1
  360. package/dist/tests/typeEvaluator2.test.js +21 -12
  361. package/dist/tests/typeEvaluator2.test.js.map +1 -1
  362. package/dist/tests/typeEvaluator3.test.js +84 -70
  363. package/dist/tests/typeEvaluator3.test.js.map +1 -1
  364. package/dist/tests/typeEvaluator4.test.js +26 -21
  365. package/dist/tests/typeEvaluator4.test.js.map +1 -1
  366. package/dist/tests/typeEvaluator5.test.js +36 -31
  367. package/dist/tests/typeEvaluator5.test.js.map +1 -1
  368. package/dist/tests/typePrinter.test.js +4 -3
  369. package/dist/tests/typePrinter.test.js.map +1 -1
  370. package/dist/tests/uri.test.d.ts +1 -0
  371. package/dist/tests/uri.test.js +695 -0
  372. package/dist/tests/uri.test.js.map +1 -0
  373. package/dist/tests/workspaceEditUtils.test.js +28 -28
  374. package/dist/tests/workspaceEditUtils.test.js.map +1 -1
  375. package/dist/tests/zipfs.test.js +11 -11
  376. package/dist/tests/zipfs.test.js.map +1 -1
  377. package/dist/workspaceFactory.d.ts +13 -14
  378. package/dist/workspaceFactory.js +54 -55
  379. package/dist/workspaceFactory.js.map +1 -1
  380. package/package.json +2 -2
  381. package/dist/common/uriParser.d.ts +0 -24
  382. package/dist/common/uriParser.js +0 -45
  383. package/dist/common/uriParser.js.map +0 -1
@@ -47,6 +47,7 @@ const diagnosticRules_1 = require("../common/diagnosticRules");
47
47
  const positionUtils_1 = require("../common/positionUtils");
48
48
  const pythonVersion_1 = require("../common/pythonVersion");
49
49
  const textRange_1 = require("../common/textRange");
50
+ const uri_1 = require("../common/uri/uri");
50
51
  const localize_1 = require("../localization/localize");
51
52
  const parseNodes_1 = require("../parser/parseNodes");
52
53
  const parser_1 = require("../parser/parser");
@@ -262,7 +263,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
262
263
  const message = `Type cache flag mismatch for node type ${node.nodeType} ` +
263
264
  `(parent ${(_b = (_a = node.parent) === null || _a === void 0 ? void 0 : _a.nodeType) !== null && _b !== void 0 ? _b : 'none'}): ` +
264
265
  `cached flags = ${expectedFlags}, access flags = ${flags}, ` +
265
- `file = {${fileInfo.filePath} [${position.line + 1}:${position.character + 1}]}`;
266
+ `file = {${fileInfo.fileUri} [${position.line + 1}:${position.character + 1}]}`;
266
267
  if (evaluatorOptions.verifyTypeCacheEvaluatorFlags) {
267
268
  (0, debug_1.fail)(message);
268
269
  }
@@ -735,15 +736,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
735
736
  }
736
737
  }
737
738
  }
738
- function reportInvalidUseOfPep695TypeAlias(type, node) {
739
- var _a;
740
- // PEP 695 type aliases cannot be used as instantiable classes.
741
- if (((_a = type.typeAliasInfo) === null || _a === void 0 ? void 0 : _a.name) && type.typeAliasInfo.isPep695Syntax && types_1.TypeBase.isSpecialForm(type)) {
742
- addDiagnostic(AnalyzerNodeInfo.getFileInfo(node).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.typeAliasNotAllowed().format({ name: type.typeAliasInfo.name }), node);
743
- return true;
744
- }
745
- return false;
746
- }
747
739
  function validateTypeIsInstantiable(typeResult, flags, node) {
748
740
  var _a;
749
741
  // If the type is incomplete, don't log any diagnostics yet.
@@ -770,7 +762,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
770
762
  }
771
763
  function getTypeOfAwaitOperator(node, flags, inferenceContext) {
772
764
  const effectiveExpectedType = inferenceContext
773
- ? createAwaitableReturnType(node, inferenceContext.expectedType, /* isGenerator */ false)
765
+ ? createAwaitableReturnType(node, inferenceContext.expectedType,
766
+ /* isGenerator */ false,
767
+ /* useCoroutine */ false)
774
768
  : undefined;
775
769
  const exprTypeResult = getTypeOfExpression(node.expression, flags, (0, typeUtils_1.makeInferenceContext)(effectiveExpectedType));
776
770
  const typeResult = {
@@ -1414,9 +1408,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
1414
1408
  return getBoundMagicMethod(boundMethodResult.type, '__call__', selfType !== null && selfType !== void 0 ? selfType : types_1.ClassType.cloneAsInstance(classType), recursionCount);
1415
1409
  }
1416
1410
  if ((0, types_1.isAnyOrUnknown)(boundMethodResult.type)) {
1417
- const unknownFunction = types_1.FunctionType.createSynthesizedInstance('', 32768 /* FunctionTypeFlags.SkipArgsKwargsCompatibilityCheck */);
1418
- types_1.FunctionType.addDefaultParameters(unknownFunction);
1419
- return unknownFunction;
1411
+ return (0, typeUtils_1.getUnknownTypeForCallable)();
1420
1412
  }
1421
1413
  return undefined;
1422
1414
  }
@@ -1930,7 +1922,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
1930
1922
  }
1931
1923
  function getTypeOfModule(node, symbolName, nameParts) {
1932
1924
  const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
1933
- const lookupResult = importLookup({ nameParts, importingFilePath: fileInfo.filePath });
1925
+ const lookupResult = importLookup({ nameParts, importingFileUri: fileInfo.fileUri });
1934
1926
  if (!lookupResult) {
1935
1927
  return undefined;
1936
1928
  }
@@ -2480,13 +2472,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
2480
2472
  (0, types_1.isFunction)(subtype) &&
2481
2473
  subtype.details.parameters.length === 0 &&
2482
2474
  subtype.details.paramSpec) {
2483
- const concreteFunction = types_1.FunctionType.createInstance('', '', '', 64 /* FunctionTypeFlags.SynthesizedMethod */ | 32768 /* FunctionTypeFlags.SkipArgsKwargsCompatibilityCheck */);
2484
- types_1.FunctionType.addDefaultParameters(concreteFunction);
2485
- return types_1.FunctionType.cloneForParamSpec(subtype, concreteFunction);
2475
+ return types_1.FunctionType.cloneForParamSpec(subtype, (0, typeUtils_1.getUnknownTypeForCallable)());
2486
2476
  }
2487
- // If this is a TypeVarTuple *Ts, convert it to an unpacked tuple
2488
- // *tuple[*Ts].
2489
- if ((0, types_1.isVariadicTypeVar)(subtype)) {
2477
+ if ((0, types_1.isTypeVar)(subtype) && subtype.details.isVariadic) {
2490
2478
  // If it's in a union, convert to type or object.
2491
2479
  if (subtype.isVariadicInUnion) {
2492
2480
  if (types_1.TypeBase.isInstantiable(subtype)) {
@@ -2499,11 +2487,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
2499
2487
  }
2500
2488
  return types_1.AnyType.create();
2501
2489
  }
2502
- if (tupleClassType && (0, types_1.isInstantiableClass)(tupleClassType)) {
2503
- return (0, typeUtils_1.convertToInstance)((0, typeUtils_1.specializeTupleClass)(tupleClassType, [{ type: subtype, isUnbounded: false }],
2504
- /* isTypeArgumentExplicit */ true,
2505
- /* isUnpackedTuple */ true));
2506
- }
2490
+ return subtype;
2507
2491
  }
2508
2492
  if ((0, types_1.isTypeVar)(subtype) && !subtype.details.recursiveTypeAliasName) {
2509
2493
  // If this is a recursive type alias placeholder
@@ -2555,7 +2539,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
2555
2539
  isConstrainedTypeVar: false,
2556
2540
  },
2557
2541
  ]);
2558
- return types_1.AnyType.create();
2559
2542
  }
2560
2543
  return subtype;
2561
2544
  });
@@ -2591,7 +2574,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
2591
2574
  if (typeCondition && typeCondition.length > 0) {
2592
2575
  transformedType = (0, typeUtils_1.addConditionToType)(transformedType, typeCondition);
2593
2576
  }
2594
- newSubtypes.push(transformedType);
2577
+ // This code path can often produce many duplicate subtypes. We can
2578
+ // reduce the cost of the combineTypes call below by filtering out these
2579
+ // duplicates proactively.
2580
+ if (newSubtypes.length === 0 ||
2581
+ !(0, types_1.isTypeSame)(transformedType, newSubtypes[newSubtypes.length - 1])) {
2582
+ newSubtypes.push(transformedType);
2583
+ }
2595
2584
  }
2596
2585
  return undefined;
2597
2586
  }, sortSubtypes);
@@ -2873,6 +2862,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
2873
2862
  }
2874
2863
  }
2875
2864
  function getTypeOfName(node, flags) {
2865
+ var _a;
2876
2866
  const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
2877
2867
  const name = node.value;
2878
2868
  let symbol;
@@ -3024,9 +3014,15 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3024
3014
  if ((flags & 256 /* EvaluatorFlags.ExpectingTypeAnnotation */) === 0) {
3025
3015
  reportUseOfTypeCheckOnly(type, node);
3026
3016
  }
3027
- if ((flags & 16777216 /* EvaluatorFlags.DisallowPep695TypeAlias */) !== 0) {
3028
- if (reportInvalidUseOfPep695TypeAlias(type, node)) {
3029
- type = types_1.UnknownType.create();
3017
+ if ((flags & 16777216 /* EvaluatorFlags.TreatPep695TypeAliasAsObject */) !== 0) {
3018
+ if (((_a = type.typeAliasInfo) === null || _a === void 0 ? void 0 : _a.name) && type.typeAliasInfo.isPep695Syntax && types_1.TypeBase.isSpecialForm(type)) {
3019
+ const typeAliasType = getTypingType(node, 'TypeAliasType');
3020
+ if (typeAliasType && (0, types_1.isInstantiableClass)(typeAliasType)) {
3021
+ type = types_1.ClassType.cloneAsInstance(typeAliasType);
3022
+ }
3023
+ else {
3024
+ type = types_1.UnknownType.create();
3025
+ }
3030
3026
  }
3031
3027
  }
3032
3028
  if ((flags & 128 /* EvaluatorFlags.ExpectingInstantiableType */) !== 0) {
@@ -3073,7 +3069,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3073
3069
  return type;
3074
3070
  }
3075
3071
  // Handles the case where a variable or parameter is defined in an outer
3076
- // scope and captured by an inner scope (either a function or a lambda).
3072
+ // scope and captured by an inner scope (a function, lambda, or comprehension).
3077
3073
  function getCodeFlowTypeForCapturedVariable(node, symbolWithScope, effectiveType) {
3078
3074
  // This function applies only to variables, parameters, and imports, not to other
3079
3075
  // types of symbols.
@@ -3093,16 +3089,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3093
3089
  // If the symbol is a variable captured by an inner function
3094
3090
  // or lambda, see if we can infer the type from the outer scope.
3095
3091
  const scopeHierarchy = ScopeUtils.getScopeHierarchy(node, symbolWithScope.scope);
3096
- // Handle the case where all of the nested scopes are functions,
3097
- // lambdas and modules. Don't allow other types of scopes.
3098
- if (scopeHierarchy &&
3099
- scopeHierarchy.length >= 2 &&
3100
- scopeHierarchy.every((s) => s.type === 1 /* ScopeType.Function */ || s.type === 3 /* ScopeType.Module */)) {
3092
+ if (scopeHierarchy && scopeHierarchy.length >= 2) {
3101
3093
  // Find the parse node associated with the scope that is just inside of the
3102
3094
  // scope that declares the captured variable.
3103
3095
  const innerScopeNode = ScopeUtils.findTopNodeInScope(node, scopeHierarchy[scopeHierarchy.length - 2]);
3104
- if (innerScopeNode &&
3105
- (innerScopeNode.nodeType === 28 /* ParseNodeType.Function */ || innerScopeNode.nodeType === 30 /* ParseNodeType.Lambda */)) {
3096
+ if ((innerScopeNode === null || innerScopeNode === void 0 ? void 0 : innerScopeNode.nodeType) === 28 /* ParseNodeType.Function */ ||
3097
+ (innerScopeNode === null || innerScopeNode === void 0 ? void 0 : innerScopeNode.nodeType) === 30 /* ParseNodeType.Lambda */ ||
3098
+ (innerScopeNode === null || innerScopeNode === void 0 ? void 0 : innerScopeNode.nodeType) === 10 /* ParseNodeType.Class */) {
3106
3099
  const innerScopeCodeFlowNode = AnalyzerNodeInfo.getFlowNode(innerScopeNode);
3107
3100
  if (innerScopeCodeFlowNode) {
3108
3101
  // See if any of the assignments of the symbol are reachable
@@ -3470,7 +3463,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3470
3463
  // cases where a type is passed as an argument (e.g. "defaultdict(list)").
3471
3464
  // It can also come up in cases like "isinstance(x, (list, dict))".
3472
3465
  // We need to check for functions as well to handle Callable.
3473
- if ((0, types_1.isInstantiableClass)(typeResult.type) || (0, types_1.isFunction)(typeResult.type)) {
3466
+ if ((0, types_1.isInstantiableClass)(typeResult.type) ||
3467
+ ((0, types_1.isFunction)(typeResult.type) && types_1.TypeBase.isSpecialForm(typeResult.type))) {
3474
3468
  const argNode = ParseTreeUtils.getParentNodeOfType(node, 1 /* ParseNodeType.Argument */);
3475
3469
  if (argNode && ((_a = argNode === null || argNode === void 0 ? void 0 : argNode.parent) === null || _a === void 0 ? void 0 : _a.nodeType) === 9 /* ParseNodeType.Call */) {
3476
3470
  skipPartialUnknownCheck = true;
@@ -3486,7 +3480,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3486
3480
  }
3487
3481
  function getTypeOfMemberAccessWithBaseType(node, baseTypeResult, usage, flags) {
3488
3482
  var _a, _b;
3489
- let baseType = baseTypeResult.type;
3483
+ let baseType = (0, typeUtils_1.transformPossibleRecursiveTypeAlias)(baseTypeResult.type);
3490
3484
  const memberName = node.memberName.value;
3491
3485
  let diag = new diagnostic_1.DiagnosticAddendum();
3492
3486
  const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
@@ -3624,9 +3618,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3624
3618
  const getAttrSymbol = types_1.ModuleType.getField(baseType, '__getattr__');
3625
3619
  if (getAttrSymbol) {
3626
3620
  const isModuleGetAttrSupported = fileInfo.executionEnvironment.pythonVersion >= pythonVersion_1.PythonVersion.V3_7 ||
3627
- getAttrSymbol
3628
- .getDeclarations()
3629
- .some((decl) => decl.path.toLowerCase().endsWith('.pyi'));
3621
+ getAttrSymbol.getDeclarations().some((decl) => decl.uri.hasExtension('.pyi'));
3630
3622
  if (isModuleGetAttrSupported) {
3631
3623
  const getAttrTypeResult = getEffectiveTypeOfSymbolForUsage(getAttrSymbol);
3632
3624
  if ((0, types_1.isFunction)(getAttrTypeResult.type)) {
@@ -4071,7 +4063,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
4071
4063
  if (types_1.ClassType.isClassProperty(concreteMemberType)) {
4072
4064
  // Handle "class properties" as a special case. We need to pass
4073
4065
  // the class rather than the object instance in this case.
4074
- objArgType = classType;
4066
+ objArgType = isAccessedThroughObject ? types_1.ClassType.cloneAsInstantiable(classType) : classType;
4075
4067
  }
4076
4068
  else if (isAccessedThroughObject) {
4077
4069
  objArgType = selfType !== null && selfType !== void 0 ? selfType : types_1.ClassType.cloneAsInstance(classType);
@@ -4357,7 +4349,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
4357
4349
  }
4358
4350
  }
4359
4351
  }
4360
- const indexTypeResult = getTypeOfIndexWithBaseType(node, baseTypeResult, { method: 'get' }, flags & ~16777216 /* EvaluatorFlags.DisallowPep695TypeAlias */);
4352
+ const indexTypeResult = getTypeOfIndexWithBaseType(node, baseTypeResult, { method: 'get' }, flags & ~16777216 /* EvaluatorFlags.TreatPep695TypeAliasAsObject */);
4361
4353
  if ((0, codeFlowTypes_1.isCodeFlowSupportedForReference)(node)) {
4362
4354
  // We limit type narrowing for index expressions to built-in types that are
4363
4355
  // known to have symmetric __getitem__ and __setitem__ methods (i.e. the value
@@ -5706,9 +5698,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
5706
5698
  addError(localize_1.Localizer.Diagnostic.superCallArgCount(), node.arguments[2]);
5707
5699
  }
5708
5700
  const enclosingFunction = ParseTreeUtils.getEnclosingFunctionEvaluationScope(node);
5709
- const enclosingClass = enclosingFunction
5710
- ? ParseTreeUtils.getEnclosingClass(enclosingFunction, /* stopAtFunction */ true)
5711
- : undefined;
5701
+ const enclosingClass = enclosingFunction ? ParseTreeUtils.getEnclosingClass(enclosingFunction) : undefined;
5712
5702
  const enclosingClassType = enclosingClass ? (_a = getTypeOfClass(enclosingClass)) === null || _a === void 0 ? void 0 : _a.classType : undefined;
5713
5703
  // Determine which class the "super" call is applied to. If
5714
5704
  // there is no first argument, then the class is implicit.
@@ -5771,6 +5761,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
5771
5761
  if (reportError) {
5772
5762
  const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
5773
5763
  addDiagnostic(fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.superCallSecondArg().format({ type: printType(targetClassType) }), node.arguments[1].valueExpression);
5764
+ return { type: types_1.UnknownType.create() };
5774
5765
  }
5775
5766
  }
5776
5767
  else if (enclosingClassType) {
@@ -5838,34 +5829,77 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
5838
5829
  const lookupResults = bindToType
5839
5830
  ? (0, typeUtils_1.lookUpClassMember)(bindToType, memberName, 0 /* MemberAccessFlags.Default */, effectiveTargetClass)
5840
5831
  : undefined;
5832
+ let resultType;
5841
5833
  if (lookupResults && (0, types_1.isInstantiableClass)(lookupResults.classType)) {
5842
- return {
5843
- type: resultIsInstance
5844
- ? types_1.ClassType.cloneAsInstance(lookupResults.classType)
5845
- : lookupResults.classType,
5846
- bindToSelfType: bindToType
5847
- ? types_1.TypeBase.cloneForCondition((0, typeUtils_1.synthesizeTypeVarForSelfCls)(bindToType, /* isClsParam */ false), bindToType.condition)
5848
- : undefined,
5849
- };
5834
+ resultType = lookupResults.classType;
5835
+ }
5836
+ else if (effectiveTargetClass &&
5837
+ !(0, types_1.isAnyOrUnknown)(effectiveTargetClass) &&
5838
+ !(0, typeUtils_1.derivesFromAnyOrUnknown)(effectiveTargetClass) &&
5839
+ objectType &&
5840
+ (0, types_1.isClassInstance)(objectType)) {
5841
+ resultType = types_1.ClassType.cloneAsInstantiable(objectType);
5850
5842
  }
5843
+ else {
5844
+ resultType = types_1.UnknownType.create();
5845
+ }
5846
+ return {
5847
+ type: resultIsInstance ? (0, typeUtils_1.convertToInstance)(resultType) : resultType,
5848
+ bindToSelfType: bindToType
5849
+ ? types_1.TypeBase.cloneForCondition((0, typeUtils_1.synthesizeTypeVarForSelfCls)(bindToType, /* isClsParam */ false), bindToType.condition)
5850
+ : undefined,
5851
+ };
5851
5852
  }
5852
- // If the lookup failed, try to return the first base class. An error
5853
- // will be reported by the member lookup logic at a later time.
5853
+ // Handle the super() call when used outside of a member access expression.
5854
5854
  if ((0, types_1.isInstantiableClass)(targetClassType)) {
5855
- // If the class derives from one or more unknown classes,
5856
- // return unknown here to prevent spurious errors.
5857
- if (targetClassType.details.mro.some((mroBase) => (0, types_1.isAnyOrUnknown)(mroBase))) {
5858
- return { type: types_1.UnknownType.create() };
5859
- }
5860
- const baseClasses = targetClassType.details.baseClasses;
5861
- if (baseClasses.length > 0) {
5862
- const baseClassType = baseClasses[0];
5863
- if ((0, types_1.isInstantiableClass)(baseClassType)) {
5855
+ // We don't know which member is going to be accessed, so we cannot
5856
+ // deterministically determine the correct type in this case. We'll
5857
+ // use a heuristic that produces the "correct" (desired) behavior in
5858
+ // most cases. If there's a bindToType and the targetClassType is one
5859
+ // of the base classes of the bindToType, we'll return the next base
5860
+ // class.
5861
+ if (bindToType) {
5862
+ let nextBaseClassType;
5863
+ if (types_1.ClassType.isSameGenericClass(bindToType, targetClassType)) {
5864
+ if (bindToType.details.baseClasses.length > 0) {
5865
+ nextBaseClassType = bindToType.details.baseClasses[0];
5866
+ }
5867
+ }
5868
+ else {
5869
+ const baseClassIndex = bindToType.details.baseClasses.findIndex((baseClass) => (0, types_1.isClass)(baseClass) && types_1.ClassType.isSameGenericClass(baseClass, targetClassType));
5870
+ if (baseClassIndex >= 0 && baseClassIndex < bindToType.details.baseClasses.length - 1) {
5871
+ nextBaseClassType = bindToType.details.baseClasses[baseClassIndex + 1];
5872
+ }
5873
+ }
5874
+ if (nextBaseClassType) {
5875
+ if ((0, types_1.isInstantiableClass)(nextBaseClassType)) {
5876
+ nextBaseClassType = (0, typeUtils_1.specializeForBaseClass)(bindToType, nextBaseClassType);
5877
+ }
5878
+ return { type: resultIsInstance ? (0, typeUtils_1.convertToInstance)(nextBaseClassType) : nextBaseClassType };
5879
+ }
5880
+ // There's not much we can say about the type. Simply return object or type.
5881
+ if (objectType && (0, types_1.isClassInstance)(objectType) && typeClassType && (0, types_1.isInstantiableClass)(typeClassType)) {
5864
5882
  return {
5865
- type: resultIsInstance ? types_1.ClassType.cloneAsInstance(baseClassType) : baseClassType,
5883
+ type: resultIsInstance ? objectType : (0, typeUtils_1.convertToInstance)(typeClassType),
5866
5884
  };
5867
5885
  }
5868
5886
  }
5887
+ else {
5888
+ // If the class derives from one or more unknown classes,
5889
+ // return unknown here to prevent spurious errors.
5890
+ if (targetClassType.details.mro.some((mroBase) => (0, types_1.isAnyOrUnknown)(mroBase))) {
5891
+ return { type: types_1.UnknownType.create() };
5892
+ }
5893
+ const baseClasses = targetClassType.details.baseClasses;
5894
+ if (baseClasses.length > 0) {
5895
+ const baseClassType = baseClasses[0];
5896
+ if ((0, types_1.isInstantiableClass)(baseClassType)) {
5897
+ return {
5898
+ type: resultIsInstance ? types_1.ClassType.cloneAsInstance(baseClassType) : baseClassType,
5899
+ };
5900
+ }
5901
+ }
5902
+ }
5869
5903
  }
5870
5904
  return { type: types_1.UnknownType.create() };
5871
5905
  }
@@ -6183,7 +6217,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
6183
6217
  const diagnostic = addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.noOverload().format({ name: functionName }), errorNode);
6184
6218
  const overrideDecl = bestMatch.overload.details.declaration;
6185
6219
  if (diagnostic && overrideDecl) {
6186
- diagnostic.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.overloadIndex().format({ index: bestMatch.overloadIndex + 1 }), overrideDecl.path, overrideDecl.range);
6220
+ diagnostic.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.overloadIndex().format({ index: bestMatch.overloadIndex + 1 }), overrideDecl.uri, overrideDecl.range);
6187
6221
  }
6188
6222
  }
6189
6223
  const effectiveTypeVarContext = typeVarContext !== null && typeVarContext !== void 0 ? typeVarContext : new typeVarContext_1.TypeVarContext();
@@ -6663,7 +6697,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
6663
6697
  newClassName = firstArgType.literalValue;
6664
6698
  }
6665
6699
  }
6666
- const newClassType = types_1.ClassType.createInstantiable(newClassName, '', '', AnalyzerNodeInfo.getFileInfo(errorNode).filePath, 0 /* ClassTypeFlags.None */, ParseTreeUtils.getTypeSourceId(errorNode), types_1.ClassType.cloneAsInstantiable(returnType), types_1.ClassType.cloneAsInstantiable(returnType));
6700
+ const newClassType = types_1.ClassType.createInstantiable(newClassName, '', '', AnalyzerNodeInfo.getFileInfo(errorNode).fileUri, 0 /* ClassTypeFlags.None */, ParseTreeUtils.getTypeSourceId(errorNode), types_1.ClassType.cloneAsInstantiable(returnType), types_1.ClassType.cloneAsInstantiable(returnType));
6667
6701
  newClassType.details.baseClasses.push(getBuiltInType(errorNode, 'object'));
6668
6702
  newClassType.details.effectiveMetaclass = expandedCallType;
6669
6703
  (0, typeUtils_1.computeMroLinearization)(newClassType);
@@ -6913,7 +6947,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
6913
6947
  tooManyPositionals = true;
6914
6948
  }
6915
6949
  if (tooManyPositionals) {
6916
- if (!isDiagnosticSuppressedForNode(errorNode)) {
6950
+ if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
6917
6951
  addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, positionParamLimitIndex === 1
6918
6952
  ? localize_1.Localizer.Diagnostic.argPositionalExpectedOne()
6919
6953
  : localize_1.Localizer.Diagnostic.argPositionalExpectedCount().format({
@@ -6946,7 +6980,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
6946
6980
  if ((0, types_1.isTypeVar)(argTypeResult.type) &&
6947
6981
  argTypeResult.type.paramSpecAccess === 'args' &&
6948
6982
  paramDetails.params[paramIndex].param.category !== 1 /* ParameterCategory.ArgsList */) {
6949
- if (!isDiagnosticSuppressedForNode(errorNode)) {
6983
+ if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
6950
6984
  addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, positionParamLimitIndex === 1
6951
6985
  ? localize_1.Localizer.Diagnostic.argPositionalExpectedOne()
6952
6986
  : localize_1.Localizer.Diagnostic.argPositionalExpectedCount().format({
@@ -7013,7 +7047,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7013
7047
  // It's not allowed to use unpacked arguments with a variadic *args
7014
7048
  // parameter unless the argument is a variadic arg as well.
7015
7049
  if (isParamVariadic && !isArgCompatibleWithVariadic) {
7016
- if (!isDiagnosticSuppressedForNode(errorNode)) {
7050
+ if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7017
7051
  addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.unpackedArgWithVariadicParam(), argList[argIndex].valueExpression || errorNode);
7018
7052
  }
7019
7053
  reportedArgError = true;
@@ -7070,7 +7104,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7070
7104
  : 0 /* ParameterCategory.Simple */;
7071
7105
  if (remainingArgCount <= remainingParamCount) {
7072
7106
  if (remainingArgCount < remainingParamCount) {
7073
- if (!isDiagnosticSuppressedForNode(errorNode)) {
7107
+ if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7074
7108
  // Have we run out of arguments and still have parameters left to fill?
7075
7109
  addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, remainingArgCount === 1
7076
7110
  ? localize_1.Localizer.Diagnostic.argMorePositionalExpectedOne()
@@ -7153,7 +7187,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7153
7187
  argsRemainingCount--;
7154
7188
  }
7155
7189
  if (argsRemainingCount > 0) {
7156
- if (!isDiagnosticSuppressedForNode(errorNode)) {
7190
+ if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7157
7191
  addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, argsRemainingCount === 1
7158
7192
  ? localize_1.Localizer.Diagnostic.argMorePositionalExpectedOne()
7159
7193
  : localize_1.Localizer.Diagnostic.argMorePositionalExpectedCount().format({
@@ -7235,7 +7269,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7235
7269
  }
7236
7270
  });
7237
7271
  if (!diag.isEmpty()) {
7238
- if (!isDiagnosticSuppressedForNode(errorNode)) {
7272
+ if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7239
7273
  addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.unpackedTypedDictArgument() + diag.getString(), argList[argIndex].valueExpression || errorNode);
7240
7274
  }
7241
7275
  reportedArgError = true;
@@ -7296,7 +7330,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7296
7330
  });
7297
7331
  }
7298
7332
  if (!isValidMappingType) {
7299
- if (!isDiagnosticSuppressedForNode(errorNode)) {
7333
+ if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7300
7334
  addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet
7301
7335
  .reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.unpackedDictArgumentNotMapping(), argList[argIndex].valueExpression || errorNode);
7302
7336
  }
@@ -7318,7 +7352,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7318
7352
  const paramEntry = paramMap.get(paramNameValue);
7319
7353
  if (paramEntry && !paramEntry.isPositionalOnly) {
7320
7354
  if (paramEntry.argsReceived > 0) {
7321
- addDiagnostic(AnalyzerNodeInfo.getFileInfo(paramName).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.paramAlreadyAssigned().format({ name: paramNameValue }), paramName);
7355
+ if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7356
+ addDiagnostic(AnalyzerNodeInfo.getFileInfo(paramName).diagnosticRuleSet
7357
+ .reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.paramAlreadyAssigned().format({ name: paramNameValue }), paramName);
7358
+ }
7322
7359
  reportedArgError = true;
7323
7360
  }
7324
7361
  else {
@@ -7360,7 +7397,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7360
7397
  trySetActive(argList[argIndex], paramDetails.params[paramDetails.kwargsIndex].param);
7361
7398
  }
7362
7399
  else {
7363
- addDiagnostic(AnalyzerNodeInfo.getFileInfo(paramName).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.paramNameMissing().format({ name: paramName.value }), paramName);
7400
+ if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7401
+ addDiagnostic(AnalyzerNodeInfo.getFileInfo(paramName).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.paramNameMissing().format({ name: paramName.value }), paramName);
7402
+ }
7364
7403
  reportedArgError = true;
7365
7404
  }
7366
7405
  }
@@ -7369,9 +7408,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7369
7408
  paramSpecArgList.push(argList[argIndex]);
7370
7409
  }
7371
7410
  else {
7372
- if (!isDiagnosticSuppressedForNode(errorNode)) {
7373
- const fileInfo = AnalyzerNodeInfo.getFileInfo(errorNode);
7374
- addDiagnostic(fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, positionParamLimitIndex === 1
7411
+ if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7412
+ addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, positionParamLimitIndex === 1
7375
7413
  ? localize_1.Localizer.Diagnostic.argPositionalExpectedOne()
7376
7414
  : localize_1.Localizer.Diagnostic.argPositionalExpectedCount().format({
7377
7415
  expected: positionParamLimitIndex,
@@ -7447,9 +7485,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7447
7485
  if (unassignedParams.length > 0) {
7448
7486
  if (!isDiagnosticSuppressedForNode(errorNode)) {
7449
7487
  const missingParamNames = unassignedParams.map((p) => `"${p}"`).join(', ');
7450
- addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, unassignedParams.length === 1
7451
- ? localize_1.Localizer.Diagnostic.argMissingForParam().format({ name: missingParamNames })
7452
- : localize_1.Localizer.Diagnostic.argMissingForParams().format({ names: missingParamNames }), errorNode);
7488
+ if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7489
+ addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, unassignedParams.length === 1
7490
+ ? localize_1.Localizer.Diagnostic.argMissingForParam().format({ name: missingParamNames })
7491
+ : localize_1.Localizer.Diagnostic.argMissingForParams().format({ names: missingParamNames }), errorNode);
7492
+ }
7453
7493
  }
7454
7494
  reportedArgError = true;
7455
7495
  }
@@ -7515,14 +7555,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7515
7555
  if (containsVariadicTypeVar &&
7516
7556
  argParam.argument.argumentCategory !== 1 /* ArgumentCategory.UnpackedList */ &&
7517
7557
  !argParam.mapsToVarArgList) {
7518
- if (!isDiagnosticSuppressedForNode(errorNode)) {
7558
+ if (!isDiagnosticSuppressedForNode(errorNode) && !isTypeIncomplete) {
7519
7559
  addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet
7520
7560
  .reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.typeVarTupleMustBeUnpacked(), (_a = argParam.argument.valueExpression) !== null && _a !== void 0 ? _a : errorNode);
7521
7561
  }
7522
7562
  reportedArgError = true;
7523
7563
  }
7524
7564
  return {
7525
- type: stripLiteralValue(argType),
7565
+ type: argType,
7526
7566
  isUnbounded: argParam.argument.argumentCategory === 1 /* ArgumentCategory.UnpackedList */,
7527
7567
  };
7528
7568
  });
@@ -7605,7 +7645,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7605
7645
  }
7606
7646
  const effectiveReturnType = getFunctionEffectiveReturnType(type);
7607
7647
  let effectiveExpectedType = inferenceContext.expectedType;
7608
- let effectiveFlags = 0 /* AssignTypeFlags.Default */;
7648
+ let effectiveFlags = 1024 /* AssignTypeFlags.PopulatingExpectedType */;
7609
7649
  if ((0, typeUtils_1.containsLiteralType)(effectiveExpectedType, /* includeTypeArgs */ true)) {
7610
7650
  effectiveFlags |= 128 /* AssignTypeFlags.RetainLiteralsForTypeVar */;
7611
7651
  }
@@ -7617,7 +7657,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7617
7657
  const typeVarContextCopy = typeVarContext.clone();
7618
7658
  assignType(effectiveReturnType, effectiveExpectedType,
7619
7659
  /* diag */ undefined, typeVarContextCopy,
7620
- /* srcTypeVarContext */ undefined, effectiveFlags | 1024 /* AssignTypeFlags.PopulatingExpectedType */);
7660
+ /* srcTypeVarContext */ undefined, effectiveFlags);
7621
7661
  const speculativeResults = validateFunctionArgumentTypes(errorNode, matchResults, typeVarContextCopy, signatureTracker, skipUnknownArgCheck);
7622
7662
  if (speculativeResults === null || speculativeResults === void 0 ? void 0 : speculativeResults.argumentErrors) {
7623
7663
  effectiveExpectedType = undefined;
@@ -7663,6 +7703,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7663
7703
  effectiveExpectedType = (0, typeUtils_1.applySolvedTypeVars)(genericReturnType, tempTypeVarContext, {
7664
7704
  unknownIfNotFound: true,
7665
7705
  });
7706
+ effectiveFlags |= 2048 /* AssignTypeFlags.SkipPopulateUnknownExpectedType */;
7666
7707
  }
7667
7708
  }
7668
7709
  }
@@ -7678,7 +7719,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7678
7719
  effectiveExpectedType = (0, typeUtils_1.transformExpectedType)(effectiveExpectedType, liveTypeVarScopes, errorNode.start);
7679
7720
  assignType(effectiveReturnType, effectiveExpectedType,
7680
7721
  /* diag */ undefined, typeVarContext,
7681
- /* srcTypeVarContext */ undefined, effectiveFlags | 1024 /* AssignTypeFlags.PopulatingExpectedType */);
7722
+ /* srcTypeVarContext */ undefined, effectiveFlags);
7682
7723
  }
7683
7724
  return validateFunctionArgumentTypes(errorNode, matchResults, typeVarContext, signatureTracker, skipUnknownArgCheck);
7684
7725
  }
@@ -8179,7 +8220,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8179
8220
  8 /* EvaluatorFlags.EvaluateStringLiteralAsType */ |
8180
8221
  32 /* EvaluatorFlags.DisallowParamSpec */ |
8181
8222
  64 /* EvaluatorFlags.DisallowTypeVarTuple */ |
8182
- 16777216 /* EvaluatorFlags.DisallowPep695TypeAlias */
8223
+ 16777216 /* EvaluatorFlags.TreatPep695TypeAliasAsObject */
8183
8224
  : 2 /* EvaluatorFlags.DoNotSpecialize */;
8184
8225
  const exprTypeResult = getTypeOfExpression(argParam.argument.valueExpression, flags, (0, typeUtils_1.makeInferenceContext)(expectedType, !!(typeResult === null || typeResult === void 0 ? void 0 : typeResult.isIncomplete), signatureTracker));
8185
8226
  argType = exprTypeResult.type;
@@ -8377,21 +8418,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8377
8418
  const diagAddendum = getDiagAddendum();
8378
8419
  addDiagnostic(fileInfo.diagnosticRuleSet.reportUnknownArgumentType, diagnosticRules_1.DiagnosticRule.reportUnknownArgumentType, localize_1.Localizer.Diagnostic.argTypeUnknown() + diagAddendum.getString(), argParam.errorNode);
8379
8420
  }
8380
- else if ((0, typeUtils_1.isPartlyUnknown)(simplifiedType, /* allowUnknownTypeArgsForClasses */ true)) {
8381
- let suppressPartialUnknown = false;
8382
- // Don't report an error if the type is a partially-specialized
8383
- // class. This comes up frequently in cases where a type is passed
8384
- // as an argument (e.g. "defaultdict(list)").
8385
- if ((0, types_1.isInstantiableClass)(simplifiedType)) {
8386
- suppressPartialUnknown = true;
8387
- }
8421
+ else if ((0, typeUtils_1.isPartlyUnknown)(simplifiedType)) {
8388
8422
  // If the parameter type is also partially unknown, don't report
8389
8423
  // the error because it's likely that the partially-unknown type
8390
8424
  // arose due to bidirectional type matching.
8391
- if ((0, typeUtils_1.isPartlyUnknown)(argParam.paramType)) {
8392
- suppressPartialUnknown = true;
8393
- }
8394
- if (!suppressPartialUnknown) {
8425
+ if (!(0, typeUtils_1.isPartlyUnknown)(argParam.paramType)) {
8395
8426
  const diagAddendum = getDiagAddendum();
8396
8427
  diagAddendum.addMessage(localize_1.Localizer.DiagnosticAddendum.argumentType().format({
8397
8428
  type: printType(simplifiedType, { expandTypeAlias: true }),
@@ -8755,7 +8786,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8755
8786
  }
8756
8787
  return getTypeOfTypeAliasCommon(nameNode, nameNode, valueExpr,
8757
8788
  /* isPep695Syntax */ false,
8758
- /* typeParamNodes */ undefined, () => typeParameters !== null && typeParameters !== void 0 ? typeParameters : []);
8789
+ /* typeParamNodes */ undefined, () => typeParameters);
8759
8790
  }
8760
8791
  function getBooleanValue(node) {
8761
8792
  if (node.nodeType === 11 /* ParseNodeType.Constant */) {
@@ -8823,7 +8854,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8823
8854
  }
8824
8855
  let classFlags = baseClass.details.flags & ~(1 /* ClassTypeFlags.BuiltInClass */ | 2 /* ClassTypeFlags.SpecialBuiltIn */);
8825
8856
  classFlags |= 4096 /* ClassTypeFlags.Final */;
8826
- const classType = types_1.ClassType.createInstantiable(className, ParseTreeUtils.getClassFullName(errorNode, fileInfo.moduleName, className), fileInfo.moduleName, fileInfo.filePath, classFlags, ParseTreeUtils.getTypeSourceId(errorNode),
8857
+ const classType = types_1.ClassType.createInstantiable(className, ParseTreeUtils.getClassFullName(errorNode, fileInfo.moduleName, className), fileInfo.moduleName, fileInfo.fileUri, classFlags, ParseTreeUtils.getTypeSourceId(errorNode),
8827
8858
  /* declaredMetaclass */ undefined, baseClass.details.effectiveMetaclass);
8828
8859
  classType.details.baseClasses.push(isBaseClassAny ? types_1.AnyType.create() : baseClass);
8829
8860
  (0, typeUtils_1.computeMroLinearization)(classType);
@@ -8870,7 +8901,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8870
8901
  if (!(0, types_1.isClassInstance)(arg1Type) || !(0, typeUtils_1.isTupleClass)(arg1Type) || arg1Type.tupleTypeArguments === undefined) {
8871
8902
  return undefined;
8872
8903
  }
8873
- const classType = types_1.ClassType.createInstantiable(className, ParseTreeUtils.getClassFullName(errorNode, fileInfo.moduleName, className), fileInfo.moduleName, fileInfo.filePath, 0 /* ClassTypeFlags.None */, ParseTreeUtils.getTypeSourceId(errorNode),
8904
+ const classType = types_1.ClassType.createInstantiable(className, ParseTreeUtils.getClassFullName(errorNode, fileInfo.moduleName, className), fileInfo.moduleName, fileInfo.fileUri, 0 /* ClassTypeFlags.None */, ParseTreeUtils.getTypeSourceId(errorNode),
8874
8905
  /* declaredMetaclass */ undefined, arg1Type.details.effectiveMetaclass);
8875
8906
  arg1Type.tupleTypeArguments.forEach((typeArg) => {
8876
8907
  const specializedType = makeTopLevelTypeVarsConcrete(typeArg.type);
@@ -9655,6 +9686,11 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
9655
9686
  paramType = getTypeOfExpression(param.defaultValue, undefined, inferenceContext).type;
9656
9687
  }
9657
9688
  }
9689
+ else if (param.defaultValue) {
9690
+ // If there is no inference context but we have a default value,
9691
+ // use the default value to infer the parameter's type.
9692
+ paramType = inferParameterTypeFromDefaultValue(param.defaultValue);
9693
+ }
9658
9694
  if (param.name) {
9659
9695
  writeTypeCache(param.name, { type: transformVariadicParamType(node, param.category, paramType !== null && paramType !== void 0 ? paramType : types_1.UnknownType.create()) }, 0 /* EvaluatorFlags.None */);
9660
9696
  }
@@ -10266,7 +10302,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
10266
10302
  });
10267
10303
  return types_1.ClassType.cloneForSpecialization(classType, convertedTypeArgs, /* isTypeArgumentExplicit */ true);
10268
10304
  }
10269
- function createSelfType(classType, errorNode, typeArgs) {
10305
+ function createSelfType(classType, errorNode, typeArgs, flags) {
10270
10306
  var _a;
10271
10307
  const fileInfo = AnalyzerNodeInfo.getFileInfo(errorNode);
10272
10308
  // Self doesn't support any type arguments.
@@ -10278,7 +10314,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
10278
10314
  const enclosingClass = ParseTreeUtils.getEnclosingClass(errorNode);
10279
10315
  const enclosingClassTypeResult = enclosingClass ? getTypeOfClass(enclosingClass) : undefined;
10280
10316
  if (!enclosingClassTypeResult) {
10281
- addDiagnostic(fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.selfTypeContext(), errorNode);
10317
+ if ((flags & 256 /* EvaluatorFlags.ExpectingTypeAnnotation */) !== 0) {
10318
+ addDiagnostic(fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.selfTypeContext(), errorNode);
10319
+ }
10282
10320
  return types_1.UnknownType.create();
10283
10321
  }
10284
10322
  const enclosingFunction = ParseTreeUtils.getEnclosingFunction(errorNode);
@@ -10653,7 +10691,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
10653
10691
  }
10654
10692
  return createSpecialType(classType, typeArgs, /* paramLimit */ undefined, /* allowParamSpec */ true);
10655
10693
  }
10656
- function transformTypeForTypeAlias(type, name, errorNode, isPep695Syntax, typeParameters, typeParamNodes) {
10694
+ function transformTypeForTypeAlias(type, name, errorNode, isPep695Syntax, isPep695TypeVarType, typeParameters, typeParamNodes) {
10657
10695
  if (!types_1.TypeBase.isInstantiable(type)) {
10658
10696
  return type;
10659
10697
  }
@@ -10698,24 +10736,26 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
10698
10736
  names: variadics.map((v) => `"${v.details.name}"`).join(', '),
10699
10737
  }), errorNode);
10700
10738
  }
10701
- const fileInfo = AnalyzerNodeInfo.getFileInfo(name);
10702
- const boundTypeVars = typeParameters.filter((typeVar) => typeVar.scopeId !== typeAliasScopeId && typeVar.scopeType === 0 /* TypeVarScopeType.Class */);
10703
- if (boundTypeVars.length > 0) {
10704
- addError(localize_1.Localizer.Diagnostic.genericTypeAliasBoundTypeVar().format({
10705
- names: boundTypeVars.map((t) => `${t.details.name}`).join(', '),
10706
- }), errorNode);
10739
+ if (!isPep695Syntax && !isPep695TypeVarType) {
10740
+ const boundTypeVars = typeParameters.filter((typeVar) => typeVar.scopeId !== typeAliasScopeId && typeVar.scopeType === 0 /* TypeVarScopeType.Class */);
10741
+ if (boundTypeVars.length > 0) {
10742
+ addError(localize_1.Localizer.Diagnostic.genericTypeAliasBoundTypeVar().format({
10743
+ names: boundTypeVars.map((t) => `${t.details.name}`).join(', '),
10744
+ }), errorNode);
10745
+ }
10707
10746
  }
10747
+ const fileInfo = AnalyzerNodeInfo.getFileInfo(name);
10708
10748
  const typeAlias = types_1.TypeBase.cloneForTypeAlias(type, name.value, ParseTreeUtils.getClassFullName(name, fileInfo.moduleName, name.value), typeAliasScopeId, isPep695Syntax, typeParameters.length > 0 ? typeParameters : undefined);
10709
10749
  // All PEP 695 type aliases are special forms because they are
10710
10750
  // TypeAliasType objects at runtime.
10711
- if (isPep695Syntax) {
10751
+ if (isPep695Syntax || isPep695TypeVarType) {
10712
10752
  typeAlias.flags |= 8 /* TypeFlags.SpecialForm */;
10713
10753
  }
10714
10754
  return typeAlias;
10715
10755
  }
10716
10756
  function createSpecialBuiltInClass(node, assignedName, aliasMapEntry) {
10717
10757
  const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
10718
- let specialClassType = types_1.ClassType.createInstantiable(assignedName, ParseTreeUtils.getClassFullName(node, fileInfo.moduleName, assignedName), fileInfo.moduleName, fileInfo.filePath, 1 /* ClassTypeFlags.BuiltInClass */ | 2 /* ClassTypeFlags.SpecialBuiltIn */,
10758
+ let specialClassType = types_1.ClassType.createInstantiable(assignedName, ParseTreeUtils.getClassFullName(node, fileInfo.moduleName, assignedName), fileInfo.moduleName, fileInfo.fileUri, 1 /* ClassTypeFlags.BuiltInClass */ | 2 /* ClassTypeFlags.SpecialBuiltIn */,
10719
10759
  /* typeSourceId */ 0,
10720
10760
  /* declaredMetaclass */ undefined,
10721
10761
  /* effectiveMetaclass */ undefined);
@@ -10964,7 +11004,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
10964
11004
  if (!isSpeculativeTypeAlias || isLegalImplicitTypeAliasType(rightHandType)) {
10965
11005
  // If this is a type alias, record its name based on the assignment target.
10966
11006
  rightHandType = transformTypeForTypeAlias(rightHandType, typeAliasNameNode, node.rightExpression,
10967
- /* isPep695Syntax */ false);
11007
+ /* isPep695Syntax */ false,
11008
+ /* isPep695TypeVarType */ false);
10968
11009
  (0, debug_1.assert)(typeAliasTypeVar !== undefined);
10969
11010
  if ((0, typeUtils_1.isTypeAliasRecursive)(typeAliasTypeVar, rightHandType)) {
10970
11011
  addDiagnostic(fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.typeAliasIsRecursiveDirect().format({
@@ -11021,11 +11062,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11021
11062
  var _a;
11022
11063
  return getTypeOfTypeAliasCommon(node, node.name, node.expression,
11023
11064
  /* isPep695Syntax */ true, (_a = node.typeParameters) === null || _a === void 0 ? void 0 : _a.parameters, () => {
11024
- let typeParameters = [];
11025
11065
  if (node.typeParameters) {
11026
- typeParameters = evaluateTypeParameterList(node.typeParameters);
11066
+ return evaluateTypeParameterList(node.typeParameters);
11027
11067
  }
11028
- return typeParameters;
11068
+ return undefined;
11029
11069
  });
11030
11070
  }
11031
11071
  // This function is common to the handling of "type" statements and explicit
@@ -11064,7 +11104,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11064
11104
  if (aliasTypeResult.isIncomplete) {
11065
11105
  isIncomplete = true;
11066
11106
  }
11067
- aliasType = transformTypeForTypeAlias(aliasType, nameNode, valueNode, isPep695Syntax, typeParameters, typeParamNodes);
11107
+ aliasType = transformTypeForTypeAlias(aliasType, nameNode, valueNode, isPep695Syntax,
11108
+ /* isPep695TypeVarType */ true, typeParameters, typeParamNodes);
11068
11109
  if ((0, typeUtils_1.isTypeAliasRecursive)(typeAliasTypeVar, aliasType)) {
11069
11110
  addDiagnostic(AnalyzerNodeInfo.getFileInfo(valueNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.typeAliasIsRecursiveDirect().format({
11070
11111
  name: nameNode.value,
@@ -11125,7 +11166,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11125
11166
  if (fileInfo.isStubFile) {
11126
11167
  classFlags |= 8388608 /* ClassTypeFlags.DefinedInStub */;
11127
11168
  }
11128
- const classType = types_1.ClassType.createInstantiable(node.name.value, ParseTreeUtils.getClassFullName(node, fileInfo.moduleName, node.name.value), fileInfo.moduleName, fileInfo.filePath, classFlags,
11169
+ const classType = types_1.ClassType.createInstantiable(node.name.value, ParseTreeUtils.getClassFullName(node, fileInfo.moduleName, node.name.value), fileInfo.moduleName, fileInfo.fileUri, classFlags,
11129
11170
  /* typeSourceId */ 0,
11130
11171
  /* declaredMetaclass */ undefined,
11131
11172
  /* effectiveMetaclass */ undefined, ParseTreeUtils.getDocString(node.suite.statements));
@@ -11168,7 +11209,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11168
11209
  2048 /* EvaluatorFlags.DisallowTypeVarsWithScopeId */ |
11169
11210
  8192 /* EvaluatorFlags.AssociateTypeVarsWithCurrentScope */ |
11170
11211
  16384 /* EvaluatorFlags.EnforceTypeVarVarianceConsistency */ |
11171
- 16777216 /* EvaluatorFlags.DisallowPep695TypeAlias */;
11212
+ 16777216 /* EvaluatorFlags.TreatPep695TypeAliasAsObject */;
11172
11213
  if (fileInfo.isStubFile) {
11173
11214
  exprFlags |= 4 /* EvaluatorFlags.AllowForwardReferences */;
11174
11215
  }
@@ -11271,10 +11312,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11271
11312
  classType.details.flags |= 1048576 /* ClassTypeFlags.EnumClass */;
11272
11313
  }
11273
11314
  // Determine if the class is abstract. Protocol classes support abstract methods
11274
- // even though they don't derive from the ABCMeta class. We'll exclude built-in
11275
- // protocol classes because these are known not to contain any abstract methods
11276
- // and getAbstractMethods causes problems because of dependencies on some of these
11277
- // built-in protocol classes.
11315
+ // because they are constructed by the _ProtocolMeta metaclass, which derives
11316
+ // from ABCMeta. We'll exclude built-in protocol classes because these are known
11317
+ // not to contain any abstract methods and getAbstractMethods causes problems
11318
+ // because of dependencies on some of these built-in protocol classes.
11278
11319
  if (types_1.ClassType.supportsAbstractMethods(argType) ||
11279
11320
  (types_1.ClassType.isProtocolClass(argType) && !types_1.ClassType.isBuiltIn(argType))) {
11280
11321
  classType.details.flags |= 1024 /* ClassTypeFlags.SupportsAbstractMethods */;
@@ -11666,7 +11707,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11666
11707
  // Replace all of the type parameters with invariant TypeVars.
11667
11708
  const updatedTypeParams = classType.details.typeParameters.map((typeParam) => types_1.TypeVarType.cloneAsInvariant(typeParam));
11668
11709
  const updatedClassType = types_1.ClassType.cloneWithNewTypeParameters(classType, updatedTypeParams);
11669
- const dummyTypeObject = types_1.ClassType.createInstantiable('__varianceDummy', '', '', '', 0, 0, undefined, undefined);
11710
+ const dummyTypeObject = types_1.ClassType.createInstantiable('__varianceDummy', '', '', uri_1.Uri.empty(), 0, 0, undefined, undefined);
11670
11711
  updatedTypeParams.forEach((param, paramIndex) => {
11671
11712
  // Skip variadics and ParamSpecs.
11672
11713
  if (param.details.isVariadic || param.details.isParamSpec) {
@@ -11949,7 +11990,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11949
11990
  if (diag && initSubclassDecl) {
11950
11991
  diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.initSubclassLocation().format({
11951
11992
  name: printType((0, typeUtils_1.convertToInstance)(initSubclassMethodInfo.classType)),
11952
- }), initSubclassDecl.path, initSubclassDecl.range);
11993
+ }), initSubclassDecl.uri, initSubclassDecl.range);
11953
11994
  }
11954
11995
  }
11955
11996
  }
@@ -11972,6 +12013,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11972
12013
  // function declaration falls within an unreachable code block.
11973
12014
  return undefined;
11974
12015
  }
12016
+ if (types_1.FunctionType.isPartiallyEvaluated(functionType)) {
12017
+ return { functionType, decoratedType: functionType };
12018
+ }
11975
12019
  }
11976
12020
  else {
11977
12021
  functionType = getTypeOfFunctionPredecorated(node);
@@ -12128,7 +12172,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
12128
12172
  node.parameters.forEach((param, index) => {
12129
12173
  let paramType;
12130
12174
  let annotatedType;
12131
- let isNoneWithoutOptional = false;
12132
12175
  let paramTypeNode;
12133
12176
  if (param.name) {
12134
12177
  if (index === 0 && isFirstParamClsOrSelf) {
@@ -12176,7 +12219,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
12176
12219
  const adjustedAnnotatedType = adjustParameterAnnotatedType(param, annotatedType);
12177
12220
  if (adjustedAnnotatedType !== annotatedType) {
12178
12221
  annotatedType = adjustedAnnotatedType;
12179
- isNoneWithoutOptional = true;
12180
12222
  }
12181
12223
  }
12182
12224
  let defaultValueType;
@@ -12205,17 +12247,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
12205
12247
  }
12206
12248
  }
12207
12249
  if (!assignType(annotatedType, defaultValueType, diagAddendum, typeVarContext)) {
12208
- const diag = addDiagnostic(fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.paramAssignmentMismatch().format({
12250
+ addDiagnostic(fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.paramAssignmentMismatch().format({
12209
12251
  sourceType: printType(defaultValueType),
12210
12252
  paramType: printType(annotatedType),
12211
12253
  }) + diagAddendum.getString(), param.defaultValue);
12212
- if (isNoneWithoutOptional && paramTypeNode) {
12213
- const addOptionalAction = {
12214
- action: "pyright.addoptionalforparam" /* Commands.addMissingOptionalToParam */,
12215
- offsetOfTypeNode: paramTypeNode.start + 1,
12216
- };
12217
- diag === null || diag === void 0 ? void 0 : diag.addAction(addOptionalAction);
12218
- }
12219
12254
  }
12220
12255
  }
12221
12256
  paramType = annotatedType;
@@ -12474,43 +12509,46 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
12474
12509
  // type from this information.
12475
12510
  const paramValueExpr = functionNode.parameters[paramIndex].defaultValue;
12476
12511
  if (paramValueExpr) {
12477
- const defaultValueType = getTypeOfExpression(paramValueExpr, 1 /* EvaluatorFlags.ConvertEllipsisToAny */).type;
12478
- let inferredParamType;
12479
- // Is the default value a "None" or an instance of some private class (one
12480
- // whose name starts with an underscore)? If so, we will assume that the
12481
- // value is a singleton sentinel. The actual supported type is going to be
12482
- // a union of this type and Unknown.
12483
- if ((0, typeUtils_1.isNoneInstance)(defaultValueType) ||
12484
- ((0, types_1.isClassInstance)(defaultValueType) && (0, symbolNameUtils_1.isPrivateOrProtectedName)(defaultValueType.details.name))) {
12485
- inferredParamType = (0, types_1.combineTypes)([defaultValueType, types_1.UnknownType.create()]);
12512
+ return inferParameterTypeFromDefaultValue(paramValueExpr);
12513
+ }
12514
+ return undefined;
12515
+ }
12516
+ function inferParameterTypeFromDefaultValue(paramValueExpr) {
12517
+ const defaultValueType = getTypeOfExpression(paramValueExpr, 1 /* EvaluatorFlags.ConvertEllipsisToAny */).type;
12518
+ let inferredParamType;
12519
+ // Is the default value a "None" or an instance of some private class (one
12520
+ // whose name starts with an underscore)? If so, we will assume that the
12521
+ // value is a singleton sentinel. The actual supported type is going to be
12522
+ // a union of this type and Unknown.
12523
+ if ((0, typeUtils_1.isNoneInstance)(defaultValueType) ||
12524
+ ((0, types_1.isClassInstance)(defaultValueType) && (0, symbolNameUtils_1.isPrivateOrProtectedName)(defaultValueType.details.name))) {
12525
+ inferredParamType = (0, types_1.combineTypes)([defaultValueType, types_1.UnknownType.create()]);
12526
+ }
12527
+ else {
12528
+ let skipInference = false;
12529
+ if ((0, types_1.isFunction)(defaultValueType) || (0, types_1.isOverloadedFunction)(defaultValueType)) {
12530
+ // Do not infer parameter types that use a lambda or another function as a
12531
+ // default value. We're likely to generate false positives in this case.
12532
+ // It's not clear whether parameters should be positional-only or not.
12533
+ skipInference = true;
12486
12534
  }
12487
- else {
12488
- let skipInference = false;
12489
- if ((0, types_1.isFunction)(defaultValueType) || (0, types_1.isOverloadedFunction)(defaultValueType)) {
12490
- // Do not infer parameter types that use a lambda or another function as a
12491
- // default value. We're likely to generate false positives in this case.
12492
- // It's not clear whether parameters should be positional-only or not.
12493
- skipInference = true;
12494
- }
12495
- else if ((0, types_1.isClassInstance)(defaultValueType) &&
12496
- types_1.ClassType.isBuiltIn(defaultValueType, ['tuple', 'list', 'set', 'dict'])) {
12497
- // Do not infer certain types like tuple because it's likely to be
12498
- // more restrictive (narrower) than intended.
12499
- skipInference = true;
12500
- }
12501
- if (!skipInference) {
12502
- inferredParamType = stripLiteralValue(defaultValueType);
12503
- }
12535
+ else if ((0, types_1.isClassInstance)(defaultValueType) &&
12536
+ types_1.ClassType.isBuiltIn(defaultValueType, ['tuple', 'list', 'set', 'dict'])) {
12537
+ // Do not infer certain types like tuple because it's likely to be
12538
+ // more restrictive (narrower) than intended.
12539
+ skipInference = true;
12504
12540
  }
12505
- if (inferredParamType) {
12506
- const fileInfo = AnalyzerNodeInfo.getFileInfo(functionNode);
12507
- if (fileInfo.isInPyTypedPackage && !fileInfo.isStubFile) {
12508
- inferredParamType = types_1.TypeBase.cloneForAmbiguousType(inferredParamType);
12509
- }
12541
+ if (!skipInference) {
12542
+ inferredParamType = stripLiteralValue(defaultValueType);
12510
12543
  }
12511
- return inferredParamType;
12512
12544
  }
12513
- return undefined;
12545
+ if (inferredParamType) {
12546
+ const fileInfo = AnalyzerNodeInfo.getFileInfo(paramValueExpr);
12547
+ if (fileInfo.isInPyTypedPackage && !fileInfo.isStubFile) {
12548
+ inferredParamType = types_1.TypeBase.cloneForAmbiguousType(inferredParamType);
12549
+ }
12550
+ }
12551
+ return inferredParamType;
12514
12552
  }
12515
12553
  // Transforms the parameter type based on its category. If it's a simple parameter,
12516
12554
  // no transform is applied. If it's a var-arg or keyword-arg parameter, the type
@@ -12565,7 +12603,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
12565
12603
  }
12566
12604
  return awaitableFunctionType;
12567
12605
  }
12568
- function createAwaitableReturnType(node, returnType, isGenerator) {
12606
+ function createAwaitableReturnType(node, returnType, isGenerator, useCoroutine = true) {
12569
12607
  let awaitableReturnType;
12570
12608
  if ((0, types_1.isClassInstance)(returnType)) {
12571
12609
  if (types_1.ClassType.isBuiltIn(returnType)) {
@@ -12593,10 +12631,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
12593
12631
  }
12594
12632
  }
12595
12633
  if (!awaitableReturnType || !isGenerator) {
12596
- // Wrap in a Coroutine, which is a subclass of Awaitable.
12597
- const coroutineType = getTypingType(node, 'Coroutine');
12598
- if (coroutineType && (0, types_1.isInstantiableClass)(coroutineType)) {
12599
- awaitableReturnType = types_1.ClassType.cloneAsInstance(types_1.ClassType.cloneForSpecialization(coroutineType, [types_1.AnyType.create(), types_1.AnyType.create(), returnType],
12634
+ // Wrap in either an Awaitable or a Coroutine, which is a subclass of Awaitable.
12635
+ const awaitableType = getTypingType(node, useCoroutine ? 'Coroutine' : 'Awaitable');
12636
+ if (awaitableType && (0, types_1.isInstantiableClass)(awaitableType)) {
12637
+ awaitableReturnType = types_1.ClassType.cloneAsInstance(types_1.ClassType.cloneForSpecialization(awaitableType, useCoroutine ? [types_1.AnyType.create(), types_1.AnyType.create(), returnType] : [returnType],
12600
12638
  /* isTypeArgumentExplicit */ true));
12601
12639
  }
12602
12640
  else {
@@ -12981,7 +13019,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
12981
13019
  (0, debug_1.assert)(!parentNode.isWildcardImport);
12982
13020
  const importInfo = AnalyzerNodeInfo.getImportInfo(parentNode.module);
12983
13021
  if (importInfo && importInfo.isImportFound && !importInfo.isNativeLib) {
12984
- const resolvedPath = importInfo.resolvedPaths[importInfo.resolvedPaths.length - 1];
13022
+ const resolvedPath = importInfo.resolvedUris[importInfo.resolvedUris.length - 1];
12985
13023
  const importLookupInfo = importLookup(resolvedPath);
12986
13024
  let reportError = false;
12987
13025
  // If we were able to resolve the import, report the error as
@@ -13001,7 +13039,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
13001
13039
  }
13002
13040
  }
13003
13041
  }
13004
- else if (!resolvedPath) {
13042
+ else if (resolvedPath.isEmpty()) {
13005
13043
  // This corresponds to the "from . import a" form.
13006
13044
  reportError = true;
13007
13045
  }
@@ -13765,7 +13803,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
13765
13803
  break;
13766
13804
  }
13767
13805
  case 'Self': {
13768
- return { type: createSelfType(classType, errorNode, typeArgs) };
13806
+ return { type: createSelfType(classType, errorNode, typeArgs, flags) };
13769
13807
  }
13770
13808
  case 'LiteralString': {
13771
13809
  return { type: createSpecialType(classType, typeArgs, 0) };
@@ -14404,13 +14442,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
14404
14442
  if (namePartIndex >= 0 &&
14405
14443
  importInfo &&
14406
14444
  !importInfo.isNativeLib &&
14407
- namePartIndex < importInfo.resolvedPaths.length) {
14408
- if (importInfo.resolvedPaths[namePartIndex]) {
14445
+ namePartIndex < importInfo.resolvedUris.length) {
14446
+ if (importInfo.resolvedUris[namePartIndex]) {
14409
14447
  evaluateTypesForStatement(node);
14410
14448
  // Synthesize an alias declaration for this name part. The only
14411
14449
  // time this case is used is for IDE services such as
14412
14450
  // the find all references, hover provider and etc.
14413
- declarations.push((0, declarationUtils_1.createSynthesizedAliasDeclaration)(importInfo.resolvedPaths[namePartIndex]));
14451
+ declarations.push((0, declarationUtils_1.createSynthesizedAliasDeclaration)(importInfo.resolvedUris[namePartIndex]));
14414
14452
  }
14415
14453
  }
14416
14454
  }
@@ -14723,8 +14761,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
14723
14761
  return evaluatorOptions.evaluateUnknownImportsAsAny ? types_1.AnyType.create() : types_1.UnknownType.create();
14724
14762
  }
14725
14763
  function applyLoaderActionsToModuleType(moduleType, loaderActions, importLookup) {
14726
- if (loaderActions.path && loaderActions.loadSymbolsFromPath) {
14727
- const lookupResults = importLookup(loaderActions.path);
14764
+ if (!loaderActions.uri.isEmpty() && loaderActions.loadSymbolsFromPath) {
14765
+ const lookupResults = importLookup(loaderActions.uri);
14728
14766
  if (lookupResults) {
14729
14767
  moduleType.fields = lookupResults.symbolTable;
14730
14768
  moduleType.docString = lookupResults.docString;
@@ -14747,7 +14785,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
14747
14785
  }
14748
14786
  else {
14749
14787
  const moduleName = moduleType.moduleName ? moduleType.moduleName + '.' + name : '';
14750
- const importedModuleType = types_1.ModuleType.create(moduleName, implicitImport.path);
14788
+ const importedModuleType = types_1.ModuleType.create(moduleName, implicitImport.uri);
14751
14789
  symbolType = applyLoaderActionsToModuleType(importedModuleType, implicitImport, importLookup);
14752
14790
  }
14753
14791
  const importedModuleSymbol = symbol_1.Symbol.createWithType(0 /* SymbolFlags.None */, symbolType);
@@ -14762,7 +14800,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
14762
14800
  if (resolvedDecl.type === 8 /* DeclarationType.Alias */) {
14763
14801
  // Build a module type that corresponds to the declaration and
14764
14802
  // its associated loader actions.
14765
- const moduleType = types_1.ModuleType.create(resolvedDecl.moduleName, resolvedDecl.path);
14803
+ const moduleType = types_1.ModuleType.create(resolvedDecl.moduleName, resolvedDecl.uri);
14766
14804
  if (resolvedDecl.symbolName && resolvedDecl.submoduleFallback) {
14767
14805
  return applyLoaderActionsToModuleType(moduleType, resolvedDecl.submoduleFallback, importLookup);
14768
14806
  }
@@ -14856,7 +14894,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
14856
14894
  // (but not an ellipsis).
14857
14895
  if (isLegalImplicitTypeAliasType(inferredType)) {
14858
14896
  inferredType = transformTypeForTypeAlias(inferredType, resolvedDecl.typeAliasName, resolvedDecl.node,
14859
- /* isPep695Syntax */ false);
14897
+ /* isPep695Syntax */ false,
14898
+ /* isPep695TypeVarType */ false);
14860
14899
  isUnambiguousType = true;
14861
14900
  }
14862
14901
  }
@@ -15760,11 +15799,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15760
15799
  // the length of the src type arguments list if the dest or source contain
15761
15800
  // entries with indeterminate length or variadic entries. It returns true
15762
15801
  // if the source is potentially compatible with the dest type, false otherwise.
15763
- function adjustSrcTupleTypeArgs(destTypeArgs, srcTypeArgs) {
15764
- const destUnboundedIndex = destTypeArgs.findIndex((t) => t.isUnbounded || (0, types_1.isVariadicTypeVar)(t.type));
15802
+ function adjustTupleTypeArgs(destTypeArgs, srcTypeArgs, flags) {
15803
+ const destUnboundedOrVariadicIndex = destTypeArgs.findIndex((t) => t.isUnbounded || (0, types_1.isVariadicTypeVar)(t.type));
15765
15804
  const srcUnboundedIndex = srcTypeArgs.findIndex((t) => t.isUnbounded);
15805
+ const srcVariadicIndex = srcTypeArgs.findIndex((t) => (0, types_1.isVariadicTypeVar)(t.type));
15766
15806
  // If the src contains an unbounded type but the dest does not, it's incompatible.
15767
- if (srcUnboundedIndex >= 0 && destUnboundedIndex < 0) {
15807
+ if (srcUnboundedIndex >= 0 && destUnboundedOrVariadicIndex < 0) {
15768
15808
  return false;
15769
15809
  }
15770
15810
  if (srcUnboundedIndex >= 0) {
@@ -15775,36 +15815,71 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15775
15815
  srcTypeArgs.splice(srcUnboundedIndex, 0, { type: typeToReplicate, isUnbounded: true });
15776
15816
  }
15777
15817
  }
15778
- const srcArgsToCapture = srcTypeArgs.length - destTypeArgs.length + 1;
15779
- if (destUnboundedIndex >= 0 && srcArgsToCapture >= 0) {
15780
- // If the dest contains a variadic element, determine which source
15781
- // args map to this element and package them up into an unpacked tuple.
15782
- if ((0, types_1.isVariadicTypeVar)(destTypeArgs[destUnboundedIndex].type)) {
15783
- if (tupleClassType && (0, types_1.isInstantiableClass)(tupleClassType)) {
15784
- const removedArgs = srcTypeArgs.splice(destUnboundedIndex, srcArgsToCapture);
15818
+ // Remove any optional parameters from the end of the two lists until the lengths match.
15819
+ while (srcTypeArgs.length > destTypeArgs.length && srcTypeArgs[srcTypeArgs.length - 1].isOptional) {
15820
+ srcTypeArgs.splice(srcTypeArgs.length - 1, 1);
15821
+ }
15822
+ while (destTypeArgs.length > srcTypeArgs.length && destTypeArgs[destTypeArgs.length - 1].isOptional) {
15823
+ destTypeArgs.splice(destTypeArgs.length - 1, 1);
15824
+ }
15825
+ if (srcVariadicIndex >= 0) {
15826
+ const destArgsToCapture = destTypeArgs.length - srcTypeArgs.length + 1;
15827
+ // If we're doing reverse type mappings and the source contains a variadic
15828
+ // TypeVar, we need to adjust the dest so the reverse type mapping assignment
15829
+ // can be performed.
15830
+ if (destArgsToCapture >= 0 && (flags & 2 /* AssignTypeFlags.ReverseTypeVarMatching */) !== 0) {
15831
+ // If the only removed arg from the dest type args is itself a variadic,
15832
+ // don't bother adjusting it.
15833
+ const skipAdjustment = destArgsToCapture === 1 && (0, types_1.isVariadicTypeVar)(destTypeArgs[srcVariadicIndex].type);
15834
+ if (!skipAdjustment && tupleClassType && (0, types_1.isInstantiableClass)(tupleClassType)) {
15835
+ const removedArgs = destTypeArgs.splice(srcVariadicIndex, destArgsToCapture);
15785
15836
  // Package up the remaining type arguments into a tuple object.
15786
15837
  const variadicTuple = (0, typeUtils_1.convertToInstance)((0, typeUtils_1.specializeTupleClass)(tupleClassType, removedArgs.map((typeArg) => {
15787
15838
  return { type: typeArg.type, isUnbounded: typeArg.isUnbounded };
15788
15839
  }),
15789
15840
  /* isTypeArgumentExplicit */ true,
15790
15841
  /* isUnpackedTuple */ true));
15791
- srcTypeArgs.splice(destUnboundedIndex, 0, {
15842
+ destTypeArgs.splice(srcVariadicIndex, 0, {
15792
15843
  type: variadicTuple,
15793
15844
  isUnbounded: false,
15794
15845
  });
15795
15846
  }
15796
15847
  }
15797
- else {
15798
- const removedArgTypes = srcTypeArgs.splice(destUnboundedIndex, srcArgsToCapture).map((t) => {
15799
- if ((0, types_1.isTypeVar)(t.type) && (0, types_1.isUnpackedVariadicTypeVar)(t.type) && !t.type.isVariadicInUnion) {
15800
- return types_1.TypeVarType.cloneForUnpacked(t.type, /* isInUnion */ true);
15848
+ }
15849
+ else {
15850
+ const srcArgsToCapture = srcTypeArgs.length - destTypeArgs.length + 1;
15851
+ if (destUnboundedOrVariadicIndex >= 0 && srcArgsToCapture >= 0) {
15852
+ // If the dest contains a variadic element, determine which source
15853
+ // args map to this element and package them up into an unpacked tuple.
15854
+ if ((0, types_1.isVariadicTypeVar)(destTypeArgs[destUnboundedOrVariadicIndex].type)) {
15855
+ if (tupleClassType && (0, types_1.isInstantiableClass)(tupleClassType)) {
15856
+ const removedArgs = srcTypeArgs.splice(destUnboundedOrVariadicIndex, srcArgsToCapture);
15857
+ // Package up the remaining type arguments into a tuple object.
15858
+ const variadicTuple = (0, typeUtils_1.convertToInstance)((0, typeUtils_1.specializeTupleClass)(tupleClassType, removedArgs.map((typeArg) => {
15859
+ return { type: typeArg.type, isUnbounded: typeArg.isUnbounded };
15860
+ }),
15861
+ /* isTypeArgumentExplicit */ true,
15862
+ /* isUnpackedTuple */ true));
15863
+ srcTypeArgs.splice(destUnboundedOrVariadicIndex, 0, {
15864
+ type: variadicTuple,
15865
+ isUnbounded: false,
15866
+ });
15801
15867
  }
15802
- return t.type;
15803
- });
15804
- srcTypeArgs.splice(destUnboundedIndex, 0, {
15805
- type: removedArgTypes.length > 0 ? (0, types_1.combineTypes)(removedArgTypes) : types_1.AnyType.create(),
15806
- isUnbounded: false,
15807
- });
15868
+ }
15869
+ else {
15870
+ const removedArgTypes = srcTypeArgs
15871
+ .splice(destUnboundedOrVariadicIndex, srcArgsToCapture)
15872
+ .map((t) => {
15873
+ if ((0, types_1.isTypeVar)(t.type) && (0, types_1.isUnpackedVariadicTypeVar)(t.type) && !t.type.isVariadicInUnion) {
15874
+ return types_1.TypeVarType.cloneForUnpacked(t.type, /* isInUnion */ true);
15875
+ }
15876
+ return t.type;
15877
+ });
15878
+ srcTypeArgs.splice(destUnboundedOrVariadicIndex, 0, {
15879
+ type: removedArgTypes.length > 0 ? (0, types_1.combineTypes)(removedArgTypes) : types_1.AnyType.create(),
15880
+ isUnbounded: false,
15881
+ });
15882
+ }
15808
15883
  }
15809
15884
  }
15810
15885
  return destTypeArgs.length === srcTypeArgs.length;
@@ -15813,8 +15888,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15813
15888
  var _a, _b;
15814
15889
  const destTypeArgs = [...((_a = destType.tupleTypeArguments) !== null && _a !== void 0 ? _a : [])];
15815
15890
  const srcTypeArgs = [...((_b = srcType.tupleTypeArguments) !== null && _b !== void 0 ? _b : [])];
15816
- const reverseMapping = (flags & 2 /* AssignTypeFlags.ReverseTypeVarMatching */) !== 0;
15817
- if (adjustSrcTupleTypeArgs(reverseMapping ? srcTypeArgs : destTypeArgs, reverseMapping ? destTypeArgs : srcTypeArgs)) {
15891
+ if (adjustTupleTypeArgs(destTypeArgs, srcTypeArgs, flags)) {
15818
15892
  for (let argIndex = 0; argIndex < srcTypeArgs.length; argIndex++) {
15819
15893
  const entryDiag = diag === null || diag === void 0 ? void 0 : diag.createAddendum();
15820
15894
  if (!assignType(destTypeArgs[argIndex].type, srcTypeArgs[argIndex].type, entryDiag === null || entryDiag === void 0 ? void 0 : entryDiag.createAddendum(), destTypeVarContext, srcTypeVarContext, flags, recursionCount)) {
@@ -16014,6 +16088,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16014
16088
  else if (types_1.ClassType.isBuiltIn(destType, 'list')) {
16015
16089
  childDiag.addMessage(localize_1.Localizer.DiagnosticAddendum.invariantSuggestionList());
16016
16090
  }
16091
+ else if (types_1.ClassType.isBuiltIn(destType, 'set')) {
16092
+ childDiag.addMessage(localize_1.Localizer.DiagnosticAddendum.invariantSuggestionSet());
16093
+ }
16017
16094
  }
16018
16095
  }
16019
16096
  else {
@@ -16313,14 +16390,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16313
16390
  typeTypeArg = types_1.UnknownType.create();
16314
16391
  }
16315
16392
  if ((0, types_1.isAnyOrUnknown)(typeTypeArg)) {
16316
- if ((0, types_1.isClassInstance)(destType) && types_1.ClassType.isBuiltIn(expandedSrcType, 'type')) {
16393
+ if ((0, typeUtils_1.isEffectivelyInstantiable)(destType)) {
16317
16394
  return true;
16318
16395
  }
16319
- return types_1.TypeBase.isInstantiable(destType);
16320
16396
  }
16321
- const instantiableType = (0, typeUtils_1.convertToInstantiable)(typeTypeArg);
16322
- if ((0, types_1.isClassInstance)(typeTypeArg) || (0, types_1.isTypeVar)(typeTypeArg)) {
16323
- if (assignType(destType, instantiableType, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), destTypeVarContext, srcTypeVarContext, flags, recursionCount)) {
16397
+ else if ((0, types_1.isClassInstance)(typeTypeArg) || (0, types_1.isTypeVar)(typeTypeArg)) {
16398
+ if (assignType(destType, (0, typeUtils_1.convertToInstantiable)(typeTypeArg), diag === null || diag === void 0 ? void 0 : diag.createAddendum(), destTypeVarContext, srcTypeVarContext, flags, recursionCount)) {
16324
16399
  return true;
16325
16400
  }
16326
16401
  diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.typeAssignmentMismatch().format(printSrcDestTypes(srcType, destType)));
@@ -16332,7 +16407,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16332
16407
  // PEP 544 says that if the dest type is a type[Proto] class,
16333
16408
  // the source must be a "concrete" (non-protocol) class.
16334
16409
  if (types_1.ClassType.isProtocolClass(destType) &&
16335
- (flags & 4096 /* AssignTypeFlags.IgnoreProtocolAssignmentCheck */) === 0) {
16410
+ (flags & 8192 /* AssignTypeFlags.IgnoreProtocolAssignmentCheck */) === 0) {
16336
16411
  if (types_1.ClassType.isProtocolClass(expandedSrcType) &&
16337
16412
  (0, types_1.isInstantiableClass)(srcType) &&
16338
16413
  !srcType.includeSubclasses) {
@@ -17020,15 +17095,6 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17020
17095
  specializedSrcType = (0, typeUtils_1.applySolvedTypeVars)(srcType, srcTypeVarContext);
17021
17096
  }
17022
17097
  }
17023
- // Handle the special case where the source is a Self type and the
17024
- // destination is not.
17025
- if (!(0, types_1.isTypeVar)(specializedDestType) || !specializedDestType.details.isSynthesizedSelf) {
17026
- if ((0, types_1.isTypeVar)(specializedSrcType) &&
17027
- specializedSrcType.details.isSynthesizedSelf &&
17028
- specializedSrcType.details.boundType) {
17029
- specializedSrcType = (0, typeUtils_1.applySolvedTypeVars)(specializedSrcType.details.boundType, new typeVarContext_1.TypeVarContext((0, typeUtils_1.getTypeVarScopeId)(specializedSrcType)), { unknownIfNotFound: true });
17030
- }
17031
- }
17032
17098
  if (!assignType(specializedSrcType, specializedDestType, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), srcTypeVarContext, destTypeVarContext, flags, recursionCount)) {
17033
17099
  // There are cases involving lambdas where the parameter types are type
17034
17100
  // variables and match exactly but fail the assignment check because the
@@ -17089,7 +17155,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17089
17155
  }
17090
17156
  }
17091
17157
  else {
17092
- srcTupleTypes.push({ type: entry.type, isUnbounded: false });
17158
+ srcTupleTypes.push({ type: entry.type, isUnbounded: false, isOptional: entry.param.hasDefault });
17093
17159
  }
17094
17160
  });
17095
17161
  if (srcTupleTypes.length !== 1 || !(0, types_1.isVariadicTypeVar)(srcTupleTypes[0].type)) {
@@ -18118,7 +18184,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
18118
18184
  let bestConstraintSoFar;
18119
18185
  // Try to find the best (narrowest) match among the constraints.
18120
18186
  for (const constraint of constraints) {
18121
- if (assignType(constraint, effectiveSrcType)) {
18187
+ // Don't allow Never as a type argument.
18188
+ if (assignType(constraint, effectiveSrcType) && !(0, types_1.isNever)(effectiveSrcType)) {
18122
18189
  if (!bestConstraintSoFar || assignType(bestConstraintSoFar, constraint)) {
18123
18190
  bestConstraintSoFar = constraint;
18124
18191
  }
@@ -18252,7 +18319,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
18252
18319
  }
18253
18320
  }
18254
18321
  else if (!assignType(memberTypeFirstParamType, firstParamType, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), typeVarContext,
18255
- /* srcTypeVarContext */ undefined, 2048 /* AssignTypeFlags.AllowUnspecifiedTypeArguments */, recursionCount)) {
18322
+ /* srcTypeVarContext */ undefined, 4096 /* AssignTypeFlags.AllowUnspecifiedTypeArguments */, recursionCount)) {
18256
18323
  if (memberTypeFirstParam.name &&
18257
18324
  !memberTypeFirstParam.isNameSynthesized &&
18258
18325
  memberTypeFirstParam.hasDeclaredType) {