@zzzen/pyright-internal 1.1.255 → 1.2.0-dev.20220703

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 (1456) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1 -0
  3. package/dist/analyzer/aliasDeclarationUtils.js +2 -2
  4. package/dist/analyzer/analyzerFileInfo.d.ts +1 -1
  5. package/dist/analyzer/analyzerNodeInfo.d.ts +4 -1
  6. package/dist/analyzer/analyzerNodeInfo.js +12 -1
  7. package/dist/analyzer/analyzerNodeInfo.js.map +1 -1
  8. package/dist/analyzer/backgroundAnalysisProgram.d.ts +1 -0
  9. package/dist/analyzer/backgroundAnalysisProgram.js +3 -0
  10. package/dist/analyzer/backgroundAnalysisProgram.js.map +1 -1
  11. package/dist/analyzer/binder.d.ts +6 -1
  12. package/dist/analyzer/binder.js +142 -32
  13. package/dist/analyzer/binder.js.map +1 -1
  14. package/dist/analyzer/checker.d.ts +4 -1
  15. package/dist/analyzer/checker.js +144 -73
  16. package/dist/analyzer/checker.js.map +1 -1
  17. package/dist/analyzer/codeFlowUtils.js +33 -0
  18. package/dist/analyzer/codeFlowUtils.js.map +1 -1
  19. package/dist/analyzer/constraintSolver.js +6 -3
  20. package/dist/analyzer/constraintSolver.js.map +1 -1
  21. package/dist/analyzer/dataClasses.js +6 -4
  22. package/dist/analyzer/dataClasses.js.map +1 -1
  23. package/dist/analyzer/declaration.d.ts +18 -6
  24. package/dist/analyzer/declaration.js +25 -5
  25. package/dist/analyzer/declaration.js.map +1 -1
  26. package/dist/analyzer/declarationUtils.d.ts +1 -1
  27. package/dist/analyzer/declarationUtils.js +19 -16
  28. package/dist/analyzer/declarationUtils.js.map +1 -1
  29. package/dist/analyzer/importResult.js +7 -0
  30. package/dist/analyzer/importResult.js.map +1 -1
  31. package/dist/analyzer/importStatementUtils.js +10 -1
  32. package/dist/analyzer/importStatementUtils.js.map +1 -1
  33. package/dist/analyzer/namedTuples.js +1 -1
  34. package/dist/analyzer/namedTuples.js.map +1 -1
  35. package/dist/analyzer/packageTypeReport.js +10 -1
  36. package/dist/analyzer/packageTypeReport.js.map +1 -1
  37. package/dist/analyzer/packageTypeVerifier.js +6 -6
  38. package/dist/analyzer/parseTreeUtils.d.ts +3 -3
  39. package/dist/analyzer/parseTreeUtils.js +27 -13
  40. package/dist/analyzer/parseTreeUtils.js.map +1 -1
  41. package/dist/analyzer/parseTreeWalker.d.ts +4 -1
  42. package/dist/analyzer/parseTreeWalker.js +19 -1
  43. package/dist/analyzer/parseTreeWalker.js.map +1 -1
  44. package/dist/analyzer/program.d.ts +2 -1
  45. package/dist/analyzer/program.js +27 -23
  46. package/dist/analyzer/program.js.map +1 -1
  47. package/dist/analyzer/properties.js +2 -0
  48. package/dist/analyzer/properties.js.map +1 -1
  49. package/dist/analyzer/protocols.d.ts +0 -1
  50. package/dist/analyzer/protocols.js +4 -64
  51. package/dist/analyzer/protocols.js.map +1 -1
  52. package/dist/analyzer/scope.js +22 -1
  53. package/dist/analyzer/scope.js.map +1 -1
  54. package/dist/analyzer/service.d.ts +20 -8
  55. package/dist/analyzer/service.js +39 -19
  56. package/dist/analyzer/service.js.map +1 -1
  57. package/dist/analyzer/sourceFile.js +1 -1
  58. package/dist/analyzer/sourceFile.js.map +1 -1
  59. package/dist/analyzer/sourceFileInfoUtils.d.ts +2 -0
  60. package/dist/analyzer/sourceFileInfoUtils.js +15 -0
  61. package/dist/analyzer/sourceFileInfoUtils.js.map +1 -0
  62. package/dist/analyzer/symbol.d.ts +3 -1
  63. package/dist/analyzer/symbol.js +39 -1
  64. package/dist/analyzer/symbol.js.map +1 -1
  65. package/dist/analyzer/tracePrinter.js +8 -4
  66. package/dist/analyzer/tracePrinter.js.map +1 -1
  67. package/dist/analyzer/typeDocStringUtils.js +11 -3
  68. package/dist/analyzer/typeDocStringUtils.js.map +1 -1
  69. package/dist/analyzer/typeEvaluator.js +610 -208
  70. package/dist/analyzer/typeEvaluator.js.map +1 -1
  71. package/dist/analyzer/typeEvaluatorTypes.d.ts +2 -1
  72. package/dist/analyzer/typeEvaluatorTypes.js +65 -1
  73. package/dist/analyzer/typeEvaluatorTypes.js.map +1 -1
  74. package/dist/analyzer/typeEvaluatorWithTracker.js +2 -0
  75. package/dist/analyzer/typeEvaluatorWithTracker.js.map +1 -1
  76. package/dist/analyzer/typeGuards.d.ts +2 -0
  77. package/dist/analyzer/typeGuards.js +113 -69
  78. package/dist/analyzer/typeGuards.js.map +1 -1
  79. package/dist/analyzer/typePrinter.js +27 -2
  80. package/dist/analyzer/typePrinter.js.map +1 -1
  81. package/dist/analyzer/typeStubWriter.d.ts +4 -1
  82. package/dist/analyzer/typeStubWriter.js +36 -0
  83. package/dist/analyzer/typeStubWriter.js.map +1 -1
  84. package/dist/analyzer/typeUtils.js +129 -33
  85. package/dist/analyzer/typeUtils.js.map +1 -1
  86. package/dist/analyzer/typedDicts.js +2 -1
  87. package/dist/analyzer/typedDicts.js.map +1 -1
  88. package/dist/analyzer/types.d.ts +12 -4
  89. package/dist/analyzer/types.js +215 -6
  90. package/dist/analyzer/types.js.map +1 -1
  91. package/dist/backgroundAnalysisBase.d.ts +1 -1
  92. package/dist/commands/commands.js +9 -0
  93. package/dist/commands/commands.js.map +1 -1
  94. package/dist/common/commandLineOptions.js +8 -1
  95. package/dist/common/commandLineOptions.js.map +1 -1
  96. package/dist/common/core.js +7 -1
  97. package/dist/common/core.js.map +1 -1
  98. package/dist/common/diagnostic.js +9 -1
  99. package/dist/common/diagnostic.js.map +1 -1
  100. package/dist/common/host.js +7 -1
  101. package/dist/common/host.js.map +1 -1
  102. package/dist/common/pathUtils.d.ts +1 -0
  103. package/dist/common/pathUtils.js +34 -1
  104. package/dist/common/pathUtils.js.map +1 -1
  105. package/dist/common/stringUtils.d.ts +1 -0
  106. package/dist/common/stringUtils.js +8 -1
  107. package/dist/common/stringUtils.js.map +1 -1
  108. package/dist/languageServerBase.d.ts +10 -3
  109. package/dist/languageServerBase.js +40 -14
  110. package/dist/languageServerBase.js.map +1 -1
  111. package/dist/languageService/analyzerServiceExecutor.js +3 -0
  112. package/dist/languageService/analyzerServiceExecutor.js.map +1 -1
  113. package/dist/languageService/autoImporter.js +2 -1
  114. package/dist/languageService/autoImporter.js.map +1 -1
  115. package/dist/languageService/callHierarchyProvider.js +9 -9
  116. package/dist/languageService/completionProvider.d.ts +2 -2
  117. package/dist/languageService/completionProvider.js +22 -18
  118. package/dist/languageService/completionProvider.js.map +1 -1
  119. package/dist/languageService/definitionProvider.js +3 -3
  120. package/dist/languageService/documentSymbolCollector.js +1 -1
  121. package/dist/languageService/documentSymbolProvider.js +10 -7
  122. package/dist/languageService/documentSymbolProvider.js.map +1 -1
  123. package/dist/languageService/hoverProvider.js +19 -5
  124. package/dist/languageService/hoverProvider.js.map +1 -1
  125. package/dist/languageService/referencesProvider.js +8 -5
  126. package/dist/languageService/referencesProvider.js.map +1 -1
  127. package/dist/languageService/tooltipUtils.js +1 -1
  128. package/dist/localization/localize.d.ts +27 -0
  129. package/dist/localization/localize.js +16 -0
  130. package/dist/localization/localize.js.map +1 -1
  131. package/dist/localization/package.nls.en-us.json +18 -2
  132. package/dist/parser/parseNodes.d.ts +44 -5
  133. package/dist/parser/parseNodes.js +191 -4
  134. package/dist/parser/parseNodes.js.map +1 -1
  135. package/dist/parser/parser.d.ts +3 -1
  136. package/dist/parser/parser.js +155 -24
  137. package/dist/parser/parser.js.map +1 -1
  138. package/dist/parser/stringTokenUtils.js +8 -1
  139. package/dist/parser/stringTokenUtils.js.map +1 -1
  140. package/dist/parser/tokenizer.js +4 -3
  141. package/dist/parser/tokenizer.js.map +1 -1
  142. package/dist/parser/tokenizerTypes.d.ts +5 -3
  143. package/dist/parser/tokenizerTypes.js +157 -1
  144. package/dist/parser/tokenizerTypes.js.map +1 -1
  145. package/dist/pyright.js +6 -1
  146. package/dist/pyright.js.map +1 -1
  147. package/dist/tests/chainedSourceFiles.test.js +12 -9
  148. package/dist/tests/chainedSourceFiles.test.js.map +1 -1
  149. package/dist/tests/checker.test.js +4 -0
  150. package/dist/tests/checker.test.js.map +1 -1
  151. package/dist/tests/config.test.js +14 -13
  152. package/dist/tests/config.test.js.map +1 -1
  153. package/dist/tests/debug.test.js +6 -0
  154. package/dist/tests/debug.test.js.map +1 -1
  155. package/dist/tests/fourslash/completions.autoimport.lib.alias.fourslash.d.ts +1 -0
  156. package/dist/tests/fourslash/completions.autoimport.lib.alias.fourslash.js +53 -0
  157. package/dist/tests/fourslash/completions.autoimport.lib.alias.fourslash.js.map +1 -0
  158. package/dist/tests/fourslash/fourslash.d.ts +16 -0
  159. package/dist/tests/fourslash/hover.class.docString.fourslash.d.ts +1 -0
  160. package/dist/tests/fourslash/hover.class.docString.fourslash.js +24 -0
  161. package/dist/tests/fourslash/hover.class.docString.fourslash.js.map +1 -0
  162. package/dist/tests/harness/fourslash/fourSlashParser.js +6 -0
  163. package/dist/tests/harness/fourslash/fourSlashParser.js.map +1 -1
  164. package/dist/tests/harness/fourslash/fourSlashTypes.js +19 -1
  165. package/dist/tests/harness/fourslash/fourSlashTypes.js.map +1 -1
  166. package/dist/tests/harness/fourslash/testLanguageService.js +9 -1
  167. package/dist/tests/harness/fourslash/testLanguageService.js.map +1 -1
  168. package/dist/tests/harness/fourslash/testState.Consts.d.ts +1 -0
  169. package/dist/tests/harness/fourslash/testState.Consts.js +1 -0
  170. package/dist/tests/harness/fourslash/testState.Consts.js.map +1 -1
  171. package/dist/tests/harness/fourslash/testState.d.ts +4 -3
  172. package/dist/tests/harness/fourslash/testState.js +27 -11
  173. package/dist/tests/harness/fourslash/testState.js.map +1 -1
  174. package/dist/tests/harness/vfs/pathValidation.js +25 -1
  175. package/dist/tests/harness/vfs/pathValidation.js.map +1 -1
  176. package/dist/tests/pathUtils.test.js +17 -0
  177. package/dist/tests/pathUtils.test.js.map +1 -1
  178. package/dist/tests/testUtils.js +1 -1
  179. package/dist/tests/testUtils.js.map +1 -1
  180. package/dist/tests/typeEvaluator1.test.js +9 -1
  181. package/dist/tests/typeEvaluator1.test.js.map +1 -1
  182. package/dist/tests/typeEvaluator2.test.js +9 -1
  183. package/dist/tests/typeEvaluator2.test.js.map +1 -1
  184. package/dist/tests/typeEvaluator3.test.js +4 -0
  185. package/dist/tests/typeEvaluator3.test.js.map +1 -1
  186. package/dist/tests/typeEvaluator5.test.d.ts +1 -0
  187. package/dist/tests/typeEvaluator5.test.js +112 -0
  188. package/dist/tests/typeEvaluator5.test.js.map +1 -0
  189. package/dist/workspaceMap.d.ts +2 -1
  190. package/dist/workspaceMap.js +25 -3
  191. package/dist/workspaceMap.js.map +1 -1
  192. package/package.json +45 -45
  193. package/src/analyzer/aliasDeclarationUtils.ts +0 -169
  194. package/src/analyzer/analysis.ts +0 -92
  195. package/src/analyzer/analyzerFileInfo.ts +0 -56
  196. package/src/analyzer/analyzerNodeInfo.ts +0 -198
  197. package/src/analyzer/backgroundAnalysisProgram.ts +0 -311
  198. package/src/analyzer/binder.ts +0 -4081
  199. package/src/analyzer/checker.ts +0 -5507
  200. package/src/analyzer/circularDependency.ts +0 -52
  201. package/src/analyzer/codeFlowEngine.ts +0 -1548
  202. package/src/analyzer/codeFlowTypes.ts +0 -266
  203. package/src/analyzer/codeFlowUtils.ts +0 -436
  204. package/src/analyzer/commentUtils.ts +0 -174
  205. package/src/analyzer/constraintSolver.ts +0 -926
  206. package/src/analyzer/constructorTransform.ts +0 -317
  207. package/src/analyzer/dataClasses.ts +0 -999
  208. package/src/analyzer/declaration.ts +0 -252
  209. package/src/analyzer/declarationUtils.ts +0 -238
  210. package/src/analyzer/docStringConversion.ts +0 -850
  211. package/src/analyzer/docStringUtils.ts +0 -112
  212. package/src/analyzer/functionTransform.ts +0 -137
  213. package/src/analyzer/importResolver.ts +0 -2308
  214. package/src/analyzer/importResult.ts +0 -98
  215. package/src/analyzer/importStatementUtils.ts +0 -834
  216. package/src/analyzer/namedTuples.ts +0 -422
  217. package/src/analyzer/packageTypeReport.ts +0 -108
  218. package/src/analyzer/packageTypeVerifier.ts +0 -1466
  219. package/src/analyzer/parentDirectoryCache.ts +0 -88
  220. package/src/analyzer/parseTreeCleaner.ts +0 -35
  221. package/src/analyzer/parseTreeUtils.ts +0 -2165
  222. package/src/analyzer/parseTreeWalker.ts +0 -663
  223. package/src/analyzer/patternMatching.ts +0 -1356
  224. package/src/analyzer/program.ts +0 -2778
  225. package/src/analyzer/properties.ts +0 -534
  226. package/src/analyzer/protocols.ts +0 -660
  227. package/src/analyzer/pyTypedUtils.ts +0 -52
  228. package/src/analyzer/pythonPathUtils.ts +0 -201
  229. package/src/analyzer/scope.ts +0 -202
  230. package/src/analyzer/scopeUtils.ts +0 -81
  231. package/src/analyzer/service.ts +0 -1679
  232. package/src/analyzer/sourceFile.ts +0 -1401
  233. package/src/analyzer/sourceMapper.ts +0 -717
  234. package/src/analyzer/staticExpressions.ts +0 -308
  235. package/src/analyzer/symbol.ts +0 -249
  236. package/src/analyzer/symbolNameUtils.ts +0 -50
  237. package/src/analyzer/symbolUtils.ts +0 -49
  238. package/src/analyzer/testWalker.ts +0 -101
  239. package/src/analyzer/tracePrinter.ts +0 -264
  240. package/src/analyzer/typeCache.ts +0 -181
  241. package/src/analyzer/typeDocStringUtils.ts +0 -371
  242. package/src/analyzer/typeEvaluator.ts +0 -23395
  243. package/src/analyzer/typeEvaluatorTypes.ts +0 -452
  244. package/src/analyzer/typeEvaluatorWithTracker.ts +0 -161
  245. package/src/analyzer/typeGuards.ts +0 -1828
  246. package/src/analyzer/typePrinter.ts +0 -807
  247. package/src/analyzer/typeStubWriter.ts +0 -727
  248. package/src/analyzer/typeUtils.ts +0 -3126
  249. package/src/analyzer/typeVarContext.ts +0 -330
  250. package/src/analyzer/typedDicts.ts +0 -950
  251. package/src/analyzer/types.ts +0 -2857
  252. package/src/backgroundAnalysis.ts +0 -49
  253. package/src/backgroundAnalysisBase.ts +0 -606
  254. package/src/backgroundThreadBase.ts +0 -143
  255. package/src/commands/commandController.ts +0 -62
  256. package/src/commands/commandResult.ts +0 -21
  257. package/src/commands/commands.ts +0 -16
  258. package/src/commands/createTypeStub.ts +0 -56
  259. package/src/commands/quickActionCommand.ts +0 -40
  260. package/src/commands/restartServer.ts +0 -20
  261. package/src/common/cancellationUtils.ts +0 -71
  262. package/src/common/chokidarFileWatcherProvider.ts +0 -74
  263. package/src/common/collectionUtils.ts +0 -379
  264. package/src/common/commandLineOptions.ts +0 -132
  265. package/src/common/configOptions.ts +0 -1291
  266. package/src/common/console.ts +0 -201
  267. package/src/common/core.ts +0 -152
  268. package/src/common/crypto.ts +0 -60
  269. package/src/common/debug.ts +0 -144
  270. package/src/common/deferred.ts +0 -78
  271. package/src/common/diagnostic.ts +0 -191
  272. package/src/common/diagnosticRules.ts +0 -80
  273. package/src/common/diagnosticSink.ts +0 -150
  274. package/src/common/editAction.ts +0 -46
  275. package/src/common/extensibility.ts +0 -35
  276. package/src/common/extensions.ts +0 -21
  277. package/src/common/fileBasedCancellationUtils.ts +0 -274
  278. package/src/common/fileSystem.ts +0 -152
  279. package/src/common/fullAccessHost.ts +0 -203
  280. package/src/common/host.ts +0 -49
  281. package/src/common/logTracker.ts +0 -157
  282. package/src/common/lspUtils.ts +0 -18
  283. package/src/common/memUtils.ts +0 -36
  284. package/src/common/pathConsts.ts +0 -16
  285. package/src/common/pathUtils.ts +0 -987
  286. package/src/common/positionUtils.ts +0 -78
  287. package/src/common/progressReporter.ts +0 -53
  288. package/src/common/pythonVersion.ts +0 -74
  289. package/src/common/realFileSystem.ts +0 -433
  290. package/src/common/stringUtils.ts +0 -161
  291. package/src/common/textEditUtils.ts +0 -31
  292. package/src/common/textRange.ts +0 -225
  293. package/src/common/textRangeCollection.ts +0 -122
  294. package/src/common/timing.ts +0 -105
  295. package/src/common/uriParser.ts +0 -26
  296. package/src/common/workspaceEditUtils.ts +0 -100
  297. package/src/languageServerBase.ts +0 -1556
  298. package/src/languageService/analyzerServiceExecutor.ts +0 -144
  299. package/src/languageService/autoImporter.ts +0 -926
  300. package/src/languageService/callHierarchyProvider.ts +0 -476
  301. package/src/languageService/codeActionProvider.ts +0 -85
  302. package/src/languageService/completionProvider.ts +0 -3103
  303. package/src/languageService/definitionProvider.ts +0 -235
  304. package/src/languageService/documentHighlightProvider.ts +0 -61
  305. package/src/languageService/documentSymbolCollector.ts +0 -466
  306. package/src/languageService/documentSymbolProvider.ts +0 -466
  307. package/src/languageService/hoverProvider.ts +0 -499
  308. package/src/languageService/importAdder.ts +0 -437
  309. package/src/languageService/importSorter.ts +0 -196
  310. package/src/languageService/indentationUtils.ts +0 -813
  311. package/src/languageService/quickActions.ts +0 -113
  312. package/src/languageService/referencesProvider.ts +0 -316
  313. package/src/languageService/renameModuleProvider.ts +0 -1400
  314. package/src/languageService/signatureHelpProvider.ts +0 -227
  315. package/src/languageService/tooltipUtils.ts +0 -147
  316. package/src/localization/localize.ts +0 -1272
  317. package/src/localization/package.nls.de.json +0 -3
  318. package/src/localization/package.nls.en-us.json +0 -636
  319. package/src/localization/package.nls.es.json +0 -3
  320. package/src/localization/package.nls.fr.json +0 -3
  321. package/src/localization/package.nls.ja.json +0 -3
  322. package/src/localization/package.nls.ru.json +0 -3
  323. package/src/localization/package.nls.zh-cn.json +0 -3
  324. package/src/localization/package.nls.zh-tw.json +0 -3
  325. package/src/nodeMain.ts +0 -21
  326. package/src/nodeServer.ts +0 -30
  327. package/src/parser/characterStream.ts +0 -145
  328. package/src/parser/characters.ts +0 -285
  329. package/src/parser/parseNodes.ts +0 -2338
  330. package/src/parser/parser.ts +0 -4859
  331. package/src/parser/stringTokenUtils.ts +0 -564
  332. package/src/parser/tokenizer.ts +0 -1379
  333. package/src/parser/tokenizerTypes.ts +0 -420
  334. package/src/parser/unicode.ts +0 -2917
  335. package/src/pyright.ts +0 -824
  336. package/src/pyrightFileSystem.ts +0 -237
  337. package/src/readonlyAugmentedFileSystem.ts +0 -204
  338. package/src/server.ts +0 -298
  339. package/src/tests/chainedSourceFiles.test.ts +0 -183
  340. package/src/tests/checker.test.ts +0 -445
  341. package/src/tests/collectionUtils.test.ts +0 -178
  342. package/src/tests/common.test.ts +0 -117
  343. package/src/tests/config.test.ts +0 -291
  344. package/src/tests/debug.test.ts +0 -120
  345. package/src/tests/deferred.test.ts +0 -54
  346. package/src/tests/diagnosticOverrides.test.ts +0 -104
  347. package/src/tests/docStringConversion.test.ts +0 -823
  348. package/src/tests/docStringUtils.test.ts +0 -57
  349. package/src/tests/documentSymbolCollector.test.ts +0 -735
  350. package/src/tests/filesystem.test.ts +0 -215
  351. package/src/tests/fourSlashParser.test.ts +0 -330
  352. package/src/tests/fourSlashRunner.test.ts +0 -36
  353. package/src/tests/fourslash/completions.autoimport.Lib.Found.Type.fourslash.ts +0 -33
  354. package/src/tests/fourslash/completions.autoimport.Lib.Found.duplication.fourslash.ts +0 -47
  355. package/src/tests/fourslash/completions.autoimport.Lib.NotFound.fourslash.ts +0 -14
  356. package/src/tests/fourslash/completions.autoimport.disabled.fourslash.ts +0 -25
  357. package/src/tests/fourslash/completions.autoimport.duplicates.fourslash.ts +0 -36
  358. package/src/tests/fourslash/completions.autoimport.fourslash.ts +0 -29
  359. package/src/tests/fourslash/completions.autoimport.fromImport.fourslash.ts +0 -130
  360. package/src/tests/fourslash/completions.autoimport.plainText.fourslash.ts +0 -29
  361. package/src/tests/fourslash/completions.autoimport.shadow.fourslash.ts +0 -48
  362. package/src/tests/fourslash/completions.autoimport.submodule.fourslash.ts +0 -31
  363. package/src/tests/fourslash/completions.autoimport.topLevel.fourslash.ts +0 -57
  364. package/src/tests/fourslash/completions.builtinDocstrings.fourslash.ts +0 -117
  365. package/src/tests/fourslash/completions.builtinOverride.fourslash.ts +0 -22
  366. package/src/tests/fourslash/completions.call.stringLiteral.fourslash.ts +0 -55
  367. package/src/tests/fourslash/completions.call.typedDict.fourslash.ts +0 -247
  368. package/src/tests/fourslash/completions.call.typedDict.list.fourslash.ts +0 -163
  369. package/src/tests/fourslash/completions.call.typedDict.states.fourslash.ts +0 -135
  370. package/src/tests/fourslash/completions.classVariable.fourslash.ts +0 -37
  371. package/src/tests/fourslash/completions.comment.fourslash.ts +0 -28
  372. package/src/tests/fourslash/completions.declNames.class.fourslash.ts +0 -35
  373. package/src/tests/fourslash/completions.declNames.exception.fourslash.ts +0 -18
  374. package/src/tests/fourslash/completions.declNames.for.fourslash.ts +0 -30
  375. package/src/tests/fourslash/completions.declNames.importAlias.fourslash.ts +0 -15
  376. package/src/tests/fourslash/completions.declNames.lambda.fourslash.ts +0 -45
  377. package/src/tests/fourslash/completions.declNames.method.fourslash.ts +0 -71
  378. package/src/tests/fourslash/completions.declNames.overload.fourslash.ts +0 -156
  379. package/src/tests/fourslash/completions.declNames.topLevelOverload.fourslash.ts +0 -141
  380. package/src/tests/fourslash/completions.dictionary.keys.complex.fourslash.ts +0 -76
  381. package/src/tests/fourslash/completions.dictionary.keys.expression.fourslash.ts +0 -63
  382. package/src/tests/fourslash/completions.dictionary.keys.literalTypes.fourslash.ts +0 -161
  383. package/src/tests/fourslash/completions.dictionary.keys.simple.fourslash.ts +0 -151
  384. package/src/tests/fourslash/completions.dictionary.keys.stringLiterals.fourslash.ts +0 -116
  385. package/src/tests/fourslash/completions.dictionary.keys.symbols.fourslash.ts +0 -53
  386. package/src/tests/fourslash/completions.enums.members.fourslash.ts +0 -44
  387. package/src/tests/fourslash/completions.excluded.fourslash.ts +0 -12
  388. package/src/tests/fourslash/completions.fourslash.ts +0 -51
  389. package/src/tests/fourslash/completions.fstring.fourslash.ts +0 -33
  390. package/src/tests/fourslash/completions.fstring.stringLiteral.fourslash.ts +0 -96
  391. package/src/tests/fourslash/completions.fuzzyMatching.fourslash.ts +0 -30
  392. package/src/tests/fourslash/completions.importDunderNames.fourslash.ts +0 -31
  393. package/src/tests/fourslash/completions.importSubmodule.fourslash.ts +0 -26
  394. package/src/tests/fourslash/completions.importsDuplicates.fourslash.ts +0 -23
  395. package/src/tests/fourslash/completions.inList.fourslash.ts +0 -33
  396. package/src/tests/fourslash/completions.included.fourslash.ts +0 -12
  397. package/src/tests/fourslash/completions.indexer.keys.getitem.fourslash.ts +0 -57
  398. package/src/tests/fourslash/completions.inherited.function.docFromStub.fourslash.ts +0 -28
  399. package/src/tests/fourslash/completions.inherited.overload.docFromScrWithStub.fourslash.ts +0 -52
  400. package/src/tests/fourslash/completions.inherited.overload.docFromStub.fourslash.ts +0 -53
  401. package/src/tests/fourslash/completions.inherited.property.docFromSrc.fourslash.ts +0 -104
  402. package/src/tests/fourslash/completions.inherited.property.docFromStub.fourslash.ts +0 -108
  403. package/src/tests/fourslash/completions.keywords.pythonVersion.fourslash.ts +0 -72
  404. package/src/tests/fourslash/completions.libCodeAndStub.fourslash.ts +0 -79
  405. package/src/tests/fourslash/completions.libCodeNoStub.fourslash.ts +0 -69
  406. package/src/tests/fourslash/completions.libStub.fourslash.ts +0 -69
  407. package/src/tests/fourslash/completions.literals.fourslash.ts +0 -33
  408. package/src/tests/fourslash/completions.localCode.fourslash.ts +0 -74
  409. package/src/tests/fourslash/completions.moduleContext.UnknownMemberOnInstance.fourslash.ts +0 -17
  410. package/src/tests/fourslash/completions.moduleContext.UnknownStaticFunctionOnClass.fourslash.ts +0 -57
  411. package/src/tests/fourslash/completions.moduleContext.libCodeNoStub.fourslash.ts +0 -30
  412. package/src/tests/fourslash/completions.overloads.fourslash.ts +0 -40
  413. package/src/tests/fourslash/completions.override.default.fourslash.ts +0 -47
  414. package/src/tests/fourslash/completions.override.default.importStub.ts +0 -50
  415. package/src/tests/fourslash/completions.override.default.imported.fourslash.ts +0 -61
  416. package/src/tests/fourslash/completions.override.default.stub.fourslash.ts +0 -47
  417. package/src/tests/fourslash/completions.override.fourslash.ts +0 -47
  418. package/src/tests/fourslash/completions.override.property.fourslash.ts +0 -31
  419. package/src/tests/fourslash/completions.override.property.stub.fourslash.ts +0 -31
  420. package/src/tests/fourslash/completions.override.staticAndClassmethod.fourslash.ts +0 -64
  421. package/src/tests/fourslash/completions.override.stub.fourslash.ts +0 -47
  422. package/src/tests/fourslash/completions.override2.fourslash.ts +0 -71
  423. package/src/tests/fourslash/completions.parameters.fourslash.ts +0 -23
  424. package/src/tests/fourslash/completions.params.fourslash.ts +0 -24
  425. package/src/tests/fourslash/completions.parentFolder.fourslash.ts +0 -17
  426. package/src/tests/fourslash/completions.parentFolders.fourslash.ts +0 -77
  427. package/src/tests/fourslash/completions.plainText.fourslash.ts +0 -34
  428. package/src/tests/fourslash/completions.private.fourslash.ts +0 -64
  429. package/src/tests/fourslash/completions.property.fourslash.ts +0 -28
  430. package/src/tests/fourslash/completions.propertyDocStrings.fourslash.ts +0 -64
  431. package/src/tests/fourslash/completions.self.fourslash.ts +0 -43
  432. package/src/tests/fourslash/completions.stringLiteral.escape.fourslash.ts +0 -71
  433. package/src/tests/fourslash/completions.stringLiteral.fourslash.ts +0 -79
  434. package/src/tests/fourslash/completions.typeAlias.fourslash.ts +0 -29
  435. package/src/tests/fourslash/completions.typeshed.fourslash.ts +0 -9
  436. package/src/tests/fourslash/completions.vardecls.fourslash.ts +0 -40
  437. package/src/tests/fourslash/completions.variableDocStrings.fourslash.ts +0 -69
  438. package/src/tests/fourslash/completions.wildcardimports.fourslash.ts +0 -116
  439. package/src/tests/fourslash/completions.with.fourslash.ts +0 -26
  440. package/src/tests/fourslash/diagnostics.missingModuleSource.fourslash.ts +0 -69
  441. package/src/tests/fourslash/findDefinitions.builtinClass.fourslash.ts +0 -29
  442. package/src/tests/fourslash/findDefinitions.classes.fourslash.ts +0 -101
  443. package/src/tests/fourslash/findDefinitions.definitionFilter.preferSource.fourslash.ts +0 -29
  444. package/src/tests/fourslash/findDefinitions.definitionFilter.preferSource.onlyStubs.ts +0 -24
  445. package/src/tests/fourslash/findDefinitions.definitionFilter.preferStub.fourslash.ts +0 -29
  446. package/src/tests/fourslash/findDefinitions.definitionFilter.preferStub.onlySource.fourslash.ts +0 -25
  447. package/src/tests/fourslash/findDefinitions.fields.fourslash.ts +0 -131
  448. package/src/tests/fourslash/findDefinitions.functions.fourslash.ts +0 -87
  449. package/src/tests/fourslash/findDefinitions.methods.fourslash.ts +0 -162
  450. package/src/tests/fourslash/findDefinitions.modules.fourslash.ts +0 -50
  451. package/src/tests/fourslash/findDefinitions.namespaceImport.fourslash.ts +0 -40
  452. package/src/tests/fourslash/findDefinitions.overloads.fourslash.ts +0 -223
  453. package/src/tests/fourslash/findDefinitions.parameters.fourslash.ts +0 -162
  454. package/src/tests/fourslash/findDefinitions.sourceAndStub.function.fourslash.ts +0 -26
  455. package/src/tests/fourslash/findDefinitions.sourceAndStub.innerClass.fourslash.ts +0 -32
  456. package/src/tests/fourslash/findDefinitions.sourceAndStub.innerClassMethod.fourslash.ts +0 -33
  457. package/src/tests/fourslash/findDefinitions.sourceAndStub.outerClass.fourslash.ts +0 -28
  458. package/src/tests/fourslash/findDefinitions.sourceAndStub.outerClassMethod.fourslash.ts +0 -29
  459. package/src/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadOnly.fourslash.ts +0 -31
  460. package/src/tests/fourslash/findDefinitions.sourceAndStub.outerClassPropertyReadWrite.fourslash.ts +0 -36
  461. package/src/tests/fourslash/findDefinitions.sourceOnly.class.fourslash.ts +0 -29
  462. package/src/tests/fourslash/findDefinitions.sourceOnly.function1.fourslash.ts +0 -28
  463. package/src/tests/fourslash/findDefinitions.sourceOnly.function2.fourslash.ts +0 -28
  464. package/src/tests/fourslash/findDefinitions.sourceOnly.relativeImport1.fourslash.ts +0 -22
  465. package/src/tests/fourslash/findDefinitions.sourceOnly.relativeImport2.fourslash.ts +0 -22
  466. package/src/tests/fourslash/findDefinitions.stubOnly.fourslash.ts +0 -61
  467. package/src/tests/fourslash/findDefinitions.stubPackages.fourslash.ts +0 -71
  468. package/src/tests/fourslash/findDefinitions.typedDict.keys.fourslash.ts +0 -99
  469. package/src/tests/fourslash/findDefinitions.variables.fourslash.ts +0 -88
  470. package/src/tests/fourslash/findDefinitions.wildcardimports.fourslash.ts +0 -117
  471. package/src/tests/fourslash/findTypeDefinitions.builtinClass.fourslash.ts +0 -26
  472. package/src/tests/fourslash/findTypeDefinitions.classes.fourslash.ts +0 -72
  473. package/src/tests/fourslash/findTypeDefinitions.unions.fourslash.ts +0 -26
  474. package/src/tests/fourslash/findallreferences.classPropertyReadWrite.ts +0 -39
  475. package/src/tests/fourslash/findallreferences.fourslash.ts +0 -34
  476. package/src/tests/fourslash/findallreferences.importalias.fourslash.ts +0 -34
  477. package/src/tests/fourslash/findallreferences.invokedFromLibrary.fourslash.ts +0 -52
  478. package/src/tests/fourslash/findallreferences.module.nested.fourslash.ts +0 -67
  479. package/src/tests/fourslash/findallreferences.modules.duplicated.fourslash.ts +0 -59
  480. package/src/tests/fourslash/findallreferences.modules.fourslash.ts +0 -46
  481. package/src/tests/fourslash/findallreferences.modules.shadow.fourslash.ts +0 -95
  482. package/src/tests/fourslash/findallreferences.openFiles.fourslash.ts +0 -37
  483. package/src/tests/fourslash/findallreferences.parameter.fourslash.ts +0 -24
  484. package/src/tests/fourslash/findallreferences.sourceAndStub.class.fourslash.ts +0 -33
  485. package/src/tests/fourslash/findallreferences.sourceAndStub.classMethod.fourslash.ts +0 -37
  486. package/src/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadOnly.fourslash.ts +0 -40
  487. package/src/tests/fourslash/findallreferences.sourceAndStub.classPropertyReadWrite.fourslash.skip.ts +0 -48
  488. package/src/tests/fourslash/findallreferences.sourceAndStub.function.fourslash.ts +0 -35
  489. package/src/tests/fourslash/findallreferences.variable.fourslash.ts +0 -24
  490. package/src/tests/fourslash/fourslash.ts +0 -411
  491. package/src/tests/fourslash/highlightreferences.attributes.fourslash.ts +0 -31
  492. package/src/tests/fourslash/hover.builtinDocstrings.fourslash.ts +0 -64
  493. package/src/tests/fourslash/hover.classNoInit.fourslash.ts +0 -14
  494. package/src/tests/fourslash/hover.docFromScr.stringFormat.fourslash.ts +0 -52
  495. package/src/tests/fourslash/hover.docFromSrc.fourslash.ts +0 -83
  496. package/src/tests/fourslash/hover.docFromSrc.pkg-vs-module1.fourslash.ts +0 -26
  497. package/src/tests/fourslash/hover.docFromSrc.pkg-vs-module2.fourslash.ts +0 -26
  498. package/src/tests/fourslash/hover.docFromSrc.relativeImport1.fourslash.ts +0 -23
  499. package/src/tests/fourslash/hover.docFromSrc.relativeImport2.fourslash.ts +0 -22
  500. package/src/tests/fourslash/hover.docFromSrc.relativeImport3.fourslash.ts +0 -46
  501. package/src/tests/fourslash/hover.docFromSrc.stubs-package.fourslash.ts +0 -29
  502. package/src/tests/fourslash/hover.docFromSrc.typeshed.fourslash.ts +0 -20
  503. package/src/tests/fourslash/hover.docstring.links.fourslash.ts +0 -12
  504. package/src/tests/fourslash/hover.docstring.overloads.fourslash.ts +0 -41
  505. package/src/tests/fourslash/hover.docstring.split.fourslash.ts +0 -24
  506. package/src/tests/fourslash/hover.fourslash.ts +0 -20
  507. package/src/tests/fourslash/hover.import.django.view.fourslash.ts +0 -27
  508. package/src/tests/fourslash/hover.import.fourslash.ts +0 -11
  509. package/src/tests/fourslash/hover.inherited.docFromSrc.fourslash.ts +0 -63
  510. package/src/tests/fourslash/hover.inherited.docFromSrcWithStub.fourslash.ts +0 -54
  511. package/src/tests/fourslash/hover.inherited.docFromStub.fourslash.ts +0 -42
  512. package/src/tests/fourslash/hover.inherited.overload.docFromSrcWithStub.fourslash.ts +0 -46
  513. package/src/tests/fourslash/hover.inherited.overload.docFromStub.fourslash.ts +0 -47
  514. package/src/tests/fourslash/hover.inherited.property.docFromSrcWithStub.fourslash.ts +0 -87
  515. package/src/tests/fourslash/hover.inherited.property.docFromStub.fourslash.ts +0 -91
  516. package/src/tests/fourslash/hover.init.fourslash.ts +0 -39
  517. package/src/tests/fourslash/hover.libCodeAndStub.fourslash.ts +0 -52
  518. package/src/tests/fourslash/hover.libCodeNoStub.fourslash.ts +0 -41
  519. package/src/tests/fourslash/hover.libStub.fourslash.ts +0 -41
  520. package/src/tests/fourslash/hover.optionalAliasParameter.fourslash.ts +0 -14
  521. package/src/tests/fourslash/hover.plainText.fourslash.ts +0 -21
  522. package/src/tests/fourslash/hover.typedDict.key.fourslash.ts +0 -51
  523. package/src/tests/fourslash/hover.variable.docString.fourslash.ts +0 -41
  524. package/src/tests/fourslash/hover.wildcardimports.fourslash.ts +0 -80
  525. package/src/tests/fourslash/import.publicSymbols.fourslash.ts +0 -65
  526. package/src/tests/fourslash/import.pytyped.dunderAll.fourslash.ts +0 -77
  527. package/src/tests/fourslash/import.pytyped.privateSymbols.fourslash.ts +0 -65
  528. package/src/tests/fourslash/import.pytyped.typeCheckingBasic.fourslash.ts +0 -38
  529. package/src/tests/fourslash/import.pytyped.typeCheckingOff.fourslash.ts +0 -38
  530. package/src/tests/fourslash/import.wildcard.fourslash.ts +0 -27
  531. package/src/tests/fourslash/importnotresolved.fourslash.ts +0 -13
  532. package/src/tests/fourslash/missingModuleSource.disablingInStrictMode.fourslash.ts +0 -20
  533. package/src/tests/fourslash/missingModuleSource.fourslash.ts +0 -14
  534. package/src/tests/fourslash/missingTypeStub.codeAction.fourslash.ts +0 -33
  535. package/src/tests/fourslash/missingTypeStub.command.multipart.fourslash.ts +0 -48
  536. package/src/tests/fourslash/missingTypeStub.command.singlefile.fourslash.ts +0 -38
  537. package/src/tests/fourslash/missingTypeStub.command.singlepart.fourslash.ts +0 -38
  538. package/src/tests/fourslash/missingTypeStub.fourslash.ts +0 -20
  539. package/src/tests/fourslash/missingTypeStub.invokeCodeAction.fourslash.ts +0 -36
  540. package/src/tests/fourslash/noerrors.fourslash.ts +0 -9
  541. package/src/tests/fourslash/orderImports1.command.fourslash.ts +0 -20
  542. package/src/tests/fourslash/orderImports2.command.fourslash.ts +0 -24
  543. package/src/tests/fourslash/rename.externallyHidden.fourslash.ts +0 -24
  544. package/src/tests/fourslash/rename.externallyHidden.params.fourslash.ts +0 -24
  545. package/src/tests/fourslash/rename.fourslash.ts +0 -29
  546. package/src/tests/fourslash/rename.library.fourslash.ts +0 -29
  547. package/src/tests/fourslash/rename.library.sourceAndStub.fourslash.ts +0 -33
  548. package/src/tests/fourslash/rename.multipleDecl.fourslash.ts +0 -21
  549. package/src/tests/fourslash/rename.sourceAndStub.fourslash.ts +0 -37
  550. package/src/tests/fourslash/rename.string.excluded.fourslash.ts +0 -43
  551. package/src/tests/fourslash/rename.string.fourslash.ts +0 -26
  552. package/src/tests/fourslash/signature.builtinDocstrings.fourslash.ts +0 -63
  553. package/src/tests/fourslash/signature.complicated.fourslash.ts +0 -100
  554. package/src/tests/fourslash/signature.cornercases.fourslash.ts +0 -23
  555. package/src/tests/fourslash/signature.docstrings.fourslash.ts +0 -43
  556. package/src/tests/fourslash/signature.docstrings.overloaded.fourslash.ts +0 -50
  557. package/src/tests/fourslash/signature.docstrings.wildcardimports.fourslash.ts +0 -122
  558. package/src/tests/fourslash/signature.overload.fourslash.ts +0 -64
  559. package/src/tests/fourslash/signature.simple.fourslash.ts +0 -104
  560. package/src/tests/harness/fourslash/fourSlashParser.ts +0 -441
  561. package/src/tests/harness/fourslash/fourSlashTypes.ts +0 -134
  562. package/src/tests/harness/fourslash/runner.ts +0 -99
  563. package/src/tests/harness/fourslash/testLanguageService.ts +0 -142
  564. package/src/tests/harness/fourslash/testState.Consts.ts +0 -29
  565. package/src/tests/harness/fourslash/testState.ts +0 -1993
  566. package/src/tests/harness/testAccessHost.ts +0 -23
  567. package/src/tests/harness/testHost.ts +0 -177
  568. package/src/tests/harness/utils.ts +0 -355
  569. package/src/tests/harness/vfs/factory.ts +0 -199
  570. package/src/tests/harness/vfs/filesystem.ts +0 -1893
  571. package/src/tests/harness/vfs/pathValidation.ts +0 -154
  572. package/src/tests/importAdder.test.ts +0 -1361
  573. package/src/tests/importResolver.test.ts +0 -534
  574. package/src/tests/importStatementUtils.test.ts +0 -526
  575. package/src/tests/indentationUtils.ptvs.test.ts +0 -388
  576. package/src/tests/indentationUtils.reindent.test.ts +0 -403
  577. package/src/tests/indentationUtils.test.ts +0 -455
  578. package/src/tests/ipythonMode.test.ts +0 -365
  579. package/src/tests/localizer.test.ts +0 -47
  580. package/src/tests/parseTreeUtils.test.ts +0 -281
  581. package/src/tests/parser.test.ts +0 -99
  582. package/src/tests/pathUtils.test.ts +0 -321
  583. package/src/tests/pyrightFileSystem.test.ts +0 -183
  584. package/src/tests/renameModule.folder.test.ts +0 -261
  585. package/src/tests/renameModule.fromImports.test.ts +0 -952
  586. package/src/tests/renameModule.imports.test.ts +0 -450
  587. package/src/tests/renameModule.misc.test.ts +0 -765
  588. package/src/tests/renameModule.relativePath.test.ts +0 -277
  589. package/src/tests/renameModuleTestUtils.ts +0 -210
  590. package/src/tests/samples/abstractClass1.py +0 -51
  591. package/src/tests/samples/abstractClass2.py +0 -25
  592. package/src/tests/samples/abstractClass3.py +0 -30
  593. package/src/tests/samples/abstractClass4.py +0 -30
  594. package/src/tests/samples/abstractClass5.py +0 -42
  595. package/src/tests/samples/abstractClass6.py +0 -25
  596. package/src/tests/samples/abstractClass7.py +0 -22
  597. package/src/tests/samples/abstractClass8.py +0 -27
  598. package/src/tests/samples/annotated1.py +0 -72
  599. package/src/tests/samples/annotatedVar1.py +0 -22
  600. package/src/tests/samples/annotatedVar2.py +0 -28
  601. package/src/tests/samples/annotatedVar3.py +0 -54
  602. package/src/tests/samples/annotatedVar4.py +0 -24
  603. package/src/tests/samples/annotatedVar5.py +0 -37
  604. package/src/tests/samples/annotatedVar6.py +0 -22
  605. package/src/tests/samples/annotatedVar7.py +0 -13
  606. package/src/tests/samples/annotatedVar8.py +0 -29
  607. package/src/tests/samples/annotations1.py +0 -98
  608. package/src/tests/samples/annotations2.py +0 -33
  609. package/src/tests/samples/annotations3.py +0 -43
  610. package/src/tests/samples/annotations4.py +0 -54
  611. package/src/tests/samples/annotations5.py +0 -9
  612. package/src/tests/samples/annotations6.py +0 -29
  613. package/src/tests/samples/assert1.py +0 -22
  614. package/src/tests/samples/assertType1.py +0 -46
  615. package/src/tests/samples/assignment1.py +0 -58
  616. package/src/tests/samples/assignment10.py +0 -14
  617. package/src/tests/samples/assignment2.py +0 -40
  618. package/src/tests/samples/assignment3.py +0 -46
  619. package/src/tests/samples/assignment4.py +0 -20
  620. package/src/tests/samples/assignment5.py +0 -16
  621. package/src/tests/samples/assignment6.py +0 -25
  622. package/src/tests/samples/assignment7.py +0 -13
  623. package/src/tests/samples/assignment8.py +0 -40
  624. package/src/tests/samples/assignment9.py +0 -25
  625. package/src/tests/samples/assignmentExpr1.py +0 -23
  626. package/src/tests/samples/assignmentExpr2.py +0 -49
  627. package/src/tests/samples/assignmentExpr3.py +0 -27
  628. package/src/tests/samples/assignmentExpr4.py +0 -49
  629. package/src/tests/samples/assignmentExpr5.py +0 -15
  630. package/src/tests/samples/assignmentExpr6.py +0 -10
  631. package/src/tests/samples/assignmentExpr7.py +0 -13
  632. package/src/tests/samples/assignmentExpr8.py +0 -11
  633. package/src/tests/samples/assignmentExpr9.py +0 -28
  634. package/src/tests/samples/async1.py +0 -49
  635. package/src/tests/samples/augmentedAssignment1.py +0 -62
  636. package/src/tests/samples/augmentedAssignment2.py +0 -23
  637. package/src/tests/samples/augmentedAssignment3.py +0 -8
  638. package/src/tests/samples/await1.py +0 -23
  639. package/src/tests/samples/await2.py +0 -25
  640. package/src/tests/samples/badToken1.py +0 -6
  641. package/src/tests/samples/builtins1.py +0 -2
  642. package/src/tests/samples/call1.py +0 -93
  643. package/src/tests/samples/call2.py +0 -118
  644. package/src/tests/samples/call3.py +0 -168
  645. package/src/tests/samples/call4.py +0 -13
  646. package/src/tests/samples/call5.py +0 -95
  647. package/src/tests/samples/call6.py +0 -35
  648. package/src/tests/samples/call7.py +0 -57
  649. package/src/tests/samples/callSite1.py +0 -6
  650. package/src/tests/samples/callSite2.py +0 -12
  651. package/src/tests/samples/callable1.py +0 -53
  652. package/src/tests/samples/callable2.py +0 -58
  653. package/src/tests/samples/callable3.py +0 -28
  654. package/src/tests/samples/callable4.py +0 -32
  655. package/src/tests/samples/callable5.py +0 -40
  656. package/src/tests/samples/callable6.py +0 -83
  657. package/src/tests/samples/callbackProtocol1.py +0 -119
  658. package/src/tests/samples/callbackProtocol2.py +0 -29
  659. package/src/tests/samples/callbackProtocol3.py +0 -23
  660. package/src/tests/samples/callbackProtocol4.py +0 -73
  661. package/src/tests/samples/callbackProtocol5.py +0 -66
  662. package/src/tests/samples/callbackProtocol6.py +0 -66
  663. package/src/tests/samples/callbackProtocol7.py +0 -16
  664. package/src/tests/samples/callbackProtocol8.py +0 -16
  665. package/src/tests/samples/capturedVariable1.py +0 -106
  666. package/src/tests/samples/circular1.py +0 -16
  667. package/src/tests/samples/circular2.py +0 -38
  668. package/src/tests/samples/circularBaseClass.py +0 -17
  669. package/src/tests/samples/classGetItem1.py +0 -30
  670. package/src/tests/samples/classVar1.py +0 -41
  671. package/src/tests/samples/classVar2.py +0 -29
  672. package/src/tests/samples/classVar3.py +0 -46
  673. package/src/tests/samples/classVar4.py +0 -36
  674. package/src/tests/samples/classes1.py +0 -50
  675. package/src/tests/samples/classes3.py +0 -48
  676. package/src/tests/samples/classes4.py +0 -15
  677. package/src/tests/samples/classes5.py +0 -260
  678. package/src/tests/samples/classes6.py +0 -16
  679. package/src/tests/samples/classes7.py +0 -18
  680. package/src/tests/samples/classes8.py +0 -47
  681. package/src/tests/samples/codeFlow1.py +0 -65
  682. package/src/tests/samples/codeFlow2.py +0 -26
  683. package/src/tests/samples/codeFlow3.py +0 -8
  684. package/src/tests/samples/codeFlow4.py +0 -133
  685. package/src/tests/samples/codeFlow5.py +0 -10
  686. package/src/tests/samples/codeFlow6.py +0 -35
  687. package/src/tests/samples/codeFlow7.py +0 -35
  688. package/src/tests/samples/comparison1.py +0 -77
  689. package/src/tests/samples/comparison2.py +0 -37
  690. package/src/tests/samples/complex1.py +0 -17
  691. package/src/tests/samples/constant1.py +0 -40
  692. package/src/tests/samples/constants1.py +0 -64
  693. package/src/tests/samples/constructor1.py +0 -30
  694. package/src/tests/samples/constructor10.py +0 -19
  695. package/src/tests/samples/constructor11.py +0 -32
  696. package/src/tests/samples/constructor12.py +0 -20
  697. package/src/tests/samples/constructor13.py +0 -15
  698. package/src/tests/samples/constructor2.py +0 -180
  699. package/src/tests/samples/constructor3.py +0 -18
  700. package/src/tests/samples/constructor4.py +0 -25
  701. package/src/tests/samples/constructor5.py +0 -25
  702. package/src/tests/samples/constructor6.py +0 -70
  703. package/src/tests/samples/constructor7.py +0 -11
  704. package/src/tests/samples/constructor8.py +0 -99
  705. package/src/tests/samples/constructor9.py +0 -19
  706. package/src/tests/samples/coroutines1.py +0 -60
  707. package/src/tests/samples/coroutines2.py +0 -20
  708. package/src/tests/samples/coroutines3.py +0 -37
  709. package/src/tests/samples/dataclass1.py +0 -44
  710. package/src/tests/samples/dataclass10.py +0 -45
  711. package/src/tests/samples/dataclass11.py +0 -53
  712. package/src/tests/samples/dataclass12.py +0 -32
  713. package/src/tests/samples/dataclass13.py +0 -42
  714. package/src/tests/samples/dataclass14.py +0 -38
  715. package/src/tests/samples/dataclass15.py +0 -58
  716. package/src/tests/samples/dataclass16.py +0 -21
  717. package/src/tests/samples/dataclass17.py +0 -46
  718. package/src/tests/samples/dataclass18.py +0 -57
  719. package/src/tests/samples/dataclass19.py +0 -44
  720. package/src/tests/samples/dataclass2.py +0 -30
  721. package/src/tests/samples/dataclass20.py +0 -71
  722. package/src/tests/samples/dataclass21.py +0 -13
  723. package/src/tests/samples/dataclass3.py +0 -18
  724. package/src/tests/samples/dataclass4.py +0 -64
  725. package/src/tests/samples/dataclass5.py +0 -81
  726. package/src/tests/samples/dataclass6.py +0 -29
  727. package/src/tests/samples/dataclass7.py +0 -93
  728. package/src/tests/samples/dataclass8.py +0 -22
  729. package/src/tests/samples/dataclass9.py +0 -24
  730. package/src/tests/samples/dataclassPostInit1.py +0 -61
  731. package/src/tests/samples/dataclassTransform1.py +0 -71
  732. package/src/tests/samples/dataclassTransform2.py +0 -78
  733. package/src/tests/samples/dataclassTransform3.py +0 -83
  734. package/src/tests/samples/dataclassTransform4.py +0 -87
  735. package/src/tests/samples/decorator1.py +0 -20
  736. package/src/tests/samples/decorator2.py +0 -31
  737. package/src/tests/samples/decorator3.py +0 -27
  738. package/src/tests/samples/decorator4.py +0 -37
  739. package/src/tests/samples/decorator5.py +0 -29
  740. package/src/tests/samples/decorator6.py +0 -34
  741. package/src/tests/samples/defaultInitializer1.py +0 -26
  742. package/src/tests/samples/deprecated1.py +0 -37
  743. package/src/tests/samples/descriptor1.py +0 -134
  744. package/src/tests/samples/descriptor2.py +0 -29
  745. package/src/tests/samples/dictionary1.py +0 -42
  746. package/src/tests/samples/dictionary2.py +0 -14
  747. package/src/tests/samples/dictionary3.py +0 -30
  748. package/src/tests/samples/dictionary4.py +0 -106
  749. package/src/tests/samples/dunderAll1.py +0 -32
  750. package/src/tests/samples/dunderAll2.py +0 -16
  751. package/src/tests/samples/dunderAll3.pyi +0 -16
  752. package/src/tests/samples/duplicateDeclaration1.py +0 -115
  753. package/src/tests/samples/duplicateDeclaration2.py +0 -45
  754. package/src/tests/samples/duplicateImports1.py +0 -13
  755. package/src/tests/samples/ellipsis1.pyi +0 -48
  756. package/src/tests/samples/emptyContainers1.py +0 -89
  757. package/src/tests/samples/enums1.py +0 -52
  758. package/src/tests/samples/enums2.py +0 -15
  759. package/src/tests/samples/enums3.py +0 -24
  760. package/src/tests/samples/enums4.py +0 -23
  761. package/src/tests/samples/enums5.py +0 -16
  762. package/src/tests/samples/enums6.py +0 -33
  763. package/src/tests/samples/enums7.py +0 -54
  764. package/src/tests/samples/enums8.py +0 -14
  765. package/src/tests/samples/expressions1.py +0 -54
  766. package/src/tests/samples/expressions2.py +0 -29
  767. package/src/tests/samples/expressions3.py +0 -26
  768. package/src/tests/samples/expressions4.py +0 -23
  769. package/src/tests/samples/expressions5.py +0 -70
  770. package/src/tests/samples/expressions6.py +0 -14
  771. package/src/tests/samples/expressions7.py +0 -40
  772. package/src/tests/samples/expressions8.py +0 -26
  773. package/src/tests/samples/expressions9.py +0 -14
  774. package/src/tests/samples/final1.py +0 -14
  775. package/src/tests/samples/final2.py +0 -86
  776. package/src/tests/samples/final3.py +0 -179
  777. package/src/tests/samples/final4.pyi +0 -21
  778. package/src/tests/samples/final5.py +0 -18
  779. package/src/tests/samples/forLoop1.py +0 -88
  780. package/src/tests/samples/forLoop2.py +0 -48
  781. package/src/tests/samples/fstring1.py +0 -66
  782. package/src/tests/samples/fstring2.py +0 -12
  783. package/src/tests/samples/fstring3.py +0 -35
  784. package/src/tests/samples/fstring4.py +0 -17
  785. package/src/tests/samples/fstring5.py +0 -17
  786. package/src/tests/samples/fstring6.py +0 -14
  787. package/src/tests/samples/function1.py +0 -12
  788. package/src/tests/samples/function10.py +0 -20
  789. package/src/tests/samples/function11.py +0 -36
  790. package/src/tests/samples/function2.py +0 -7
  791. package/src/tests/samples/function3.py +0 -82
  792. package/src/tests/samples/function4.py +0 -13
  793. package/src/tests/samples/function6.py +0 -24
  794. package/src/tests/samples/function7.py +0 -13
  795. package/src/tests/samples/function8.py +0 -38
  796. package/src/tests/samples/function9.py +0 -75
  797. package/src/tests/samples/functionAnnotation1.py +0 -61
  798. package/src/tests/samples/functionAnnotation2.py +0 -26
  799. package/src/tests/samples/functionAnnotation3.py +0 -37
  800. package/src/tests/samples/functionAnnotation4.py +0 -22
  801. package/src/tests/samples/functionMember1.py +0 -18
  802. package/src/tests/samples/functionMember2.py +0 -45
  803. package/src/tests/samples/generators1.py +0 -122
  804. package/src/tests/samples/generators10.py +0 -18
  805. package/src/tests/samples/generators11.py +0 -27
  806. package/src/tests/samples/generators12.py +0 -25
  807. package/src/tests/samples/generators13.py +0 -65
  808. package/src/tests/samples/generators14.py +0 -19
  809. package/src/tests/samples/generators15.py +0 -26
  810. package/src/tests/samples/generators2.py +0 -31
  811. package/src/tests/samples/generators3.py +0 -42
  812. package/src/tests/samples/generators4.py +0 -33
  813. package/src/tests/samples/generators5.py +0 -24
  814. package/src/tests/samples/generators6.py +0 -14
  815. package/src/tests/samples/generators7.py +0 -18
  816. package/src/tests/samples/generators8.py +0 -12
  817. package/src/tests/samples/generators9.py +0 -19
  818. package/src/tests/samples/generic1.py +0 -41
  819. package/src/tests/samples/genericTypes1.py +0 -12
  820. package/src/tests/samples/genericTypes10.py +0 -38
  821. package/src/tests/samples/genericTypes11.py +0 -26
  822. package/src/tests/samples/genericTypes12.py +0 -14
  823. package/src/tests/samples/genericTypes13.py +0 -27
  824. package/src/tests/samples/genericTypes14.py +0 -22
  825. package/src/tests/samples/genericTypes15.py +0 -13
  826. package/src/tests/samples/genericTypes16.py +0 -15
  827. package/src/tests/samples/genericTypes17.py +0 -24
  828. package/src/tests/samples/genericTypes18.py +0 -135
  829. package/src/tests/samples/genericTypes19.py +0 -32
  830. package/src/tests/samples/genericTypes2.py +0 -40
  831. package/src/tests/samples/genericTypes20.py +0 -44
  832. package/src/tests/samples/genericTypes21.py +0 -29
  833. package/src/tests/samples/genericTypes22.py +0 -23
  834. package/src/tests/samples/genericTypes23.py +0 -27
  835. package/src/tests/samples/genericTypes24.py +0 -32
  836. package/src/tests/samples/genericTypes25.py +0 -37
  837. package/src/tests/samples/genericTypes26.py +0 -31
  838. package/src/tests/samples/genericTypes27.py +0 -14
  839. package/src/tests/samples/genericTypes28.py +0 -51
  840. package/src/tests/samples/genericTypes29.py +0 -24
  841. package/src/tests/samples/genericTypes3.py +0 -13
  842. package/src/tests/samples/genericTypes30.py +0 -32
  843. package/src/tests/samples/genericTypes31.py +0 -30
  844. package/src/tests/samples/genericTypes32.py +0 -25
  845. package/src/tests/samples/genericTypes33.py +0 -46
  846. package/src/tests/samples/genericTypes34.py +0 -54
  847. package/src/tests/samples/genericTypes35.py +0 -45
  848. package/src/tests/samples/genericTypes36.py +0 -35
  849. package/src/tests/samples/genericTypes37.py +0 -26
  850. package/src/tests/samples/genericTypes38.py +0 -15
  851. package/src/tests/samples/genericTypes39.py +0 -82
  852. package/src/tests/samples/genericTypes4.py +0 -37
  853. package/src/tests/samples/genericTypes40.py +0 -38
  854. package/src/tests/samples/genericTypes41.py +0 -16
  855. package/src/tests/samples/genericTypes42.py +0 -32
  856. package/src/tests/samples/genericTypes43.py +0 -24
  857. package/src/tests/samples/genericTypes44.py +0 -33
  858. package/src/tests/samples/genericTypes45.py +0 -43
  859. package/src/tests/samples/genericTypes46.py +0 -66
  860. package/src/tests/samples/genericTypes47.py +0 -39
  861. package/src/tests/samples/genericTypes48.py +0 -18
  862. package/src/tests/samples/genericTypes49.py +0 -41
  863. package/src/tests/samples/genericTypes5.py +0 -42
  864. package/src/tests/samples/genericTypes50.py +0 -62
  865. package/src/tests/samples/genericTypes51.py +0 -55
  866. package/src/tests/samples/genericTypes52.py +0 -34
  867. package/src/tests/samples/genericTypes53.py +0 -42
  868. package/src/tests/samples/genericTypes54.py +0 -31
  869. package/src/tests/samples/genericTypes55.py +0 -61
  870. package/src/tests/samples/genericTypes56.py +0 -19
  871. package/src/tests/samples/genericTypes57.py +0 -30
  872. package/src/tests/samples/genericTypes58.py +0 -52
  873. package/src/tests/samples/genericTypes59.py +0 -71
  874. package/src/tests/samples/genericTypes6.py +0 -49
  875. package/src/tests/samples/genericTypes60.py +0 -27
  876. package/src/tests/samples/genericTypes61.py +0 -34
  877. package/src/tests/samples/genericTypes62.py +0 -26
  878. package/src/tests/samples/genericTypes63.py +0 -32
  879. package/src/tests/samples/genericTypes64.py +0 -16
  880. package/src/tests/samples/genericTypes65.py +0 -15
  881. package/src/tests/samples/genericTypes66.py +0 -30
  882. package/src/tests/samples/genericTypes67.py +0 -57
  883. package/src/tests/samples/genericTypes68.py +0 -14
  884. package/src/tests/samples/genericTypes69.py +0 -45
  885. package/src/tests/samples/genericTypes7.py +0 -24
  886. package/src/tests/samples/genericTypes70.py +0 -31
  887. package/src/tests/samples/genericTypes71.py +0 -72
  888. package/src/tests/samples/genericTypes72.py +0 -24
  889. package/src/tests/samples/genericTypes73.py +0 -14
  890. package/src/tests/samples/genericTypes74.py +0 -23
  891. package/src/tests/samples/genericTypes75.py +0 -45
  892. package/src/tests/samples/genericTypes76.py +0 -107
  893. package/src/tests/samples/genericTypes77.py +0 -26
  894. package/src/tests/samples/genericTypes78.py +0 -23
  895. package/src/tests/samples/genericTypes79.py +0 -37
  896. package/src/tests/samples/genericTypes8.py +0 -26
  897. package/src/tests/samples/genericTypes80.py +0 -10
  898. package/src/tests/samples/genericTypes81.py +0 -32
  899. package/src/tests/samples/genericTypes82.py +0 -19
  900. package/src/tests/samples/genericTypes83.py +0 -28
  901. package/src/tests/samples/genericTypes84.py +0 -11
  902. package/src/tests/samples/genericTypes85.py +0 -20
  903. package/src/tests/samples/genericTypes86.py +0 -15
  904. package/src/tests/samples/genericTypes87.py +0 -21
  905. package/src/tests/samples/genericTypes88.py +0 -25
  906. package/src/tests/samples/genericTypes89.py +0 -17
  907. package/src/tests/samples/genericTypes9.py +0 -109
  908. package/src/tests/samples/genericTypes90.py +0 -12
  909. package/src/tests/samples/genericTypes91.py +0 -20
  910. package/src/tests/samples/import1.py +0 -7
  911. package/src/tests/samples/import10.py +0 -11
  912. package/src/tests/samples/import11.py +0 -11
  913. package/src/tests/samples/import12.py +0 -5
  914. package/src/tests/samples/import13.py +0 -6
  915. package/src/tests/samples/import14.py +0 -10
  916. package/src/tests/samples/import2.py +0 -27
  917. package/src/tests/samples/import3.py +0 -8
  918. package/src/tests/samples/import4.py +0 -15
  919. package/src/tests/samples/import5.py +0 -6
  920. package/src/tests/samples/import6.py +0 -17
  921. package/src/tests/samples/import7.py +0 -14
  922. package/src/tests/samples/import8.py +0 -7
  923. package/src/tests/samples/import9.py +0 -7
  924. package/src/tests/samples/inconsistentConstructor1.py +0 -23
  925. package/src/tests/samples/inconsistentSpaceTab1.py +0 -9
  926. package/src/tests/samples/inconsistentSpaceTab2.py +0 -10
  927. package/src/tests/samples/index1.py +0 -97
  928. package/src/tests/samples/inferredTypes1.py +0 -25
  929. package/src/tests/samples/initVar1.py +0 -23
  930. package/src/tests/samples/initsubclass1.py +0 -46
  931. package/src/tests/samples/initsubclass2.py +0 -16
  932. package/src/tests/samples/isinstance1.py +0 -57
  933. package/src/tests/samples/isinstance10.py +0 -15
  934. package/src/tests/samples/isinstance2.py +0 -28
  935. package/src/tests/samples/isinstance3.py +0 -59
  936. package/src/tests/samples/isinstance4.py +0 -57
  937. package/src/tests/samples/isinstance5.py +0 -8
  938. package/src/tests/samples/isinstance6.py +0 -19
  939. package/src/tests/samples/isinstance7.py +0 -42
  940. package/src/tests/samples/isinstance9.py +0 -26
  941. package/src/tests/samples/kwargsUnpack1.py +0 -116
  942. package/src/tests/samples/lambda1.py +0 -77
  943. package/src/tests/samples/lambda2.py +0 -26
  944. package/src/tests/samples/lambda3.py +0 -34
  945. package/src/tests/samples/lambda4.py +0 -70
  946. package/src/tests/samples/lambda5.py +0 -23
  947. package/src/tests/samples/lambda6.py +0 -15
  948. package/src/tests/samples/lines1.py +0 -14
  949. package/src/tests/samples/list1.py +0 -90
  950. package/src/tests/samples/listComprehension1.py +0 -45
  951. package/src/tests/samples/listComprehension2.py +0 -17
  952. package/src/tests/samples/listComprehension3.py +0 -12
  953. package/src/tests/samples/listComprehension4.py +0 -15
  954. package/src/tests/samples/listComprehension5.py +0 -20
  955. package/src/tests/samples/listComprehension6.py +0 -14
  956. package/src/tests/samples/listComprehension7.py +0 -15
  957. package/src/tests/samples/listComprehension8.py +0 -15
  958. package/src/tests/samples/literalString1.py +0 -43
  959. package/src/tests/samples/literals1.py +0 -48
  960. package/src/tests/samples/literals2.py +0 -30
  961. package/src/tests/samples/literals3.py +0 -40
  962. package/src/tests/samples/literals4.py +0 -10
  963. package/src/tests/samples/literals5.py +0 -28
  964. package/src/tests/samples/literals6.py +0 -90
  965. package/src/tests/samples/literals7.py +0 -38
  966. package/src/tests/samples/loops1.py +0 -45
  967. package/src/tests/samples/loops10.py +0 -11
  968. package/src/tests/samples/loops11.py +0 -22
  969. package/src/tests/samples/loops12.py +0 -18
  970. package/src/tests/samples/loops13.py +0 -13
  971. package/src/tests/samples/loops14.py +0 -22
  972. package/src/tests/samples/loops15.py +0 -22
  973. package/src/tests/samples/loops16.py +0 -322
  974. package/src/tests/samples/loops17.py +0 -9
  975. package/src/tests/samples/loops18.py +0 -23
  976. package/src/tests/samples/loops19.py +0 -14
  977. package/src/tests/samples/loops2.py +0 -25
  978. package/src/tests/samples/loops20.py +0 -41
  979. package/src/tests/samples/loops21.py +0 -18
  980. package/src/tests/samples/loops22.py +0 -21
  981. package/src/tests/samples/loops23.py +0 -16
  982. package/src/tests/samples/loops24.py +0 -12
  983. package/src/tests/samples/loops25.py +0 -45
  984. package/src/tests/samples/loops26.py +0 -12
  985. package/src/tests/samples/loops3.py +0 -11
  986. package/src/tests/samples/loops4.py +0 -17
  987. package/src/tests/samples/loops5.py +0 -14
  988. package/src/tests/samples/loops6.py +0 -25
  989. package/src/tests/samples/loops7.py +0 -14
  990. package/src/tests/samples/loops8.py +0 -17
  991. package/src/tests/samples/loops9.py +0 -25
  992. package/src/tests/samples/match1.py +0 -190
  993. package/src/tests/samples/match10.py +0 -67
  994. package/src/tests/samples/match2.py +0 -340
  995. package/src/tests/samples/match3.py +0 -364
  996. package/src/tests/samples/match4.py +0 -100
  997. package/src/tests/samples/match5.py +0 -70
  998. package/src/tests/samples/match6.py +0 -64
  999. package/src/tests/samples/match7.py +0 -65
  1000. package/src/tests/samples/match8.py +0 -19
  1001. package/src/tests/samples/match9.py +0 -53
  1002. package/src/tests/samples/maxParseDepth1.py +0 -499
  1003. package/src/tests/samples/maxParseDepth2.py +0 -16
  1004. package/src/tests/samples/memberAccess1.py +0 -70
  1005. package/src/tests/samples/memberAccess10.py +0 -65
  1006. package/src/tests/samples/memberAccess11.py +0 -37
  1007. package/src/tests/samples/memberAccess12.py +0 -36
  1008. package/src/tests/samples/memberAccess13.py +0 -17
  1009. package/src/tests/samples/memberAccess14.py +0 -63
  1010. package/src/tests/samples/memberAccess15.py +0 -20
  1011. package/src/tests/samples/memberAccess16.py +0 -12
  1012. package/src/tests/samples/memberAccess17.py +0 -31
  1013. package/src/tests/samples/memberAccess18.py +0 -31
  1014. package/src/tests/samples/memberAccess2.py +0 -45
  1015. package/src/tests/samples/memberAccess3.py +0 -64
  1016. package/src/tests/samples/memberAccess4.py +0 -91
  1017. package/src/tests/samples/memberAccess5.py +0 -26
  1018. package/src/tests/samples/memberAccess6.py +0 -52
  1019. package/src/tests/samples/memberAccess7.py +0 -36
  1020. package/src/tests/samples/memberAccess8.py +0 -75
  1021. package/src/tests/samples/memberAccess9.py +0 -11
  1022. package/src/tests/samples/metaclass1.py +0 -7
  1023. package/src/tests/samples/metaclass2.py +0 -35
  1024. package/src/tests/samples/metaclass3.py +0 -43
  1025. package/src/tests/samples/metaclass4.py +0 -26
  1026. package/src/tests/samples/metaclass5.py +0 -33
  1027. package/src/tests/samples/metaclass6.py +0 -15
  1028. package/src/tests/samples/metaclass7.py +0 -38
  1029. package/src/tests/samples/metaclass8.py +0 -20
  1030. package/src/tests/samples/metaclass9.py +0 -77
  1031. package/src/tests/samples/methodOverride1.py +0 -507
  1032. package/src/tests/samples/methodOverride2.py +0 -74
  1033. package/src/tests/samples/methodOverride3.py +0 -111
  1034. package/src/tests/samples/methodOverride4.py +0 -36
  1035. package/src/tests/samples/missingSuper1.py +0 -73
  1036. package/src/tests/samples/module1.py +0 -13
  1037. package/src/tests/samples/module2.py +0 -7
  1038. package/src/tests/samples/mro1.py +0 -16
  1039. package/src/tests/samples/mro2.py +0 -45
  1040. package/src/tests/samples/mro3.py +0 -30
  1041. package/src/tests/samples/mro4.py +0 -30
  1042. package/src/tests/samples/nameBindings1.py +0 -48
  1043. package/src/tests/samples/nameBindings2.py +0 -9
  1044. package/src/tests/samples/nameBindings3.py +0 -36
  1045. package/src/tests/samples/nameBindings4.py +0 -10
  1046. package/src/tests/samples/nameBindings5.py +0 -53
  1047. package/src/tests/samples/namedTuples1.py +0 -103
  1048. package/src/tests/samples/namedTuples2.py +0 -56
  1049. package/src/tests/samples/namedTuples3.py +0 -15
  1050. package/src/tests/samples/namedTuples4.py +0 -24
  1051. package/src/tests/samples/namedTuples5.py +0 -15
  1052. package/src/tests/samples/namedTuples6.py +0 -31
  1053. package/src/tests/samples/namedTuples7.py +0 -27
  1054. package/src/tests/samples/never1.py +0 -12
  1055. package/src/tests/samples/never2.py +0 -43
  1056. package/src/tests/samples/newType1.py +0 -34
  1057. package/src/tests/samples/newType2.py +0 -25
  1058. package/src/tests/samples/newType3.py +0 -34
  1059. package/src/tests/samples/newType4.py +0 -8
  1060. package/src/tests/samples/none1.py +0 -29
  1061. package/src/tests/samples/none2.py +0 -22
  1062. package/src/tests/samples/noreturn1.py +0 -78
  1063. package/src/tests/samples/noreturn2.py +0 -37
  1064. package/src/tests/samples/noreturn3.py +0 -16
  1065. package/src/tests/samples/noreturn4.py +0 -29
  1066. package/src/tests/samples/operators1.py +0 -101
  1067. package/src/tests/samples/operators2.py +0 -30
  1068. package/src/tests/samples/operators3.py +0 -8
  1069. package/src/tests/samples/operators4.py +0 -22
  1070. package/src/tests/samples/operators5.py +0 -5
  1071. package/src/tests/samples/operators6.py +0 -10
  1072. package/src/tests/samples/operators7.py +0 -24
  1073. package/src/tests/samples/operators8.py +0 -125
  1074. package/src/tests/samples/optional1.py +0 -77
  1075. package/src/tests/samples/optional2.py +0 -23
  1076. package/src/tests/samples/overload1.py +0 -50
  1077. package/src/tests/samples/overload10.py +0 -48
  1078. package/src/tests/samples/overload2.py +0 -37
  1079. package/src/tests/samples/overload3.py +0 -29
  1080. package/src/tests/samples/overload4.py +0 -46
  1081. package/src/tests/samples/overload5.py +0 -333
  1082. package/src/tests/samples/overload6.py +0 -64
  1083. package/src/tests/samples/overload7.py +0 -376
  1084. package/src/tests/samples/overload8.py +0 -89
  1085. package/src/tests/samples/overload9.py +0 -19
  1086. package/src/tests/samples/package1/__init__.py +0 -3
  1087. package/src/tests/samples/package1/psyche/pysche.py +0 -4
  1088. package/src/tests/samples/package1/psyche.py +0 -4
  1089. package/src/tests/samples/package1/sub/__init__.py +0 -5
  1090. package/src/tests/samples/package1/sub.py +0 -4
  1091. package/src/tests/samples/package1/sub.pyi +0 -2
  1092. package/src/tests/samples/paramInference1.py +0 -27
  1093. package/src/tests/samples/paramNames1.py +0 -39
  1094. package/src/tests/samples/paramSpec1.py +0 -64
  1095. package/src/tests/samples/paramSpec10.py +0 -57
  1096. package/src/tests/samples/paramSpec11.py +0 -36
  1097. package/src/tests/samples/paramSpec12.py +0 -88
  1098. package/src/tests/samples/paramSpec13.py +0 -112
  1099. package/src/tests/samples/paramSpec14.py +0 -30
  1100. package/src/tests/samples/paramSpec15.py +0 -28
  1101. package/src/tests/samples/paramSpec16.py +0 -28
  1102. package/src/tests/samples/paramSpec17.py +0 -34
  1103. package/src/tests/samples/paramSpec18.py +0 -43
  1104. package/src/tests/samples/paramSpec19.py +0 -93
  1105. package/src/tests/samples/paramSpec2.py +0 -29
  1106. package/src/tests/samples/paramSpec20.py +0 -87
  1107. package/src/tests/samples/paramSpec21.py +0 -58
  1108. package/src/tests/samples/paramSpec22.py +0 -26
  1109. package/src/tests/samples/paramSpec23.py +0 -21
  1110. package/src/tests/samples/paramSpec24.py +0 -67
  1111. package/src/tests/samples/paramSpec25.py +0 -36
  1112. package/src/tests/samples/paramSpec26.py +0 -25
  1113. package/src/tests/samples/paramSpec27.py +0 -57
  1114. package/src/tests/samples/paramSpec28.py +0 -39
  1115. package/src/tests/samples/paramSpec29.py +0 -37
  1116. package/src/tests/samples/paramSpec3.py +0 -71
  1117. package/src/tests/samples/paramSpec30.py +0 -49
  1118. package/src/tests/samples/paramSpec31.py +0 -16
  1119. package/src/tests/samples/paramSpec32.py +0 -57
  1120. package/src/tests/samples/paramSpec33.py +0 -29
  1121. package/src/tests/samples/paramSpec34.py +0 -29
  1122. package/src/tests/samples/paramSpec35.py +0 -24
  1123. package/src/tests/samples/paramSpec36.py +0 -43
  1124. package/src/tests/samples/paramSpec37.py +0 -25
  1125. package/src/tests/samples/paramSpec4.py +0 -109
  1126. package/src/tests/samples/paramSpec5.py +0 -29
  1127. package/src/tests/samples/paramSpec6.py +0 -17
  1128. package/src/tests/samples/paramSpec7.py +0 -22
  1129. package/src/tests/samples/paramSpec8.py +0 -45
  1130. package/src/tests/samples/paramSpec9.py +0 -57
  1131. package/src/tests/samples/paramType1.py +0 -71
  1132. package/src/tests/samples/parameters1.py +0 -16
  1133. package/src/tests/samples/partial1.py +0 -163
  1134. package/src/tests/samples/partial2.py +0 -31
  1135. package/src/tests/samples/private1.py +0 -55
  1136. package/src/tests/samples/private2.py +0 -11
  1137. package/src/tests/samples/project1/pyrightconfig.json +0 -5
  1138. package/src/tests/samples/project1/sample1.py +0 -0
  1139. package/src/tests/samples/project1/subfolder1/sample2.py +0 -0
  1140. package/src/tests/samples/project1/subfolder1/subfolder1-1/sample3.py +0 -0
  1141. package/src/tests/samples/project2/pyrightconfig.json +0 -3
  1142. package/src/tests/samples/project3/pyrightconfig.json +0 -7
  1143. package/src/tests/samples/project4/presentfile.py +0 -0
  1144. package/src/tests/samples/project4/pyrightconfig.json +0 -11
  1145. package/src/tests/samples/project4/subfolder/presentfile2.py +0 -0
  1146. package/src/tests/samples/project4/subfolder/presentfile3.py +0 -0
  1147. package/src/tests/samples/project5/pyrightconfig.json +0 -4
  1148. package/src/tests/samples/project6/app1.py +0 -0
  1149. package/src/tests/samples/project6/app2.py +0 -0
  1150. package/src/tests/samples/project6/projectA/foo/__init__.py +0 -0
  1151. package/src/tests/samples/project6/projectA/foo/bar/__init__.py +0 -0
  1152. package/src/tests/samples/project6/projectB/foo/__init__.py +0 -0
  1153. package/src/tests/samples/project6/projectB/foo/baz/__init__.py +0 -0
  1154. package/src/tests/samples/project_src/src/module1.py +0 -0
  1155. package/src/tests/samples/project_src_is_pkg/src/__init__.py +0 -0
  1156. package/src/tests/samples/project_src_is_pkg/src/module1.py +0 -0
  1157. package/src/tests/samples/project_src_with_config_extra_paths/pyrightconfig.json +0 -3
  1158. package/src/tests/samples/project_src_with_config_extra_paths/src/module1.py +0 -0
  1159. package/src/tests/samples/project_src_with_config_no_extra_paths/pyrightconfig.json +0 -2
  1160. package/src/tests/samples/project_src_with_config_no_extra_paths/src/module1.py +0 -0
  1161. package/src/tests/samples/project_src_with_extra_paths/src/_vendored/vendored1.py +0 -1
  1162. package/src/tests/samples/project_src_with_extra_paths/src/module1.py +0 -2
  1163. package/src/tests/samples/project_with_pyproject_toml/pyproject.toml +0 -7
  1164. package/src/tests/samples/project_with_venv_auto_detect_exclude/myvenv/Lib/site-packages/library1.py +0 -0
  1165. package/src/tests/samples/project_with_venv_auto_detect_exclude/myvenv/pyvenv.cfg +0 -0
  1166. package/src/tests/samples/project_with_venv_auto_detect_exclude/pyrightconfig.json +0 -2
  1167. package/src/tests/samples/project_with_venv_auto_detect_exclude/sample1.py +0 -0
  1168. package/src/tests/samples/project_with_venv_auto_detect_exclude/subfolder1/sample2.py +0 -0
  1169. package/src/tests/samples/project_with_venv_auto_detect_exclude/subfolder1/subfolder1-1/sample3.py +0 -0
  1170. package/src/tests/samples/project_with_venv_auto_detect_include/excluded/excluded1.py +0 -0
  1171. package/src/tests/samples/project_with_venv_auto_detect_include/myvenv/Lib/site-packages/library1.py +0 -0
  1172. package/src/tests/samples/project_with_venv_auto_detect_include/myvenv/pyvenv.cfg +0 -0
  1173. package/src/tests/samples/project_with_venv_auto_detect_include/pyrightconfig.json +0 -3
  1174. package/src/tests/samples/project_with_venv_auto_detect_include/sample1.py +0 -0
  1175. package/src/tests/samples/project_with_venv_auto_detect_include/subfolder1/sample2.py +0 -0
  1176. package/src/tests/samples/project_with_venv_auto_detect_include/subfolder1/subfolder1-1/sample3.py +0 -0
  1177. package/src/tests/samples/properties1.py +0 -64
  1178. package/src/tests/samples/properties10.py +0 -19
  1179. package/src/tests/samples/properties11.py +0 -45
  1180. package/src/tests/samples/properties12.py +0 -23
  1181. package/src/tests/samples/properties13.py +0 -15
  1182. package/src/tests/samples/properties2.py +0 -34
  1183. package/src/tests/samples/properties3.py +0 -93
  1184. package/src/tests/samples/properties4.py +0 -17
  1185. package/src/tests/samples/properties5.py +0 -29
  1186. package/src/tests/samples/properties6.py +0 -35
  1187. package/src/tests/samples/properties7.py +0 -30
  1188. package/src/tests/samples/properties8.py +0 -26
  1189. package/src/tests/samples/properties9.py +0 -24
  1190. package/src/tests/samples/protocol1.py +0 -132
  1191. package/src/tests/samples/protocol10.py +0 -36
  1192. package/src/tests/samples/protocol11.py +0 -32
  1193. package/src/tests/samples/protocol12.py +0 -12
  1194. package/src/tests/samples/protocol13.py +0 -26
  1195. package/src/tests/samples/protocol14.py +0 -27
  1196. package/src/tests/samples/protocol15.py +0 -27
  1197. package/src/tests/samples/protocol16.py +0 -22
  1198. package/src/tests/samples/protocol17.py +0 -94
  1199. package/src/tests/samples/protocol18.py +0 -27
  1200. package/src/tests/samples/protocol19.py +0 -39
  1201. package/src/tests/samples/protocol2.py +0 -38
  1202. package/src/tests/samples/protocol20.py +0 -22
  1203. package/src/tests/samples/protocol21.py +0 -26
  1204. package/src/tests/samples/protocol22.py +0 -43
  1205. package/src/tests/samples/protocol23.py +0 -41
  1206. package/src/tests/samples/protocol24.py +0 -74
  1207. package/src/tests/samples/protocol25.py +0 -31
  1208. package/src/tests/samples/protocol26.py +0 -40
  1209. package/src/tests/samples/protocol27.py +0 -76
  1210. package/src/tests/samples/protocol28.py +0 -32
  1211. package/src/tests/samples/protocol29.py +0 -26
  1212. package/src/tests/samples/protocol3.py +0 -110
  1213. package/src/tests/samples/protocol30.py +0 -30
  1214. package/src/tests/samples/protocol31.py +0 -22
  1215. package/src/tests/samples/protocol32.py +0 -67
  1216. package/src/tests/samples/protocol33.py +0 -39
  1217. package/src/tests/samples/protocol34.py +0 -21
  1218. package/src/tests/samples/protocol4.py +0 -22
  1219. package/src/tests/samples/protocol5.py +0 -25
  1220. package/src/tests/samples/protocol6.py +0 -65
  1221. package/src/tests/samples/protocol7.py +0 -24
  1222. package/src/tests/samples/protocol8.py +0 -34
  1223. package/src/tests/samples/protocol9.py +0 -35
  1224. package/src/tests/samples/protocolModule1.py +0 -15
  1225. package/src/tests/samples/protocolModule2.py +0 -83
  1226. package/src/tests/samples/protocolModule3.py +0 -14
  1227. package/src/tests/samples/protocolModule4.py +0 -26
  1228. package/src/tests/samples/pseudoGeneric1.py +0 -20
  1229. package/src/tests/samples/pyrightIgnore1.py +0 -11
  1230. package/src/tests/samples/pyrightIgnore2.py +0 -24
  1231. package/src/tests/samples/python2.py +0 -31
  1232. package/src/tests/samples/recursiveTypeAlias1.py +0 -79
  1233. package/src/tests/samples/recursiveTypeAlias2.py +0 -32
  1234. package/src/tests/samples/recursiveTypeAlias3.py +0 -26
  1235. package/src/tests/samples/recursiveTypeAlias4.py +0 -55
  1236. package/src/tests/samples/recursiveTypeAlias5.pyi +0 -10
  1237. package/src/tests/samples/recursiveTypeAlias6.py +0 -25
  1238. package/src/tests/samples/recursiveTypeAlias7.py +0 -15
  1239. package/src/tests/samples/recursiveTypeAlias8.py +0 -38
  1240. package/src/tests/samples/recursiveTypeAlias9.py +0 -22
  1241. package/src/tests/samples/required1.py +0 -47
  1242. package/src/tests/samples/required2.py +0 -56
  1243. package/src/tests/samples/required3.py +0 -22
  1244. package/src/tests/samples/returnTypes1.py +0 -26
  1245. package/src/tests/samples/revealedType1.py +0 -30
  1246. package/src/tests/samples/sample1.py +0 -6
  1247. package/src/tests/samples/self1.py +0 -93
  1248. package/src/tests/samples/self2.py +0 -195
  1249. package/src/tests/samples/self3.py +0 -9
  1250. package/src/tests/samples/self4.py +0 -18
  1251. package/src/tests/samples/self5.py +0 -26
  1252. package/src/tests/samples/setComprehension1.py +0 -34
  1253. package/src/tests/samples/slots1.py +0 -63
  1254. package/src/tests/samples/slots2.py +0 -38
  1255. package/src/tests/samples/slots3.py +0 -35
  1256. package/src/tests/samples/specialization1.py +0 -78
  1257. package/src/tests/samples/specialization2.py +0 -51
  1258. package/src/tests/samples/staticExpressions1.py +0 -52
  1259. package/src/tests/samples/strings1.py +0 -22
  1260. package/src/tests/samples/subscript1.py +0 -74
  1261. package/src/tests/samples/subscript2.py +0 -55
  1262. package/src/tests/samples/subscript3.py +0 -135
  1263. package/src/tests/samples/suiteExpectedColon1.py +0 -4
  1264. package/src/tests/samples/suiteExpectedColon2.py +0 -2
  1265. package/src/tests/samples/suiteExpectedColon3.py +0 -2
  1266. package/src/tests/samples/super1.py +0 -57
  1267. package/src/tests/samples/super2.py +0 -29
  1268. package/src/tests/samples/super3.py +0 -10
  1269. package/src/tests/samples/super4.py +0 -24
  1270. package/src/tests/samples/super5.py +0 -28
  1271. package/src/tests/samples/super6.py +0 -17
  1272. package/src/tests/samples/super7.py +0 -52
  1273. package/src/tests/samples/super8.py +0 -7
  1274. package/src/tests/samples/super9.py +0 -36
  1275. package/src/tests/samples/test_file1.py +0 -0
  1276. package/src/tests/samples/threePartVersion1.py +0 -33
  1277. package/src/tests/samples/totalOrdering1.py +0 -52
  1278. package/src/tests/samples/tryExcept1.py +0 -39
  1279. package/src/tests/samples/tryExcept10.py +0 -12
  1280. package/src/tests/samples/tryExcept2.py +0 -16
  1281. package/src/tests/samples/tryExcept3.py +0 -12
  1282. package/src/tests/samples/tryExcept4.py +0 -28
  1283. package/src/tests/samples/tryExcept5.py +0 -30
  1284. package/src/tests/samples/tryExcept6.py +0 -27
  1285. package/src/tests/samples/tryExcept7.py +0 -17
  1286. package/src/tests/samples/tryExcept8.py +0 -69
  1287. package/src/tests/samples/tryExcept9.py +0 -42
  1288. package/src/tests/samples/tupleUnpack1.py +0 -63
  1289. package/src/tests/samples/tupleUnpack2.py +0 -56
  1290. package/src/tests/samples/tupleUnpack3.py +0 -28
  1291. package/src/tests/samples/tuples1.py +0 -185
  1292. package/src/tests/samples/tuples10.py +0 -30
  1293. package/src/tests/samples/tuples11.py +0 -21
  1294. package/src/tests/samples/tuples12.py +0 -31
  1295. package/src/tests/samples/tuples13.py +0 -26
  1296. package/src/tests/samples/tuples15.py +0 -16
  1297. package/src/tests/samples/tuples16.py +0 -14
  1298. package/src/tests/samples/tuples2.py +0 -23
  1299. package/src/tests/samples/tuples3.py +0 -15
  1300. package/src/tests/samples/tuples4.py +0 -21
  1301. package/src/tests/samples/tuples5.py +0 -16
  1302. package/src/tests/samples/tuples6.py +0 -56
  1303. package/src/tests/samples/tuples7.py +0 -61
  1304. package/src/tests/samples/tuples8.py +0 -98
  1305. package/src/tests/samples/tuples9.py +0 -17
  1306. package/src/tests/samples/typeAlias1.py +0 -37
  1307. package/src/tests/samples/typeAlias10.py +0 -45
  1308. package/src/tests/samples/typeAlias11.py +0 -37
  1309. package/src/tests/samples/typeAlias12.py +0 -20
  1310. package/src/tests/samples/typeAlias13.py +0 -53
  1311. package/src/tests/samples/typeAlias14.py +0 -29
  1312. package/src/tests/samples/typeAlias15.py +0 -24
  1313. package/src/tests/samples/typeAlias16.py +0 -24
  1314. package/src/tests/samples/typeAlias2.py +0 -26
  1315. package/src/tests/samples/typeAlias3.py +0 -35
  1316. package/src/tests/samples/typeAlias4.py +0 -68
  1317. package/src/tests/samples/typeAlias5.py +0 -56
  1318. package/src/tests/samples/typeAlias6.py +0 -51
  1319. package/src/tests/samples/typeAlias7.py +0 -50
  1320. package/src/tests/samples/typeAlias8.py +0 -24
  1321. package/src/tests/samples/typeAlias9.py +0 -35
  1322. package/src/tests/samples/typeGuard1.py +0 -68
  1323. package/src/tests/samples/typeGuard2.py +0 -58
  1324. package/src/tests/samples/typeGuard3.py +0 -98
  1325. package/src/tests/samples/typeIgnore1.py +0 -10
  1326. package/src/tests/samples/typeIgnore2.py +0 -20
  1327. package/src/tests/samples/typeIgnore3.py +0 -22
  1328. package/src/tests/samples/typeIgnore4.py +0 -10
  1329. package/src/tests/samples/typeIgnore5.py +0 -7
  1330. package/src/tests/samples/typeNarrowing1.py +0 -56
  1331. package/src/tests/samples/typeNarrowing2.py +0 -14
  1332. package/src/tests/samples/typeNarrowing3.py +0 -47
  1333. package/src/tests/samples/typeNarrowing4.py +0 -24
  1334. package/src/tests/samples/typeNarrowing5.py +0 -19
  1335. package/src/tests/samples/typeNarrowing6.py +0 -27
  1336. package/src/tests/samples/typeNarrowing7.py +0 -71
  1337. package/src/tests/samples/typeNarrowingAssert1.py +0 -24
  1338. package/src/tests/samples/typeNarrowingCallable1.py +0 -78
  1339. package/src/tests/samples/typeNarrowingEnum1.py +0 -58
  1340. package/src/tests/samples/typeNarrowingEnum2.py +0 -71
  1341. package/src/tests/samples/typeNarrowingFalsy1.py +0 -50
  1342. package/src/tests/samples/typeNarrowingIn1.py +0 -97
  1343. package/src/tests/samples/typeNarrowingIsNone1.py +0 -56
  1344. package/src/tests/samples/typeNarrowingIsNone2.py +0 -8
  1345. package/src/tests/samples/typeNarrowingIsNoneTuple1.py +0 -42
  1346. package/src/tests/samples/typeNarrowingIsNoneTuple2.py +0 -35
  1347. package/src/tests/samples/typeNarrowingIsinstance1.py +0 -162
  1348. package/src/tests/samples/typeNarrowingIsinstance2.py +0 -14
  1349. package/src/tests/samples/typeNarrowingIsinstance3.py +0 -78
  1350. package/src/tests/samples/typeNarrowingIsinstance4.py +0 -50
  1351. package/src/tests/samples/typeNarrowingIsinstance5.py +0 -39
  1352. package/src/tests/samples/typeNarrowingIsinstance6.py +0 -77
  1353. package/src/tests/samples/typeNarrowingIsinstance7.py +0 -19
  1354. package/src/tests/samples/typeNarrowingIsinstance8.py +0 -19
  1355. package/src/tests/samples/typeNarrowingLiteral1.py +0 -35
  1356. package/src/tests/samples/typeNarrowingLiteral2.py +0 -63
  1357. package/src/tests/samples/typeNarrowingLiteralMember1.py +0 -140
  1358. package/src/tests/samples/typeNarrowingLocalConst1.py +0 -136
  1359. package/src/tests/samples/typeNarrowingNoneMember1.py +0 -102
  1360. package/src/tests/samples/typeNarrowingTuple1.py +0 -23
  1361. package/src/tests/samples/typeNarrowingTupleLength1.py +0 -47
  1362. package/src/tests/samples/typeNarrowingTypeIs1.py +0 -95
  1363. package/src/tests/samples/typeNarrowingTypedDict1.py +0 -99
  1364. package/src/tests/samples/typeNarrowingTypedDict2.py +0 -35
  1365. package/src/tests/samples/typeNarrowingTypedDict3.py +0 -45
  1366. package/src/tests/samples/typePromotions1.py +0 -30
  1367. package/src/tests/samples/typeVar1.py +0 -23
  1368. package/src/tests/samples/typeVar10.py +0 -21
  1369. package/src/tests/samples/typeVar11.py +0 -12
  1370. package/src/tests/samples/typeVar2.py +0 -26
  1371. package/src/tests/samples/typeVar3.py +0 -73
  1372. package/src/tests/samples/typeVar4.py +0 -45
  1373. package/src/tests/samples/typeVar5.py +0 -75
  1374. package/src/tests/samples/typeVar6.py +0 -115
  1375. package/src/tests/samples/typeVar7.py +0 -171
  1376. package/src/tests/samples/typeVar8.py +0 -30
  1377. package/src/tests/samples/typeVar9.py +0 -118
  1378. package/src/tests/samples/typedDict1.py +0 -63
  1379. package/src/tests/samples/typedDict10.py +0 -34
  1380. package/src/tests/samples/typedDict11.py +0 -12
  1381. package/src/tests/samples/typedDict12.py +0 -103
  1382. package/src/tests/samples/typedDict13.py +0 -14
  1383. package/src/tests/samples/typedDict14.py +0 -25
  1384. package/src/tests/samples/typedDict15.py +0 -53
  1385. package/src/tests/samples/typedDict16.py +0 -103
  1386. package/src/tests/samples/typedDict17.py +0 -24
  1387. package/src/tests/samples/typedDict18.py +0 -43
  1388. package/src/tests/samples/typedDict2.py +0 -56
  1389. package/src/tests/samples/typedDict3.py +0 -40
  1390. package/src/tests/samples/typedDict4.py +0 -68
  1391. package/src/tests/samples/typedDict5.py +0 -50
  1392. package/src/tests/samples/typedDict6.py +0 -77
  1393. package/src/tests/samples/typedDict7.py +0 -22
  1394. package/src/tests/samples/typedDict8.py +0 -19
  1395. package/src/tests/samples/typedDict9.py +0 -22
  1396. package/src/tests/samples/unbound1.py +0 -18
  1397. package/src/tests/samples/unbound2.py +0 -12
  1398. package/src/tests/samples/unbound3.py +0 -13
  1399. package/src/tests/samples/unbound4.py +0 -25
  1400. package/src/tests/samples/unicode1.py +0 -39
  1401. package/src/tests/samples/uninitializedVariable1.py +0 -27
  1402. package/src/tests/samples/unions1.py +0 -79
  1403. package/src/tests/samples/unions2.py +0 -15
  1404. package/src/tests/samples/unions3.py +0 -48
  1405. package/src/tests/samples/unions4.py +0 -20
  1406. package/src/tests/samples/unions5.py +0 -43
  1407. package/src/tests/samples/unnecessaryCast1.py +0 -13
  1408. package/src/tests/samples/unnecessaryIsInstance1.py +0 -91
  1409. package/src/tests/samples/unnecessaryIsSubclass1.py +0 -22
  1410. package/src/tests/samples/unpack1.py +0 -56
  1411. package/src/tests/samples/unpack2.py +0 -27
  1412. package/src/tests/samples/unpack3.py +0 -16
  1413. package/src/tests/samples/unpack4.py +0 -15
  1414. package/src/tests/samples/unreachable1.py +0 -112
  1415. package/src/tests/samples/unusedCallResult1.py +0 -67
  1416. package/src/tests/samples/unusedCoroutine1.py +0 -23
  1417. package/src/tests/samples/unusedExpression1.py +0 -34
  1418. package/src/tests/samples/unusedVariable1.py +0 -21
  1419. package/src/tests/samples/variadicTypeVar1.py +0 -51
  1420. package/src/tests/samples/variadicTypeVar10.py +0 -65
  1421. package/src/tests/samples/variadicTypeVar11.py +0 -72
  1422. package/src/tests/samples/variadicTypeVar12.py +0 -26
  1423. package/src/tests/samples/variadicTypeVar13.py +0 -35
  1424. package/src/tests/samples/variadicTypeVar14.py +0 -72
  1425. package/src/tests/samples/variadicTypeVar2.py +0 -63
  1426. package/src/tests/samples/variadicTypeVar3.py +0 -86
  1427. package/src/tests/samples/variadicTypeVar4.py +0 -71
  1428. package/src/tests/samples/variadicTypeVar5.py +0 -131
  1429. package/src/tests/samples/variadicTypeVar6.py +0 -78
  1430. package/src/tests/samples/variadicTypeVar7.py +0 -59
  1431. package/src/tests/samples/variadicTypeVar8.py +0 -116
  1432. package/src/tests/samples/variadicTypeVar9.py +0 -38
  1433. package/src/tests/samples/with1.py +0 -117
  1434. package/src/tests/samples/with2.py +0 -63
  1435. package/src/tests/samples/with3.py +0 -66
  1436. package/src/tests/samples/with4.py +0 -24
  1437. package/src/tests/samples/with5.py +0 -33
  1438. package/src/tests/samples/zipfs/bad.egg +0 -1
  1439. package/src/tests/samples/zipfs/bad.zip +0 -1
  1440. package/src/tests/samples/zipfs/basic.egg +0 -0
  1441. package/src/tests/samples/zipfs/basic.zip +0 -0
  1442. package/src/tests/samples/zipfs/corrupt.egg +0 -0
  1443. package/src/tests/samples/zipfs/corrupt.zip +0 -0
  1444. package/src/tests/sourceFile.test.ts +0 -25
  1445. package/src/tests/stringUtils.test.ts +0 -63
  1446. package/src/tests/symbolNameUtils.test.ts +0 -77
  1447. package/src/tests/testState.test.ts +0 -579
  1448. package/src/tests/testUtils.ts +0 -251
  1449. package/src/tests/tokenizer.test.ts +0 -1534
  1450. package/src/tests/typeEvaluator1.test.ts +0 -1372
  1451. package/src/tests/typeEvaluator2.test.ts +0 -1253
  1452. package/src/tests/typeEvaluator3.test.ts +0 -1279
  1453. package/src/tests/typeEvaluator4.test.ts +0 -1178
  1454. package/src/tests/updateSymbolReference.test.ts +0 -1107
  1455. package/src/tests/zipfs.test.ts +0 -116
  1456. package/src/workspaceMap.ts +0 -76
