@zzzen/pyright-internal 1.2.0-dev.20231203 → 1.2.0-dev.20231217

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 (360) 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 +67 -62
  7. package/dist/analyzer/binder.js.map +1 -1
  8. package/dist/analyzer/checker.js +43 -33
  9. package/dist/analyzer/checker.js.map +1 -1
  10. package/dist/analyzer/circularDependency.d.ts +3 -2
  11. package/dist/analyzer/circularDependency.js.map +1 -1
  12. package/dist/analyzer/codeFlowEngine.js +47 -47
  13. package/dist/analyzer/codeFlowEngine.js.map +1 -1
  14. package/dist/analyzer/codeFlowTypes.d.ts +0 -1
  15. package/dist/analyzer/codeFlowTypes.js.map +1 -1
  16. package/dist/analyzer/constraintSolver.js +3 -5
  17. package/dist/analyzer/constraintSolver.js.map +1 -1
  18. package/dist/analyzer/dataClasses.js +1 -1
  19. package/dist/analyzer/dataClasses.js.map +1 -1
  20. package/dist/analyzer/declaration.d.ts +5 -3
  21. package/dist/analyzer/declaration.js +3 -2
  22. package/dist/analyzer/declaration.js.map +1 -1
  23. package/dist/analyzer/declarationUtils.d.ts +3 -2
  24. package/dist/analyzer/declarationUtils.js +14 -12
  25. package/dist/analyzer/declarationUtils.js.map +1 -1
  26. package/dist/analyzer/decorators.js +14 -43
  27. package/dist/analyzer/decorators.js.map +1 -1
  28. package/dist/analyzer/enums.js +1 -1
  29. package/dist/analyzer/enums.js.map +1 -1
  30. package/dist/analyzer/importResolver.d.ts +29 -25
  31. package/dist/analyzer/importResolver.js +300 -301
  32. package/dist/analyzer/importResolver.js.map +1 -1
  33. package/dist/analyzer/importResult.d.ts +5 -4
  34. package/dist/analyzer/importResult.js.map +1 -1
  35. package/dist/analyzer/importStatementUtils.d.ts +5 -4
  36. package/dist/analyzer/importStatementUtils.js +23 -22
  37. package/dist/analyzer/importStatementUtils.js.map +1 -1
  38. package/dist/analyzer/namedTuples.js +3 -3
  39. package/dist/analyzer/namedTuples.js.map +1 -1
  40. package/dist/analyzer/packageTypeReport.d.ts +7 -6
  41. package/dist/analyzer/packageTypeReport.js +4 -4
  42. package/dist/analyzer/packageTypeReport.js.map +1 -1
  43. package/dist/analyzer/packageTypeVerifier.js +68 -64
  44. package/dist/analyzer/packageTypeVerifier.js.map +1 -1
  45. package/dist/analyzer/parentDirectoryCache.d.ts +7 -6
  46. package/dist/analyzer/parentDirectoryCache.js +9 -10
  47. package/dist/analyzer/parentDirectoryCache.js.map +1 -1
  48. package/dist/analyzer/parseTreeUtils.d.ts +1 -1
  49. package/dist/analyzer/parseTreeUtils.js +7 -4
  50. package/dist/analyzer/parseTreeUtils.js.map +1 -1
  51. package/dist/analyzer/patternMatching.js +102 -14
  52. package/dist/analyzer/patternMatching.js.map +1 -1
  53. package/dist/analyzer/program.d.ts +27 -26
  54. package/dist/analyzer/program.js +162 -156
  55. package/dist/analyzer/program.js.map +1 -1
  56. package/dist/analyzer/properties.js +6 -3
  57. package/dist/analyzer/properties.js.map +1 -1
  58. package/dist/analyzer/pyTypedUtils.d.ts +3 -2
  59. package/dist/analyzer/pyTypedUtils.js +4 -5
  60. package/dist/analyzer/pyTypedUtils.js.map +1 -1
  61. package/dist/analyzer/pythonPathUtils.d.ts +7 -6
  62. package/dist/analyzer/pythonPathUtils.js +21 -23
  63. package/dist/analyzer/pythonPathUtils.js.map +1 -1
  64. package/dist/analyzer/service.d.ts +24 -23
  65. package/dist/analyzer/service.js +190 -184
  66. package/dist/analyzer/service.js.map +1 -1
  67. package/dist/analyzer/sourceFile.d.ts +4 -5
  68. package/dist/analyzer/sourceFile.js +68 -56
  69. package/dist/analyzer/sourceFile.js.map +1 -1
  70. package/dist/analyzer/sourceFileInfoUtils.js +3 -3
  71. package/dist/analyzer/sourceFileInfoUtils.js.map +1 -1
  72. package/dist/analyzer/sourceMapper.d.ts +11 -10
  73. package/dist/analyzer/sourceMapper.js +61 -63
  74. package/dist/analyzer/sourceMapper.js.map +1 -1
  75. package/dist/analyzer/sourceMapperUtils.d.ts +2 -1
  76. package/dist/analyzer/sourceMapperUtils.js +2 -2
  77. package/dist/analyzer/sourceMapperUtils.js.map +1 -1
  78. package/dist/analyzer/tracePrinter.d.ts +3 -2
  79. package/dist/analyzer/tracePrinter.js +21 -23
  80. package/dist/analyzer/tracePrinter.js.map +1 -1
  81. package/dist/analyzer/typeDocStringUtils.d.ts +2 -1
  82. package/dist/analyzer/typeDocStringUtils.js +14 -17
  83. package/dist/analyzer/typeDocStringUtils.js.map +1 -1
  84. package/dist/analyzer/typeEvaluator.js +259 -152
  85. package/dist/analyzer/typeEvaluator.js.map +1 -1
  86. package/dist/analyzer/typeGuards.d.ts +1 -0
  87. package/dist/analyzer/typeGuards.js +5 -4
  88. package/dist/analyzer/typeGuards.js.map +1 -1
  89. package/dist/analyzer/typePrinter.d.ts +2 -0
  90. package/dist/analyzer/typePrinter.js +48 -8
  91. package/dist/analyzer/typePrinter.js.map +1 -1
  92. package/dist/analyzer/typeStubWriter.d.ts +2 -1
  93. package/dist/analyzer/typeStubWriter.js +2 -2
  94. package/dist/analyzer/typeStubWriter.js.map +1 -1
  95. package/dist/analyzer/typeUtils.d.ts +5 -2
  96. package/dist/analyzer/typeUtils.js +37 -10
  97. package/dist/analyzer/typeUtils.js.map +1 -1
  98. package/dist/analyzer/typedDicts.js +4 -4
  99. package/dist/analyzer/typedDicts.js.map +1 -1
  100. package/dist/analyzer/types.d.ts +10 -6
  101. package/dist/analyzer/types.js +7 -5
  102. package/dist/analyzer/types.js.map +1 -1
  103. package/dist/backgroundAnalysis.d.ts +1 -2
  104. package/dist/backgroundAnalysis.js +6 -4
  105. package/dist/backgroundAnalysis.js.map +1 -1
  106. package/dist/backgroundAnalysisBase.d.ts +22 -20
  107. package/dist/backgroundAnalysisBase.js +76 -55
  108. package/dist/backgroundAnalysisBase.js.map +1 -1
  109. package/dist/backgroundThreadBase.d.ts +1 -1
  110. package/dist/backgroundThreadBase.js +20 -11
  111. package/dist/backgroundThreadBase.js.map +1 -1
  112. package/dist/commands/createTypeStub.js +3 -2
  113. package/dist/commands/createTypeStub.js.map +1 -1
  114. package/dist/commands/dumpFileDebugInfoCommand.js +21 -20
  115. package/dist/commands/dumpFileDebugInfoCommand.js.map +1 -1
  116. package/dist/commands/quickActionCommand.js +5 -5
  117. package/dist/commands/quickActionCommand.js.map +1 -1
  118. package/dist/common/configOptions.d.ts +14 -13
  119. package/dist/common/configOptions.js +29 -27
  120. package/dist/common/configOptions.js.map +1 -1
  121. package/dist/common/diagnostic.d.ts +6 -5
  122. package/dist/common/diagnostic.js +2 -2
  123. package/dist/common/diagnostic.js.map +1 -1
  124. package/dist/common/diagnosticSink.d.ts +2 -1
  125. package/dist/common/diagnosticSink.js.map +1 -1
  126. package/dist/common/editAction.d.ts +6 -5
  127. package/dist/common/editAction.js +2 -2
  128. package/dist/common/editAction.js.map +1 -1
  129. package/dist/common/envVarUtils.d.ts +2 -1
  130. package/dist/common/envVarUtils.js +20 -28
  131. package/dist/common/envVarUtils.js.map +1 -1
  132. package/dist/common/extensibility.d.ts +19 -19
  133. package/dist/common/extensibility.js.map +1 -1
  134. package/dist/common/fileSystem.d.ts +29 -28
  135. package/dist/common/fileWatcher.d.ts +2 -1
  136. package/dist/common/fileWatcher.js.map +1 -1
  137. package/dist/common/fullAccessHost.d.ts +8 -7
  138. package/dist/common/fullAccessHost.js +21 -16
  139. package/dist/common/fullAccessHost.js.map +1 -1
  140. package/dist/common/host.d.ts +7 -6
  141. package/dist/common/host.js +1 -1
  142. package/dist/common/host.js.map +1 -1
  143. package/dist/common/logTracker.d.ts +2 -1
  144. package/dist/common/logTracker.js +4 -4
  145. package/dist/common/logTracker.js.map +1 -1
  146. package/dist/common/pathUtils.d.ts +1 -28
  147. package/dist/common/pathUtils.js +17 -366
  148. package/dist/common/pathUtils.js.map +1 -1
  149. package/dist/common/realFileSystem.d.ts +7 -3
  150. package/dist/common/realFileSystem.js +78 -60
  151. package/dist/common/realFileSystem.js.map +1 -1
  152. package/dist/common/serviceProviderExtensions.d.ts +2 -1
  153. package/dist/common/serviceProviderExtensions.js +5 -2
  154. package/dist/common/serviceProviderExtensions.js.map +1 -1
  155. package/dist/common/textEditTracker.d.ts +2 -1
  156. package/dist/common/textEditTracker.js +28 -28
  157. package/dist/common/textEditTracker.js.map +1 -1
  158. package/dist/common/textRange.d.ts +2 -1
  159. package/dist/common/textRange.js.map +1 -1
  160. package/dist/common/uri/baseUri.d.ts +51 -0
  161. package/dist/common/uri/baseUri.js +194 -0
  162. package/dist/common/uri/baseUri.js.map +1 -0
  163. package/dist/common/uri/emptyUri.d.ts +32 -0
  164. package/dist/common/uri/emptyUri.js +98 -0
  165. package/dist/common/uri/emptyUri.js.map +1 -0
  166. package/dist/common/uri/fileUri.d.ts +36 -0
  167. package/dist/common/uri/fileUri.js +180 -0
  168. package/dist/common/uri/fileUri.js.map +1 -0
  169. package/dist/common/uri/memoization.d.ts +3 -0
  170. package/dist/common/uri/memoization.js +72 -0
  171. package/dist/common/uri/memoization.js.map +1 -0
  172. package/dist/common/uri/uri.d.ts +50 -0
  173. package/dist/common/uri/uri.js +104 -0
  174. package/dist/common/uri/uri.js.map +1 -0
  175. package/dist/common/uri/uriUtils.d.ts +39 -0
  176. package/dist/common/uri/uriUtils.js +362 -0
  177. package/dist/common/uri/uriUtils.js.map +1 -0
  178. package/dist/common/uri/webUri.d.ts +36 -0
  179. package/dist/common/uri/webUri.js +207 -0
  180. package/dist/common/uri/webUri.js.map +1 -0
  181. package/dist/common/workspaceEditUtils.d.ts +8 -8
  182. package/dist/common/workspaceEditUtils.js +35 -38
  183. package/dist/common/workspaceEditUtils.js.map +1 -1
  184. package/dist/languageServerBase.d.ts +19 -22
  185. package/dist/languageServerBase.js +91 -95
  186. package/dist/languageServerBase.js.map +1 -1
  187. package/dist/languageService/analyzerServiceExecutor.d.ts +2 -1
  188. package/dist/languageService/analyzerServiceExecutor.js +14 -16
  189. package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
  190. package/dist/languageService/autoImporter.d.ts +11 -9
  191. package/dist/languageService/autoImporter.js +45 -44
  192. package/dist/languageService/autoImporter.js.map +1 -1
  193. package/dist/languageService/callHierarchyProvider.d.ts +3 -2
  194. package/dist/languageService/callHierarchyProvider.js +23 -35
  195. package/dist/languageService/callHierarchyProvider.js.map +1 -1
  196. package/dist/languageService/codeActionProvider.d.ts +2 -1
  197. package/dist/languageService/codeActionProvider.js +8 -10
  198. package/dist/languageService/codeActionProvider.js.map +1 -1
  199. package/dist/languageService/completionProvider.d.ts +7 -6
  200. package/dist/languageService/completionProvider.js +32 -30
  201. package/dist/languageService/completionProvider.js.map +1 -1
  202. package/dist/languageService/completionProviderUtils.d.ts +2 -1
  203. package/dist/languageService/completionProviderUtils.js +1 -1
  204. package/dist/languageService/completionProviderUtils.js.map +1 -1
  205. package/dist/languageService/definitionProvider.d.ts +4 -3
  206. package/dist/languageService/definitionProvider.js +26 -24
  207. package/dist/languageService/definitionProvider.js.map +1 -1
  208. package/dist/languageService/documentHighlightProvider.d.ts +3 -2
  209. package/dist/languageService/documentHighlightProvider.js +3 -3
  210. package/dist/languageService/documentHighlightProvider.js.map +1 -1
  211. package/dist/languageService/documentSymbolCollector.js +8 -7
  212. package/dist/languageService/documentSymbolCollector.js.map +1 -1
  213. package/dist/languageService/documentSymbolProvider.d.ts +5 -4
  214. package/dist/languageService/documentSymbolProvider.js +9 -11
  215. package/dist/languageService/documentSymbolProvider.js.map +1 -1
  216. package/dist/languageService/hoverProvider.d.ts +4 -3
  217. package/dist/languageService/hoverProvider.js +6 -5
  218. package/dist/languageService/hoverProvider.js.map +1 -1
  219. package/dist/languageService/navigationUtils.d.ts +2 -1
  220. package/dist/languageService/navigationUtils.js +2 -3
  221. package/dist/languageService/navigationUtils.js.map +1 -1
  222. package/dist/languageService/quickActions.d.ts +2 -1
  223. package/dist/languageService/quickActions.js +3 -3
  224. package/dist/languageService/quickActions.js.map +1 -1
  225. package/dist/languageService/referencesProvider.d.ts +10 -9
  226. package/dist/languageService/referencesProvider.js +28 -28
  227. package/dist/languageService/referencesProvider.js.map +1 -1
  228. package/dist/languageService/renameProvider.d.ts +4 -3
  229. package/dist/languageService/renameProvider.js +17 -18
  230. package/dist/languageService/renameProvider.js.map +1 -1
  231. package/dist/languageService/signatureHelpProvider.d.ts +3 -2
  232. package/dist/languageService/signatureHelpProvider.js +4 -4
  233. package/dist/languageService/signatureHelpProvider.js.map +1 -1
  234. package/dist/languageService/symbolIndexer.d.ts +2 -1
  235. package/dist/languageService/symbolIndexer.js +11 -3
  236. package/dist/languageService/symbolIndexer.js.map +1 -1
  237. package/dist/languageService/tooltipUtils.js +10 -4
  238. package/dist/languageService/tooltipUtils.js.map +1 -1
  239. package/dist/languageService/workspaceSymbolProvider.d.ts +4 -3
  240. package/dist/languageService/workspaceSymbolProvider.js +10 -11
  241. package/dist/languageService/workspaceSymbolProvider.js.map +1 -1
  242. package/dist/localization/localize.d.ts +2 -0
  243. package/dist/localization/localize.js +2 -0
  244. package/dist/localization/localize.js.map +1 -1
  245. package/dist/localization/package.nls.en-us.json +3 -1
  246. package/dist/parser/parseNodes.d.ts +1 -0
  247. package/dist/parser/parseNodes.js +1 -0
  248. package/dist/parser/parseNodes.js.map +1 -1
  249. package/dist/parser/parser.js +18 -15
  250. package/dist/parser/parser.js.map +1 -1
  251. package/dist/pyright.js +16 -15
  252. package/dist/pyright.js.map +1 -1
  253. package/dist/pyrightFileSystem.d.ts +13 -13
  254. package/dist/pyrightFileSystem.js +38 -43
  255. package/dist/pyrightFileSystem.js.map +1 -1
  256. package/dist/readonlyAugmentedFileSystem.d.ts +29 -28
  257. package/dist/readonlyAugmentedFileSystem.js +62 -65
  258. package/dist/readonlyAugmentedFileSystem.js.map +1 -1
  259. package/dist/server.js +21 -20
  260. package/dist/server.js.map +1 -1
  261. package/dist/tests/chainedSourceFiles.test.js +39 -30
  262. package/dist/tests/chainedSourceFiles.test.js.map +1 -1
  263. package/dist/tests/checker.test.js +31 -30
  264. package/dist/tests/checker.test.js.map +1 -1
  265. package/dist/tests/classDeclaration.test.d.ts +1 -0
  266. package/dist/tests/classDeclaration.test.js +166 -0
  267. package/dist/tests/classDeclaration.test.js.map +1 -0
  268. package/dist/tests/completions.test.js +7 -3
  269. package/dist/tests/completions.test.js.map +1 -1
  270. package/dist/tests/config.test.js +24 -22
  271. package/dist/tests/config.test.js.map +1 -1
  272. package/dist/tests/documentSymbolCollector.test.js +3 -2
  273. package/dist/tests/documentSymbolCollector.test.js.map +1 -1
  274. package/dist/tests/filesystem.test.js +37 -35
  275. package/dist/tests/filesystem.test.js.map +1 -1
  276. package/dist/tests/fourSlashParser.test.js +4 -4
  277. package/dist/tests/fourSlashParser.test.js.map +1 -1
  278. package/dist/tests/fourslash/hover.docstring.alias.fourslash.js +27 -11
  279. package/dist/tests/fourslash/hover.docstring.alias.fourslash.js.map +1 -1
  280. package/dist/tests/harness/fourslash/fourSlashParser.js +2 -2
  281. package/dist/tests/harness/fourslash/fourSlashParser.js.map +1 -1
  282. package/dist/tests/harness/fourslash/testLanguageService.d.ts +4 -5
  283. package/dist/tests/harness/fourslash/testLanguageService.js +9 -15
  284. package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
  285. package/dist/tests/harness/fourslash/testState.d.ts +4 -4
  286. package/dist/tests/harness/fourslash/testState.js +91 -51
  287. package/dist/tests/harness/fourslash/testState.js.map +1 -1
  288. package/dist/tests/harness/fourslash/workspaceEditTestUtils.js +4 -0
  289. package/dist/tests/harness/fourslash/workspaceEditTestUtils.js.map +1 -1
  290. package/dist/tests/harness/testAccessHost.d.ts +3 -2
  291. package/dist/tests/harness/testAccessHost.js +2 -1
  292. package/dist/tests/harness/testAccessHost.js.map +1 -1
  293. package/dist/tests/harness/testHost.js +13 -11
  294. package/dist/tests/harness/testHost.js.map +1 -1
  295. package/dist/tests/harness/vfs/factory.d.ts +3 -2
  296. package/dist/tests/harness/vfs/factory.js +5 -4
  297. package/dist/tests/harness/vfs/factory.js.map +1 -1
  298. package/dist/tests/harness/vfs/filesystem.d.ts +32 -31
  299. package/dist/tests/harness/vfs/filesystem.js +47 -49
  300. package/dist/tests/harness/vfs/filesystem.js.map +1 -1
  301. package/dist/tests/harness/vfs/pathValidation.js +1 -10
  302. package/dist/tests/harness/vfs/pathValidation.js.map +1 -1
  303. package/dist/tests/importResolver.test.js +106 -58
  304. package/dist/tests/importResolver.test.js.map +1 -1
  305. package/dist/tests/importStatementUtils.test.js +10 -9
  306. package/dist/tests/importStatementUtils.test.js.map +1 -1
  307. package/dist/tests/ipythonMode.test.js +12 -11
  308. package/dist/tests/ipythonMode.test.js.map +1 -1
  309. package/dist/tests/logger.test.js +2 -1
  310. package/dist/tests/logger.test.js.map +1 -1
  311. package/dist/tests/parseTreeUtils.test.js +2 -1
  312. package/dist/tests/parseTreeUtils.test.js.map +1 -1
  313. package/dist/tests/pathUtils.test.js +3 -138
  314. package/dist/tests/pathUtils.test.js.map +1 -1
  315. package/dist/tests/pyrightFileSystem.test.js +38 -34
  316. package/dist/tests/pyrightFileSystem.test.js.map +1 -1
  317. package/dist/tests/service.test.js +37 -42
  318. package/dist/tests/service.test.js.map +1 -1
  319. package/dist/tests/signatureHelp.test.js +3 -2
  320. package/dist/tests/signatureHelp.test.js.map +1 -1
  321. package/dist/tests/sourceFile.test.js +8 -7
  322. package/dist/tests/sourceFile.test.js.map +1 -1
  323. package/dist/tests/sourceMapperUtils.test.js +73 -35
  324. package/dist/tests/sourceMapperUtils.test.js.map +1 -1
  325. package/dist/tests/testState.test.js +13 -9
  326. package/dist/tests/testState.test.js.map +1 -1
  327. package/dist/tests/testStateUtils.d.ts +2 -5
  328. package/dist/tests/testStateUtils.js +27 -64
  329. package/dist/tests/testStateUtils.js.map +1 -1
  330. package/dist/tests/testUtils.d.ts +3 -5
  331. package/dist/tests/testUtils.js +15 -64
  332. package/dist/tests/testUtils.js.map +1 -1
  333. package/dist/tests/textEditUtil.test.js +4 -3
  334. package/dist/tests/textEditUtil.test.js.map +1 -1
  335. package/dist/tests/typeEvaluator1.test.js +16 -15
  336. package/dist/tests/typeEvaluator1.test.js.map +1 -1
  337. package/dist/tests/typeEvaluator2.test.js +22 -9
  338. package/dist/tests/typeEvaluator2.test.js.map +1 -1
  339. package/dist/tests/typeEvaluator3.test.js +86 -63
  340. package/dist/tests/typeEvaluator3.test.js.map +1 -1
  341. package/dist/tests/typeEvaluator4.test.js +29 -20
  342. package/dist/tests/typeEvaluator4.test.js.map +1 -1
  343. package/dist/tests/typeEvaluator5.test.js +28 -27
  344. package/dist/tests/typeEvaluator5.test.js.map +1 -1
  345. package/dist/tests/typePrinter.test.js +4 -3
  346. package/dist/tests/typePrinter.test.js.map +1 -1
  347. package/dist/tests/uri.test.d.ts +1 -0
  348. package/dist/tests/uri.test.js +695 -0
  349. package/dist/tests/uri.test.js.map +1 -0
  350. package/dist/tests/workspaceEditUtils.test.js +28 -28
  351. package/dist/tests/workspaceEditUtils.test.js.map +1 -1
  352. package/dist/tests/zipfs.test.js +11 -11
  353. package/dist/tests/zipfs.test.js.map +1 -1
  354. package/dist/workspaceFactory.d.ts +13 -14
  355. package/dist/workspaceFactory.js +54 -55
  356. package/dist/workspaceFactory.js.map +1 -1
  357. package/package.json +2 -2
  358. package/dist/common/uriParser.d.ts +0 -24
  359. package/dist/common/uriParser.js +0 -45
  360. 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
  }
