@zzzen/pyright-internal 1.1.255 → 1.2.0-beta

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 (1409) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/dist/analyzer/analyzerFileInfo.d.ts +1 -1
  4. package/dist/analyzer/backgroundAnalysisProgram.d.ts +1 -0
  5. package/dist/analyzer/backgroundAnalysisProgram.js +3 -0
  6. package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
  7. package/dist/analyzer/binder.js +9 -2
  8. package/dist/analyzer/binder.js.map +1 -1
  9. package/dist/analyzer/checker.js +19 -26
  10. package/dist/analyzer/checker.js.map +1 -1
  11. package/dist/analyzer/codeFlowUtils.js +33 -0
  12. package/dist/analyzer/codeFlowUtils.js.map +1 -1
  13. package/dist/analyzer/dataClasses.js +6 -4
  14. package/dist/analyzer/dataClasses.js.map +1 -1
  15. package/dist/analyzer/declaration.js +11 -1
  16. package/dist/analyzer/declaration.js.map +1 -1
  17. package/dist/analyzer/importResult.js +7 -0
  18. package/dist/analyzer/importResult.js.map +1 -1
  19. package/dist/analyzer/importStatementUtils.js +10 -1
  20. package/dist/analyzer/importStatementUtils.js.map +1 -1
  21. package/dist/analyzer/namedTuples.js +1 -1
  22. package/dist/analyzer/namedTuples.js.map +1 -1
  23. package/dist/analyzer/packageTypeReport.js +10 -1
  24. package/dist/analyzer/packageTypeReport.js.map +1 -1
  25. package/dist/analyzer/parseTreeUtils.js +11 -2
  26. package/dist/analyzer/parseTreeUtils.js.map +1 -1
  27. package/dist/analyzer/program.d.ts +2 -1
  28. package/dist/analyzer/program.js +27 -23
  29. package/dist/analyzer/program.js.map +1 -1
  30. package/dist/analyzer/protocols.js +3 -1
  31. package/dist/analyzer/protocols.js.map +1 -1
  32. package/dist/analyzer/scope.js +22 -1
  33. package/dist/analyzer/scope.js.map +1 -1
  34. package/dist/analyzer/service.d.ts +20 -8
  35. package/dist/analyzer/service.js +39 -19
  36. package/dist/analyzer/service.js.map +1 -1
  37. package/dist/analyzer/sourceFile.js +1 -1
  38. package/dist/analyzer/sourceFile.js.map +1 -1
  39. package/dist/analyzer/sourceFileInfoUtils.d.ts +2 -0
  40. package/dist/analyzer/sourceFileInfoUtils.js +15 -0
  41. package/dist/analyzer/sourceFileInfoUtils.js.map +1 -0
  42. package/dist/analyzer/symbol.d.ts +3 -1
  43. package/dist/analyzer/symbol.js +39 -1
  44. package/dist/analyzer/symbol.js.map +1 -1
  45. package/dist/analyzer/typeDocStringUtils.js +10 -2
  46. package/dist/analyzer/typeDocStringUtils.js.map +1 -1
  47. package/dist/analyzer/typeEvaluator.js +86 -32
  48. package/dist/analyzer/typeEvaluator.js.map +1 -1
  49. package/dist/analyzer/typeEvaluatorTypes.d.ts +0 -1
  50. package/dist/analyzer/typeEvaluatorTypes.js +65 -1
  51. package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
  52. package/dist/analyzer/typeGuards.d.ts +2 -0
  53. package/dist/analyzer/typeGuards.js +113 -69
  54. package/dist/analyzer/typeGuards.js.map +1 -1
  55. package/dist/analyzer/typePrinter.js +23 -1
  56. package/dist/analyzer/typePrinter.js.map +1 -1
  57. package/dist/analyzer/typeUtils.js +119 -28
  58. package/dist/analyzer/typeUtils.js.map +1 -1
  59. package/dist/analyzer/typedDicts.js +2 -1
  60. package/dist/analyzer/typedDicts.js.map +1 -1
  61. package/dist/analyzer/types.d.ts +1 -0
  62. package/dist/analyzer/types.js +195 -1
  63. package/dist/analyzer/types.js.map +1 -1
  64. package/dist/backgroundAnalysisBase.d.ts +1 -1
  65. package/dist/commands/commands.js +9 -0
  66. package/dist/commands/commands.js.map +1 -1
  67. package/dist/common/commandLineOptions.js +8 -1
  68. package/dist/common/commandLineOptions.js.map +1 -1
  69. package/dist/common/core.js +7 -1
  70. package/dist/common/core.js.map +1 -1
  71. package/dist/common/diagnostic.js +9 -1
  72. package/dist/common/diagnostic.js.map +1 -1
  73. package/dist/common/host.js +7 -1
  74. package/dist/common/host.js.map +1 -1
  75. package/dist/common/pathUtils.d.ts +1 -0
  76. package/dist/common/pathUtils.js +34 -1
  77. package/dist/common/pathUtils.js.map +1 -1
  78. package/dist/common/stringUtils.d.ts +1 -0
  79. package/dist/common/stringUtils.js +8 -1
  80. package/dist/common/stringUtils.js.map +1 -1
  81. package/dist/languageServerBase.d.ts +10 -3
  82. package/dist/languageServerBase.js +40 -14
  83. package/dist/languageServerBase.js.map +1 -1
  84. package/dist/languageService/analyzerServiceExecutor.js +3 -0
  85. package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
  86. package/dist/languageService/autoImporter.js +2 -1
  87. package/dist/languageService/autoImporter.js.map +1 -1
  88. package/dist/languageService/completionProvider.d.ts +2 -2
  89. package/dist/languageService/completionProvider.js +3 -5
  90. package/dist/languageService/completionProvider.js.map +1 -1
  91. package/dist/parser/parseNodes.d.ts +3 -0
  92. package/dist/parser/parseNodes.js +110 -2
  93. package/dist/parser/parseNodes.js.map +1 -1
  94. package/dist/parser/parser.d.ts +0 -1
  95. package/dist/parser/parser.js +26 -12
  96. package/dist/parser/parser.js.map +1 -1
  97. package/dist/parser/stringTokenUtils.js +8 -1
  98. package/dist/parser/stringTokenUtils.js.map +1 -1
  99. package/dist/parser/tokenizerTypes.js +155 -1
  100. package/dist/parser/tokenizerTypes.js.map +1 -1
  101. package/dist/pyright.js +6 -1
  102. package/dist/pyright.js.map +1 -1
  103. package/dist/tests/chainedSourceFiles.test.js +12 -9
  104. package/dist/tests/chainedSourceFiles.test.js.map +1 -1
  105. package/dist/tests/checker.test.js +4 -0
  106. package/dist/tests/checker.test.js.map +1 -1
  107. package/dist/tests/config.test.js +14 -13
  108. package/dist/tests/config.test.js.map +1 -1
  109. package/dist/tests/debug.test.js +6 -0
  110. package/dist/tests/debug.test.js.map +1 -1
  111. package/dist/tests/fourslash/completions.autoimport.lib.alias.fourslash.d.ts +1 -0
  112. package/dist/tests/fourslash/completions.autoimport.lib.alias.fourslash.js +53 -0
  113. package/dist/tests/fourslash/completions.autoimport.lib.alias.fourslash.js.map +1 -0
  114. package/dist/tests/fourslash/fourslash.d.ts +16 -0
  115. package/dist/tests/fourslash/hover.class.docString.fourslash.d.ts +1 -0
  116. package/dist/tests/fourslash/hover.class.docString.fourslash.js +24 -0
  117. package/dist/tests/fourslash/hover.class.docString.fourslash.js.map +1 -0
  118. package/dist/tests/harness/fourslash/fourSlashParser.js +6 -0
  119. package/dist/tests/harness/fourslash/fourSlashParser.js.map +1 -1
  120. package/dist/tests/harness/fourslash/fourSlashTypes.js +19 -1
  121. package/dist/tests/harness/fourslash/fourSlashTypes.js.map +1 -1
  122. package/dist/tests/harness/fourslash/testLanguageService.js +9 -1
  123. package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
  124. package/dist/tests/harness/fourslash/testState.Consts.d.ts +1 -0
  125. package/dist/tests/harness/fourslash/testState.Consts.js +1 -0
  126. package/dist/tests/harness/fourslash/testState.Consts.js.map +1 -1
  127. package/dist/tests/harness/fourslash/testState.d.ts +4 -3
  128. package/dist/tests/harness/fourslash/testState.js +27 -11
  129. package/dist/tests/harness/fourslash/testState.js.map +1 -1
  130. package/dist/tests/harness/vfs/pathValidation.js +25 -1
  131. package/dist/tests/harness/vfs/pathValidation.js.map +1 -1
  132. package/dist/tests/pathUtils.test.js +17 -0
  133. package/dist/tests/pathUtils.test.js.map +1 -1
  134. package/dist/tests/testUtils.js +1 -1
  135. package/dist/tests/testUtils.js.map +1 -1
  136. package/dist/tests/typeEvaluator1.test.js +9 -1
  137. package/dist/tests/typeEvaluator1.test.js.map +1 -1
  138. package/dist/tests/typeEvaluator2.test.js +9 -1
  139. package/dist/tests/typeEvaluator2.test.js.map +1 -1
  140. package/dist/tests/typeEvaluator3.test.js +4 -0
  141. package/dist/tests/typeEvaluator3.test.js.map +1 -1
  142. package/dist/workspaceMap.d.ts +2 -1
  143. package/dist/workspaceMap.js +25 -3
  144. package/dist/workspaceMap.js.map +1 -1
  145. package/package.json +45 -45
  146. package/src/analyzer/aliasDeclarationUtils.ts +0 -169
  147. package/src/analyzer/analysis.ts +0 -92
  148. package/src/analyzer/analyzerFileInfo.ts +0 -56
  149. package/src/analyzer/analyzerNodeInfo.ts +0 -198
  150. package/src/analyzer/backgroundAnalysisProgram.ts +0 -311
  151. package/src/analyzer/binder.ts +0 -4081
  152. package/src/analyzer/checker.ts +0 -5507
  153. package/src/analyzer/circularDependency.ts +0 -52
  154. package/src/analyzer/codeFlowEngine.ts +0 -1548
  155. package/src/analyzer/codeFlowTypes.ts +0 -266
  156. package/src/analyzer/codeFlowUtils.ts +0 -436
  157. package/src/analyzer/commentUtils.ts +0 -174
  158. package/src/analyzer/constraintSolver.ts +0 -926
  159. package/src/analyzer/constructorTransform.ts +0 -317
  160. package/src/analyzer/dataClasses.ts +0 -999
  161. package/src/analyzer/declaration.ts +0 -252
  162. package/src/analyzer/declarationUtils.ts +0 -238
  163. package/src/analyzer/docStringConversion.ts +0 -850
  164. package/src/analyzer/docStringUtils.ts +0 -112
  165. package/src/analyzer/functionTransform.ts +0 -137
  166. package/src/analyzer/importResolver.ts +0 -2308
  167. package/src/analyzer/importResult.ts +0 -98
  168. package/src/analyzer/importStatementUtils.ts +0 -834
  169. package/src/analyzer/namedTuples.ts +0 -422
  170. package/src/analyzer/packageTypeReport.ts +0 -108
  171. package/src/analyzer/packageTypeVerifier.ts +0 -1466
  172. package/src/analyzer/parentDirectoryCache.ts +0 -88
  173. package/src/analyzer/parseTreeCleaner.ts +0 -35
  174. package/src/analyzer/parseTreeUtils.ts +0 -2165
  175. package/src/analyzer/parseTreeWalker.ts +0 -663
  176. package/src/analyzer/patternMatching.ts +0 -1356
  177. package/src/analyzer/program.ts +0 -2778
  178. package/src/analyzer/properties.ts +0 -534
  179. package/src/analyzer/protocols.ts +0 -660
  180. package/src/analyzer/pyTypedUtils.ts +0 -52
  181. package/src/analyzer/pythonPathUtils.ts +0 -201
  182. package/src/analyzer/scope.ts +0 -202
  183. package/src/analyzer/scopeUtils.ts +0 -81
  184. package/src/analyzer/service.ts +0 -1679
  185. package/src/analyzer/sourceFile.ts +0 -1401
  186. package/src/analyzer/sourceMapper.ts +0 -717
  187. package/src/analyzer/staticExpressions.ts +0 -308
  188. package/src/analyzer/symbol.ts +0 -249
  189. package/src/analyzer/symbolNameUtils.ts +0 -50
  190. package/src/analyzer/symbolUtils.ts +0 -49
  191. package/src/analyzer/testWalker.ts +0 -101
  192. package/src/analyzer/tracePrinter.ts +0 -264
  193. package/src/analyzer/typeCache.ts +0 -181
  194. package/src/analyzer/typeDocStringUtils.ts +0 -371
  195. package/src/analyzer/typeEvaluator.ts +0 -23395
  196. package/src/analyzer/typeEvaluatorTypes.ts +0 -452
  197. package/src/analyzer/typeEvaluatorWithTracker.ts +0 -161
  198. package/src/analyzer/typeGuards.ts +0 -1828
  199. package/src/analyzer/typePrinter.ts +0 -807
  200. package/src/analyzer/typeStubWriter.ts +0 -727
  201. package/src/analyzer/typeUtils.ts +0 -3126
  202. package/src/analyzer/typeVarContext.ts +0 -330
  203. package/src/analyzer/typedDicts.ts +0 -950
  204. package/src/analyzer/types.ts +0 -2857
  205. package/src/backgroundAnalysis.ts +0 -49
  206. package/src/backgroundAnalysisBase.ts +0 -606
  207. package/src/backgroundThreadBase.ts +0 -143
  208. package/src/commands/commandController.ts +0 -62
  209. package/src/commands/commandResult.ts +0 -21
  210. package/src/commands/commands.ts +0 -16
  211. package/src/commands/createTypeStub.ts +0 -56
  212. package/src/commands/quickActionCommand.ts +0 -40
  213. package/src/commands/restartServer.ts +0 -20
  214. package/src/common/cancellationUtils.ts +0 -71
  215. package/src/common/chokidarFileWatcherProvider.ts +0 -74
  216. package/src/common/collectionUtils.ts +0 -379
  217. package/src/common/commandLineOptions.ts +0 -132
  218. package/src/common/configOptions.ts +0 -1291
  219. package/src/common/console.ts +0 -201
  220. package/src/common/core.ts +0 -152
  221. package/src/common/crypto.ts +0 -60
  222. package/src/common/debug.ts +0 -144
  223. package/src/common/deferred.ts +0 -78
  224. package/src/common/diagnostic.ts +0 -191
  225. package/src/common/diagnosticRules.ts +0 -80
  226. package/src/common/diagnosticSink.ts +0 -150
  227. package/src/common/editAction.ts +0 -46
  228. package/src/common/extensibility.ts +0 -35
  229. package/src/common/extensions.ts +0 -21
  230. package/src/common/fileBasedCancellationUtils.ts +0 -274
  231. package/src/common/fileSystem.ts +0 -152
  232. package/src/common/fullAccessHost.ts +0 -203
  233. package/src/common/host.ts +0 -49
  234. package/src/common/logTracker.ts +0 -157
  235. package/src/common/lspUtils.ts +0 -18
  236. package/src/common/memUtils.ts +0 -36
  237. package/src/common/pathConsts.ts +0 -16
  238. package/src/common/pathUtils.ts +0 -987
  239. package/src/common/positionUtils.ts +0 -78
  240. package/src/common/progressReporter.ts +0 -53
  241. package/src/common/pythonVersion.ts +0 -74
  242. package/src/common/realFileSystem.ts +0 -433
  243. package/src/common/stringUtils.ts +0 -161
  244. package/src/common/textEditUtils.ts +0 -31
  245. package/src/common/textRange.ts +0 -225
  246. package/src/common/textRangeCollection.ts +0 -122
  247. package/src/common/timing.ts +0 -105
  248. package/src/common/uriParser.ts +0 -26
  249. package/src/common/workspaceEditUtils.ts +0 -100
  250. package/src/languageServerBase.ts +0 -1556
  251. package/src/languageService/analyzerServiceExecutor.ts +0 -144
  252. package/src/languageService/autoImporter.ts +0 -926
  253. package/src/languageService/callHierarchyProvider.ts +0 -476
  254. package/src/languageService/codeActionProvider.ts +0 -85
  255. package/src/languageService/completionProvider.ts +0 -3103
  256. package/src/languageService/definitionProvider.ts +0 -235
  257. package/src/languageService/documentHighlightProvider.ts +0 -61
  258. package/src/languageService/documentSymbolCollector.ts +0 -466
  259. package/src/languageService/documentSymbolProvider.ts +0 -466
  260. package/src/languageService/hoverProvider.ts +0 -499
  261. package/src/languageService/importAdder.ts +0 -437
  262. package/src/languageService/importSorter.ts +0 -196
  263. package/src/languageService/indentationUtils.ts +0 -813
  264. package/src/languageService/quickActions.ts +0 -113
  265. package/src/languageService/referencesProvider.ts +0 -316
  266. package/src/languageService/renameModuleProvider.ts +0 -1400
  267. package/src/languageService/signatureHelpProvider.ts +0 -227
  268. package/src/languageService/tooltipUtils.ts +0 -147
  269. package/src/localization/localize.ts +0 -1272
  270. package/src/localization/package.nls.de.json +0 -3
  271. package/src/localization/package.nls.en-us.json +0 -636
  272. package/src/localization/package.nls.es.json +0 -3
  273. package/src/localization/package.nls.fr.json +0 -3
  274. package/src/localization/package.nls.ja.json +0 -3
  275. package/src/localization/package.nls.ru.json +0 -3
  276. package/src/localization/package.nls.zh-cn.json +0 -3
  277. package/src/localization/package.nls.zh-tw.json +0 -3
  278. package/src/nodeMain.ts +0 -21
  279. package/src/nodeServer.ts +0 -30
  280. package/src/parser/characterStream.ts +0 -145
  281. package/src/parser/characters.ts +0 -285
  282. package/src/parser/parseNodes.ts +0 -2338
  283. package/src/parser/parser.ts +0 -4859
  284. package/src/parser/stringTokenUtils.ts +0 -564
  285. package/src/parser/tokenizer.ts +0 -1379
  286. package/src/parser/tokenizerTypes.ts +0 -420
  287. package/src/parser/unicode.ts +0 -2917
  288. package/src/pyright.ts +0 -824
  289. package/src/pyrightFileSystem.ts +0 -237
  290. package/src/readonlyAugmentedFileSystem.ts +0 -204
  291. package/src/server.ts +0 -298
  292. package/src/tests/chainedSourceFiles.test.ts +0 -183
  293. package/src/tests/checker.test.ts +0 -445
  294. package/src/tests/collectionUtils.test.ts +0 -178
  295. package/src/tests/common.test.ts +0 -117
  296. package/src/tests/config.test.ts +0 -291
  297. package/src/tests/debug.test.ts +0 -120
  298. package/src/tests/deferred.test.ts +0 -54
  299. package/src/tests/diagnosticOverrides.test.ts +0 -104
  300. package/src/tests/docStringConversion.test.ts +0 -823
  301. package/src/tests/docStringUtils.test.ts +0 -57
  302. package/src/tests/documentSymbolCollector.test.ts +0 -735
  303. package/src/tests/filesystem.test.ts +0 -215
  304. package/src/tests/fourSlashParser.test.ts +0 -330
  305. package/src/tests/fourSlashRunner.test.ts +0 -36
  306. package/src/tests/fourslash/completions.autoimport.Lib.Found.Type.fourslash.ts +0 -33
  307. package/src/tests/fourslash/completions.autoimport.Lib.Found.duplication.fourslash.ts +0 -47
  308. package/src/tests/fourslash/completions.autoimport.Lib.NotFound.fourslash.ts +0 -14
  309. package/src/tests/fourslash/completions.autoimport.disabled.fourslash.ts +0 -25
  310. package/src/tests/fourslash/completions.autoimport.duplicates.fourslash.ts +0 -36
  311. package/src/tests/fourslash/completions.autoimport.fourslash.ts +0 -29
  312. package/src/tests/fourslash/completions.autoimport.fromImport.fourslash.ts +0 -130
  313. package/src/tests/fourslash/completions.autoimport.plainText.fourslash.ts +0 -29
  314. package/src/tests/fourslash/completions.autoimport.shadow.fourslash.ts +0 -48
  315. package/src/tests/fourslash/completions.autoimport.submodule.fourslash.ts +0 -31
  316. package/src/tests/fourslash/completions.autoimport.topLevel.fourslash.ts +0 -57
  317. package/src/tests/fourslash/completions.builtinDocstrings.fourslash.ts +0 -117
  318. package/src/tests/fourslash/completions.builtinOverride.fourslash.ts +0 -22
  319. package/src/tests/fourslash/completions.call.stringLiteral.fourslash.ts +0 -55
  320. package/src/tests/fourslash/completions.call.typedDict.fourslash.ts +0 -247
  321. package/src/tests/fourslash/completions.call.typedDict.list.fourslash.ts +0 -163
  322. package/src/tests/fourslash/completions.call.typedDict.states.fourslash.ts +0 -135
  323. package/src/tests/fourslash/completions.classVariable.fourslash.ts +0 -37
  324. package/src/tests/fourslash/completions.comment.fourslash.ts +0 -28
  325. package/src/tests/fourslash/completions.declNames.class.fourslash.ts +0 -35
  326. package/src/tests/fourslash/completions.declNames.exception.fourslash.ts +0 -18
  327. package/src/tests/fourslash/completions.declNames.for.fourslash.ts +0 -30
  328. package/src/tests/fourslash/completions.declNames.importAlias.fourslash.ts +0 -15
  329. package/src/tests/fourslash/completions.declNames.lambda.fourslash.ts +0 -45
  330. package/src/tests/fourslash/completions.declNames.method.fourslash.ts +0 -71
  331. package/src/tests/fourslash/completions.declNames.overload.fourslash.ts +0 -156
  332. package/src/tests/fourslash/completions.declNames.topLevelOverload.fourslash.ts +0 -141
  333. package/src/tests/fourslash/completions.dictionary.keys.complex.fourslash.ts +0 -76
  334. package/src/tests/fourslash/completions.dictionary.keys.expression.fourslash.ts +0 -63
  335. package/src/tests/fourslash/completions.dictionary.keys.literalTypes.fourslash.ts +0 -161
  336. package/src/tests/fourslash/completions.dictionary.keys.simple.fourslash.ts +0 -151
  337. package/src/tests/fourslash/completions.dictionary.keys.stringLiterals.fourslash.ts +0 -116
  338. package/src/tests/fourslash/completions.dictionary.keys.symbols.fourslash.ts +0 -53
  339. package/src/tests/fourslash/completions.enums.members.fourslash.ts +0 -44
  340. package/src/tests/fourslash/completions.excluded.fourslash.ts +0 -12
  341. package/src/tests/fourslash/completions.fourslash.ts +0 -51
  342. package/src/tests/fourslash/completions.fstring.fourslash.ts +0 -33
  343. package/src/tests/fourslash/completions.fstring.stringLiteral.fourslash.ts +0 -96
  344. package/src/tests/fourslash/completions.fuzzyMatching.fourslash.ts +0 -30
  345. package/src/tests/fourslash/completions.importDunderNames.fourslash.ts +0 -31
  346. package/src/tests/fourslash/completions.importSubmodule.fourslash.ts +0 -26
  347. package/src/tests/fourslash/completions.importsDuplicates.fourslash.ts +0 -23
  348. package/src/tests/fourslash/completions.inList.fourslash.ts +0 -33
  349. package/src/tests/fourslash/completions.included.fourslash.ts +0 -12
  350. package/src/tests/fourslash/completions.indexer.keys.getitem.fourslash.ts +0 -57
  351. package/src/tests/fourslash/completions.inherited.function.docFromStub.fourslash.ts +0 -28
  352. package/src/tests/fourslash/completions.inherited.overload.docFromScrWithStub.fourslash.ts +0 -52
  353. package/src/tests/fourslash/completions.inherited.overload.docFromStub.fourslash.ts +0 -53
  354. package/src/tests/fourslash/completions.inherited.property.docFromSrc.fourslash.ts +0 -104
  355. package/src/tests/fourslash/completions.inherited.property.docFromStub.fourslash.ts +0 -108
  356. package/src/tests/fourslash/completions.keywords.pythonVersion.fourslash.ts +0 -72
  357. package/src/tests/fourslash/completions.libCodeAndStub.fourslash.ts +0 -79
  358. package/src/tests/fourslash/completions.libCodeNoStub.fourslash.ts +0 -69
  359. package/src/tests/fourslash/completions.libStub.fourslash.ts +0 -69
  360. package/src/tests/fourslash/completions.literals.fourslash.ts +0 -33
  361. package/src/tests/fourslash/completions.localCode.fourslash.ts +0 -74
  362. package/src/tests/fourslash/completions.moduleContext.UnknownMemberOnInstance.fourslash.ts +0 -17
  363. package/src/tests/fourslash/completions.moduleContext.UnknownStaticFunctionOnClass.fourslash.ts +0 -57
  364. package/src/tests/fourslash/completions.moduleContext.libCodeNoStub.fourslash.ts +0 -30
  365. package/src/tests/fourslash/completions.overloads.fourslash.ts +0 -40
  366. package/src/tests/fourslash/completions.override.default.fourslash.ts +0 -47
  367. package/src/tests/fourslash/completions.override.default.importStub.ts +0 -50
  368. package/src/tests/fourslash/completions.override.default.imported.fourslash.ts +0 -61
  369. package/src/tests/fourslash/completions.override.default.stub.fourslash.ts +0 -47
  370. package/src/tests/fourslash/completions.override.fourslash.ts +0 -47
  371. package/src/tests/fourslash/completions.override.property.fourslash.ts +0 -31
  372. package/src/tests/fourslash/completions.override.property.stub.fourslash.ts +0 -31
  373. package/src/tests/fourslash/completions.override.staticAndClassmethod.fourslash.ts +0 -64
  374. package/src/tests/fourslash/completions.override.stub.fourslash.ts +0 -47
  375. package/src/tests/fourslash/completions.override2.fourslash.ts +0 -71
  376. package/src/tests/fourslash/completions.parameters.fourslash.ts +0 -23
  377. package/src/tests/fourslash/completions.params.fourslash.ts +0 -24
  378. package/src/tests/fourslash/completions.parentFolder.fourslash.ts +0 -17
  379. package/src/tests/fourslash/completions.parentFolders.fourslash.ts +0 -77
  380. package/src/tests/fourslash/completions.plainText.fourslash.ts +0 -34
  381. package/src/tests/fourslash/completions.private.fourslash.ts +0 -64
  382. package/src/tests/fourslash/completions.property.fourslash.ts +0 -28
  383. package/src/tests/fourslash/completions.propertyDocStrings.fourslash.ts +0 -64
  384. package/src/tests/fourslash/completions.self.fourslash.ts +0 -43
  385. package/src/tests/fourslash/completions.stringLiteral.escape.fourslash.ts +0 -71
  386. package/src/tests/fourslash/completions.stringLiteral.fourslash.ts +0 -79
  387. package/src/tests/fourslash/completions.typeAlias.fourslash.ts +0 -29
  388. package/src/tests/fourslash/completions.typeshed.fourslash.ts +0 -9
  389. package/src/tests/fourslash/completions.vardecls.fourslash.ts +0 -40
  390. package/src/tests/fourslash/completions.variableDocStrings.fourslash.ts +0 -69
  391. package/src/tests/fourslash/completions.wildcardimports.fourslash.ts +0 -116
  392. package/src/tests/fourslash/completions.with.fourslash.ts +0 -26
  393. package/src/tests/fourslash/diagnostics.missingModuleSource.fourslash.ts +0 -69
  394. package/src/tests/fourslash/findDefinitions.builtinClass.fourslash.ts +0 -29
  395. package/src/tests/fourslash/findDefinitions.classes.fourslash.ts +0 -101
  396. package/src/tests/fourslash/findDefinitions.definitionFilter.preferSource.fourslash.ts +0 -29
  397. package/src/tests/fourslash/findDefinitions.definitionFilter.preferSource.onlyStubs.ts +0 -24
  398. package/src/tests/fourslash/findDefinitions.definitionFilter.preferStub.fourslash.ts +0 -29
  399. package/src/tests/fourslash/findDefinitions.definitionFilter.preferStub.onlySource.fourslash.ts +0 -25
  400. package/src/tests/fourslash/findDefinitions.fields.fourslash.ts +0 -131
  401. package/src/tests/fourslash/findDefinitions.functions.fourslash.ts +0 -87
  402. package/src/tests/fourslash/findDefinitions.methods.fourslash.ts +0 -162
  403. package/src/tests/fourslash/findDefinitions.modules.fourslash.ts +0 -50
  404. package/src/tests/fourslash/findDefinitions.namespaceImport.fourslash.ts +0 -40
  405. package/src/tests/fourslash/findDefinitions.overloads.fourslash.ts +0 -223
  406. package/src/tests/fourslash/findDefinitions.parameters.fourslash.ts +0 -162
  407. package/src/tests/fourslash/findDefinitions.sourceAndStub.function.fourslash.ts +0 -26
  408. package/src/tests/fourslash/findDefinitions.sourceAndStub.innerClass.fourslash.ts +0 -32
  409. package/src/tests/fourslash/findDefinitions.sourceAndStub.innerClassMethod.fourslash.ts +0 -33
  410. package/src/tests/fourslash/findDefinitions.sourceAndStub.outerClass.fourslash.ts +0 -28
  411. package/src/tests/fourslash/findDefinitions.sourceAndStub.outerClassMethod.fourslash.ts +0 -29
  412. package/src/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadOnly.fourslash.ts +0 -31
  413. package/src/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadWrite.fourslash.ts +0 -36
  414. package/src/tests/fourslash/findDefinitions.sourceOnly.class.fourslash.ts +0 -29
  415. package/src/tests/fourslash/findDefinitions.sourceOnly.function1.fourslash.ts +0 -28
  416. package/src/tests/fourslash/findDefinitions.sourceOnly.function2.fourslash.ts +0 -28
  417. package/src/tests/fourslash/findDefinitions.sourceOnly.relativeImport1.fourslash.ts +0 -22
  418. package/src/tests/fourslash/findDefinitions.sourceOnly.relativeImport2.fourslash.ts +0 -22
  419. package/src/tests/fourslash/findDefinitions.stubOnly.fourslash.ts +0 -61
  420. package/src/tests/fourslash/findDefinitions.stubPackages.fourslash.ts +0 -71
  421. package/src/tests/fourslash/findDefinitions.typedDict.keys.fourslash.ts +0 -99
  422. package/src/tests/fourslash/findDefinitions.variables.fourslash.ts +0 -88
  423. package/src/tests/fourslash/findDefinitions.wildcardimports.fourslash.ts +0 -117
  424. package/src/tests/fourslash/findTypeDefinitions.builtinClass.fourslash.ts +0 -26
  425. package/src/tests/fourslash/findTypeDefinitions.classes.fourslash.ts +0 -72
  426. package/src/tests/fourslash/findTypeDefinitions.unions.fourslash.ts +0 -26
  427. package/src/tests/fourslash/findallreferences.classPropertyReadWrite.ts +0 -39
  428. package/src/tests/fourslash/findallreferences.fourslash.ts +0 -34
  429. package/src/tests/fourslash/findallreferences.importalias.fourslash.ts +0 -34
  430. package/src/tests/fourslash/findallreferences.invokedFromLibrary.fourslash.ts +0 -52
  431. package/src/tests/fourslash/findallreferences.module.nested.fourslash.ts +0 -67
  432. package/src/tests/fourslash/findallreferences.modules.duplicated.fourslash.ts +0 -59
  433. package/src/tests/fourslash/findallreferences.modules.fourslash.ts +0 -46
  434. package/src/tests/fourslash/findallreferences.modules.shadow.fourslash.ts +0 -95
  435. package/src/tests/fourslash/findallreferences.openFiles.fourslash.ts +0 -37
  436. package/src/tests/fourslash/findallreferences.parameter.fourslash.ts +0 -24
  437. package/src/tests/fourslash/findallreferences.sourceAndStub.class.fourslash.ts +0 -33
  438. package/src/tests/fourslash/findallreferences.sourceAndStub.classMethod.fourslash.ts +0 -37
  439. package/src/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadOnly.fourslash.ts +0 -40
  440. package/src/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadWrite.fourslash.skip.ts +0 -48
  441. package/src/tests/fourslash/findallreferences.sourceAndStub.function.fourslash.ts +0 -35
  442. package/src/tests/fourslash/findallreferences.variable.fourslash.ts +0 -24
  443. package/src/tests/fourslash/fourslash.ts +0 -411
  444. package/src/tests/fourslash/highlightreferences.attributes.fourslash.ts +0 -31
  445. package/src/tests/fourslash/hover.builtinDocstrings.fourslash.ts +0 -64
  446. package/src/tests/fourslash/hover.classNoInit.fourslash.ts +0 -14
  447. package/src/tests/fourslash/hover.docFromScr.stringFormat.fourslash.ts +0 -52
  448. package/src/tests/fourslash/hover.docFromSrc.fourslash.ts +0 -83
  449. package/src/tests/fourslash/hover.docFromSrc.pkg-vs-module1.fourslash.ts +0 -26
  450. package/src/tests/fourslash/hover.docFromSrc.pkg-vs-module2.fourslash.ts +0 -26
  451. package/src/tests/fourslash/hover.docFromSrc.relativeImport1.fourslash.ts +0 -23
  452. package/src/tests/fourslash/hover.docFromSrc.relativeImport2.fourslash.ts +0 -22
  453. package/src/tests/fourslash/hover.docFromSrc.relativeImport3.fourslash.ts +0 -46
  454. package/src/tests/fourslash/hover.docFromSrc.stubs-package.fourslash.ts +0 -29
  455. package/src/tests/fourslash/hover.docFromSrc.typeshed.fourslash.ts +0 -20
  456. package/src/tests/fourslash/hover.docstring.links.fourslash.ts +0 -12
  457. package/src/tests/fourslash/hover.docstring.overloads.fourslash.ts +0 -41
  458. package/src/tests/fourslash/hover.docstring.split.fourslash.ts +0 -24
  459. package/src/tests/fourslash/hover.fourslash.ts +0 -20
  460. package/src/tests/fourslash/hover.import.django.view.fourslash.ts +0 -27
  461. package/src/tests/fourslash/hover.import.fourslash.ts +0 -11
  462. package/src/tests/fourslash/hover.inherited.docFromSrc.fourslash.ts +0 -63
  463. package/src/tests/fourslash/hover.inherited.docFromSrcWithStub.fourslash.ts +0 -54
  464. package/src/tests/fourslash/hover.inherited.docFromStub.fourslash.ts +0 -42
  465. package/src/tests/fourslash/hover.inherited.overload.docFromSrcWithStub.fourslash.ts +0 -46
  466. package/src/tests/fourslash/hover.inherited.overload.docFromStub.fourslash.ts +0 -47
  467. package/src/tests/fourslash/hover.inherited.property.docFromSrcWithStub.fourslash.ts +0 -87
  468. package/src/tests/fourslash/hover.inherited.property.docFromStub.fourslash.ts +0 -91
  469. package/src/tests/fourslash/hover.init.fourslash.ts +0 -39
  470. package/src/tests/fourslash/hover.libCodeAndStub.fourslash.ts +0 -52
  471. package/src/tests/fourslash/hover.libCodeNoStub.fourslash.ts +0 -41
  472. package/src/tests/fourslash/hover.libStub.fourslash.ts +0 -41
  473. package/src/tests/fourslash/hover.optionalAliasParameter.fourslash.ts +0 -14
  474. package/src/tests/fourslash/hover.plainText.fourslash.ts +0 -21
  475. package/src/tests/fourslash/hover.typedDict.key.fourslash.ts +0 -51
  476. package/src/tests/fourslash/hover.variable.docString.fourslash.ts +0 -41
  477. package/src/tests/fourslash/hover.wildcardimports.fourslash.ts +0 -80
  478. package/src/tests/fourslash/import.publicSymbols.fourslash.ts +0 -65
  479. package/src/tests/fourslash/import.pytyped.dunderAll.fourslash.ts +0 -77
  480. package/src/tests/fourslash/import.pytyped.privateSymbols.fourslash.ts +0 -65
  481. package/src/tests/fourslash/import.pytyped.typeCheckingBasic.fourslash.ts +0 -38
  482. package/src/tests/fourslash/import.pytyped.typeCheckingOff.fourslash.ts +0 -38
  483. package/src/tests/fourslash/import.wildcard.fourslash.ts +0 -27
  484. package/src/tests/fourslash/importnotresolved.fourslash.ts +0 -13
  485. package/src/tests/fourslash/missingModuleSource.disablingInStrictMode.fourslash.ts +0 -20
  486. package/src/tests/fourslash/missingModuleSource.fourslash.ts +0 -14
  487. package/src/tests/fourslash/missingTypeStub.codeAction.fourslash.ts +0 -33
  488. package/src/tests/fourslash/missingTypeStub.command.multipart.fourslash.ts +0 -48
  489. package/src/tests/fourslash/missingTypeStub.command.singlefile.fourslash.ts +0 -38
  490. package/src/tests/fourslash/missingTypeStub.command.singlepart.fourslash.ts +0 -38
  491. package/src/tests/fourslash/missingTypeStub.fourslash.ts +0 -20
  492. package/src/tests/fourslash/missingTypeStub.invokeCodeAction.fourslash.ts +0 -36
  493. package/src/tests/fourslash/noerrors.fourslash.ts +0 -9
  494. package/src/tests/fourslash/orderImports1.command.fourslash.ts +0 -20
  495. package/src/tests/fourslash/orderImports2.command.fourslash.ts +0 -24
  496. package/src/tests/fourslash/rename.externallyHidden.fourslash.ts +0 -24
  497. package/src/tests/fourslash/rename.externallyHidden.params.fourslash.ts +0 -24
  498. package/src/tests/fourslash/rename.fourslash.ts +0 -29
  499. package/src/tests/fourslash/rename.library.fourslash.ts +0 -29
  500. package/src/tests/fourslash/rename.library.sourceAndStub.fourslash.ts +0 -33
  501. package/src/tests/fourslash/rename.multipleDecl.fourslash.ts +0 -21
  502. package/src/tests/fourslash/rename.sourceAndStub.fourslash.ts +0 -37
  503. package/src/tests/fourslash/rename.string.excluded.fourslash.ts +0 -43
  504. package/src/tests/fourslash/rename.string.fourslash.ts +0 -26
  505. package/src/tests/fourslash/signature.builtinDocstrings.fourslash.ts +0 -63
  506. package/src/tests/fourslash/signature.complicated.fourslash.ts +0 -100
  507. package/src/tests/fourslash/signature.cornercases.fourslash.ts +0 -23
  508. package/src/tests/fourslash/signature.docstrings.fourslash.ts +0 -43
  509. package/src/tests/fourslash/signature.docstrings.overloaded.fourslash.ts +0 -50
  510. package/src/tests/fourslash/signature.docstrings.wildcardimports.fourslash.ts +0 -122
  511. package/src/tests/fourslash/signature.overload.fourslash.ts +0 -64
  512. package/src/tests/fourslash/signature.simple.fourslash.ts +0 -104
  513. package/src/tests/harness/fourslash/fourSlashParser.ts +0 -441
  514. package/src/tests/harness/fourslash/fourSlashTypes.ts +0 -134
  515. package/src/tests/harness/fourslash/runner.ts +0 -99
  516. package/src/tests/harness/fourslash/testLanguageService.ts +0 -142
  517. package/src/tests/harness/fourslash/testState.Consts.ts +0 -29
  518. package/src/tests/harness/fourslash/testState.ts +0 -1993
  519. package/src/tests/harness/testAccessHost.ts +0 -23
  520. package/src/tests/harness/testHost.ts +0 -177
  521. package/src/tests/harness/utils.ts +0 -355
  522. package/src/tests/harness/vfs/factory.ts +0 -199
  523. package/src/tests/harness/vfs/filesystem.ts +0 -1893
  524. package/src/tests/harness/vfs/pathValidation.ts +0 -154
  525. package/src/tests/importAdder.test.ts +0 -1361
  526. package/src/tests/importResolver.test.ts +0 -534
  527. package/src/tests/importStatementUtils.test.ts +0 -526
  528. package/src/tests/indentationUtils.ptvs.test.ts +0 -388
  529. package/src/tests/indentationUtils.reindent.test.ts +0 -403
  530. package/src/tests/indentationUtils.test.ts +0 -455
  531. package/src/tests/ipythonMode.test.ts +0 -365
  532. package/src/tests/localizer.test.ts +0 -47
  533. package/src/tests/parseTreeUtils.test.ts +0 -281
  534. package/src/tests/parser.test.ts +0 -99
  535. package/src/tests/pathUtils.test.ts +0 -321
  536. package/src/tests/pyrightFileSystem.test.ts +0 -183
  537. package/src/tests/renameModule.folder.test.ts +0 -261
  538. package/src/tests/renameModule.fromImports.test.ts +0 -952
  539. package/src/tests/renameModule.imports.test.ts +0 -450
  540. package/src/tests/renameModule.misc.test.ts +0 -765
  541. package/src/tests/renameModule.relativePath.test.ts +0 -277
  542. package/src/tests/renameModuleTestUtils.ts +0 -210
  543. package/src/tests/samples/abstractClass1.py +0 -51
  544. package/src/tests/samples/abstractClass2.py +0 -25
  545. package/src/tests/samples/abstractClass3.py +0 -30
  546. package/src/tests/samples/abstractClass4.py +0 -30
  547. package/src/tests/samples/abstractClass5.py +0 -42
  548. package/src/tests/samples/abstractClass6.py +0 -25
  549. package/src/tests/samples/abstractClass7.py +0 -22
  550. package/src/tests/samples/abstractClass8.py +0 -27
  551. package/src/tests/samples/annotated1.py +0 -72
  552. package/src/tests/samples/annotatedVar1.py +0 -22
  553. package/src/tests/samples/annotatedVar2.py +0 -28
  554. package/src/tests/samples/annotatedVar3.py +0 -54
  555. package/src/tests/samples/annotatedVar4.py +0 -24
  556. package/src/tests/samples/annotatedVar5.py +0 -37
  557. package/src/tests/samples/annotatedVar6.py +0 -22
  558. package/src/tests/samples/annotatedVar7.py +0 -13
  559. package/src/tests/samples/annotatedVar8.py +0 -29
  560. package/src/tests/samples/annotations1.py +0 -98
  561. package/src/tests/samples/annotations2.py +0 -33
  562. package/src/tests/samples/annotations3.py +0 -43
  563. package/src/tests/samples/annotations4.py +0 -54
  564. package/src/tests/samples/annotations5.py +0 -9
  565. package/src/tests/samples/annotations6.py +0 -29
  566. package/src/tests/samples/assert1.py +0 -22
  567. package/src/tests/samples/assertType1.py +0 -46
  568. package/src/tests/samples/assignment1.py +0 -58
  569. package/src/tests/samples/assignment10.py +0 -14
  570. package/src/tests/samples/assignment2.py +0 -40
  571. package/src/tests/samples/assignment3.py +0 -46
  572. package/src/tests/samples/assignment4.py +0 -20
  573. package/src/tests/samples/assignment5.py +0 -16
  574. package/src/tests/samples/assignment6.py +0 -25
  575. package/src/tests/samples/assignment7.py +0 -13
  576. package/src/tests/samples/assignment8.py +0 -40
  577. package/src/tests/samples/assignment9.py +0 -25
  578. package/src/tests/samples/assignmentExpr1.py +0 -23
  579. package/src/tests/samples/assignmentExpr2.py +0 -49
  580. package/src/tests/samples/assignmentExpr3.py +0 -27
  581. package/src/tests/samples/assignmentExpr4.py +0 -49
  582. package/src/tests/samples/assignmentExpr5.py +0 -15
  583. package/src/tests/samples/assignmentExpr6.py +0 -10
  584. package/src/tests/samples/assignmentExpr7.py +0 -13
  585. package/src/tests/samples/assignmentExpr8.py +0 -11
  586. package/src/tests/samples/assignmentExpr9.py +0 -28
  587. package/src/tests/samples/async1.py +0 -49
  588. package/src/tests/samples/augmentedAssignment1.py +0 -62
  589. package/src/tests/samples/augmentedAssignment2.py +0 -23
  590. package/src/tests/samples/augmentedAssignment3.py +0 -8
  591. package/src/tests/samples/await1.py +0 -23
  592. package/src/tests/samples/await2.py +0 -25
  593. package/src/tests/samples/badToken1.py +0 -6
  594. package/src/tests/samples/builtins1.py +0 -2
  595. package/src/tests/samples/call1.py +0 -93
  596. package/src/tests/samples/call2.py +0 -118
  597. package/src/tests/samples/call3.py +0 -168
  598. package/src/tests/samples/call4.py +0 -13
  599. package/src/tests/samples/call5.py +0 -95
  600. package/src/tests/samples/call6.py +0 -35
  601. package/src/tests/samples/call7.py +0 -57
  602. package/src/tests/samples/callSite1.py +0 -6
  603. package/src/tests/samples/callSite2.py +0 -12
  604. package/src/tests/samples/callable1.py +0 -53
  605. package/src/tests/samples/callable2.py +0 -58
  606. package/src/tests/samples/callable3.py +0 -28
  607. package/src/tests/samples/callable4.py +0 -32
  608. package/src/tests/samples/callable5.py +0 -40
  609. package/src/tests/samples/callable6.py +0 -83
  610. package/src/tests/samples/callbackProtocol1.py +0 -119
  611. package/src/tests/samples/callbackProtocol2.py +0 -29
  612. package/src/tests/samples/callbackProtocol3.py +0 -23
  613. package/src/tests/samples/callbackProtocol4.py +0 -73
  614. package/src/tests/samples/callbackProtocol5.py +0 -66
  615. package/src/tests/samples/callbackProtocol6.py +0 -66
  616. package/src/tests/samples/callbackProtocol7.py +0 -16
  617. package/src/tests/samples/callbackProtocol8.py +0 -16
  618. package/src/tests/samples/capturedVariable1.py +0 -106
  619. package/src/tests/samples/circular1.py +0 -16
  620. package/src/tests/samples/circular2.py +0 -38
  621. package/src/tests/samples/circularBaseClass.py +0 -17
  622. package/src/tests/samples/classGetItem1.py +0 -30
  623. package/src/tests/samples/classVar1.py +0 -41
  624. package/src/tests/samples/classVar2.py +0 -29
  625. package/src/tests/samples/classVar3.py +0 -46
  626. package/src/tests/samples/classVar4.py +0 -36
  627. package/src/tests/samples/classes1.py +0 -50
  628. package/src/tests/samples/classes3.py +0 -48
  629. package/src/tests/samples/classes4.py +0 -15
  630. package/src/tests/samples/classes5.py +0 -260
  631. package/src/tests/samples/classes6.py +0 -16
  632. package/src/tests/samples/classes7.py +0 -18
  633. package/src/tests/samples/classes8.py +0 -47
  634. package/src/tests/samples/codeFlow1.py +0 -65
  635. package/src/tests/samples/codeFlow2.py +0 -26
  636. package/src/tests/samples/codeFlow3.py +0 -8
  637. package/src/tests/samples/codeFlow4.py +0 -133
  638. package/src/tests/samples/codeFlow5.py +0 -10
  639. package/src/tests/samples/codeFlow6.py +0 -35
  640. package/src/tests/samples/codeFlow7.py +0 -35
  641. package/src/tests/samples/comparison1.py +0 -77
  642. package/src/tests/samples/comparison2.py +0 -37
  643. package/src/tests/samples/complex1.py +0 -17
  644. package/src/tests/samples/constant1.py +0 -40
  645. package/src/tests/samples/constants1.py +0 -64
  646. package/src/tests/samples/constructor1.py +0 -30
  647. package/src/tests/samples/constructor10.py +0 -19
  648. package/src/tests/samples/constructor11.py +0 -32
  649. package/src/tests/samples/constructor12.py +0 -20
  650. package/src/tests/samples/constructor13.py +0 -15
  651. package/src/tests/samples/constructor2.py +0 -180
  652. package/src/tests/samples/constructor3.py +0 -18
  653. package/src/tests/samples/constructor4.py +0 -25
  654. package/src/tests/samples/constructor5.py +0 -25
  655. package/src/tests/samples/constructor6.py +0 -70
  656. package/src/tests/samples/constructor7.py +0 -11
  657. package/src/tests/samples/constructor8.py +0 -99
  658. package/src/tests/samples/constructor9.py +0 -19
  659. package/src/tests/samples/coroutines1.py +0 -60
  660. package/src/tests/samples/coroutines2.py +0 -20
  661. package/src/tests/samples/coroutines3.py +0 -37
  662. package/src/tests/samples/dataclass1.py +0 -44
  663. package/src/tests/samples/dataclass10.py +0 -45
  664. package/src/tests/samples/dataclass11.py +0 -53
  665. package/src/tests/samples/dataclass12.py +0 -32
  666. package/src/tests/samples/dataclass13.py +0 -42
  667. package/src/tests/samples/dataclass14.py +0 -38
  668. package/src/tests/samples/dataclass15.py +0 -58
  669. package/src/tests/samples/dataclass16.py +0 -21
  670. package/src/tests/samples/dataclass17.py +0 -46
  671. package/src/tests/samples/dataclass18.py +0 -57
  672. package/src/tests/samples/dataclass19.py +0 -44
  673. package/src/tests/samples/dataclass2.py +0 -30
  674. package/src/tests/samples/dataclass20.py +0 -71
  675. package/src/tests/samples/dataclass21.py +0 -13
  676. package/src/tests/samples/dataclass3.py +0 -18
  677. package/src/tests/samples/dataclass4.py +0 -64
  678. package/src/tests/samples/dataclass5.py +0 -81
  679. package/src/tests/samples/dataclass6.py +0 -29
  680. package/src/tests/samples/dataclass7.py +0 -93
  681. package/src/tests/samples/dataclass8.py +0 -22
  682. package/src/tests/samples/dataclass9.py +0 -24
  683. package/src/tests/samples/dataclassPostInit1.py +0 -61
  684. package/src/tests/samples/dataclassTransform1.py +0 -71
  685. package/src/tests/samples/dataclassTransform2.py +0 -78
  686. package/src/tests/samples/dataclassTransform3.py +0 -83
  687. package/src/tests/samples/dataclassTransform4.py +0 -87
  688. package/src/tests/samples/decorator1.py +0 -20
  689. package/src/tests/samples/decorator2.py +0 -31
  690. package/src/tests/samples/decorator3.py +0 -27
  691. package/src/tests/samples/decorator4.py +0 -37
  692. package/src/tests/samples/decorator5.py +0 -29
  693. package/src/tests/samples/decorator6.py +0 -34
  694. package/src/tests/samples/defaultInitializer1.py +0 -26
  695. package/src/tests/samples/deprecated1.py +0 -37
  696. package/src/tests/samples/descriptor1.py +0 -134
  697. package/src/tests/samples/descriptor2.py +0 -29
  698. package/src/tests/samples/dictionary1.py +0 -42
  699. package/src/tests/samples/dictionary2.py +0 -14
  700. package/src/tests/samples/dictionary3.py +0 -30
  701. package/src/tests/samples/dictionary4.py +0 -106
  702. package/src/tests/samples/dunderAll1.py +0 -32
  703. package/src/tests/samples/dunderAll2.py +0 -16
  704. package/src/tests/samples/dunderAll3.pyi +0 -16
  705. package/src/tests/samples/duplicateDeclaration1.py +0 -115
  706. package/src/tests/samples/duplicateDeclaration2.py +0 -45
  707. package/src/tests/samples/duplicateImports1.py +0 -13
  708. package/src/tests/samples/ellipsis1.pyi +0 -48
  709. package/src/tests/samples/emptyContainers1.py +0 -89
  710. package/src/tests/samples/enums1.py +0 -52
  711. package/src/tests/samples/enums2.py +0 -15
  712. package/src/tests/samples/enums3.py +0 -24
  713. package/src/tests/samples/enums4.py +0 -23
  714. package/src/tests/samples/enums5.py +0 -16
  715. package/src/tests/samples/enums6.py +0 -33
  716. package/src/tests/samples/enums7.py +0 -54
  717. package/src/tests/samples/enums8.py +0 -14
  718. package/src/tests/samples/expressions1.py +0 -54
  719. package/src/tests/samples/expressions2.py +0 -29
  720. package/src/tests/samples/expressions3.py +0 -26
  721. package/src/tests/samples/expressions4.py +0 -23
  722. package/src/tests/samples/expressions5.py +0 -70
  723. package/src/tests/samples/expressions6.py +0 -14
  724. package/src/tests/samples/expressions7.py +0 -40
  725. package/src/tests/samples/expressions8.py +0 -26
  726. package/src/tests/samples/expressions9.py +0 -14
  727. package/src/tests/samples/final1.py +0 -14
  728. package/src/tests/samples/final2.py +0 -86
  729. package/src/tests/samples/final3.py +0 -179
  730. package/src/tests/samples/final4.pyi +0 -21
  731. package/src/tests/samples/final5.py +0 -18
  732. package/src/tests/samples/forLoop1.py +0 -88
  733. package/src/tests/samples/forLoop2.py +0 -48
  734. package/src/tests/samples/fstring1.py +0 -66
  735. package/src/tests/samples/fstring2.py +0 -12
  736. package/src/tests/samples/fstring3.py +0 -35
  737. package/src/tests/samples/fstring4.py +0 -17
  738. package/src/tests/samples/fstring5.py +0 -17
  739. package/src/tests/samples/fstring6.py +0 -14
  740. package/src/tests/samples/function1.py +0 -12
  741. package/src/tests/samples/function10.py +0 -20
  742. package/src/tests/samples/function11.py +0 -36
  743. package/src/tests/samples/function2.py +0 -7
  744. package/src/tests/samples/function3.py +0 -82
  745. package/src/tests/samples/function4.py +0 -13
  746. package/src/tests/samples/function6.py +0 -24
  747. package/src/tests/samples/function7.py +0 -13
  748. package/src/tests/samples/function8.py +0 -38
  749. package/src/tests/samples/function9.py +0 -75
  750. package/src/tests/samples/functionAnnotation1.py +0 -61
  751. package/src/tests/samples/functionAnnotation2.py +0 -26
  752. package/src/tests/samples/functionAnnotation3.py +0 -37
  753. package/src/tests/samples/functionAnnotation4.py +0 -22
  754. package/src/tests/samples/functionMember1.py +0 -18
  755. package/src/tests/samples/functionMember2.py +0 -45
  756. package/src/tests/samples/generators1.py +0 -122
  757. package/src/tests/samples/generators10.py +0 -18
  758. package/src/tests/samples/generators11.py +0 -27
  759. package/src/tests/samples/generators12.py +0 -25
  760. package/src/tests/samples/generators13.py +0 -65
  761. package/src/tests/samples/generators14.py +0 -19
  762. package/src/tests/samples/generators15.py +0 -26
  763. package/src/tests/samples/generators2.py +0 -31
  764. package/src/tests/samples/generators3.py +0 -42
  765. package/src/tests/samples/generators4.py +0 -33
  766. package/src/tests/samples/generators5.py +0 -24
  767. package/src/tests/samples/generators6.py +0 -14
  768. package/src/tests/samples/generators7.py +0 -18
  769. package/src/tests/samples/generators8.py +0 -12
  770. package/src/tests/samples/generators9.py +0 -19
  771. package/src/tests/samples/generic1.py +0 -41
  772. package/src/tests/samples/genericTypes1.py +0 -12
  773. package/src/tests/samples/genericTypes10.py +0 -38
  774. package/src/tests/samples/genericTypes11.py +0 -26
  775. package/src/tests/samples/genericTypes12.py +0 -14
  776. package/src/tests/samples/genericTypes13.py +0 -27
  777. package/src/tests/samples/genericTypes14.py +0 -22
  778. package/src/tests/samples/genericTypes15.py +0 -13
  779. package/src/tests/samples/genericTypes16.py +0 -15
  780. package/src/tests/samples/genericTypes17.py +0 -24
  781. package/src/tests/samples/genericTypes18.py +0 -135
  782. package/src/tests/samples/genericTypes19.py +0 -32
  783. package/src/tests/samples/genericTypes2.py +0 -40
  784. package/src/tests/samples/genericTypes20.py +0 -44
  785. package/src/tests/samples/genericTypes21.py +0 -29
  786. package/src/tests/samples/genericTypes22.py +0 -23
  787. package/src/tests/samples/genericTypes23.py +0 -27
  788. package/src/tests/samples/genericTypes24.py +0 -32
  789. package/src/tests/samples/genericTypes25.py +0 -37
  790. package/src/tests/samples/genericTypes26.py +0 -31
  791. package/src/tests/samples/genericTypes27.py +0 -14
  792. package/src/tests/samples/genericTypes28.py +0 -51
  793. package/src/tests/samples/genericTypes29.py +0 -24
  794. package/src/tests/samples/genericTypes3.py +0 -13
  795. package/src/tests/samples/genericTypes30.py +0 -32
  796. package/src/tests/samples/genericTypes31.py +0 -30
  797. package/src/tests/samples/genericTypes32.py +0 -25
  798. package/src/tests/samples/genericTypes33.py +0 -46
  799. package/src/tests/samples/genericTypes34.py +0 -54
  800. package/src/tests/samples/genericTypes35.py +0 -45
  801. package/src/tests/samples/genericTypes36.py +0 -35
  802. package/src/tests/samples/genericTypes37.py +0 -26
  803. package/src/tests/samples/genericTypes38.py +0 -15
  804. package/src/tests/samples/genericTypes39.py +0 -82
  805. package/src/tests/samples/genericTypes4.py +0 -37
  806. package/src/tests/samples/genericTypes40.py +0 -38
  807. package/src/tests/samples/genericTypes41.py +0 -16
  808. package/src/tests/samples/genericTypes42.py +0 -32
  809. package/src/tests/samples/genericTypes43.py +0 -24
  810. package/src/tests/samples/genericTypes44.py +0 -33
  811. package/src/tests/samples/genericTypes45.py +0 -43
  812. package/src/tests/samples/genericTypes46.py +0 -66
  813. package/src/tests/samples/genericTypes47.py +0 -39
  814. package/src/tests/samples/genericTypes48.py +0 -18
  815. package/src/tests/samples/genericTypes49.py +0 -41
  816. package/src/tests/samples/genericTypes5.py +0 -42
  817. package/src/tests/samples/genericTypes50.py +0 -62
  818. package/src/tests/samples/genericTypes51.py +0 -55
  819. package/src/tests/samples/genericTypes52.py +0 -34
  820. package/src/tests/samples/genericTypes53.py +0 -42
  821. package/src/tests/samples/genericTypes54.py +0 -31
  822. package/src/tests/samples/genericTypes55.py +0 -61
  823. package/src/tests/samples/genericTypes56.py +0 -19
  824. package/src/tests/samples/genericTypes57.py +0 -30
  825. package/src/tests/samples/genericTypes58.py +0 -52
  826. package/src/tests/samples/genericTypes59.py +0 -71
  827. package/src/tests/samples/genericTypes6.py +0 -49
  828. package/src/tests/samples/genericTypes60.py +0 -27
  829. package/src/tests/samples/genericTypes61.py +0 -34
  830. package/src/tests/samples/genericTypes62.py +0 -26
  831. package/src/tests/samples/genericTypes63.py +0 -32
  832. package/src/tests/samples/genericTypes64.py +0 -16
  833. package/src/tests/samples/genericTypes65.py +0 -15
  834. package/src/tests/samples/genericTypes66.py +0 -30
  835. package/src/tests/samples/genericTypes67.py +0 -57
  836. package/src/tests/samples/genericTypes68.py +0 -14
  837. package/src/tests/samples/genericTypes69.py +0 -45
  838. package/src/tests/samples/genericTypes7.py +0 -24
  839. package/src/tests/samples/genericTypes70.py +0 -31
  840. package/src/tests/samples/genericTypes71.py +0 -72
  841. package/src/tests/samples/genericTypes72.py +0 -24
  842. package/src/tests/samples/genericTypes73.py +0 -14
  843. package/src/tests/samples/genericTypes74.py +0 -23
  844. package/src/tests/samples/genericTypes75.py +0 -45
  845. package/src/tests/samples/genericTypes76.py +0 -107
  846. package/src/tests/samples/genericTypes77.py +0 -26
  847. package/src/tests/samples/genericTypes78.py +0 -23
  848. package/src/tests/samples/genericTypes79.py +0 -37
  849. package/src/tests/samples/genericTypes8.py +0 -26
  850. package/src/tests/samples/genericTypes80.py +0 -10
  851. package/src/tests/samples/genericTypes81.py +0 -32
  852. package/src/tests/samples/genericTypes82.py +0 -19
  853. package/src/tests/samples/genericTypes83.py +0 -28
  854. package/src/tests/samples/genericTypes84.py +0 -11
  855. package/src/tests/samples/genericTypes85.py +0 -20
  856. package/src/tests/samples/genericTypes86.py +0 -15
  857. package/src/tests/samples/genericTypes87.py +0 -21
  858. package/src/tests/samples/genericTypes88.py +0 -25
  859. package/src/tests/samples/genericTypes89.py +0 -17
  860. package/src/tests/samples/genericTypes9.py +0 -109
  861. package/src/tests/samples/genericTypes90.py +0 -12
  862. package/src/tests/samples/genericTypes91.py +0 -20
  863. package/src/tests/samples/import1.py +0 -7
  864. package/src/tests/samples/import10.py +0 -11
  865. package/src/tests/samples/import11.py +0 -11
  866. package/src/tests/samples/import12.py +0 -5
  867. package/src/tests/samples/import13.py +0 -6
  868. package/src/tests/samples/import14.py +0 -10
  869. package/src/tests/samples/import2.py +0 -27
  870. package/src/tests/samples/import3.py +0 -8
  871. package/src/tests/samples/import4.py +0 -15
  872. package/src/tests/samples/import5.py +0 -6
  873. package/src/tests/samples/import6.py +0 -17
  874. package/src/tests/samples/import7.py +0 -14
  875. package/src/tests/samples/import8.py +0 -7
  876. package/src/tests/samples/import9.py +0 -7
  877. package/src/tests/samples/inconsistentConstructor1.py +0 -23
  878. package/src/tests/samples/inconsistentSpaceTab1.py +0 -9
  879. package/src/tests/samples/inconsistentSpaceTab2.py +0 -10
  880. package/src/tests/samples/index1.py +0 -97
  881. package/src/tests/samples/inferredTypes1.py +0 -25
  882. package/src/tests/samples/initVar1.py +0 -23
  883. package/src/tests/samples/initsubclass1.py +0 -46
  884. package/src/tests/samples/initsubclass2.py +0 -16
  885. package/src/tests/samples/isinstance1.py +0 -57
  886. package/src/tests/samples/isinstance10.py +0 -15
  887. package/src/tests/samples/isinstance2.py +0 -28
  888. package/src/tests/samples/isinstance3.py +0 -59
  889. package/src/tests/samples/isinstance4.py +0 -57
  890. package/src/tests/samples/isinstance5.py +0 -8
  891. package/src/tests/samples/isinstance6.py +0 -19
  892. package/src/tests/samples/isinstance7.py +0 -42
  893. package/src/tests/samples/isinstance9.py +0 -26
  894. package/src/tests/samples/kwargsUnpack1.py +0 -116
  895. package/src/tests/samples/lambda1.py +0 -77
  896. package/src/tests/samples/lambda2.py +0 -26
  897. package/src/tests/samples/lambda3.py +0 -34
  898. package/src/tests/samples/lambda4.py +0 -70
  899. package/src/tests/samples/lambda5.py +0 -23
  900. package/src/tests/samples/lambda6.py +0 -15
  901. package/src/tests/samples/lines1.py +0 -14
  902. package/src/tests/samples/list1.py +0 -90
  903. package/src/tests/samples/listComprehension1.py +0 -45
  904. package/src/tests/samples/listComprehension2.py +0 -17
  905. package/src/tests/samples/listComprehension3.py +0 -12
  906. package/src/tests/samples/listComprehension4.py +0 -15
  907. package/src/tests/samples/listComprehension5.py +0 -20
  908. package/src/tests/samples/listComprehension6.py +0 -14
  909. package/src/tests/samples/listComprehension7.py +0 -15
  910. package/src/tests/samples/listComprehension8.py +0 -15
  911. package/src/tests/samples/literalString1.py +0 -43
  912. package/src/tests/samples/literals1.py +0 -48
  913. package/src/tests/samples/literals2.py +0 -30
  914. package/src/tests/samples/literals3.py +0 -40
  915. package/src/tests/samples/literals4.py +0 -10
  916. package/src/tests/samples/literals5.py +0 -28
  917. package/src/tests/samples/literals6.py +0 -90
  918. package/src/tests/samples/literals7.py +0 -38
  919. package/src/tests/samples/loops1.py +0 -45
  920. package/src/tests/samples/loops10.py +0 -11
  921. package/src/tests/samples/loops11.py +0 -22
  922. package/src/tests/samples/loops12.py +0 -18
  923. package/src/tests/samples/loops13.py +0 -13
  924. package/src/tests/samples/loops14.py +0 -22
  925. package/src/tests/samples/loops15.py +0 -22
  926. package/src/tests/samples/loops16.py +0 -322
  927. package/src/tests/samples/loops17.py +0 -9
  928. package/src/tests/samples/loops18.py +0 -23
  929. package/src/tests/samples/loops19.py +0 -14
  930. package/src/tests/samples/loops2.py +0 -25
  931. package/src/tests/samples/loops20.py +0 -41
  932. package/src/tests/samples/loops21.py +0 -18
  933. package/src/tests/samples/loops22.py +0 -21
  934. package/src/tests/samples/loops23.py +0 -16
  935. package/src/tests/samples/loops24.py +0 -12
  936. package/src/tests/samples/loops25.py +0 -45
  937. package/src/tests/samples/loops26.py +0 -12
  938. package/src/tests/samples/loops3.py +0 -11
  939. package/src/tests/samples/loops4.py +0 -17
  940. package/src/tests/samples/loops5.py +0 -14
  941. package/src/tests/samples/loops6.py +0 -25
  942. package/src/tests/samples/loops7.py +0 -14
  943. package/src/tests/samples/loops8.py +0 -17
  944. package/src/tests/samples/loops9.py +0 -25
  945. package/src/tests/samples/match1.py +0 -190
  946. package/src/tests/samples/match10.py +0 -67
  947. package/src/tests/samples/match2.py +0 -340
  948. package/src/tests/samples/match3.py +0 -364
  949. package/src/tests/samples/match4.py +0 -100
  950. package/src/tests/samples/match5.py +0 -70
  951. package/src/tests/samples/match6.py +0 -64
  952. package/src/tests/samples/match7.py +0 -65
  953. package/src/tests/samples/match8.py +0 -19
  954. package/src/tests/samples/match9.py +0 -53
  955. package/src/tests/samples/maxParseDepth1.py +0 -499
  956. package/src/tests/samples/maxParseDepth2.py +0 -16
  957. package/src/tests/samples/memberAccess1.py +0 -70
  958. package/src/tests/samples/memberAccess10.py +0 -65
  959. package/src/tests/samples/memberAccess11.py +0 -37
  960. package/src/tests/samples/memberAccess12.py +0 -36
  961. package/src/tests/samples/memberAccess13.py +0 -17
  962. package/src/tests/samples/memberAccess14.py +0 -63
  963. package/src/tests/samples/memberAccess15.py +0 -20
  964. package/src/tests/samples/memberAccess16.py +0 -12
  965. package/src/tests/samples/memberAccess17.py +0 -31
  966. package/src/tests/samples/memberAccess18.py +0 -31
  967. package/src/tests/samples/memberAccess2.py +0 -45
  968. package/src/tests/samples/memberAccess3.py +0 -64
  969. package/src/tests/samples/memberAccess4.py +0 -91
  970. package/src/tests/samples/memberAccess5.py +0 -26
  971. package/src/tests/samples/memberAccess6.py +0 -52
  972. package/src/tests/samples/memberAccess7.py +0 -36
  973. package/src/tests/samples/memberAccess8.py +0 -75
  974. package/src/tests/samples/memberAccess9.py +0 -11
  975. package/src/tests/samples/metaclass1.py +0 -7
  976. package/src/tests/samples/metaclass2.py +0 -35
  977. package/src/tests/samples/metaclass3.py +0 -43
  978. package/src/tests/samples/metaclass4.py +0 -26
  979. package/src/tests/samples/metaclass5.py +0 -33
  980. package/src/tests/samples/metaclass6.py +0 -15
  981. package/src/tests/samples/metaclass7.py +0 -38
  982. package/src/tests/samples/metaclass8.py +0 -20
  983. package/src/tests/samples/metaclass9.py +0 -77
  984. package/src/tests/samples/methodOverride1.py +0 -507
  985. package/src/tests/samples/methodOverride2.py +0 -74
  986. package/src/tests/samples/methodOverride3.py +0 -111
  987. package/src/tests/samples/methodOverride4.py +0 -36
  988. package/src/tests/samples/missingSuper1.py +0 -73
  989. package/src/tests/samples/module1.py +0 -13
  990. package/src/tests/samples/module2.py +0 -7
  991. package/src/tests/samples/mro1.py +0 -16
  992. package/src/tests/samples/mro2.py +0 -45
  993. package/src/tests/samples/mro3.py +0 -30
  994. package/src/tests/samples/mro4.py +0 -30
  995. package/src/tests/samples/nameBindings1.py +0 -48
  996. package/src/tests/samples/nameBindings2.py +0 -9
  997. package/src/tests/samples/nameBindings3.py +0 -36
  998. package/src/tests/samples/nameBindings4.py +0 -10
  999. package/src/tests/samples/nameBindings5.py +0 -53
  1000. package/src/tests/samples/namedTuples1.py +0 -103
  1001. package/src/tests/samples/namedTuples2.py +0 -56
  1002. package/src/tests/samples/namedTuples3.py +0 -15
  1003. package/src/tests/samples/namedTuples4.py +0 -24
  1004. package/src/tests/samples/namedTuples5.py +0 -15
  1005. package/src/tests/samples/namedTuples6.py +0 -31
  1006. package/src/tests/samples/namedTuples7.py +0 -27
  1007. package/src/tests/samples/never1.py +0 -12
  1008. package/src/tests/samples/never2.py +0 -43
  1009. package/src/tests/samples/newType1.py +0 -34
  1010. package/src/tests/samples/newType2.py +0 -25
  1011. package/src/tests/samples/newType3.py +0 -34
  1012. package/src/tests/samples/newType4.py +0 -8
  1013. package/src/tests/samples/none1.py +0 -29
  1014. package/src/tests/samples/none2.py +0 -22
  1015. package/src/tests/samples/noreturn1.py +0 -78
  1016. package/src/tests/samples/noreturn2.py +0 -37
  1017. package/src/tests/samples/noreturn3.py +0 -16
  1018. package/src/tests/samples/noreturn4.py +0 -29
  1019. package/src/tests/samples/operators1.py +0 -101
  1020. package/src/tests/samples/operators2.py +0 -30
  1021. package/src/tests/samples/operators3.py +0 -8
  1022. package/src/tests/samples/operators4.py +0 -22
  1023. package/src/tests/samples/operators5.py +0 -5
  1024. package/src/tests/samples/operators6.py +0 -10
  1025. package/src/tests/samples/operators7.py +0 -24
  1026. package/src/tests/samples/operators8.py +0 -125
  1027. package/src/tests/samples/optional1.py +0 -77
  1028. package/src/tests/samples/optional2.py +0 -23
  1029. package/src/tests/samples/overload1.py +0 -50
  1030. package/src/tests/samples/overload10.py +0 -48
  1031. package/src/tests/samples/overload2.py +0 -37
  1032. package/src/tests/samples/overload3.py +0 -29
  1033. package/src/tests/samples/overload4.py +0 -46
  1034. package/src/tests/samples/overload5.py +0 -333
  1035. package/src/tests/samples/overload6.py +0 -64
  1036. package/src/tests/samples/overload7.py +0 -376
  1037. package/src/tests/samples/overload8.py +0 -89
  1038. package/src/tests/samples/overload9.py +0 -19
  1039. package/src/tests/samples/package1/__init__.py +0 -3
  1040. package/src/tests/samples/package1/psyche/pysche.py +0 -4
  1041. package/src/tests/samples/package1/psyche.py +0 -4
  1042. package/src/tests/samples/package1/sub/__init__.py +0 -5
  1043. package/src/tests/samples/package1/sub.py +0 -4
  1044. package/src/tests/samples/package1/sub.pyi +0 -2
  1045. package/src/tests/samples/paramInference1.py +0 -27
  1046. package/src/tests/samples/paramNames1.py +0 -39
  1047. package/src/tests/samples/paramSpec1.py +0 -64
  1048. package/src/tests/samples/paramSpec10.py +0 -57
  1049. package/src/tests/samples/paramSpec11.py +0 -36
  1050. package/src/tests/samples/paramSpec12.py +0 -88
  1051. package/src/tests/samples/paramSpec13.py +0 -112
  1052. package/src/tests/samples/paramSpec14.py +0 -30
  1053. package/src/tests/samples/paramSpec15.py +0 -28
  1054. package/src/tests/samples/paramSpec16.py +0 -28
  1055. package/src/tests/samples/paramSpec17.py +0 -34
  1056. package/src/tests/samples/paramSpec18.py +0 -43
  1057. package/src/tests/samples/paramSpec19.py +0 -93
  1058. package/src/tests/samples/paramSpec2.py +0 -29
  1059. package/src/tests/samples/paramSpec20.py +0 -87
  1060. package/src/tests/samples/paramSpec21.py +0 -58
  1061. package/src/tests/samples/paramSpec22.py +0 -26
  1062. package/src/tests/samples/paramSpec23.py +0 -21
  1063. package/src/tests/samples/paramSpec24.py +0 -67
  1064. package/src/tests/samples/paramSpec25.py +0 -36
  1065. package/src/tests/samples/paramSpec26.py +0 -25
  1066. package/src/tests/samples/paramSpec27.py +0 -57
  1067. package/src/tests/samples/paramSpec28.py +0 -39
  1068. package/src/tests/samples/paramSpec29.py +0 -37
  1069. package/src/tests/samples/paramSpec3.py +0 -71
  1070. package/src/tests/samples/paramSpec30.py +0 -49
  1071. package/src/tests/samples/paramSpec31.py +0 -16
  1072. package/src/tests/samples/paramSpec32.py +0 -57
  1073. package/src/tests/samples/paramSpec33.py +0 -29
  1074. package/src/tests/samples/paramSpec34.py +0 -29
  1075. package/src/tests/samples/paramSpec35.py +0 -24
  1076. package/src/tests/samples/paramSpec36.py +0 -43
  1077. package/src/tests/samples/paramSpec37.py +0 -25
  1078. package/src/tests/samples/paramSpec4.py +0 -109
  1079. package/src/tests/samples/paramSpec5.py +0 -29
  1080. package/src/tests/samples/paramSpec6.py +0 -17
  1081. package/src/tests/samples/paramSpec7.py +0 -22
  1082. package/src/tests/samples/paramSpec8.py +0 -45
  1083. package/src/tests/samples/paramSpec9.py +0 -57
  1084. package/src/tests/samples/paramType1.py +0 -71
  1085. package/src/tests/samples/parameters1.py +0 -16
  1086. package/src/tests/samples/partial1.py +0 -163
  1087. package/src/tests/samples/partial2.py +0 -31
  1088. package/src/tests/samples/private1.py +0 -55
  1089. package/src/tests/samples/private2.py +0 -11
  1090. package/src/tests/samples/project1/pyrightconfig.json +0 -5
  1091. package/src/tests/samples/project1/sample1.py +0 -0
  1092. package/src/tests/samples/project1/subfolder1/sample2.py +0 -0
  1093. package/src/tests/samples/project1/subfolder1/subfolder1-1/sample3.py +0 -0
  1094. package/src/tests/samples/project2/pyrightconfig.json +0 -3
  1095. package/src/tests/samples/project3/pyrightconfig.json +0 -7
  1096. package/src/tests/samples/project4/presentfile.py +0 -0
  1097. package/src/tests/samples/project4/pyrightconfig.json +0 -11
  1098. package/src/tests/samples/project4/subfolder/presentfile2.py +0 -0
  1099. package/src/tests/samples/project4/subfolder/presentfile3.py +0 -0
  1100. package/src/tests/samples/project5/pyrightconfig.json +0 -4
  1101. package/src/tests/samples/project6/app1.py +0 -0
  1102. package/src/tests/samples/project6/app2.py +0 -0
  1103. package/src/tests/samples/project6/projectA/foo/__init__.py +0 -0
  1104. package/src/tests/samples/project6/projectA/foo/bar/__init__.py +0 -0
  1105. package/src/tests/samples/project6/projectB/foo/__init__.py +0 -0
  1106. package/src/tests/samples/project6/projectB/foo/baz/__init__.py +0 -0
  1107. package/src/tests/samples/project_src/src/module1.py +0 -0
  1108. package/src/tests/samples/project_src_is_pkg/src/__init__.py +0 -0
  1109. package/src/tests/samples/project_src_is_pkg/src/module1.py +0 -0
  1110. package/src/tests/samples/project_src_with_config_extra_paths/pyrightconfig.json +0 -3
  1111. package/src/tests/samples/project_src_with_config_extra_paths/src/module1.py +0 -0
  1112. package/src/tests/samples/project_src_with_config_no_extra_paths/pyrightconfig.json +0 -2
  1113. package/src/tests/samples/project_src_with_config_no_extra_paths/src/module1.py +0 -0
  1114. package/src/tests/samples/project_src_with_extra_paths/src/_vendored/vendored1.py +0 -1
  1115. package/src/tests/samples/project_src_with_extra_paths/src/module1.py +0 -2
  1116. package/src/tests/samples/project_with_pyproject_toml/pyproject.toml +0 -7
  1117. package/src/tests/samples/project_with_venv_auto_detect_exclude/myvenv/Lib/site-packages/library1.py +0 -0
  1118. package/src/tests/samples/project_with_venv_auto_detect_exclude/myvenv/pyvenv.cfg +0 -0
  1119. package/src/tests/samples/project_with_venv_auto_detect_exclude/pyrightconfig.json +0 -2
  1120. package/src/tests/samples/project_with_venv_auto_detect_exclude/sample1.py +0 -0
  1121. package/src/tests/samples/project_with_venv_auto_detect_exclude/subfolder1/sample2.py +0 -0
  1122. package/src/tests/samples/project_with_venv_auto_detect_exclude/subfolder1/subfolder1-1/sample3.py +0 -0
  1123. package/src/tests/samples/project_with_venv_auto_detect_include/excluded/excluded1.py +0 -0
  1124. package/src/tests/samples/project_with_venv_auto_detect_include/myvenv/Lib/site-packages/library1.py +0 -0
  1125. package/src/tests/samples/project_with_venv_auto_detect_include/myvenv/pyvenv.cfg +0 -0
  1126. package/src/tests/samples/project_with_venv_auto_detect_include/pyrightconfig.json +0 -3
  1127. package/src/tests/samples/project_with_venv_auto_detect_include/sample1.py +0 -0
  1128. package/src/tests/samples/project_with_venv_auto_detect_include/subfolder1/sample2.py +0 -0
  1129. package/src/tests/samples/project_with_venv_auto_detect_include/subfolder1/subfolder1-1/sample3.py +0 -0
  1130. package/src/tests/samples/properties1.py +0 -64
  1131. package/src/tests/samples/properties10.py +0 -19
  1132. package/src/tests/samples/properties11.py +0 -45
  1133. package/src/tests/samples/properties12.py +0 -23
  1134. package/src/tests/samples/properties13.py +0 -15
  1135. package/src/tests/samples/properties2.py +0 -34
  1136. package/src/tests/samples/properties3.py +0 -93
  1137. package/src/tests/samples/properties4.py +0 -17
  1138. package/src/tests/samples/properties5.py +0 -29
  1139. package/src/tests/samples/properties6.py +0 -35
  1140. package/src/tests/samples/properties7.py +0 -30
  1141. package/src/tests/samples/properties8.py +0 -26
  1142. package/src/tests/samples/properties9.py +0 -24
  1143. package/src/tests/samples/protocol1.py +0 -132
  1144. package/src/tests/samples/protocol10.py +0 -36
  1145. package/src/tests/samples/protocol11.py +0 -32
  1146. package/src/tests/samples/protocol12.py +0 -12
  1147. package/src/tests/samples/protocol13.py +0 -26
  1148. package/src/tests/samples/protocol14.py +0 -27
  1149. package/src/tests/samples/protocol15.py +0 -27
  1150. package/src/tests/samples/protocol16.py +0 -22
  1151. package/src/tests/samples/protocol17.py +0 -94
  1152. package/src/tests/samples/protocol18.py +0 -27
  1153. package/src/tests/samples/protocol19.py +0 -39
  1154. package/src/tests/samples/protocol2.py +0 -38
  1155. package/src/tests/samples/protocol20.py +0 -22
  1156. package/src/tests/samples/protocol21.py +0 -26
  1157. package/src/tests/samples/protocol22.py +0 -43
  1158. package/src/tests/samples/protocol23.py +0 -41
  1159. package/src/tests/samples/protocol24.py +0 -74
  1160. package/src/tests/samples/protocol25.py +0 -31
  1161. package/src/tests/samples/protocol26.py +0 -40
  1162. package/src/tests/samples/protocol27.py +0 -76
  1163. package/src/tests/samples/protocol28.py +0 -32
  1164. package/src/tests/samples/protocol29.py +0 -26
  1165. package/src/tests/samples/protocol3.py +0 -110
  1166. package/src/tests/samples/protocol30.py +0 -30
  1167. package/src/tests/samples/protocol31.py +0 -22
  1168. package/src/tests/samples/protocol32.py +0 -67
  1169. package/src/tests/samples/protocol33.py +0 -39
  1170. package/src/tests/samples/protocol34.py +0 -21
  1171. package/src/tests/samples/protocol4.py +0 -22
  1172. package/src/tests/samples/protocol5.py +0 -25
  1173. package/src/tests/samples/protocol6.py +0 -65
  1174. package/src/tests/samples/protocol7.py +0 -24
  1175. package/src/tests/samples/protocol8.py +0 -34
  1176. package/src/tests/samples/protocol9.py +0 -35
  1177. package/src/tests/samples/protocolModule1.py +0 -15
  1178. package/src/tests/samples/protocolModule2.py +0 -83
  1179. package/src/tests/samples/protocolModule3.py +0 -14
  1180. package/src/tests/samples/protocolModule4.py +0 -26
  1181. package/src/tests/samples/pseudoGeneric1.py +0 -20
  1182. package/src/tests/samples/pyrightIgnore1.py +0 -11
  1183. package/src/tests/samples/pyrightIgnore2.py +0 -24
  1184. package/src/tests/samples/python2.py +0 -31
  1185. package/src/tests/samples/recursiveTypeAlias1.py +0 -79
  1186. package/src/tests/samples/recursiveTypeAlias2.py +0 -32
  1187. package/src/tests/samples/recursiveTypeAlias3.py +0 -26
  1188. package/src/tests/samples/recursiveTypeAlias4.py +0 -55
  1189. package/src/tests/samples/recursiveTypeAlias5.pyi +0 -10
  1190. package/src/tests/samples/recursiveTypeAlias6.py +0 -25
  1191. package/src/tests/samples/recursiveTypeAlias7.py +0 -15
  1192. package/src/tests/samples/recursiveTypeAlias8.py +0 -38
  1193. package/src/tests/samples/recursiveTypeAlias9.py +0 -22
  1194. package/src/tests/samples/required1.py +0 -47
  1195. package/src/tests/samples/required2.py +0 -56
  1196. package/src/tests/samples/required3.py +0 -22
  1197. package/src/tests/samples/returnTypes1.py +0 -26
  1198. package/src/tests/samples/revealedType1.py +0 -30
  1199. package/src/tests/samples/sample1.py +0 -6
  1200. package/src/tests/samples/self1.py +0 -93
  1201. package/src/tests/samples/self2.py +0 -195
  1202. package/src/tests/samples/self3.py +0 -9
  1203. package/src/tests/samples/self4.py +0 -18
  1204. package/src/tests/samples/self5.py +0 -26
  1205. package/src/tests/samples/setComprehension1.py +0 -34
  1206. package/src/tests/samples/slots1.py +0 -63
  1207. package/src/tests/samples/slots2.py +0 -38
  1208. package/src/tests/samples/slots3.py +0 -35
  1209. package/src/tests/samples/specialization1.py +0 -78
  1210. package/src/tests/samples/specialization2.py +0 -51
  1211. package/src/tests/samples/staticExpressions1.py +0 -52
  1212. package/src/tests/samples/strings1.py +0 -22
  1213. package/src/tests/samples/subscript1.py +0 -74
  1214. package/src/tests/samples/subscript2.py +0 -55
  1215. package/src/tests/samples/subscript3.py +0 -135
  1216. package/src/tests/samples/suiteExpectedColon1.py +0 -4
  1217. package/src/tests/samples/suiteExpectedColon2.py +0 -2
  1218. package/src/tests/samples/suiteExpectedColon3.py +0 -2
  1219. package/src/tests/samples/super1.py +0 -57
  1220. package/src/tests/samples/super2.py +0 -29
  1221. package/src/tests/samples/super3.py +0 -10
  1222. package/src/tests/samples/super4.py +0 -24
  1223. package/src/tests/samples/super5.py +0 -28
  1224. package/src/tests/samples/super6.py +0 -17
  1225. package/src/tests/samples/super7.py +0 -52
  1226. package/src/tests/samples/super8.py +0 -7
  1227. package/src/tests/samples/super9.py +0 -36
  1228. package/src/tests/samples/test_file1.py +0 -0
  1229. package/src/tests/samples/threePartVersion1.py +0 -33
  1230. package/src/tests/samples/totalOrdering1.py +0 -52
  1231. package/src/tests/samples/tryExcept1.py +0 -39
  1232. package/src/tests/samples/tryExcept10.py +0 -12
  1233. package/src/tests/samples/tryExcept2.py +0 -16
  1234. package/src/tests/samples/tryExcept3.py +0 -12
  1235. package/src/tests/samples/tryExcept4.py +0 -28
  1236. package/src/tests/samples/tryExcept5.py +0 -30
  1237. package/src/tests/samples/tryExcept6.py +0 -27
  1238. package/src/tests/samples/tryExcept7.py +0 -17
  1239. package/src/tests/samples/tryExcept8.py +0 -69
  1240. package/src/tests/samples/tryExcept9.py +0 -42
  1241. package/src/tests/samples/tupleUnpack1.py +0 -63
  1242. package/src/tests/samples/tupleUnpack2.py +0 -56
  1243. package/src/tests/samples/tupleUnpack3.py +0 -28
  1244. package/src/tests/samples/tuples1.py +0 -185
  1245. package/src/tests/samples/tuples10.py +0 -30
  1246. package/src/tests/samples/tuples11.py +0 -21
  1247. package/src/tests/samples/tuples12.py +0 -31
  1248. package/src/tests/samples/tuples13.py +0 -26
  1249. package/src/tests/samples/tuples15.py +0 -16
  1250. package/src/tests/samples/tuples16.py +0 -14
  1251. package/src/tests/samples/tuples2.py +0 -23
  1252. package/src/tests/samples/tuples3.py +0 -15
  1253. package/src/tests/samples/tuples4.py +0 -21
  1254. package/src/tests/samples/tuples5.py +0 -16
  1255. package/src/tests/samples/tuples6.py +0 -56
  1256. package/src/tests/samples/tuples7.py +0 -61
  1257. package/src/tests/samples/tuples8.py +0 -98
  1258. package/src/tests/samples/tuples9.py +0 -17
  1259. package/src/tests/samples/typeAlias1.py +0 -37
  1260. package/src/tests/samples/typeAlias10.py +0 -45
  1261. package/src/tests/samples/typeAlias11.py +0 -37
  1262. package/src/tests/samples/typeAlias12.py +0 -20
  1263. package/src/tests/samples/typeAlias13.py +0 -53
  1264. package/src/tests/samples/typeAlias14.py +0 -29
  1265. package/src/tests/samples/typeAlias15.py +0 -24
  1266. package/src/tests/samples/typeAlias16.py +0 -24
  1267. package/src/tests/samples/typeAlias2.py +0 -26
  1268. package/src/tests/samples/typeAlias3.py +0 -35
  1269. package/src/tests/samples/typeAlias4.py +0 -68
  1270. package/src/tests/samples/typeAlias5.py +0 -56
  1271. package/src/tests/samples/typeAlias6.py +0 -51
  1272. package/src/tests/samples/typeAlias7.py +0 -50
  1273. package/src/tests/samples/typeAlias8.py +0 -24
  1274. package/src/tests/samples/typeAlias9.py +0 -35
  1275. package/src/tests/samples/typeGuard1.py +0 -68
  1276. package/src/tests/samples/typeGuard2.py +0 -58
  1277. package/src/tests/samples/typeGuard3.py +0 -98
  1278. package/src/tests/samples/typeIgnore1.py +0 -10
  1279. package/src/tests/samples/typeIgnore2.py +0 -20
  1280. package/src/tests/samples/typeIgnore3.py +0 -22
  1281. package/src/tests/samples/typeIgnore4.py +0 -10
  1282. package/src/tests/samples/typeIgnore5.py +0 -7
  1283. package/src/tests/samples/typeNarrowing1.py +0 -56
  1284. package/src/tests/samples/typeNarrowing2.py +0 -14
  1285. package/src/tests/samples/typeNarrowing3.py +0 -47
  1286. package/src/tests/samples/typeNarrowing4.py +0 -24
  1287. package/src/tests/samples/typeNarrowing5.py +0 -19
  1288. package/src/tests/samples/typeNarrowing6.py +0 -27
  1289. package/src/tests/samples/typeNarrowing7.py +0 -71
  1290. package/src/tests/samples/typeNarrowingAssert1.py +0 -24
  1291. package/src/tests/samples/typeNarrowingCallable1.py +0 -78
  1292. package/src/tests/samples/typeNarrowingEnum1.py +0 -58
  1293. package/src/tests/samples/typeNarrowingEnum2.py +0 -71
  1294. package/src/tests/samples/typeNarrowingFalsy1.py +0 -50
  1295. package/src/tests/samples/typeNarrowingIn1.py +0 -97
  1296. package/src/tests/samples/typeNarrowingIsNone1.py +0 -56
  1297. package/src/tests/samples/typeNarrowingIsNone2.py +0 -8
  1298. package/src/tests/samples/typeNarrowingIsNoneTuple1.py +0 -42
  1299. package/src/tests/samples/typeNarrowingIsNoneTuple2.py +0 -35
  1300. package/src/tests/samples/typeNarrowingIsinstance1.py +0 -162
  1301. package/src/tests/samples/typeNarrowingIsinstance2.py +0 -14
  1302. package/src/tests/samples/typeNarrowingIsinstance3.py +0 -78
  1303. package/src/tests/samples/typeNarrowingIsinstance4.py +0 -50
  1304. package/src/tests/samples/typeNarrowingIsinstance5.py +0 -39
  1305. package/src/tests/samples/typeNarrowingIsinstance6.py +0 -77
  1306. package/src/tests/samples/typeNarrowingIsinstance7.py +0 -19
  1307. package/src/tests/samples/typeNarrowingIsinstance8.py +0 -19
  1308. package/src/tests/samples/typeNarrowingLiteral1.py +0 -35
  1309. package/src/tests/samples/typeNarrowingLiteral2.py +0 -63
  1310. package/src/tests/samples/typeNarrowingLiteralMember1.py +0 -140
  1311. package/src/tests/samples/typeNarrowingLocalConst1.py +0 -136
  1312. package/src/tests/samples/typeNarrowingNoneMember1.py +0 -102
  1313. package/src/tests/samples/typeNarrowingTuple1.py +0 -23
  1314. package/src/tests/samples/typeNarrowingTupleLength1.py +0 -47
  1315. package/src/tests/samples/typeNarrowingTypeIs1.py +0 -95
  1316. package/src/tests/samples/typeNarrowingTypedDict1.py +0 -99
  1317. package/src/tests/samples/typeNarrowingTypedDict2.py +0 -35
  1318. package/src/tests/samples/typeNarrowingTypedDict3.py +0 -45
  1319. package/src/tests/samples/typePromotions1.py +0 -30
  1320. package/src/tests/samples/typeVar1.py +0 -23
  1321. package/src/tests/samples/typeVar10.py +0 -21
  1322. package/src/tests/samples/typeVar11.py +0 -12
  1323. package/src/tests/samples/typeVar2.py +0 -26
  1324. package/src/tests/samples/typeVar3.py +0 -73
  1325. package/src/tests/samples/typeVar4.py +0 -45
  1326. package/src/tests/samples/typeVar5.py +0 -75
  1327. package/src/tests/samples/typeVar6.py +0 -115
  1328. package/src/tests/samples/typeVar7.py +0 -171
  1329. package/src/tests/samples/typeVar8.py +0 -30
  1330. package/src/tests/samples/typeVar9.py +0 -118
  1331. package/src/tests/samples/typedDict1.py +0 -63
  1332. package/src/tests/samples/typedDict10.py +0 -34
  1333. package/src/tests/samples/typedDict11.py +0 -12
  1334. package/src/tests/samples/typedDict12.py +0 -103
  1335. package/src/tests/samples/typedDict13.py +0 -14
  1336. package/src/tests/samples/typedDict14.py +0 -25
  1337. package/src/tests/samples/typedDict15.py +0 -53
  1338. package/src/tests/samples/typedDict16.py +0 -103
  1339. package/src/tests/samples/typedDict17.py +0 -24
  1340. package/src/tests/samples/typedDict18.py +0 -43
  1341. package/src/tests/samples/typedDict2.py +0 -56
  1342. package/src/tests/samples/typedDict3.py +0 -40
  1343. package/src/tests/samples/typedDict4.py +0 -68
  1344. package/src/tests/samples/typedDict5.py +0 -50
  1345. package/src/tests/samples/typedDict6.py +0 -77
  1346. package/src/tests/samples/typedDict7.py +0 -22
  1347. package/src/tests/samples/typedDict8.py +0 -19
  1348. package/src/tests/samples/typedDict9.py +0 -22
  1349. package/src/tests/samples/unbound1.py +0 -18
  1350. package/src/tests/samples/unbound2.py +0 -12
  1351. package/src/tests/samples/unbound3.py +0 -13
  1352. package/src/tests/samples/unbound4.py +0 -25
  1353. package/src/tests/samples/unicode1.py +0 -39
  1354. package/src/tests/samples/uninitializedVariable1.py +0 -27
  1355. package/src/tests/samples/unions1.py +0 -79
  1356. package/src/tests/samples/unions2.py +0 -15
  1357. package/src/tests/samples/unions3.py +0 -48
  1358. package/src/tests/samples/unions4.py +0 -20
  1359. package/src/tests/samples/unions5.py +0 -43
  1360. package/src/tests/samples/unnecessaryCast1.py +0 -13
  1361. package/src/tests/samples/unnecessaryIsInstance1.py +0 -91
  1362. package/src/tests/samples/unnecessaryIsSubclass1.py +0 -22
  1363. package/src/tests/samples/unpack1.py +0 -56
  1364. package/src/tests/samples/unpack2.py +0 -27
  1365. package/src/tests/samples/unpack3.py +0 -16
  1366. package/src/tests/samples/unpack4.py +0 -15
  1367. package/src/tests/samples/unreachable1.py +0 -112
  1368. package/src/tests/samples/unusedCallResult1.py +0 -67
  1369. package/src/tests/samples/unusedCoroutine1.py +0 -23
  1370. package/src/tests/samples/unusedExpression1.py +0 -34
  1371. package/src/tests/samples/unusedVariable1.py +0 -21
  1372. package/src/tests/samples/variadicTypeVar1.py +0 -51
  1373. package/src/tests/samples/variadicTypeVar10.py +0 -65
  1374. package/src/tests/samples/variadicTypeVar11.py +0 -72
  1375. package/src/tests/samples/variadicTypeVar12.py +0 -26
  1376. package/src/tests/samples/variadicTypeVar13.py +0 -35
  1377. package/src/tests/samples/variadicTypeVar14.py +0 -72
  1378. package/src/tests/samples/variadicTypeVar2.py +0 -63
  1379. package/src/tests/samples/variadicTypeVar3.py +0 -86
  1380. package/src/tests/samples/variadicTypeVar4.py +0 -71
  1381. package/src/tests/samples/variadicTypeVar5.py +0 -131
  1382. package/src/tests/samples/variadicTypeVar6.py +0 -78
  1383. package/src/tests/samples/variadicTypeVar7.py +0 -59
  1384. package/src/tests/samples/variadicTypeVar8.py +0 -116
  1385. package/src/tests/samples/variadicTypeVar9.py +0 -38
  1386. package/src/tests/samples/with1.py +0 -117
  1387. package/src/tests/samples/with2.py +0 -63
  1388. package/src/tests/samples/with3.py +0 -66
  1389. package/src/tests/samples/with4.py +0 -24
  1390. package/src/tests/samples/with5.py +0 -33
  1391. package/src/tests/samples/zipfs/bad.egg +0 -1
  1392. package/src/tests/samples/zipfs/bad.zip +0 -1
  1393. package/src/tests/samples/zipfs/basic.egg +0 -0
  1394. package/src/tests/samples/zipfs/basic.zip +0 -0
  1395. package/src/tests/samples/zipfs/corrupt.egg +0 -0
  1396. package/src/tests/samples/zipfs/corrupt.zip +0 -0
  1397. package/src/tests/sourceFile.test.ts +0 -25
  1398. package/src/tests/stringUtils.test.ts +0 -63
  1399. package/src/tests/symbolNameUtils.test.ts +0 -77
  1400. package/src/tests/testState.test.ts +0 -579
  1401. package/src/tests/testUtils.ts +0 -251
  1402. package/src/tests/tokenizer.test.ts +0 -1534
  1403. package/src/tests/typeEvaluator1.test.ts +0 -1372
  1404. package/src/tests/typeEvaluator2.test.ts +0 -1253
  1405. package/src/tests/typeEvaluator3.test.ts +0 -1279
  1406. package/src/tests/typeEvaluator4.test.ts +0 -1178
  1407. package/src/tests/updateSymbolReference.test.ts +0 -1107
  1408. package/src/tests/zipfs.test.ts +0 -116
  1409. package/src/workspaceMap.ts +0 -76