@@ -1,2857 +0,0 @@
1
- /*
2
- * types.ts
3
- * Copyright (c) Microsoft Corporation.
4
- * Licensed under the MIT license.
5
- * Author: Eric Traut
6
- *
7
- * Representation of types used during type analysis within Python.
8
- */
9
-
10
- import { assert } from '../common/debug';
11
- import { ExpressionNode, ParameterCategory } from '../parser/parseNodes';
12
- import { FunctionDeclaration } from './declaration';
13
- import { Symbol, SymbolTable } from './symbol';
14
-
15
- export const enum TypeCategory {
16
- // Name is not bound to a value of any type.
17
- Unbound,
18
-
19
- // Type exists but is not currently known by the
20
- // type analyzer (e.g. there is no available typings file).
21
- // Unknown types are treated the same as "Any" at analysis time.
22
- Unknown,
23
-
24
- // Type can be anything.
25
- Any,
26
-
27
- // Special "None" type defined in Python.
28
- None,
29
-
30
- // Used in type narrowing to indicate that all possible
31
- // subtypes in a union have been eliminated, and execution
32
- // should never get to this point.
33
- Never,
34
-
35
- // Callable type with typed input parameters and return parameter.
36
- Function,
37
-
38
- // Functions defined with @overload decorator in stub files that
39
- // have multiple function declarations for a common implementation.
40
- OverloadedFunction,
41
-
42
- // Class definition, including associated instance methods,
43
- // class methods, static methods, properties, and variables.
44
- Class,
45
-
46
- // Module instance.
47
- Module,
48
-
49
- // Composite type (e.g. Number OR String OR None).
50
- Union,
51
-
52
- // Type variable (defined with TypeVar)
53
- TypeVar,
54
- }
55
-
56
- export const enum TypeFlags {
57
- None = 0,
58
-
59
- // This type refers to something that can be instantiated.
60
- Instantiable = 1 << 0,
61
-
62
- // This type refers to something that has been instantiated.
63
- Instance = 1 << 1,
64
-
65
- // This type refers to a type that is wrapped an "Annotated"
66
- // (PEP 593) annotation.
67
- Annotated = 1 << 2,
68
-
69
- // This type is a special form like "UnionType".
70
- SpecialForm = 1 << 3,
71
- }
72
-
73
- export type UnionableType =
74
- | UnboundType
75
- | UnknownType
76
- | AnyType
77
- | NoneType
78
- | FunctionType
79
- | OverloadedFunctionType
80
- | ClassType
81
- | ModuleType
82
- | TypeVarType;
83
-
84
- export type Type = UnionableType | NeverType | UnionType;
85
-
86
- export type TypeVarScopeId = string;
87
- export const WildcardTypeVarScopeId = '*';
88
-
89
- export class EnumLiteral {
90
- constructor(public className: string, public itemName: string, public itemType: Type) {}
91
- }
92
-
93
- export type LiteralValue = number | bigint | boolean | string | EnumLiteral;
94
-
95
- export type TypeSourceId = number;
96
- export const maxTypeRecursionCount = 14;
97
-
98
- export type InheritanceChain = (ClassType | UnknownType)[];
99
-
100
- interface TypeAliasInfo {
101
- name: string;
102
- fullName: string;
103
- typeParameters?: TypeVarType[] | undefined;
104
- typeArguments?: Type[] | undefined;
105
- typeVarScopeId: TypeVarScopeId;
106
- }
107
-
108
- interface TypeBase {
109
- category: TypeCategory;
110
- flags: TypeFlags;
111
-
112
- // Used to handle nested references to instantiable classes
113
- // (e.g. type[type[type[T]]]). If the field isn't present,
114
- // it is assumed to be zero.
115
- instantiableNestingLevel?: number;
116
-
117
- // Used only for type aliases
118
- typeAliasInfo?: TypeAliasInfo | undefined;
119
-
120
- // Used only for conditional (constrained) types
121
- condition?: TypeCondition[] | undefined;
122
-
123
- // This type is inferred within a py.typed source file and could be
124
- // inferred differently by other type checkers. We don't model this
125
- // with a TypeFlags because we don't want an ambiguous and unambiguous
126
- // type to be seen as distinct when comparing types.
127
- isAmbiguous?: boolean;
128
- }
129
-
130
- export namespace TypeBase {
131
- export function isInstantiable(type: TypeBase) {
132
- return (type.flags & TypeFlags.Instantiable) !== 0;
133
- }
134
-
135
- export function isInstance(type: TypeBase) {
136
- return (type.flags & TypeFlags.Instance) !== 0;
137
- }
138
-
139
- export function isAnnotated(type: TypeBase) {
140
- return (type.flags & TypeFlags.Annotated) !== 0;
141
- }
142
-
143
- export function isSpecialForm(type: TypeBase) {
144
- return (type.flags & TypeFlags.SpecialForm) !== 0;
145
- }
146
-
147
- export function setSpecialForm(type: TypeBase) {
148
- return (type.flags |= TypeFlags.SpecialForm);
149
- }
150
-
151
- export function isAmbiguous(type: TypeBase) {
152
- return !!type.isAmbiguous;
153
- }
154
-
155
- export function cloneType<T extends TypeBase>(type: T): T {
156
- return { ...type };
157
- }
158
-
159
- export function cloneTypeAsInstance<T extends TypeBase>(type: T): T {
160
- assert(TypeBase.isInstantiable(type));
161
-
162
- const newInstance = TypeBase.cloneType(type);
163
-
164
- if (newInstance.instantiableNestingLevel === undefined) {
165
- newInstance.flags &= ~TypeFlags.Instantiable;
166
- newInstance.flags |= TypeFlags.Instance;
167
- delete newInstance.instantiableNestingLevel;
168
- } else {
169
- if (newInstance.instantiableNestingLevel === 1) {
170
- delete newInstance.instantiableNestingLevel;
171
- } else {
172
- newInstance.instantiableNestingLevel--;
173
- }
174
- }
175
-
176
- return newInstance;
177
- }
178
-
179
- export function cloneTypeAsInstantiable<T extends TypeBase>(type: T): T {
180
- const newInstance: T = TypeBase.cloneType(type);
181
-
182
- if (TypeBase.isInstance(type)) {
183
- newInstance.flags &= ~TypeFlags.Instance;
184
- newInstance.flags |= TypeFlags.Instantiable;
185
- } else {
186
- newInstance.instantiableNestingLevel =
187
- newInstance.instantiableNestingLevel === undefined ? 1 : newInstance.instantiableNestingLevel;
188
- }
189
-
190
- return newInstance;
191
- }
192
-
193
- export function cloneForTypeAlias(
194
- type: Type,
195
- name: string,
196
- fullName: string,
197
- typeVarScopeId: TypeVarScopeId,
198
- typeParams?: TypeVarType[],
199
- typeArgs?: Type[]
200
- ): Type {
201
- const typeClone = cloneType(type);
202
-
203
- typeClone.typeAliasInfo = {
204
- name,
205
- fullName,
206
- typeParameters: typeParams,
207
- typeArguments: typeArgs,
208
- typeVarScopeId,
209
- };
210
-
211
- return typeClone;
212
- }
213
-
214
- export function cloneForAnnotated(type: Type) {
215
- const typeClone = cloneType(type);
216
- typeClone.flags |= TypeFlags.Annotated;
217
- return typeClone;
218
- }
219
-
220
- export function cloneForCondition<T extends Type>(type: T, condition: TypeCondition[] | undefined): T {
221
- // Handle the common case where there are no conditions. In this case,
222
- // cloning isn't necessary.
223
- if (type.condition === undefined && condition === undefined) {
224
- return type;
225
- }
226
-
227
- const typeClone = cloneType(type);
228
- typeClone.condition = condition;
229
- return typeClone;
230
- }
231
-
232
- export function cloneForAmbiguousType(type: Type) {
233
- if (type.isAmbiguous) {
234
- return type;
235
- }
236
-
237
- const typeClone = cloneType(type);
238
- typeClone.isAmbiguous = true;
239
- return typeClone;
240
- }
241
- }
242
-
243
- export interface UnboundType extends TypeBase {
244
- category: TypeCategory.Unbound;
245
- }
246
-
247
- export namespace UnboundType {
248
- const _instance: UnboundType = {
249
- category: TypeCategory.Unbound,
250
- flags: TypeFlags.Instantiable | TypeFlags.Instance,
251
- };
252
-
253
- export function create() {
254
- // All Unbound objects are the same, so use a shared instance.
255
- return _instance;
256
- }
257
- }
258
-
259
- export interface UnknownType extends TypeBase {
260
- category: TypeCategory.Unknown;
261
- isIncomplete: boolean;
262
- }
263
-
264
- export namespace UnknownType {
265
- const _instance: UnknownType = {
266
- category: TypeCategory.Unknown,
267
- flags: TypeFlags.Instantiable | TypeFlags.Instance,
268
- isIncomplete: false,
269
- };
270
- const _incompleteInstance: UnknownType = {
271
- category: TypeCategory.Unknown,
272
- flags: TypeFlags.Instantiable | TypeFlags.Instance,
273
- isIncomplete: true,
274
- };
275
-
276
- export function create(isIncomplete = false) {
277
- return isIncomplete ? _incompleteInstance : _instance;
278
- }
279
- }
280
-
281
- export interface ModuleType extends TypeBase {
282
- category: TypeCategory.Module;
283
- fields: SymbolTable;
284
- docString?: string | undefined;
285
-
286
- // A "loader" module includes symbols that were injected by
287
- // the module loader. We keep these separate so we don't
288
- // pollute the symbols exported by the module itself.
289
- loaderFields: SymbolTable;
290
-
291
- // The period-delimited import name of this module.
292
- moduleName: string;
293
-
294
- filePath: string;
295
- }
296
-
297
- export namespace ModuleType {
298
- export function create(moduleName: string, filePath: string, symbolTable?: SymbolTable) {
299
- const newModuleType: ModuleType = {
300
- category: TypeCategory.Module,
301
- fields: symbolTable || new Map<string, Symbol>(),
302
- loaderFields: new Map<string, Symbol>(),
303
- flags: TypeFlags.Instantiable | TypeFlags.Instantiable,
304
- moduleName,
305
- filePath,
306
- };
307
- return newModuleType;
308
- }
309
-
310
- export function getField(moduleType: ModuleType, name: string): Symbol | undefined {
311
- // Always look for the symbol in the module's fields before consulting
312
- // the loader fields. The loader runs before the module, so its values
313
- // will be overwritten by the module.
314
- let symbol = moduleType.fields.get(name);
315
-
316
- if (moduleType.loaderFields) {
317
- if (!symbol) {
318
- symbol = moduleType.loaderFields.get(name);
319
- } else if (symbol.isExternallyHidden()) {
320
- // If the symbol is hidden when accessed via the module but is
321
- // also accessible through a loader field, use the latter so it
322
- // isn't flagged as an error.
323
- const loaderSymbol = moduleType.loaderFields.get(name);
324
- if (loaderSymbol && !loaderSymbol.isExternallyHidden()) {
325
- symbol = loaderSymbol;
326
- }
327
- }
328
- }
329
- return symbol;
330
- }
331
- }
332
-
333
- export interface DataClassEntry {
334
- name: string;
335
- classType: ClassType;
336
- isClassVar: boolean;
337
- isKeywordOnly: boolean;
338
- alias?: string | undefined;
339
- hasDefault?: boolean | undefined;
340
- defaultValueExpression?: ExpressionNode | undefined;
341
- includeInInit: boolean;
342
- type: Type;
343
- }
344
-
345
- export interface TypedDictEntry {
346
- valueType: Type;
347
- isRequired: boolean;
348
- isProvided: boolean;
349
- }
350
-
351
- export const enum ClassTypeFlags {
352
- None = 0,
353
-
354
- // Class is defined in the "builtins" or "typing" file.
355
- BuiltInClass = 1 << 0,
356
-
357
- // Class requires special-case handling because it
358
- // exhibits non-standard behavior or is not defined
359
- // formally as a class. Examples include 'Optional'
360
- // and 'Union'.
361
- SpecialBuiltIn = 1 << 1,
362
-
363
- // Introduced in Python 3.7 - class either derives directly
364
- // from NamedTuple or has a @dataclass class decorator.
365
- DataClass = 1 << 2,
366
-
367
- // Indicates that the dataclass is frozen.
368
- FrozenDataClass = 1 << 3,
369
-
370
- // Flags that control whether methods should be
371
- // synthesized for a dataclass class.
372
- SkipSynthesizedDataClassInit = 1 << 4,
373
- SkipSynthesizedDataClassEq = 1 << 5,
374
- SynthesizedDataClassOrder = 1 << 6,
375
-
376
- // Introduced in PEP 589, TypedDict classes provide a way
377
- // to specify type hints for dictionaries with different
378
- // value types and a limited set of static keys.
379
- TypedDictClass = 1 << 7,
380
-
381
- // Used in conjunction with TypedDictClass, indicates that
382
- // the dictionary values can be omitted.
383
- CanOmitDictValues = 1 << 8,
384
-
385
- // The class derives from a class that has the ABCMeta
386
- // metaclass. Such classes are allowed to contain
387
- // @abstractmethod decorators.
388
- SupportsAbstractMethods = 1 << 9,
389
-
390
- // Derives from property class and has the semantics of
391
- // a property (with optional setter, deleter).
392
- PropertyClass = 1 << 11,
393
-
394
- // The class is decorated with a "@final" decorator
395
- // indicating that it cannot be subclassed.
396
- Final = 1 << 12,
397
-
398
- // The class derives directly from "Protocol".
399
- ProtocolClass = 1 << 13,
400
-
401
- // A class whose constructor (__init__ method) does not have
402
- // annotated types and is treated as though each parameter
403
- // is a generic type for purposes of type inference.
404
- PseudoGenericClass = 1 << 14,
405
-
406
- // A protocol class that is "runtime checkable" can be used
407
- // in an isinstance call.
408
- RuntimeCheckable = 1 << 15,
409
-
410
- // The type is defined in the typing_extensions.pyi file.
411
- TypingExtensionClass = 1 << 16,
412
-
413
- // The class type is in the process of being evaluated and
414
- // is not yet complete. This allows us to detect cases where
415
- // the class refers to itself (e.g. uses itself as a type
416
- // argument to one of its generic base classes).
417
- PartiallyEvaluated = 1 << 17,
418
-
419
- // The class or one of its ancestors defines a __class_getitem__
420
- // method that is used for subscripting. This is not set if the
421
- // class is generic, and therefore supports standard subscripting
422
- // semantics.
423
- HasCustomClassGetItem = 1 << 18,
424
-
425
- // The tuple class uses a variadic type parameter and requires
426
- // special-case handling of its type arguments.
427
- TupleClass = 1 << 19,
428
-
429
- // The class has a metaclass of EnumMet or derives from
430
- // a class that has this metaclass.
431
- EnumClass = 1 << 20,
432
-
433
- // For dataclasses, should __init__ method always be generated
434
- // with keyword-only parameters?
435
- DataClassKeywordOnlyParams = 1 << 21,
436
-
437
- // Properties that are defined using the @classmethod decorator.
438
- ClassProperty = 1 << 22,
439
-
440
- // Class is declared within a type stub file.
441
- DefinedInStub = 1 << 23,
442
-
443
- // Class does not allow writing or deleting its instance variables
444
- // through a member access. Used with named tuples.
445
- ReadOnlyInstanceVariables = 1 << 24,
446
-
447
- // For dataclasses, should __slots__ be generated?
448
- GenerateDataClassSlots = 1 << 25,
449
-
450
- // For dataclasses, should __hash__ be generated?
451
- SynthesizeDataClassUnsafeHash = 1 << 26,
452
- }
453
-
454
- export interface DataClassBehaviors {
455
- keywordOnlyParams: boolean;
456
- generateEq: boolean;
457
- generateOrder: boolean;
458
- fieldDescriptorNames: string[];
459
- }
460
-
461
- interface ClassDetails {
462
- name: string;
463
- fullName: string;
464
- moduleName: string;
465
- filePath: string;
466
- flags: ClassTypeFlags;
467
- typeSourceId: TypeSourceId;
468
- baseClasses: Type[];
469
- mro: Type[];
470
- declaredMetaclass?: ClassType | UnknownType | undefined;
471
- effectiveMetaclass?: ClassType | UnknownType | undefined;
472
- fields: SymbolTable;
473
- typeParameters: TypeVarType[];
474
- typeVarScopeId?: TypeVarScopeId | undefined;
475
- docString?: string | undefined;
476
- dataClassEntries?: DataClassEntry[] | undefined;
477
- dataClassBehaviors?: DataClassBehaviors | undefined;
478
- typedDictEntries?: Map<string, TypedDictEntry> | undefined;
479
- inheritedSlotsNames?: string[];
480
- localSlotsNames?: string[];
481
-
482
- // A cache of protocol classes (indexed by the class full name)
483
- // that have been determined to be compatible with this class.
484
- compatibleProtocols?: Set<string>;
485
-
486
- // Transforms to apply if this class is used as a metaclass
487
- // or a base class.
488
- classDataClassTransform?: DataClassBehaviors | undefined;
489
- }
490
-
491
- export interface TupleTypeArgument {
492
- type: Type;
493
-
494
- // Does the type argument represent a single value or
495
- // an "unbounded" (zero or more) arguments?
496
- isUnbounded: boolean;
497
- }
498
-
499
- export interface ClassType extends TypeBase {
500
- category: TypeCategory.Class;
501
-
502
- details: ClassDetails;
503
-
504
- // A generic class that has been completely or partially
505
- // specialized will have type arguments that correspond to
506
- // some or all of the type parameters.
507
- typeArguments?: Type[] | undefined;
508
-
509
- // A bool value that has been returned by a user-defined
510
- // type guard (see PEP 647) will have additional type information
511
- // that indicates how a type should be narrowed. This field will
512
- // be used only in a bool class.
513
- typeGuardType?: Type | undefined;
514
- isStrictTypeGuard?: boolean;
515
-
516
- // If a generic container class (like a list or dict) is known
517
- // to contain no elements, its type arguments may be "Unknown".
518
- // This value allows us to elide the Unknown when it's safe to
519
- // do so.
520
- isEmptyContainer?: boolean | undefined;
521
-
522
- // For tuples, the class definition calls for a single type parameter but
523
- // the spec allows the programmer to provide an arbitrary number of
524
- // type arguments. This field holds the individual type arguments
525
- // while the "typeArguments" field holds the derived non-variadic
526
- // type argument, which is the union of the tuple type arguments.
527
- tupleTypeArguments?: TupleTypeArgument[] | undefined;
528
-
529
- // We sometimes package multiple types into a tuple internally
530
- // for matching against a variadic type variable or another unpacked
531
- // tuple. We need to be able to distinguish this case from normal tuples.
532
- isUnpacked?: boolean | undefined;
533
-
534
- // If type arguments are present, were they explicit (i.e.
535
- // provided explicitly in the code)?
536
- isTypeArgumentExplicit?: boolean | undefined;
537
-
538
- // This class type represents the class and any classes that
539
- // derive from it, as opposed to the original class only. This
540
- // distinction is important in certain scenarios like instantiation
541
- // of abstract or protocol classes.
542
- includeSubclasses?: boolean;
543
-
544
- // Some types can be further constrained to have
545
- // literal types (e.g. true or 'string' or 3).
546
- literalValue?: LiteralValue | undefined;
547
-
548
- // The typing module defines aliases for builtin types
549
- // (e.g. Tuple, List, Dict). This field holds the alias
550
- // name.
551
- aliasName?: string | undefined;
552
-
553
- // Used for "narrowing" of typed dicts where some entries
554
- // that are not required have been confirmed to be present
555
- // through the use of a guard expression.
556
- typedDictNarrowedEntries?: Map<string, TypedDictEntry> | undefined;
557
-
558
- // Indicates whether the class is an asymmetric descriptor
559
- // or property - one where the __get__ and __set__ types differ.
560
- // If undefined, it hasn't been tested yet for asymmetry.
561
- isAsymmetricDescriptor?: boolean;
562
- }
563
-
564
- export namespace ClassType {
565
- export function createInstantiable(
566
- name: string,
567
- fullName: string,
568
- moduleName: string,
569
- filePath: string,
570
- flags: ClassTypeFlags,
571
- typeSourceId: TypeSourceId,
572
- declaredMetaclass: ClassType | UnknownType | undefined,
573
- effectiveMetaclass: ClassType | UnknownType | undefined,
574
- docString?: string
575
- ) {
576
- const newClass: ClassType = {
577
- category: TypeCategory.Class,
578
- details: {
579
- name,
580
- fullName,
581
- moduleName,
582
- filePath,
583
- flags,
584
- typeSourceId,
585
- baseClasses: [],
586
- declaredMetaclass,
587
- effectiveMetaclass,
588
- mro: [],
589
- fields: new Map<string, Symbol>(),
590
- typeParameters: [],
591
- docString,
592
- },
593
- flags: TypeFlags.Instantiable,
594
- };
595
-
596
- return newClass;
597
- }
598
-
599
- export function cloneAsInstance(type: ClassType): ClassType {
600
- if (TypeBase.isInstance(type)) {
601
- return type;
602
- }
603
-
604
- const newInstance = TypeBase.cloneTypeAsInstance(type);
605
- newInstance.flags &= ~TypeFlags.SpecialForm;
606
- newInstance.includeSubclasses = true;
607
- return newInstance;
608
- }
609
-
610
- export function cloneAsInstantiable(objectType: ClassType): ClassType {
611
- return TypeBase.cloneTypeAsInstantiable(objectType);
612
- }
613
-
614
- export function cloneForSpecialization(
615
- classType: ClassType,
616
- typeArguments: Type[] | undefined,
617
- isTypeArgumentExplicit: boolean,
618
- includeSubclasses = false,
619
- tupleTypeArguments?: TupleTypeArgument[],
620
- isEmptyContainer?: boolean
621
- ): ClassType {
622
- const newClassType = TypeBase.cloneType(classType);
623
-
624
- // Never should never appear as a type argument, so replace it with
625
- newClassType.typeArguments = typeArguments
626
- ? typeArguments.map((t) => (isNever(t) && !t.isNoReturn ? UnknownType.create() : t))
627
- : undefined;
628
-
629
- newClassType.isTypeArgumentExplicit = isTypeArgumentExplicit;
630
- if (includeSubclasses) {
631
- newClassType.includeSubclasses = true;
632
- }
633
- newClassType.tupleTypeArguments = tupleTypeArguments
634
- ? tupleTypeArguments.map((t) =>
635
- isNever(t.type) ? { type: UnknownType.create(), isUnbounded: t.isUnbounded } : t
636
- )
637
- : undefined;
638
-
639
- if (isEmptyContainer !== undefined) {
640
- newClassType.isEmptyContainer = isEmptyContainer;
641
- }
642
-
643
- return newClassType;
644
- }
645
-
646
- export function cloneWithLiteral(classType: ClassType, value: LiteralValue | undefined): ClassType {
647
- const newClassType = TypeBase.cloneType(classType);
648
- newClassType.literalValue = value;
649
- return newClassType;
650
- }
651
-
652
- export function cloneForTypingAlias(classType: ClassType, aliasName: string): ClassType {
653
- const newClassType = TypeBase.cloneType(classType);
654
- newClassType.aliasName = aliasName;
655
- return newClassType;
656
- }
657
-
658
- export function cloneForNarrowedTypedDictEntries(
659
- classType: ClassType,
660
- narrowedEntries?: Map<string, TypedDictEntry>
661
- ): ClassType {
662
- const newClassType = TypeBase.cloneType(classType);
663
- newClassType.typedDictNarrowedEntries = narrowedEntries;
664
- return newClassType;
665
- }
666
-
667
- export function cloneWithNewTypeParameters(classType: ClassType, typeParams: TypeVarType[]): ClassType {
668
- const newClassType = TypeBase.cloneType(classType);
669
- newClassType.details = { ...newClassType.details };
670
- newClassType.details.typeParameters = typeParams;
671
- return newClassType;
672
- }
673
-
674
- export function cloneForTypeGuard(
675
- classType: ClassType,
676
- typeGuardType: Type,
677
- isStrictTypeGuard: boolean
678
- ): ClassType {
679
- const newClassType = TypeBase.cloneType(classType);
680
- newClassType.typeGuardType = typeGuardType;
681
- newClassType.isStrictTypeGuard = isStrictTypeGuard;
682
- return newClassType;
683
- }
684
-
685
- export function cloneForSymbolTableUpdate(classType: ClassType): ClassType {
686
- const newClassType = TypeBase.cloneType(classType);
687
- newClassType.details = { ...newClassType.details };
688
- newClassType.details.fields = new Map(newClassType.details.fields);
689
- newClassType.details.mro = [...newClassType.details.mro];
690
- newClassType.details.mro[0] = cloneAsInstantiable(newClassType);
691
- return newClassType;
692
- }
693
-
694
- export function cloneForUnpacked(classType: ClassType, isUnpacked = true): ClassType {
695
- const newClassType = TypeBase.cloneType(classType);
696
- newClassType.isUnpacked = isUnpacked;
697
- return newClassType;
698
- }
699
-
700
- export function isLiteralValueSame(type1: ClassType, type2: ClassType): boolean {
701
- if (type1.literalValue === undefined) {
702
- return type2.literalValue === undefined;
703
- } else if (type2.literalValue === undefined) {
704
- return false;
705
- }
706
-
707
- if (type1.literalValue instanceof EnumLiteral) {
708
- if (type2.literalValue instanceof EnumLiteral) {
709
- return type1.literalValue.itemName === type2.literalValue.itemName;
710
- }
711
- return false;
712
- }
713
-
714
- return type1.literalValue === type2.literalValue;
715
- }
716
-
717
- // Is the class generic but not specialized?
718
- export function isUnspecialized(classType: ClassType) {
719
- return classType.details.typeParameters.length > 0 && classType.typeArguments === undefined;
720
- }
721
-
722
- export function isSpecialBuiltIn(classType: ClassType, className?: string) {
723
- if (!(classType.details.flags & ClassTypeFlags.SpecialBuiltIn) && !classType.aliasName) {
724
- return false;
725
- }
726
-
727
- if (className !== undefined) {
728
- return classType.details.name === className;
729
- }
730
-
731
- return true;
732
- }
733
-
734
- export function isBuiltIn(classType: ClassType, className?: string | string[]) {
735
- if (!(classType.details.flags & ClassTypeFlags.BuiltInClass)) {
736
- return false;
737
- }
738
-
739
- if (className !== undefined) {
740
- const classArray = Array.isArray(className) ? className : [className];
741
- return (
742
- classArray.some((name) => name === classType.details.name) ||
743
- classArray.some((name) => name === classType.aliasName)
744
- );
745
- }
746
-
747
- return true;
748
- }
749
-
750
- export function derivesFromAnyOrUnknown(classType: ClassType) {
751
- return classType.details.mro.some((mroClass) => !isClass(mroClass));
752
- }
753
-
754
- export function supportsAbstractMethods(classType: ClassType) {
755
- return !!(classType.details.flags & ClassTypeFlags.SupportsAbstractMethods);
756
- }
757
-
758
- export function isDataClass(classType: ClassType) {
759
- return !!(classType.details.flags & ClassTypeFlags.DataClass);
760
- }
761
-
762
- export function isSkipSynthesizedDataClassInit(classType: ClassType) {
763
- return !!(classType.details.flags & ClassTypeFlags.SkipSynthesizedDataClassInit);
764
- }
765
-
766
- export function isSkipSynthesizedDataClassEq(classType: ClassType) {
767
- return !!(classType.details.flags & ClassTypeFlags.SkipSynthesizedDataClassEq);
768
- }
769
-
770
- export function isFrozenDataClass(classType: ClassType) {
771
- return !!(classType.details.flags & ClassTypeFlags.FrozenDataClass);
772
- }
773
-
774
- export function isSynthesizedDataclassOrder(classType: ClassType) {
775
- return !!(classType.details.flags & ClassTypeFlags.SynthesizedDataClassOrder);
776
- }
777
-
778
- export function isDataClassKeywordOnlyParams(classType: ClassType) {
779
- return !!(classType.details.flags & ClassTypeFlags.DataClassKeywordOnlyParams);
780
- }
781
-
782
- export function isGeneratedDataClassSlots(classType: ClassType) {
783
- return !!(classType.details.flags & ClassTypeFlags.GenerateDataClassSlots);
784
- }
785
-
786
- export function isSynthesizeDataClassUnsafeHash(classType: ClassType) {
787
- return !!(classType.details.flags & ClassTypeFlags.SynthesizeDataClassUnsafeHash);
788
- }
789
-
790
- export function isTypedDictClass(classType: ClassType) {
791
- return !!(classType.details.flags & ClassTypeFlags.TypedDictClass);
792
- }
793
-
794
- export function isCanOmitDictValues(classType: ClassType) {
795
- return !!(classType.details.flags & ClassTypeFlags.CanOmitDictValues);
796
- }
797
-
798
- export function isEnumClass(classType: ClassType) {
799
- return !!(classType.details.flags & ClassTypeFlags.EnumClass);
800
- }
801
-
802
- export function isPropertyClass(classType: ClassType) {
803
- return !!(classType.details.flags & ClassTypeFlags.PropertyClass);
804
- }
805
-
806
- export function isClassProperty(classType: ClassType) {
807
- return !!(classType.details.flags & ClassTypeFlags.ClassProperty);
808
- }
809
-
810
- export function isFinal(classType: ClassType) {
811
- return !!(classType.details.flags & ClassTypeFlags.Final);
812
- }
813
-
814
- export function isProtocolClass(classType: ClassType) {
815
- return !!(classType.details.flags & ClassTypeFlags.ProtocolClass);
816
- }
817
-
818
- export function isDefinedInStub(classType: ClassType) {
819
- return !!(classType.details.flags & ClassTypeFlags.DefinedInStub);
820
- }
821
-
822
- export function isPseudoGenericClass(classType: ClassType) {
823
- return !!(classType.details.flags & ClassTypeFlags.PseudoGenericClass);
824
- }
825
-
826
- export function getDataClassEntries(classType: ClassType): DataClassEntry[] {
827
- return classType.details.dataClassEntries || [];
828
- }
829
-
830
- export function isRuntimeCheckable(classType: ClassType) {
831
- return !!(classType.details.flags & ClassTypeFlags.RuntimeCheckable);
832
- }
833
-
834
- export function isTypingExtensionClass(classType: ClassType) {
835
- return !!(classType.details.flags & ClassTypeFlags.TypingExtensionClass);
836
- }
837
-
838
- export function isPartiallyEvaluated(classType: ClassType) {
839
- return !!(classType.details.flags & ClassTypeFlags.PartiallyEvaluated);
840
- }
841
-
842
- export function hasCustomClassGetItem(classType: ClassType) {
843
- return !!(classType.details.flags & ClassTypeFlags.HasCustomClassGetItem);
844
- }
845
-
846
- export function isTupleClass(classType: ClassType) {
847
- return !!(classType.details.flags & ClassTypeFlags.TupleClass);
848
- }
849
-
850
- export function isReadOnlyInstanceVariables(classType: ClassType) {
851
- return !!(classType.details.flags & ClassTypeFlags.ReadOnlyInstanceVariables);
852
- }
853
-
854
- export function getTypeParameters(classType: ClassType) {
855
- return classType.details.typeParameters;
856
- }
857
-
858
- export function hasUnknownBaseClass(classType: ClassType) {
859
- return classType.details.mro.some((baseClass) => isAnyOrUnknown(baseClass));
860
- }
861
-
862
- // Similar to isPartiallyEvaluated except that it also looks at all of the
863
- // classes in the MRO list for this class to see if any of them are still
864
- // partially evaluated.
865
- export function isHierarchyPartiallyEvaluated(classType: ClassType) {
866
- return (
867
- ClassType.isPartiallyEvaluated(classType) ||
868
- classType.details.mro.some((mroClass) => isClass(mroClass) && ClassType.isPartiallyEvaluated(mroClass))
869
- );
870
- }
871
-
872
- // Same as isSame except that it doesn't compare type arguments.
873
- export function isSameGenericClass(classType: ClassType, type2: ClassType, recursionCount = 0) {
874
- if (recursionCount > maxTypeRecursionCount) {
875
- return true;
876
- }
877
- recursionCount++;
878
-
879
- // If the class details match, it's definitely the same class.
880
- if (classType.details === type2.details) {
881
- return true;
882
- }
883
-
884
- // If either or both have aliases (e.g. List -> list), use the
885
- // aliases for comparison purposes.
886
- const class1Details = classType.details;
887
- const class2Details = type2.details;
888
-
889
- if (class1Details === class2Details) {
890
- return true;
891
- }
892
-
893
- // Compare most of the details fields. We intentionally skip the isAbstractClass
894
- // flag because it gets set dynamically.
895
- if (
896
- class1Details.fullName !== class2Details.fullName ||
897
- class1Details.flags !== class2Details.flags ||
898
- class1Details.typeSourceId !== class2Details.typeSourceId ||
899
- class1Details.baseClasses.length !== class2Details.baseClasses.length ||
900
- class1Details.typeParameters.length !== class2Details.typeParameters.length
901
- ) {
902
- return false;
903
- }
904
-
905
- // Special-case NamedTuple and Tuple classes because we rewrite the base classes
906
- // in these cases.
907
- if (ClassType.isBuiltIn(classType, 'NamedTuple') && ClassType.isBuiltIn(type2, 'NamedTuple')) {
908
- return true;
909
- }
910
- if (ClassType.isBuiltIn(classType, 'tuple') && ClassType.isBuiltIn(type2, 'tuple')) {
911
- return true;
912
- }
913
-
914
- // Make sure the base classes match.
915
- for (let i = 0; i < class1Details.baseClasses.length; i++) {
916
- if (
917
- !isTypeSame(
918
- class1Details.baseClasses[i],
919
- class2Details.baseClasses[i],
920
- /* ignorePseudoGeneric */ true,
921
- /* ignoreTypeFlags */ undefined,
922
- recursionCount
923
- )
924
- ) {
925
- return false;
926
- }
927
- }
928
-
929
- if (class1Details.declaredMetaclass || class2Details.declaredMetaclass) {
930
- if (
931
- !class1Details.declaredMetaclass ||
932
- !class2Details.declaredMetaclass ||
933
- !isTypeSame(
934
- class1Details.declaredMetaclass,
935
- class2Details.declaredMetaclass,
936
- /* ignorePseudoGeneric */ true,
937
- /* ignoreTypeFlags */ undefined,
938
- recursionCount
939
- )
940
- ) {
941
- return false;
942
- }
943
- }
944
-
945
- for (let i = 0; i < class1Details.typeParameters.length; i++) {
946
- if (
947
- !isTypeSame(
948
- class1Details.typeParameters[i],
949
- class2Details.typeParameters[i],
950
- /* ignorePseudoGeneric */ true,
951
- /* ignoreTypeFlags */ undefined,
952
- recursionCount
953
- )
954
- ) {
955
- return false;
956
- }
957
- }
958
-
959
- return true;
960
- }
961
-
962
- // Determines whether this is a subclass (derived class)
963
- // of the specified class. If the caller passes an empty
964
- // array to inheritanceChain, it will be filled in by
965
- // the call to include the chain of inherited classes starting
966
- // with type2 and ending with this type.
967
- export function isDerivedFrom(
968
- subclassType: ClassType,
969
- parentClassType: ClassType,
970
- inheritanceChain?: InheritanceChain
971
- ): boolean {
972
- // Is it the exact same class?
973
- if (isSameGenericClass(subclassType, parentClassType)) {
974
- if (inheritanceChain) {
975
- inheritanceChain.push(subclassType);
976
- }
977
- return true;
978
- }
979
-
980
- // Handle built-in types like 'dict' and 'list', which are all
981
- // subclasses of object even though they are not explicitly declared
982
- // that way.
983
- if (isBuiltIn(subclassType) && isBuiltIn(parentClassType, 'object')) {
984
- if (inheritanceChain) {
985
- inheritanceChain.push(parentClassType);
986
- }
987
- return true;
988
- }
989
-
990
- for (const baseClass of subclassType.details.baseClasses) {
991
- if (isInstantiableClass(baseClass)) {
992
- if (isDerivedFrom(baseClass, parentClassType, inheritanceChain)) {
993
- if (inheritanceChain) {
994
- inheritanceChain.push(subclassType);
995
- }
996
- return true;
997
- }
998
- } else if (isAnyOrUnknown(baseClass)) {
999
- if (inheritanceChain) {
1000
- inheritanceChain.push(UnknownType.create());
1001
- }
1002
- return true;
1003
- }
1004
- }
1005
-
1006
- return false;
1007
- }
1008
- }
1009
-
1010
- export interface ParamSpecEntry {
1011
- category: ParameterCategory;
1012
- name?: string | undefined;
1013
- isNameSynthesized?: boolean;
1014
- hasDefault?: boolean | undefined;
1015
- type: Type;
1016
- }
1017
-
1018
- export interface FunctionParameter extends ParamSpecEntry {
1019
- isTypeInferred?: boolean | undefined;
1020
- defaultValueExpression?: ExpressionNode | undefined;
1021
- defaultType?: Type | undefined;
1022
- hasDeclaredType?: boolean | undefined;
1023
- typeAnnotation?: ExpressionNode | undefined;
1024
- }
1025
-
1026
- export const enum FunctionTypeFlags {
1027
- None = 0,
1028
-
1029
- // Function is a __new__ method; first parameter is "cls"
1030
- ConstructorMethod = 1 << 0,
1031
-
1032
- // Function is decorated with @classmethod; first parameter is "cls";
1033
- // can be bound to associated class
1034
- ClassMethod = 1 << 1,
1035
-
1036
- // Function is decorated with @staticmethod; cannot be bound to class
1037
- StaticMethod = 1 << 2,
1038
-
1039
- // Function is decorated with @abstractmethod
1040
- AbstractMethod = 1 << 3,
1041
-
1042
- // Function contains "yield" or "yield from" statements
1043
- Generator = 1 << 4,
1044
-
1045
- // Skip check that validates that all parameters without default
1046
- // value expressions have corresponding arguments; used for
1047
- // named tuples in some cases
1048
- DisableDefaultChecks = 1 << 5,
1049
-
1050
- // Method has no declaration in user code, it's synthesized; used
1051
- // for implied methods such as those used in namedtuple, dataclass, etc.
1052
- SynthesizedMethod = 1 << 6,
1053
-
1054
- // For some synthesized classes (in particular, NamedTuple), the
1055
- // __init__ method is created with default parameters, so we will
1056
- // skip the constructor check for these methods.
1057
- SkipConstructorCheck = 1 << 7,
1058
-
1059
- // Function is decorated with @overload
1060
- Overloaded = 1 << 8,
1061
-
1062
- // Function is declared with async keyword
1063
- Async = 1 << 9,
1064
-
1065
- // Indicates that return type should be wrapped in an awaitable type
1066
- WrapReturnTypeInAwait = 1 << 10,
1067
-
1068
- // Function is declared within a type stub fille
1069
- StubDefinition = 1 << 11,
1070
-
1071
- // Function is declared within a module that claims to be fully typed
1072
- // (i.e. a "py.typed" file is present).
1073
- PyTypedDefinition = 1 << 12,
1074
-
1075
- // Function is decorated with @final
1076
- Final = 1 << 13,
1077
-
1078
- // Function has one or more parameters that are missing type annotations
1079
- UnannotatedParams = 1 << 14,
1080
-
1081
- // The *args and **kwargs parameters do not need to be present for this
1082
- // function to be compatible. This is used for Callable[..., x] and
1083
- // ... type arguments to ParamSpec and Concatenate.
1084
- SkipArgsKwargsCompatibilityCheck = 1 << 15,
1085
-
1086
- // This function represents the value bound to a ParamSpec, so its return
1087
- // type is not meaningful.
1088
- ParamSpecValue = 1 << 16,
1089
-
1090
- // The function type is in the process of being evaluated and
1091
- // is not yet complete. This allows us to detect cases where
1092
- // the function refers to itself (e.g. uses a type annotation
1093
- // that contains a forward reference that requires the function
1094
- // type itself to be evaluated first).
1095
- PartiallyEvaluated = 1 << 17,
1096
- }
1097
-
1098
- interface FunctionDetails {
1099
- name: string;
1100
- fullName: string;
1101
- moduleName: string;
1102
- flags: FunctionTypeFlags;
1103
- parameters: FunctionParameter[];
1104
- declaredReturnType?: Type | undefined;
1105
- declaration?: FunctionDeclaration | undefined;
1106
- typeVarScopeId?: TypeVarScopeId | undefined;
1107
- constructorTypeVarScopeId?: TypeVarScopeId | undefined;
1108
- builtInName?: string | undefined;
1109
- docString?: string | undefined;
1110
-
1111
- // Transforms to apply if this function is used
1112
- // as a decorator.
1113
- decoratorDataClassBehaviors?: DataClassBehaviors | undefined;
1114
-
1115
- // Parameter specification used only for Callable types created
1116
- // with a ParamSpec representing the parameters.
1117
- paramSpec?: TypeVarType | undefined;
1118
- }
1119
-
1120
- export interface SpecializedFunctionTypes {
1121
- // Specialized types for each of the parameters in the "parameters" array.
1122
- parameterTypes: Type[];
1123
-
1124
- // Specialized types of default arguments for each parameter in
1125
- // the "parameters" array. If an entry is undefined or the entire array
1126
- // is missing, there is no specialized type, and the original "defaultType"
1127
- // should be used.
1128
- parameterDefaultArgs?: (Type | undefined)[];
1129
-
1130
- // Specialized type of the declared return type. Undefined if there is
1131
- // no declared return type.
1132
- returnType?: Type | undefined;
1133
- }
1134
-
1135
- export interface FunctionType extends TypeBase {
1136
- category: TypeCategory.Function;
1137
-
1138
- details: FunctionDetails;
1139
-
1140
- // A function type can be specialized (i.e. generic type
1141
- // variables replaced by a concrete type).
1142
- specializedTypes?: SpecializedFunctionTypes | undefined;
1143
-
1144
- // Filled in lazily
1145
- inferredReturnType?: Type | undefined;
1146
-
1147
- // If this is a bound function where the first parameter
1148
- // was stripped from the original unbound function, the
1149
- // (specialized) type of that stripped parameter.
1150
- strippedFirstParamType?: Type | undefined;
1151
-
1152
- // If this is a bound function where the first parameter
1153
- // was stripped from the original unbound function,
1154
- // the class or object to which the function was bound.
1155
- boundToType?: ClassType | undefined;
1156
-
1157
- // The flags for the function prior to binding
1158
- preBoundFlags?: FunctionTypeFlags;
1159
-
1160
- // The type var scope for the class that the function was bound to
1161
- boundTypeVarScopeId?: TypeVarScopeId | undefined;
1162
- }
1163
-
1164
- export interface ParamSpecValue {
1165
- flags: FunctionTypeFlags;
1166
- parameters: ParamSpecEntry[];
1167
- typeVarScopeId: TypeVarScopeId | undefined;
1168
- docString: string | undefined;
1169
- paramSpec: TypeVarType | undefined;
1170
- }
1171
-
1172
- export namespace FunctionType {
1173
- export function createInstance(
1174
- name: string,
1175
- fullName: string,
1176
- moduleName: string,
1177
- functionFlags: FunctionTypeFlags,
1178
- docString?: string
1179
- ) {
1180
- return create(name, fullName, moduleName, functionFlags, TypeFlags.Instance, docString);
1181
- }
1182
-
1183
- export function createInstantiable(functionFlags: FunctionTypeFlags, docString?: string) {
1184
- return create('', '', '', functionFlags, TypeFlags.Instantiable, docString);
1185
- }
1186
-
1187
- export function createSynthesizedInstance(name: string, additionalFlags = FunctionTypeFlags.None) {
1188
- return create(name, '', '', additionalFlags | FunctionTypeFlags.SynthesizedMethod, TypeFlags.Instance);
1189
- }
1190
-
1191
- function create(
1192
- name: string,
1193
- fullName: string,
1194
- moduleName: string,
1195
- functionFlags: FunctionTypeFlags,
1196
- typeFlags: TypeFlags,
1197
- docString?: string
1198
- ) {
1199
- const newFunctionType: FunctionType = {
1200
- category: TypeCategory.Function,
1201
- details: {
1202
- name,
1203
- fullName,
1204
- moduleName,
1205
- flags: functionFlags,
1206
- parameters: [],
1207
- docString,
1208
- },
1209
- flags: typeFlags,
1210
- };
1211
- return newFunctionType;
1212
- }
1213
-
1214
- // Creates a deep copy of the function type, including a fresh
1215
- // version of _functionDetails.
1216
- export function clone(
1217
- type: FunctionType,
1218
- stripFirstParam = false,
1219
- boundToType?: ClassType,
1220
- boundTypeVarScopeId?: TypeVarScopeId
1221
- ): FunctionType {
1222
- const newFunction = create(
1223
- type.details.name,
1224
- type.details.fullName,
1225
- type.details.moduleName,
1226
- type.details.flags,
1227
- type.flags,
1228
- type.details.docString
1229
- );
1230
-
1231
- newFunction.details = { ...type.details };
1232
- newFunction.boundToType = boundToType;
1233
- newFunction.preBoundFlags = newFunction.details.flags;
1234
-
1235
- if (stripFirstParam) {
1236
- if (
1237
- type.details.parameters.length > 0 &&
1238
- type.details.parameters[0].category === ParameterCategory.Simple
1239
- ) {
1240
- if (type.details.parameters.length > 0 && !type.details.parameters[0].isTypeInferred) {
1241
- // Stash away the effective type of the first parameter if it
1242
- // wasn't synthesized.
1243
- newFunction.strippedFirstParamType = getEffectiveParameterType(type, 0);
1244
- }
1245
- newFunction.details.parameters = type.details.parameters.slice(1);
1246
- } else {
1247
- stripFirstParam = false;
1248
- }
1249
-
1250
- // If we strip off the first parameter, this is no longer an
1251
- // instance method or class method.
1252
- newFunction.details.flags &= ~(FunctionTypeFlags.ConstructorMethod | FunctionTypeFlags.ClassMethod);
1253
- newFunction.details.flags |= FunctionTypeFlags.StaticMethod;
1254
- }
1255
-
1256
- if (type.typeAliasInfo !== undefined) {
1257
- newFunction.typeAliasInfo = type.typeAliasInfo;
1258
- }
1259
-
1260
- if (type.specializedTypes) {
1261
- newFunction.specializedTypes = {
1262
- parameterTypes: stripFirstParam
1263
- ? type.specializedTypes.parameterTypes.slice(1)
1264
- : type.specializedTypes.parameterTypes,
1265
- parameterDefaultArgs: stripFirstParam
1266
- ? type.specializedTypes.parameterDefaultArgs?.slice(1)
1267
- : type.specializedTypes.parameterDefaultArgs,
1268
- returnType: type.specializedTypes.returnType,
1269
- };
1270
- }
1271
-
1272
- newFunction.inferredReturnType = type.inferredReturnType;
1273
- newFunction.boundTypeVarScopeId = boundTypeVarScopeId;
1274
-
1275
- return newFunction;
1276
- }
1277
-
1278
- export function cloneAsInstance(type: FunctionType): FunctionType {
1279
- const newInstance = TypeBase.cloneTypeAsInstance(type);
1280
- newInstance.flags &= ~TypeFlags.SpecialForm;
1281
- return newInstance;
1282
- }
1283
-
1284
- export function cloneAsInstantiable(type: FunctionType): FunctionType {
1285
- const newInstance = TypeBase.cloneTypeAsInstantiable(type);
1286
- newInstance.flags &= ~TypeFlags.SpecialForm;
1287
- return newInstance;
1288
- }
1289
-
1290
- // Creates a shallow copy of the function type with new
1291
- // specialized types. The clone shares the _functionDetails
1292
- // with the object being cloned.
1293
- export function cloneForSpecialization(
1294
- type: FunctionType,
1295
- specializedTypes: SpecializedFunctionTypes,
1296
- specializedInferredReturnType: Type | undefined
1297
- ): FunctionType {
1298
- const newFunction = create(
1299
- type.details.name,
1300
- type.details.fullName,
1301
- type.details.moduleName,
1302
- type.details.flags,
1303
- type.flags,
1304
- type.details.docString
1305
- );
1306
- newFunction.details = type.details;
1307
-
1308
- assert(specializedTypes.parameterTypes.length === type.details.parameters.length);
1309
- if (specializedTypes.parameterDefaultArgs) {
1310
- assert(specializedTypes.parameterDefaultArgs.length === type.details.parameters.length);
1311
- }
1312
- newFunction.specializedTypes = specializedTypes;
1313
-
1314
- if (specializedInferredReturnType) {
1315
- newFunction.inferredReturnType = specializedInferredReturnType;
1316
- }
1317
-
1318
- return newFunction;
1319
- }
1320
-
1321
- // Creates a new function based on the parameters of another function.
1322
- export function cloneForParamSpec(type: FunctionType, paramSpecValue: ParamSpecValue | undefined): FunctionType {
1323
- const newFunction = create(
1324
- type.details.name,
1325
- type.details.fullName,
1326
- type.details.moduleName,
1327
- type.details.flags,
1328
- type.flags,
1329
- type.details.docString
1330
- );
1331
-
1332
- // Make a shallow clone of the details.
1333
- newFunction.details = { ...type.details };
1334
-
1335
- // The clone should no longer have a parameter specification
1336
- // since we're replacing it.
1337
- delete newFunction.details.paramSpec;
1338
-
1339
- if (paramSpecValue) {
1340
- newFunction.details.parameters = [
1341
- ...type.details.parameters,
1342
- ...paramSpecValue.parameters.map((specEntry) => {
1343
- return {
1344
- category: specEntry.category,
1345
- name: specEntry.name,
1346
- hasDefault: specEntry.hasDefault,
1347
- isNameSynthesized: specEntry.isNameSynthesized,
1348
- hasDeclaredType: true,
1349
- type: specEntry.type,
1350
- };
1351
- }),
1352
- ];
1353
-
1354
- if (!newFunction.details.docString) {
1355
- newFunction.details.docString = paramSpecValue.docString;
1356
- }
1357
-
1358
- newFunction.details.flags =
1359
- (paramSpecValue.flags &
1360
- (FunctionTypeFlags.ClassMethod |
1361
- FunctionTypeFlags.StaticMethod |
1362
- FunctionTypeFlags.ConstructorMethod |
1363
- FunctionTypeFlags.SkipArgsKwargsCompatibilityCheck)) |
1364
- FunctionTypeFlags.SynthesizedMethod;
1365
-
1366
- if (FunctionType.isParamSpecValue(type)) {
1367
- newFunction.details.flags |= FunctionTypeFlags.ParamSpecValue;
1368
- }
1369
-
1370
- // Update the specialized parameter types as well.
1371
- if (type.specializedTypes) {
1372
- newFunction.specializedTypes = {
1373
- parameterTypes: [...type.specializedTypes.parameterTypes],
1374
- returnType: type.specializedTypes.returnType,
1375
- };
1376
- if (type.specializedTypes.parameterDefaultArgs) {
1377
- newFunction.specializedTypes.parameterDefaultArgs = [...type.specializedTypes.parameterDefaultArgs];
1378
- }
1379
- paramSpecValue.parameters.forEach((paramInfo) => {
1380
- newFunction.specializedTypes!.parameterTypes.push(paramInfo.type);
1381
- if (newFunction.specializedTypes!.parameterDefaultArgs) {
1382
- // Assume that the parameters introduced via paramSpec have no specialized
1383
- // default arg types. Fall back on the original default arg type in this case.
1384
- newFunction.specializedTypes!.parameterDefaultArgs.push(undefined);
1385
- }
1386
- });
1387
- }
1388
-
1389
- newFunction.details.paramSpec = paramSpecValue.paramSpec;
1390
- }
1391
-
1392
- return newFunction;
1393
- }
1394
-
1395
- export function cloneWithNewFlags(type: FunctionType, flags: FunctionTypeFlags): FunctionType {
1396
- const newFunction = TypeBase.cloneType(type);
1397
-
1398
- // Make a shallow clone of the details.
1399
- newFunction.details = { ...type.details };
1400
-
1401
- newFunction.details.flags = flags;
1402
-
1403
- return newFunction;
1404
- }
1405
-
1406
- export function cloneForParamSpecApplication(type: FunctionType, paramSpecValue: ParamSpecValue): FunctionType {
1407
- const newFunction = TypeBase.cloneType(type);
1408
-
1409
- // Make a shallow clone of the details.
1410
- newFunction.details = { ...type.details };
1411
-
1412
- // Remove the last two parameters, which are the *args and **kwargs.
1413
- newFunction.details.parameters = newFunction.details.parameters.slice(
1414
- 0,
1415
- newFunction.details.parameters.length - 2
1416
- );
1417
-
1418
- // If there is a position-only separator in the captured param spec signature,
1419
- // remove the position-only separator in the existing signature. Otherwise,
1420
- // we'll end up with redundant position-only separators.
1421
- if (paramSpecValue.parameters.some((entry) => entry.category === ParameterCategory.Simple && !entry.name)) {
1422
- if (newFunction.details.parameters.length > 0) {
1423
- const lastParam = newFunction.details.parameters[newFunction.details.parameters.length - 1];
1424
- if (lastParam.category === ParameterCategory.Simple && !lastParam.name) {
1425
- newFunction.details.parameters.pop();
1426
- }
1427
- }
1428
- }
1429
-
1430
- paramSpecValue.parameters.forEach((specEntry) => {
1431
- newFunction.details.parameters.push({
1432
- category: specEntry.category,
1433
- name: specEntry.name,
1434
- hasDefault: specEntry.hasDefault,
1435
- isNameSynthesized: specEntry.isNameSynthesized,
1436
- hasDeclaredType: true,
1437
- type: specEntry.type,
1438
- });
1439
- });
1440
-
1441
- newFunction.details.paramSpec = paramSpecValue.paramSpec;
1442
- if (!newFunction.details.docString) {
1443
- newFunction.details.docString = paramSpecValue.docString;
1444
- }
1445
-
1446
- return newFunction;
1447
- }
1448
-
1449
- export function cloneRemoveParamSpecVariadics(type: FunctionType, paramSpec: TypeVarType): FunctionType {
1450
- const newFunction = create(
1451
- type.details.name,
1452
- type.details.fullName,
1453
- type.details.moduleName,
1454
- type.details.flags,
1455
- type.flags,
1456
- type.details.docString
1457
- );
1458
-
1459
- // Make a shallow clone of the details.
1460
- newFunction.details = { ...type.details };
1461
-
1462
- // Remove the last two parameters, which are the *args and **kwargs.
1463
- newFunction.details.parameters = newFunction.details.parameters.slice(
1464
- 0,
1465
- newFunction.details.parameters.length - 2
1466
- );
1467
-
1468
- if (type.specializedTypes) {
1469
- newFunction.specializedTypes = { ...type.specializedTypes };
1470
- newFunction.specializedTypes.parameterTypes = newFunction.specializedTypes.parameterTypes.slice(
1471
- 0,
1472
- newFunction.specializedTypes.parameterTypes.length - 2
1473
- );
1474
- if (newFunction.specializedTypes.parameterDefaultArgs) {
1475
- newFunction.specializedTypes.parameterDefaultArgs =
1476
- newFunction.specializedTypes.parameterDefaultArgs.slice(
1477
- 0,
1478
- newFunction.specializedTypes.parameterDefaultArgs.length - 2
1479
- );
1480
- }
1481
- }
1482
-
1483
- if (!newFunction.details.paramSpec) {
1484
- newFunction.details.paramSpec = paramSpec;
1485
- }
1486
-
1487
- return newFunction;
1488
- }
1489
-
1490
- export function addDefaultParameters(functionType: FunctionType, useUnknown = false) {
1491
- getDefaultParameters(useUnknown).forEach((param) => {
1492
- FunctionType.addParameter(functionType, param);
1493
- });
1494
- }
1495
-
1496
- export function getDefaultParameters(useUnknown = false): FunctionParameter[] {
1497
- return [
1498
- {
1499
- category: ParameterCategory.VarArgList,
1500
- name: 'args',
1501
- type: useUnknown ? UnknownType.create() : AnyType.create(),
1502
- hasDeclaredType: !useUnknown,
1503
- },
1504
- {
1505
- category: ParameterCategory.VarArgDictionary,
1506
- name: 'kwargs',
1507
- type: useUnknown ? UnknownType.create() : AnyType.create(),
1508
- hasDeclaredType: !useUnknown,
1509
- },
1510
- ];
1511
- }
1512
-
1513
- // Indicates whether the input signature consists of (*args: Any, **kwargs: Any).
1514
- export function hasDefaultParameters(functionType: FunctionType): boolean {
1515
- let sawArgs = false;
1516
- let sawKwargs = false;
1517
-
1518
- for (let i = 0; i < functionType.details.parameters.length; i++) {
1519
- const param = functionType.details.parameters[i];
1520
-
1521
- // Ignore nameless separator parameters.
1522
- if (!param.name) {
1523
- continue;
1524
- }
1525
-
1526
- if (param.category === ParameterCategory.Simple) {
1527
- return false;
1528
- } else if (param.category === ParameterCategory.VarArgList) {
1529
- sawArgs = true;
1530
- } else if (param.category === ParameterCategory.VarArgDictionary) {
1531
- sawKwargs = true;
1532
- }
1533
-
1534
- if (!isAnyOrUnknown(FunctionType.getEffectiveParameterType(functionType, i))) {
1535
- return false;
1536
- }
1537
- }
1538
-
1539
- return sawArgs && sawKwargs;
1540
- }
1541
-
1542
- export function isInstanceMethod(type: FunctionType): boolean {
1543
- return (
1544
- (type.details.flags &
1545
- (FunctionTypeFlags.ConstructorMethod |
1546
- FunctionTypeFlags.StaticMethod |
1547
- FunctionTypeFlags.ClassMethod)) ===
1548
- 0
1549
- );
1550
- }
1551
-
1552
- export function isConstructorMethod(type: FunctionType): boolean {
1553
- return (type.details.flags & FunctionTypeFlags.ConstructorMethod) !== 0;
1554
- }
1555
-
1556
- export function isStaticMethod(type: FunctionType): boolean {
1557
- return (type.details.flags & FunctionTypeFlags.StaticMethod) !== 0;
1558
- }
1559
-
1560
- export function isClassMethod(type: FunctionType): boolean {
1561
- return (type.details.flags & FunctionTypeFlags.ClassMethod) !== 0;
1562
- }
1563
-
1564
- export function isAbstractMethod(type: FunctionType): boolean {
1565
- return (type.details.flags & FunctionTypeFlags.AbstractMethod) !== 0;
1566
- }
1567
-
1568
- export function isGenerator(type: FunctionType): boolean {
1569
- return (type.details.flags & FunctionTypeFlags.Generator) !== 0;
1570
- }
1571
-
1572
- export function isSynthesizedMethod(type: FunctionType): boolean {
1573
- return (type.details.flags & FunctionTypeFlags.SynthesizedMethod) !== 0;
1574
- }
1575
-
1576
- export function isSkipConstructorCheck(type: FunctionType): boolean {
1577
- return (type.details.flags & FunctionTypeFlags.SkipConstructorCheck) !== 0;
1578
- }
1579
-
1580
- export function isOverloaded(type: FunctionType): boolean {
1581
- return (type.details.flags & FunctionTypeFlags.Overloaded) !== 0;
1582
- }
1583
-
1584
- export function isDefaultParameterCheckDisabled(type: FunctionType) {
1585
- return (type.details.flags & FunctionTypeFlags.DisableDefaultChecks) !== 0;
1586
- }
1587
-
1588
- export function isAsync(type: FunctionType) {
1589
- return (type.details.flags & FunctionTypeFlags.Async) !== 0;
1590
- }
1591
-
1592
- export function isWrapReturnTypeInAwait(type: FunctionType) {
1593
- return (type.details.flags & FunctionTypeFlags.WrapReturnTypeInAwait) !== 0;
1594
- }
1595
-
1596
- export function isStubDefinition(type: FunctionType) {
1597
- return (type.details.flags & FunctionTypeFlags.StubDefinition) !== 0;
1598
- }
1599
-
1600
- export function isPyTypedDefinition(type: FunctionType) {
1601
- return (type.details.flags & FunctionTypeFlags.PyTypedDefinition) !== 0;
1602
- }
1603
-
1604
- export function isFinal(type: FunctionType) {
1605
- return (type.details.flags & FunctionTypeFlags.Final) !== 0;
1606
- }
1607
-
1608
- export function hasUnannotatedParams(type: FunctionType) {
1609
- return (type.details.flags & FunctionTypeFlags.UnannotatedParams) !== 0;
1610
- }
1611
-
1612
- export function shouldSkipArgsKwargsCompatibilityCheck(type: FunctionType) {
1613
- return (type.details.flags & FunctionTypeFlags.SkipArgsKwargsCompatibilityCheck) !== 0;
1614
- }
1615
-
1616
- export function isParamSpecValue(type: FunctionType) {
1617
- return (type.details.flags & FunctionTypeFlags.ParamSpecValue) !== 0;
1618
- }
1619
-
1620
- export function isPartiallyEvaluated(type: FunctionType) {
1621
- return !!(type.details.flags & FunctionTypeFlags.PartiallyEvaluated);
1622
- }
1623
-
1624
- export function getEffectiveParameterType(type: FunctionType, index: number): Type {
1625
- assert(index < type.details.parameters.length, 'Parameter types array overflow');
1626
-
1627
- if (type.specializedTypes && index < type.specializedTypes.parameterTypes.length) {
1628
- return type.specializedTypes.parameterTypes[index];
1629
- }
1630
-
1631
- return type.details.parameters[index].type;
1632
- }
1633
-
1634
- export function getEffectiveParameterDefaultArgType(type: FunctionType, index: number): Type | undefined {
1635
- assert(index < type.details.parameters.length, 'Parameter types array overflow');
1636
-
1637
- if (type.specializedTypes?.parameterDefaultArgs && index < type.specializedTypes.parameterDefaultArgs.length) {
1638
- const defaultArgType = type.specializedTypes.parameterDefaultArgs[index];
1639
- if (defaultArgType) {
1640
- return defaultArgType;
1641
- }
1642
- }
1643
-
1644
- return type.details.parameters[index].defaultType;
1645
- }
1646
-
1647
- export function addParameter(type: FunctionType, param: FunctionParameter) {
1648
- type.details.parameters.push(param);
1649
- }
1650
-
1651
- export function getSpecializedReturnType(type: FunctionType) {
1652
- return type.specializedTypes && type.specializedTypes.returnType
1653
- ? type.specializedTypes.returnType
1654
- : type.details.declaredReturnType;
1655
- }
1656
- }
1657
-
1658
- export interface OverloadedFunctionType extends TypeBase {
1659
- category: TypeCategory.OverloadedFunction;
1660
- overloads: FunctionType[];
1661
- }
1662
-
1663
- export namespace OverloadedFunctionType {
1664
- export function create(overloads: FunctionType[]) {
1665
- const newType: OverloadedFunctionType = {
1666
- category: TypeCategory.OverloadedFunction,
1667
- overloads,
1668
- flags: TypeFlags.Instance,
1669
- };
1670
- return newType;
1671
- }
1672
-
1673
- export function addOverload(type: OverloadedFunctionType, functionType: FunctionType) {
1674
- type.overloads.push(functionType);
1675
- }
1676
- }
1677
-
1678
- export interface NoneType extends TypeBase {
1679
- category: TypeCategory.None;
1680
- }
1681
-
1682
- export namespace NoneType {
1683
- const _noneInstance: NoneType = {
1684
- category: TypeCategory.None,
1685
- flags: TypeFlags.Instance,
1686
- };
1687
-
1688
- const _noneType: NoneType = {
1689
- category: TypeCategory.None,
1690
- flags: TypeFlags.Instantiable,
1691
- };
1692
-
1693
- export function createInstance() {
1694
- return _noneInstance;
1695
- }
1696
-
1697
- export function createType() {
1698
- return _noneType;
1699
- }
1700
- }
1701
-
1702
- export interface NeverType extends TypeBase {
1703
- category: TypeCategory.Never;
1704
- isNoReturn: boolean;
1705
- }
1706
-
1707
- export namespace NeverType {
1708
- const _neverInstance: NeverType = {
1709
- category: TypeCategory.Never,
1710
- flags: TypeFlags.Instance | TypeFlags.Instantiable,
1711
- isNoReturn: false,
1712
- };
1713
-
1714
- const _noReturnInstance: NeverType = {
1715
- category: TypeCategory.Never,
1716
- flags: TypeFlags.Instance | TypeFlags.Instantiable,
1717
- isNoReturn: true,
1718
- };
1719
-
1720
- export function createNever() {
1721
- return _neverInstance;
1722
- }
1723
-
1724
- export function createNoReturn() {
1725
- return _noReturnInstance;
1726
- }
1727
- }
1728
-
1729
- export interface AnyType extends TypeBase {
1730
- category: TypeCategory.Any;
1731
- isEllipsis: boolean;
1732
- }
1733
-
1734
- export namespace AnyType {
1735
- const _anyInstance: AnyType = {
1736
- category: TypeCategory.Any,
1737
- isEllipsis: false,
1738
- flags: TypeFlags.Instance | TypeFlags.Instantiable,
1739
- };
1740
-
1741
- const _ellipsisInstance: AnyType = {
1742
- category: TypeCategory.Any,
1743
- isEllipsis: true,
1744
- flags: TypeFlags.Instance | TypeFlags.Instantiable,
1745
- };
1746
-
1747
- export function create(isEllipsis = false) {
1748
- return isEllipsis ? _ellipsisInstance : _anyInstance;
1749
- }
1750
- }
1751
-
1752
- // References a single condition associated with a constrained TypeVar.
1753
- export interface TypeCondition {
1754
- typeVarName: string;
1755
- constraintIndex: number;
1756
- isConstrainedTypeVar: boolean;
1757
- }
1758
-
1759
- export namespace TypeCondition {
1760
- export function combine(
1761
- conditions1: TypeCondition[] | undefined,
1762
- conditions2: TypeCondition[] | undefined
1763
- ): TypeCondition[] | undefined {
1764
- if (!conditions1) {
1765
- return conditions2;
1766
- }
1767
-
1768
- if (!conditions2) {
1769
- return conditions1;
1770
- }
1771
-
1772
- // Deduplicate the lists.
1773
- const combined = [...conditions1];
1774
- conditions2.forEach((c1) => {
1775
- if (!combined.some((c2) => _compare(c1, c2) === 0)) {
1776
- combined.push(c1);
1777
- }
1778
- });
1779
-
1780
- // Always keep the conditions sorted for easier comparison.
1781
- return combined.sort(_compare);
1782
- }
1783
-
1784
- function _compare(c1: TypeCondition, c2: TypeCondition) {
1785
- if (c1.typeVarName < c2.typeVarName) {
1786
- return -1;
1787
- } else if (c1.typeVarName > c2.typeVarName) {
1788
- return 1;
1789
- }
1790
- if (c1.constraintIndex < c2.constraintIndex) {
1791
- return -1;
1792
- } else if (c1.constraintIndex > c2.constraintIndex) {
1793
- return 1;
1794
- }
1795
- return 0;
1796
- }
1797
-
1798
- export function isSame(
1799
- conditions1: TypeCondition[] | undefined,
1800
- conditions2: TypeCondition[] | undefined
1801
- ): boolean {
1802
- if (!conditions1) {
1803
- return !conditions2;
1804
- }
1805
-
1806
- if (!conditions2 || conditions1.length !== conditions2.length) {
1807
- return false;
1808
- }
1809
-
1810
- return (
1811
- conditions1.find(
1812
- (c1, index) =>
1813
- c1.typeVarName !== conditions2[index].typeVarName ||
1814
- c1.constraintIndex !== conditions2[index].constraintIndex
1815
- ) === undefined
1816
- );
1817
- }
1818
-
1819
- // Determines if the two conditions can be used at the same time. If
1820
- // one constraint list contains a constraint for a type variable, and the
1821
- // same constraint is not in the other constraint list, the two are considered
1822
- // incompatible.
1823
- export function isCompatible(
1824
- conditions1: TypeCondition[] | undefined,
1825
- conditions2: TypeCondition[] | undefined
1826
- ): boolean {
1827
- if (!conditions1 || !conditions2) {
1828
- return true;
1829
- }
1830
-
1831
- for (const c1 of conditions1) {
1832
- let foundTypeVarMatch = false;
1833
- const exactMatch = conditions2.find((c2) => {
1834
- if (c1.typeVarName === c2.typeVarName) {
1835
- foundTypeVarMatch = true;
1836
- return c1.constraintIndex === c2.constraintIndex;
1837
- }
1838
- return false;
1839
- });
1840
-
1841
- if (foundTypeVarMatch && !exactMatch) {
1842
- return false;
1843
- }
1844
- }
1845
-
1846
- return true;
1847
- }
1848
- }
1849
-
1850
- export interface UnionType extends TypeBase {
1851
- category: TypeCategory.Union;
1852
- subtypes: UnionableType[];
1853
- literalStrMap?: Map<string, UnionableType> | undefined;
1854
- literalIntMap?: Map<bigint | number, UnionableType> | undefined;
1855
- typeAliasSources?: Set<UnionType>;
1856
- }
1857
-
1858
- export namespace UnionType {
1859
- export function create() {
1860
- const newUnionType: UnionType = {
1861
- category: TypeCategory.Union,
1862
- subtypes: [],
1863
- flags: TypeFlags.Instance | TypeFlags.Instantiable,
1864
- };
1865
-
1866
- return newUnionType;
1867
- }
1868
-
1869
- export function addType(unionType: UnionType, newType: UnionableType) {
1870
- // If we're adding a string literal or integer type, add it to the
1871
- // corresponding literal map to speed up some operations. It's not
1872
- // uncommon for unions to contain hundreds of literals.
1873
- if (isClassInstance(newType) && newType.literalValue !== undefined && newType.condition === undefined) {
1874
- if (ClassType.isBuiltIn(newType, 'str')) {
1875
- if (unionType.literalStrMap === undefined) {
1876
- unionType.literalStrMap = new Map<string, UnionableType>();
1877
- }
1878
- unionType.literalStrMap.set(newType.literalValue as string, newType);
1879
- } else if (ClassType.isBuiltIn(newType, 'int')) {
1880
- if (unionType.literalIntMap === undefined) {
1881
- unionType.literalIntMap = new Map<bigint | number, UnionableType>();
1882
- }
1883
- unionType.literalIntMap.set(newType.literalValue as number | bigint, newType);
1884
- }
1885
- }
1886
-
1887
- unionType.flags &= newType.flags;
1888
- unionType.subtypes.push(newType);
1889
- }
1890
-
1891
- export function containsType(unionType: UnionType, subtype: Type, recursionCount = 0): boolean {
1892
- // Handle string literals as a special case because unions can sometimes
1893
- // contain hundreds of string literal types.
1894
- if (isClassInstance(subtype) && subtype.condition === undefined && subtype.literalValue !== undefined) {
1895
- if (ClassType.isBuiltIn(subtype, 'str') && unionType.literalStrMap !== undefined) {
1896
- return unionType.literalStrMap.has(subtype.literalValue as string);
1897
- } else if (ClassType.isBuiltIn(subtype, 'int') && unionType.literalIntMap !== undefined) {
1898
- return unionType.literalIntMap.has(subtype.literalValue as number | bigint);
1899
- }
1900
- }
1901
-
1902
- return (
1903
- unionType.subtypes.find((t) =>
1904
- isTypeSame(
1905
- t,
1906
- subtype,
1907
- /* ignorePseudoGeneric */ undefined,
1908
- /* ignoreTypeFlags */ undefined,
1909
- recursionCount
1910
- )
1911
- ) !== undefined
1912
- );
1913
- }
1914
-
1915
- export function addTypeAliasSource(unionType: UnionType, typeAliasSource: Type) {
1916
- if (typeAliasSource.category === TypeCategory.Union) {
1917
- const sourcesToAdd = typeAliasSource.typeAliasInfo ? [typeAliasSource] : typeAliasSource.typeAliasSources;
1918
-
1919
- if (sourcesToAdd) {
1920
- if (!unionType.typeAliasSources) {
1921
- unionType.typeAliasSources = new Set<UnionType>();
1922
- }
1923
-
1924
- sourcesToAdd.forEach((source) => {
1925
- unionType.typeAliasSources!.add(source);
1926
- });
1927
- }
1928
- }
1929
- }
1930
- }
1931
-
1932
- export const enum Variance {
1933
- Invariant,
1934
- Covariant,
1935
- Contravariant,
1936
- }
1937
-
1938
- export interface TypeVarDetails {
1939
- name: string;
1940
- constraints: Type[];
1941
- boundType?: Type | undefined;
1942
- variance: Variance;
1943
- isParamSpec: boolean;
1944
- isVariadic: boolean;
1945
-
1946
- // Internally created (e.g. for pseudo-generic classes)
1947
- isSynthesized: boolean;
1948
- isSynthesizedSelf?: boolean | undefined;
1949
- synthesizedIndex?: number | undefined;
1950
- isExemptFromBoundCheck?: boolean;
1951
-
1952
- // Used for recursive type aliases.
1953
- recursiveTypeAliasName?: string | undefined;
1954
- recursiveTypeAliasScopeId?: TypeVarScopeId | undefined;
1955
- illegalRecursionDetected?: boolean | undefined;
1956
-
1957
- // Type parameters for a recursive type alias.
1958
- recursiveTypeParameters?: TypeVarType[] | undefined;
1959
- }
1960
-
1961
- export type ParamSpecAccess = 'args' | 'kwargs';
1962
-
1963
- export const enum TypeVarScopeType {
1964
- Class,
1965
- Function,
1966
- TypeAlias,
1967
- }
1968
-
1969
- export interface TypeVarType extends TypeBase {
1970
- category: TypeCategory.TypeVar;
1971
- details: TypeVarDetails;
1972
-
1973
- // An ID that uniquely identifies the scope in which this TypeVar is defined.
1974
- scopeId?: TypeVarScopeId | undefined;
1975
-
1976
- // A human-readable name of the function, class, or type alias that
1977
- // provides the scope for this type variable. This might not be unique,
1978
- // so it should be used only for error messages.
1979
- scopeName?: string | undefined;
1980
-
1981
- // If the TypeVar is bound to a scope, this is the scope type.
1982
- scopeType?: TypeVarScopeType;
1983
-
1984
- // String formatted as <name>.<scopeId>.
1985
- nameWithScope?: string | undefined;
1986
-
1987
- // Is this variadic TypeVar unpacked (i.e. Unpack or * operator applied)?
1988
- isVariadicUnpacked?: boolean | undefined;
1989
-
1990
- // Is this variadic TypeVar included in a Union[]? This allows us to
1991
- // differentiate between Unpack[Vs] and Union[Unpack[Vs]].
1992
- isVariadicInUnion?: boolean | undefined;
1993
-
1994
- // Represents access to "args" or "kwargs" of a ParamSpec.
1995
- paramSpecAccess?: ParamSpecAccess;
1996
- }
1997
-
1998
- export namespace TypeVarType {
1999
- export function createInstance(name: string) {
2000
- return create(name, /* isParamSpec */ false, TypeFlags.Instance);
2001
- }
2002
-
2003
- export function createInstantiable(name: string, isParamSpec = false) {
2004
- return create(name, isParamSpec, TypeFlags.Instantiable);
2005
- }
2006
-
2007
- export function cloneAsInstance(type: TypeVarType): TypeVarType {
2008
- assert(TypeBase.isInstantiable(type));
2009
- const newInstance = TypeBase.cloneTypeAsInstance(type);
2010
- newInstance.flags &= ~TypeFlags.SpecialForm;
2011
- return newInstance;
2012
- }
2013
-
2014
- export function cloneAsInstantiable(type: TypeVarType): TypeVarType {
2015
- const newInstance = TypeBase.cloneTypeAsInstantiable(type);
2016
- newInstance.flags &= ~TypeFlags.SpecialForm;
2017
- return newInstance;
2018
- }
2019
-
2020
- export function cloneForScopeId(
2021
- type: TypeVarType,
2022
- scopeId: string,
2023
- scopeName: string,
2024
- scopeType: TypeVarScopeType
2025
- ): TypeVarType {
2026
- const newInstance = TypeBase.cloneType(type);
2027
- newInstance.nameWithScope = makeNameWithScope(type.details.name, scopeId);
2028
- newInstance.scopeId = scopeId;
2029
- newInstance.scopeName = scopeName;
2030
- newInstance.scopeType = scopeType;
2031
- return newInstance;
2032
- }
2033
-
2034
- export function cloneForUnpacked(type: TypeVarType, isInUnion = false) {
2035
- assert(type.details.isVariadic);
2036
- const newInstance = TypeBase.cloneType(type);
2037
- newInstance.isVariadicUnpacked = true;
2038
- newInstance.isVariadicInUnion = isInUnion;
2039
- return newInstance;
2040
- }
2041
-
2042
- export function cloneForPacked(type: TypeVarType) {
2043
- assert(type.details.isVariadic);
2044
- const newInstance = TypeBase.cloneType(type);
2045
- newInstance.isVariadicUnpacked = false;
2046
- newInstance.isVariadicInUnion = false;
2047
- return newInstance;
2048
- }
2049
-
2050
- // Creates a "simplified" version of the TypeVar with invariance
2051
- // and no bound or constraints. ParamSpecs and variadics are left unmodified.
2052
- export function cloneAsInvariant(type: TypeVarType): TypeVarType {
2053
- if (type.details.isParamSpec || type.details.isVariadic) {
2054
- return type;
2055
- }
2056
-
2057
- if (type.details.variance === Variance.Invariant) {
2058
- if (type.details.boundType === undefined && type.details.constraints.length === 0) {
2059
- return type;
2060
- }
2061
- }
2062
-
2063
- const newInstance = TypeBase.cloneType(type);
2064
- newInstance.details = { ...newInstance.details };
2065
- newInstance.details.variance = Variance.Invariant;
2066
- newInstance.details.boundType = undefined;
2067
- newInstance.details.constraints = [];
2068
- return newInstance;
2069
- }
2070
-
2071
- export function cloneForParamSpecAccess(type: TypeVarType, access: ParamSpecAccess | undefined): TypeVarType {
2072
- const newInstance = TypeBase.cloneType(type);
2073
- newInstance.paramSpecAccess = access;
2074
- return newInstance;
2075
- }
2076
-
2077
- export function cloneAsSpecializedSelf(type: TypeVarType, specializedBoundType: Type): TypeVarType {
2078
- assert(type.details.isSynthesizedSelf);
2079
- const newInstance = TypeBase.cloneType(type);
2080
- newInstance.details = { ...newInstance.details };
2081
- newInstance.details.boundType = specializedBoundType;
2082
- return newInstance;
2083
- }
2084
-
2085
- export function makeNameWithScope(name: string, scopeId: string) {
2086
- return `${name}.${scopeId}`;
2087
- }
2088
-
2089
- function create(name: string, isParamSpec: boolean, typeFlags: TypeFlags): TypeVarType {
2090
- const newTypeVarType: TypeVarType = {
2091
- category: TypeCategory.TypeVar,
2092
- details: {
2093
- name,
2094
- constraints: [],
2095
- variance: Variance.Invariant,
2096
- isParamSpec,
2097
- isVariadic: false,
2098
- isSynthesized: false,
2099
- },
2100
- flags: typeFlags,
2101
- };
2102
- return newTypeVarType;
2103
- }
2104
-
2105
- export function addConstraint(typeVarType: TypeVarType, constraintType: Type) {
2106
- typeVarType.details.constraints.push(constraintType);
2107
- }
2108
-
2109
- export function getNameWithScope(typeVarType: TypeVarType) {
2110
- // If there is no name with scope, fall back on the (unscoped) name.
2111
- return typeVarType.nameWithScope || typeVarType.details.name;
2112
- }
2113
-
2114
- export function getReadableName(typeVarType: TypeVarType) {
2115
- if (typeVarType.scopeName) {
2116
- return `${typeVarType.details.name}@${typeVarType.scopeName}`;
2117
- }
2118
-
2119
- return typeVarType.details.name;
2120
- }
2121
- }
2122
-
2123
- export function isNever(type: Type): type is NeverType {
2124
- return type.category === TypeCategory.Never;
2125
- }
2126
-
2127
- export function isNoneInstance(type: Type): type is NoneType {
2128
- return type.category === TypeCategory.None && TypeBase.isInstance(type);
2129
- }
2130
-
2131
- export function isNoneTypeClass(type: Type): type is NoneType {
2132
- return type.category === TypeCategory.None && TypeBase.isInstantiable(type);
2133
- }
2134
-
2135
- export function isAny(type: Type): type is AnyType {
2136
- return type.category === TypeCategory.Any;
2137
- }
2138
-
2139
- export function isUnknown(type: Type): type is UnknownType {
2140
- return type.category === TypeCategory.Unknown;
2141
- }
2142
-
2143
- export function isAnyOrUnknown(type: Type): type is AnyType | UnknownType {
2144
- if (type.category === TypeCategory.Any || type.category === TypeCategory.Unknown) {
2145
- return true;
2146
- }
2147
-
2148
- if (isUnion(type)) {
2149
- return type.subtypes.find((subtype) => !isAnyOrUnknown(subtype)) === undefined;
2150
- }
2151
-
2152
- return false;
2153
- }
2154
-
2155
- export function isUnbound(type: Type): type is UnboundType {
2156
- return type.category === TypeCategory.Unbound;
2157
- }
2158
-
2159
- export function isUnion(type: Type): type is UnionType {
2160
- return type.category === TypeCategory.Union;
2161
- }
2162
-
2163
- export function isPossiblyUnbound(type: Type): boolean {
2164
- if (isUnbound(type)) {
2165
- return true;
2166
- }
2167
-
2168
- if (isUnion(type)) {
2169
- return type.subtypes.find((subtype) => isPossiblyUnbound(subtype)) !== undefined;
2170
- }
2171
-
2172
- return false;
2173
- }
2174
-
2175
- export function isClass(type: Type): type is ClassType {
2176
- return type.category === TypeCategory.Class;
2177
- }
2178
-
2179
- export function isInstantiableClass(type: Type): type is ClassType {
2180
- return type.category === TypeCategory.Class && TypeBase.isInstantiable(type);
2181
- }
2182
-
2183
- export function isClassInstance(type: Type): type is ClassType {
2184
- return type.category === TypeCategory.Class && TypeBase.isInstance(type);
2185
- }
2186
-
2187
- export function isModule(type: Type): type is ModuleType {
2188
- return type.category === TypeCategory.Module;
2189
- }
2190
-
2191
- export function isTypeVar(type: Type): type is TypeVarType {
2192
- return type.category === TypeCategory.TypeVar;
2193
- }
2194
-
2195
- export function isVariadicTypeVar(type: Type): type is TypeVarType {
2196
- return type.category === TypeCategory.TypeVar && type.details.isVariadic;
2197
- }
2198
-
2199
- export function isUnpackedVariadicTypeVar(type: Type): boolean {
2200
- if (isUnion(type) && type.subtypes.length === 1) {
2201
- type = type.subtypes[0];
2202
- }
2203
- return type.category === TypeCategory.TypeVar && type.details.isVariadic && !!type.isVariadicUnpacked;
2204
- }
2205
-
2206
- export function isUnpackedClass(type: Type): type is ClassType {
2207
- if (!isClass(type) || !type.isUnpacked) {
2208
- return false;
2209
- }
2210
-
2211
- return true;
2212
- }
2213
-
2214
- export function isUnpacked(type: Type): boolean {
2215
- return isUnpackedVariadicTypeVar(type) || isUnpackedClass(type);
2216
- }
2217
-
2218
- export function isParamSpec(type: Type): type is TypeVarType {
2219
- return type.category === TypeCategory.TypeVar && type.details.isParamSpec;
2220
- }
2221
-
2222
- export function isFunction(type: Type): type is FunctionType {
2223
- return type.category === TypeCategory.Function;
2224
- }
2225
-
2226
- export function isOverloadedFunction(type: Type): type is OverloadedFunctionType {
2227
- return type.category === TypeCategory.OverloadedFunction;
2228
- }
2229
-
2230
- export function getTypeAliasInfo(type: Type) {
2231
- if (type.typeAliasInfo) {
2232
- return type.typeAliasInfo;
2233
- }
2234
-
2235
- if (
2236
- isTypeVar(type) &&
2237
- type.details.recursiveTypeAliasName &&
2238
- type.details.boundType &&
2239
- type.details.boundType.typeAliasInfo
2240
- ) {
2241
- return type.details.boundType.typeAliasInfo;
2242
- }
2243
-
2244
- return undefined;
2245
- }
2246
-
2247
- // Determines whether two types are the same. If ignorePseudoGeneric is true,
2248
- // type arguments for "pseudo-generic" classes (non-generic classes whose init
2249
- // methods are not annotated and are therefore treated as generic) are ignored.
2250
- export function isTypeSame(
2251
- type1: Type,
2252
- type2: Type,
2253
- ignorePseudoGeneric = false,
2254
- ignoreTypeFlags = false,
2255
- recursionCount = 0
2256
- ): boolean {
2257
- if (type1 === type2) {
2258
- return true;
2259
- }
2260
-
2261
- if (type1.category !== type2.category) {
2262
- return false;
2263
- }
2264
-
2265
- if (!ignoreTypeFlags && type1.flags !== type2.flags) {
2266
- return false;
2267
- }
2268
-
2269
- if (recursionCount > maxTypeRecursionCount) {
2270
- return true;
2271
- }
2272
- recursionCount++;
2273
-
2274
- switch (type1.category) {
2275
- case TypeCategory.Class: {
2276
- const classType2 = type2 as ClassType;
2277
-
2278
- // If the details are not the same it's not the same class.
2279
- if (!ClassType.isSameGenericClass(type1, classType2, recursionCount)) {
2280
- return false;
2281
- }
2282
-
2283
- if (!TypeCondition.isSame(type1.condition, type2.condition)) {
2284
- return false;
2285
- }
2286
-
2287
- if (!ignorePseudoGeneric || !ClassType.isPseudoGenericClass(type1)) {
2288
- // Make sure the type args match.
2289
- if (type1.tupleTypeArguments && classType2.tupleTypeArguments) {
2290
- const type1TupleTypeArgs = type1.tupleTypeArguments || [];
2291
- const type2TupleTypeArgs = classType2.tupleTypeArguments || [];
2292
- if (type1TupleTypeArgs.length !== type2TupleTypeArgs.length) {
2293
- return false;
2294
- }
2295
-
2296
- for (let i = 0; i < type1TupleTypeArgs.length; i++) {
2297
- if (
2298
- !isTypeSame(
2299
- type1TupleTypeArgs[i].type,
2300
- type2TupleTypeArgs[i].type,
2301
- ignorePseudoGeneric,
2302
- /* ignoreTypeFlags */ false,
2303
- recursionCount
2304
- )
2305
- ) {
2306
- return false;
2307
- }
2308
-
2309
- if (type1TupleTypeArgs[i].isUnbounded !== type2TupleTypeArgs[i].isUnbounded) {
2310
- return false;
2311
- }
2312
- }
2313
- } else {
2314
- const type1TypeArgs = type1.typeArguments || [];
2315
- const type2TypeArgs = classType2.typeArguments || [];
2316
- const typeArgCount = Math.max(type1TypeArgs.length, type2TypeArgs.length);
2317
-
2318
- for (let i = 0; i < typeArgCount; i++) {
2319
- // Assume that missing type args are "Any".
2320
- const typeArg1 = i < type1TypeArgs.length ? type1TypeArgs[i] : AnyType.create();
2321
- const typeArg2 = i < type2TypeArgs.length ? type2TypeArgs[i] : AnyType.create();
2322
-
2323
- if (
2324
- !isTypeSame(
2325
- typeArg1,
2326
- typeArg2,
2327
- ignorePseudoGeneric,
2328
- /* ignoreTypeFlags */ false,
2329
- recursionCount
2330
- )
2331
- ) {
2332
- return false;
2333
- }
2334
- }
2335
- }
2336
- }
2337
-
2338
- if (!ClassType.isLiteralValueSame(type1, classType2)) {
2339
- return false;
2340
- }
2341
-
2342
- return true;
2343
- }
2344
-
2345
- case TypeCategory.Function: {
2346
- // Make sure the parameter counts match.
2347
- const functionType2 = type2 as FunctionType;
2348
- const params1 = type1.details.parameters;
2349
- const params2 = functionType2.details.parameters;
2350
-
2351
- if (params1.length !== params2.length) {
2352
- return false;
2353
- }
2354
-
2355
- const positionalOnlyIndex1 = params1.findIndex(
2356
- (param) => param.category === ParameterCategory.Simple && !param.name
2357
- );
2358
- const positionalOnlyIndex2 = params2.findIndex(
2359
- (param) => param.category === ParameterCategory.Simple && !param.name
2360
- );
2361
-
2362
- // Make sure the parameter details match.
2363
- for (let i = 0; i < params1.length; i++) {
2364
- const param1 = params1[i];
2365
- const param2 = params2[i];
2366
-
2367
- if (param1.category !== param2.category) {
2368
- return false;
2369
- }
2370
-
2371
- const isName1Relevant = positionalOnlyIndex1 !== undefined && i >= positionalOnlyIndex1;
2372
- const isName2Relevant = positionalOnlyIndex2 !== undefined && i >= positionalOnlyIndex2;
2373
-
2374
- if (isName1Relevant !== isName2Relevant) {
2375
- return false;
2376
- }
2377
-
2378
- if (isName1Relevant) {
2379
- if (param1.name !== param2.name) {
2380
- return false;
2381
- }
2382
- }
2383
-
2384
- const param1Type = FunctionType.getEffectiveParameterType(type1, i);
2385
- const param2Type = FunctionType.getEffectiveParameterType(functionType2, i);
2386
- if (
2387
- !isTypeSame(
2388
- param1Type,
2389
- param2Type,
2390
- ignorePseudoGeneric,
2391
- /* ignoreTypeFlags */ false,
2392
- recursionCount
2393
- )
2394
- ) {
2395
- return false;
2396
- }
2397
- }
2398
-
2399
- // Make sure the return types match.
2400
- let return1Type = type1.details.declaredReturnType;
2401
- if (type1.specializedTypes && type1.specializedTypes.returnType) {
2402
- return1Type = type1.specializedTypes.returnType;
2403
- }
2404
- if (!return1Type && type1.inferredReturnType) {
2405
- return1Type = type1.inferredReturnType;
2406
- }
2407
-
2408
- let return2Type = functionType2.details.declaredReturnType;
2409
- if (functionType2.specializedTypes && functionType2.specializedTypes.returnType) {
2410
- return2Type = functionType2.specializedTypes.returnType;
2411
- }
2412
- if (!return2Type && functionType2.inferredReturnType) {
2413
- return2Type = functionType2.inferredReturnType;
2414
- }
2415
-
2416
- if (return1Type || return2Type) {
2417
- if (
2418
- !return1Type ||
2419
- !return2Type ||
2420
- !isTypeSame(
2421
- return1Type,
2422
- return2Type,
2423
- ignorePseudoGeneric,
2424
- /* ignoreTypeFlags */ false,
2425
- recursionCount
2426
- )
2427
- ) {
2428
- return false;
2429
- }
2430
- }
2431
-
2432
- return true;
2433
- }
2434
-
2435
- case TypeCategory.OverloadedFunction: {
2436
- // Make sure the overload counts match.
2437
- const functionType2 = type2 as OverloadedFunctionType;
2438
- if (type1.overloads.length !== functionType2.overloads.length) {
2439
- return false;
2440
- }
2441
-
2442
- // We assume here that overloaded functions always appear
2443
- // in the same order from one analysis pass to another.
2444
- for (let i = 0; i < type1.overloads.length; i++) {
2445
- if (
2446
- !isTypeSame(
2447
- type1.overloads[i],
2448
- functionType2.overloads[i],
2449
- ignorePseudoGeneric,
2450
- ignoreTypeFlags,
2451
- recursionCount
2452
- )
2453
- ) {
2454
- return false;
2455
- }
2456
- }
2457
-
2458
- return true;
2459
- }
2460
-
2461
- case TypeCategory.Union: {
2462
- const unionType2 = type2 as UnionType;
2463
- const subtypes1 = type1.subtypes;
2464
- const subtypes2 = unionType2.subtypes;
2465
-
2466
- if (subtypes1.length !== subtypes2.length) {
2467
- return false;
2468
- }
2469
-
2470
- // The types do not have a particular order, so we need to
2471
- // do the comparison in an order-independent manner.
2472
- return (
2473
- findSubtype(type1, (subtype) => !UnionType.containsType(unionType2, subtype, recursionCount)) ===
2474
- undefined
2475
- );
2476
- }
2477
-
2478
- case TypeCategory.TypeVar: {
2479
- const type2TypeVar = type2 as TypeVarType;
2480
-
2481
- if (type1.scopeId !== type2TypeVar.scopeId) {
2482
- return false;
2483
- }
2484
-
2485
- // Handle the case where this is a generic recursive type alias. Make
2486
- // sure that the type argument types match.
2487
- if (type1.details.recursiveTypeParameters && type2TypeVar.details.recursiveTypeParameters) {
2488
- const type1TypeArgs = type1?.typeAliasInfo?.typeArguments || [];
2489
- const type2TypeArgs = type2?.typeAliasInfo?.typeArguments || [];
2490
- const typeArgCount = Math.max(type1TypeArgs.length, type2TypeArgs.length);
2491
-
2492
- for (let i = 0; i < typeArgCount; i++) {
2493
- // Assume that missing type args are "Any".
2494
- const typeArg1 = i < type1TypeArgs.length ? type1TypeArgs[i] : AnyType.create();
2495
- const typeArg2 = i < type2TypeArgs.length ? type2TypeArgs[i] : AnyType.create();
2496
-
2497
- if (
2498
- !isTypeSame(
2499
- typeArg1,
2500
- typeArg2,
2501
- ignorePseudoGeneric,
2502
- /* ignoreTypeFlags */ false,
2503
- recursionCount
2504
- )
2505
- ) {
2506
- return false;
2507
- }
2508
- }
2509
- }
2510
-
2511
- if (type1.details === type2TypeVar.details) {
2512
- return true;
2513
- }
2514
-
2515
- if (
2516
- type1.details.name !== type2TypeVar.details.name ||
2517
- type1.details.isParamSpec !== type2TypeVar.details.isParamSpec ||
2518
- type1.details.isVariadic !== type2TypeVar.details.isVariadic ||
2519
- type1.details.isSynthesized !== type2TypeVar.details.isSynthesized ||
2520
- type1.details.variance !== type2TypeVar.details.variance ||
2521
- type1.scopeId !== type2TypeVar.scopeId
2522
- ) {
2523
- return false;
2524
- }
2525
-
2526
- const boundType1 = type1.details.boundType;
2527
- const boundType2 = type2TypeVar.details.boundType;
2528
- if (boundType1) {
2529
- if (
2530
- !boundType2 ||
2531
- !isTypeSame(
2532
- boundType1,
2533
- boundType2,
2534
- ignorePseudoGeneric,
2535
- /* ignoreTypeFlags */ false,
2536
- recursionCount
2537
- )
2538
- ) {
2539
- return false;
2540
- }
2541
- } else {
2542
- if (boundType2) {
2543
- return false;
2544
- }
2545
- }
2546
-
2547
- const constraints1 = type1.details.constraints;
2548
- const constraints2 = type2TypeVar.details.constraints;
2549
- if (constraints1.length !== constraints2.length) {
2550
- return false;
2551
- }
2552
-
2553
- for (let i = 0; i < constraints1.length; i++) {
2554
- if (
2555
- !isTypeSame(
2556
- constraints1[i],
2557
- constraints2[i],
2558
- ignorePseudoGeneric,
2559
- /* ignoreTypeFlags */ false,
2560
- recursionCount
2561
- )
2562
- ) {
2563
- return false;
2564
- }
2565
- }
2566
-
2567
- return true;
2568
- }
2569
-
2570
- case TypeCategory.Module: {
2571
- const type2Module = type2 as ModuleType;
2572
-
2573
- // Module types are the same if they share the same
2574
- // module symbol table.
2575
- if (type1.fields === type2Module.fields) {
2576
- return true;
2577
- }
2578
-
2579
- // If both symbol tables are empty, we can also assume
2580
- // they're equal.
2581
- if (type1.fields.size === 0 && type2Module.fields.size === 0) {
2582
- return true;
2583
- }
2584
-
2585
- return false;
2586
- }
2587
- }
2588
-
2589
- return true;
2590
- }
2591
-
2592
- // If the type is a union, remove an "unknown" type from the union,
2593
- // returning only the known types.
2594
- export function removeUnknownFromUnion(type: Type): Type {
2595
- return removeFromUnion(type, (t: Type) => isUnknown(t));
2596
- }
2597
-
2598
- export function removeIncompleteUnknownFromUnion(type: Type): Type {
2599
- return removeFromUnion(type, (t: Type) => isUnknown(t) && t.isIncomplete);
2600
- }
2601
-
2602
- // If the type is a union, remove an "unbound" type from the union,
2603
- // returning only the known types.
2604
- export function removeUnbound(type: Type): Type {
2605
- if (isUnion(type)) {
2606
- return removeFromUnion(type, (t: Type) => isUnbound(t));
2607
- }
2608
-
2609
- if (isUnbound(type)) {
2610
- return UnknownType.create();
2611
- }
2612
-
2613
- return type;
2614
- }
2615
-
2616
- // If the type is a union, remove an "None" type from the union,
2617
- // returning only the known types.
2618
- export function removeNoneFromUnion(type: Type): Type {
2619
- return removeFromUnion(type, (t: Type) => isNoneInstance(t));
2620
- }
2621
-
2622
- export function removeFromUnion(type: Type, removeFilter: (type: Type) => boolean) {
2623
- if (isUnion(type)) {
2624
- const remainingTypes = type.subtypes.filter((t) => !removeFilter(t));
2625
- if (remainingTypes.length < type.subtypes.length) {
2626
- const newType = combineTypes(remainingTypes);
2627
-
2628
- if (isUnion(newType)) {
2629
- UnionType.addTypeAliasSource(newType, type);
2630
- }
2631
-
2632
- return newType;
2633
- }
2634
- }
2635
-
2636
- return type;
2637
- }
2638
-
2639
- export function findSubtype(type: Type, filter: (type: UnionableType | NeverType) => boolean) {
2640
- if (isUnion(type)) {
2641
- return type.subtypes.find((subtype) => {
2642
- return filter(subtype);
2643
- });
2644
- }
2645
-
2646
- return filter(type) ? type : undefined;
2647
- }
2648
-
2649
- // Combines multiple types into a single type. If the types are
2650
- // the same, only one is returned. If they differ, they
2651
- // are combined into a UnionType. NeverTypes are filtered out.
2652
- // If no types remain in the end, a NeverType is returned.
2653
- export function combineTypes(subtypes: Type[], maxSubtypeCount?: number): Type {
2654
- // Filter out any "Never" and "NoReturn" types.
2655
- let sawNoReturn = false;
2656
-
2657
- if (subtypes.some((subtype) => subtype.category === TypeCategory.Never))
2658
- subtypes = subtypes.filter((subtype) => {
2659
- if (subtype.category === TypeCategory.Never && subtype.isNoReturn) {
2660
- sawNoReturn = true;
2661
- }
2662
- return subtype.category !== TypeCategory.Never;
2663
- });
2664
-
2665
- if (subtypes.length === 0) {
2666
- return sawNoReturn ? NeverType.createNoReturn() : NeverType.createNever();
2667
- }
2668
-
2669
- // Handle the common case where there is only one type.
2670
- // Also handle the common case where there are multiple copies of the same type.
2671
- let allSubtypesAreSame = true;
2672
- if (subtypes.length > 1) {
2673
- for (let index = 1; index < subtypes.length; index++) {
2674
- if (subtypes[index] !== subtypes[0]) {
2675
- allSubtypesAreSame = false;
2676
- break;
2677
- }
2678
- }
2679
- }
2680
-
2681
- if (allSubtypesAreSame) {
2682
- return subtypes[0];
2683
- }
2684
-
2685
- // Expand all union types.
2686
- let expandedTypes: Type[] = [];
2687
- const typeAliasSources = new Set<UnionType>();
2688
-
2689
- for (const subtype of subtypes) {
2690
- if (isUnion(subtype)) {
2691
- expandedTypes = expandedTypes.concat(subtype.subtypes);
2692
-
2693
- if (subtype.typeAliasInfo) {
2694
- typeAliasSources.add(subtype);
2695
- } else if (subtype.typeAliasSources) {
2696
- subtype.typeAliasSources.forEach((subtype) => {
2697
- typeAliasSources.add(subtype);
2698
- });
2699
- }
2700
- } else {
2701
- expandedTypes.push(subtype);
2702
- }
2703
- }
2704
-
2705
- // Sort all of the literal and empty types to the end.
2706
- expandedTypes = expandedTypes.sort((type1, type2) => {
2707
- if (
2708
- (isClassInstance(type1) && type1.literalValue !== undefined) ||
2709
- (isInstantiableClass(type1) && type1.literalValue !== undefined)
2710
- ) {
2711
- return 1;
2712
- } else if (
2713
- (isClassInstance(type2) && type2.literalValue !== undefined) ||
2714
- (isInstantiableClass(type2) && type2.literalValue !== undefined)
2715
- ) {
2716
- return -1;
2717
- }
2718
-
2719
- if (isClassInstance(type1) && type1.isEmptyContainer) {
2720
- return 1;
2721
- } else if (isClassInstance(type2) && type2.isEmptyContainer) {
2722
- return -1;
2723
- }
2724
-
2725
- return 0;
2726
- });
2727
-
2728
- // If removing all NoReturn types results in no remaining types,
2729
- // convert it to an unknown.
2730
- if (expandedTypes.length === 0) {
2731
- return UnknownType.create();
2732
- }
2733
-
2734
- const newUnionType = UnionType.create();
2735
- if (typeAliasSources.size > 0) {
2736
- newUnionType.typeAliasSources = typeAliasSources;
2737
- }
2738
-
2739
- let hitMaxSubtypeCount = false;
2740
-
2741
- expandedTypes.forEach((subtype, index) => {
2742
- if (index === 0) {
2743
- UnionType.addType(newUnionType, subtype as UnionableType);
2744
- } else {
2745
- if (maxSubtypeCount === undefined || newUnionType.subtypes.length < maxSubtypeCount) {
2746
- _addTypeIfUnique(newUnionType, subtype as UnionableType);
2747
- } else {
2748
- hitMaxSubtypeCount = true;
2749
- }
2750
- }
2751
- });
2752
-
2753
- if (hitMaxSubtypeCount) {
2754
- return AnyType.create();
2755
- }
2756
-
2757
- // If only one type remains, convert it from a union to a simple type.
2758
- if (newUnionType.subtypes.length === 1) {
2759
- return newUnionType.subtypes[0];
2760
- }
2761
-
2762
- return newUnionType;
2763
- }
2764
-
2765
- // Determines whether the dest type is the same as the source type with
2766
- // the possible exception that the source type has a literal value when
2767
- // the dest does not.
2768
- export function isSameWithoutLiteralValue(destType: Type, srcType: Type): boolean {
2769
- // If it's the same with literals, great.
2770
- if (isTypeSame(destType, srcType)) {
2771
- return true;
2772
- }
2773
-
2774
- if (isInstantiableClass(srcType) && srcType.literalValue !== undefined) {
2775
- // Strip the literal.
2776
- srcType = ClassType.cloneWithLiteral(srcType, /* value */ undefined);
2777
- return isTypeSame(destType, srcType);
2778
- }
2779
-
2780
- if (isClassInstance(srcType) && srcType.literalValue !== undefined) {
2781
- // Strip the literal.
2782
- srcType = ClassType.cloneWithLiteral(srcType, /* value */ undefined);
2783
- return isTypeSame(destType, srcType);
2784
- }
2785
-
2786
- return false;
2787
- }
2788
-
2789
- function _addTypeIfUnique(unionType: UnionType, typeToAdd: UnionableType) {
2790
- // Handle the addition of a string literal in a special manner to
2791
- // avoid n^2 behavior in unions that contain hundreds of string
2792
- // literal types. Skip this for constrained types.
2793
- if (isClassInstance(typeToAdd) && typeToAdd.condition === undefined) {
2794
- if (
2795
- ClassType.isBuiltIn(typeToAdd, 'str') &&
2796
- typeToAdd.literalValue !== undefined &&
2797
- unionType.literalStrMap !== undefined
2798
- ) {
2799
- if (!unionType.literalStrMap.has(typeToAdd.literalValue as string)) {
2800
- UnionType.addType(unionType, typeToAdd);
2801
- }
2802
- return;
2803
- } else if (
2804
- ClassType.isBuiltIn(typeToAdd, 'int') &&
2805
- typeToAdd.literalValue !== undefined &&
2806
- unionType.literalIntMap !== undefined
2807
- ) {
2808
- if (!unionType.literalIntMap.has(typeToAdd.literalValue as number | bigint)) {
2809
- UnionType.addType(unionType, typeToAdd);
2810
- }
2811
- return;
2812
- }
2813
- }
2814
-
2815
- for (let i = 0; i < unionType.subtypes.length; i++) {
2816
- const type = unionType.subtypes[i];
2817
-
2818
- // Does this type already exist in the types array?
2819
- if (isTypeSame(type, typeToAdd)) {
2820
- return;
2821
- }
2822
-
2823
- // If the typeToAdd is a literal value and there's already
2824
- // a non-literal type that matches, don't add the literal value.
2825
- if (isClassInstance(type) && isClassInstance(typeToAdd)) {
2826
- if (isSameWithoutLiteralValue(type, typeToAdd)) {
2827
- if (type.literalValue === undefined) {
2828
- return;
2829
- }
2830
- }
2831
-
2832
- // If we're adding Literal[False] or Literal[True] to its
2833
- // opposite, combine them into a non-literal 'bool' type.
2834
- if (
2835
- ClassType.isBuiltIn(type, 'bool') &&
2836
- !type.condition &&
2837
- ClassType.isBuiltIn(typeToAdd, 'bool') &&
2838
- !typeToAdd.condition
2839
- ) {
2840
- if (typeToAdd.literalValue !== undefined && !typeToAdd.literalValue === type.literalValue) {
2841
- unionType.subtypes[i] = ClassType.cloneWithLiteral(type, /* value */ undefined);
2842
- return;
2843
- }
2844
- }
2845
- }
2846
-
2847
- // If the typeToAdd is an empty container and there's already
2848
- // non-empty container of the same type, don't add the empty container.
2849
- if (isClassInstance(typeToAdd) && typeToAdd.isEmptyContainer) {
2850
- if (isClassInstance(type) && ClassType.isSameGenericClass(type, typeToAdd)) {
2851
- return;
2852
- }
2853
- }
2854
- }
2855
-
2856
- UnionType.addType(unionType, typeToAdd);
2857
- }