@@ -621,6 +622,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
621
622
  break;
622
623
  }
623
624
  case 4 /* ParseNodeType.AssignmentExpression */: {
625
+ if ((flags & 256 /* EvaluatorFlags.ExpectingTypeAnnotation */) !== 0) {
626
+ addError(localize_1.Localizer.Diagnostic.walrusNotAllowed(), node);
627
+ }
624
628
  typeResult = getTypeOfExpression(node.rightExpression, flags, inferenceContext);
625
629
  assignTypeToExpression(node.name, typeResult.type, !!typeResult.isIncomplete, node.rightExpression,
626
630
  /* ignoreEmptyContainers */ true);
@@ -760,6 +764,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
760
764
  }
761
765
  }
762
766
  function getTypeOfAwaitOperator(node, flags, inferenceContext) {
767
+ if ((flags & 256 /* EvaluatorFlags.ExpectingTypeAnnotation */) !== 0) {
768
+ addError(localize_1.Localizer.Diagnostic.awaitNotAllowed(), node);
769
+ return { type: types_1.UnknownType.create() };
770
+ }
763
771
  const effectiveExpectedType = inferenceContext
764
772
  ? createAwaitableReturnType(node, inferenceContext.expectedType,
765
773
  /* isGenerator */ false,
@@ -814,24 +822,26 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
814
822
  !iterType.isVariadicUnpacked) {
815
823
  typeResult = { type: types_1.TypeVarType.cloneForUnpacked(iterType) };
816
824
  }
825
+ else if ((flags & 2097152 /* EvaluatorFlags.AllowUnpackedTupleOrTypeVarTuple */) !== 0 &&
826
+ (0, types_1.isInstantiableClass)(iterType) &&
827
+ types_1.ClassType.isBuiltIn(iterType, 'tuple')) {
828
+ typeResult = { type: types_1.ClassType.cloneForUnpacked(iterType) };
829
+ }
830
+ else if ((flags & 256 /* EvaluatorFlags.ExpectingTypeAnnotation */) !== 0) {
831
+ addError(localize_1.Localizer.Diagnostic.unpackInAnnotation(), node, node.starToken);
832
+ typeResult = { type: types_1.UnknownType.create() };
833
+ }
817
834
  else {
818
- if ((flags & 2097152 /* EvaluatorFlags.AllowUnpackedTupleOrTypeVarTuple */) !== 0 &&
819
- (0, types_1.isInstantiableClass)(iterType) &&
820
- types_1.ClassType.isBuiltIn(iterType, 'tuple')) {
821
- typeResult = { type: types_1.ClassType.cloneForUnpacked(iterType) };
822
- }
823
- else {
824
- const iteratorTypeResult = (_a = getTypeOfIterator(iterTypeResult, /* isAsync */ false, node)) !== null && _a !== void 0 ? _a : {
825
- type: types_1.UnknownType.create(!!iterTypeResult.isIncomplete),
826
- isIncomplete: iterTypeResult.isIncomplete,
827
- };
828
- typeResult = {
829
- type: iteratorTypeResult.type,
830
- typeErrors: iterTypeResult.typeErrors,
831
- unpackedType: iterType,
832
- isIncomplete: iteratorTypeResult.isIncomplete,
833
- };
834
- }
835
+ const iteratorTypeResult = (_a = getTypeOfIterator(iterTypeResult, /* isAsync */ false, node)) !== null && _a !== void 0 ? _a : {
836
+ type: types_1.UnknownType.create(!!iterTypeResult.isIncomplete),
837
+ isIncomplete: iterTypeResult.isIncomplete,
838
+ };
839
+ typeResult = {
840
+ type: iteratorTypeResult.type,
841
+ typeErrors: iterTypeResult.typeErrors,
842
+ unpackedType: iterType,
843
+ isIncomplete: iteratorTypeResult.isIncomplete,
844
+ };
835
845
  }
836
846
  return typeResult;
837
847
  }