@@ -1,3126 +0,0 @@
1
- /*
2
- * typeUtils.ts
3
- * Copyright (c) Microsoft Corporation.
4
- * Licensed under the MIT license.
5
- * Author: Eric Traut
6
- *
7
- * Collection of functions that operate on Type objects.
8
- */
9
-
10
- import { appendArray } from '../common/collectionUtils';
11
- import { assert } from '../common/debug';
12
- import { ParameterCategory } from '../parser/parseNodes';
13
- import { DeclarationType } from './declaration';
14
- import { Symbol, SymbolFlags, SymbolTable } from './symbol';
15
- import { isDunderName } from './symbolNameUtils';
16
- import { isTypedDictMemberAccessedThroughIndex } from './symbolUtils';
17
- import {
18
- AnyType,
19
- ClassType,
20
- combineTypes,
21
- findSubtype,
22
- FunctionParameter,
23
- FunctionType,
24
- FunctionTypeFlags,
25
- isAny,
26
- isAnyOrUnknown,
27
- isClass,
28
- isClassInstance,
29
- isFunction,
30
- isInstantiableClass,
31
- isNever,
32
- isNoneInstance,
33
- isOverloadedFunction,
34
- isParamSpec,
35
- isTypeSame,
36
- isTypeVar,
37
- isUnbound,
38
- isUnion,
39
- isUnknown,
40
- isUnpackedClass,
41
- isVariadicTypeVar,
42
- maxTypeRecursionCount,
43
- ModuleType,
44
- NeverType,
45
- NoneType,
46
- OverloadedFunctionType,
47
- ParamSpecEntry,
48
- ParamSpecValue,
49
- SpecializedFunctionTypes,
50
- TupleTypeArgument,
51
- Type,
52
- TypeBase,
53
- TypeCategory,
54
- TypeCondition,
55
- TypeFlags,
56
- TypeVarScopeId,
57
- TypeVarType,
58
- UnionType,
59
- UnknownType,
60
- WildcardTypeVarScopeId,
61
- } from './types';
62
- import { TypeVarContext } from './typeVarContext';
63
-
64
- export interface ClassMember {
65
- // Symbol
66
- symbol: Symbol;
67
-
68
- // Partially-specialized class that contains the class member
69
- classType: ClassType | UnknownType;
70
-
71
- // True if it is an instance or class member; it can be both a class and
72
- // an instance member in cases where a class variable is overridden
73
- // by an instance variable
74
- isInstanceMember: boolean;
75
- isClassMember: boolean;
76
-
77
- // True if explicitly declared as "ClassVar" and therefore is
78
- // a type violation if it is overwritten by an instance variable
79
- isClassVar: boolean;
80
-
81
- // True if member has declared type, false if inferred
82
- isTypeDeclared: boolean;
83
-
84
- // True if member lookup skipped an undeclared (inferred) type
85
- // in a subclass before finding a declared type in a base class
86
- skippedUndeclaredType: boolean;
87
- }
88
-
89
- export const enum ClassMemberLookupFlags {
90
- Default = 0,
91
-
92
- // By default, the original (derived) class is searched along
93
- // with its base classes. If this flag is set, the original
94
- // class is skipped and only the base classes are searched.
95
- SkipOriginalClass = 1 << 0,
96
-
97
- // By default, base classes are searched as well as the
98
- // original (derived) class. If this flag is set, no recursion
99
- // is performed.
100
- SkipBaseClasses = 1 << 1,
101
-
102
- // Skip the 'object' base class in particular.
103
- SkipObjectBaseClass = 1 << 2,
104
-
105
- // By default, both class and instance variables are searched.
106
- // If this flag is set, the instance variables are skipped.
107
- SkipInstanceVariables = 1 << 3,
108
-
109
- // By default, the first symbol is returned even if it has only
110
- // an inferred type associated with it. If this flag is set,
111
- // the search looks only for symbols with declared types.
112
- DeclaredTypesOnly = 1 << 4,
113
-
114
- // Skip the 'type' base class in particular.
115
- SkipTypeBaseClass = 1 << 5,
116
- }
117
-
118
- export const enum ClassIteratorFlags {
119
- Default = 0,
120
-
121
- // By default, the original (derived) class is searched along
122
- // with its base classes. If this flag is set, the original
123
- // class is skipped and only the base classes are searched.
124
- SkipOriginalClass = 1 << 0,
125
-
126
- // By default, base classes are searched as well as the
127
- // original (derived) class. If this flag is set, no recursion
128
- // is performed.
129
- SkipBaseClasses = 1 << 1,
130
-
131
- // Skip the 'object' base class in particular.
132
- SkipObjectBaseClass = 1 << 2,
133
-
134
- // Skip the 'type' base class in particular.
135
- SkipTypeBaseClass = 1 << 3,
136
- }
137
-
138
- export const enum AssignTypeFlags {
139
- Default = 0,
140
-
141
- // Require invariance with respect to class matching? Normally
142
- // subclasses are allowed.
143
- EnforceInvariance = 1 << 0,
144
-
145
- // The caller has swapped the source and dest types because
146
- // the types are contravariant. Perform type var matching
147
- // on dest type vars rather than source type var.
148
- ReverseTypeVarMatching = 1 << 1,
149
-
150
- // Normally invariant and contravariant TypeVars cannot be
151
- // narrowed. This overrides the standard behavior.
152
- AllowTypeVarNarrowing = 1 << 2,
153
-
154
- // Normally type vars are treated as variables that need to
155
- // be "solved". If this flag is set, they are treated as types
156
- // that must match. It is used for overload consistency checking.
157
- SkipSolveTypeVars = 1 << 3,
158
-
159
- // If the dest is not Any but the src is Any, treat it
160
- // as incompatible. Also, treat all source TypeVars as their
161
- // concrete counterparts. This option is used for validating
162
- // whether overload signatures overlap.
163
- OverloadOverlapCheck = 1 << 4,
164
-
165
- // For function types, skip the return type check.
166
- SkipFunctionReturnTypeCheck = 1 << 5,
167
-
168
- // Allow bool values to be assigned to TypeGuard[x] types.
169
- AllowBoolTypeGuard = 1 << 6,
170
-
171
- // In most cases, literals are stripped when assigning to a
172
- // type variable. This overrides the standard behavior.
173
- RetainLiteralsForTypeVar = 1 << 7,
174
-
175
- // When validating the type of a self or cls parameter, allow
176
- // a type mismatch. This is used in overload consistency validation
177
- // because overloads can provide explicit type annotations for self
178
- // or cls.
179
- SkipSelfClsTypeCheck = 1 << 8,
180
-
181
- // If an assignment is made to a TypeVar that is out of scope,
182
- // do not generate an error. This is used for populating the
183
- // typeVarContext when handling contravariant parameters in a callable.
184
- IgnoreTypeVarScope = 1 << 9,
185
-
186
- // We're initially populating the typeVarContext with an expected type,
187
- // so TypeVars should match the specified type exactly rather than
188
- // employing narrowing or widening, and don't strip literals.
189
- PopulatingExpectedType = 1 << 10,
190
-
191
- // We're comparing type compatibility of two distinct recursive types.
192
- // This has the potential of recursing infinitely. This flag allows us
193
- // to detect the recursion after the first level of checking.
194
- SkipRecursiveTypeCheck = 1 << 11,
195
- }
196
-
197
- export enum ParameterSource {
198
- PositionOnly,
199
- PositionOrKeyword,
200
- KeywordOnly,
201
- }
202
-
203
- export interface VirtualParameterDetails {
204
- param: FunctionParameter;
205
- type: Type;
206
- defaultArgType?: Type | undefined;
207
- index: number;
208
- source: ParameterSource;
209
- }
210
-
211
- export interface ParameterListDetails {
212
- // Virtual parameter list that refers to original parameters
213
- params: VirtualParameterDetails[];
214
-
215
- // Counts of virtual parameters
216
- positionOnlyParamCount: number;
217
- positionParamCount: number;
218
-
219
- // Indexes into virtual parameter list
220
- kwargsIndex?: number;
221
- argsIndex?: number;
222
- firstKeywordOnlyIndex?: number;
223
- firstPositionOrKeywordIndex: number;
224
-
225
- // Other information
226
- hasUnpackedVariadicTypeVar: boolean;
227
- hasUnpackedTypedDict: boolean;
228
- }
229
-
230
- // Examines the input parameters within a function signature and creates a
231
- // "virtual list" of parameters, stripping out any markers and expanding
232
- // any *args with unpacked tuples.
233
- export function getParameterListDetails(type: FunctionType): ParameterListDetails {
234
- const result: ParameterListDetails = {
235
- firstPositionOrKeywordIndex: 0,
236
- positionParamCount: 0,
237
- positionOnlyParamCount: 0,
238
- params: [],
239
- hasUnpackedVariadicTypeVar: false,
240
- hasUnpackedTypedDict: false,
241
- };
242
-
243
- let positionOnlyIndex = type.details.parameters.findIndex(
244
- (p) => p.category === ParameterCategory.Simple && !p.name
245
- );
246
-
247
- // Handle the old (pre Python 3.8) way of specifying positional-only
248
- // parameters by naming them with "__".
249
- if (positionOnlyIndex < 0) {
250
- for (let i = 0; i < type.details.parameters.length; i++) {
251
- const p = type.details.parameters[i];
252
- if (p.category !== ParameterCategory.Simple) {
253
- break;
254
- }
255
-
256
- if (!p.name) {
257
- break;
258
- }
259
-
260
- if (isDunderName(p.name) || !p.name.startsWith('__')) {
261
- break;
262
- }
263
-
264
- positionOnlyIndex = i + 1;
265
- }
266
- }
267
-
268
- if (positionOnlyIndex >= 0) {
269
- result.firstPositionOrKeywordIndex = positionOnlyIndex;
270
- }
271
-
272
- for (let i = 0; i < positionOnlyIndex; i++) {
273
- if (type.details.parameters[i].hasDefault) {
274
- break;
275
- }
276
-
277
- result.positionOnlyParamCount++;
278
- }
279
-
280
- let sawKeywordOnlySeparator = false;
281
-
282
- const addVirtualParameter = (
283
- param: FunctionParameter,
284
- index: number,
285
- typeOverride?: Type,
286
- defaultArgTypeOverride?: Type
287
- ) => {
288
- if (param.name) {
289
- let source: ParameterSource;
290
- if (param.category === ParameterCategory.VarArgList) {
291
- source = ParameterSource.PositionOnly;
292
- } else if (sawKeywordOnlySeparator) {
293
- source = ParameterSource.KeywordOnly;
294
- } else if (positionOnlyIndex >= 0 && index < positionOnlyIndex) {
295
- source = ParameterSource.PositionOnly;
296
- } else {
297
- source = ParameterSource.PositionOrKeyword;
298
- }
299
-
300
- result.params.push({
301
- param,
302
- index,
303
- type: typeOverride ?? FunctionType.getEffectiveParameterType(type, index),
304
- defaultArgType: defaultArgTypeOverride,
305
- source,
306
- });
307
- }
308
- };
309
-
310
- type.details.parameters.forEach((param, index) => {
311
- if (param.category === ParameterCategory.VarArgList) {
312
- // If this is an unpacked tuple, expand the entries.
313
- const paramType = FunctionType.getEffectiveParameterType(type, index);
314
- if (param.name && isUnpackedClass(paramType) && paramType.tupleTypeArguments) {
315
- paramType.tupleTypeArguments.forEach((tupleArg, index) => {
316
- const category =
317
- isVariadicTypeVar(tupleArg.type) || tupleArg.isUnbounded
318
- ? ParameterCategory.VarArgList
319
- : ParameterCategory.Simple;
320
-
321
- if (category === ParameterCategory.VarArgList) {
322
- result.argsIndex = result.params.length;
323
- }
324
-
325
- if (isVariadicTypeVar(param.type)) {
326
- result.hasUnpackedVariadicTypeVar = true;
327
- }
328
-
329
- addVirtualParameter(
330
- {
331
- category,
332
- name: `${param.name}[${index.toString()}]`,
333
- isNameSynthesized: true,
334
- type: tupleArg.type,
335
- hasDeclaredType: true,
336
- },
337
- index,
338
- tupleArg.type
339
- );
340
- });
341
- } else {
342
- if (param.name && result.argsIndex === undefined) {
343
- result.argsIndex = result.params.length;
344
-
345
- if (isVariadicTypeVar(param.type)) {
346
- result.hasUnpackedVariadicTypeVar = true;
347
- }
348
- }
349
-
350
- // Normally, a VarArgList parameter (either named or as an unnamed separator)
351
- // would signify the start of keyword-only parameters. However, we can construct
352
- // callable signatures that defy this rule by using Callable and TypeVarTuples
353
- // or unpacked tuples.
354
- if (!sawKeywordOnlySeparator && (positionOnlyIndex < 0 || index >= positionOnlyIndex)) {
355
- result.firstKeywordOnlyIndex = result.params.length;
356
- if (param.name) {
357
- result.firstKeywordOnlyIndex++;
358
- }
359
- sawKeywordOnlySeparator = true;
360
- }
361
-
362
- addVirtualParameter(param, index);
363
- }
364
- } else if (param.category === ParameterCategory.VarArgDictionary) {
365
- sawKeywordOnlySeparator = true;
366
-
367
- // Is this an unpacked TypedDict? If so, expand the entries.
368
- if (isClassInstance(param.type) && isUnpackedClass(param.type) && param.type.details.typedDictEntries) {
369
- if (result.firstKeywordOnlyIndex === undefined) {
370
- result.firstKeywordOnlyIndex = result.params.length;
371
- }
372
-
373
- param.type.details.typedDictEntries.forEach((entry, name) => {
374
- addVirtualParameter(
375
- {
376
- category: ParameterCategory.Simple,
377
- name,
378
- type: entry.valueType,
379
- hasDeclaredType: true,
380
- hasDefault: !entry.isRequired,
381
- },
382
- index,
383
- entry.valueType
384
- );
385
- });
386
-
387
- result.hasUnpackedTypedDict = true;
388
- } else if (param.name) {
389
- if (result.kwargsIndex === undefined) {
390
- result.kwargsIndex = result.params.length;
391
- }
392
-
393
- if (result.firstKeywordOnlyIndex === undefined) {
394
- result.firstKeywordOnlyIndex = result.params.length;
395
- }
396
-
397
- addVirtualParameter(param, index);
398
- }
399
- } else if (param.category === ParameterCategory.Simple) {
400
- if (param.name && !sawKeywordOnlySeparator) {
401
- result.positionParamCount++;
402
- }
403
-
404
- addVirtualParameter(
405
- param,
406
- index,
407
- /* typeOverride */ undefined,
408
- type.specializedTypes?.parameterDefaultArgs
409
- ? type.specializedTypes?.parameterDefaultArgs[index]
410
- : undefined
411
- );
412
- }
413
- });
414
-
415
- return result;
416
- }
417
-
418
- export function isOptionalType(type: Type): boolean {
419
- if (isUnion(type)) {
420
- return findSubtype(type, (subtype) => isNoneInstance(subtype)) !== undefined;
421
- }
422
-
423
- return false;
424
- }
425
-
426
- // Calls a callback for each subtype and combines the results
427
- // into a final type.
428
- export function mapSubtypes(type: Type, callback: (type: Type) => Type | undefined): Type {
429
- if (isUnion(type)) {
430
- const newSubtypes: Type[] = [];
431
- let typeChanged = false;
432
-
433
- type.subtypes.forEach((subtype) => {
434
- const transformedType = callback(subtype);
435
- if (transformedType) {
436
- if (transformedType !== subtype) {
437
- newSubtypes.push(addConditionToType(transformedType, getTypeCondition(type)));
438
- typeChanged = true;
439
- } else {
440
- newSubtypes.push(subtype);
441
- }
442
- } else {
443
- typeChanged = true;
444
- }
445
- });
446
-
447
- if (!typeChanged) {
448
- return type;
449
- }
450
-
451
- const newType = combineTypes(newSubtypes);
452
-
453
- // Do our best to retain type aliases.
454
- if (newType.category === TypeCategory.Union) {
455
- UnionType.addTypeAliasSource(newType, type);
456
- }
457
- return newType;
458
- }
459
-
460
- const transformedSubtype = callback(type);
461
- if (!transformedSubtype) {
462
- return NeverType.createNever();
463
- }
464
- return transformedSubtype;
465
- }
466
-
467
- export function doForEachSubtype(type: Type, callback: (type: Type, index: number) => void): void {
468
- if (isUnion(type)) {
469
- type.subtypes.forEach((subtype, index) => {
470
- callback(subtype, index);
471
- });
472
- } else {
473
- callback(type, 0);
474
- }
475
- }
476
-
477
- // Determines if all of the types in the array are the same.
478
- export function areTypesSame(types: Type[], ignorePseudoGeneric: boolean): boolean {
479
- if (types.length < 2) {
480
- return true;
481
- }
482
-
483
- for (let i = 1; i < types.length; i++) {
484
- if (!isTypeSame(types[0], types[i], ignorePseudoGeneric)) {
485
- return false;
486
- }
487
- }
488
-
489
- return true;
490
- }
491
-
492
- // If either type is "Unknown" (versus Any), propagate the Unknown. Preserve
493
- // the incomplete flag on the unknown if present. The caller should verify that
494
- // one or the other type is Unknown or Any.
495
- export function preserveUnknown(type1: Type, type2: Type): AnyType | UnknownType {
496
- if (isUnknown(type1) && type1.isIncomplete) {
497
- return type1;
498
- } else if (isUnknown(type2) && type2.isIncomplete) {
499
- return type2;
500
- } else if (isUnknown(type1) || isUnknown(type2)) {
501
- return UnknownType.create();
502
- } else {
503
- return AnyType.create();
504
- }
505
- }
506
-
507
- // Determines whether the specified type is a type that can be
508
- // combined with other types for a union.
509
- export function isUnionableType(subtypes: Type[]): boolean {
510
- let typeFlags = TypeFlags.Instance | TypeFlags.Instantiable;
511
-
512
- for (const subtype of subtypes) {
513
- typeFlags &= subtype.flags;
514
- }
515
-
516
- // All subtypes need to be instantiable. Some types (like Any
517
- // and None) are both instances and instantiable. It's OK to
518
- // include some of these, but at least one subtype needs to
519
- // be definitively instantiable (not an instance).
520
- return (typeFlags & TypeFlags.Instantiable) !== 0 && (typeFlags & TypeFlags.Instance) === 0;
521
- }
522
-
523
- export function derivesFromAnyOrUnknown(type: Type): boolean {
524
- let anyOrUnknown = false;
525
-
526
- doForEachSubtype(type, (subtype) => {
527
- if (isAnyOrUnknown(type)) {
528
- anyOrUnknown = true;
529
- } else if (isInstantiableClass(subtype)) {
530
- if (ClassType.hasUnknownBaseClass(subtype)) {
531
- anyOrUnknown = true;
532
- }
533
- } else if (isClassInstance(subtype)) {
534
- if (ClassType.hasUnknownBaseClass(subtype)) {
535
- anyOrUnknown = true;
536
- }
537
- }
538
- });
539
-
540
- return anyOrUnknown;
541
- }
542
-
543
- export function getFullNameOfType(type: Type): string | undefined {
544
- if (type.typeAliasInfo?.fullName) {
545
- return type.typeAliasInfo.fullName;
546
- }
547
-
548
- switch (type.category) {
549
- case TypeCategory.Any:
550
- case TypeCategory.Unknown:
551
- return 'typing.Any';
552
-
553
- case TypeCategory.None:
554
- return 'builtins.None';
555
-
556
- case TypeCategory.Class:
557
- return type.details.fullName;
558
-
559
- case TypeCategory.Function:
560
- return type.details.fullName;
561
-
562
- case TypeCategory.Module:
563
- return type.moduleName;
564
-
565
- case TypeCategory.OverloadedFunction:
566
- return type.overloads[0].details.fullName;
567
- }
568
-
569
- return undefined;
570
- }
571
-
572
- export function stripLiteralValue(type: Type): Type {
573
- if (isClass(type)) {
574
- if (type.literalValue !== undefined) {
575
- type = ClassType.cloneWithLiteral(type, /* value */ undefined);
576
- }
577
-
578
- return type;
579
- }
580
-
581
- if (isUnion(type)) {
582
- return mapSubtypes(type, (subtype) => {
583
- return stripLiteralValue(subtype);
584
- });
585
- }
586
-
587
- return type;
588
- }
589
-
590
- export function addConditionToType(type: Type, condition: TypeCondition[] | undefined): Type {
591
- if (!condition) {
592
- return type;
593
- }
594
-
595
- switch (type.category) {
596
- case TypeCategory.Unbound:
597
- case TypeCategory.Unknown:
598
- case TypeCategory.Any:
599
- case TypeCategory.Never:
600
- case TypeCategory.Module:
601
- case TypeCategory.TypeVar:
602
- return type;
603
-
604
- case TypeCategory.None:
605
- case TypeCategory.Function:
606
- return TypeBase.cloneForCondition(type, TypeCondition.combine(type.condition, condition));
607
-
608
- case TypeCategory.OverloadedFunction:
609
- return OverloadedFunctionType.create(
610
- type.overloads.map((t) => addConditionToType(t, condition) as FunctionType)
611
- );
612
-
613
- case TypeCategory.Class:
614
- return TypeBase.cloneForCondition(type, TypeCondition.combine(type.condition, condition));
615
-
616
- case TypeCategory.Union:
617
- return combineTypes(type.subtypes.map((t) => addConditionToType(t, condition)));
618
- }
619
- }
620
-
621
- export function getTypeCondition(type: Type): TypeCondition[] | undefined {
622
- switch (type.category) {
623
- case TypeCategory.Unbound:
624
- case TypeCategory.Unknown:
625
- case TypeCategory.Any:
626
- case TypeCategory.Never:
627
- case TypeCategory.Module:
628
- case TypeCategory.TypeVar:
629
- case TypeCategory.OverloadedFunction:
630
- case TypeCategory.Union:
631
- return undefined;
632
-
633
- case TypeCategory.None:
634
- case TypeCategory.Class:
635
- case TypeCategory.Function:
636
- return type.condition;
637
- }
638
- }
639
-
640
- // Indicates whether the specified type is a recursive type alias
641
- // placeholder that has not yet been resolved.
642
- export function isTypeAliasPlaceholder(type: Type): type is TypeVarType {
643
- if (!isTypeVar(type)) {
644
- return false;
645
- }
646
-
647
- return !!type.details.recursiveTypeAliasName && !type.details.boundType;
648
- }
649
-
650
- // Determines whether the type alias placeholder is used directly
651
- // within the specified type. It's OK if it's used indirectly as
652
- // a type argument.
653
- export function isTypeAliasRecursive(typeAliasPlaceholder: TypeVarType, type: Type) {
654
- if (type.category !== TypeCategory.Union) {
655
- if (type === typeAliasPlaceholder) {
656
- return true;
657
- }
658
-
659
- // Handle the specific case where the type alias directly refers to itself.
660
- // In this case, the type will be unbound because it could not be resolved.
661
- return (
662
- isUnbound(type) &&
663
- type.typeAliasInfo &&
664
- type.typeAliasInfo.name === typeAliasPlaceholder.details.recursiveTypeAliasName
665
- );
666
- }
667
-
668
- return findSubtype(type, (subtype) => isTypeSame(typeAliasPlaceholder, subtype)) !== undefined;
669
- }
670
-
671
- export function transformPossibleRecursiveTypeAlias(type: Type): Type;
672
- export function transformPossibleRecursiveTypeAlias(type: Type | undefined): Type | undefined;
673
- export function transformPossibleRecursiveTypeAlias(type: Type | undefined): Type | undefined {
674
- if (type) {
675
- if (isTypeVar(type) && type.details.recursiveTypeAliasName && type.details.boundType) {
676
- const unspecializedType = TypeBase.isInstance(type)
677
- ? convertToInstance(type.details.boundType)
678
- : type.details.boundType;
679
-
680
- if (!type.typeAliasInfo?.typeArguments || !type.details.recursiveTypeParameters) {
681
- return unspecializedType;
682
- }
683
-
684
- const typeVarContext = buildTypeVarContext(
685
- type.details.recursiveTypeParameters,
686
- type.typeAliasInfo.typeArguments,
687
- getTypeVarScopeId(type)
688
- );
689
- return applySolvedTypeVars(unspecializedType, typeVarContext);
690
- }
691
- }
692
-
693
- return type;
694
- }
695
-
696
- export function getTypeVarScopeId(type: Type): TypeVarScopeId | undefined {
697
- if (isClass(type)) {
698
- return type.details.typeVarScopeId;
699
- }
700
-
701
- if (isFunction(type)) {
702
- return type.details.typeVarScopeId;
703
- }
704
-
705
- if (isTypeVar(type)) {
706
- return type.scopeId;
707
- }
708
-
709
- return undefined;
710
- }
711
-
712
- // Determines whether the type derives from tuple. If so, it returns
713
- // the specialized tuple type.
714
- export function getSpecializedTupleType(type: Type): ClassType | undefined {
715
- let classType: ClassType | undefined;
716
-
717
- if (isInstantiableClass(type)) {
718
- classType = type;
719
- } else if (isClassInstance(type)) {
720
- classType = ClassType.cloneAsInstantiable(type);
721
- }
722
-
723
- if (!classType) {
724
- return undefined;
725
- }
726
-
727
- // See if this class derives from Tuple or tuple. If it does, we'll assume that it
728
- // hasn't been overridden in a way that changes the behavior of the tuple class.
729
- const tupleClass = classType.details.mro.find(
730
- (mroClass) => isInstantiableClass(mroClass) && isTupleClass(mroClass)
731
- );
732
- if (!tupleClass || !isInstantiableClass(tupleClass)) {
733
- return undefined;
734
- }
735
-
736
- if (ClassType.isSameGenericClass(classType, tupleClass)) {
737
- return classType;
738
- }
739
-
740
- const typeVarContext = buildTypeVarContextFromSpecializedClass(classType);
741
- return applySolvedTypeVars(tupleClass, typeVarContext) as ClassType;
742
- }
743
-
744
- export function isLiteralType(type: ClassType): boolean {
745
- return TypeBase.isInstance(type) && type.literalValue !== undefined;
746
- }
747
-
748
- export function isLiteralTypeOrUnion(type: Type): boolean {
749
- if (isClassInstance(type)) {
750
- return type.literalValue !== undefined;
751
- }
752
-
753
- if (isUnion(type)) {
754
- return !findSubtype(type, (subtype) => !isClassInstance(subtype) || subtype.literalValue === undefined);
755
- }
756
-
757
- return false;
758
- }
759
-
760
- export function containsLiteralType(type: Type, includeTypeArgs = false, recursionCount = 0): boolean {
761
- if (recursionCount > maxTypeRecursionCount) {
762
- return false;
763
- }
764
- recursionCount++;
765
-
766
- if (isClassInstance(type) && isLiteralType(type)) {
767
- return true;
768
- }
769
-
770
- if (includeTypeArgs && isClass(type)) {
771
- const typeArgs = type.tupleTypeArguments?.map((t) => t.type) || type.typeArguments;
772
- if (typeArgs) {
773
- return typeArgs.some((typeArg) => containsLiteralType(typeArg, includeTypeArgs, recursionCount));
774
- }
775
- }
776
-
777
- if (isUnion(type)) {
778
- return type.subtypes.some((subtype) => containsLiteralType(subtype, includeTypeArgs, recursionCount));
779
- }
780
-
781
- if (isOverloadedFunction(type)) {
782
- return type.overloads.some((overload) => containsLiteralType(overload, includeTypeArgs, recursionCount));
783
- }
784
-
785
- if (isFunction(type)) {
786
- const returnType = FunctionType.getSpecializedReturnType(type);
787
- if (returnType && containsLiteralType(returnType, includeTypeArgs, recursionCount)) {
788
- return true;
789
- }
790
-
791
- for (let i = 0; i < type.details.parameters.length; i++) {
792
- const paramType = FunctionType.getEffectiveParameterType(type, i);
793
- if (containsLiteralType(paramType, includeTypeArgs, recursionCount)) {
794
- return true;
795
- }
796
- }
797
- }
798
-
799
- return false;
800
- }
801
-
802
- // If all of the subtypes are literals with the same built-in class (e.g.
803
- // all 'int' or all 'str'), this function returns the name of that type. If
804
- // some of the subtypes are not literals or the literal classes don't match,
805
- // it returns undefined.
806
- export function getLiteralTypeClassName(type: Type): string | undefined {
807
- if (isClassInstance(type)) {
808
- if (type.literalValue !== undefined && ClassType.isBuiltIn(type)) {
809
- return type.details.name;
810
- }
811
- return undefined;
812
- }
813
-
814
- if (isUnion(type)) {
815
- let className: string | undefined;
816
- let foundMismatch = false;
817
-
818
- doForEachSubtype(type, (subtype) => {
819
- const subtypeLiteralTypeName = getLiteralTypeClassName(subtype);
820
- if (!subtypeLiteralTypeName) {
821
- foundMismatch = true;
822
- } else if (!className) {
823
- className = subtypeLiteralTypeName;
824
- }
825
- });
826
-
827
- return foundMismatch ? undefined : className;
828
- }
829
-
830
- return undefined;
831
- }
832
-
833
- export function getUnionSubtypeCount(type: Type): number {
834
- if (isUnion(type)) {
835
- return type.subtypes.length;
836
- }
837
-
838
- return 1;
839
- }
840
-
841
- export function isEllipsisType(type: Type): boolean {
842
- return isAny(type) && type.isEllipsis;
843
- }
844
-
845
- export function isProperty(type: Type) {
846
- return isClassInstance(type) && ClassType.isPropertyClass(type);
847
- }
848
-
849
- export function isDescriptorInstance(type: Type, requireSetter = false): boolean {
850
- if (isUnion(type)) {
851
- return type.subtypes.every((subtype) => isMaybeDescriptorInstance(subtype, requireSetter));
852
- }
853
-
854
- return isMaybeDescriptorInstance(type, requireSetter);
855
- }
856
-
857
- export function isMaybeDescriptorInstance(type: Type, requireSetter = false): boolean {
858
- if (isUnion(type)) {
859
- return type.subtypes.some((subtype) => isMaybeDescriptorInstance(subtype, requireSetter));
860
- }
861
-
862
- if (!isClassInstance(type)) {
863
- return false;
864
- }
865
-
866
- if (!type.details.fields.has('__get__')) {
867
- return false;
868
- }
869
-
870
- if (requireSetter && !type.details.fields.has('__set__')) {
871
- return false;
872
- }
873
-
874
- return true;
875
- }
876
-
877
- export function isTupleClass(type: ClassType) {
878
- return ClassType.isBuiltIn(type, 'tuple');
879
- }
880
-
881
- // Indicates whether the type is a tuple class of
882
- // the form tuple[x, ...] where the number of elements
883
- // in the tuple is unknown.
884
- export function isUnboundedTupleClass(type: ClassType) {
885
- return type.tupleTypeArguments && type.tupleTypeArguments.some((t) => t.isUnbounded);
886
- }
887
-
888
- // Partially specializes a type within the context of a specified
889
- // (presumably specialized) class. Optionally specializes the `Self`
890
- // type variables, replacing them with selfClass.
891
- export function partiallySpecializeType(
892
- type: Type,
893
- contextClassType: ClassType,
894
- selfClass?: ClassType,
895
- typeClassType?: Type
896
- ): Type {
897
- // If the context class is not specialized (or doesn't need specialization),
898
- // then there's no need to do any more work.
899
- if (ClassType.isUnspecialized(contextClassType)) {
900
- return type;
901
- }
902
-
903
- // Partially specialize the type using the specialized class type vars.
904
- const typeVarContext = buildTypeVarContextFromSpecializedClass(contextClassType, /* makeConcrete */ undefined);
905
-
906
- if (selfClass) {
907
- populateTypeVarContextForSelfType(typeVarContext, contextClassType, selfClass);
908
- }
909
-
910
- return applySolvedTypeVars(
911
- type,
912
- typeVarContext,
913
- /* unknownIfNotFound */ undefined,
914
- /* useNarrowBoundOnly */ undefined,
915
- /* eliminateUnsolvedInUnions */ undefined,
916
- typeClassType
917
- );
918
- }
919
-
920
- export function populateTypeVarContextForSelfType(
921
- typeVarContext: TypeVarContext,
922
- contextClassType: ClassType,
923
- selfClass: ClassType
924
- ) {
925
- const synthesizedSelfTypeVar = synthesizeTypeVarForSelfCls(contextClassType, /* isClsParam */ false);
926
- typeVarContext.setTypeVarType(synthesizedSelfTypeVar, convertToInstance(selfClass));
927
- }
928
-
929
- // Specializes a (potentially generic) type by substituting
930
- // type variables from a type var map.
931
- export function applySolvedTypeVars(
932
- type: Type,
933
- typeVarContext: TypeVarContext,
934
- unknownIfNotFound = false,
935
- useNarrowBoundOnly = false,
936
- eliminateUnsolvedInUnions = false,
937
- typeClassType?: Type
938
- ): Type {
939
- // Use a shortcut if the typeVarContext is empty and no transform is necessary.
940
- if (typeVarContext.isEmpty() && !unknownIfNotFound && !eliminateUnsolvedInUnions) {
941
- return type;
942
- }
943
-
944
- const transformer = new ApplySolvedTypeVarsTransformer(
945
- typeVarContext,
946
- unknownIfNotFound,
947
- useNarrowBoundOnly,
948
- eliminateUnsolvedInUnions,
949
- typeClassType
950
- );
951
- return transformer.apply(type);
952
- }
953
-
954
- // During bidirectional type inference for constructors, an "executed type"
955
- // is used to prepopulate the type var map. This is problematic when the
956
- // expected type uses TypeVars that are not part of the context of the
957
- // class we are constructing. We'll replace these type variables with dummy
958
- // type variables that are scoped to the appropriate context.
959
- export function transformExpectedTypeForConstructor(
960
- expectedType: Type,
961
- typeVarContext: TypeVarContext,
962
- liveTypeVarScopes: TypeVarScopeId[]
963
- ): Type | undefined {
964
- const isTypeVarLive = (typeVar: TypeVarType) => liveTypeVarScopes.some((scopeId) => typeVar.scopeId === scopeId);
965
-
966
- // Handle "naked TypeVars" (i.e. the expectedType is a TypeVar itself)
967
- // specially. Return undefined to indicate that it's an out-of-scope
968
- // TypeVar.
969
- if (isTypeVar(expectedType)) {
970
- if (isTypeVarLive(expectedType)) {
971
- return expectedType;
972
- }
973
-
974
- return undefined;
975
- }
976
-
977
- const transformer = new ExpectedConstructorTypeTransformer(typeVarContext, liveTypeVarScopes);
978
- return transformer.apply(expectedType);
979
- }
980
-
981
- // Given a protocol class, this function returns a set of all the
982
- // symbols (indexed by symbol name) that are part of that protocol
983
- // and its protocol parent classes. If a same-named symbol appears
984
- // in a parent and a child, the child overrides the parent.
985
- export function getProtocolSymbols(classType: ClassType) {
986
- const symbolMap = new Map<string, ClassMember>();
987
-
988
- if (ClassType.isProtocolClass(classType)) {
989
- getProtocolSymbolsRecursive(classType, symbolMap);
990
- }
991
-
992
- return symbolMap;
993
- }
994
-
995
- function getProtocolSymbolsRecursive(classType: ClassType, symbolMap: Map<string, ClassMember>, recursionCount = 0) {
996
- if (recursionCount > maxTypeRecursionCount) {
997
- return;
998
- }
999
-
1000
- classType.details.baseClasses.forEach((baseClass) => {
1001
- if (isClass(baseClass) && ClassType.isProtocolClass(baseClass)) {
1002
- getProtocolSymbolsRecursive(baseClass, symbolMap, recursionCount + 1);
1003
- }
1004
- });
1005
-
1006
- classType.details.fields.forEach((symbol, name) => {
1007
- if (!symbol.isIgnoredForProtocolMatch()) {
1008
- symbolMap.set(name, {
1009
- symbol,
1010
- classType,
1011
- isInstanceMember: symbol.isInstanceMember(),
1012
- isClassMember: symbol.isClassMember(),
1013
- isClassVar: symbol.isClassVar(),
1014
- isTypeDeclared: symbol.hasTypedDeclarations(),
1015
- skippedUndeclaredType: false,
1016
- });
1017
- }
1018
- });
1019
- }
1020
-
1021
- export function lookUpObjectMember(
1022
- objectType: Type,
1023
- memberName: string,
1024
- flags = ClassMemberLookupFlags.Default
1025
- ): ClassMember | undefined {
1026
- if (isClassInstance(objectType)) {
1027
- return lookUpClassMember(objectType, memberName, flags);
1028
- }
1029
-
1030
- return undefined;
1031
- }
1032
-
1033
- // Looks up a member in a class using the multiple-inheritance rules
1034
- // defined by Python.
1035
- export function lookUpClassMember(
1036
- classType: Type,
1037
- memberName: string,
1038
- flags = ClassMemberLookupFlags.Default
1039
- ): ClassMember | undefined {
1040
- const memberItr = getClassMemberIterator(classType, memberName, flags);
1041
-
1042
- return memberItr.next()?.value;
1043
- }
1044
-
1045
- // Iterates members in a class matching memberName using the multiple-inheritance rules.
1046
- // For more details, see this note on method resolution
1047
- // order: https://www.python.org/download/releases/2.3/mro/.
1048
- // As it traverses the inheritance tree, it applies partial specialization
1049
- // to the the base class and member. For example, if ClassA inherits from
1050
- // ClassB[str] which inherits from Dict[_T1, int], a search for '__iter__'
1051
- // would return a class type of Dict[str, int] and a symbolType of
1052
- // (self) -> Iterator[str].
1053
- export function* getClassMemberIterator(classType: Type, memberName: string, flags = ClassMemberLookupFlags.Default) {
1054
- const declaredTypesOnly = (flags & ClassMemberLookupFlags.DeclaredTypesOnly) !== 0;
1055
- let skippedUndeclaredType = false;
1056
-
1057
- if (isClass(classType)) {
1058
- let classFlags = ClassIteratorFlags.Default;
1059
- if (flags & ClassMemberLookupFlags.SkipOriginalClass) {
1060
- classFlags = classFlags | ClassIteratorFlags.SkipOriginalClass;
1061
- }
1062
- if (flags & ClassMemberLookupFlags.SkipBaseClasses) {
1063
- classFlags = classFlags | ClassIteratorFlags.SkipBaseClasses;
1064
- }
1065
- if (flags & ClassMemberLookupFlags.SkipObjectBaseClass) {
1066
- classFlags = classFlags | ClassIteratorFlags.SkipObjectBaseClass;
1067
- }
1068
- if (flags & ClassMemberLookupFlags.SkipTypeBaseClass) {
1069
- classFlags = classFlags | ClassIteratorFlags.SkipTypeBaseClass;
1070
- }
1071
-
1072
- const classItr = getClassIterator(classType, classFlags);
1073
-
1074
- for (const [mroClass, specializedMroClass] of classItr) {
1075
- if (!isInstantiableClass(mroClass)) {
1076
- if (!declaredTypesOnly) {
1077
- // The class derives from an unknown type, so all bets are off
1078
- // when trying to find a member. Return an unknown symbol.
1079
- const cm: ClassMember = {
1080
- symbol: Symbol.createWithType(SymbolFlags.None, UnknownType.create()),
1081
- isInstanceMember: false,
1082
- isClassMember: true,
1083
- isClassVar: false,
1084
- classType: UnknownType.create(),
1085
- isTypeDeclared: false,
1086
- skippedUndeclaredType: false,
1087
- };
1088
- yield cm;
1089
- }
1090
- continue;
1091
- }
1092
-
1093
- if (!isInstantiableClass(specializedMroClass)) {
1094
- continue;
1095
- }
1096
-
1097
- const memberFields = specializedMroClass.details.fields;
1098
-
1099
- // Look at instance members first if requested.
1100
- if ((flags & ClassMemberLookupFlags.SkipInstanceVariables) === 0) {
1101
- const symbol = memberFields.get(memberName);
1102
- if (symbol && symbol.isInstanceMember()) {
1103
- const hasDeclaredType = symbol.hasTypedDeclarations();
1104
- if (!declaredTypesOnly || hasDeclaredType) {
1105
- const cm: ClassMember = {
1106
- symbol,
1107
- isInstanceMember: true,
1108
- isClassMember: symbol.isClassMember(),
1109
- isClassVar: symbol.isClassVar(),
1110
- classType: specializedMroClass,
1111
- isTypeDeclared: hasDeclaredType,
1112
- skippedUndeclaredType,
1113
- };
1114
- yield cm;
1115
- } else {
1116
- skippedUndeclaredType = true;
1117
- }
1118
- }
1119
- }
1120
-
1121
- // Next look at class members.
1122
- const symbol = memberFields.get(memberName);
1123
- if (symbol && symbol.isClassMember()) {
1124
- const hasDeclaredType = symbol.hasTypedDeclarations();
1125
- if (!declaredTypesOnly || hasDeclaredType) {
1126
- let isInstanceMember = symbol.isInstanceMember();
1127
- let isClassMember = true;
1128
-
1129
- // For data classes and typed dicts, variables that are declared
1130
- // within the class are treated as instance variables. This distinction
1131
- // is important in cases where a variable is a callable type because
1132
- // we don't want to bind it to the instance like we would for a
1133
- // class member.
1134
- const isDataclass = ClassType.isDataClass(specializedMroClass);
1135
- const isTypedDict = ClassType.isTypedDictClass(specializedMroClass);
1136
- if (isDataclass || isTypedDict) {
1137
- const decls = symbol.getDeclarations();
1138
- if (decls.length > 0 && decls[0].type === DeclarationType.Variable) {
1139
- isInstanceMember = true;
1140
- isClassMember = isDataclass;
1141
- }
1142
- }
1143
-
1144
- const cm: ClassMember = {
1145
- symbol,
1146
- isInstanceMember,
1147
- isClassMember,
1148
- isClassVar: symbol.isClassVar(),
1149
- classType: specializedMroClass,
1150
- isTypeDeclared: hasDeclaredType,
1151
- skippedUndeclaredType,
1152
- };
1153
- yield cm;
1154
- } else {
1155
- skippedUndeclaredType = true;
1156
- }
1157
- }
1158
- }
1159
- } else if (isAnyOrUnknown(classType)) {
1160
- // The class derives from an unknown type, so all bets are off
1161
- // when trying to find a member. Return an unknown symbol.
1162
- const cm: ClassMember = {
1163
- symbol: Symbol.createWithType(SymbolFlags.None, UnknownType.create()),
1164
- isInstanceMember: false,
1165
- isClassMember: true,
1166
- isClassVar: false,
1167
- classType: UnknownType.create(),
1168
- isTypeDeclared: false,
1169
- skippedUndeclaredType: false,
1170
- };
1171
- yield cm;
1172
- }
1173
-
1174
- return undefined;
1175
- }
1176
-
1177
- export function* getClassIterator(classType: Type, flags = ClassIteratorFlags.Default) {
1178
- if (isClass(classType)) {
1179
- let skipMroEntry = (flags & ClassIteratorFlags.SkipOriginalClass) !== 0;
1180
-
1181
- for (const mroClass of classType.details.mro) {
1182
- if (skipMroEntry) {
1183
- skipMroEntry = false;
1184
- continue;
1185
- }
1186
-
1187
- // If mroClass is an ancestor of classType, partially specialize
1188
- // it in the context of classType.
1189
- const specializedMroClass = partiallySpecializeType(mroClass, classType);
1190
-
1191
- // Should we ignore members on the 'object' base class?
1192
- if (flags & ClassIteratorFlags.SkipObjectBaseClass) {
1193
- if (isInstantiableClass(specializedMroClass)) {
1194
- if (ClassType.isBuiltIn(specializedMroClass, 'object')) {
1195
- break;
1196
- }
1197
- }
1198
- }
1199
-
1200
- // Should we ignore members on the 'type' base class?
1201
- if (flags & ClassIteratorFlags.SkipTypeBaseClass) {
1202
- if (isInstantiableClass(specializedMroClass)) {
1203
- if (ClassType.isBuiltIn(specializedMroClass, 'type')) {
1204
- break;
1205
- }
1206
- }
1207
- }
1208
-
1209
- yield [mroClass, specializedMroClass];
1210
-
1211
- if ((flags & ClassIteratorFlags.SkipBaseClasses) !== 0) {
1212
- break;
1213
- }
1214
- }
1215
- }
1216
-
1217
- return undefined;
1218
- }
1219
-
1220
- export function getClassFieldsRecursive(classType: ClassType): Map<string, ClassMember> {
1221
- const memberMap = new Map<string, ClassMember>();
1222
-
1223
- // Evaluate the types of members from the end of the MRO to the beginning.
1224
- for (let i = classType.details.mro.length - 1; i >= 0; i--) {
1225
- const mroClass = partiallySpecializeType(classType.details.mro[i], classType);
1226
-
1227
- // If this ancestor class is unknown, throw away all symbols
1228
- // found so far because they could be overridden by the unknown class.
1229
- if (!isClass(mroClass)) {
1230
- memberMap.clear();
1231
- continue;
1232
- }
1233
-
1234
- mroClass.details.fields.forEach((symbol, name) => {
1235
- if (!symbol.isIgnoredForProtocolMatch() && symbol.hasTypedDeclarations()) {
1236
- memberMap.set(name, {
1237
- classType: mroClass,
1238
- symbol,
1239
- isInstanceMember: symbol.isInstanceMember(),
1240
- isClassMember: symbol.isClassMember(),
1241
- isClassVar: symbol.isClassVar(),
1242
- isTypeDeclared: true,
1243
- skippedUndeclaredType: false,
1244
- });
1245
- }
1246
- });
1247
- }
1248
-
1249
- return memberMap;
1250
- }
1251
-
1252
- // Combines two lists of type var types, maintaining the combined order
1253
- // but removing any duplicates.
1254
- export function addTypeVarsToListIfUnique(list1: TypeVarType[], list2: TypeVarType[]) {
1255
- for (const type2 of list2) {
1256
- if (!list1.find((type1) => isTypeSame(convertToInstance(type1), convertToInstance(type2)))) {
1257
- list1.push(type2);
1258
- }
1259
- }
1260
- }
1261
-
1262
- // Walks the type recursively (in a depth-first manner), finds all
1263
- // type variables that are referenced, and returns an ordered list
1264
- // of unique type variables. For example, if the type is
1265
- // Union[List[Dict[_T1, _T2]], _T1, _T3], the result would be
1266
- // [_T1, _T2, _T3].
1267
- export function getTypeVarArgumentsRecursive(type: Type, recursionCount = 0): TypeVarType[] {
1268
- if (recursionCount > maxTypeRecursionCount) {
1269
- return [];
1270
- }
1271
- recursionCount++;
1272
-
1273
- const getTypeVarsFromClass = (classType: ClassType) => {
1274
- const combinedList: TypeVarType[] = [];
1275
- if (classType.typeArguments) {
1276
- classType.typeArguments.forEach((typeArg) => {
1277
- addTypeVarsToListIfUnique(combinedList, getTypeVarArgumentsRecursive(typeArg, recursionCount));
1278
- });
1279
- }
1280
-
1281
- return combinedList;
1282
- };
1283
-
1284
- if (type.typeAliasInfo?.typeArguments) {
1285
- const combinedList: TypeVarType[] = [];
1286
-
1287
- type.typeAliasInfo?.typeArguments.forEach((typeArg) => {
1288
- addTypeVarsToListIfUnique(combinedList, getTypeVarArgumentsRecursive(typeArg, recursionCount));
1289
- });
1290
-
1291
- return combinedList;
1292
- }
1293
-
1294
- if (isTypeVar(type)) {
1295
- // Don't return any recursive type alias placeholders.
1296
- if (type.details.recursiveTypeAliasName) {
1297
- return [];
1298
- }
1299
-
1300
- // Don't return any P.args or P.kwargs types.
1301
- if (isParamSpec(type) && type.paramSpecAccess) {
1302
- return [];
1303
- }
1304
-
1305
- return [TypeBase.isInstantiable(type) ? TypeVarType.cloneAsInstance(type) : type];
1306
- }
1307
-
1308
- if (isClass(type)) {
1309
- return getTypeVarsFromClass(type);
1310
- }
1311
-
1312
- if (isUnion(type)) {
1313
- const combinedList: TypeVarType[] = [];
1314
- doForEachSubtype(type, (subtype) => {
1315
- addTypeVarsToListIfUnique(combinedList, getTypeVarArgumentsRecursive(subtype, recursionCount));
1316
- });
1317
- return combinedList;
1318
- }
1319
-
1320
- if (isFunction(type)) {
1321
- const combinedList: TypeVarType[] = [];
1322
-
1323
- for (let i = 0; i < type.details.parameters.length; i++) {
1324
- addTypeVarsToListIfUnique(
1325
- combinedList,
1326
- getTypeVarArgumentsRecursive(FunctionType.getEffectiveParameterType(type, i), recursionCount)
1327
- );
1328
- }
1329
-
1330
- if (type.details.paramSpec) {
1331
- addTypeVarsToListIfUnique(combinedList, [type.details.paramSpec]);
1332
- }
1333
-
1334
- const returnType = FunctionType.getSpecializedReturnType(type);
1335
- if (returnType) {
1336
- addTypeVarsToListIfUnique(combinedList, getTypeVarArgumentsRecursive(returnType, recursionCount));
1337
- }
1338
-
1339
- return combinedList;
1340
- }
1341
-
1342
- return [];
1343
- }
1344
-
1345
- // Creates a specialized version of the class, filling in any unspecified
1346
- // type arguments with Unknown.
1347
- export function specializeClassType(type: ClassType): ClassType {
1348
- const typeVarContext = new TypeVarContext(getTypeVarScopeId(type));
1349
- const typeParams = ClassType.getTypeParameters(type);
1350
-
1351
- typeParams.forEach((typeParam) => {
1352
- typeVarContext.setTypeVarType(typeParam, UnknownType.create());
1353
- });
1354
-
1355
- return applySolvedTypeVars(type, typeVarContext) as ClassType;
1356
- }
1357
-
1358
- // Recursively finds all of the type arguments and sets them
1359
- // to the specified srcType.
1360
- export function setTypeArgumentsRecursive(
1361
- destType: Type,
1362
- srcType: Type,
1363
- typeVarContext: TypeVarContext,
1364
- recursionCount = 0
1365
- ) {
1366
- if (recursionCount > maxTypeRecursionCount) {
1367
- return;
1368
- }
1369
- recursionCount++;
1370
-
1371
- if (typeVarContext.isLocked()) {
1372
- return;
1373
- }
1374
-
1375
- switch (destType.category) {
1376
- case TypeCategory.Union:
1377
- doForEachSubtype(destType, (subtype) => {
1378
- setTypeArgumentsRecursive(subtype, srcType, typeVarContext, recursionCount);
1379
- });
1380
- break;
1381
-
1382
- case TypeCategory.Class:
1383
- if (destType.typeArguments) {
1384
- destType.typeArguments.forEach((typeArg) => {
1385
- setTypeArgumentsRecursive(typeArg, srcType, typeVarContext, recursionCount);
1386
- });
1387
- }
1388
- if (destType.tupleTypeArguments) {
1389
- destType.tupleTypeArguments.forEach((typeArg) => {
1390
- setTypeArgumentsRecursive(typeArg.type, srcType, typeVarContext, recursionCount);
1391
- });
1392
- }
1393
- break;
1394
-
1395
- case TypeCategory.Function:
1396
- if (destType.specializedTypes) {
1397
- destType.specializedTypes.parameterTypes.forEach((paramType) => {
1398
- setTypeArgumentsRecursive(paramType, srcType, typeVarContext, recursionCount);
1399
- });
1400
- if (destType.specializedTypes.returnType) {
1401
- setTypeArgumentsRecursive(
1402
- destType.specializedTypes.returnType,
1403
- srcType,
1404
- typeVarContext,
1405
- recursionCount
1406
- );
1407
- }
1408
- } else {
1409
- destType.details.parameters.forEach((param) => {
1410
- setTypeArgumentsRecursive(param.type, srcType, typeVarContext, recursionCount);
1411
- });
1412
- if (destType.details.declaredReturnType) {
1413
- setTypeArgumentsRecursive(
1414
- destType.details.declaredReturnType,
1415
- srcType,
1416
- typeVarContext,
1417
- recursionCount
1418
- );
1419
- }
1420
-
1421
- if (destType.details.paramSpec) {
1422
- // Fill in an empty signature for a ParamSpec if the source is Any or Unknown.
1423
- if (!typeVarContext.hasTypeVar(destType.details.paramSpec) && isAnyOrUnknown(srcType)) {
1424
- typeVarContext.setParamSpec(destType.details.paramSpec, {
1425
- flags: FunctionTypeFlags.None,
1426
- parameters: FunctionType.getDefaultParameters(),
1427
- typeVarScopeId: undefined,
1428
- docString: undefined,
1429
- paramSpec: undefined,
1430
- });
1431
- }
1432
- }
1433
- }
1434
- break;
1435
-
1436
- case TypeCategory.OverloadedFunction:
1437
- destType.overloads.forEach((subtype) => {
1438
- setTypeArgumentsRecursive(subtype, srcType, typeVarContext, recursionCount);
1439
- });
1440
- break;
1441
-
1442
- case TypeCategory.TypeVar:
1443
- if (!typeVarContext.hasTypeVar(destType)) {
1444
- typeVarContext.setTypeVarType(destType, srcType);
1445
- }
1446
- break;
1447
- }
1448
- }
1449
-
1450
- // Builds a mapping between type parameters and their specialized
1451
- // types. For example, if the generic type is Dict[_T1, _T2] and the
1452
- // specialized type is Dict[str, int], it returns a map that associates
1453
- // _T1 with str and _T2 with int.
1454
- export function buildTypeVarContextFromSpecializedClass(classType: ClassType, makeConcrete = true): TypeVarContext {
1455
- const typeParameters = ClassType.getTypeParameters(classType);
1456
- let typeArguments = classType.typeArguments;
1457
-
1458
- // If there are no type arguments, we can either use the type variables
1459
- // from the type parameters (keeping the type arguments generic) or
1460
- // fill in concrete types.
1461
- if (!typeArguments && !makeConcrete) {
1462
- typeArguments = typeParameters;
1463
- }
1464
-
1465
- const typeVarContext = buildTypeVarContext(typeParameters, typeArguments, getTypeVarScopeId(classType));
1466
- if (ClassType.isTupleClass(classType) && classType.tupleTypeArguments && typeParameters.length >= 1) {
1467
- typeVarContext.setVariadicTypeVar(typeParameters[0], classType.tupleTypeArguments);
1468
- }
1469
-
1470
- return typeVarContext;
1471
- }
1472
-
1473
- export function buildTypeVarContext(
1474
- typeParameters: TypeVarType[],
1475
- typeArgs: Type[] | undefined,
1476
- typeVarScopeId: TypeVarScopeId | undefined
1477
- ): TypeVarContext {
1478
- const typeVarContext = new TypeVarContext(typeVarScopeId);
1479
- typeParameters.forEach((typeParam, index) => {
1480
- let typeArgType: Type;
1481
-
1482
- if (typeArgs) {
1483
- if (isParamSpec(typeParam)) {
1484
- if (index < typeArgs.length) {
1485
- typeArgType = typeArgs[index];
1486
- if (isFunction(typeArgType) && FunctionType.isParamSpecValue(typeArgType)) {
1487
- const paramSpecEntries: ParamSpecEntry[] = [];
1488
- const typeArgFunctionType = typeArgType;
1489
- typeArgType.details.parameters.forEach((param, paramIndex) => {
1490
- paramSpecEntries.push({
1491
- category: param.category,
1492
- name: param.name,
1493
- hasDefault: !!param.hasDefault,
1494
- isNameSynthesized: param.isNameSynthesized,
1495
- type: FunctionType.getEffectiveParameterType(typeArgFunctionType, paramIndex),
1496
- });
1497
- });
1498
- typeVarContext.setParamSpec(typeParam, {
1499
- parameters: paramSpecEntries,
1500
- typeVarScopeId: typeArgType.details.typeVarScopeId,
1501
- flags: typeArgType.details.flags,
1502
- docString: typeArgType.details.docString,
1503
- paramSpec: typeArgType.details.paramSpec,
1504
- });
1505
- } else if (isParamSpec(typeArgType)) {
1506
- typeVarContext.setParamSpec(typeParam, {
1507
- flags: FunctionTypeFlags.None,
1508
- parameters: [],
1509
- typeVarScopeId: undefined,
1510
- docString: undefined,
1511
- paramSpec: typeArgType,
1512
- });
1513
- } else if (isAnyOrUnknown(typeArgType)) {
1514
- // Fill in an empty signature if the arg type is Any or Unknown.
1515
- typeVarContext.setParamSpec(typeParam, {
1516
- flags: FunctionTypeFlags.None,
1517
- parameters: FunctionType.getDefaultParameters(),
1518
- typeVarScopeId: undefined,
1519
- docString: undefined,
1520
- paramSpec: undefined,
1521
- });
1522
- }
1523
- }
1524
- } else {
1525
- if (index >= typeArgs.length) {
1526
- typeArgType = AnyType.create();
1527
- } else {
1528
- typeArgType = typeArgs[index];
1529
- }
1530
-
1531
- typeVarContext.setTypeVarType(typeParam, typeArgType, typeArgType, /* retainLiteral */ true);
1532
- }
1533
- }
1534
- });
1535
-
1536
- return typeVarContext;
1537
- }
1538
-
1539
- // Determines the specialized base class type that srcType derives from.
1540
- export function specializeForBaseClass(srcType: ClassType, baseClass: ClassType): ClassType {
1541
- const typeParams = ClassType.getTypeParameters(baseClass);
1542
-
1543
- // If there are no type parameters for the specified base class,
1544
- // no specialization is required.
1545
- if (typeParams.length === 0) {
1546
- return baseClass;
1547
- }
1548
-
1549
- const typeVarContext = buildTypeVarContextFromSpecializedClass(srcType);
1550
- const specializedType = applySolvedTypeVars(baseClass, typeVarContext);
1551
- assert(isInstantiableClass(specializedType));
1552
- return specializedType as ClassType;
1553
- }
1554
-
1555
- // If ignoreUnknown is true, an unknown base class is ignored when
1556
- // checking for derivation. If ignoreUnknown is false, a return value
1557
- // of true is assumed.
1558
- export function derivesFromClassRecursive(classType: ClassType, baseClassToFind: ClassType, ignoreUnknown: boolean) {
1559
- if (ClassType.isSameGenericClass(classType, baseClassToFind)) {
1560
- return true;
1561
- }
1562
-
1563
- for (const baseClass of classType.details.baseClasses) {
1564
- if (isInstantiableClass(baseClass)) {
1565
- if (derivesFromClassRecursive(baseClass, baseClassToFind, ignoreUnknown)) {
1566
- return true;
1567
- }
1568
- } else if (!ignoreUnknown && isAnyOrUnknown(baseClass)) {
1569
- // If the base class is unknown, we have to make a conservative assumption.
1570
- return true;
1571
- }
1572
- }
1573
-
1574
- return false;
1575
- }
1576
-
1577
- export function synthesizeTypeVarForSelfCls(classType: ClassType, isClsParam: boolean): TypeVarType {
1578
- const selfType = TypeVarType.createInstance(`__type_of_self__`);
1579
- const scopeId = getTypeVarScopeId(classType) ?? '';
1580
- selfType.details.isSynthesized = true;
1581
- selfType.details.isSynthesizedSelf = true;
1582
- selfType.nameWithScope = TypeVarType.makeNameWithScope(selfType.details.name, scopeId);
1583
- selfType.scopeId = scopeId;
1584
-
1585
- const boundType = ClassType.cloneForSpecialization(
1586
- classType,
1587
- ClassType.getTypeParameters(classType),
1588
- /* isTypeArgumentExplicit */ false,
1589
- /* includeSubclasses */ true
1590
- );
1591
-
1592
- selfType.details.boundType = ClassType.cloneAsInstance(boundType);
1593
-
1594
- return isClsParam ? TypeVarType.cloneAsInstantiable(selfType) : selfType;
1595
- }
1596
-
1597
- // Returns the declared "return" type (the type returned from a return statement)
1598
- // if it was declared, or undefined otherwise.
1599
- export function getDeclaredGeneratorReturnType(functionType: FunctionType): Type | undefined {
1600
- const returnType = FunctionType.getSpecializedReturnType(functionType);
1601
- if (returnType) {
1602
- const generatorTypeArgs = getGeneratorTypeArgs(returnType);
1603
-
1604
- if (generatorTypeArgs) {
1605
- // The send type is the third type arg.
1606
- return generatorTypeArgs.length >= 3 ? generatorTypeArgs[2] : UnknownType.create();
1607
- }
1608
- }
1609
-
1610
- return undefined;
1611
- }
1612
-
1613
- // If the declared return type is a Generator, Iterable, Iterator or the async
1614
- // counterparts, returns the yield type. If the type is invalid for a generator,
1615
- // returns undefined.
1616
- export function getGeneratorYieldType(declaredReturnType: Type, isAsync: boolean): Type | undefined {
1617
- let isLegalGeneratorType = true;
1618
-
1619
- const yieldType = mapSubtypes(declaredReturnType, (subtype) => {
1620
- if (isAnyOrUnknown(subtype)) {
1621
- return subtype;
1622
- }
1623
-
1624
- if (isClassInstance(subtype)) {
1625
- const expectedClasses = [
1626
- ['AsyncIterable', 'Iterable'],
1627
- ['AsyncIterator', 'Iterator'],
1628
- ['AsyncGenerator', 'Generator'],
1629
- ['', 'AwaitableGenerator'],
1630
- ];
1631
-
1632
- if (expectedClasses.some((classes) => ClassType.isBuiltIn(subtype, isAsync ? classes[0] : classes[1]))) {
1633
- return subtype.typeArguments && subtype.typeArguments.length >= 1
1634
- ? subtype.typeArguments[0]
1635
- : UnknownType.create();
1636
- }
1637
- }
1638
-
1639
- isLegalGeneratorType = false;
1640
- return undefined;
1641
- });
1642
-
1643
- return isLegalGeneratorType ? yieldType : undefined;
1644
- }
1645
-
1646
- export function isEffectivelyInstantiable(type: Type): boolean {
1647
- if (TypeBase.isInstantiable(type)) {
1648
- return true;
1649
- }
1650
-
1651
- // Handle the special case of 'type', which is instantiable.
1652
- if (isClassInstance(type) && ClassType.isBuiltIn(type, 'type')) {
1653
- return true;
1654
- }
1655
-
1656
- if (isUnion(type)) {
1657
- return type.subtypes.every((subtype) => isEffectivelyInstantiable(subtype));
1658
- }
1659
-
1660
- return false;
1661
- }
1662
-
1663
- export function convertToInstance(type: Type): Type {
1664
- let result = mapSubtypes(type, (subtype) => {
1665
- switch (subtype.category) {
1666
- case TypeCategory.Class: {
1667
- // Handle Type[x] as a special case.
1668
- if (ClassType.isBuiltIn(subtype, 'Type')) {
1669
- if (!subtype.typeArguments || subtype.typeArguments.length < 1) {
1670
- return UnknownType.create();
1671
- } else {
1672
- return convertToInstantiable(subtype.typeArguments[0]);
1673
- }
1674
- }
1675
-
1676
- return ClassType.cloneAsInstance(subtype);
1677
- }
1678
-
1679
- case TypeCategory.None: {
1680
- return NoneType.createInstance();
1681
- }
1682
-
1683
- case TypeCategory.Function: {
1684
- if (TypeBase.isInstantiable(subtype)) {
1685
- return FunctionType.cloneAsInstance(subtype);
1686
- }
1687
- break;
1688
- }
1689
-
1690
- case TypeCategory.TypeVar: {
1691
- if (TypeBase.isInstantiable(subtype)) {
1692
- return TypeVarType.cloneAsInstance(subtype);
1693
- }
1694
- break;
1695
- }
1696
- }
1697
-
1698
- return subtype;
1699
- });
1700
-
1701
- // Copy over any type alias information.
1702
- if (type.typeAliasInfo && type !== result) {
1703
- result = TypeBase.cloneForTypeAlias(
1704
- result,
1705
- type.typeAliasInfo.name,
1706
- type.typeAliasInfo.fullName,
1707
- type.typeAliasInfo.typeVarScopeId,
1708
- type.typeAliasInfo.typeParameters,
1709
- type.typeAliasInfo.typeArguments
1710
- );
1711
- }
1712
-
1713
- return result;
1714
- }
1715
-
1716
- export function convertToInstantiable(type: Type): Type {
1717
- let result = mapSubtypes(type, (subtype) => {
1718
- switch (subtype.category) {
1719
- case TypeCategory.Class: {
1720
- return ClassType.cloneAsInstantiable(subtype);
1721
- }
1722
-
1723
- case TypeCategory.None: {
1724
- return NoneType.createType();
1725
- }
1726
-
1727
- case TypeCategory.Function: {
1728
- return FunctionType.cloneAsInstantiable(subtype);
1729
- }
1730
-
1731
- case TypeCategory.TypeVar: {
1732
- return TypeVarType.cloneAsInstantiable(subtype);
1733
- }
1734
- }
1735
-
1736
- return subtype;
1737
- });
1738
-
1739
- // Copy over any type alias information.
1740
- if (type.typeAliasInfo && type !== result) {
1741
- result = TypeBase.cloneForTypeAlias(
1742
- result,
1743
- type.typeAliasInfo.name,
1744
- type.typeAliasInfo.fullName,
1745
- type.typeAliasInfo.typeVarScopeId,
1746
- type.typeAliasInfo.typeParameters,
1747
- type.typeAliasInfo.typeArguments
1748
- );
1749
- }
1750
-
1751
- return result;
1752
- }
1753
-
1754
- export function getMembersForClass(classType: ClassType, symbolTable: SymbolTable, includeInstanceVars: boolean) {
1755
- for (let i = 0; i < classType.details.mro.length; i++) {
1756
- const mroClass = classType.details.mro[i];
1757
-
1758
- if (isInstantiableClass(mroClass)) {
1759
- // Add any new member variables from this class.
1760
- const isClassTypedDict = ClassType.isTypedDictClass(mroClass);
1761
- mroClass.details.fields.forEach((symbol, name) => {
1762
- if (symbol.isClassMember() || (includeInstanceVars && symbol.isInstanceMember())) {
1763
- if (!isClassTypedDict || !isTypedDictMemberAccessedThroughIndex(symbol)) {
1764
- if (!symbol.isInitVar()) {
1765
- const existingSymbol = symbolTable.get(name);
1766
-
1767
- if (!existingSymbol) {
1768
- symbolTable.set(name, symbol);
1769
- } else if (!existingSymbol.hasTypedDeclarations() && symbol.hasTypedDeclarations()) {
1770
- // If the existing symbol is unannotated but a parent class
1771
- // has an annotation for the symbol, use the parent type instead.
1772
- symbolTable.set(name, symbol);
1773
- }
1774
- }
1775
- }
1776
- }
1777
- });
1778
- }
1779
- }
1780
-
1781
- // Add members of the metaclass as well.
1782
- if (!includeInstanceVars) {
1783
- const metaclass = classType.details.effectiveMetaclass;
1784
- if (metaclass && isInstantiableClass(metaclass)) {
1785
- for (const mroClass of metaclass.details.mro) {
1786
- if (isInstantiableClass(mroClass)) {
1787
- mroClass.details.fields.forEach((symbol, name) => {
1788
- const existingSymbol = symbolTable.get(name);
1789
-
1790
- if (!existingSymbol) {
1791
- symbolTable.set(name, symbol);
1792
- } else if (!existingSymbol.hasTypedDeclarations() && symbol.hasTypedDeclarations()) {
1793
- // If the existing symbol is unannotated but a parent class
1794
- // has an annotation for the symbol, use the parent type instead.
1795
- symbolTable.set(name, symbol);
1796
- }
1797
- });
1798
- } else {
1799
- break;
1800
- }
1801
- }
1802
- }
1803
- }
1804
- }
1805
-
1806
- export function getMembersForModule(moduleType: ModuleType, symbolTable: SymbolTable) {
1807
- // Start with the loader fields. If there are any symbols of the
1808
- // same name defined within the module, they will overwrite the
1809
- // loader fields.
1810
- if (moduleType.loaderFields) {
1811
- moduleType.loaderFields.forEach((symbol, name) => {
1812
- symbolTable.set(name, symbol);
1813
- });
1814
- }
1815
-
1816
- moduleType.fields.forEach((symbol, name) => {
1817
- symbolTable.set(name, symbol);
1818
- });
1819
- }
1820
-
1821
- // Determines if the type is an Unknown or a union that contains an Unknown.
1822
- // It does not look at type arguments.
1823
- export function containsUnknown(type: Type) {
1824
- let foundUnknown = false;
1825
-
1826
- doForEachSubtype(type, (subtype) => {
1827
- if (isUnknown(subtype)) {
1828
- foundUnknown = true;
1829
- }
1830
- });
1831
-
1832
- return foundUnknown;
1833
- }
1834
-
1835
- // Determines if any part of the type contains "Unknown", including any type arguments.
1836
- export function isPartlyUnknown(type: Type, allowUnknownTypeArgsForClasses = false, recursionCount = 0): boolean {
1837
- if (recursionCount > maxTypeRecursionCount) {
1838
- return false;
1839
- }
1840
- recursionCount++;
1841
-
1842
- if (isUnknown(type)) {
1843
- return true;
1844
- }
1845
-
1846
- // If this is a generic type alias, see if any of its type arguments
1847
- // are either unspecified or are partially known.
1848
- if (type.typeAliasInfo?.typeArguments) {
1849
- if (
1850
- type.typeAliasInfo.typeArguments.some((typeArg) =>
1851
- isPartlyUnknown(typeArg, allowUnknownTypeArgsForClasses, recursionCount)
1852
- )
1853
- ) {
1854
- return true;
1855
- }
1856
- }
1857
-
1858
- // See if a union contains an unknown type.
1859
- if (isUnion(type)) {
1860
- return (
1861
- findSubtype(type, (subtype) => isPartlyUnknown(subtype, allowUnknownTypeArgsForClasses, recursionCount)) !==
1862
- undefined
1863
- );
1864
- }
1865
-
1866
- // See if an object or class has an unknown type argument.
1867
- if (isClass(type)) {
1868
- if (TypeBase.isInstance(type)) {
1869
- allowUnknownTypeArgsForClasses = false;
1870
- }
1871
-
1872
- if (!allowUnknownTypeArgsForClasses && !ClassType.isPseudoGenericClass(type)) {
1873
- const typeArgs = type.tupleTypeArguments?.map((t) => t.type) || type.typeArguments;
1874
- if (typeArgs) {
1875
- for (const argType of typeArgs) {
1876
- if (isPartlyUnknown(argType, allowUnknownTypeArgsForClasses, recursionCount)) {
1877
- return true;
1878
- }
1879
- }
1880
- }
1881
- }
1882
-
1883
- return false;
1884
- }
1885
-
1886
- // See if a function has an unknown type.
1887
- if (isOverloadedFunction(type)) {
1888
- return type.overloads.some((overload) => {
1889
- return isPartlyUnknown(overload, false, recursionCount);
1890
- });
1891
- }
1892
-
1893
- if (isFunction(type)) {
1894
- for (let i = 0; i < type.details.parameters.length; i++) {
1895
- // Ignore parameters such as "*" that have no name.
1896
- if (type.details.parameters[i].name) {
1897
- const paramType = FunctionType.getEffectiveParameterType(type, i);
1898
- if (isPartlyUnknown(paramType, /* allowUnknownTypeArgsForClasses */ false, recursionCount)) {
1899
- return true;
1900
- }
1901
- }
1902
- }
1903
-
1904
- if (
1905
- type.details.declaredReturnType &&
1906
- !FunctionType.isParamSpecValue(type) &&
1907
- isPartlyUnknown(type.details.declaredReturnType, /* allowUnknownTypeArgsForClasses */ false, recursionCount)
1908
- ) {
1909
- return true;
1910
- }
1911
-
1912
- return false;
1913
- }
1914
-
1915
- return false;
1916
- }
1917
-
1918
- // If the specified type is a generic class with a single type argument
1919
- // that is a union, it "explodes" the class into a union of classes with
1920
- // each element of the union - e.g. Foo[A | B] becomes Foo[A] | Foo[B].
1921
- export function explodeGenericClass(classType: ClassType) {
1922
- if (!classType.typeArguments || classType.typeArguments.length !== 1 || !isUnion(classType.typeArguments[0])) {
1923
- return classType;
1924
- }
1925
-
1926
- return combineTypes(
1927
- classType.typeArguments[0].subtypes.map((subtype) => {
1928
- return ClassType.cloneForSpecialization(classType, [subtype], /* isTypeArgumentExplicit */ true);
1929
- })
1930
- );
1931
- }
1932
-
1933
- // If the type is a union of same-sized tuples, these are combined into
1934
- // a single tuple with that size. Otherwise, returns undefined.
1935
- export function combineSameSizedTuples(type: Type, tupleType: Type | undefined) {
1936
- if (!tupleType || !isInstantiableClass(tupleType) || isUnboundedTupleClass(tupleType)) {
1937
- return undefined;
1938
- }
1939
-
1940
- let tupleEntries: Type[][] | undefined;
1941
- let isValid = true;
1942
-
1943
- doForEachSubtype(type, (subtype) => {
1944
- if (isClassInstance(subtype)) {
1945
- let tupleClass: ClassType | undefined;
1946
- if (isClass(subtype) && isTupleClass(subtype) && !isUnboundedTupleClass(subtype)) {
1947
- tupleClass = subtype;
1948
- }
1949
-
1950
- if (!tupleClass) {
1951
- // Look in the mro list to see if this subtype derives from a
1952
- // tuple with a known size. This includes named tuples.
1953
- tupleClass = subtype.details.mro.find(
1954
- (mroClass) => isClass(mroClass) && isTupleClass(mroClass) && !isUnboundedTupleClass(mroClass)
1955
- ) as ClassType | undefined;
1956
- }
1957
-
1958
- if (tupleClass && isClass(tupleClass) && tupleClass.tupleTypeArguments) {
1959
- if (tupleEntries) {
1960
- if (tupleEntries.length === tupleClass.tupleTypeArguments.length) {
1961
- tupleClass.tupleTypeArguments.forEach((entry, index) => {
1962
- tupleEntries![index].push(entry.type);
1963
- });
1964
- } else {
1965
- isValid = false;
1966
- }
1967
- } else {
1968
- tupleEntries = tupleClass.tupleTypeArguments.map((entry) => [entry.type]);
1969
- }
1970
- } else {
1971
- isValid = false;
1972
- }
1973
- } else {
1974
- isValid = false;
1975
- }
1976
- });
1977
-
1978
- if (!isValid || !tupleEntries) {
1979
- return undefined;
1980
- }
1981
-
1982
- return convertToInstance(
1983
- specializeTupleClass(
1984
- tupleType,
1985
- tupleEntries.map((entry) => {
1986
- return { type: combineTypes(entry), isUnbounded: false };
1987
- })
1988
- )
1989
- );
1990
- }
1991
-
1992
- // Tuples require special handling for specialization. This method computes
1993
- // the "effective" type argument, which is a union of the variadic type
1994
- // arguments. If stripLiterals is true, literal values are stripped when
1995
- // computing the effective type args.
1996
- export function specializeTupleClass(
1997
- classType: ClassType,
1998
- typeArgs: TupleTypeArgument[],
1999
- isTypeArgumentExplicit = true,
2000
- stripLiterals = true,
2001
- isUnpackedTuple = false
2002
- ): ClassType {
2003
- let combinedTupleType = combineTypes(typeArgs.map((t) => t.type));
2004
-
2005
- if (stripLiterals) {
2006
- combinedTupleType = stripLiteralValue(combinedTupleType);
2007
- }
2008
-
2009
- // An empty tuple has an effective type of Any.
2010
- if (isNever(combinedTupleType)) {
2011
- combinedTupleType = AnyType.create();
2012
- }
2013
-
2014
- const clonedClassType = ClassType.cloneForSpecialization(
2015
- classType,
2016
- [combinedTupleType],
2017
- isTypeArgumentExplicit,
2018
- /* includeSubclasses */ undefined,
2019
- typeArgs
2020
- );
2021
-
2022
- if (isUnpackedTuple) {
2023
- clonedClassType.isUnpacked = true;
2024
- }
2025
-
2026
- return clonedClassType;
2027
- }
2028
-
2029
- // If the type is a function or overloaded function that has a paramSpec
2030
- // associated with it and P.args and P.kwargs at the end of the signature,
2031
- // it removes these parameters from the function.
2032
- export function removeParamSpecVariadicsFromSignature(type: FunctionType | OverloadedFunctionType) {
2033
- if (isFunction(type)) {
2034
- return removeParamSpecVariadicsFromFunction(type);
2035
- }
2036
-
2037
- const newOverloads: FunctionType[] = [];
2038
- let newTypeNeeded = false;
2039
-
2040
- for (const overload of type.overloads) {
2041
- const newOverload = removeParamSpecVariadicsFromFunction(overload);
2042
- newOverloads.push(newOverload);
2043
- if (newOverload !== overload) {
2044
- newTypeNeeded = true;
2045
- }
2046
- }
2047
-
2048
- return newTypeNeeded ? OverloadedFunctionType.create(newOverloads) : type;
2049
- }
2050
-
2051
- export function removeParamSpecVariadicsFromFunction(type: FunctionType): FunctionType {
2052
- const paramCount = type.details.parameters.length;
2053
- if (paramCount < 2) {
2054
- return type;
2055
- }
2056
-
2057
- const argsParam = type.details.parameters[paramCount - 2];
2058
- const kwargsParam = type.details.parameters[paramCount - 1];
2059
-
2060
- if (
2061
- argsParam.category !== ParameterCategory.VarArgList ||
2062
- kwargsParam.category !== ParameterCategory.VarArgDictionary ||
2063
- !isParamSpec(argsParam.type) ||
2064
- !isParamSpec(kwargsParam.type) ||
2065
- !isTypeSame(argsParam.type, kwargsParam.type)
2066
- ) {
2067
- return type;
2068
- }
2069
-
2070
- return FunctionType.cloneRemoveParamSpecVariadics(type, argsParam.type);
2071
- }
2072
-
2073
- function _expandVariadicUnpackedUnion(type: Type) {
2074
- if (isClassInstance(type) && isTupleClass(type) && type.tupleTypeArguments && type.isUnpacked) {
2075
- return combineTypes(type.tupleTypeArguments.map((t) => t.type));
2076
- }
2077
-
2078
- return type;
2079
- }
2080
-
2081
- // If the declared return type for the function is a Generator or AsyncGenerator,
2082
- // returns the type arguments for the type.
2083
- export function getGeneratorTypeArgs(returnType: Type): Type[] | undefined {
2084
- if (isClassInstance(returnType)) {
2085
- if (ClassType.isBuiltIn(returnType, ['Generator', 'AsyncGenerator'])) {
2086
- return returnType.typeArguments;
2087
- } else if (ClassType.isBuiltIn(returnType, 'AwaitableGenerator')) {
2088
- // AwaitableGenerator has four type arguments, and the last 3
2089
- // correspond to the generator.
2090
- return returnType.typeArguments?.slice(1);
2091
- }
2092
- }
2093
-
2094
- return undefined;
2095
- }
2096
-
2097
- export function requiresTypeArguments(classType: ClassType) {
2098
- if (classType.details.typeParameters.length > 0) {
2099
- // If there are type parameters, type arguments are needed.
2100
- // The exception is if type parameters have been synthesized
2101
- // for classes that have untyped constructors.
2102
- return !classType.details.typeParameters[0].details.isSynthesized;
2103
- }
2104
-
2105
- // There are a few built-in special classes that require
2106
- // type arguments even though typeParameters is empty.
2107
- if (ClassType.isSpecialBuiltIn(classType)) {
2108
- const specialClasses = [
2109
- 'Tuple',
2110
- 'Callable',
2111
- 'Generic',
2112
- 'Type',
2113
- 'Optional',
2114
- 'Union',
2115
- 'Literal',
2116
- 'Annotated',
2117
- 'TypeGuard',
2118
- 'StrictTypeGuard',
2119
- ];
2120
-
2121
- if (specialClasses.some((t) => t === (classType.aliasName || classType.details.name))) {
2122
- return true;
2123
- }
2124
- }
2125
-
2126
- return false;
2127
- }
2128
-
2129
- export function requiresSpecialization(
2130
- type: Type,
2131
- ignorePseudoGeneric = false,
2132
- ignoreSelf = false,
2133
- recursionCount = 0
2134
- ): boolean {
2135
- if (recursionCount > maxTypeRecursionCount) {
2136
- return false;
2137
- }
2138
- recursionCount++;
2139
-
2140
- switch (type.category) {
2141
- case TypeCategory.Class: {
2142
- if (ClassType.isPseudoGenericClass(type) && ignorePseudoGeneric) {
2143
- return false;
2144
- }
2145
-
2146
- if (type.typeArguments) {
2147
- return (
2148
- type.typeArguments.find((typeArg) =>
2149
- requiresSpecialization(typeArg, ignorePseudoGeneric, ignoreSelf, recursionCount)
2150
- ) !== undefined
2151
- );
2152
- }
2153
-
2154
- return ClassType.getTypeParameters(type).length > 0;
2155
- }
2156
-
2157
- case TypeCategory.Function: {
2158
- if (type.details.paramSpec) {
2159
- return true;
2160
- }
2161
-
2162
- for (let i = 0; i < type.details.parameters.length; i++) {
2163
- if (
2164
- requiresSpecialization(
2165
- FunctionType.getEffectiveParameterType(type, i),
2166
- ignorePseudoGeneric,
2167
- ignoreSelf,
2168
- recursionCount
2169
- )
2170
- ) {
2171
- return true;
2172
- }
2173
- }
2174
-
2175
- const declaredReturnType =
2176
- type.specializedTypes && type.specializedTypes.returnType
2177
- ? type.specializedTypes.returnType
2178
- : type.details.declaredReturnType;
2179
- if (declaredReturnType) {
2180
- if (requiresSpecialization(declaredReturnType, ignorePseudoGeneric, ignoreSelf, recursionCount)) {
2181
- return true;
2182
- }
2183
- } else if (type.inferredReturnType) {
2184
- if (requiresSpecialization(type.inferredReturnType, ignorePseudoGeneric, ignoreSelf, recursionCount)) {
2185
- return true;
2186
- }
2187
- }
2188
-
2189
- return false;
2190
- }
2191
-
2192
- case TypeCategory.OverloadedFunction: {
2193
- return (
2194
- type.overloads.find((overload) =>
2195
- requiresSpecialization(overload, ignorePseudoGeneric, ignoreSelf, recursionCount)
2196
- ) !== undefined
2197
- );
2198
- }
2199
-
2200
- case TypeCategory.Union: {
2201
- return (
2202
- findSubtype(type, (subtype) =>
2203
- requiresSpecialization(subtype, ignorePseudoGeneric, ignoreSelf, recursionCount)
2204
- ) !== undefined
2205
- );
2206
- }
2207
-
2208
- case TypeCategory.TypeVar: {
2209
- // Most TypeVar types need to be specialized.
2210
- if (!type.details.recursiveTypeAliasName) {
2211
- if (type.details.isSynthesizedSelf && ignoreSelf) {
2212
- return false;
2213
- }
2214
-
2215
- return true;
2216
- }
2217
-
2218
- // If this is a recursive type alias, it may need to be specialized
2219
- // if it has generic type arguments.
2220
- if (type.typeAliasInfo?.typeArguments) {
2221
- return type.typeAliasInfo.typeArguments.some((typeArg) =>
2222
- requiresSpecialization(typeArg, ignorePseudoGeneric, ignoreSelf, recursionCount)
2223
- );
2224
- }
2225
- }
2226
- }
2227
-
2228
- return false;
2229
- }
2230
-
2231
- // Computes the method resolution ordering for a class whose base classes
2232
- // have already been filled in. The algorithm for computing MRO is described
2233
- // here: https://www.python.org/download/releases/2.3/mro/. It returns true
2234
- // if an MRO was possible, false otherwise.
2235
- export function computeMroLinearization(classType: ClassType): boolean {
2236
- let isMroFound = true;
2237
-
2238
- // Clear out any existing MRO information.
2239
- classType.details.mro = [];
2240
-
2241
- const filteredBaseClasses = classType.details.baseClasses.filter((baseClass, index) => {
2242
- if (isInstantiableClass(baseClass)) {
2243
- // Generic has some special-case logic (see description of __mro_entries__
2244
- // in PEP 560) that we need to account for here.
2245
- if (ClassType.isBuiltIn(baseClass, 'Generic')) {
2246
- // If the class is a Protocol, the generic is ignored for the purposes
2247
- // of computing the MRO.
2248
- if (ClassType.isProtocolClass(classType)) {
2249
- return false;
2250
- }
2251
-
2252
- // If the class contains any specialized generic classes after
2253
- // the Generic base, the Generic base is ignored for purposes
2254
- // of computing the MRO.
2255
- if (
2256
- classType.details.baseClasses.some((innerBaseClass, innerIndex) => {
2257
- return (
2258
- innerIndex > index &&
2259
- isInstantiableClass(innerBaseClass) &&
2260
- innerBaseClass.typeArguments &&
2261
- innerBaseClass.isTypeArgumentExplicit
2262
- );
2263
- })
2264
- ) {
2265
- return false;
2266
- }
2267
- }
2268
- }
2269
-
2270
- return true;
2271
- });
2272
-
2273
- // Construct the list of class lists that need to be merged.
2274
- const classListsToMerge: Type[][] = [];
2275
-
2276
- filteredBaseClasses.forEach((baseClass, index) => {
2277
- if (isInstantiableClass(baseClass)) {
2278
- const typeVarContext = buildTypeVarContextFromSpecializedClass(baseClass, /* makeConcrete */ false);
2279
- classListsToMerge.push(
2280
- baseClass.details.mro.map((mroClass) => {
2281
- return applySolvedTypeVars(mroClass, typeVarContext);
2282
- })
2283
- );
2284
- } else {
2285
- classListsToMerge.push([baseClass]);
2286
- }
2287
- });
2288
-
2289
- classListsToMerge.push(
2290
- filteredBaseClasses.map((baseClass) => {
2291
- const typeVarContext = buildTypeVarContextFromSpecializedClass(classType, /* makeConcrete */ false);
2292
- return applySolvedTypeVars(baseClass, typeVarContext);
2293
- })
2294
- );
2295
-
2296
- // The first class in the MRO is the class itself.
2297
- const typeVarContext = buildTypeVarContextFromSpecializedClass(classType, /* makeConcrete */ false);
2298
- classType.details.mro.push(applySolvedTypeVars(classType, typeVarContext));
2299
-
2300
- // Helper function that returns true if the specified searchClass
2301
- // is found in the "tail" (i.e. in elements 1 through n) of any
2302
- // of the class lists.
2303
- const isInTail = (searchClass: ClassType, classLists: Type[][]) => {
2304
- return classLists.some((classList) => {
2305
- return (
2306
- classList.findIndex(
2307
- (value) => isInstantiableClass(value) && ClassType.isSameGenericClass(value, searchClass)
2308
- ) > 0
2309
- );
2310
- });
2311
- };
2312
-
2313
- const filterClass = (classToFilter: ClassType, classLists: Type[][]) => {
2314
- for (let i = 0; i < classLists.length; i++) {
2315
- classLists[i] = classLists[i].filter(
2316
- (value) => !isInstantiableClass(value) || !ClassType.isSameGenericClass(value, classToFilter)
2317
- );
2318
- }
2319
- };
2320
-
2321
- while (true) {
2322
- let foundValidHead = false;
2323
- let nonEmptyList: Type[] | undefined = undefined;
2324
-
2325
- for (let i = 0; i < classListsToMerge.length; i++) {
2326
- const classList = classListsToMerge[i];
2327
-
2328
- if (classList.length > 0) {
2329
- if (nonEmptyList === undefined) {
2330
- nonEmptyList = classList;
2331
- }
2332
-
2333
- if (!isInstantiableClass(classList[0])) {
2334
- foundValidHead = true;
2335
- classType.details.mro.push(classList[0]);
2336
- classList.shift();
2337
- break;
2338
- } else if (!isInTail(classList[0], classListsToMerge)) {
2339
- foundValidHead = true;
2340
- classType.details.mro.push(classList[0]);
2341
- filterClass(classList[0], classListsToMerge);
2342
- break;
2343
- }
2344
- }
2345
- }
2346
-
2347
- // If all lists are empty, we are done.
2348
- if (!nonEmptyList) {
2349
- break;
2350
- }
2351
-
2352
- // We made it all the way through the list of class lists without
2353
- // finding a valid head, but there is at least one list that's not
2354
- // yet empty. This means there's no valid MRO order.
2355
- if (!foundValidHead) {
2356
- isMroFound = false;
2357
-
2358
- // Handle the situation by pull the head off the first empty list.
2359
- // This allows us to make forward progress.
2360
- if (!isInstantiableClass(nonEmptyList[0])) {
2361
- classType.details.mro.push(nonEmptyList[0]);
2362
- nonEmptyList.shift();
2363
- } else {
2364
- classType.details.mro.push(nonEmptyList[0]);
2365
- filterClass(nonEmptyList[0], classListsToMerge);
2366
- }
2367
- }
2368
- }
2369
-
2370
- return isMroFound;
2371
- }
2372
-
2373
- // Returns zero or more unique module names that point to the place(s)
2374
- // where the type is declared. Unions, for example, can result in more
2375
- // than one result. Type arguments are not included.
2376
- export function getDeclaringModulesForType(type: Type): string[] {
2377
- const moduleList: string[] = [];
2378
- addDeclaringModuleNamesForType(type, moduleList);
2379
- return moduleList;
2380
- }
2381
-
2382
- function addDeclaringModuleNamesForType(type: Type, moduleList: string[], recursionCount = 0) {
2383
- if (recursionCount > maxTypeRecursionCount) {
2384
- return;
2385
- }
2386
- recursionCount++;
2387
-
2388
- const addIfUnique = (moduleName: string) => {
2389
- if (moduleName && !moduleList.some((n) => n === moduleName)) {
2390
- moduleList.push(moduleName);
2391
- }
2392
- };
2393
-
2394
- switch (type.category) {
2395
- case TypeCategory.Class: {
2396
- addIfUnique(type.details.moduleName);
2397
- break;
2398
- }
2399
-
2400
- case TypeCategory.Function: {
2401
- addIfUnique(type.details.moduleName);
2402
- break;
2403
- }
2404
-
2405
- case TypeCategory.OverloadedFunction: {
2406
- type.overloads.forEach((overload) => {
2407
- addDeclaringModuleNamesForType(overload, moduleList, recursionCount);
2408
- });
2409
- break;
2410
- }
2411
-
2412
- case TypeCategory.Union: {
2413
- doForEachSubtype(type, (subtype) => {
2414
- addDeclaringModuleNamesForType(subtype, moduleList, recursionCount);
2415
- });
2416
- break;
2417
- }
2418
-
2419
- case TypeCategory.Module: {
2420
- addIfUnique(type.moduleName);
2421
- break;
2422
- }
2423
- }
2424
- }
2425
-
2426
- export function convertParamSpecValueToType(paramSpecEntry: ParamSpecValue, omitParamSpec = false): Type {
2427
- let hasParameters = paramSpecEntry.parameters.length > 0;
2428
-
2429
- if (paramSpecEntry.parameters.length === 1) {
2430
- // If the ParamSpec has a position-only separator as its only parameter,
2431
- // treat it as though there are no parameters.
2432
- const onlyParam = paramSpecEntry.parameters[0];
2433
- if (onlyParam.category === ParameterCategory.Simple && !onlyParam.name) {
2434
- hasParameters = false;
2435
- }
2436
- }
2437
-
2438
- if (hasParameters || !paramSpecEntry.paramSpec || omitParamSpec) {
2439
- // Create a function type from the param spec entries.
2440
- const functionType = FunctionType.createInstance(
2441
- '',
2442
- '',
2443
- '',
2444
- FunctionTypeFlags.ParamSpecValue | paramSpecEntry.flags
2445
- );
2446
-
2447
- paramSpecEntry.parameters.forEach((entry) => {
2448
- FunctionType.addParameter(functionType, {
2449
- category: entry.category,
2450
- name: entry.name,
2451
- hasDefault: entry.hasDefault,
2452
- isNameSynthesized: entry.isNameSynthesized,
2453
- hasDeclaredType: true,
2454
- type: entry.type,
2455
- });
2456
- });
2457
-
2458
- if (!omitParamSpec) {
2459
- functionType.details.paramSpec = paramSpecEntry.paramSpec;
2460
- }
2461
- functionType.details.docString = paramSpecEntry.docString;
2462
-
2463
- return functionType;
2464
- }
2465
-
2466
- return paramSpecEntry.paramSpec;
2467
- }
2468
-
2469
- // Recursively walks a type and calls a callback for each TypeVar, allowing
2470
- // it to be replaced with something else.
2471
- class TypeVarTransformer {
2472
- private _isTransformingTypeArg = false;
2473
- private _pendingTypeVarTransformations = new Set<string>();
2474
-
2475
- apply(type: Type, recursionCount = 0): Type {
2476
- if (recursionCount > maxTypeRecursionCount) {
2477
- return type;
2478
- }
2479
- recursionCount++;
2480
-
2481
- type = this._transformGenericTypeAlias(type, recursionCount);
2482
-
2483
- // Shortcut the operation if possible.
2484
- if (!requiresSpecialization(type)) {
2485
- return type;
2486
- }
2487
-
2488
- if (isAnyOrUnknown(type)) {
2489
- return type;
2490
- }
2491
-
2492
- if (isNoneInstance(type)) {
2493
- return type;
2494
- }
2495
-
2496
- if (isTypeVar(type)) {
2497
- // Handle recursive type aliases specially. In particular,
2498
- // we need to specialize type arguments for generic recursive
2499
- // type aliases.
2500
- if (type.details.recursiveTypeAliasName) {
2501
- if (!type.typeAliasInfo?.typeArguments) {
2502
- return type;
2503
- }
2504
-
2505
- let requiresUpdate = false;
2506
- const typeArgs = type.typeAliasInfo.typeArguments.map((typeArg) => {
2507
- const replacementType = this.apply(typeArg, recursionCount);
2508
- if (replacementType !== typeArg) {
2509
- requiresUpdate = true;
2510
- }
2511
- return replacementType;
2512
- });
2513
-
2514
- if (requiresUpdate) {
2515
- return TypeBase.cloneForTypeAlias(
2516
- type,
2517
- type.typeAliasInfo.name,
2518
- type.typeAliasInfo.fullName,
2519
- type.typeAliasInfo.typeVarScopeId,
2520
- type.typeAliasInfo.typeParameters,
2521
- typeArgs
2522
- );
2523
- }
2524
-
2525
- return type;
2526
- }
2527
-
2528
- let replacementType: Type = type;
2529
-
2530
- // Recursively transform the results, but ensure that we don't replace the
2531
- // same type variable recursively by setting it in the
2532
- // _pendingTypeVarTransformations set.
2533
- const typeVarName = TypeVarType.getNameWithScope(type);
2534
- if (!this._pendingTypeVarTransformations.has(typeVarName)) {
2535
- replacementType = this.transformTypeVar(type);
2536
-
2537
- if (!this._isTransformingTypeArg) {
2538
- this._pendingTypeVarTransformations.add(typeVarName);
2539
- replacementType = this.apply(replacementType, recursionCount);
2540
- this._pendingTypeVarTransformations.delete(typeVarName);
2541
- }
2542
-
2543
- // If we're transforming a variadic type variable that was in a union,
2544
- // expand the union types.
2545
- if (isVariadicTypeVar(type) && type.isVariadicInUnion) {
2546
- replacementType = _expandVariadicUnpackedUnion(replacementType);
2547
- }
2548
- }
2549
-
2550
- return replacementType;
2551
- }
2552
-
2553
- if (isUnion(type)) {
2554
- const newUnionType = mapSubtypes(type, (subtype) => {
2555
- let transformedType: Type = this.apply(subtype, recursionCount);
2556
-
2557
- // If we're transforming a variadic type variable within a union,
2558
- // combine the individual types within the variadic type variable.
2559
- if (isVariadicTypeVar(subtype) && !isVariadicTypeVar(transformedType)) {
2560
- const subtypesToCombine: Type[] = [];
2561
- doForEachSubtype(transformedType, (transformedSubtype) => {
2562
- subtypesToCombine.push(_expandVariadicUnpackedUnion(transformedSubtype));
2563
- });
2564
-
2565
- transformedType = combineTypes(subtypesToCombine);
2566
- }
2567
-
2568
- if (this.transformUnionSubtype) {
2569
- return this.transformUnionSubtype(subtype, transformedType);
2570
- }
2571
-
2572
- return transformedType;
2573
- });
2574
-
2575
- return !isNever(newUnionType) ? newUnionType : UnknownType.create();
2576
- }
2577
-
2578
- if (isClass(type)) {
2579
- return this._transformTypeVarsInClassType(type, recursionCount);
2580
- }
2581
-
2582
- if (isFunction(type)) {
2583
- return this._transformTypeVarsInFunctionType(type, recursionCount);
2584
- }
2585
-
2586
- if (isOverloadedFunction(type)) {
2587
- let requiresUpdate = false;
2588
-
2589
- // Specialize each of the functions in the overload.
2590
- const newOverloads: FunctionType[] = [];
2591
- type.overloads.forEach((entry) => {
2592
- const replacementType = this._transformTypeVarsInFunctionType(entry, recursionCount);
2593
- newOverloads.push(replacementType);
2594
- if (replacementType !== entry) {
2595
- requiresUpdate = true;
2596
- }
2597
- });
2598
-
2599
- // Construct a new overload with the specialized function types.
2600
- return requiresUpdate ? OverloadedFunctionType.create(newOverloads) : type;
2601
- }
2602
-
2603
- return type;
2604
- }
2605
-
2606
- transformTypeVar(typeVar: TypeVarType): Type {
2607
- return typeVar;
2608
- }
2609
-
2610
- transformVariadicTypeVar(paramSpec: TypeVarType): TupleTypeArgument[] | undefined {
2611
- return undefined;
2612
- }
2613
-
2614
- transformParamSpec(paramSpec: TypeVarType): ParamSpecValue | undefined {
2615
- return undefined;
2616
- }
2617
-
2618
- transformUnionSubtype(preTransform: Type, postTransform: Type): Type | undefined {
2619
- return postTransform;
2620
- }
2621
-
2622
- private _transformGenericTypeAlias(type: Type, recursionCount: number) {
2623
- if (!type.typeAliasInfo || !type.typeAliasInfo.typeParameters || !type.typeAliasInfo.typeArguments) {
2624
- return type;
2625
- }
2626
-
2627
- let requiresUpdate = false;
2628
- const newTypeArgs = type.typeAliasInfo.typeArguments.map((typeArg) => {
2629
- const updatedType = this.apply(typeArg, recursionCount);
2630
- if (type !== updatedType) {
2631
- requiresUpdate = true;
2632
- }
2633
- return updatedType;
2634
- });
2635
-
2636
- return requiresUpdate
2637
- ? TypeBase.cloneForTypeAlias(
2638
- type,
2639
- type.typeAliasInfo.name,
2640
- type.typeAliasInfo.fullName,
2641
- type.typeAliasInfo.typeVarScopeId,
2642
- type.typeAliasInfo.typeParameters,
2643
- newTypeArgs
2644
- )
2645
- : type;
2646
- }
2647
-
2648
- private _transformTypeVarsInClassType(classType: ClassType, recursionCount: number): ClassType {
2649
- // Handle the common case where the class has no type parameters.
2650
- if (ClassType.getTypeParameters(classType).length === 0 && !ClassType.isSpecialBuiltIn(classType)) {
2651
- return classType;
2652
- }
2653
-
2654
- let newTypeArgs: Type[] = [];
2655
- let newVariadicTypeArgs: TupleTypeArgument[] | undefined;
2656
- let specializationNeeded = false;
2657
- const typeParams = ClassType.getTypeParameters(classType);
2658
-
2659
- const transformParamSpec = (paramSpec: TypeVarType) => {
2660
- const paramSpecValue = this.transformParamSpec(paramSpec);
2661
- if (paramSpecValue) {
2662
- specializationNeeded = true;
2663
- return convertParamSpecValueToType(paramSpecValue);
2664
- } else {
2665
- return paramSpec;
2666
- }
2667
- };
2668
-
2669
- const wasTransformingTypeArg = this._isTransformingTypeArg;
2670
- this._isTransformingTypeArg = true;
2671
-
2672
- // If type args were previously provided, specialize them.
2673
- if (classType.typeArguments) {
2674
- newTypeArgs = classType.typeArguments.map((oldTypeArgType) => {
2675
- if (isTypeVar(oldTypeArgType) && oldTypeArgType.details.isParamSpec) {
2676
- return transformParamSpec(oldTypeArgType);
2677
- }
2678
-
2679
- let newTypeArgType = this.apply(oldTypeArgType, recursionCount);
2680
- if (newTypeArgType !== oldTypeArgType) {
2681
- specializationNeeded = true;
2682
-
2683
- // If this was a variadic type variable that was part of a union
2684
- // (e.g. Union[Unpack[Vs]]), expand the subtypes into a union here.
2685
- if (
2686
- isTypeVar(oldTypeArgType) &&
2687
- isVariadicTypeVar(oldTypeArgType) &&
2688
- oldTypeArgType.isVariadicInUnion
2689
- ) {
2690
- newTypeArgType = _expandVariadicUnpackedUnion(newTypeArgType);
2691
- }
2692
- }
2693
- return newTypeArgType;
2694
- });
2695
- } else {
2696
- typeParams.forEach((typeParam) => {
2697
- let replacementType: Type = typeParam;
2698
-
2699
- if (typeParam.details.isParamSpec) {
2700
- replacementType = transformParamSpec(typeParam);
2701
- if (replacementType !== typeParam) {
2702
- specializationNeeded = true;
2703
- }
2704
- } else {
2705
- const typeParamName = TypeVarType.getNameWithScope(typeParam);
2706
- if (!this._pendingTypeVarTransformations.has(typeParamName)) {
2707
- replacementType = this.transformTypeVar(typeParam);
2708
-
2709
- if (replacementType !== typeParam) {
2710
- if (!this._isTransformingTypeArg) {
2711
- this._pendingTypeVarTransformations.add(typeParamName);
2712
- replacementType = this.apply(replacementType, recursionCount);
2713
- this._pendingTypeVarTransformations.delete(typeParamName);
2714
- }
2715
-
2716
- specializationNeeded = true;
2717
- }
2718
- }
2719
- }
2720
-
2721
- newTypeArgs.push(replacementType);
2722
- });
2723
- }
2724
-
2725
- if (ClassType.isTupleClass(classType)) {
2726
- if (classType.tupleTypeArguments) {
2727
- newVariadicTypeArgs = [];
2728
- classType.tupleTypeArguments.forEach((oldTypeArgType) => {
2729
- const newTypeArgType = this.apply(oldTypeArgType.type, recursionCount);
2730
-
2731
- if (newTypeArgType !== oldTypeArgType.type) {
2732
- specializationNeeded = true;
2733
- }
2734
-
2735
- if (
2736
- isVariadicTypeVar(oldTypeArgType.type) &&
2737
- isClassInstance(newTypeArgType) &&
2738
- isTupleClass(newTypeArgType) &&
2739
- newTypeArgType.tupleTypeArguments
2740
- ) {
2741
- appendArray(newVariadicTypeArgs!, newTypeArgType.tupleTypeArguments);
2742
- } else {
2743
- newVariadicTypeArgs!.push({ type: newTypeArgType, isUnbounded: oldTypeArgType.isUnbounded });
2744
- }
2745
- });
2746
- } else if (typeParams.length > 0) {
2747
- newVariadicTypeArgs = this.transformVariadicTypeVar(typeParams[0]);
2748
- if (newVariadicTypeArgs) {
2749
- specializationNeeded = true;
2750
- }
2751
- }
2752
- }
2753
-
2754
- this._isTransformingTypeArg = wasTransformingTypeArg;
2755
-
2756
- // If specialization wasn't needed, don't allocate a new class.
2757
- if (!specializationNeeded) {
2758
- return classType;
2759
- }
2760
-
2761
- return ClassType.cloneForSpecialization(
2762
- classType,
2763
- newTypeArgs,
2764
- /* isTypeArgumentExplicit */ true,
2765
- /* includeSubclasses */ undefined,
2766
- newVariadicTypeArgs
2767
- );
2768
- }
2769
-
2770
- private _transformTypeVarsInFunctionType(sourceType: FunctionType, recursionCount: number): FunctionType {
2771
- let functionType = sourceType;
2772
-
2773
- // Handle functions with a parameter specification in a special manner.
2774
- if (functionType.details.paramSpec) {
2775
- const paramSpec = this.transformParamSpec(functionType.details.paramSpec);
2776
- if (paramSpec) {
2777
- functionType = FunctionType.cloneForParamSpec(functionType, paramSpec);
2778
- }
2779
- }
2780
-
2781
- const declaredReturnType = FunctionType.getSpecializedReturnType(functionType);
2782
- const specializedReturnType = declaredReturnType ? this.apply(declaredReturnType, recursionCount) : undefined;
2783
- let typesRequiredSpecialization = declaredReturnType !== specializedReturnType;
2784
-
2785
- const specializedParameters: SpecializedFunctionTypes = {
2786
- parameterTypes: [],
2787
- returnType: specializedReturnType,
2788
- };
2789
-
2790
- // Does this function end with *args: P.args, **args: P.kwargs? If so, we'll
2791
- // modify the function and replace these parameters with the signature captured
2792
- // by the ParamSpec.
2793
- if (functionType.details.parameters.length >= 2) {
2794
- const argsParam = functionType.details.parameters[functionType.details.parameters.length - 2];
2795
- const kwargsParam = functionType.details.parameters[functionType.details.parameters.length - 1];
2796
- const argsParamType = FunctionType.getEffectiveParameterType(
2797
- functionType,
2798
- functionType.details.parameters.length - 2
2799
- );
2800
- const kwargsParamType = FunctionType.getEffectiveParameterType(
2801
- functionType,
2802
- functionType.details.parameters.length - 1
2803
- );
2804
-
2805
- if (
2806
- argsParam.category === ParameterCategory.VarArgList &&
2807
- kwargsParam.category === ParameterCategory.VarArgDictionary &&
2808
- isParamSpec(argsParamType) &&
2809
- isParamSpec(kwargsParamType) &&
2810
- isTypeSame(argsParamType, kwargsParamType)
2811
- ) {
2812
- const paramSpecType = this.transformParamSpec(argsParamType);
2813
- if (paramSpecType) {
2814
- if (
2815
- paramSpecType.parameters.length > 0 ||
2816
- paramSpecType.paramSpec === undefined ||
2817
- !isTypeSame(argsParamType, paramSpecType.paramSpec)
2818
- ) {
2819
- functionType = FunctionType.cloneForParamSpecApplication(functionType, paramSpecType);
2820
- }
2821
- }
2822
- }
2823
- }
2824
-
2825
- let variadicParamIndex: number | undefined;
2826
- let variadicTypesToUnpack: TupleTypeArgument[] | undefined;
2827
- const specializedDefaultArgs: (Type | undefined)[] = [];
2828
-
2829
- for (let i = 0; i < functionType.details.parameters.length; i++) {
2830
- const paramType = FunctionType.getEffectiveParameterType(functionType, i);
2831
- const specializedType = this.apply(paramType, recursionCount);
2832
- specializedParameters.parameterTypes.push(specializedType);
2833
-
2834
- // Do we need to specialize the default argument type for this parameter?
2835
- let defaultArgType = FunctionType.getEffectiveParameterDefaultArgType(functionType, i);
2836
- if (defaultArgType) {
2837
- const specializedArgType = this.apply(defaultArgType, recursionCount);
2838
- if (specializedArgType !== defaultArgType) {
2839
- defaultArgType = specializedArgType;
2840
- typesRequiredSpecialization = true;
2841
- }
2842
- }
2843
- specializedDefaultArgs.push(defaultArgType);
2844
-
2845
- if (
2846
- variadicParamIndex === undefined &&
2847
- isVariadicTypeVar(paramType) &&
2848
- functionType.details.parameters[i].category === ParameterCategory.VarArgList
2849
- ) {
2850
- variadicParamIndex = i;
2851
-
2852
- if (isClassInstance(specializedType) && isTupleClass(specializedType) && specializedType.isUnpacked) {
2853
- variadicTypesToUnpack = specializedType.tupleTypeArguments;
2854
- }
2855
- }
2856
-
2857
- if (paramType !== specializedType) {
2858
- typesRequiredSpecialization = true;
2859
- }
2860
- }
2861
-
2862
- if (!typesRequiredSpecialization) {
2863
- return functionType;
2864
- }
2865
-
2866
- let specializedInferredReturnType: Type | undefined;
2867
- if (functionType.inferredReturnType) {
2868
- specializedInferredReturnType = this.apply(functionType.inferredReturnType, recursionCount);
2869
- }
2870
-
2871
- if (specializedDefaultArgs.some((t) => t !== undefined)) {
2872
- specializedParameters.parameterDefaultArgs = specializedDefaultArgs;
2873
- }
2874
-
2875
- // If there was no unpacked variadic type variable, we're done.
2876
- if (!variadicTypesToUnpack) {
2877
- return FunctionType.cloneForSpecialization(
2878
- functionType,
2879
- specializedParameters,
2880
- specializedInferredReturnType
2881
- );
2882
- }
2883
-
2884
- // Unpack the tuple and synthesize a new function in the process.
2885
- const newFunctionType = FunctionType.createSynthesizedInstance('');
2886
- let insertKeywordOnlySeparator = false;
2887
- let swallowPositionOnlySeparator = false;
2888
-
2889
- specializedParameters.parameterTypes.forEach((paramType, index) => {
2890
- if (index === variadicParamIndex) {
2891
- let sawUnboundedEntry = false;
2892
-
2893
- // Unpack the tuple into individual parameters.
2894
- variadicTypesToUnpack!.forEach((unpackedType) => {
2895
- FunctionType.addParameter(newFunctionType, {
2896
- category: unpackedType.isUnbounded ? ParameterCategory.VarArgList : ParameterCategory.Simple,
2897
- name: `__p${newFunctionType.details.parameters.length}`,
2898
- isNameSynthesized: true,
2899
- type: unpackedType.type,
2900
- hasDeclaredType: true,
2901
- });
2902
-
2903
- if (unpackedType.isUnbounded) {
2904
- sawUnboundedEntry = true;
2905
- }
2906
- });
2907
-
2908
- if (sawUnboundedEntry) {
2909
- swallowPositionOnlySeparator = true;
2910
- } else {
2911
- insertKeywordOnlySeparator = true;
2912
- }
2913
- } else {
2914
- const param = { ...functionType.details.parameters[index] };
2915
-
2916
- if (param.category === ParameterCategory.VarArgList && !param.name) {
2917
- insertKeywordOnlySeparator = false;
2918
- } else if (param.category === ParameterCategory.VarArgDictionary) {
2919
- insertKeywordOnlySeparator = false;
2920
- }
2921
-
2922
- // Insert a keyword-only separator parameter if we previously
2923
- // unpacked a variadic TypeVar.
2924
- if (param.category === ParameterCategory.Simple && param.name && insertKeywordOnlySeparator) {
2925
- FunctionType.addParameter(newFunctionType, {
2926
- category: ParameterCategory.VarArgList,
2927
- type: UnknownType.create(),
2928
- });
2929
- insertKeywordOnlySeparator = false;
2930
- }
2931
-
2932
- param.type = paramType;
2933
- if (param.name && param.isNameSynthesized) {
2934
- param.name = `__p${newFunctionType.details.parameters.length}`;
2935
- }
2936
-
2937
- if (param.category !== ParameterCategory.Simple || param.name || !swallowPositionOnlySeparator) {
2938
- FunctionType.addParameter(newFunctionType, param);
2939
- }
2940
- }
2941
- });
2942
-
2943
- newFunctionType.details.declaredReturnType = specializedParameters.returnType;
2944
-
2945
- return newFunctionType;
2946
- }
2947
- }
2948
-
2949
- // Specializes a (potentially generic) type by substituting
2950
- // type variables from a type var map.
2951
- class ApplySolvedTypeVarsTransformer extends TypeVarTransformer {
2952
- constructor(
2953
- private _typeVarContext: TypeVarContext,
2954
- private _unknownIfNotFound = false,
2955
- private _useNarrowBoundOnly = false,
2956
- private _eliminateUnsolvedInUnions = false,
2957
- private _typeClassType?: Type
2958
- ) {
2959
- super();
2960
- }
2961
-
2962
- override transformTypeVar(typeVar: TypeVarType) {
2963
- // If the type variable is unrelated to the scopes we're solving,
2964
- // don't transform that type variable.
2965
- if (typeVar.scopeId && this._typeVarContext.hasSolveForScope(typeVar.scopeId)) {
2966
- let replacement = this._typeVarContext.getTypeVarType(typeVar, this._useNarrowBoundOnly);
2967
-
2968
- // If there was no narrow bound but there is a wide bound that
2969
- // contains literals, we'll use the wide bound even if "useNarrowBoundOnly"
2970
- // is specified.
2971
- if (!replacement && this._useNarrowBoundOnly) {
2972
- const wideType = this._typeVarContext.getTypeVarType(typeVar);
2973
- if (wideType) {
2974
- if (containsLiteralType(wideType, /* includeTypeArgs */ true)) {
2975
- replacement = wideType;
2976
- }
2977
- }
2978
- }
2979
-
2980
- if (replacement) {
2981
- if (TypeBase.isInstantiable(typeVar)) {
2982
- if (
2983
- isAnyOrUnknown(replacement) &&
2984
- this._typeClassType &&
2985
- isInstantiableClass(this._typeClassType)
2986
- ) {
2987
- replacement = ClassType.cloneForSpecialization(
2988
- ClassType.cloneAsInstance(this._typeClassType),
2989
- [replacement],
2990
- /* isTypeArgumentExplicit */ true
2991
- );
2992
- } else {
2993
- replacement = convertToInstantiable(replacement);
2994
- }
2995
- }
2996
- return replacement;
2997
- }
2998
-
2999
- // If this typeVar is in scope for what we're solving but the type
3000
- // var map doesn't contain any entry for it, replace with Unknown.
3001
- if (this._unknownIfNotFound && !this._typeVarContext.hasSolveForScope(WildcardTypeVarScopeId)) {
3002
- return UnknownType.create();
3003
- }
3004
- }
3005
-
3006
- return typeVar;
3007
- }
3008
-
3009
- override transformUnionSubtype(preTransform: Type, postTransform: Type): Type | undefined {
3010
- // If a union contains unsolved TypeVars within scope, eliminate them
3011
- // unless this results in an empty union. This elimination is needed
3012
- // in cases where TypeVars can go unsolved due to unions in parameter
3013
- // annotations, like this:
3014
- // def test(x: Union[str, T]) -> Union[str, T]
3015
- if (this._eliminateUnsolvedInUnions) {
3016
- if (
3017
- isTypeVar(preTransform) &&
3018
- preTransform.scopeId !== undefined &&
3019
- this._typeVarContext.hasSolveForScope(preTransform.scopeId)
3020
- ) {
3021
- // If the TypeVar was not transformed, then it was unsolved,
3022
- // and we'll eliminate it.
3023
- if (preTransform === postTransform) {
3024
- return undefined;
3025
- }
3026
-
3027
- // If _unknownIfNotFound is true, the postTransform type will
3028
- // be Unknown, which we want to eliminate.
3029
- if (isUnknown(postTransform) && this._unknownIfNotFound) {
3030
- return undefined;
3031
- }
3032
- }
3033
- }
3034
-
3035
- return postTransform;
3036
- }
3037
-
3038
- override transformVariadicTypeVar(typeVar: TypeVarType) {
3039
- if (!typeVar.scopeId || !this._typeVarContext.hasSolveForScope(typeVar.scopeId)) {
3040
- return undefined;
3041
- }
3042
-
3043
- return this._typeVarContext.getVariadicTypeVar(typeVar);
3044
- }
3045
-
3046
- override transformParamSpec(paramSpec: TypeVarType) {
3047
- if (!paramSpec.scopeId || !this._typeVarContext.hasSolveForScope(paramSpec.scopeId)) {
3048
- return undefined;
3049
- }
3050
-
3051
- const transformedParamSpec = this._typeVarContext.getParamSpec(paramSpec);
3052
- if (transformedParamSpec) {
3053
- return transformedParamSpec;
3054
- }
3055
-
3056
- if (this._unknownIfNotFound && !this._typeVarContext.hasSolveForScope(WildcardTypeVarScopeId)) {
3057
- // Convert to the ParamSpec equivalent of "Unknown".
3058
- const paramSpecValue: ParamSpecValue = {
3059
- flags: FunctionTypeFlags.None,
3060
- parameters: FunctionType.getDefaultParameters(/* useUnknown */ true),
3061
- typeVarScopeId: undefined,
3062
- docString: undefined,
3063
- paramSpec: undefined,
3064
- };
3065
-
3066
- return paramSpecValue;
3067
- }
3068
-
3069
- return undefined;
3070
- }
3071
- }
3072
-
3073
- class ExpectedConstructorTypeTransformer extends TypeVarTransformer {
3074
- static synthesizedTypeVarIndexForExpectedType = 1;
3075
-
3076
- dummyScopeId = '__expected_type_scope_id';
3077
- dummyTypeVarPrefix = '__expected_type_';
3078
-
3079
- constructor(private _typeVarContext: TypeVarContext, private _liveTypeVarScopes: TypeVarScopeId[]) {
3080
- super();
3081
-
3082
- this._typeVarContext.addSolveForScope(this.dummyScopeId);
3083
- }
3084
-
3085
- private _isTypeVarLive(typeVar: TypeVarType) {
3086
- return this._liveTypeVarScopes.some((scopeId) => typeVar.scopeId === scopeId);
3087
- }
3088
-
3089
- private _createDummyTypeVar(prevTypeVar: TypeVarType) {
3090
- // If we previously synthesized this dummy type var, just return it.
3091
- if (prevTypeVar.details.isSynthesized && prevTypeVar.details.name.startsWith(this.dummyTypeVarPrefix)) {
3092
- return prevTypeVar;
3093
- }
3094
-
3095
- const isInstance = TypeBase.isInstance(prevTypeVar);
3096
- let newTypeVar = TypeVarType.createInstance(
3097
- `__expected_type_${ExpectedConstructorTypeTransformer.synthesizedTypeVarIndexForExpectedType}`
3098
- );
3099
- newTypeVar.details.isSynthesized = true;
3100
- newTypeVar.scopeId = this.dummyScopeId;
3101
- newTypeVar.nameWithScope = TypeVarType.makeNameWithScope(newTypeVar.details.name, this.dummyScopeId);
3102
- if (!isInstance) {
3103
- newTypeVar = convertToInstantiable(newTypeVar) as TypeVarType;
3104
- }
3105
-
3106
- // If the original TypeVar was bound or constrained, make the replacement as well.
3107
- newTypeVar.details.boundType = prevTypeVar.details.boundType;
3108
- newTypeVar.details.constraints = prevTypeVar.details.constraints;
3109
-
3110
- // Also copy the variance.
3111
- newTypeVar.details.variance = prevTypeVar.details.variance;
3112
-
3113
- ExpectedConstructorTypeTransformer.synthesizedTypeVarIndexForExpectedType++;
3114
- return newTypeVar;
3115
- }
3116
-
3117
- override transformTypeVar(typeVar: TypeVarType) {
3118
- // If the type variable is unrelated to the scopes we're solving,
3119
- // don't transform that type variable.
3120
- if (this._isTypeVarLive(typeVar)) {
3121
- return typeVar;
3122
- }
3123
-
3124
- return this._createDummyTypeVar(typeVar);
3125
- }
3126
- }