@@ -1407,9 +1417,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
1407
1417
  return getBoundMagicMethod(boundMethodResult.type, '__call__', selfType !== null && selfType !== void 0 ? selfType : types_1.ClassType.cloneAsInstance(classType), recursionCount);
1408
1418
  }
1409
1419
  if ((0, types_1.isAnyOrUnknown)(boundMethodResult.type)) {
1410
- const unknownFunction = types_1.FunctionType.createSynthesizedInstance('', 32768 /* FunctionTypeFlags.SkipArgsKwargsCompatibilityCheck */);
1411
- types_1.FunctionType.addDefaultParameters(unknownFunction);
1412
- return unknownFunction;
1420
+ return (0, typeUtils_1.getUnknownTypeForCallable)();
1413
1421
  }
1414
1422
  return undefined;
1415
1423
  }
@@ -1492,8 +1500,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
1492
1500
  // type information than `__new__`.
1493
1501
  const initMethodResult = (0, constructors_1.getBoundInitMethod)(evaluatorInterface, callNode, types_1.ClassType.cloneAsInstance(subtype),
1494
1502
  /* skipObjectBase */ false);
1495
- if (initMethodResult && !initMethodResult.typeErrors && (0, types_1.isFunction)(initMethodResult.type)) {
1496
- constructorType = initMethodResult.type;
1503
+ if (initMethodResult && !initMethodResult.typeErrors) {
1504
+ if ((0, types_1.isFunction)(initMethodResult.type) || (0, types_1.isOverloadedFunction)(initMethodResult.type)) {
1505
+ constructorType = initMethodResult.type;
1506
+ }
1497
1507
  }
1498
1508
  const isObjectInit = constructorType &&
1499
1509
  (0, types_1.isFunction)(constructorType) &&
@@ -1507,11 +1517,14 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
1507
1517
  if (!constructorType || isObjectInit || isDefaultParams) {
1508
1518
  const newMethodResult = (0, constructors_1.getBoundNewMethod)(evaluatorInterface, callNode, subtype,
1509
1519
  /* skipObjectBase */ false);
1510
- if (newMethodResult &&
1511
- !newMethodResult.typeErrors &&
1512
- (0, types_1.isFunction)(newMethodResult.type) &&
1513
- newMethodResult.type.details.fullName !== 'builtins.object.__new__') {
1514
- constructorType = newMethodResult.type;
1520
+ if (newMethodResult && !newMethodResult.typeErrors && (0, types_1.isFunction)(newMethodResult.type)) {
1521
+ if ((0, types_1.isFunction)(newMethodResult.type) &&
1522
+ newMethodResult.type.details.fullName !== 'builtins.object.__new__') {
1523
+ constructorType = newMethodResult.type;
1524
+ }
1525
+ else if ((0, types_1.isOverloadedFunction)(newMethodResult.type)) {
1526
+ constructorType = newMethodResult.type;
1527
+ }
1515
1528
  }
1516
1529
  }
1517
1530
  if (constructorType) {
@@ -1923,7 +1936,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
1923
1936
  }
1924
1937
  function getTypeOfModule(node, symbolName, nameParts) {
1925
1938
  const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
1926
- const lookupResult = importLookup({ nameParts, importingFilePath: fileInfo.filePath });
1939
+ const lookupResult = importLookup({ nameParts, importingFileUri: fileInfo.fileUri });
1927
1940
  if (!lookupResult) {
1928
1941
  return undefined;
1929
1942
  }
@@ -2473,9 +2486,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
2473
2486
  (0, types_1.isFunction)(subtype) &&
2474
2487
  subtype.details.parameters.length === 0 &&
2475
2488
  subtype.details.paramSpec) {
2476
- const concreteFunction = types_1.FunctionType.createInstance('', '', '', 64 /* FunctionTypeFlags.SynthesizedMethod */ | 32768 /* FunctionTypeFlags.SkipArgsKwargsCompatibilityCheck */);
2477
- types_1.FunctionType.addDefaultParameters(concreteFunction);
2478
- return types_1.FunctionType.cloneForParamSpec(subtype, concreteFunction);
2489
+ return types_1.FunctionType.cloneForParamSpec(subtype, (0, typeUtils_1.getUnknownTypeForCallable)());
2479
2490
  }
2480
2491
  if ((0, types_1.isTypeVar)(subtype) && subtype.details.isVariadic) {
2481
2492
  // If it's in a union, convert to type or object.
@@ -3072,7 +3083,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3072
3083
  return type;
3073
3084
  }
3074
3085
  // Handles the case where a variable or parameter is defined in an outer
3075
- // scope and captured by an inner scope (either a function or a lambda).
3086
+ // scope and captured by an inner scope (a function, lambda, or comprehension).
3076
3087
  function getCodeFlowTypeForCapturedVariable(node, symbolWithScope, effectiveType) {
3077
3088
  // This function applies only to variables, parameters, and imports, not to other
3078
3089
  // types of symbols.
@@ -3092,16 +3103,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3092
3103
  // If the symbol is a variable captured by an inner function
3093
3104
  // or lambda, see if we can infer the type from the outer scope.
3094
3105
  const scopeHierarchy = ScopeUtils.getScopeHierarchy(node, symbolWithScope.scope);
3095
- // Handle the case where all of the nested scopes are functions,
3096
- // lambdas and modules. Don't allow other types of scopes.
3097
- if (scopeHierarchy &&
3098
- scopeHierarchy.length >= 2 &&
3099
- scopeHierarchy.every((s) => s.type === 1 /* ScopeType.Function */ || s.type === 3 /* ScopeType.Module */)) {
3106
+ if (scopeHierarchy && scopeHierarchy.length >= 2) {
3100
3107
  // Find the parse node associated with the scope that is just inside of the
3101
3108
  // scope that declares the captured variable.
3102
3109
  const innerScopeNode = ScopeUtils.findTopNodeInScope(node, scopeHierarchy[scopeHierarchy.length - 2]);
3103
- if (innerScopeNode &&
3104
- (innerScopeNode.nodeType === 28 /* ParseNodeType.Function */ || innerScopeNode.nodeType === 30 /* ParseNodeType.Lambda */)) {
3110
+ if ((innerScopeNode === null || innerScopeNode === void 0 ? void 0 : innerScopeNode.nodeType) === 28 /* ParseNodeType.Function */ ||
3111
+ (innerScopeNode === null || innerScopeNode === void 0 ? void 0 : innerScopeNode.nodeType) === 30 /* ParseNodeType.Lambda */ ||
3112
+ (innerScopeNode === null || innerScopeNode === void 0 ? void 0 : innerScopeNode.nodeType) === 10 /* ParseNodeType.Class */) {
3105
3113
  const innerScopeCodeFlowNode = AnalyzerNodeInfo.getFlowNode(innerScopeNode);
3106
3114
  if (innerScopeCodeFlowNode) {
3107
3115
  // See if any of the assignments of the symbol are reachable
@@ -3288,7 +3296,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3288
3296
  name: type.typeAliasInfo.name,
3289
3297
  }), node);
3290
3298
  }
3291
- type = types_1.TypeBase.cloneForTypeAlias((0, typeUtils_1.applySolvedTypeVars)(type, typeVarContext, { unknownIfNotFound: true }), type.typeAliasInfo.name, type.typeAliasInfo.fullName, type.typeAliasInfo.typeVarScopeId, type.typeAliasInfo.isPep695Syntax, type.typeAliasInfo.typeParameters, defaultTypeArgs);
3299
+ type = types_1.TypeBase.cloneForTypeAlias((0, typeUtils_1.applySolvedTypeVars)(type, typeVarContext, { unknownIfNotFound: true }), type.typeAliasInfo.name, type.typeAliasInfo.fullName, type.typeAliasInfo.moduleName, type.typeAliasInfo.fileUri, type.typeAliasInfo.typeVarScopeId, type.typeAliasInfo.isPep695Syntax, type.typeAliasInfo.typeParameters, defaultTypeArgs);
3292
3300
  }
3293
3301
  return type;
3294
3302
  }
@@ -3624,9 +3632,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
3624
3632
  const getAttrSymbol = types_1.ModuleType.getField(baseType, '__getattr__');
3625
3633
  if (getAttrSymbol) {
3626
3634
  const isModuleGetAttrSupported = fileInfo.executionEnvironment.pythonVersion >= pythonVersion_1.PythonVersion.V3_7 ||
3627
- getAttrSymbol
3628
- .getDeclarations()
3629
- .some((decl) => decl.path.toLowerCase().endsWith('.pyi'));
3635
+ getAttrSymbol.getDeclarations().some((decl) => decl.uri.hasExtension('.pyi'));
3630
3636
  if (isModuleGetAttrSupported) {
3631
3637
  const getAttrTypeResult = getEffectiveTypeOfSymbolForUsage(getAttrSymbol);
3632
3638
  if ((0, types_1.isFunction)(getAttrTypeResult.type)) {
@@ -4642,7 +4648,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
4642
4648
  }
4643
4649
  aliasTypeArgs.push(typeVarType);
4644
4650
  });
4645
- const type = types_1.TypeBase.cloneForTypeAlias((0, typeUtils_1.applySolvedTypeVars)(baseType, typeVarContext), baseType.typeAliasInfo.name, baseType.typeAliasInfo.fullName, baseType.typeAliasInfo.typeVarScopeId, baseType.typeAliasInfo.isPep695Syntax, baseType.typeAliasInfo.typeParameters, aliasTypeArgs);
4651
+ const type = types_1.TypeBase.cloneForTypeAlias((0, typeUtils_1.applySolvedTypeVars)(baseType, typeVarContext), baseType.typeAliasInfo.name, baseType.typeAliasInfo.fullName, baseType.typeAliasInfo.moduleName, baseType.typeAliasInfo.fileUri, baseType.typeAliasInfo.typeVarScopeId, baseType.typeAliasInfo.isPep695Syntax, baseType.typeAliasInfo.typeParameters, aliasTypeArgs);
4646
4652
  return { type, node };
4647
4653
  }
4648
4654
  function getTypeOfIndexWithBaseType(node, baseTypeResult, usage, flags) {
@@ -4653,7 +4659,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
4653
4659
  }
4654
4660
  if ((0, types_1.isTypeVar)(baseTypeResult.type) && (0, typeUtils_1.isTypeAliasPlaceholder)(baseTypeResult.type)) {
4655
4661
  const typeArgTypes = getTypeArgs(node, flags).map((t) => (0, typeUtils_1.convertToInstance)(t.type));
4656
- const type = types_1.TypeBase.cloneForTypeAlias(baseTypeResult.type, baseTypeResult.type.details.recursiveTypeAliasName, '', baseTypeResult.type.details.recursiveTypeAliasScopeId, !!baseTypeResult.type.details.recursiveTypeAliasIsPep695Syntax, baseTypeResult.type.details.recursiveTypeParameters, typeArgTypes);
4662
+ const type = types_1.TypeBase.cloneForTypeAlias(baseTypeResult.type, baseTypeResult.type.details.recursiveTypeAliasName, '', '', uri_1.Uri.empty(), baseTypeResult.type.details.recursiveTypeAliasScopeId, !!baseTypeResult.type.details.recursiveTypeAliasIsPep695Syntax, baseTypeResult.type.details.recursiveTypeParameters, typeArgTypes);
4657
4663
  return { type };
4658
4664
  }
4659
4665
  let isIncomplete = baseTypeResult.isIncomplete;
@@ -5706,9 +5712,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
5706
5712
  addError(localize_1.Localizer.Diagnostic.superCallArgCount(), node.arguments[2]);
5707
5713
  }
5708
5714
  const enclosingFunction = ParseTreeUtils.getEnclosingFunctionEvaluationScope(node);
5709
- const enclosingClass = enclosingFunction
5710
- ? ParseTreeUtils.getEnclosingClass(enclosingFunction, /* stopAtFunction */ true)
5711
- : undefined;
5715
+ const enclosingClass = enclosingFunction ? ParseTreeUtils.getEnclosingClass(enclosingFunction) : undefined;
5712
5716
  const enclosingClassType = enclosingClass ? (_a = getTypeOfClass(enclosingClass)) === null || _a === void 0 ? void 0 : _a.classType : undefined;
5713
5717
  // Determine which class the "super" call is applied to. If
5714
5718
  // there is no first argument, then the class is implicit.
@@ -5771,6 +5775,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
5771
5775
  if (reportError) {
5772
5776
  const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
5773
5777
  addDiagnostic(fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.superCallSecondArg().format({ type: printType(targetClassType) }), node.arguments[1].valueExpression);
5778
+ return { type: types_1.UnknownType.create() };
5774
5779
  }
5775
5780
  }
5776
5781
  else if (enclosingClassType) {
@@ -5838,34 +5843,77 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
5838
5843
  const lookupResults = bindToType
5839
5844
  ? (0, typeUtils_1.lookUpClassMember)(bindToType, memberName, 0 /* MemberAccessFlags.Default */, effectiveTargetClass)
5840
5845
  : undefined;
5846
+ let resultType;
5841
5847
  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
- };
5848
+ resultType = lookupResults.classType;
5850
5849
  }
5850
+ else if (effectiveTargetClass &&
5851
+ !(0, types_1.isAnyOrUnknown)(effectiveTargetClass) &&
5852
+ !(0, typeUtils_1.derivesFromAnyOrUnknown)(effectiveTargetClass) &&
5853
+ objectType &&
5854
+ (0, types_1.isClassInstance)(objectType)) {
5855
+ resultType = types_1.ClassType.cloneAsInstantiable(objectType);
5856
+ }
5857
+ else {
5858
+ resultType = types_1.UnknownType.create();
5859
+ }
5860
+ return {
5861
+ type: resultIsInstance ? (0, typeUtils_1.convertToInstance)(resultType) : resultType,
5862
+ bindToSelfType: bindToType
5863
+ ? types_1.TypeBase.cloneForCondition((0, typeUtils_1.synthesizeTypeVarForSelfCls)(bindToType, /* isClsParam */ false), bindToType.condition)
5864
+ : undefined,
5865
+ };
5851
5866
  }
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.
5867
+ // Handle the super() call when used outside of a member access expression.
5854
5868
  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)) {
5869
+ // We don't know which member is going to be accessed, so we cannot
5870
+ // deterministically determine the correct type in this case. We'll
5871
+ // use a heuristic that produces the "correct" (desired) behavior in
5872
+ // most cases. If there's a bindToType and the targetClassType is one
5873
+ // of the base classes of the bindToType, we'll return the next base
5874
+ // class.
5875
+ if (bindToType) {
5876
+ let nextBaseClassType;
5877
+ if (types_1.ClassType.isSameGenericClass(bindToType, targetClassType)) {
5878
+ if (bindToType.details.baseClasses.length > 0) {
5879
+ nextBaseClassType = bindToType.details.baseClasses[0];
5880
+ }
5881
+ }
5882
+ else {
5883
+ const baseClassIndex = bindToType.details.baseClasses.findIndex((baseClass) => (0, types_1.isClass)(baseClass) && types_1.ClassType.isSameGenericClass(baseClass, targetClassType));
5884
+ if (baseClassIndex >= 0 && baseClassIndex < bindToType.details.baseClasses.length - 1) {
5885
+ nextBaseClassType = bindToType.details.baseClasses[baseClassIndex + 1];
5886
+ }
5887
+ }
5888
+ if (nextBaseClassType) {
5889
+ if ((0, types_1.isInstantiableClass)(nextBaseClassType)) {
5890
+ nextBaseClassType = (0, typeUtils_1.specializeForBaseClass)(bindToType, nextBaseClassType);
5891
+ }
5892
+ return { type: resultIsInstance ? (0, typeUtils_1.convertToInstance)(nextBaseClassType) : nextBaseClassType };
5893
+ }
5894
+ // There's not much we can say about the type. Simply return object or type.
5895
+ if (objectType && (0, types_1.isClassInstance)(objectType) && typeClassType && (0, types_1.isInstantiableClass)(typeClassType)) {
5864
5896
  return {
5865
- type: resultIsInstance ? types_1.ClassType.cloneAsInstance(baseClassType) : baseClassType,
5897
+ type: resultIsInstance ? objectType : (0, typeUtils_1.convertToInstance)(typeClassType),
5866
5898
  };
5867
5899
  }
5868
5900
  }
5901
+ else {
5902
+ // If the class derives from one or more unknown classes,
5903
+ // return unknown here to prevent spurious errors.
5904
+ if (targetClassType.details.mro.some((mroBase) => (0, types_1.isAnyOrUnknown)(mroBase))) {
5905
+ return { type: types_1.UnknownType.create() };
5906
+ }
5907
+ const baseClasses = targetClassType.details.baseClasses;
5908
+ if (baseClasses.length > 0) {
5909
+ const baseClassType = baseClasses[0];
5910
+ if ((0, types_1.isInstantiableClass)(baseClassType)) {
5911
+ return {
5912
+ type: resultIsInstance ? types_1.ClassType.cloneAsInstance(baseClassType) : baseClassType,
5913
+ };
5914
+ }
5915
+ }
5916
+ }
5869
5917
  }
5870
5918
  return { type: types_1.UnknownType.create() };
5871
5919
  }
@@ -6183,7 +6231,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
6183
6231
  const diagnostic = addDiagnostic(AnalyzerNodeInfo.getFileInfo(errorNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.noOverload().format({ name: functionName }), errorNode);
6184
6232
  const overrideDecl = bestMatch.overload.details.declaration;
6185
6233
  if (diagnostic && overrideDecl) {
6186
- diagnostic.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.overloadIndex().format({ index: bestMatch.overloadIndex + 1 }), overrideDecl.path, overrideDecl.range);
6234
+ diagnostic.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.overloadIndex().format({ index: bestMatch.overloadIndex + 1 }), overrideDecl.uri, overrideDecl.range);
6187
6235
  }
6188
6236
  }
6189
6237
  const effectiveTypeVarContext = typeVarContext !== null && typeVarContext !== void 0 ? typeVarContext : new typeVarContext_1.TypeVarContext();
@@ -6663,9 +6711,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
6663
6711
  newClassName = firstArgType.literalValue;
6664
6712
  }
6665
6713
  }
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));
6714
+ 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
6715
  newClassType.details.baseClasses.push(getBuiltInType(errorNode, 'object'));
6668
6716
  newClassType.details.effectiveMetaclass = expandedCallType;
6717
+ newClassType.details.declaration = returnType.details.declaration;
6669
6718
  (0, typeUtils_1.computeMroLinearization)(newClassType);
6670
6719
  returnType = newClassType;
6671
6720
  }
@@ -6824,7 +6873,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
6824
6873
  }
6825
6874
  else if (typeResult.type.details.paramSpec) {
6826
6875
  const paramSpecScopeId = typeResult.type.details.paramSpec.scopeId;
6827
- if (paramSpecScopeId === typeResult.type.details.typeVarScopeId ||
6876
+ if (typeResult.type.details.typeVarScopeId === types_1.WildcardTypeVarScopeId ||
6877
+ paramSpecScopeId === typeResult.type.details.typeVarScopeId ||
6828
6878
  paramSpecScopeId === typeResult.type.details.constructorTypeVarScopeId) {
6829
6879
  hasParamSpecArgsKwargs = true;
6830
6880
  paramSpecArgList = [];
@@ -7611,7 +7661,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7611
7661
  }
7612
7662
  const effectiveReturnType = getFunctionEffectiveReturnType(type);
7613
7663
  let effectiveExpectedType = inferenceContext.expectedType;
7614
- let effectiveFlags = 0 /* AssignTypeFlags.Default */;
7664
+ let effectiveFlags = 1024 /* AssignTypeFlags.PopulatingExpectedType */;
7615
7665
  if ((0, typeUtils_1.containsLiteralType)(effectiveExpectedType, /* includeTypeArgs */ true)) {
7616
7666
  effectiveFlags |= 128 /* AssignTypeFlags.RetainLiteralsForTypeVar */;
7617
7667
  }
@@ -7623,7 +7673,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7623
7673
  const typeVarContextCopy = typeVarContext.clone();
7624
7674
  assignType(effectiveReturnType, effectiveExpectedType,
7625
7675
  /* diag */ undefined, typeVarContextCopy,
7626
- /* srcTypeVarContext */ undefined, effectiveFlags | 1024 /* AssignTypeFlags.PopulatingExpectedType */);
7676
+ /* srcTypeVarContext */ undefined, effectiveFlags);
7627
7677
  const speculativeResults = validateFunctionArgumentTypes(errorNode, matchResults, typeVarContextCopy, signatureTracker, skipUnknownArgCheck);
7628
7678
  if (speculativeResults === null || speculativeResults === void 0 ? void 0 : speculativeResults.argumentErrors) {
7629
7679
  effectiveExpectedType = undefined;
@@ -7669,6 +7719,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7669
7719
  effectiveExpectedType = (0, typeUtils_1.applySolvedTypeVars)(genericReturnType, tempTypeVarContext, {
7670
7720
  unknownIfNotFound: true,
7671
7721
  });
7722
+ effectiveFlags |= 2048 /* AssignTypeFlags.SkipPopulateUnknownExpectedType */;
7672
7723
  }
7673
7724
  }
7674
7725
  }
@@ -7684,7 +7735,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
7684
7735
  effectiveExpectedType = (0, typeUtils_1.transformExpectedType)(effectiveExpectedType, liveTypeVarScopes, errorNode.start);
7685
7736
  assignType(effectiveReturnType, effectiveExpectedType,
7686
7737
  /* diag */ undefined, typeVarContext,
7687
- /* srcTypeVarContext */ undefined, effectiveFlags | 1024 /* AssignTypeFlags.PopulatingExpectedType */);
7738
+ /* srcTypeVarContext */ undefined, effectiveFlags);
7688
7739
  }
7689
7740
  return validateFunctionArgumentTypes(errorNode, matchResults, typeVarContext, signatureTracker, skipUnknownArgCheck);
7690
7741
  }
@@ -8101,7 +8152,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8101
8152
  let argErrorNode;
8102
8153
  for (const arg of argList) {
8103
8154
  const argType = (_a = getTypeOfArgument(arg)) === null || _a === void 0 ? void 0 : _a.type;
8104
- const isArgTypeCompatible = argType && ((0, types_1.isTypeSame)(argType, paramSpec) || (0, types_1.isAnyOrUnknown)(argType));
8155
+ const isArgTypeCompatible = argType && ((0, types_1.isTypeSame)(argType, paramSpec, { ignoreTypeFlags: true }) || (0, types_1.isAnyOrUnknown)(argType));
8105
8156
  if (arg.argumentCategory === 1 /* ArgumentCategory.UnpackedList */ && !sawArgs && isArgTypeCompatible) {
8106
8157
  sawArgs = true;
8107
8158
  }
@@ -8751,7 +8802,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8751
8802
  }
8752
8803
  return getTypeOfTypeAliasCommon(nameNode, nameNode, valueExpr,
8753
8804
  /* isPep695Syntax */ false,
8754
- /* typeParamNodes */ undefined, () => typeParameters !== null && typeParameters !== void 0 ? typeParameters : []);
8805
+ /* typeParamNodes */ undefined, () => typeParameters);
8755
8806
  }
8756
8807
  function getBooleanValue(node) {
8757
8808
  if (node.nodeType === 11 /* ParseNodeType.Constant */) {
@@ -8819,7 +8870,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8819
8870
  }
8820
8871
  let classFlags = baseClass.details.flags & ~(1 /* ClassTypeFlags.BuiltInClass */ | 2 /* ClassTypeFlags.SpecialBuiltIn */);
8821
8872
  classFlags |= 4096 /* ClassTypeFlags.Final */;
8822
- const classType = types_1.ClassType.createInstantiable(className, ParseTreeUtils.getClassFullName(errorNode, fileInfo.moduleName, className), fileInfo.moduleName, fileInfo.filePath, classFlags, ParseTreeUtils.getTypeSourceId(errorNode),
8873
+ const classType = types_1.ClassType.createInstantiable(className, ParseTreeUtils.getClassFullName(errorNode, fileInfo.moduleName, className), fileInfo.moduleName, fileInfo.fileUri, classFlags, ParseTreeUtils.getTypeSourceId(errorNode),
8823
8874
  /* declaredMetaclass */ undefined, baseClass.details.effectiveMetaclass);
8824
8875
  classType.details.baseClasses.push(isBaseClassAny ? types_1.AnyType.create() : baseClass);
8825
8876
  (0, typeUtils_1.computeMroLinearization)(classType);
@@ -8866,7 +8917,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
8866
8917
  if (!(0, types_1.isClassInstance)(arg1Type) || !(0, typeUtils_1.isTupleClass)(arg1Type) || arg1Type.tupleTypeArguments === undefined) {
8867
8918
  return undefined;
8868
8919
  }
8869
- const classType = types_1.ClassType.createInstantiable(className, ParseTreeUtils.getClassFullName(errorNode, fileInfo.moduleName, className), fileInfo.moduleName, fileInfo.filePath, 0 /* ClassTypeFlags.None */, ParseTreeUtils.getTypeSourceId(errorNode),
8920
+ const classType = types_1.ClassType.createInstantiable(className, ParseTreeUtils.getClassFullName(errorNode, fileInfo.moduleName, className), fileInfo.moduleName, fileInfo.fileUri, 0 /* ClassTypeFlags.None */, ParseTreeUtils.getTypeSourceId(errorNode),
8870
8921
  /* declaredMetaclass */ undefined, arg1Type.details.effectiveMetaclass);
8871
8922
  arg1Type.tupleTypeArguments.forEach((typeArg) => {
8872
8923
  const specializedType = makeTopLevelTypeVarsConcrete(typeArg.type);
@@ -10656,7 +10707,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
10656
10707
  }
10657
10708
  return createSpecialType(classType, typeArgs, /* paramLimit */ undefined, /* allowParamSpec */ true);
10658
10709
  }
10659
- function transformTypeForTypeAlias(type, name, errorNode, isPep695Syntax, typeParameters, typeParamNodes) {
10710
+ function transformTypeForTypeAlias(type, name, errorNode, isPep695Syntax, isPep695TypeVarType, typeParameters, typeParamNodes) {
10660
10711
  if (!types_1.TypeBase.isInstantiable(type)) {
10661
10712
  return type;
10662
10713
  }
@@ -10701,27 +10752,32 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
10701
10752
  names: variadics.map((v) => `"${v.details.name}"`).join(', '),
10702
10753
  }), errorNode);
10703
10754
  }
10704
- const fileInfo = AnalyzerNodeInfo.getFileInfo(name);
10705
- const boundTypeVars = typeParameters.filter((typeVar) => typeVar.scopeId !== typeAliasScopeId && typeVar.scopeType === 0 /* TypeVarScopeType.Class */);
10706
- if (boundTypeVars.length > 0) {
10707
- addError(localize_1.Localizer.Diagnostic.genericTypeAliasBoundTypeVar().format({
10708
- names: boundTypeVars.map((t) => `${t.details.name}`).join(', '),
10709
- }), errorNode);
10755
+ if (!isPep695Syntax && !isPep695TypeVarType) {
10756
+ const boundTypeVars = typeParameters.filter((typeVar) => typeVar.scopeId !== typeAliasScopeId && typeVar.scopeType === 0 /* TypeVarScopeType.Class */);
10757
+ if (boundTypeVars.length > 0) {
10758
+ addError(localize_1.Localizer.Diagnostic.genericTypeAliasBoundTypeVar().format({
10759
+ names: boundTypeVars.map((t) => `${t.details.name}`).join(', '),
10760
+ }), errorNode);
10761
+ }
10710
10762
  }
10711
- const typeAlias = types_1.TypeBase.cloneForTypeAlias(type, name.value, ParseTreeUtils.getClassFullName(name, fileInfo.moduleName, name.value), typeAliasScopeId, isPep695Syntax, typeParameters.length > 0 ? typeParameters : undefined);
10763
+ const fileInfo = AnalyzerNodeInfo.getFileInfo(name);
10764
+ const typeAlias = types_1.TypeBase.cloneForTypeAlias(type, name.value, ParseTreeUtils.getClassFullName(name, fileInfo.moduleName, name.value), fileInfo.moduleName, fileInfo.fileUri, typeAliasScopeId, isPep695Syntax, typeParameters.length > 0 ? typeParameters : undefined);
10712
10765
  // All PEP 695 type aliases are special forms because they are
10713
10766
  // TypeAliasType objects at runtime.
10714
- if (isPep695Syntax) {
10767
+ if (isPep695Syntax || isPep695TypeVarType) {
10715
10768
  typeAlias.flags |= 8 /* TypeFlags.SpecialForm */;
10716
10769
  }
10717
10770
  return typeAlias;
10718
10771
  }
10719
10772
  function createSpecialBuiltInClass(node, assignedName, aliasMapEntry) {
10773
+ var _a;
10720
10774
  const fileInfo = AnalyzerNodeInfo.getFileInfo(node);
10721
- let specialClassType = types_1.ClassType.createInstantiable(assignedName, ParseTreeUtils.getClassFullName(node, fileInfo.moduleName, assignedName), fileInfo.moduleName, fileInfo.filePath, 1 /* ClassTypeFlags.BuiltInClass */ | 2 /* ClassTypeFlags.SpecialBuiltIn */,
10775
+ let specialClassType = types_1.ClassType.createInstantiable(assignedName, ParseTreeUtils.getClassFullName(node, fileInfo.moduleName, assignedName), fileInfo.moduleName, fileInfo.fileUri, 1 /* ClassTypeFlags.BuiltInClass */ | 2 /* ClassTypeFlags.SpecialBuiltIn */,
10722
10776
  /* typeSourceId */ 0,
10723
10777
  /* declaredMetaclass */ undefined,
10724
10778
  /* effectiveMetaclass */ undefined);
10779
+ const specialBuiltInClassDeclaration = ((_a = AnalyzerNodeInfo.getDeclaration(node)) !== null && _a !== void 0 ? _a : (node.parent ? AnalyzerNodeInfo.getDeclaration(node.parent) : undefined));
10780
+ specialClassType.details.declaration = specialBuiltInClassDeclaration;
10725
10781
  if (fileInfo.isTypingExtensionsStubFile) {
10726
10782
  specialClassType.details.flags |= 65536 /* ClassTypeFlags.TypingExtensionClass */;
10727
10783
  }
@@ -10967,7 +11023,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
10967
11023
  if (!isSpeculativeTypeAlias || isLegalImplicitTypeAliasType(rightHandType)) {
10968
11024
  // If this is a type alias, record its name based on the assignment target.
10969
11025
  rightHandType = transformTypeForTypeAlias(rightHandType, typeAliasNameNode, node.rightExpression,
10970
- /* isPep695Syntax */ false);
11026
+ /* isPep695Syntax */ false,
11027
+ /* isPep695TypeVarType */ false);
10971
11028
  (0, debug_1.assert)(typeAliasTypeVar !== undefined);
10972
11029
  if ((0, typeUtils_1.isTypeAliasRecursive)(typeAliasTypeVar, rightHandType)) {
10973
11030
  addDiagnostic(fileInfo.diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.typeAliasIsRecursiveDirect().format({
@@ -11024,11 +11081,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11024
11081
  var _a;
11025
11082
  return getTypeOfTypeAliasCommon(node, node.name, node.expression,
11026
11083
  /* isPep695Syntax */ true, (_a = node.typeParameters) === null || _a === void 0 ? void 0 : _a.parameters, () => {
11027
- let typeParameters = [];
11028
11084
  if (node.typeParameters) {
11029
- typeParameters = evaluateTypeParameterList(node.typeParameters);
11085
+ return evaluateTypeParameterList(node.typeParameters);
11030
11086
  }
11031
- return typeParameters;
11087
+ return undefined;
11032
11088
  });
11033
11089
  }
11034
11090
  // This function is common to the handling of "type" statements and explicit
@@ -11067,7 +11123,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11067
11123
  if (aliasTypeResult.isIncomplete) {
11068
11124
  isIncomplete = true;
11069
11125
  }
11070
- aliasType = transformTypeForTypeAlias(aliasType, nameNode, valueNode, isPep695Syntax, typeParameters, typeParamNodes);
11126
+ aliasType = transformTypeForTypeAlias(aliasType, nameNode, valueNode, isPep695Syntax,
11127
+ /* isPep695TypeVarType */ true, typeParameters, typeParamNodes);
11071
11128
  if ((0, typeUtils_1.isTypeAliasRecursive)(typeAliasTypeVar, aliasType)) {
11072
11129
  addDiagnostic(AnalyzerNodeInfo.getFileInfo(valueNode).diagnosticRuleSet.reportGeneralTypeIssues, diagnosticRules_1.DiagnosticRule.reportGeneralTypeIssues, localize_1.Localizer.Diagnostic.typeAliasIsRecursiveDirect().format({
11073
11130
  name: nameNode.value,
@@ -11128,7 +11185,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11128
11185
  if (fileInfo.isStubFile) {
11129
11186
  classFlags |= 8388608 /* ClassTypeFlags.DefinedInStub */;
11130
11187
  }
11131
- const classType = types_1.ClassType.createInstantiable(node.name.value, ParseTreeUtils.getClassFullName(node, fileInfo.moduleName, node.name.value), fileInfo.moduleName, fileInfo.filePath, classFlags,
11188
+ const classType = types_1.ClassType.createInstantiable(node.name.value, ParseTreeUtils.getClassFullName(node, fileInfo.moduleName, node.name.value), fileInfo.moduleName, fileInfo.fileUri, classFlags,
11132
11189
  /* typeSourceId */ 0,
11133
11190
  /* declaredMetaclass */ undefined,
11134
11191
  /* effectiveMetaclass */ undefined, ParseTreeUtils.getDocString(node.suite.statements));
@@ -11150,6 +11207,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11150
11207
  setSymbolResolutionPartialType(classSymbol, classDecl, classType);
11151
11208
  }
11152
11209
  classType.details.flags |= 131072 /* ClassTypeFlags.PartiallyEvaluated */;
11210
+ classType.details.declaration = classDecl;
11153
11211
  try {
11154
11212
  writeTypeCache(node, { type: classType }, /* flags */ undefined);
11155
11213
  writeTypeCache(node.name, { type: classType }, /* flags */ undefined);
@@ -11669,7 +11727,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11669
11727
  // Replace all of the type parameters with invariant TypeVars.
11670
11728
  const updatedTypeParams = classType.details.typeParameters.map((typeParam) => types_1.TypeVarType.cloneAsInvariant(typeParam));
11671
11729
  const updatedClassType = types_1.ClassType.cloneWithNewTypeParameters(classType, updatedTypeParams);
11672
- const dummyTypeObject = types_1.ClassType.createInstantiable('__varianceDummy', '', '', '', 0, 0, undefined, undefined);
11730
+ const dummyTypeObject = types_1.ClassType.createInstantiable('__varianceDummy', '', '', uri_1.Uri.empty(), 0, 0, undefined, undefined);
11673
11731
  updatedTypeParams.forEach((param, paramIndex) => {
11674
11732
  // Skip variadics and ParamSpecs.
11675
11733
  if (param.details.isVariadic || param.details.isParamSpec) {
@@ -11952,7 +12010,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
11952
12010
  if (diag && initSubclassDecl) {
11953
12011
  diag.addRelatedInfo(localize_1.Localizer.DiagnosticAddendum.initSubclassLocation().format({
11954
12012
  name: printType((0, typeUtils_1.convertToInstance)(initSubclassMethodInfo.classType)),
11955
- }), initSubclassDecl.path, initSubclassDecl.range);
12013
+ }), initSubclassDecl.uri, initSubclassDecl.range);
11956
12014
  }
11957
12015
  }
11958
12016
  }
@@ -12747,7 +12805,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
12747
12805
  // This eliminates any "partially unknown" errors in strict mode
12748
12806
  // in the common case.
12749
12807
  const sendType = isYieldResultUsed ? types_1.UnknownType.create() : types_1.AnyType.create();
12750
- typeArgs.push(inferredYieldType, sendType, (0, types_1.isNever)(inferredReturnType) ? getNoneType() : inferredReturnType);
12808
+ typeArgs.push(inferredYieldType, sendType, inferredReturnType);
12751
12809
  if (useAwaitableGenerator) {
12752
12810
  typeArgs.push(types_1.AnyType.create());
12753
12811
  }
@@ -12981,7 +13039,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
12981
13039
  (0, debug_1.assert)(!parentNode.isWildcardImport);
12982
13040
  const importInfo = AnalyzerNodeInfo.getImportInfo(parentNode.module);
12983
13041
  if (importInfo && importInfo.isImportFound && !importInfo.isNativeLib) {
12984
- const resolvedPath = importInfo.resolvedPaths[importInfo.resolvedPaths.length - 1];
13042
+ const resolvedPath = importInfo.resolvedUris[importInfo.resolvedUris.length - 1];
12985
13043
  const importLookupInfo = importLookup(resolvedPath);
12986
13044
  let reportError = false;
12987
13045
  // If we were able to resolve the import, report the error as
@@ -13001,7 +13059,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
13001
13059
  }
13002
13060
  }
13003
13061
  }
13004
- else if (!resolvedPath) {
13062
+ else if (resolvedPath.isEmpty()) {
13005
13063
  // This corresponds to the "from . import a" form.
13006
13064
  reportError = true;
13007
13065
  }
@@ -14404,13 +14462,13 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
14404
14462
  if (namePartIndex >= 0 &&
14405
14463
  importInfo &&
14406
14464
  !importInfo.isNativeLib &&
14407
- namePartIndex < importInfo.resolvedPaths.length) {
14408
- if (importInfo.resolvedPaths[namePartIndex]) {
14465
+ namePartIndex < importInfo.resolvedUris.length) {
14466
+ if (importInfo.resolvedUris[namePartIndex]) {
14409
14467
  evaluateTypesForStatement(node);
14410
14468
  // Synthesize an alias declaration for this name part. The only
14411
14469
  // time this case is used is for IDE services such as
14412
14470
  // the find all references, hover provider and etc.
14413
- declarations.push((0, declarationUtils_1.createSynthesizedAliasDeclaration)(importInfo.resolvedPaths[namePartIndex]));
14471
+ declarations.push((0, declarationUtils_1.createSynthesizedAliasDeclaration)(importInfo.resolvedUris[namePartIndex]));
14414
14472
  }
14415
14473
  }
14416
14474
  }
@@ -14723,8 +14781,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
14723
14781
  return evaluatorOptions.evaluateUnknownImportsAsAny ? types_1.AnyType.create() : types_1.UnknownType.create();
14724
14782
  }
14725
14783
  function applyLoaderActionsToModuleType(moduleType, loaderActions, importLookup) {
14726
- if (loaderActions.path && loaderActions.loadSymbolsFromPath) {
14727
- const lookupResults = importLookup(loaderActions.path);
14784
+ if (!loaderActions.uri.isEmpty() && loaderActions.loadSymbolsFromPath) {
14785
+ const lookupResults = importLookup(loaderActions.uri);
14728
14786
  if (lookupResults) {
14729
14787
  moduleType.fields = lookupResults.symbolTable;
14730
14788
  moduleType.docString = lookupResults.docString;
@@ -14747,7 +14805,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
14747
14805
  }
14748
14806
  else {
14749
14807
  const moduleName = moduleType.moduleName ? moduleType.moduleName + '.' + name : '';
14750
- const importedModuleType = types_1.ModuleType.create(moduleName, implicitImport.path);
14808
+ const importedModuleType = types_1.ModuleType.create(moduleName, implicitImport.uri);
14751
14809
  symbolType = applyLoaderActionsToModuleType(importedModuleType, implicitImport, importLookup);
14752
14810
  }
14753
14811
  const importedModuleSymbol = symbol_1.Symbol.createWithType(0 /* SymbolFlags.None */, symbolType);
@@ -14762,7 +14820,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
14762
14820
  if (resolvedDecl.type === 8 /* DeclarationType.Alias */) {
14763
14821
  // Build a module type that corresponds to the declaration and
14764
14822
  // its associated loader actions.
14765
- const moduleType = types_1.ModuleType.create(resolvedDecl.moduleName, resolvedDecl.path);
14823
+ const moduleType = types_1.ModuleType.create(resolvedDecl.moduleName, resolvedDecl.uri);
14766
14824
  if (resolvedDecl.symbolName && resolvedDecl.submoduleFallback) {
14767
14825
  return applyLoaderActionsToModuleType(moduleType, resolvedDecl.submoduleFallback, importLookup);
14768
14826
  }
@@ -14856,7 +14914,8 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
14856
14914
  // (but not an ellipsis).
14857
14915
  if (isLegalImplicitTypeAliasType(inferredType)) {
14858
14916
  inferredType = transformTypeForTypeAlias(inferredType, resolvedDecl.typeAliasName, resolvedDecl.node,
14859
- /* isPep695Syntax */ false);
14917
+ /* isPep695Syntax */ false,
14918
+ /* isPep695TypeVarType */ false);
14860
14919
  isUnambiguousType = true;
14861
14920
  }
14862
14921
  }
@@ -15304,7 +15363,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15304
15363
  var _a;
15305
15364
  let returnType;
15306
15365
  let isIncomplete = false;
15307
- let analyzeUnannotatedFunctions = true;
15366
+ const analyzeUnannotatedFunctions = true;
15308
15367
  // Don't attempt to infer the return type for a stub file.
15309
15368
  if (types_1.FunctionType.isStubDefinition(type)) {
15310
15369
  return types_1.UnknownType.create();
@@ -15327,10 +15386,10 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15327
15386
  }
15328
15387
  else if (type.details.declaration) {
15329
15388
  const functionNode = type.details.declaration.node;
15330
- analyzeUnannotatedFunctions =
15331
- AnalyzerNodeInfo.getFileInfo(functionNode).diagnosticRuleSet.analyzeUnannotatedFunctions;
15389
+ const skipUnannotatedFunction = !AnalyzerNodeInfo.getFileInfo(functionNode).diagnosticRuleSet.analyzeUnannotatedFunctions &&
15390
+ ParseTreeUtils.isUnannotatedFunction(functionNode);
15332
15391
  // Skip return type inference if we are in "skip unannotated function" mode.
15333
- if (analyzeUnannotatedFunctions && !checkCodeFlowTooComplex(functionNode.suite)) {
15392
+ if (!skipUnannotatedFunction && !checkCodeFlowTooComplex(functionNode.suite)) {
15334
15393
  const codeFlowComplexity = AnalyzerNodeInfo.getCodeFlowComplexity(functionNode);
15335
15394
  // For very complex functions that have no annotated parameter types,
15336
15395
  // don't attempt to infer the return type because it can be extremely
@@ -15760,11 +15819,12 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15760
15819
  // the length of the src type arguments list if the dest or source contain
15761
15820
  // entries with indeterminate length or variadic entries. It returns true
15762
15821
  // 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));
15822
+ function adjustTupleTypeArgs(destTypeArgs, srcTypeArgs, flags) {
15823
+ const destUnboundedOrVariadicIndex = destTypeArgs.findIndex((t) => t.isUnbounded || (0, types_1.isVariadicTypeVar)(t.type));
15765
15824
  const srcUnboundedIndex = srcTypeArgs.findIndex((t) => t.isUnbounded);
15825
+ const srcVariadicIndex = srcTypeArgs.findIndex((t) => (0, types_1.isVariadicTypeVar)(t.type));
15766
15826
  // If the src contains an unbounded type but the dest does not, it's incompatible.
15767
- if (srcUnboundedIndex >= 0 && destUnboundedIndex < 0) {
15827
+ if (srcUnboundedIndex >= 0 && destUnboundedOrVariadicIndex < 0) {
15768
15828
  return false;
15769
15829
  }
15770
15830
  if (srcUnboundedIndex >= 0) {
@@ -15782,36 +15842,64 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15782
15842
  while (destTypeArgs.length > srcTypeArgs.length && destTypeArgs[destTypeArgs.length - 1].isOptional) {
15783
15843
  destTypeArgs.splice(destTypeArgs.length - 1, 1);
15784
15844
  }
15785
- const srcArgsToCapture = srcTypeArgs.length - destTypeArgs.length + 1;
15786
- if (destUnboundedIndex >= 0 && srcArgsToCapture >= 0) {
15787
- // If the dest contains a variadic element, determine which source
15788
- // args map to this element and package them up into an unpacked tuple.
15789
- if ((0, types_1.isVariadicTypeVar)(destTypeArgs[destUnboundedIndex].type)) {
15790
- if (tupleClassType && (0, types_1.isInstantiableClass)(tupleClassType)) {
15791
- const removedArgs = srcTypeArgs.splice(destUnboundedIndex, srcArgsToCapture);
15845
+ if (srcVariadicIndex >= 0) {
15846
+ const destArgsToCapture = destTypeArgs.length - srcTypeArgs.length + 1;
15847
+ // If we're doing reverse type mappings and the source contains a variadic
15848
+ // TypeVar, we need to adjust the dest so the reverse type mapping assignment
15849
+ // can be performed.
15850
+ if (destArgsToCapture >= 0 && (flags & 2 /* AssignTypeFlags.ReverseTypeVarMatching */) !== 0) {
15851
+ // If the only removed arg from the dest type args is itself a variadic,
15852
+ // don't bother adjusting it.
15853
+ const skipAdjustment = destArgsToCapture === 1 && (0, types_1.isVariadicTypeVar)(destTypeArgs[srcVariadicIndex].type);
15854
+ if (!skipAdjustment && tupleClassType && (0, types_1.isInstantiableClass)(tupleClassType)) {
15855
+ const removedArgs = destTypeArgs.splice(srcVariadicIndex, destArgsToCapture);
15792
15856
  // Package up the remaining type arguments into a tuple object.
15793
15857
  const variadicTuple = (0, typeUtils_1.convertToInstance)((0, typeUtils_1.specializeTupleClass)(tupleClassType, removedArgs.map((typeArg) => {
15794
15858
  return { type: typeArg.type, isUnbounded: typeArg.isUnbounded };
15795
15859
  }),
15796
15860
  /* isTypeArgumentExplicit */ true,
15797
15861
  /* isUnpackedTuple */ true));
15798
- srcTypeArgs.splice(destUnboundedIndex, 0, {
15862
+ destTypeArgs.splice(srcVariadicIndex, 0, {
15799
15863
  type: variadicTuple,
15800
15864
  isUnbounded: false,
15801
15865
  });
15802
15866
  }
15803
15867
  }
15804
- else {
15805
- const removedArgTypes = srcTypeArgs.splice(destUnboundedIndex, srcArgsToCapture).map((t) => {
15806
- if ((0, types_1.isTypeVar)(t.type) && (0, types_1.isUnpackedVariadicTypeVar)(t.type) && !t.type.isVariadicInUnion) {
15807
- return types_1.TypeVarType.cloneForUnpacked(t.type, /* isInUnion */ true);
15868
+ }
15869
+ else {
15870
+ const srcArgsToCapture = srcTypeArgs.length - destTypeArgs.length + 1;
15871
+ if (destUnboundedOrVariadicIndex >= 0 && srcArgsToCapture >= 0) {
15872
+ // If the dest contains a variadic element, determine which source
15873
+ // args map to this element and package them up into an unpacked tuple.
15874
+ if ((0, types_1.isVariadicTypeVar)(destTypeArgs[destUnboundedOrVariadicIndex].type)) {
15875
+ if (tupleClassType && (0, types_1.isInstantiableClass)(tupleClassType)) {
15876
+ const removedArgs = srcTypeArgs.splice(destUnboundedOrVariadicIndex, srcArgsToCapture);
15877
+ // Package up the remaining type arguments into a tuple object.
15878
+ const variadicTuple = (0, typeUtils_1.convertToInstance)((0, typeUtils_1.specializeTupleClass)(tupleClassType, removedArgs.map((typeArg) => {
15879
+ return { type: typeArg.type, isUnbounded: typeArg.isUnbounded };
15880
+ }),
15881
+ /* isTypeArgumentExplicit */ true,
15882
+ /* isUnpackedTuple */ true));
15883
+ srcTypeArgs.splice(destUnboundedOrVariadicIndex, 0, {
15884
+ type: variadicTuple,
15885
+ isUnbounded: false,
15886
+ });
15808
15887
  }
15809
- return t.type;
15810
- });
15811
- srcTypeArgs.splice(destUnboundedIndex, 0, {
15812
- type: removedArgTypes.length > 0 ? (0, types_1.combineTypes)(removedArgTypes) : types_1.AnyType.create(),
15813
- isUnbounded: false,
15814
- });
15888
+ }
15889
+ else {
15890
+ const removedArgTypes = srcTypeArgs
15891
+ .splice(destUnboundedOrVariadicIndex, srcArgsToCapture)
15892
+ .map((t) => {
15893
+ if ((0, types_1.isTypeVar)(t.type) && (0, types_1.isUnpackedVariadicTypeVar)(t.type) && !t.type.isVariadicInUnion) {
15894
+ return types_1.TypeVarType.cloneForUnpacked(t.type, /* isInUnion */ true);
15895
+ }
15896
+ return t.type;
15897
+ });
15898
+ srcTypeArgs.splice(destUnboundedOrVariadicIndex, 0, {
15899
+ type: removedArgTypes.length > 0 ? (0, types_1.combineTypes)(removedArgTypes) : types_1.AnyType.create(),
15900
+ isUnbounded: false,
15901
+ });
15902
+ }
15815
15903
  }
15816
15904
  }
15817
15905
  return destTypeArgs.length === srcTypeArgs.length;
@@ -15820,8 +15908,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
15820
15908
  var _a, _b;
15821
15909
  const destTypeArgs = [...((_a = destType.tupleTypeArguments) !== null && _a !== void 0 ? _a : [])];
15822
15910
  const srcTypeArgs = [...((_b = srcType.tupleTypeArguments) !== null && _b !== void 0 ? _b : [])];
15823
- const reverseMapping = (flags & 2 /* AssignTypeFlags.ReverseTypeVarMatching */) !== 0;
15824
- if (adjustSrcTupleTypeArgs(reverseMapping ? srcTypeArgs : destTypeArgs, reverseMapping ? destTypeArgs : srcTypeArgs)) {
15911
+ if (adjustTupleTypeArgs(destTypeArgs, srcTypeArgs, flags)) {
15825
15912
  for (let argIndex = 0; argIndex < srcTypeArgs.length; argIndex++) {
15826
15913
  const entryDiag = diag === null || diag === void 0 ? void 0 : diag.createAddendum();
15827
15914
  if (!assignType(destTypeArgs[argIndex].type, srcTypeArgs[argIndex].type, entryDiag === null || entryDiag === void 0 ? void 0 : entryDiag.createAddendum(), destTypeVarContext, srcTypeVarContext, flags, recursionCount)) {
@@ -16021,6 +16108,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16021
16108
  else if (types_1.ClassType.isBuiltIn(destType, 'list')) {
16022
16109
  childDiag.addMessage(localize_1.Localizer.DiagnosticAddendum.invariantSuggestionList());
16023
16110
  }
16111
+ else if (types_1.ClassType.isBuiltIn(destType, 'set')) {
16112
+ childDiag.addMessage(localize_1.Localizer.DiagnosticAddendum.invariantSuggestionSet());
16113
+ }
16024
16114
  }
16025
16115
  }
16026
16116
  else {
@@ -16337,7 +16427,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16337
16427
  // PEP 544 says that if the dest type is a type[Proto] class,
16338
16428
  // the source must be a "concrete" (non-protocol) class.
16339
16429
  if (types_1.ClassType.isProtocolClass(destType) &&
16340
- (flags & 4096 /* AssignTypeFlags.IgnoreProtocolAssignmentCheck */) === 0) {
16430
+ (flags & 8192 /* AssignTypeFlags.IgnoreProtocolAssignmentCheck */) === 0) {
16341
16431
  if (types_1.ClassType.isProtocolClass(expandedSrcType) &&
16342
16432
  (0, types_1.isInstantiableClass)(srcType) &&
16343
16433
  !srcType.includeSubclasses) {
@@ -16621,7 +16711,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
16621
16711
  let canUseFastPath = true;
16622
16712
  // First attempt to match all of the non-generic types in the dest
16623
16713
  // to non-generic types in the source.
16624
- destType.subtypes.forEach((destSubtype) => {
16714
+ (0, typeUtils_1.sortTypes)(destType.subtypes).forEach((destSubtype) => {
16625
16715
  if ((0, typeUtils_1.requiresSpecialization)(destSubtype)) {
16626
16716
  remainingDestSubtypes.push(destSubtype);
16627
16717
  }
@@ -17129,7 +17219,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17129
17219
  }
17130
17220
  }
17131
17221
  function assignFunction(destType, srcType, diag, destTypeVarContext, srcTypeVarContext, flags, recursionCount) {
17132
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
17222
+ var _a, _b, _c, _d, _e, _f, _g, _h;
17133
17223
  let canAssign = true;
17134
17224
  const checkReturnType = (flags & 32 /* AssignTypeFlags.SkipFunctionReturnTypeCheck */) === 0;
17135
17225
  const reverseMatching = (flags & 2 /* AssignTypeFlags.ReverseTypeVarMatching */) !== 0;
@@ -17140,19 +17230,23 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17140
17230
  const srcParamDetails = (0, parameterUtils_1.getParameterListDetails)(srcType);
17141
17231
  adjustSourceParamDetailsForDestVariadic(reverseMatching ? destParamDetails : srcParamDetails, reverseMatching ? srcParamDetails : destParamDetails);
17142
17232
  const targetIncludesParamSpec = reverseMatching ? !!srcType.details.paramSpec : !!destType.details.paramSpec;
17143
- const destPositionalCount = (_b = (_a = destParamDetails.argsIndex) !== null && _a !== void 0 ? _a : destParamDetails.firstKeywordOnlyIndex) !== null && _b !== void 0 ? _b : destParamDetails.params.length;
17144
- const srcPositionalCount = (_d = (_c = srcParamDetails.argsIndex) !== null && _c !== void 0 ? _c : srcParamDetails.firstKeywordOnlyIndex) !== null && _d !== void 0 ? _d : srcParamDetails.params.length;
17233
+ const destPositionalCount = (_a = destParamDetails.firstKeywordOnlyIndex) !== null && _a !== void 0 ? _a : destParamDetails.params.length;
17234
+ const srcPositionalCount = (_b = srcParamDetails.firstKeywordOnlyIndex) !== null && _b !== void 0 ? _b : srcParamDetails.params.length;
17145
17235
  const positionalsToMatch = Math.min(destPositionalCount, srcPositionalCount);
17146
17236
  // Match positional parameters.
17147
17237
  for (let paramIndex = 0; paramIndex < positionalsToMatch; paramIndex++) {
17238
+ // Skip over the *args parameter since it's handled separately below.
17239
+ if (paramIndex === destParamDetails.argsIndex) {
17240
+ continue;
17241
+ }
17148
17242
  const destParam = destParamDetails.params[paramIndex];
17149
17243
  const srcParam = srcParamDetails.params[paramIndex];
17150
17244
  // Find the original index of this source param. If we synthesized it above (for
17151
17245
  // a variadic parameter), it may not be found.
17152
17246
  const srcParamType = srcParam.type;
17153
17247
  const destParamType = destParam.type;
17154
- const destParamName = (_e = destParam.param.name) !== null && _e !== void 0 ? _e : '';
17155
- const srcParamName = (_f = srcParam.param.name) !== null && _f !== void 0 ? _f : '';
17248
+ const destParamName = (_c = destParam.param.name) !== null && _c !== void 0 ? _c : '';
17249
+ const srcParamName = (_d = srcParam.param.name) !== null && _d !== void 0 ? _d : '';
17156
17250
  if (destParamName && !(0, symbolNameUtils_1.isPrivateOrProtectedName)(destParamName) && !(0, symbolNameUtils_1.isPrivateOrProtectedName)(srcParamName)) {
17157
17251
  const isDestPositionalOnly = destParam.source === parameterUtils_1.ParameterSource.PositionOnly;
17158
17252
  if (!isDestPositionalOnly &&
@@ -17166,7 +17260,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17166
17260
  canAssign = false;
17167
17261
  }
17168
17262
  }
17169
- if (!!destParam.param.hasDefault && !srcParam.param.hasDefault) {
17263
+ if (!!destParam.param.hasDefault &&
17264
+ !srcParam.param.hasDefault &&
17265
+ paramIndex !== srcParamDetails.argsIndex) {
17170
17266
  diag === null || diag === void 0 ? void 0 : diag.createAddendum().addMessage(localize_1.Localizer.DiagnosticAddendum.functionParamDefaultMissing().format({
17171
17267
  name: srcParamName,
17172
17268
  }));
@@ -17240,6 +17336,9 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17240
17336
  // *args parameter type.
17241
17337
  const srcArgsType = srcParamDetails.params[srcParamDetails.argsIndex].type;
17242
17338
  for (let paramIndex = srcPositionalCount; paramIndex < destPositionalCount; paramIndex++) {
17339
+ if (paramIndex === srcParamDetails.argsIndex) {
17340
+ continue;
17341
+ }
17243
17342
  const destParamType = destParamDetails.params[paramIndex].type;
17244
17343
  if ((0, types_1.isVariadicTypeVar)(destParamType) && !(0, types_1.isVariadicTypeVar)(srcArgsType)) {
17245
17344
  diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.typeVarTupleRequiresKnownLength());
@@ -17252,7 +17351,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17252
17351
  if (destParamDetails.params[paramIndex].source !== parameterUtils_1.ParameterSource.PositionOnly &&
17253
17352
  srcParamDetails.kwargsIndex === undefined) {
17254
17353
  diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.namedParamMissingInSource().format({
17255
- name: (_g = destParamDetails.params[paramIndex].param.name) !== null && _g !== void 0 ? _g : '',
17354
+ name: (_e = destParamDetails.params[paramIndex].param.name) !== null && _e !== void 0 ? _e : '',
17256
17355
  }));
17257
17356
  canAssign = false;
17258
17357
  }
@@ -17260,11 +17359,19 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17260
17359
  }
17261
17360
  }
17262
17361
  else if (!srcParamDetails.paramSpec) {
17263
- diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.functionTooManyParams().format({
17264
- expected: srcPositionalCount,
17265
- received: destPositionalCount,
17266
- }));
17267
- canAssign = false;
17362
+ // If the dest contains a *args, remove it from the positional count
17363
+ // because it's OK for zero source args to match it.
17364
+ let adjDestPositionalCount = destPositionalCount;
17365
+ if (destParamDetails.argsIndex !== undefined && destParamDetails.argsIndex < destPositionalCount) {
17366
+ adjDestPositionalCount--;
17367
+ }
17368
+ if (srcPositionalCount < adjDestPositionalCount) {
17369
+ diag === null || diag === void 0 ? void 0 : diag.addMessage(localize_1.Localizer.DiagnosticAddendum.functionTooManyParams().format({
17370
+ expected: srcPositionalCount,
17371
+ received: destPositionalCount,
17372
+ }));
17373
+ canAssign = false;
17374
+ }
17268
17375
  }
17269
17376
  }
17270
17377
  // If both src and dest have an "*args" parameter, make sure
@@ -17296,7 +17403,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17296
17403
  destParamDetails.argsIndex !== undefined &&
17297
17404
  !destParamDetails.hasUnpackedVariadicTypeVar) {
17298
17405
  diag === null || diag === void 0 ? void 0 : diag.createAddendum().addMessage(localize_1.Localizer.DiagnosticAddendum.argsParamMissing().format({
17299
- paramName: (_h = destParamDetails.params[destParamDetails.argsIndex].param.name) !== null && _h !== void 0 ? _h : '',
17406
+ paramName: (_f = destParamDetails.params[destParamDetails.argsIndex].param.name) !== null && _f !== void 0 ? _f : '',
17300
17407
  }));
17301
17408
  canAssign = false;
17302
17409
  }
@@ -17407,7 +17514,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
17407
17514
  // If the source and the dest are using the same ParamSpec, any additional
17408
17515
  // concatenated parameters must match.
17409
17516
  if (targetIncludesParamSpec &&
17410
- ((_j = srcType.details.paramSpec) === null || _j === void 0 ? void 0 : _j.nameWithScope) === ((_k = destType.details.paramSpec) === null || _k === void 0 ? void 0 : _k.nameWithScope)) {
17517
+ ((_g = srcType.details.paramSpec) === null || _g === void 0 ? void 0 : _g.nameWithScope) === ((_h = destType.details.paramSpec) === null || _h === void 0 ? void 0 : _h.nameWithScope)) {
17411
17518
  if (srcParamDetails.params.length !== destParamDetails.params.length) {
17412
17519
  canAssign = false;
17413
17520
  }
@@ -18249,7 +18356,7 @@ function createTypeEvaluator(importLookup, evaluatorOptions) {
18249
18356
  }
18250
18357
  }
18251
18358
  else if (!assignType(memberTypeFirstParamType, firstParamType, diag === null || diag === void 0 ? void 0 : diag.createAddendum(), typeVarContext,
18252
- /* srcTypeVarContext */ undefined, 2048 /* AssignTypeFlags.AllowUnspecifiedTypeArguments */, recursionCount)) {
18359
+ /* srcTypeVarContext */ undefined, 4096 /* AssignTypeFlags.AllowUnspecifiedTypeArguments */, recursionCount)) {
18253
18360
  if (memberTypeFirstParam.name &&
18254
18361
  !memberTypeFirstParam.isNameSynthesized &&
18255
18362
  memberTypeFirstParam.hasDeclaredType) {