@gnost-cli/darwin-arm64 0.0.1 → 0.5.1-rc.2

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 (1407) hide show
  1. package/README.md +1 -1
  2. package/bundle/_internal/6ec57f84c680d3a3778b__mypyc.cpython-312-darwin.so +4 -0
  3. package/bundle/_internal/Python +0 -0
  4. package/bundle/_internal/Python.framework/Python +0 -0
  5. package/bundle/_internal/Python.framework/Resources/Info.plist +30 -0
  6. package/bundle/_internal/Python.framework/Versions/3.12/Python +0 -0
  7. package/bundle/_internal/Python.framework/Versions/3.12/Resources/Info.plist +30 -0
  8. package/bundle/_internal/Python.framework/Versions/Current/Python +0 -0
  9. package/bundle/_internal/Python.framework/Versions/Current/Resources/Info.plist +30 -0
  10. package/bundle/_internal/ast_serialize/ast_serialize.abi3.so +0 -0
  11. package/bundle/_internal/bandit/__init__.py +20 -0
  12. package/bundle/_internal/bandit/__main__.py +17 -0
  13. package/bundle/_internal/bandit/blacklists/__init__.py +0 -0
  14. package/bundle/_internal/bandit/blacklists/calls.py +670 -0
  15. package/bundle/_internal/bandit/blacklists/imports.py +425 -0
  16. package/bundle/_internal/bandit/blacklists/utils.py +17 -0
  17. package/bundle/_internal/bandit/cli/__init__.py +0 -0
  18. package/bundle/_internal/bandit/cli/baseline.py +252 -0
  19. package/bundle/_internal/bandit/cli/config_generator.py +207 -0
  20. package/bundle/_internal/bandit/cli/main.py +701 -0
  21. package/bundle/_internal/bandit/core/__init__.py +15 -0
  22. package/bundle/_internal/bandit/core/blacklisting.py +72 -0
  23. package/bundle/_internal/bandit/core/config.py +271 -0
  24. package/bundle/_internal/bandit/core/constants.py +40 -0
  25. package/bundle/_internal/bandit/core/context.py +316 -0
  26. package/bundle/_internal/bandit/core/docs_utils.py +54 -0
  27. package/bundle/_internal/bandit/core/extension_loader.py +114 -0
  28. package/bundle/_internal/bandit/core/issue.py +245 -0
  29. package/bundle/_internal/bandit/core/manager.py +499 -0
  30. package/bundle/_internal/bandit/core/meta_ast.py +44 -0
  31. package/bundle/_internal/bandit/core/metrics.py +106 -0
  32. package/bundle/_internal/bandit/core/node_visitor.py +297 -0
  33. package/bundle/_internal/bandit/core/test_properties.py +83 -0
  34. package/bundle/_internal/bandit/core/test_set.py +114 -0
  35. package/bundle/_internal/bandit/core/tester.py +168 -0
  36. package/bundle/_internal/bandit/core/utils.py +398 -0
  37. package/bundle/_internal/bandit/formatters/__init__.py +0 -0
  38. package/bundle/_internal/bandit/formatters/csv.py +82 -0
  39. package/bundle/_internal/bandit/formatters/custom.py +161 -0
  40. package/bundle/_internal/bandit/formatters/html.py +394 -0
  41. package/bundle/_internal/bandit/formatters/json.py +155 -0
  42. package/bundle/_internal/bandit/formatters/sarif.py +374 -0
  43. package/bundle/_internal/bandit/formatters/screen.py +244 -0
  44. package/bundle/_internal/bandit/formatters/text.py +200 -0
  45. package/bundle/_internal/bandit/formatters/utils.py +14 -0
  46. package/bundle/_internal/bandit/formatters/xml.py +97 -0
  47. package/bundle/_internal/bandit/formatters/yaml.py +126 -0
  48. package/bundle/_internal/bandit/plugins/__init__.py +0 -0
  49. package/bundle/_internal/bandit/plugins/app_debug.py +63 -0
  50. package/bundle/_internal/bandit/plugins/asserts.py +83 -0
  51. package/bundle/_internal/bandit/plugins/crypto_request_no_cert_validation.py +75 -0
  52. package/bundle/_internal/bandit/plugins/django_sql_injection.py +155 -0
  53. package/bundle/_internal/bandit/plugins/django_xss.py +287 -0
  54. package/bundle/_internal/bandit/plugins/exec.py +55 -0
  55. package/bundle/_internal/bandit/plugins/general_bad_file_permissions.py +99 -0
  56. package/bundle/_internal/bandit/plugins/general_bind_all_interfaces.py +52 -0
  57. package/bundle/_internal/bandit/plugins/general_hardcoded_password.py +282 -0
  58. package/bundle/_internal/bandit/plugins/general_hardcoded_tmp.py +79 -0
  59. package/bundle/_internal/bandit/plugins/hashlib_insecure_functions.py +121 -0
  60. package/bundle/_internal/bandit/plugins/huggingface_unsafe_download.py +166 -0
  61. package/bundle/_internal/bandit/plugins/injection_paramiko.py +63 -0
  62. package/bundle/_internal/bandit/plugins/injection_shell.py +706 -0
  63. package/bundle/_internal/bandit/plugins/injection_sql.py +143 -0
  64. package/bundle/_internal/bandit/plugins/injection_wildcard.py +144 -0
  65. package/bundle/_internal/bandit/plugins/insecure_ssl_tls.py +285 -0
  66. package/bundle/_internal/bandit/plugins/jinja2_templates.py +134 -0
  67. package/bundle/_internal/bandit/plugins/logging_config_insecure_listen.py +58 -0
  68. package/bundle/_internal/bandit/plugins/mako_templates.py +69 -0
  69. package/bundle/_internal/bandit/plugins/markupsafe_markup_xss.py +118 -0
  70. package/bundle/_internal/bandit/plugins/pytorch_load.py +77 -0
  71. package/bundle/_internal/bandit/plugins/request_without_timeout.py +84 -0
  72. package/bundle/_internal/bandit/plugins/snmp_security_check.py +110 -0
  73. package/bundle/_internal/bandit/plugins/ssh_no_host_key_verification.py +76 -0
  74. package/bundle/_internal/bandit/plugins/tarfile_unsafe_members.py +121 -0
  75. package/bundle/_internal/bandit/plugins/trojansource.py +82 -0
  76. package/bundle/_internal/bandit/plugins/try_except_continue.py +108 -0
  77. package/bundle/_internal/bandit/plugins/try_except_pass.py +106 -0
  78. package/bundle/_internal/bandit/plugins/weak_cryptographic_key.py +165 -0
  79. package/bundle/_internal/bandit/plugins/yaml_load.py +76 -0
  80. package/bundle/_internal/bandit-1.9.4.dist-info/INSTALLER +1 -0
  81. package/bundle/_internal/bandit-1.9.4.dist-info/METADATA +212 -0
  82. package/bundle/_internal/bandit-1.9.4.dist-info/RECORD +150 -0
  83. package/bundle/_internal/bandit-1.9.4.dist-info/WHEEL +5 -0
  84. package/bundle/_internal/bandit-1.9.4.dist-info/entry_points.txt +63 -0
  85. package/bundle/_internal/bandit-1.9.4.dist-info/licenses/LICENSE +175 -0
  86. package/bundle/_internal/bandit-1.9.4.dist-info/pbr.json +1 -0
  87. package/bundle/_internal/bandit-1.9.4.dist-info/top_level.txt +1 -0
  88. package/bundle/_internal/base_library.zip +0 -0
  89. package/bundle/_internal/bin/ruff +0 -0
  90. package/bundle/_internal/gnost/__init__.py +1 -0
  91. package/bundle/_internal/gnost/analysis/__init__.py +0 -0
  92. package/bundle/_internal/gnost/analysis/analyzers/__init__.py +11 -0
  93. package/bundle/_internal/gnost/analysis/analyzers/maintainability_analyzer.py +901 -0
  94. package/bundle/_internal/gnost/analysis/analyzers/observability_analyzer.py +592 -0
  95. package/bundle/_internal/gnost/analysis/analyzers/readability_analyzer.py +968 -0
  96. package/bundle/_internal/gnost/analysis/analyzers/robustness_analyzer.py +944 -0
  97. package/bundle/_internal/gnost/analysis/config/mypy.ini +4 -0
  98. package/bundle/_internal/gnost/analysis/core/__init__.py +0 -0
  99. package/bundle/_internal/gnost/analysis/core/aggregator.py +584 -0
  100. package/bundle/_internal/gnost/analysis/core/engine.py +430 -0
  101. package/bundle/_internal/gnost/analysis/core/file_utils.py +209 -0
  102. package/bundle/_internal/gnost/analysis/core/interfaces.py +304 -0
  103. package/bundle/_internal/gnost/analysis/core/models.py +479 -0
  104. package/bundle/_internal/gnost/analysis/core/tool_runner.py +153 -0
  105. package/bundle/_internal/gnost/analysis/core/transformers.py +779 -0
  106. package/bundle/_internal/gnost/analysis/utils/__init__.py +0 -0
  107. package/bundle/_internal/gnost/analysis/utils/analyze.py +132 -0
  108. package/bundle/_internal/gnost/analysis/utils/df_handling.py +215 -0
  109. package/bundle/_internal/gnost/analysis/utils/duplicate_code.py +42 -0
  110. package/bundle/_internal/gnost/analysis/utils/extract.py +172 -0
  111. package/bundle/_internal/gnost/analysis/utils/mi.py +130 -0
  112. package/bundle/_internal/gnost/analysis/utils/tool_command.py +63 -0
  113. package/bundle/_internal/gnost/cli/__init__.py +3 -0
  114. package/bundle/_internal/gnost/cli/app.py +696 -0
  115. package/bundle/_internal/gnost/cli/commands/__init__.py +3 -0
  116. package/bundle/_internal/gnost/cli/commands/analysis.py +190 -0
  117. package/bundle/_internal/gnost/cli/commands/onboard.py +507 -0
  118. package/bundle/_internal/gnost/cli/commands/show.py +70 -0
  119. package/bundle/_internal/gnost/config/__init__.py +0 -0
  120. package/bundle/_internal/gnost/config/languages.py +10 -0
  121. package/bundle/_internal/gnost/config/settings.py +240 -0
  122. package/bundle/_internal/gnost/core/__init__.py +0 -0
  123. package/bundle/_internal/gnost/core/callgraph.py +399 -0
  124. package/bundle/_internal/gnost/core/caution.py +315 -0
  125. package/bundle/_internal/gnost/core/cycles.py +148 -0
  126. package/bundle/_internal/gnost/core/flow.py +204 -0
  127. package/bundle/_internal/gnost/core/graph.py +108 -0
  128. package/bundle/_internal/gnost/core/insight_builder.py +164 -0
  129. package/bundle/_internal/gnost/core/ranker.py +119 -0
  130. package/bundle/_internal/gnost/core/resolver.py +304 -0
  131. package/bundle/_internal/gnost/languages/base.py +108 -0
  132. package/bundle/_internal/gnost/languages/java.py +104 -0
  133. package/bundle/_internal/gnost/languages/javascript.py +153 -0
  134. package/bundle/_internal/gnost/languages/manifests.py +45 -0
  135. package/bundle/_internal/gnost/languages/python.py +318 -0
  136. package/bundle/_internal/gnost/languages/typescript.py +6 -0
  137. package/bundle/_internal/gnost/models/__init__.py +0 -0
  138. package/bundle/_internal/gnost/models/insights.py +68 -0
  139. package/bundle/_internal/gnost/reporters/__init__.py +3 -0
  140. package/bundle/_internal/gnost/reporters/analysis_html.py +1292 -0
  141. package/bundle/_internal/gnost/reporters/diagram_viewer.py +153 -0
  142. package/bundle/_internal/gnost/reporters/files.py +18 -0
  143. package/bundle/_internal/gnost/reporters/folders.py +18 -0
  144. package/bundle/_internal/gnost/reporters/insights_json.py +189 -0
  145. package/bundle/_internal/gnost/reporters/loc_summary.py +19 -0
  146. package/bundle/_internal/gnost/reporters/markdown.py +372 -0
  147. package/bundle/_internal/gnost/reporters/mermaid.py +543 -0
  148. package/bundle/_internal/gnost/reporters/mermaid_graph.py +309 -0
  149. package/bundle/_internal/gnost/reporters/readme.py +81 -0
  150. package/bundle/_internal/gnost/reporters/stats.py +13 -0
  151. package/bundle/_internal/gnost/reporters/summary.py +223 -0
  152. package/bundle/_internal/gnost/reporters/templates/analyzer_guides.json +247 -0
  153. package/bundle/_internal/gnost/reporters/templates/analyzer_guides_layout.html +9 -0
  154. package/bundle/_internal/gnost/reporters/templates/graph_viewer.html +427 -0
  155. package/bundle/_internal/gnost/reporters/vendor/THIRD_PARTY_NOTICES.md +205 -0
  156. package/bundle/_internal/gnost/reporters/vendor/cose-base.js +3214 -0
  157. package/bundle/_internal/gnost/reporters/vendor/cytoscape-fcose.js +1549 -0
  158. package/bundle/_internal/gnost/reporters/vendor/cytoscape.min.js +32 -0
  159. package/bundle/_internal/gnost/reporters/vendor/layout-base.js +5230 -0
  160. package/bundle/_internal/gnost/reporters/vendor/marked.min.js +6 -0
  161. package/bundle/_internal/gnost/reporters/vendor/mermaid.min.js +2314 -0
  162. package/bundle/_internal/gnost/reporters/vendor/svg-pan-zoom.min.js +3 -0
  163. package/bundle/_internal/gnost/reporters/vendor/vendor.json +44 -0
  164. package/bundle/_internal/gnost/routes/__init__.py +45 -0
  165. package/bundle/_internal/gnost/routes/java.py +72 -0
  166. package/bundle/_internal/gnost/routes/javascript.py +275 -0
  167. package/bundle/_internal/gnost/routes/models.py +58 -0
  168. package/bundle/_internal/gnost/routes/python.py +429 -0
  169. package/bundle/_internal/gnost/scanner/__init__.py +4 -0
  170. package/bundle/_internal/gnost/scanner/classify.py +13 -0
  171. package/bundle/_internal/gnost/scanner/engine.py +169 -0
  172. package/bundle/_internal/gnost/scanner/filters.py +197 -0
  173. package/bundle/_internal/gnost/scanner/loc.py +93 -0
  174. package/bundle/_internal/gnost/scanner/models.py +27 -0
  175. package/bundle/_internal/gnost/schemas/insights.schema.json +517 -0
  176. package/bundle/_internal/gnost/utils/__init__.py +0 -0
  177. package/bundle/_internal/gnost/utils/logger.py +85 -0
  178. package/bundle/_internal/gnost/utils/paths.py +29 -0
  179. package/bundle/_internal/gnost/utils/printer.py +46 -0
  180. package/bundle/_internal/gnost/utils/progress.py +20 -0
  181. package/bundle/_internal/gnost-0.5.1rc2.dist-info/INSTALLER +1 -0
  182. package/bundle/_internal/gnost-0.5.1rc2.dist-info/METADATA +130 -0
  183. package/bundle/_internal/gnost-0.5.1rc2.dist-info/RECORD +178 -0
  184. package/bundle/_internal/gnost-0.5.1rc2.dist-info/REQUESTED +0 -0
  185. package/bundle/_internal/gnost-0.5.1rc2.dist-info/WHEEL +5 -0
  186. package/bundle/_internal/gnost-0.5.1rc2.dist-info/direct_url.json +1 -0
  187. package/bundle/_internal/gnost-0.5.1rc2.dist-info/entry_points.txt +2 -0
  188. package/bundle/_internal/gnost-0.5.1rc2.dist-info/licenses/LICENSE +21 -0
  189. package/bundle/_internal/gnost-0.5.1rc2.dist-info/top_level.txt +1 -0
  190. package/bundle/_internal/libcrypto.3.dylib +0 -0
  191. package/bundle/_internal/libncurses.6.dylib +0 -0
  192. package/bundle/_internal/librt/base64.cpython-312-darwin.so +0 -0
  193. package/bundle/_internal/librt/internal.cpython-312-darwin.so +0 -0
  194. package/bundle/_internal/libssl.3.dylib +0 -0
  195. package/bundle/_internal/mypy/__init__.cpython-312-darwin.so +0 -0
  196. package/bundle/_internal/mypy/__init__.py +1 -0
  197. package/bundle/_internal/mypy/__main__.py +52 -0
  198. package/bundle/_internal/mypy/api.cpython-312-darwin.so +0 -0
  199. package/bundle/_internal/mypy/api.py +95 -0
  200. package/bundle/_internal/mypy/applytype.cpython-312-darwin.so +0 -0
  201. package/bundle/_internal/mypy/applytype.py +317 -0
  202. package/bundle/_internal/mypy/argmap.cpython-312-darwin.so +0 -0
  203. package/bundle/_internal/mypy/argmap.py +269 -0
  204. package/bundle/_internal/mypy/binder.cpython-312-darwin.so +0 -0
  205. package/bundle/_internal/mypy/binder.py +710 -0
  206. package/bundle/_internal/mypy/bogus_type.py +27 -0
  207. package/bundle/_internal/mypy/build.cpython-312-darwin.so +0 -0
  208. package/bundle/_internal/mypy/build.py +5533 -0
  209. package/bundle/_internal/mypy/build_worker/__init__.cpython-312-darwin.so +0 -0
  210. package/bundle/_internal/mypy/build_worker/__init__.py +0 -0
  211. package/bundle/_internal/mypy/build_worker/__main__.py +6 -0
  212. package/bundle/_internal/mypy/build_worker/worker.cpython-312-darwin.so +0 -0
  213. package/bundle/_internal/mypy/build_worker/worker.py +379 -0
  214. package/bundle/_internal/mypy/cache.cpython-312-darwin.so +0 -0
  215. package/bundle/_internal/mypy/cache.py +626 -0
  216. package/bundle/_internal/mypy/checker.cpython-312-darwin.so +0 -0
  217. package/bundle/_internal/mypy/checker.py +10110 -0
  218. package/bundle/_internal/mypy/checker_shared.cpython-312-darwin.so +0 -0
  219. package/bundle/_internal/mypy/checker_shared.py +377 -0
  220. package/bundle/_internal/mypy/checker_state.cpython-312-darwin.so +0 -0
  221. package/bundle/_internal/mypy/checker_state.py +30 -0
  222. package/bundle/_internal/mypy/checkexpr.cpython-312-darwin.so +0 -0
  223. package/bundle/_internal/mypy/checkexpr.py +7018 -0
  224. package/bundle/_internal/mypy/checkmember.cpython-312-darwin.so +0 -0
  225. package/bundle/_internal/mypy/checkmember.py +1593 -0
  226. package/bundle/_internal/mypy/checkpattern.cpython-312-darwin.so +0 -0
  227. package/bundle/_internal/mypy/checkpattern.py +883 -0
  228. package/bundle/_internal/mypy/checkstrformat.cpython-312-darwin.so +0 -0
  229. package/bundle/_internal/mypy/checkstrformat.py +1103 -0
  230. package/bundle/_internal/mypy/config_parser.cpython-312-darwin.so +0 -0
  231. package/bundle/_internal/mypy/config_parser.py +749 -0
  232. package/bundle/_internal/mypy/constant_fold.cpython-312-darwin.so +0 -0
  233. package/bundle/_internal/mypy/constant_fold.py +187 -0
  234. package/bundle/_internal/mypy/constraints.cpython-312-darwin.so +0 -0
  235. package/bundle/_internal/mypy/constraints.py +1748 -0
  236. package/bundle/_internal/mypy/copytype.cpython-312-darwin.so +0 -0
  237. package/bundle/_internal/mypy/copytype.py +137 -0
  238. package/bundle/_internal/mypy/defaults.cpython-312-darwin.so +0 -0
  239. package/bundle/_internal/mypy/defaults.py +67 -0
  240. package/bundle/_internal/mypy/dmypy/__init__.cpython-312-darwin.so +0 -0
  241. package/bundle/_internal/mypy/dmypy/__init__.py +0 -0
  242. package/bundle/_internal/mypy/dmypy/__main__.py +6 -0
  243. package/bundle/_internal/mypy/dmypy/client.cpython-312-darwin.so +0 -0
  244. package/bundle/_internal/mypy/dmypy/client.py +732 -0
  245. package/bundle/_internal/mypy/dmypy_os.cpython-312-darwin.so +0 -0
  246. package/bundle/_internal/mypy/dmypy_os.py +43 -0
  247. package/bundle/_internal/mypy/dmypy_server.cpython-312-darwin.so +0 -0
  248. package/bundle/_internal/mypy/dmypy_server.py +1132 -0
  249. package/bundle/_internal/mypy/dmypy_util.cpython-312-darwin.so +0 -0
  250. package/bundle/_internal/mypy/dmypy_util.py +117 -0
  251. package/bundle/_internal/mypy/erasetype.cpython-312-darwin.so +0 -0
  252. package/bundle/_internal/mypy/erasetype.py +301 -0
  253. package/bundle/_internal/mypy/error_formatter.cpython-312-darwin.so +0 -0
  254. package/bundle/_internal/mypy/error_formatter.py +39 -0
  255. package/bundle/_internal/mypy/errorcodes.cpython-312-darwin.so +0 -0
  256. package/bundle/_internal/mypy/errorcodes.py +340 -0
  257. package/bundle/_internal/mypy/errors.cpython-312-darwin.so +0 -0
  258. package/bundle/_internal/mypy/errors.py +1468 -0
  259. package/bundle/_internal/mypy/evalexpr.cpython-312-darwin.so +0 -0
  260. package/bundle/_internal/mypy/evalexpr.py +211 -0
  261. package/bundle/_internal/mypy/expandtype.cpython-312-darwin.so +0 -0
  262. package/bundle/_internal/mypy/expandtype.py +662 -0
  263. package/bundle/_internal/mypy/exportjson.py +616 -0
  264. package/bundle/_internal/mypy/exprtotype.cpython-312-darwin.so +0 -0
  265. package/bundle/_internal/mypy/exprtotype.py +285 -0
  266. package/bundle/_internal/mypy/fastparse.cpython-312-darwin.so +0 -0
  267. package/bundle/_internal/mypy/fastparse.py +2267 -0
  268. package/bundle/_internal/mypy/find_sources.cpython-312-darwin.so +0 -0
  269. package/bundle/_internal/mypy/find_sources.py +257 -0
  270. package/bundle/_internal/mypy/fixup.cpython-312-darwin.so +0 -0
  271. package/bundle/_internal/mypy/fixup.py +438 -0
  272. package/bundle/_internal/mypy/freetree.cpython-312-darwin.so +0 -0
  273. package/bundle/_internal/mypy/freetree.py +23 -0
  274. package/bundle/_internal/mypy/fscache.cpython-312-darwin.so +0 -0
  275. package/bundle/_internal/mypy/fscache.py +312 -0
  276. package/bundle/_internal/mypy/fswatcher.cpython-312-darwin.so +0 -0
  277. package/bundle/_internal/mypy/fswatcher.py +106 -0
  278. package/bundle/_internal/mypy/gclogger.cpython-312-darwin.so +0 -0
  279. package/bundle/_internal/mypy/gclogger.py +48 -0
  280. package/bundle/_internal/mypy/git.cpython-312-darwin.so +0 -0
  281. package/bundle/_internal/mypy/git.py +69 -0
  282. package/bundle/_internal/mypy/graph_utils.cpython-312-darwin.so +0 -0
  283. package/bundle/_internal/mypy/graph_utils.py +161 -0
  284. package/bundle/_internal/mypy/indirection.cpython-312-darwin.so +0 -0
  285. package/bundle/_internal/mypy/indirection.py +176 -0
  286. package/bundle/_internal/mypy/infer.cpython-312-darwin.so +0 -0
  287. package/bundle/_internal/mypy/infer.py +80 -0
  288. package/bundle/_internal/mypy/inspections.cpython-312-darwin.so +0 -0
  289. package/bundle/_internal/mypy/inspections.py +626 -0
  290. package/bundle/_internal/mypy/ipc.cpython-312-darwin.so +0 -0
  291. package/bundle/_internal/mypy/ipc.py +508 -0
  292. package/bundle/_internal/mypy/join.cpython-312-darwin.so +0 -0
  293. package/bundle/_internal/mypy/join.py +962 -0
  294. package/bundle/_internal/mypy/known_modules.cpython-312-darwin.so +0 -0
  295. package/bundle/_internal/mypy/known_modules.py +174 -0
  296. package/bundle/_internal/mypy/literals.cpython-312-darwin.so +0 -0
  297. package/bundle/_internal/mypy/literals.py +327 -0
  298. package/bundle/_internal/mypy/lookup.cpython-312-darwin.so +0 -0
  299. package/bundle/_internal/mypy/lookup.py +80 -0
  300. package/bundle/_internal/mypy/main.cpython-312-darwin.so +0 -0
  301. package/bundle/_internal/mypy/main.py +1793 -0
  302. package/bundle/_internal/mypy/maptype.cpython-312-darwin.so +0 -0
  303. package/bundle/_internal/mypy/maptype.py +109 -0
  304. package/bundle/_internal/mypy/meet.cpython-312-darwin.so +0 -0
  305. package/bundle/_internal/mypy/meet.py +1371 -0
  306. package/bundle/_internal/mypy/memprofile.cpython-312-darwin.so +0 -0
  307. package/bundle/_internal/mypy/memprofile.py +122 -0
  308. package/bundle/_internal/mypy/message_registry.cpython-312-darwin.so +0 -0
  309. package/bundle/_internal/mypy/message_registry.py +378 -0
  310. package/bundle/_internal/mypy/messages.cpython-312-darwin.so +0 -0
  311. package/bundle/_internal/mypy/messages.py +3535 -0
  312. package/bundle/_internal/mypy/metastore.cpython-312-darwin.so +0 -0
  313. package/bundle/_internal/mypy/metastore.py +278 -0
  314. package/bundle/_internal/mypy/mixedtraverser.cpython-312-darwin.so +0 -0
  315. package/bundle/_internal/mypy/mixedtraverser.py +147 -0
  316. package/bundle/_internal/mypy/modulefinder.cpython-312-darwin.so +0 -0
  317. package/bundle/_internal/mypy/modulefinder.py +1008 -0
  318. package/bundle/_internal/mypy/moduleinspect.cpython-312-darwin.so +0 -0
  319. package/bundle/_internal/mypy/moduleinspect.py +184 -0
  320. package/bundle/_internal/mypy/modules_state.cpython-312-darwin.so +0 -0
  321. package/bundle/_internal/mypy/modules_state.py +20 -0
  322. package/bundle/_internal/mypy/mro.cpython-312-darwin.so +0 -0
  323. package/bundle/_internal/mypy/mro.py +62 -0
  324. package/bundle/_internal/mypy/nativeparse.cpython-312-darwin.so +0 -0
  325. package/bundle/_internal/mypy/nativeparse.py +2199 -0
  326. package/bundle/_internal/mypy/nodes.cpython-312-darwin.so +0 -0
  327. package/bundle/_internal/mypy/nodes.py +5608 -0
  328. package/bundle/_internal/mypy/operators.cpython-312-darwin.so +0 -0
  329. package/bundle/_internal/mypy/operators.py +126 -0
  330. package/bundle/_internal/mypy/options.cpython-312-darwin.so +0 -0
  331. package/bundle/_internal/mypy/options.py +678 -0
  332. package/bundle/_internal/mypy/parse.cpython-312-darwin.so +0 -0
  333. package/bundle/_internal/mypy/parse.py +135 -0
  334. package/bundle/_internal/mypy/partially_defined.cpython-312-darwin.so +0 -0
  335. package/bundle/_internal/mypy/partially_defined.py +703 -0
  336. package/bundle/_internal/mypy/patterns.cpython-312-darwin.so +0 -0
  337. package/bundle/_internal/mypy/patterns.py +162 -0
  338. package/bundle/_internal/mypy/plugin.cpython-312-darwin.so +0 -0
  339. package/bundle/_internal/mypy/plugin.py +945 -0
  340. package/bundle/_internal/mypy/plugins/__init__.py +0 -0
  341. package/bundle/_internal/mypy/plugins/attrs.cpython-312-darwin.so +0 -0
  342. package/bundle/_internal/mypy/plugins/attrs.py +1179 -0
  343. package/bundle/_internal/mypy/plugins/common.cpython-312-darwin.so +0 -0
  344. package/bundle/_internal/mypy/plugins/common.py +441 -0
  345. package/bundle/_internal/mypy/plugins/constants.cpython-312-darwin.so +0 -0
  346. package/bundle/_internal/mypy/plugins/constants.py +20 -0
  347. package/bundle/_internal/mypy/plugins/ctypes.cpython-312-darwin.so +0 -0
  348. package/bundle/_internal/mypy/plugins/ctypes.py +245 -0
  349. package/bundle/_internal/mypy/plugins/dataclasses.cpython-312-darwin.so +0 -0
  350. package/bundle/_internal/mypy/plugins/dataclasses.py +1135 -0
  351. package/bundle/_internal/mypy/plugins/default.cpython-312-darwin.so +0 -0
  352. package/bundle/_internal/mypy/plugins/default.py +612 -0
  353. package/bundle/_internal/mypy/plugins/enums.cpython-312-darwin.so +0 -0
  354. package/bundle/_internal/mypy/plugins/enums.py +299 -0
  355. package/bundle/_internal/mypy/plugins/functools.cpython-312-darwin.so +0 -0
  356. package/bundle/_internal/mypy/plugins/functools.py +399 -0
  357. package/bundle/_internal/mypy/plugins/proper_plugin.cpython-312-darwin.so +0 -0
  358. package/bundle/_internal/mypy/plugins/proper_plugin.py +178 -0
  359. package/bundle/_internal/mypy/plugins/singledispatch.cpython-312-darwin.so +0 -0
  360. package/bundle/_internal/mypy/plugins/singledispatch.py +212 -0
  361. package/bundle/_internal/mypy/py.typed +1 -0
  362. package/bundle/_internal/mypy/pyinfo.py +79 -0
  363. package/bundle/_internal/mypy/reachability.cpython-312-darwin.so +0 -0
  364. package/bundle/_internal/mypy/reachability.py +388 -0
  365. package/bundle/_internal/mypy/refinfo.cpython-312-darwin.so +0 -0
  366. package/bundle/_internal/mypy/refinfo.py +92 -0
  367. package/bundle/_internal/mypy/renaming.cpython-312-darwin.so +0 -0
  368. package/bundle/_internal/mypy/renaming.py +583 -0
  369. package/bundle/_internal/mypy/report.cpython-312-darwin.so +0 -0
  370. package/bundle/_internal/mypy/report.py +930 -0
  371. package/bundle/_internal/mypy/scope.cpython-312-darwin.so +0 -0
  372. package/bundle/_internal/mypy/scope.py +125 -0
  373. package/bundle/_internal/mypy/semanal.cpython-312-darwin.so +0 -0
  374. package/bundle/_internal/mypy/semanal.py +8674 -0
  375. package/bundle/_internal/mypy/semanal_classprop.cpython-312-darwin.so +0 -0
  376. package/bundle/_internal/mypy/semanal_classprop.py +188 -0
  377. package/bundle/_internal/mypy/semanal_enum.cpython-312-darwin.so +0 -0
  378. package/bundle/_internal/mypy/semanal_enum.py +259 -0
  379. package/bundle/_internal/mypy/semanal_infer.cpython-312-darwin.so +0 -0
  380. package/bundle/_internal/mypy/semanal_infer.py +135 -0
  381. package/bundle/_internal/mypy/semanal_main.cpython-312-darwin.so +0 -0
  382. package/bundle/_internal/mypy/semanal_main.py +542 -0
  383. package/bundle/_internal/mypy/semanal_namedtuple.cpython-312-darwin.so +0 -0
  384. package/bundle/_internal/mypy/semanal_namedtuple.py +679 -0
  385. package/bundle/_internal/mypy/semanal_newtype.cpython-312-darwin.so +0 -0
  386. package/bundle/_internal/mypy/semanal_newtype.py +272 -0
  387. package/bundle/_internal/mypy/semanal_pass1.cpython-312-darwin.so +0 -0
  388. package/bundle/_internal/mypy/semanal_pass1.py +159 -0
  389. package/bundle/_internal/mypy/semanal_shared.cpython-312-darwin.so +0 -0
  390. package/bundle/_internal/mypy/semanal_shared.py +499 -0
  391. package/bundle/_internal/mypy/semanal_typeargs.cpython-312-darwin.so +0 -0
  392. package/bundle/_internal/mypy/semanal_typeargs.py +309 -0
  393. package/bundle/_internal/mypy/semanal_typeddict.cpython-312-darwin.so +0 -0
  394. package/bundle/_internal/mypy/semanal_typeddict.py +826 -0
  395. package/bundle/_internal/mypy/server/__init__.py +0 -0
  396. package/bundle/_internal/mypy/server/astdiff.cpython-312-darwin.so +0 -0
  397. package/bundle/_internal/mypy/server/astdiff.py +552 -0
  398. package/bundle/_internal/mypy/server/astmerge.cpython-312-darwin.so +0 -0
  399. package/bundle/_internal/mypy/server/astmerge.py +583 -0
  400. package/bundle/_internal/mypy/server/aststrip.cpython-312-darwin.so +0 -0
  401. package/bundle/_internal/mypy/server/aststrip.py +255 -0
  402. package/bundle/_internal/mypy/server/deps.cpython-312-darwin.so +0 -0
  403. package/bundle/_internal/mypy/server/deps.py +1153 -0
  404. package/bundle/_internal/mypy/server/mergecheck.cpython-312-darwin.so +0 -0
  405. package/bundle/_internal/mypy/server/mergecheck.py +84 -0
  406. package/bundle/_internal/mypy/server/objgraph.cpython-312-darwin.so +0 -0
  407. package/bundle/_internal/mypy/server/objgraph.py +101 -0
  408. package/bundle/_internal/mypy/server/subexpr.cpython-312-darwin.so +0 -0
  409. package/bundle/_internal/mypy/server/subexpr.py +208 -0
  410. package/bundle/_internal/mypy/server/target.cpython-312-darwin.so +0 -0
  411. package/bundle/_internal/mypy/server/target.py +11 -0
  412. package/bundle/_internal/mypy/server/trigger.cpython-312-darwin.so +0 -0
  413. package/bundle/_internal/mypy/server/trigger.py +26 -0
  414. package/bundle/_internal/mypy/server/update.cpython-312-darwin.so +0 -0
  415. package/bundle/_internal/mypy/server/update.py +1372 -0
  416. package/bundle/_internal/mypy/sharedparse.cpython-312-darwin.so +0 -0
  417. package/bundle/_internal/mypy/sharedparse.py +114 -0
  418. package/bundle/_internal/mypy/solve.cpython-312-darwin.so +0 -0
  419. package/bundle/_internal/mypy/solve.py +602 -0
  420. package/bundle/_internal/mypy/split_namespace.py +35 -0
  421. package/bundle/_internal/mypy/state.cpython-312-darwin.so +0 -0
  422. package/bundle/_internal/mypy/state.py +29 -0
  423. package/bundle/_internal/mypy/stats.cpython-312-darwin.so +0 -0
  424. package/bundle/_internal/mypy/stats.py +494 -0
  425. package/bundle/_internal/mypy/strconv.cpython-312-darwin.so +0 -0
  426. package/bundle/_internal/mypy/strconv.py +707 -0
  427. package/bundle/_internal/mypy/stubdoc.py +545 -0
  428. package/bundle/_internal/mypy/stubgen.cpython-312-darwin.so +0 -0
  429. package/bundle/_internal/mypy/stubgen.py +2064 -0
  430. package/bundle/_internal/mypy/stubgenc.py +1046 -0
  431. package/bundle/_internal/mypy/stubinfo.cpython-312-darwin.so +0 -0
  432. package/bundle/_internal/mypy/stubinfo.py +321 -0
  433. package/bundle/_internal/mypy/stubtest.py +2676 -0
  434. package/bundle/_internal/mypy/stubutil.cpython-312-darwin.so +0 -0
  435. package/bundle/_internal/mypy/stubutil.py +895 -0
  436. package/bundle/_internal/mypy/subtypes.cpython-312-darwin.so +0 -0
  437. package/bundle/_internal/mypy/subtypes.py +2572 -0
  438. package/bundle/_internal/mypy/suggestions.cpython-312-darwin.so +0 -0
  439. package/bundle/_internal/mypy/suggestions.py +1068 -0
  440. package/bundle/_internal/mypy/test/__init__.py +0 -0
  441. package/bundle/_internal/mypy/test/config.py +31 -0
  442. package/bundle/_internal/mypy/test/data.py +864 -0
  443. package/bundle/_internal/mypy/test/helpers.py +546 -0
  444. package/bundle/_internal/mypy/test/meta/__init__.py +0 -0
  445. package/bundle/_internal/mypy/test/meta/_pytest.py +72 -0
  446. package/bundle/_internal/mypy/test/meta/test_diff_helper.py +47 -0
  447. package/bundle/_internal/mypy/test/meta/test_parse_data.py +69 -0
  448. package/bundle/_internal/mypy/test/meta/test_update_data.py +131 -0
  449. package/bundle/_internal/mypy/test/test_config_parser.py +130 -0
  450. package/bundle/_internal/mypy/test/test_diff_cache.py +209 -0
  451. package/bundle/_internal/mypy/test/test_find_sources.py +376 -0
  452. package/bundle/_internal/mypy/test/test_nativeparse.py +306 -0
  453. package/bundle/_internal/mypy/test/test_ref_info.py +46 -0
  454. package/bundle/_internal/mypy/test/testapi.py +45 -0
  455. package/bundle/_internal/mypy/test/testargs.py +202 -0
  456. package/bundle/_internal/mypy/test/testcheck.py +360 -0
  457. package/bundle/_internal/mypy/test/testcmdline.py +162 -0
  458. package/bundle/_internal/mypy/test/testconstraints.py +134 -0
  459. package/bundle/_internal/mypy/test/testdaemon.py +132 -0
  460. package/bundle/_internal/mypy/test/testdeps.py +85 -0
  461. package/bundle/_internal/mypy/test/testdiff.py +70 -0
  462. package/bundle/_internal/mypy/test/testerrorstream.py +46 -0
  463. package/bundle/_internal/mypy/test/testexportjson.py +104 -0
  464. package/bundle/_internal/mypy/test/testfinegrained.py +453 -0
  465. package/bundle/_internal/mypy/test/testfinegrainedcache.py +18 -0
  466. package/bundle/_internal/mypy/test/testformatter.py +85 -0
  467. package/bundle/_internal/mypy/test/testfscache.py +100 -0
  468. package/bundle/_internal/mypy/test/testgraph.py +138 -0
  469. package/bundle/_internal/mypy/test/testinfer.py +373 -0
  470. package/bundle/_internal/mypy/test/testipc.py +154 -0
  471. package/bundle/_internal/mypy/test/testmerge.py +235 -0
  472. package/bundle/_internal/mypy/test/testmodulefinder.py +284 -0
  473. package/bundle/_internal/mypy/test/testmypyc.py +26 -0
  474. package/bundle/_internal/mypy/test/testoutput.py +64 -0
  475. package/bundle/_internal/mypy/test/testparse.py +131 -0
  476. package/bundle/_internal/mypy/test/testpep561.py +174 -0
  477. package/bundle/_internal/mypy/test/testpythoneval.py +116 -0
  478. package/bundle/_internal/mypy/test/testreports.py +59 -0
  479. package/bundle/_internal/mypy/test/testsemanal.py +219 -0
  480. package/bundle/_internal/mypy/test/testsolve.py +287 -0
  481. package/bundle/_internal/mypy/test/teststubgen.py +1650 -0
  482. package/bundle/_internal/mypy/test/teststubinfo.py +24 -0
  483. package/bundle/_internal/mypy/test/teststubtest.py +3417 -0
  484. package/bundle/_internal/mypy/test/testsubtypes.py +306 -0
  485. package/bundle/_internal/mypy/test/testtransform.py +64 -0
  486. package/bundle/_internal/mypy/test/testtypegen.py +83 -0
  487. package/bundle/_internal/mypy/test/testtypes.py +1666 -0
  488. package/bundle/_internal/mypy/test/testutil.py +111 -0
  489. package/bundle/_internal/mypy/test/typefixture.py +419 -0
  490. package/bundle/_internal/mypy/test/update_data.py +87 -0
  491. package/bundle/_internal/mypy/test/visitors.cpython-312-darwin.so +0 -0
  492. package/bundle/_internal/mypy/test/visitors.py +77 -0
  493. package/bundle/_internal/mypy/traverser.cpython-312-darwin.so +0 -0
  494. package/bundle/_internal/mypy/traverser.py +1106 -0
  495. package/bundle/_internal/mypy/treetransform.cpython-312-darwin.so +0 -0
  496. package/bundle/_internal/mypy/treetransform.py +820 -0
  497. package/bundle/_internal/mypy/tvar_scope.cpython-312-darwin.so +0 -0
  498. package/bundle/_internal/mypy/tvar_scope.py +154 -0
  499. package/bundle/_internal/mypy/type_visitor.cpython-312-darwin.so +0 -0
  500. package/bundle/_internal/mypy/type_visitor.py +630 -0
  501. package/bundle/_internal/mypy/typeanal.cpython-312-darwin.so +0 -0
  502. package/bundle/_internal/mypy/typeanal.py +2961 -0
  503. package/bundle/_internal/mypy/typeops.cpython-312-darwin.so +0 -0
  504. package/bundle/_internal/mypy/typeops.py +1355 -0
  505. package/bundle/_internal/mypy/types.cpython-312-darwin.so +0 -0
  506. package/bundle/_internal/mypy/types.py +4639 -0
  507. package/bundle/_internal/mypy/types_utils.cpython-312-darwin.so +0 -0
  508. package/bundle/_internal/mypy/types_utils.py +183 -0
  509. package/bundle/_internal/mypy/typeshed/LICENSE +237 -0
  510. package/bundle/_internal/mypy/typeshed/stdlib/VERSIONS +349 -0
  511. package/bundle/_internal/mypy/typeshed/stdlib/__future__.pyi +36 -0
  512. package/bundle/_internal/mypy/typeshed/stdlib/__main__.pyi +1 -0
  513. package/bundle/_internal/mypy/typeshed/stdlib/_ast.pyi +141 -0
  514. package/bundle/_internal/mypy/typeshed/stdlib/_asyncio.pyi +114 -0
  515. package/bundle/_internal/mypy/typeshed/stdlib/_bisect.pyi +103 -0
  516. package/bundle/_internal/mypy/typeshed/stdlib/_blake2.pyi +119 -0
  517. package/bundle/_internal/mypy/typeshed/stdlib/_bz2.pyi +24 -0
  518. package/bundle/_internal/mypy/typeshed/stdlib/_codecs.pyi +125 -0
  519. package/bundle/_internal/mypy/typeshed/stdlib/_collections_abc.pyi +105 -0
  520. package/bundle/_internal/mypy/typeshed/stdlib/_compat_pickle.pyi +10 -0
  521. package/bundle/_internal/mypy/typeshed/stdlib/_compression.pyi +39 -0
  522. package/bundle/_internal/mypy/typeshed/stdlib/_contextvars.pyi +69 -0
  523. package/bundle/_internal/mypy/typeshed/stdlib/_csv.pyi +116 -0
  524. package/bundle/_internal/mypy/typeshed/stdlib/_ctypes.pyi +375 -0
  525. package/bundle/_internal/mypy/typeshed/stdlib/_curses.pyi +583 -0
  526. package/bundle/_internal/mypy/typeshed/stdlib/_curses_panel.pyi +27 -0
  527. package/bundle/_internal/mypy/typeshed/stdlib/_dbm.pyi +46 -0
  528. package/bundle/_internal/mypy/typeshed/stdlib/_decimal.pyi +73 -0
  529. package/bundle/_internal/mypy/typeshed/stdlib/_frozen_importlib.pyi +121 -0
  530. package/bundle/_internal/mypy/typeshed/stdlib/_frozen_importlib_external.pyi +218 -0
  531. package/bundle/_internal/mypy/typeshed/stdlib/_gdbm.pyi +50 -0
  532. package/bundle/_internal/mypy/typeshed/stdlib/_hashlib.pyi +127 -0
  533. package/bundle/_internal/mypy/typeshed/stdlib/_heapq.pyi +18 -0
  534. package/bundle/_internal/mypy/typeshed/stdlib/_imp.pyi +30 -0
  535. package/bundle/_internal/mypy/typeshed/stdlib/_interpchannels.pyi +86 -0
  536. package/bundle/_internal/mypy/typeshed/stdlib/_interpqueues.pyi +31 -0
  537. package/bundle/_internal/mypy/typeshed/stdlib/_interpreters.pyi +68 -0
  538. package/bundle/_internal/mypy/typeshed/stdlib/_io.pyi +330 -0
  539. package/bundle/_internal/mypy/typeshed/stdlib/_json.pyi +59 -0
  540. package/bundle/_internal/mypy/typeshed/stdlib/_locale.pyi +121 -0
  541. package/bundle/_internal/mypy/typeshed/stdlib/_lsprof.pyi +34 -0
  542. package/bundle/_internal/mypy/typeshed/stdlib/_lzma.pyi +71 -0
  543. package/bundle/_internal/mypy/typeshed/stdlib/_markupbase.pyi +10 -0
  544. package/bundle/_internal/mypy/typeshed/stdlib/_msi.pyi +97 -0
  545. package/bundle/_internal/mypy/typeshed/stdlib/_multibytecodec.pyi +49 -0
  546. package/bundle/_internal/mypy/typeshed/stdlib/_operator.pyi +130 -0
  547. package/bundle/_internal/mypy/typeshed/stdlib/_osx_support.pyi +34 -0
  548. package/bundle/_internal/mypy/typeshed/stdlib/_pickle.pyi +114 -0
  549. package/bundle/_internal/mypy/typeshed/stdlib/_posixsubprocess.pyi +59 -0
  550. package/bundle/_internal/mypy/typeshed/stdlib/_py_abc.pyi +14 -0
  551. package/bundle/_internal/mypy/typeshed/stdlib/_pydecimal.pyi +50 -0
  552. package/bundle/_internal/mypy/typeshed/stdlib/_queue.pyi +18 -0
  553. package/bundle/_internal/mypy/typeshed/stdlib/_random.pyi +14 -0
  554. package/bundle/_internal/mypy/typeshed/stdlib/_remote_debugging.pyi +186 -0
  555. package/bundle/_internal/mypy/typeshed/stdlib/_sitebuiltins.pyi +18 -0
  556. package/bundle/_internal/mypy/typeshed/stdlib/_socket.pyi +966 -0
  557. package/bundle/_internal/mypy/typeshed/stdlib/_sqlite3.pyi +311 -0
  558. package/bundle/_internal/mypy/typeshed/stdlib/_ssl.pyi +303 -0
  559. package/bundle/_internal/mypy/typeshed/stdlib/_stat.pyi +119 -0
  560. package/bundle/_internal/mypy/typeshed/stdlib/_struct.pyi +24 -0
  561. package/bundle/_internal/mypy/typeshed/stdlib/_thread.pyi +125 -0
  562. package/bundle/_internal/mypy/typeshed/stdlib/_threading_local.pyi +24 -0
  563. package/bundle/_internal/mypy/typeshed/stdlib/_tkinter.pyi +156 -0
  564. package/bundle/_internal/mypy/typeshed/stdlib/_tracemalloc.pyi +13 -0
  565. package/bundle/_internal/mypy/typeshed/stdlib/_typeshed/README.md +34 -0
  566. package/bundle/_internal/mypy/typeshed/stdlib/_typeshed/__init__.pyi +415 -0
  567. package/bundle/_internal/mypy/typeshed/stdlib/_typeshed/_type_checker_internals.pyi +102 -0
  568. package/bundle/_internal/mypy/typeshed/stdlib/_typeshed/dbapi.pyi +36 -0
  569. package/bundle/_internal/mypy/typeshed/stdlib/_typeshed/importlib.pyi +18 -0
  570. package/bundle/_internal/mypy/typeshed/stdlib/_typeshed/wsgi.pyi +43 -0
  571. package/bundle/_internal/mypy/typeshed/stdlib/_typeshed/xml.pyi +9 -0
  572. package/bundle/_internal/mypy/typeshed/stdlib/_warnings.pyi +54 -0
  573. package/bundle/_internal/mypy/typeshed/stdlib/_weakref.pyi +15 -0
  574. package/bundle/_internal/mypy/typeshed/stdlib/_weakrefset.pyi +49 -0
  575. package/bundle/_internal/mypy/typeshed/stdlib/_winapi.pyi +319 -0
  576. package/bundle/_internal/mypy/typeshed/stdlib/_zstd.pyi +102 -0
  577. package/bundle/_internal/mypy/typeshed/stdlib/abc.pyi +50 -0
  578. package/bundle/_internal/mypy/typeshed/stdlib/aifc.pyi +79 -0
  579. package/bundle/_internal/mypy/typeshed/stdlib/annotationlib.pyi +156 -0
  580. package/bundle/_internal/mypy/typeshed/stdlib/antigravity.pyi +3 -0
  581. package/bundle/_internal/mypy/typeshed/stdlib/argparse.pyi +866 -0
  582. package/bundle/_internal/mypy/typeshed/stdlib/array.pyi +113 -0
  583. package/bundle/_internal/mypy/typeshed/stdlib/ast.pyi +2199 -0
  584. package/bundle/_internal/mypy/typeshed/stdlib/asynchat.pyi +21 -0
  585. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/__init__.pyi +1022 -0
  586. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/base_events.pyi +607 -0
  587. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/base_futures.pyi +17 -0
  588. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/base_subprocess.pyi +62 -0
  589. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/base_tasks.pyi +17 -0
  590. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/constants.pyi +20 -0
  591. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/coroutines.pyi +45 -0
  592. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/events.pyi +803 -0
  593. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/exceptions.pyi +44 -0
  594. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/format_helpers.pyi +31 -0
  595. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/futures.pyi +19 -0
  596. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/graph.pyi +29 -0
  597. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/locks.pyi +83 -0
  598. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/log.pyi +3 -0
  599. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/mixins.pyi +9 -0
  600. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/proactor_events.pyi +53 -0
  601. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/protocols.pyi +39 -0
  602. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/queues.pyi +45 -0
  603. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/runners.pyi +41 -0
  604. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/selector_events.pyi +10 -0
  605. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/sslproto.pyi +164 -0
  606. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/staggered.pyi +10 -0
  607. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/streams.pyi +124 -0
  608. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/subprocess.pyi +166 -0
  609. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/taskgroups.pyi +41 -0
  610. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/tasks.pyi +315 -0
  611. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/threads.pyi +9 -0
  612. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/timeouts.pyi +20 -0
  613. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/tools.pyi +51 -0
  614. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/transports.pyi +57 -0
  615. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/trsock.pyi +137 -0
  616. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/unix_events.pyi +277 -0
  617. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/windows_events.pyi +122 -0
  618. package/bundle/_internal/mypy/typeshed/stdlib/asyncio/windows_utils.pyi +49 -0
  619. package/bundle/_internal/mypy/typeshed/stdlib/asyncore.pyi +91 -0
  620. package/bundle/_internal/mypy/typeshed/stdlib/atexit.pyi +11 -0
  621. package/bundle/_internal/mypy/typeshed/stdlib/audioop.pyi +44 -0
  622. package/bundle/_internal/mypy/typeshed/stdlib/base64.pyi +124 -0
  623. package/bundle/_internal/mypy/typeshed/stdlib/bdb.pyi +139 -0
  624. package/bundle/_internal/mypy/typeshed/stdlib/binascii.pyi +102 -0
  625. package/bundle/_internal/mypy/typeshed/stdlib/binhex.pyi +44 -0
  626. package/bundle/_internal/mypy/typeshed/stdlib/bisect.pyi +4 -0
  627. package/bundle/_internal/mypy/typeshed/stdlib/builtins.pyi +2470 -0
  628. package/bundle/_internal/mypy/typeshed/stdlib/bz2.pyi +121 -0
  629. package/bundle/_internal/mypy/typeshed/stdlib/cProfile.pyi +33 -0
  630. package/bundle/_internal/mypy/typeshed/stdlib/calendar.pyi +249 -0
  631. package/bundle/_internal/mypy/typeshed/stdlib/cgi.pyi +120 -0
  632. package/bundle/_internal/mypy/typeshed/stdlib/cgitb.pyi +32 -0
  633. package/bundle/_internal/mypy/typeshed/stdlib/chunk.pyi +20 -0
  634. package/bundle/_internal/mypy/typeshed/stdlib/cmath.pyi +36 -0
  635. package/bundle/_internal/mypy/typeshed/stdlib/cmd.pyi +46 -0
  636. package/bundle/_internal/mypy/typeshed/stdlib/code.pyi +55 -0
  637. package/bundle/_internal/mypy/typeshed/stdlib/codecs.pyi +357 -0
  638. package/bundle/_internal/mypy/typeshed/stdlib/codeop.pyi +21 -0
  639. package/bundle/_internal/mypy/typeshed/stdlib/collections/__init__.pyi +565 -0
  640. package/bundle/_internal/mypy/typeshed/stdlib/collections/abc.pyi +2 -0
  641. package/bundle/_internal/mypy/typeshed/stdlib/colorsys.pyi +15 -0
  642. package/bundle/_internal/mypy/typeshed/stdlib/compileall.pyi +51 -0
  643. package/bundle/_internal/mypy/typeshed/stdlib/compression/__init__.pyi +0 -0
  644. package/bundle/_internal/mypy/typeshed/stdlib/compression/_common/__init__.pyi +0 -0
  645. package/bundle/_internal/mypy/typeshed/stdlib/compression/_common/_streams.pyi +37 -0
  646. package/bundle/_internal/mypy/typeshed/stdlib/compression/bz2.pyi +1 -0
  647. package/bundle/_internal/mypy/typeshed/stdlib/compression/gzip.pyi +1 -0
  648. package/bundle/_internal/mypy/typeshed/stdlib/compression/lzma.pyi +1 -0
  649. package/bundle/_internal/mypy/typeshed/stdlib/compression/zlib.pyi +1 -0
  650. package/bundle/_internal/mypy/typeshed/stdlib/compression/zstd/__init__.pyi +94 -0
  651. package/bundle/_internal/mypy/typeshed/stdlib/compression/zstd/_zstdfile.pyi +117 -0
  652. package/bundle/_internal/mypy/typeshed/stdlib/concurrent/__init__.pyi +0 -0
  653. package/bundle/_internal/mypy/typeshed/stdlib/concurrent/futures/__init__.pyi +71 -0
  654. package/bundle/_internal/mypy/typeshed/stdlib/concurrent/futures/_base.pyi +119 -0
  655. package/bundle/_internal/mypy/typeshed/stdlib/concurrent/futures/interpreter.pyi +82 -0
  656. package/bundle/_internal/mypy/typeshed/stdlib/concurrent/futures/process.pyi +248 -0
  657. package/bundle/_internal/mypy/typeshed/stdlib/concurrent/futures/thread.pyi +143 -0
  658. package/bundle/_internal/mypy/typeshed/stdlib/concurrent/interpreters/__init__.pyi +68 -0
  659. package/bundle/_internal/mypy/typeshed/stdlib/concurrent/interpreters/_crossinterp.pyi +30 -0
  660. package/bundle/_internal/mypy/typeshed/stdlib/concurrent/interpreters/_queues.pyi +74 -0
  661. package/bundle/_internal/mypy/typeshed/stdlib/configparser.pyi +509 -0
  662. package/bundle/_internal/mypy/typeshed/stdlib/contextlib.pyi +211 -0
  663. package/bundle/_internal/mypy/typeshed/stdlib/contextvars.pyi +3 -0
  664. package/bundle/_internal/mypy/typeshed/stdlib/copy.pyi +37 -0
  665. package/bundle/_internal/mypy/typeshed/stdlib/copyreg.pyi +20 -0
  666. package/bundle/_internal/mypy/typeshed/stdlib/crypt.pyi +26 -0
  667. package/bundle/_internal/mypy/typeshed/stdlib/csv.pyi +153 -0
  668. package/bundle/_internal/mypy/typeshed/stdlib/ctypes/__init__.pyi +394 -0
  669. package/bundle/_internal/mypy/typeshed/stdlib/ctypes/_endian.pyi +16 -0
  670. package/bundle/_internal/mypy/typeshed/stdlib/ctypes/macholib/__init__.pyi +3 -0
  671. package/bundle/_internal/mypy/typeshed/stdlib/ctypes/macholib/dyld.pyi +8 -0
  672. package/bundle/_internal/mypy/typeshed/stdlib/ctypes/macholib/dylib.pyi +14 -0
  673. package/bundle/_internal/mypy/typeshed/stdlib/ctypes/macholib/framework.pyi +14 -0
  674. package/bundle/_internal/mypy/typeshed/stdlib/ctypes/util.pyi +11 -0
  675. package/bundle/_internal/mypy/typeshed/stdlib/ctypes/wintypes.pyi +321 -0
  676. package/bundle/_internal/mypy/typeshed/stdlib/curses/__init__.pyi +38 -0
  677. package/bundle/_internal/mypy/typeshed/stdlib/curses/ascii.pyi +62 -0
  678. package/bundle/_internal/mypy/typeshed/stdlib/curses/has_key.pyi +1 -0
  679. package/bundle/_internal/mypy/typeshed/stdlib/curses/panel.pyi +1 -0
  680. package/bundle/_internal/mypy/typeshed/stdlib/curses/textpad.pyi +11 -0
  681. package/bundle/_internal/mypy/typeshed/stdlib/dataclasses.pyi +401 -0
  682. package/bundle/_internal/mypy/typeshed/stdlib/datetime.pyi +381 -0
  683. package/bundle/_internal/mypy/typeshed/stdlib/dbm/__init__.pyi +105 -0
  684. package/bundle/_internal/mypy/typeshed/stdlib/dbm/dumb.pyi +41 -0
  685. package/bundle/_internal/mypy/typeshed/stdlib/dbm/gnu.pyi +1 -0
  686. package/bundle/_internal/mypy/typeshed/stdlib/dbm/ndbm.pyi +1 -0
  687. package/bundle/_internal/mypy/typeshed/stdlib/dbm/sqlite3.pyi +34 -0
  688. package/bundle/_internal/mypy/typeshed/stdlib/decimal.pyi +278 -0
  689. package/bundle/_internal/mypy/typeshed/stdlib/difflib.pyi +157 -0
  690. package/bundle/_internal/mypy/typeshed/stdlib/dis.pyi +302 -0
  691. package/bundle/_internal/mypy/typeshed/stdlib/distutils/__init__.pyi +5 -0
  692. package/bundle/_internal/mypy/typeshed/stdlib/distutils/_msvccompiler.pyi +13 -0
  693. package/bundle/_internal/mypy/typeshed/stdlib/distutils/archive_util.pyi +36 -0
  694. package/bundle/_internal/mypy/typeshed/stdlib/distutils/bcppcompiler.pyi +3 -0
  695. package/bundle/_internal/mypy/typeshed/stdlib/distutils/ccompiler.pyi +182 -0
  696. package/bundle/_internal/mypy/typeshed/stdlib/distutils/cmd.pyi +238 -0
  697. package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/__init__.pyi +41 -0
  698. package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/bdist.pyi +27 -0
  699. package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/bdist_dumb.pyi +22 -0
  700. package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/bdist_msi.pyi +45 -0
  701. package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/bdist_packager.pyi +0 -0
  702. package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/bdist_rpm.pyi +53 -0
  703. package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/build.pyi +34 -0
  704. package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/build_clib.pyi +29 -0
  705. package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/build_ext.pyi +52 -0
  706. package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/build_py.pyi +45 -0
  707. package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/build_scripts.pyi +25 -0
  708. package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/check.pyi +39 -0
  709. package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/clean.pyi +18 -0
  710. package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/config.pyi +84 -0
  711. package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/install.pyi +67 -0
  712. package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/install_data.pyi +20 -0
  713. package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/install_egg_info.pyi +19 -0
  714. package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/install_headers.pyi +17 -0
  715. package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/install_lib.pyi +26 -0
  716. package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/install_scripts.pyi +19 -0
  717. package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/register.pyi +20 -0
  718. package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/sdist.pyi +45 -0
  719. package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/upload.pyi +18 -0
  720. package/bundle/_internal/mypy/typeshed/stdlib/distutils/config.pyi +17 -0
  721. package/bundle/_internal/mypy/typeshed/stdlib/distutils/core.pyi +58 -0
  722. package/bundle/_internal/mypy/typeshed/stdlib/distutils/cygwinccompiler.pyi +20 -0
  723. package/bundle/_internal/mypy/typeshed/stdlib/distutils/debug.pyi +3 -0
  724. package/bundle/_internal/mypy/typeshed/stdlib/distutils/dep_util.pyi +14 -0
  725. package/bundle/_internal/mypy/typeshed/stdlib/distutils/dir_util.pyi +23 -0
  726. package/bundle/_internal/mypy/typeshed/stdlib/distutils/dist.pyi +318 -0
  727. package/bundle/_internal/mypy/typeshed/stdlib/distutils/errors.pyi +19 -0
  728. package/bundle/_internal/mypy/typeshed/stdlib/distutils/extension.pyi +36 -0
  729. package/bundle/_internal/mypy/typeshed/stdlib/distutils/fancy_getopt.pyi +45 -0
  730. package/bundle/_internal/mypy/typeshed/stdlib/distutils/file_util.pyi +40 -0
  731. package/bundle/_internal/mypy/typeshed/stdlib/distutils/filelist.pyi +61 -0
  732. package/bundle/_internal/mypy/typeshed/stdlib/distutils/log.pyi +26 -0
  733. package/bundle/_internal/mypy/typeshed/stdlib/distutils/msvccompiler.pyi +3 -0
  734. package/bundle/_internal/mypy/typeshed/stdlib/distutils/spawn.pyi +10 -0
  735. package/bundle/_internal/mypy/typeshed/stdlib/distutils/sysconfig.pyi +32 -0
  736. package/bundle/_internal/mypy/typeshed/stdlib/distutils/text_file.pyi +21 -0
  737. package/bundle/_internal/mypy/typeshed/stdlib/distutils/unixccompiler.pyi +3 -0
  738. package/bundle/_internal/mypy/typeshed/stdlib/distutils/util.pyi +53 -0
  739. package/bundle/_internal/mypy/typeshed/stdlib/distutils/version.pyi +36 -0
  740. package/bundle/_internal/mypy/typeshed/stdlib/doctest.pyi +265 -0
  741. package/bundle/_internal/mypy/typeshed/stdlib/email/__init__.pyi +68 -0
  742. package/bundle/_internal/mypy/typeshed/stdlib/email/_header_value_parser.pyi +415 -0
  743. package/bundle/_internal/mypy/typeshed/stdlib/email/_policybase.pyi +80 -0
  744. package/bundle/_internal/mypy/typeshed/stdlib/email/base64mime.pyi +13 -0
  745. package/bundle/_internal/mypy/typeshed/stdlib/email/charset.pyi +44 -0
  746. package/bundle/_internal/mypy/typeshed/stdlib/email/contentmanager.pyi +11 -0
  747. package/bundle/_internal/mypy/typeshed/stdlib/email/encoders.pyi +8 -0
  748. package/bundle/_internal/mypy/typeshed/stdlib/email/errors.pyi +38 -0
  749. package/bundle/_internal/mypy/typeshed/stdlib/email/feedparser.pyi +24 -0
  750. package/bundle/_internal/mypy/typeshed/stdlib/email/generator.pyi +79 -0
  751. package/bundle/_internal/mypy/typeshed/stdlib/email/header.pyi +32 -0
  752. package/bundle/_internal/mypy/typeshed/stdlib/email/headerregistry.pyi +196 -0
  753. package/bundle/_internal/mypy/typeshed/stdlib/email/iterators.pyi +15 -0
  754. package/bundle/_internal/mypy/typeshed/stdlib/email/message.pyi +191 -0
  755. package/bundle/_internal/mypy/typeshed/stdlib/email/mime/__init__.pyi +0 -0
  756. package/bundle/_internal/mypy/typeshed/stdlib/email/mime/application.pyi +17 -0
  757. package/bundle/_internal/mypy/typeshed/stdlib/email/mime/audio.pyi +17 -0
  758. package/bundle/_internal/mypy/typeshed/stdlib/email/mime/base.pyi +8 -0
  759. package/bundle/_internal/mypy/typeshed/stdlib/email/mime/image.pyi +17 -0
  760. package/bundle/_internal/mypy/typeshed/stdlib/email/mime/message.pyi +8 -0
  761. package/bundle/_internal/mypy/typeshed/stdlib/email/mime/multipart.pyi +18 -0
  762. package/bundle/_internal/mypy/typeshed/stdlib/email/mime/nonmultipart.pyi +5 -0
  763. package/bundle/_internal/mypy/typeshed/stdlib/email/mime/text.pyi +9 -0
  764. package/bundle/_internal/mypy/typeshed/stdlib/email/parser.pyi +42 -0
  765. package/bundle/_internal/mypy/typeshed/stdlib/email/policy.pyi +78 -0
  766. package/bundle/_internal/mypy/typeshed/stdlib/email/quoprimime.pyi +28 -0
  767. package/bundle/_internal/mypy/typeshed/stdlib/email/utils.pyi +72 -0
  768. package/bundle/_internal/mypy/typeshed/stdlib/encodings/__init__.pyi +15 -0
  769. package/bundle/_internal/mypy/typeshed/stdlib/encodings/aliases.pyi +1 -0
  770. package/bundle/_internal/mypy/typeshed/stdlib/encodings/ascii.pyi +30 -0
  771. package/bundle/_internal/mypy/typeshed/stdlib/encodings/base64_codec.pyi +26 -0
  772. package/bundle/_internal/mypy/typeshed/stdlib/encodings/big5.pyi +23 -0
  773. package/bundle/_internal/mypy/typeshed/stdlib/encodings/big5hkscs.pyi +23 -0
  774. package/bundle/_internal/mypy/typeshed/stdlib/encodings/bz2_codec.pyi +26 -0
  775. package/bundle/_internal/mypy/typeshed/stdlib/encodings/charmap.pyi +33 -0
  776. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp037.pyi +21 -0
  777. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp1006.pyi +21 -0
  778. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp1026.pyi +21 -0
  779. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp1125.pyi +21 -0
  780. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp1140.pyi +21 -0
  781. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp1250.pyi +21 -0
  782. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp1251.pyi +21 -0
  783. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp1252.pyi +21 -0
  784. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp1253.pyi +21 -0
  785. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp1254.pyi +21 -0
  786. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp1255.pyi +21 -0
  787. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp1256.pyi +21 -0
  788. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp1257.pyi +21 -0
  789. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp1258.pyi +21 -0
  790. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp273.pyi +21 -0
  791. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp424.pyi +21 -0
  792. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp437.pyi +21 -0
  793. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp500.pyi +21 -0
  794. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp720.pyi +21 -0
  795. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp737.pyi +21 -0
  796. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp775.pyi +21 -0
  797. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp850.pyi +21 -0
  798. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp852.pyi +21 -0
  799. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp855.pyi +21 -0
  800. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp856.pyi +21 -0
  801. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp857.pyi +21 -0
  802. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp858.pyi +21 -0
  803. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp860.pyi +21 -0
  804. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp861.pyi +21 -0
  805. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp862.pyi +21 -0
  806. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp863.pyi +21 -0
  807. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp864.pyi +21 -0
  808. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp865.pyi +21 -0
  809. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp866.pyi +21 -0
  810. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp869.pyi +21 -0
  811. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp874.pyi +21 -0
  812. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp875.pyi +21 -0
  813. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp932.pyi +23 -0
  814. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp949.pyi +23 -0
  815. package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp950.pyi +23 -0
  816. package/bundle/_internal/mypy/typeshed/stdlib/encodings/euc_jis_2004.pyi +23 -0
  817. package/bundle/_internal/mypy/typeshed/stdlib/encodings/euc_jisx0213.pyi +23 -0
  818. package/bundle/_internal/mypy/typeshed/stdlib/encodings/euc_jp.pyi +23 -0
  819. package/bundle/_internal/mypy/typeshed/stdlib/encodings/euc_kr.pyi +23 -0
  820. package/bundle/_internal/mypy/typeshed/stdlib/encodings/gb18030.pyi +23 -0
  821. package/bundle/_internal/mypy/typeshed/stdlib/encodings/gb2312.pyi +23 -0
  822. package/bundle/_internal/mypy/typeshed/stdlib/encodings/gbk.pyi +23 -0
  823. package/bundle/_internal/mypy/typeshed/stdlib/encodings/hex_codec.pyi +26 -0
  824. package/bundle/_internal/mypy/typeshed/stdlib/encodings/hp_roman8.pyi +21 -0
  825. package/bundle/_internal/mypy/typeshed/stdlib/encodings/hz.pyi +23 -0
  826. package/bundle/_internal/mypy/typeshed/stdlib/encodings/idna.pyi +26 -0
  827. package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso2022_jp.pyi +23 -0
  828. package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso2022_jp_1.pyi +23 -0
  829. package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso2022_jp_2.pyi +23 -0
  830. package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso2022_jp_2004.pyi +23 -0
  831. package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso2022_jp_3.pyi +23 -0
  832. package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso2022_jp_ext.pyi +23 -0
  833. package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso2022_kr.pyi +23 -0
  834. package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso8859_1.pyi +21 -0
  835. package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso8859_10.pyi +21 -0
  836. package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso8859_11.pyi +21 -0
  837. package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso8859_13.pyi +21 -0
  838. package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso8859_14.pyi +21 -0
  839. package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso8859_15.pyi +21 -0
  840. package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso8859_16.pyi +21 -0
  841. package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso8859_2.pyi +21 -0
  842. package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso8859_3.pyi +21 -0
  843. package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso8859_4.pyi +21 -0
  844. package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso8859_5.pyi +21 -0
  845. package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso8859_6.pyi +21 -0
  846. package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso8859_7.pyi +21 -0
  847. package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso8859_8.pyi +21 -0
  848. package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso8859_9.pyi +21 -0
  849. package/bundle/_internal/mypy/typeshed/stdlib/encodings/johab.pyi +23 -0
  850. package/bundle/_internal/mypy/typeshed/stdlib/encodings/koi8_r.pyi +21 -0
  851. package/bundle/_internal/mypy/typeshed/stdlib/encodings/koi8_t.pyi +21 -0
  852. package/bundle/_internal/mypy/typeshed/stdlib/encodings/koi8_u.pyi +21 -0
  853. package/bundle/_internal/mypy/typeshed/stdlib/encodings/kz1048.pyi +21 -0
  854. package/bundle/_internal/mypy/typeshed/stdlib/encodings/latin_1.pyi +30 -0
  855. package/bundle/_internal/mypy/typeshed/stdlib/encodings/mac_arabic.pyi +21 -0
  856. package/bundle/_internal/mypy/typeshed/stdlib/encodings/mac_croatian.pyi +21 -0
  857. package/bundle/_internal/mypy/typeshed/stdlib/encodings/mac_cyrillic.pyi +21 -0
  858. package/bundle/_internal/mypy/typeshed/stdlib/encodings/mac_farsi.pyi +21 -0
  859. package/bundle/_internal/mypy/typeshed/stdlib/encodings/mac_greek.pyi +21 -0
  860. package/bundle/_internal/mypy/typeshed/stdlib/encodings/mac_iceland.pyi +21 -0
  861. package/bundle/_internal/mypy/typeshed/stdlib/encodings/mac_latin2.pyi +21 -0
  862. package/bundle/_internal/mypy/typeshed/stdlib/encodings/mac_roman.pyi +21 -0
  863. package/bundle/_internal/mypy/typeshed/stdlib/encodings/mac_romanian.pyi +21 -0
  864. package/bundle/_internal/mypy/typeshed/stdlib/encodings/mac_turkish.pyi +21 -0
  865. package/bundle/_internal/mypy/typeshed/stdlib/encodings/mbcs.pyi +28 -0
  866. package/bundle/_internal/mypy/typeshed/stdlib/encodings/oem.pyi +28 -0
  867. package/bundle/_internal/mypy/typeshed/stdlib/encodings/palmos.pyi +21 -0
  868. package/bundle/_internal/mypy/typeshed/stdlib/encodings/ptcp154.pyi +21 -0
  869. package/bundle/_internal/mypy/typeshed/stdlib/encodings/punycode.pyi +33 -0
  870. package/bundle/_internal/mypy/typeshed/stdlib/encodings/quopri_codec.pyi +26 -0
  871. package/bundle/_internal/mypy/typeshed/stdlib/encodings/raw_unicode_escape.pyi +23 -0
  872. package/bundle/_internal/mypy/typeshed/stdlib/encodings/rot_13.pyi +23 -0
  873. package/bundle/_internal/mypy/typeshed/stdlib/encodings/shift_jis.pyi +23 -0
  874. package/bundle/_internal/mypy/typeshed/stdlib/encodings/shift_jis_2004.pyi +23 -0
  875. package/bundle/_internal/mypy/typeshed/stdlib/encodings/shift_jisx0213.pyi +23 -0
  876. package/bundle/_internal/mypy/typeshed/stdlib/encodings/tis_620.pyi +21 -0
  877. package/bundle/_internal/mypy/typeshed/stdlib/encodings/undefined.pyi +20 -0
  878. package/bundle/_internal/mypy/typeshed/stdlib/encodings/unicode_escape.pyi +23 -0
  879. package/bundle/_internal/mypy/typeshed/stdlib/encodings/utf_16.pyi +20 -0
  880. package/bundle/_internal/mypy/typeshed/stdlib/encodings/utf_16_be.pyi +26 -0
  881. package/bundle/_internal/mypy/typeshed/stdlib/encodings/utf_16_le.pyi +26 -0
  882. package/bundle/_internal/mypy/typeshed/stdlib/encodings/utf_32.pyi +20 -0
  883. package/bundle/_internal/mypy/typeshed/stdlib/encodings/utf_32_be.pyi +26 -0
  884. package/bundle/_internal/mypy/typeshed/stdlib/encodings/utf_32_le.pyi +26 -0
  885. package/bundle/_internal/mypy/typeshed/stdlib/encodings/utf_7.pyi +26 -0
  886. package/bundle/_internal/mypy/typeshed/stdlib/encodings/utf_8.pyi +26 -0
  887. package/bundle/_internal/mypy/typeshed/stdlib/encodings/utf_8_sig.pyi +22 -0
  888. package/bundle/_internal/mypy/typeshed/stdlib/encodings/uu_codec.pyi +28 -0
  889. package/bundle/_internal/mypy/typeshed/stdlib/encodings/zlib_codec.pyi +26 -0
  890. package/bundle/_internal/mypy/typeshed/stdlib/ensurepip/__init__.pyi +12 -0
  891. package/bundle/_internal/mypy/typeshed/stdlib/enum.pyi +374 -0
  892. package/bundle/_internal/mypy/typeshed/stdlib/errno.pyi +227 -0
  893. package/bundle/_internal/mypy/typeshed/stdlib/faulthandler.pyi +61 -0
  894. package/bundle/_internal/mypy/typeshed/stdlib/fcntl.pyi +157 -0
  895. package/bundle/_internal/mypy/typeshed/stdlib/filecmp.pyi +65 -0
  896. package/bundle/_internal/mypy/typeshed/stdlib/fileinput.pyi +141 -0
  897. package/bundle/_internal/mypy/typeshed/stdlib/fnmatch.pyi +16 -0
  898. package/bundle/_internal/mypy/typeshed/stdlib/fractions.pyi +185 -0
  899. package/bundle/_internal/mypy/typeshed/stdlib/ftplib.pyi +174 -0
  900. package/bundle/_internal/mypy/typeshed/stdlib/functools.pyi +287 -0
  901. package/bundle/_internal/mypy/typeshed/stdlib/gc.pyi +32 -0
  902. package/bundle/_internal/mypy/typeshed/stdlib/genericpath.pyi +98 -0
  903. package/bundle/_internal/mypy/typeshed/stdlib/getopt.pyi +27 -0
  904. package/bundle/_internal/mypy/typeshed/stdlib/getpass.pyi +14 -0
  905. package/bundle/_internal/mypy/typeshed/stdlib/gettext.pyi +190 -0
  906. package/bundle/_internal/mypy/typeshed/stdlib/glob.pyi +50 -0
  907. package/bundle/_internal/mypy/typeshed/stdlib/graphlib.pyi +29 -0
  908. package/bundle/_internal/mypy/typeshed/stdlib/grp.pyi +21 -0
  909. package/bundle/_internal/mypy/typeshed/stdlib/gzip.pyi +181 -0
  910. package/bundle/_internal/mypy/typeshed/stdlib/hashlib.pyi +112 -0
  911. package/bundle/_internal/mypy/typeshed/stdlib/heapq.pyi +32 -0
  912. package/bundle/_internal/mypy/typeshed/stdlib/hmac.pyi +33 -0
  913. package/bundle/_internal/mypy/typeshed/stdlib/html/__init__.pyi +7 -0
  914. package/bundle/_internal/mypy/typeshed/stdlib/html/entities.pyi +8 -0
  915. package/bundle/_internal/mypy/typeshed/stdlib/html/parser.pyi +40 -0
  916. package/bundle/_internal/mypy/typeshed/stdlib/http/__init__.pyi +118 -0
  917. package/bundle/_internal/mypy/typeshed/stdlib/http/client.pyi +318 -0
  918. package/bundle/_internal/mypy/typeshed/stdlib/http/cookiejar.pyi +158 -0
  919. package/bundle/_internal/mypy/typeshed/stdlib/http/cookies.pyi +57 -0
  920. package/bundle/_internal/mypy/typeshed/stdlib/http/server.pyi +139 -0
  921. package/bundle/_internal/mypy/typeshed/stdlib/imaplib.pyi +212 -0
  922. package/bundle/_internal/mypy/typeshed/stdlib/imghdr.pyi +18 -0
  923. package/bundle/_internal/mypy/typeshed/stdlib/imp.pyi +63 -0
  924. package/bundle/_internal/mypy/typeshed/stdlib/importlib/__init__.pyi +17 -0
  925. package/bundle/_internal/mypy/typeshed/stdlib/importlib/_abc.pyi +21 -0
  926. package/bundle/_internal/mypy/typeshed/stdlib/importlib/_bootstrap.pyi +2 -0
  927. package/bundle/_internal/mypy/typeshed/stdlib/importlib/_bootstrap_external.pyi +2 -0
  928. package/bundle/_internal/mypy/typeshed/stdlib/importlib/abc.pyi +165 -0
  929. package/bundle/_internal/mypy/typeshed/stdlib/importlib/machinery.pyi +43 -0
  930. package/bundle/_internal/mypy/typeshed/stdlib/importlib/metadata/__init__.pyi +310 -0
  931. package/bundle/_internal/mypy/typeshed/stdlib/importlib/metadata/_meta.pyi +65 -0
  932. package/bundle/_internal/mypy/typeshed/stdlib/importlib/metadata/diagnose.pyi +2 -0
  933. package/bundle/_internal/mypy/typeshed/stdlib/importlib/readers.pyi +69 -0
  934. package/bundle/_internal/mypy/typeshed/stdlib/importlib/resources/__init__.pyi +81 -0
  935. package/bundle/_internal/mypy/typeshed/stdlib/importlib/resources/_common.pyi +48 -0
  936. package/bundle/_internal/mypy/typeshed/stdlib/importlib/resources/_functional.pyi +35 -0
  937. package/bundle/_internal/mypy/typeshed/stdlib/importlib/resources/abc.pyi +64 -0
  938. package/bundle/_internal/mypy/typeshed/stdlib/importlib/resources/readers.pyi +14 -0
  939. package/bundle/_internal/mypy/typeshed/stdlib/importlib/resources/simple.pyi +59 -0
  940. package/bundle/_internal/mypy/typeshed/stdlib/importlib/simple.pyi +11 -0
  941. package/bundle/_internal/mypy/typeshed/stdlib/importlib/util.pyi +75 -0
  942. package/bundle/_internal/mypy/typeshed/stdlib/inspect.pyi +749 -0
  943. package/bundle/_internal/mypy/typeshed/stdlib/io.pyi +75 -0
  944. package/bundle/_internal/mypy/typeshed/stdlib/ipaddress.pyi +249 -0
  945. package/bundle/_internal/mypy/typeshed/stdlib/itertools.pyi +376 -0
  946. package/bundle/_internal/mypy/typeshed/stdlib/json/__init__.pyi +93 -0
  947. package/bundle/_internal/mypy/typeshed/stdlib/json/decoder.pyi +50 -0
  948. package/bundle/_internal/mypy/typeshed/stdlib/json/encoder.pyi +40 -0
  949. package/bundle/_internal/mypy/typeshed/stdlib/json/scanner.pyi +7 -0
  950. package/bundle/_internal/mypy/typeshed/stdlib/json/tool.pyi +1 -0
  951. package/bundle/_internal/mypy/typeshed/stdlib/keyword.pyi +16 -0
  952. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/__init__.pyi +0 -0
  953. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/btm_matcher.pyi +28 -0
  954. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixer_base.pyi +42 -0
  955. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/__init__.pyi +0 -0
  956. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_apply.pyi +8 -0
  957. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_asserts.pyi +10 -0
  958. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_basestring.pyi +8 -0
  959. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_buffer.pyi +8 -0
  960. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_dict.pyi +16 -0
  961. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_except.pyi +14 -0
  962. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_exec.pyi +8 -0
  963. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_execfile.pyi +8 -0
  964. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_exitfunc.pyi +13 -0
  965. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_filter.pyi +9 -0
  966. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_funcattrs.pyi +8 -0
  967. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_future.pyi +8 -0
  968. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_getcwdu.pyi +8 -0
  969. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_has_key.pyi +8 -0
  970. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_idioms.pyi +15 -0
  971. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_import.pyi +16 -0
  972. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_imports.pyi +21 -0
  973. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_imports2.pyi +8 -0
  974. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_input.pyi +11 -0
  975. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_intern.pyi +9 -0
  976. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_isinstance.pyi +8 -0
  977. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_itertools.pyi +9 -0
  978. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_itertools_imports.pyi +7 -0
  979. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_long.pyi +7 -0
  980. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_map.pyi +9 -0
  981. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_metaclass.pyi +17 -0
  982. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_methodattrs.pyi +10 -0
  983. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_ne.pyi +8 -0
  984. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_next.pyi +19 -0
  985. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_nonzero.pyi +8 -0
  986. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_numliterals.pyi +8 -0
  987. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_operator.pyi +12 -0
  988. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_paren.pyi +8 -0
  989. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_print.pyi +12 -0
  990. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_raise.pyi +8 -0
  991. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_raw_input.pyi +8 -0
  992. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_reduce.pyi +8 -0
  993. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_reload.pyi +9 -0
  994. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_renames.pyi +17 -0
  995. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_repr.pyi +8 -0
  996. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_set_literal.pyi +7 -0
  997. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_standarderror.pyi +8 -0
  998. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_sys_exc.pyi +9 -0
  999. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_throw.pyi +8 -0
  1000. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_tuple_params.pyi +16 -0
  1001. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_types.pyi +8 -0
  1002. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_unicode.pyi +12 -0
  1003. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_urllib.pyi +15 -0
  1004. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_ws_comma.pyi +12 -0
  1005. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_xrange.pyi +20 -0
  1006. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_xreadlines.pyi +8 -0
  1007. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_zip.pyi +9 -0
  1008. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/main.pyi +42 -0
  1009. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/pgen2/__init__.pyi +8 -0
  1010. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/pgen2/driver.pyi +27 -0
  1011. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/pgen2/grammar.pyi +25 -0
  1012. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/pgen2/literals.pyi +7 -0
  1013. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/pgen2/parse.pyi +30 -0
  1014. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/pgen2/pgen.pyi +53 -0
  1015. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/pgen2/token.pyi +69 -0
  1016. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/pgen2/tokenize.pyi +96 -0
  1017. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/pygram.pyi +114 -0
  1018. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/pytree.pyi +118 -0
  1019. package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/refactor.pyi +86 -0
  1020. package/bundle/_internal/mypy/typeshed/stdlib/linecache.pyi +18 -0
  1021. package/bundle/_internal/mypy/typeshed/stdlib/locale.pyi +160 -0
  1022. package/bundle/_internal/mypy/typeshed/stdlib/logging/__init__.pyi +674 -0
  1023. package/bundle/_internal/mypy/typeshed/stdlib/logging/config.pyi +141 -0
  1024. package/bundle/_internal/mypy/typeshed/stdlib/logging/handlers.pyi +258 -0
  1025. package/bundle/_internal/mypy/typeshed/stdlib/lzma.pyi +181 -0
  1026. package/bundle/_internal/mypy/typeshed/stdlib/mailbox.pyi +307 -0
  1027. package/bundle/_internal/mypy/typeshed/stdlib/mailcap.pyi +11 -0
  1028. package/bundle/_internal/mypy/typeshed/stdlib/marshal.pyi +51 -0
  1029. package/bundle/_internal/mypy/typeshed/stdlib/math/__init__.pyi +157 -0
  1030. package/bundle/_internal/mypy/typeshed/stdlib/math/integer.pyi +8 -0
  1031. package/bundle/_internal/mypy/typeshed/stdlib/mimetypes.pyi +56 -0
  1032. package/bundle/_internal/mypy/typeshed/stdlib/mmap.pyi +191 -0
  1033. package/bundle/_internal/mypy/typeshed/stdlib/modulefinder.pyi +68 -0
  1034. package/bundle/_internal/mypy/typeshed/stdlib/msilib/__init__.pyi +177 -0
  1035. package/bundle/_internal/mypy/typeshed/stdlib/msilib/schema.pyi +95 -0
  1036. package/bundle/_internal/mypy/typeshed/stdlib/msilib/sequence.pyi +13 -0
  1037. package/bundle/_internal/mypy/typeshed/stdlib/msilib/text.pyi +8 -0
  1038. package/bundle/_internal/mypy/typeshed/stdlib/msvcrt.pyi +31 -0
  1039. package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/__init__.pyi +90 -0
  1040. package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/connection.pyi +97 -0
  1041. package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/context.pyi +220 -0
  1042. package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/dummy/__init__.pyi +89 -0
  1043. package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/dummy/connection.pyi +39 -0
  1044. package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/forkserver.pyi +78 -0
  1045. package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/heap.pyi +41 -0
  1046. package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/managers.pyi +390 -0
  1047. package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/pool.pyi +101 -0
  1048. package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/popen_fork.pyi +26 -0
  1049. package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/popen_forkserver.pyi +16 -0
  1050. package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/popen_spawn_posix.pyi +20 -0
  1051. package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/popen_spawn_win32.pyi +30 -0
  1052. package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/process.pyi +57 -0
  1053. package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/queues.pyi +46 -0
  1054. package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/reduction.pyi +95 -0
  1055. package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/resource_sharer.pyi +20 -0
  1056. package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/resource_tracker.pyi +21 -0
  1057. package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/shared_memory.pyi +43 -0
  1058. package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/sharedctypes.pyi +140 -0
  1059. package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/spawn.pyi +32 -0
  1060. package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/synchronize.pyi +63 -0
  1061. package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/util.pyi +109 -0
  1062. package/bundle/_internal/mypy/typeshed/stdlib/netrc.pyi +23 -0
  1063. package/bundle/_internal/mypy/typeshed/stdlib/nis.pyi +9 -0
  1064. package/bundle/_internal/mypy/typeshed/stdlib/nntplib.pyi +120 -0
  1065. package/bundle/_internal/mypy/typeshed/stdlib/nt.pyi +116 -0
  1066. package/bundle/_internal/mypy/typeshed/stdlib/ntpath.pyi +134 -0
  1067. package/bundle/_internal/mypy/typeshed/stdlib/nturl2path.pyi +6 -0
  1068. package/bundle/_internal/mypy/typeshed/stdlib/numbers.pyi +220 -0
  1069. package/bundle/_internal/mypy/typeshed/stdlib/opcode.pyi +53 -0
  1070. package/bundle/_internal/mypy/typeshed/stdlib/operator.pyi +219 -0
  1071. package/bundle/_internal/mypy/typeshed/stdlib/optparse.pyi +312 -0
  1072. package/bundle/_internal/mypy/typeshed/stdlib/os/__init__.pyi +1878 -0
  1073. package/bundle/_internal/mypy/typeshed/stdlib/os/path.pyi +8 -0
  1074. package/bundle/_internal/mypy/typeshed/stdlib/ossaudiodev.pyi +132 -0
  1075. package/bundle/_internal/mypy/typeshed/stdlib/pathlib/__init__.pyi +358 -0
  1076. package/bundle/_internal/mypy/typeshed/stdlib/pathlib/types.pyi +8 -0
  1077. package/bundle/_internal/mypy/typeshed/stdlib/pdb.pyi +275 -0
  1078. package/bundle/_internal/mypy/typeshed/stdlib/pickle.pyi +240 -0
  1079. package/bundle/_internal/mypy/typeshed/stdlib/pickletools.pyi +176 -0
  1080. package/bundle/_internal/mypy/typeshed/stdlib/pipes.pyi +16 -0
  1081. package/bundle/_internal/mypy/typeshed/stdlib/pkgutil.pyi +60 -0
  1082. package/bundle/_internal/mypy/typeshed/stdlib/platform.pyi +100 -0
  1083. package/bundle/_internal/mypy/typeshed/stdlib/plistlib.pyi +84 -0
  1084. package/bundle/_internal/mypy/typeshed/stdlib/poplib.pyi +93 -0
  1085. package/bundle/_internal/mypy/typeshed/stdlib/posix.pyi +427 -0
  1086. package/bundle/_internal/mypy/typeshed/stdlib/posixpath.pyi +230 -0
  1087. package/bundle/_internal/mypy/typeshed/stdlib/pprint.pyi +170 -0
  1088. package/bundle/_internal/mypy/typeshed/stdlib/profile.pyi +31 -0
  1089. package/bundle/_internal/mypy/typeshed/stdlib/profiling/__init__.pyi +3 -0
  1090. package/bundle/_internal/mypy/typeshed/stdlib/profiling/sampling/__init__.pyi +17 -0
  1091. package/bundle/_internal/mypy/typeshed/stdlib/profiling/sampling/collector.pyi +25 -0
  1092. package/bundle/_internal/mypy/typeshed/stdlib/profiling/sampling/gecko_collector.pyi +111 -0
  1093. package/bundle/_internal/mypy/typeshed/stdlib/profiling/sampling/heatmap_collector.pyi +24 -0
  1094. package/bundle/_internal/mypy/typeshed/stdlib/profiling/sampling/jsonl_collector.pyi +15 -0
  1095. package/bundle/_internal/mypy/typeshed/stdlib/profiling/sampling/pstats_collector.pyi +17 -0
  1096. package/bundle/_internal/mypy/typeshed/stdlib/profiling/sampling/stack_collector.pyi +40 -0
  1097. package/bundle/_internal/mypy/typeshed/stdlib/profiling/sampling/string_table.pyi +5 -0
  1098. package/bundle/_internal/mypy/typeshed/stdlib/profiling/tracing.pyi +9 -0
  1099. package/bundle/_internal/mypy/typeshed/stdlib/pstats.pyi +96 -0
  1100. package/bundle/_internal/mypy/typeshed/stdlib/pty.pyi +24 -0
  1101. package/bundle/_internal/mypy/typeshed/stdlib/pwd.pyi +27 -0
  1102. package/bundle/_internal/mypy/typeshed/stdlib/py_compile.pyi +28 -0
  1103. package/bundle/_internal/mypy/typeshed/stdlib/pyclbr.pyi +57 -0
  1104. package/bundle/_internal/mypy/typeshed/stdlib/pydoc.pyi +348 -0
  1105. package/bundle/_internal/mypy/typeshed/stdlib/pydoc_data/__init__.pyi +0 -0
  1106. package/bundle/_internal/mypy/typeshed/stdlib/pydoc_data/module_docs.pyi +3 -0
  1107. package/bundle/_internal/mypy/typeshed/stdlib/pydoc_data/topics.pyi +3 -0
  1108. package/bundle/_internal/mypy/typeshed/stdlib/pyexpat/__init__.pyi +88 -0
  1109. package/bundle/_internal/mypy/typeshed/stdlib/pyexpat/errors.pyi +53 -0
  1110. package/bundle/_internal/mypy/typeshed/stdlib/pyexpat/model.pyi +13 -0
  1111. package/bundle/_internal/mypy/typeshed/stdlib/queue.pyi +55 -0
  1112. package/bundle/_internal/mypy/typeshed/stdlib/quopri.pyi +12 -0
  1113. package/bundle/_internal/mypy/typeshed/stdlib/random.pyi +135 -0
  1114. package/bundle/_internal/mypy/typeshed/stdlib/re.pyi +347 -0
  1115. package/bundle/_internal/mypy/typeshed/stdlib/readline.pyi +39 -0
  1116. package/bundle/_internal/mypy/typeshed/stdlib/reprlib.pyi +64 -0
  1117. package/bundle/_internal/mypy/typeshed/stdlib/resource.pyi +102 -0
  1118. package/bundle/_internal/mypy/typeshed/stdlib/rlcompleter.pyi +9 -0
  1119. package/bundle/_internal/mypy/typeshed/stdlib/runpy.pyi +24 -0
  1120. package/bundle/_internal/mypy/typeshed/stdlib/sched.pyi +34 -0
  1121. package/bundle/_internal/mypy/typeshed/stdlib/secrets.pyi +17 -0
  1122. package/bundle/_internal/mypy/typeshed/stdlib/select.pyi +171 -0
  1123. package/bundle/_internal/mypy/typeshed/stdlib/selectors.pyi +67 -0
  1124. package/bundle/_internal/mypy/typeshed/stdlib/shelve.pyi +110 -0
  1125. package/bundle/_internal/mypy/typeshed/stdlib/shlex.pyi +63 -0
  1126. package/bundle/_internal/mypy/typeshed/stdlib/shutil.pyi +243 -0
  1127. package/bundle/_internal/mypy/typeshed/stdlib/signal.pyi +174 -0
  1128. package/bundle/_internal/mypy/typeshed/stdlib/site.pyi +46 -0
  1129. package/bundle/_internal/mypy/typeshed/stdlib/smtpd.pyi +92 -0
  1130. package/bundle/_internal/mypy/typeshed/stdlib/smtplib.pyi +223 -0
  1131. package/bundle/_internal/mypy/typeshed/stdlib/sndhdr.pyi +14 -0
  1132. package/bundle/_internal/mypy/typeshed/stdlib/socket.pyi +1587 -0
  1133. package/bundle/_internal/mypy/typeshed/stdlib/socketserver.pyi +170 -0
  1134. package/bundle/_internal/mypy/typeshed/stdlib/spwd.pyi +45 -0
  1135. package/bundle/_internal/mypy/typeshed/stdlib/sqlite3/__init__.pyi +510 -0
  1136. package/bundle/_internal/mypy/typeshed/stdlib/sqlite3/dbapi2.pyi +244 -0
  1137. package/bundle/_internal/mypy/typeshed/stdlib/sqlite3/dump.pyi +2 -0
  1138. package/bundle/_internal/mypy/typeshed/stdlib/sre_compile.pyi +12 -0
  1139. package/bundle/_internal/mypy/typeshed/stdlib/sre_constants.pyi +135 -0
  1140. package/bundle/_internal/mypy/typeshed/stdlib/sre_parse.pyi +102 -0
  1141. package/bundle/_internal/mypy/typeshed/stdlib/ssl.pyi +540 -0
  1142. package/bundle/_internal/mypy/typeshed/stdlib/stat.pyi +126 -0
  1143. package/bundle/_internal/mypy/typeshed/stdlib/statistics.pyi +161 -0
  1144. package/bundle/_internal/mypy/typeshed/stdlib/string/__init__.pyi +81 -0
  1145. package/bundle/_internal/mypy/typeshed/stdlib/string/templatelib.pyi +36 -0
  1146. package/bundle/_internal/mypy/typeshed/stdlib/stringprep.pyi +29 -0
  1147. package/bundle/_internal/mypy/typeshed/stdlib/struct.pyi +5 -0
  1148. package/bundle/_internal/mypy/typeshed/stdlib/subprocess.pyi +1484 -0
  1149. package/bundle/_internal/mypy/typeshed/stdlib/sunau.pyi +82 -0
  1150. package/bundle/_internal/mypy/typeshed/stdlib/symtable.pyi +95 -0
  1151. package/bundle/_internal/mypy/typeshed/stdlib/sys/__init__.pyi +538 -0
  1152. package/bundle/_internal/mypy/typeshed/stdlib/sys/__jit.pyi +11 -0
  1153. package/bundle/_internal/mypy/typeshed/stdlib/sys/_monitoring.pyi +69 -0
  1154. package/bundle/_internal/mypy/typeshed/stdlib/sysconfig.pyi +59 -0
  1155. package/bundle/_internal/mypy/typeshed/stdlib/syslog.pyi +58 -0
  1156. package/bundle/_internal/mypy/typeshed/stdlib/tabnanny.pyi +16 -0
  1157. package/bundle/_internal/mypy/typeshed/stdlib/tarfile.pyi +868 -0
  1158. package/bundle/_internal/mypy/typeshed/stdlib/telnetlib.pyi +123 -0
  1159. package/bundle/_internal/mypy/typeshed/stdlib/tempfile.pyi +474 -0
  1160. package/bundle/_internal/mypy/typeshed/stdlib/termios.pyi +303 -0
  1161. package/bundle/_internal/mypy/typeshed/stdlib/textwrap.pyi +103 -0
  1162. package/bundle/_internal/mypy/typeshed/stdlib/this.pyi +2 -0
  1163. package/bundle/_internal/mypy/typeshed/stdlib/threading.pyi +221 -0
  1164. package/bundle/_internal/mypy/typeshed/stdlib/time.pyi +117 -0
  1165. package/bundle/_internal/mypy/typeshed/stdlib/timeit.pyi +46 -0
  1166. package/bundle/_internal/mypy/typeshed/stdlib/tkinter/__init__.pyi +4376 -0
  1167. package/bundle/_internal/mypy/typeshed/stdlib/tkinter/colorchooser.pyi +12 -0
  1168. package/bundle/_internal/mypy/typeshed/stdlib/tkinter/commondialog.pyi +14 -0
  1169. package/bundle/_internal/mypy/typeshed/stdlib/tkinter/constants.pyi +80 -0
  1170. package/bundle/_internal/mypy/typeshed/stdlib/tkinter/dialog.pyi +13 -0
  1171. package/bundle/_internal/mypy/typeshed/stdlib/tkinter/dnd.pyi +19 -0
  1172. package/bundle/_internal/mypy/typeshed/stdlib/tkinter/filedialog.pyi +149 -0
  1173. package/bundle/_internal/mypy/typeshed/stdlib/tkinter/font.pyi +123 -0
  1174. package/bundle/_internal/mypy/typeshed/stdlib/tkinter/messagebox.pyi +98 -0
  1175. package/bundle/_internal/mypy/typeshed/stdlib/tkinter/scrolledtext.pyi +9 -0
  1176. package/bundle/_internal/mypy/typeshed/stdlib/tkinter/simpledialog.pyi +58 -0
  1177. package/bundle/_internal/mypy/typeshed/stdlib/tkinter/tix.pyi +299 -0
  1178. package/bundle/_internal/mypy/typeshed/stdlib/tkinter/ttk.pyi +1434 -0
  1179. package/bundle/_internal/mypy/typeshed/stdlib/token.pyi +166 -0
  1180. package/bundle/_internal/mypy/typeshed/stdlib/tokenize.pyi +201 -0
  1181. package/bundle/_internal/mypy/typeshed/stdlib/tomllib.pyi +27 -0
  1182. package/bundle/_internal/mypy/typeshed/stdlib/trace.pyi +85 -0
  1183. package/bundle/_internal/mypy/typeshed/stdlib/traceback.pyi +293 -0
  1184. package/bundle/_internal/mypy/typeshed/stdlib/tracemalloc.pyi +123 -0
  1185. package/bundle/_internal/mypy/typeshed/stdlib/tty.pyi +29 -0
  1186. package/bundle/_internal/mypy/typeshed/stdlib/turtle.pyi +856 -0
  1187. package/bundle/_internal/mypy/typeshed/stdlib/types.pyi +744 -0
  1188. package/bundle/_internal/mypy/typeshed/stdlib/typing.pyi +1250 -0
  1189. package/bundle/_internal/mypy/typeshed/stdlib/typing_extensions.pyi +749 -0
  1190. package/bundle/_internal/mypy/typeshed/stdlib/unicodedata.pyi +94 -0
  1191. package/bundle/_internal/mypy/typeshed/stdlib/unittest/__init__.pyi +63 -0
  1192. package/bundle/_internal/mypy/typeshed/stdlib/unittest/_log.pyi +29 -0
  1193. package/bundle/_internal/mypy/typeshed/stdlib/unittest/async_case.pyi +24 -0
  1194. package/bundle/_internal/mypy/typeshed/stdlib/unittest/case.pyi +352 -0
  1195. package/bundle/_internal/mypy/typeshed/stdlib/unittest/loader.pyi +55 -0
  1196. package/bundle/_internal/mypy/typeshed/stdlib/unittest/main.pyi +74 -0
  1197. package/bundle/_internal/mypy/typeshed/stdlib/unittest/mock.pyi +555 -0
  1198. package/bundle/_internal/mypy/typeshed/stdlib/unittest/result.pyi +46 -0
  1199. package/bundle/_internal/mypy/typeshed/stdlib/unittest/runner.pyi +93 -0
  1200. package/bundle/_internal/mypy/typeshed/stdlib/unittest/signals.pyi +15 -0
  1201. package/bundle/_internal/mypy/typeshed/stdlib/unittest/suite.pyi +23 -0
  1202. package/bundle/_internal/mypy/typeshed/stdlib/unittest/util.pyi +39 -0
  1203. package/bundle/_internal/mypy/typeshed/stdlib/urllib/__init__.pyi +0 -0
  1204. package/bundle/_internal/mypy/typeshed/stdlib/urllib/error.pyi +29 -0
  1205. package/bundle/_internal/mypy/typeshed/stdlib/urllib/parse.pyi +354 -0
  1206. package/bundle/_internal/mypy/typeshed/stdlib/urllib/request.pyi +447 -0
  1207. package/bundle/_internal/mypy/typeshed/stdlib/urllib/response.pyi +45 -0
  1208. package/bundle/_internal/mypy/typeshed/stdlib/urllib/robotparser.pyi +20 -0
  1209. package/bundle/_internal/mypy/typeshed/stdlib/uu.pyi +12 -0
  1210. package/bundle/_internal/mypy/typeshed/stdlib/uuid.pyi +106 -0
  1211. package/bundle/_internal/mypy/typeshed/stdlib/venv/__init__.pyi +86 -0
  1212. package/bundle/_internal/mypy/typeshed/stdlib/warnings.pyi +146 -0
  1213. package/bundle/_internal/mypy/typeshed/stdlib/wave.pyi +105 -0
  1214. package/bundle/_internal/mypy/typeshed/stdlib/weakref.pyi +217 -0
  1215. package/bundle/_internal/mypy/typeshed/stdlib/webbrowser.pyi +93 -0
  1216. package/bundle/_internal/mypy/typeshed/stdlib/winreg.pyi +137 -0
  1217. package/bundle/_internal/mypy/typeshed/stdlib/winsound.pyi +40 -0
  1218. package/bundle/_internal/mypy/typeshed/stdlib/wsgiref/__init__.pyi +0 -0
  1219. package/bundle/_internal/mypy/typeshed/stdlib/wsgiref/handlers.pyi +91 -0
  1220. package/bundle/_internal/mypy/typeshed/stdlib/wsgiref/headers.pyi +27 -0
  1221. package/bundle/_internal/mypy/typeshed/stdlib/wsgiref/simple_server.pyi +37 -0
  1222. package/bundle/_internal/mypy/typeshed/stdlib/wsgiref/types.pyi +31 -0
  1223. package/bundle/_internal/mypy/typeshed/stdlib/wsgiref/util.pyi +26 -0
  1224. package/bundle/_internal/mypy/typeshed/stdlib/wsgiref/validate.pyi +50 -0
  1225. package/bundle/_internal/mypy/typeshed/stdlib/xdrlib.pyi +57 -0
  1226. package/bundle/_internal/mypy/typeshed/stdlib/xml/__init__.pyi +9 -0
  1227. package/bundle/_internal/mypy/typeshed/stdlib/xml/dom/NodeFilter.pyi +22 -0
  1228. package/bundle/_internal/mypy/typeshed/stdlib/xml/dom/__init__.pyi +101 -0
  1229. package/bundle/_internal/mypy/typeshed/stdlib/xml/dom/domreg.pyi +8 -0
  1230. package/bundle/_internal/mypy/typeshed/stdlib/xml/dom/expatbuilder.pyi +126 -0
  1231. package/bundle/_internal/mypy/typeshed/stdlib/xml/dom/minicompat.pyi +24 -0
  1232. package/bundle/_internal/mypy/typeshed/stdlib/xml/dom/minidom.pyi +693 -0
  1233. package/bundle/_internal/mypy/typeshed/stdlib/xml/dom/pulldom.pyi +109 -0
  1234. package/bundle/_internal/mypy/typeshed/stdlib/xml/dom/xmlbuilder.pyi +82 -0
  1235. package/bundle/_internal/mypy/typeshed/stdlib/xml/etree/ElementInclude.pyi +28 -0
  1236. package/bundle/_internal/mypy/typeshed/stdlib/xml/etree/ElementPath.pyi +42 -0
  1237. package/bundle/_internal/mypy/typeshed/stdlib/xml/etree/ElementTree.pyi +402 -0
  1238. package/bundle/_internal/mypy/typeshed/stdlib/xml/etree/__init__.pyi +0 -0
  1239. package/bundle/_internal/mypy/typeshed/stdlib/xml/etree/cElementTree.pyi +1 -0
  1240. package/bundle/_internal/mypy/typeshed/stdlib/xml/parsers/__init__.pyi +1 -0
  1241. package/bundle/_internal/mypy/typeshed/stdlib/xml/parsers/expat/__init__.pyi +7 -0
  1242. package/bundle/_internal/mypy/typeshed/stdlib/xml/parsers/expat/errors.pyi +1 -0
  1243. package/bundle/_internal/mypy/typeshed/stdlib/xml/parsers/expat/model.pyi +1 -0
  1244. package/bundle/_internal/mypy/typeshed/stdlib/xml/sax/__init__.pyi +42 -0
  1245. package/bundle/_internal/mypy/typeshed/stdlib/xml/sax/_exceptions.pyi +19 -0
  1246. package/bundle/_internal/mypy/typeshed/stdlib/xml/sax/expatreader.pyi +72 -0
  1247. package/bundle/_internal/mypy/typeshed/stdlib/xml/sax/handler.pyi +85 -0
  1248. package/bundle/_internal/mypy/typeshed/stdlib/xml/sax/saxutils.pyi +69 -0
  1249. package/bundle/_internal/mypy/typeshed/stdlib/xml/sax/xmlreader.pyi +94 -0
  1250. package/bundle/_internal/mypy/typeshed/stdlib/xml/utils.pyi +2 -0
  1251. package/bundle/_internal/mypy/typeshed/stdlib/xmlrpc/__init__.pyi +0 -0
  1252. package/bundle/_internal/mypy/typeshed/stdlib/xmlrpc/client.pyi +300 -0
  1253. package/bundle/_internal/mypy/typeshed/stdlib/xmlrpc/server.pyi +149 -0
  1254. package/bundle/_internal/mypy/typeshed/stdlib/xxlimited.pyi +15 -0
  1255. package/bundle/_internal/mypy/typeshed/stdlib/zipapp.pyi +19 -0
  1256. package/bundle/_internal/mypy/typeshed/stdlib/zipfile/__init__.pyi +411 -0
  1257. package/bundle/_internal/mypy/typeshed/stdlib/zipfile/_path/__init__.pyi +87 -0
  1258. package/bundle/_internal/mypy/typeshed/stdlib/zipfile/_path/glob.pyi +26 -0
  1259. package/bundle/_internal/mypy/typeshed/stdlib/zipimport.pyi +44 -0
  1260. package/bundle/_internal/mypy/typeshed/stdlib/zlib.pyi +81 -0
  1261. package/bundle/_internal/mypy/typeshed/stdlib/zoneinfo/__init__.pyi +36 -0
  1262. package/bundle/_internal/mypy/typeshed/stdlib/zoneinfo/_common.pyi +14 -0
  1263. package/bundle/_internal/mypy/typeshed/stdlib/zoneinfo/_tzpath.pyi +13 -0
  1264. package/bundle/_internal/mypy/typeshed/stubs/librt/librt/__init__.pyi +0 -0
  1265. package/bundle/_internal/mypy/typeshed/stubs/librt/librt/base64.pyi +4 -0
  1266. package/bundle/_internal/mypy/typeshed/stubs/librt/librt/internal.pyi +22 -0
  1267. package/bundle/_internal/mypy/typeshed/stubs/librt/librt/random.pyi +22 -0
  1268. package/bundle/_internal/mypy/typeshed/stubs/librt/librt/strings.pyi +61 -0
  1269. package/bundle/_internal/mypy/typeshed/stubs/librt/librt/threading.pyi +16 -0
  1270. package/bundle/_internal/mypy/typeshed/stubs/librt/librt/time.pyi +1 -0
  1271. package/bundle/_internal/mypy/typeshed/stubs/librt/librt/vecs.pyi +24 -0
  1272. package/bundle/_internal/mypy/typeshed/stubs/mypy-extensions/mypy_extensions.pyi +226 -0
  1273. package/bundle/_internal/mypy/typestate.cpython-312-darwin.so +0 -0
  1274. package/bundle/_internal/mypy/typestate.py +334 -0
  1275. package/bundle/_internal/mypy/typetraverser.cpython-312-darwin.so +0 -0
  1276. package/bundle/_internal/mypy/typetraverser.py +166 -0
  1277. package/bundle/_internal/mypy/typevars.cpython-312-darwin.so +0 -0
  1278. package/bundle/_internal/mypy/typevars.py +84 -0
  1279. package/bundle/_internal/mypy/typevartuples.cpython-312-darwin.so +0 -0
  1280. package/bundle/_internal/mypy/typevartuples.py +36 -0
  1281. package/bundle/_internal/mypy/util.cpython-312-darwin.so +0 -0
  1282. package/bundle/_internal/mypy/util.py +1055 -0
  1283. package/bundle/_internal/mypy/version.py +1 -0
  1284. package/bundle/_internal/mypy/visitor.cpython-312-darwin.so +0 -0
  1285. package/bundle/_internal/mypy/visitor.py +639 -0
  1286. package/bundle/_internal/mypy/xml/mypy-html.css +104 -0
  1287. package/bundle/_internal/mypy/xml/mypy-html.xslt +81 -0
  1288. package/bundle/_internal/mypy/xml/mypy-txt.xslt +100 -0
  1289. package/bundle/_internal/mypy/xml/mypy.xsd +50 -0
  1290. package/bundle/_internal/mypy-2.4.1.dist-info/INSTALLER +1 -0
  1291. package/bundle/_internal/mypy-2.4.1.dist-info/METADATA +56 -0
  1292. package/bundle/_internal/mypy-2.4.1.dist-info/RECORD +1814 -0
  1293. package/bundle/_internal/mypy-2.4.1.dist-info/WHEEL +6 -0
  1294. package/bundle/_internal/mypy-2.4.1.dist-info/entry_points.txt +6 -0
  1295. package/bundle/_internal/mypy-2.4.1.dist-info/licenses/LICENSE +264 -0
  1296. package/bundle/_internal/mypy-2.4.1.dist-info/licenses/mypy/typeshed/LICENSE +237 -0
  1297. package/bundle/_internal/mypy-2.4.1.dist-info/top_level.txt +3 -0
  1298. package/bundle/_internal/mypyc/__init__.cpython-312-darwin.so +0 -0
  1299. package/bundle/_internal/python3.12/lib-dynload/_asyncio.cpython-312-darwin.so +0 -0
  1300. package/bundle/_internal/python3.12/lib-dynload/_bisect.cpython-312-darwin.so +0 -0
  1301. package/bundle/_internal/python3.12/lib-dynload/_blake2.cpython-312-darwin.so +0 -0
  1302. package/bundle/_internal/python3.12/lib-dynload/_bz2.cpython-312-darwin.so +0 -0
  1303. package/bundle/_internal/python3.12/lib-dynload/_codecs_cn.cpython-312-darwin.so +0 -0
  1304. package/bundle/_internal/python3.12/lib-dynload/_codecs_hk.cpython-312-darwin.so +0 -0
  1305. package/bundle/_internal/python3.12/lib-dynload/_codecs_iso2022.cpython-312-darwin.so +0 -0
  1306. package/bundle/_internal/python3.12/lib-dynload/_codecs_jp.cpython-312-darwin.so +0 -0
  1307. package/bundle/_internal/python3.12/lib-dynload/_codecs_kr.cpython-312-darwin.so +0 -0
  1308. package/bundle/_internal/python3.12/lib-dynload/_codecs_tw.cpython-312-darwin.so +0 -0
  1309. package/bundle/_internal/python3.12/lib-dynload/_contextvars.cpython-312-darwin.so +0 -0
  1310. package/bundle/_internal/python3.12/lib-dynload/_csv.cpython-312-darwin.so +0 -0
  1311. package/bundle/_internal/python3.12/lib-dynload/_ctypes.cpython-312-darwin.so +0 -0
  1312. package/bundle/_internal/python3.12/lib-dynload/_curses.cpython-312-darwin.so +0 -0
  1313. package/bundle/_internal/python3.12/lib-dynload/_datetime.cpython-312-darwin.so +0 -0
  1314. package/bundle/_internal/python3.12/lib-dynload/_decimal.cpython-312-darwin.so +0 -0
  1315. package/bundle/_internal/python3.12/lib-dynload/_elementtree.cpython-312-darwin.so +0 -0
  1316. package/bundle/_internal/python3.12/lib-dynload/_hashlib.cpython-312-darwin.so +0 -0
  1317. package/bundle/_internal/python3.12/lib-dynload/_heapq.cpython-312-darwin.so +0 -0
  1318. package/bundle/_internal/python3.12/lib-dynload/_json.cpython-312-darwin.so +0 -0
  1319. package/bundle/_internal/python3.12/lib-dynload/_lzma.cpython-312-darwin.so +0 -0
  1320. package/bundle/_internal/python3.12/lib-dynload/_md5.cpython-312-darwin.so +0 -0
  1321. package/bundle/_internal/python3.12/lib-dynload/_multibytecodec.cpython-312-darwin.so +0 -0
  1322. package/bundle/_internal/python3.12/lib-dynload/_multiprocessing.cpython-312-darwin.so +0 -0
  1323. package/bundle/_internal/python3.12/lib-dynload/_opcode.cpython-312-darwin.so +0 -0
  1324. package/bundle/_internal/python3.12/lib-dynload/_pickle.cpython-312-darwin.so +0 -0
  1325. package/bundle/_internal/python3.12/lib-dynload/_posixshmem.cpython-312-darwin.so +0 -0
  1326. package/bundle/_internal/python3.12/lib-dynload/_posixsubprocess.cpython-312-darwin.so +0 -0
  1327. package/bundle/_internal/python3.12/lib-dynload/_queue.cpython-312-darwin.so +0 -0
  1328. package/bundle/_internal/python3.12/lib-dynload/_random.cpython-312-darwin.so +0 -0
  1329. package/bundle/_internal/python3.12/lib-dynload/_scproxy.cpython-312-darwin.so +0 -0
  1330. package/bundle/_internal/python3.12/lib-dynload/_sha1.cpython-312-darwin.so +0 -0
  1331. package/bundle/_internal/python3.12/lib-dynload/_sha2.cpython-312-darwin.so +0 -0
  1332. package/bundle/_internal/python3.12/lib-dynload/_sha3.cpython-312-darwin.so +0 -0
  1333. package/bundle/_internal/python3.12/lib-dynload/_socket.cpython-312-darwin.so +0 -0
  1334. package/bundle/_internal/python3.12/lib-dynload/_sqlite3.cpython-312-darwin.so +0 -0
  1335. package/bundle/_internal/python3.12/lib-dynload/_ssl.cpython-312-darwin.so +0 -0
  1336. package/bundle/_internal/python3.12/lib-dynload/_statistics.cpython-312-darwin.so +0 -0
  1337. package/bundle/_internal/python3.12/lib-dynload/_struct.cpython-312-darwin.so +0 -0
  1338. package/bundle/_internal/python3.12/lib-dynload/_uuid.cpython-312-darwin.so +0 -0
  1339. package/bundle/_internal/python3.12/lib-dynload/array.cpython-312-darwin.so +0 -0
  1340. package/bundle/_internal/python3.12/lib-dynload/binascii.cpython-312-darwin.so +0 -0
  1341. package/bundle/_internal/python3.12/lib-dynload/fcntl.cpython-312-darwin.so +0 -0
  1342. package/bundle/_internal/python3.12/lib-dynload/grp.cpython-312-darwin.so +0 -0
  1343. package/bundle/_internal/python3.12/lib-dynload/math.cpython-312-darwin.so +0 -0
  1344. package/bundle/_internal/python3.12/lib-dynload/mmap.cpython-312-darwin.so +0 -0
  1345. package/bundle/_internal/python3.12/lib-dynload/pyexpat.cpython-312-darwin.so +0 -0
  1346. package/bundle/_internal/python3.12/lib-dynload/readline.cpython-312-darwin.so +0 -0
  1347. package/bundle/_internal/python3.12/lib-dynload/resource.cpython-312-darwin.so +0 -0
  1348. package/bundle/_internal/python3.12/lib-dynload/select.cpython-312-darwin.so +0 -0
  1349. package/bundle/_internal/python3.12/lib-dynload/syslog.cpython-312-darwin.so +0 -0
  1350. package/bundle/_internal/python3.12/lib-dynload/termios.cpython-312-darwin.so +0 -0
  1351. package/bundle/_internal/python3.12/lib-dynload/unicodedata.cpython-312-darwin.so +0 -0
  1352. package/bundle/_internal/python3.12/lib-dynload/zlib.cpython-312-darwin.so +0 -0
  1353. package/bundle/_internal/radon/__init__.py +21 -0
  1354. package/bundle/_internal/radon/__main__.py +4 -0
  1355. package/bundle/_internal/radon/cli/__init__.py +433 -0
  1356. package/bundle/_internal/radon/cli/colors.py +49 -0
  1357. package/bundle/_internal/radon/cli/harvest.py +449 -0
  1358. package/bundle/_internal/radon/cli/tools.py +597 -0
  1359. package/bundle/_internal/radon/complexity.py +108 -0
  1360. package/bundle/_internal/radon/contrib/__init__.py +0 -0
  1361. package/bundle/_internal/radon/contrib/flake8.py +72 -0
  1362. package/bundle/_internal/radon/metrics.py +157 -0
  1363. package/bundle/_internal/radon/raw.py +245 -0
  1364. package/bundle/_internal/radon/tests/__init__.py +0 -0
  1365. package/bundle/_internal/radon/tests/conftest.py +31 -0
  1366. package/bundle/_internal/radon/tests/data/__init__.py +5 -0
  1367. package/bundle/_internal/radon/tests/data/no_encoding.py +2 -0
  1368. package/bundle/_internal/radon/tests/data/py3unicode.py +5 -0
  1369. package/bundle/_internal/radon/tests/run.py +14 -0
  1370. package/bundle/_internal/radon/tests/test_cli.py +282 -0
  1371. package/bundle/_internal/radon/tests/test_cli_colors.py +22 -0
  1372. package/bundle/_internal/radon/tests/test_cli_harvest.py +392 -0
  1373. package/bundle/_internal/radon/tests/test_cli_tools.py +616 -0
  1374. package/bundle/_internal/radon/tests/test_complexity_utils.py +118 -0
  1375. package/bundle/_internal/radon/tests/test_complexity_visitor.py +754 -0
  1376. package/bundle/_internal/radon/tests/test_halstead.py +113 -0
  1377. package/bundle/_internal/radon/tests/test_ipynb.py +141 -0
  1378. package/bundle/_internal/radon/tests/test_other_metrics.py +169 -0
  1379. package/bundle/_internal/radon/tests/test_raw.py +467 -0
  1380. package/bundle/_internal/radon/visitors.py +460 -0
  1381. package/bundle/_internal/radon-6.0.1.dist-info/INSTALLER +1 -0
  1382. package/bundle/_internal/radon-6.0.1.dist-info/LICENSE +22 -0
  1383. package/bundle/_internal/radon-6.0.1.dist-info/METADATA +263 -0
  1384. package/bundle/_internal/radon-6.0.1.dist-info/RECORD +64 -0
  1385. package/bundle/_internal/radon-6.0.1.dist-info/WHEEL +6 -0
  1386. package/bundle/_internal/radon-6.0.1.dist-info/entry_points.txt +8 -0
  1387. package/bundle/_internal/radon-6.0.1.dist-info/top_level.txt +1 -0
  1388. package/bundle/_internal/setuptools/_vendor/jaraco/text/Lorem ipsum.txt +2 -0
  1389. package/bundle/_internal/stevedore-5.10.0.dist-info/INSTALLER +1 -0
  1390. package/bundle/_internal/stevedore-5.10.0.dist-info/METADATA +56 -0
  1391. package/bundle/_internal/stevedore-5.10.0.dist-info/RECORD +84 -0
  1392. package/bundle/_internal/stevedore-5.10.0.dist-info/WHEEL +5 -0
  1393. package/bundle/_internal/stevedore-5.10.0.dist-info/entry_points.txt +10 -0
  1394. package/bundle/_internal/stevedore-5.10.0.dist-info/licenses/AUTHORS +76 -0
  1395. package/bundle/_internal/stevedore-5.10.0.dist-info/licenses/LICENSE +202 -0
  1396. package/bundle/_internal/stevedore-5.10.0.dist-info/pbr.json +1 -0
  1397. package/bundle/_internal/stevedore-5.10.0.dist-info/top_level.txt +1 -0
  1398. package/bundle/_internal/tqdm-4.70.1.dist-info/INSTALLER +1 -0
  1399. package/bundle/_internal/tqdm-4.70.1.dist-info/METADATA +1600 -0
  1400. package/bundle/_internal/tqdm-4.70.1.dist-info/RECORD +72 -0
  1401. package/bundle/_internal/tqdm-4.70.1.dist-info/WHEEL +5 -0
  1402. package/bundle/_internal/tqdm-4.70.1.dist-info/entry_points.txt +2 -0
  1403. package/bundle/_internal/tqdm-4.70.1.dist-info/licenses/LICENCE +49 -0
  1404. package/bundle/_internal/tqdm-4.70.1.dist-info/top_level.txt +1 -0
  1405. package/bundle/_internal/yaml/_yaml.cpython-312-darwin.so +0 -0
  1406. package/bundle/gnost +0 -0
  1407. package/package.json +10 -7
@@ -0,0 +1,2961 @@
1
+ """Semantic analysis of types"""
2
+
3
+ from __future__ import annotations
4
+
5
+ import itertools
6
+ from collections.abc import Callable, Iterable, Iterator, Sequence
7
+ from contextlib import contextmanager
8
+ from typing import Final, Protocol, TypeVar
9
+
10
+ from mypy import errorcodes as codes, message_registry, nodes
11
+ from mypy.errorcodes import ErrorCode
12
+ from mypy.errors import ErrorInfo
13
+ from mypy.expandtype import expand_type
14
+ from mypy.message_registry import (
15
+ INVALID_PARAM_SPEC_LOCATION,
16
+ INVALID_PARAM_SPEC_LOCATION_NOTE,
17
+ TYPEDDICT_OVERRIDE_MERGE,
18
+ )
19
+ from mypy.messages import (
20
+ MessageBuilder,
21
+ format_type,
22
+ format_type_bare,
23
+ quote_type_string,
24
+ wrong_type_arg_count,
25
+ )
26
+ from mypy.nodes import (
27
+ ARG_NAMED,
28
+ ARG_NAMED_OPT,
29
+ ARG_OPT,
30
+ ARG_POS,
31
+ ARG_STAR,
32
+ ARG_STAR2,
33
+ MISSING_FALLBACK,
34
+ SYMBOL_FUNCBASE_TYPES,
35
+ ArgKind,
36
+ Context,
37
+ Decorator,
38
+ ImportFrom,
39
+ MypyFile,
40
+ ParamSpecExpr,
41
+ PlaceholderNode,
42
+ SymbolTableNode,
43
+ TypeAlias,
44
+ TypeInfo,
45
+ TypeVarExpr,
46
+ TypeVarLikeExpr,
47
+ TypeVarTupleExpr,
48
+ Var,
49
+ check_arg_kinds,
50
+ check_param_names,
51
+ )
52
+ from mypy.options import INLINE_TYPEDDICT, Options
53
+ from mypy.plugin import AnalyzeTypeContext, Plugin, TypeAnalyzerPluginInterface
54
+ from mypy.semanal_shared import (
55
+ SemanticAnalyzerCoreInterface,
56
+ SemanticAnalyzerInterface,
57
+ paramspec_args,
58
+ paramspec_kwargs,
59
+ )
60
+ from mypy.state import state
61
+ from mypy.tvar_scope import TypeVarLikeScope
62
+ from mypy.types import (
63
+ ANNOTATED_TYPE_NAMES,
64
+ ANY_STRATEGY,
65
+ CONCATENATE_TYPE_NAMES,
66
+ FINAL_TYPE_NAMES,
67
+ LITERAL_TYPE_NAMES,
68
+ MYPYC_NATIVE_INT_NAMES,
69
+ NEVER_NAMES,
70
+ TUPLE_NAMES,
71
+ TYPE_ALIAS_NAMES,
72
+ TYPE_NAMES,
73
+ UNPACK_TYPE_NAMES,
74
+ AnyType,
75
+ BoolTypeQuery,
76
+ CallableArgument,
77
+ CallableType,
78
+ CollectAliasesVisitor,
79
+ DeletedType,
80
+ EllipsisType,
81
+ ErasedType,
82
+ Instance,
83
+ LiteralType,
84
+ NoneType,
85
+ Overloaded,
86
+ Parameters,
87
+ ParamSpecFlavor,
88
+ ParamSpecType,
89
+ PartialType,
90
+ PlaceholderType,
91
+ ProperType,
92
+ RawExpressionType,
93
+ ReadOnlyType,
94
+ RequiredType,
95
+ SyntheticTypeVisitor,
96
+ TrivialSyntheticTypeTranslator,
97
+ TupleType,
98
+ Type,
99
+ TypeAliasType,
100
+ TypedDictType,
101
+ TypeList,
102
+ TypeOfAny,
103
+ TypeQuery,
104
+ TypeType,
105
+ TypeVarId,
106
+ TypeVarLikeType,
107
+ TypeVarTupleType,
108
+ TypeVarType,
109
+ UnboundType,
110
+ UninhabitedType,
111
+ UnionType,
112
+ UnpackType,
113
+ callable_with_ellipsis,
114
+ find_unpack_in_list,
115
+ flatten_nested_tuples,
116
+ get_proper_type,
117
+ has_type_vars,
118
+ )
119
+ from mypy.types_utils import get_bad_type_type_item
120
+ from mypy.typevars import fill_typevars
121
+
122
+ T = TypeVar("T")
123
+
124
+ type_constructors: Final = {
125
+ "typing.Callable",
126
+ "typing.Optional",
127
+ "typing.Tuple",
128
+ "typing.Type",
129
+ "typing.Union",
130
+ *LITERAL_TYPE_NAMES,
131
+ *ANNOTATED_TYPE_NAMES,
132
+ }
133
+
134
+ ARG_KINDS_BY_CONSTRUCTOR: Final = {
135
+ "mypy_extensions.Arg": ARG_POS,
136
+ "mypy_extensions.DefaultArg": ARG_OPT,
137
+ "mypy_extensions.NamedArg": ARG_NAMED,
138
+ "mypy_extensions.DefaultNamedArg": ARG_NAMED_OPT,
139
+ "mypy_extensions.VarArg": ARG_STAR,
140
+ "mypy_extensions.KwArg": ARG_STAR2,
141
+ }
142
+
143
+ SELF_TYPE_NAMES: Final = {"typing.Self", "typing_extensions.Self"}
144
+
145
+
146
+ def analyze_type_alias(
147
+ type: Type,
148
+ api: SemanticAnalyzerCoreInterface,
149
+ tvar_scope: TypeVarLikeScope,
150
+ plugin: Plugin,
151
+ options: Options,
152
+ cur_mod_node: MypyFile,
153
+ is_typeshed_stub: bool,
154
+ allow_placeholder: bool = False,
155
+ in_dynamic_func: bool = False,
156
+ global_scope: bool = True,
157
+ allowed_alias_tvars: list[TypeVarLikeType] | None = None,
158
+ erase_tvar_defs: list[TypeVarType] | None = None,
159
+ alias_type_params_names: list[str] | None = None,
160
+ python_3_12_type_alias: bool = False,
161
+ ) -> tuple[Type, set[str]]:
162
+ """Analyze r.h.s. of a (potential) type alias definition.
163
+
164
+ If `node` is valid as a type alias rvalue, return the resulting type and a set of
165
+ full names of type aliases it depends on (directly or indirectly).
166
+ 'node' must have been semantically analyzed.
167
+ """
168
+ analyzer = TypeAnalyser(
169
+ api,
170
+ tvar_scope,
171
+ plugin,
172
+ options,
173
+ cur_mod_node,
174
+ is_typeshed_stub,
175
+ defining_alias=True,
176
+ allow_placeholder=allow_placeholder,
177
+ prohibit_self_type="type alias target",
178
+ allowed_alias_tvars=allowed_alias_tvars,
179
+ erase_tvar_defs=erase_tvar_defs,
180
+ alias_type_params_names=alias_type_params_names,
181
+ python_3_12_type_alias=python_3_12_type_alias,
182
+ )
183
+ analyzer.in_dynamic_func = in_dynamic_func
184
+ analyzer.global_scope = global_scope
185
+ res = analyzer.anal_type(type, nested=False)
186
+ return res, analyzer.aliases_used
187
+
188
+
189
+ class TypeAnalyser(SyntheticTypeVisitor[Type], TypeAnalyzerPluginInterface):
190
+ """Semantic analyzer for types.
191
+
192
+ Converts unbound types into bound types. This is a no-op for already
193
+ bound types.
194
+
195
+ If an incomplete reference is encountered, this does a defer. The
196
+ caller never needs to defer.
197
+ """
198
+
199
+ # Is this called from an untyped function definition?
200
+ in_dynamic_func: bool = False
201
+ # Is this called from global scope?
202
+ global_scope: bool = True
203
+
204
+ def __init__(
205
+ self,
206
+ api: SemanticAnalyzerCoreInterface,
207
+ tvar_scope: TypeVarLikeScope,
208
+ plugin: Plugin,
209
+ options: Options,
210
+ cur_mod_node: MypyFile,
211
+ is_typeshed_stub: bool,
212
+ *,
213
+ defining_alias: bool = False,
214
+ python_3_12_type_alias: bool = False,
215
+ allow_tuple_literal: bool = False,
216
+ allow_unbound_tvars: bool = False,
217
+ allow_placeholder: bool = False,
218
+ allow_typed_dict_special_forms: bool = False,
219
+ allow_final: bool = True,
220
+ allow_param_spec_literals: bool = False,
221
+ allow_unpack: bool = False,
222
+ report_invalid_types: bool = True,
223
+ prohibit_self_type: str | None = None,
224
+ prohibit_special_class_field_types: str | None = None,
225
+ allowed_alias_tvars: list[TypeVarLikeType] | None = None,
226
+ erase_tvar_defs: list[TypeVarType] | None = None,
227
+ allow_type_any: bool = False,
228
+ alias_type_params_names: list[str] | None = None,
229
+ analyzing_tvar_def: bool = False,
230
+ ) -> None:
231
+ self.api = api
232
+ self.fail_func = api.fail
233
+ self.note_func = api.note
234
+ self.tvar_scope = tvar_scope
235
+ # Are we analysing a type alias definition rvalue?
236
+ self.defining_alias = defining_alias
237
+ self.python_3_12_type_alias = python_3_12_type_alias
238
+ self.allow_tuple_literal = allow_tuple_literal
239
+ # Positive if we are analyzing arguments of another (outer) type
240
+ self.nesting_level = 0
241
+ # Should we accept unbound type variables? This is currently used for class bases,
242
+ # and alias right hand sides (before they are analyzed as type aliases).
243
+ self.allow_unbound_tvars = allow_unbound_tvars
244
+ if allowed_alias_tvars is None:
245
+ allowed_alias_tvars = []
246
+ self.allowed_alias_tvars = allowed_alias_tvars
247
+ # Should we erase some type variables? This can be used to mass-erase type
248
+ # variables that were found to be invalid at the class/alias definition.
249
+ if erase_tvar_defs is None:
250
+ erase_tvar_defs = []
251
+ self.erase_tvar_defs = erase_tvar_defs
252
+ self.alias_type_params_names = alias_type_params_names
253
+ # If false, record incomplete ref if we generate PlaceholderType.
254
+ self.allow_placeholder = allow_placeholder
255
+ # Are we in a context where Required[] is allowed?
256
+ self.allow_typed_dict_special_forms = allow_typed_dict_special_forms
257
+ # Set True when we analyze ClassVar else False
258
+ self.allow_final = allow_final
259
+ # Are we in a context where ParamSpec literals are allowed?
260
+ self.allow_param_spec_literals = allow_param_spec_literals
261
+ # Are we in context where literal "..." specifically is allowed?
262
+ self.allow_ellipsis = False
263
+ # Should we report an error whenever we encounter a RawExpressionType outside
264
+ # of a Literal context: e.g. whenever we encounter an invalid type? Normally,
265
+ # we want to report an error, but the caller may want to do more specialized
266
+ # error handling.
267
+ self.report_invalid_types = report_invalid_types
268
+ self.plugin = plugin
269
+ self.options = options
270
+ self.cur_mod_node = cur_mod_node
271
+ self.is_typeshed_stub = is_typeshed_stub
272
+ # Names of type aliases encountered while analysing a type will be collected here.
273
+ self.aliases_used: set[str] = set()
274
+ self.prohibit_self_type = prohibit_self_type
275
+ # Set when we analyze TypedDicts or NamedTuples, since they are special:
276
+ self.prohibit_special_class_field_types = prohibit_special_class_field_types
277
+ # Allow variables typed as Type[Any] and type (useful for base classes).
278
+ self.allow_type_any = allow_type_any
279
+ # Level of nesting at which a TypeVarTuple is allowed. Note we specify exact level
280
+ # to prohibit things like Unpack[list[Ts]], which are not supported.
281
+ self.allow_type_var_tuple = -1
282
+ self.allow_unpack = allow_unpack
283
+ # Set when we are analyzing a default of a type variable.
284
+ self.analyzing_tvar_def = analyzing_tvar_def
285
+
286
+ def lookup_qualified(
287
+ self, name: str, ctx: Context, suppress_errors: bool = False
288
+ ) -> SymbolTableNode | None:
289
+ return self.api.lookup_qualified(name, ctx, suppress_errors)
290
+
291
+ def lookup_fully_qualified(self, fullname: str) -> SymbolTableNode:
292
+ return self.api.lookup_fully_qualified(fullname)
293
+
294
+ def visit_unbound_type(self, t: UnboundType, defining_literal: bool = False) -> Type:
295
+ typ = self.visit_unbound_type_nonoptional(t, defining_literal)
296
+ if t.optional:
297
+ # We don't need to worry about double-wrapping Optionals or
298
+ # wrapping Anys: Union simplification will take care of that.
299
+ return make_optional_type(typ)
300
+ return typ
301
+
302
+ def not_declared_in_type_params(self, tvar_name: str) -> bool:
303
+ return (
304
+ self.alias_type_params_names is not None
305
+ and tvar_name not in self.alias_type_params_names
306
+ )
307
+
308
+ def visit_unbound_type_nonoptional(self, t: UnboundType, defining_literal: bool) -> Type:
309
+ sym = self.lookup_qualified(t.name, t)
310
+ param_spec_name = None
311
+ if t.name.endswith((".args", ".kwargs")):
312
+ param_spec_name = t.name.rsplit(".", 1)[0]
313
+ maybe_param_spec = self.lookup_qualified(param_spec_name, t)
314
+ if maybe_param_spec and isinstance(maybe_param_spec.node, ParamSpecExpr):
315
+ sym = maybe_param_spec
316
+ else:
317
+ param_spec_name = None
318
+
319
+ if sym is not None:
320
+ node = sym.node
321
+ if isinstance(node, PlaceholderNode):
322
+ if node.becomes_typeinfo:
323
+ # Reference to placeholder type.
324
+ if self.api.final_iteration:
325
+ self.cannot_resolve_type(t)
326
+ return AnyType(TypeOfAny.from_error)
327
+ elif self.allow_placeholder:
328
+ self.api.defer()
329
+ else:
330
+ self.api.record_incomplete_ref()
331
+ # Always allow ParamSpec for placeholders, if they are actually not valid,
332
+ # they will be reported later, after we resolve placeholders.
333
+ return PlaceholderType(
334
+ node.fullname,
335
+ self.anal_array(
336
+ t.args,
337
+ allow_param_spec=True,
338
+ allow_param_spec_literals=True,
339
+ allow_unpack=True,
340
+ ),
341
+ t.line,
342
+ )
343
+ else:
344
+ if self.api.final_iteration:
345
+ self.cannot_resolve_type(t)
346
+ return AnyType(TypeOfAny.from_error)
347
+ else:
348
+ # Reference to an unknown placeholder node.
349
+ self.api.record_incomplete_ref()
350
+ return AnyType(TypeOfAny.special_form)
351
+ if node is None:
352
+ self.fail(f"Internal error (node is None, kind={sym.kind})", t)
353
+ return AnyType(TypeOfAny.special_form)
354
+ fullname = node.fullname
355
+ hook = self.plugin.get_type_analyze_hook(fullname)
356
+ if hook is not None:
357
+ return hook(AnalyzeTypeContext(t, t, self))
358
+ tvar_def = self.tvar_scope.get_binding(sym)
359
+ if tvar_def is not None:
360
+ # We need to cover special-case explained in get_typevarlike_argument() here,
361
+ # since otherwise the deferral will not be triggered if the type variable is
362
+ # used in a different module. Using isinstance() should be safe for this purpose.
363
+ tvar_params = [tvar_def.upper_bound, tvar_def.default]
364
+ if isinstance(tvar_def, TypeVarType):
365
+ tvar_params += tvar_def.values
366
+ if any(isinstance(tp, PlaceholderType) for tp in tvar_params):
367
+ self.api.defer()
368
+ if isinstance(sym.node, ParamSpecExpr):
369
+ if tvar_def is None:
370
+ if self.allow_unbound_tvars:
371
+ return t
372
+ name = param_spec_name or t.name
373
+ if self.defining_alias and self.not_declared_in_type_params(t.name):
374
+ msg = f'ParamSpec "{name}" is not included in type_params'
375
+ else:
376
+ msg = f'ParamSpec "{name}" is unbound'
377
+ self.fail(msg, t, code=codes.VALID_TYPE)
378
+ return AnyType(TypeOfAny.from_error)
379
+ assert isinstance(tvar_def, ParamSpecType)
380
+ if len(t.args) > 0:
381
+ self.fail(
382
+ f'ParamSpec "{t.name}" used with arguments', t, code=codes.VALID_TYPE
383
+ )
384
+ if param_spec_name is not None and not self.allow_param_spec_literals:
385
+ self.fail(
386
+ "ParamSpec components are not allowed here", t, code=codes.VALID_TYPE
387
+ )
388
+ return AnyType(TypeOfAny.from_error)
389
+ # Change the line number
390
+ return ParamSpecType(
391
+ tvar_def.name,
392
+ tvar_def.fullname,
393
+ tvar_def.id,
394
+ tvar_def.flavor,
395
+ tvar_def.upper_bound,
396
+ tvar_def.default,
397
+ line=t.line,
398
+ column=t.column,
399
+ )
400
+ if (
401
+ isinstance(sym.node, TypeVarExpr)
402
+ and self.defining_alias
403
+ and not defining_literal
404
+ and (tvar_def is None or tvar_def not in self.allowed_alias_tvars)
405
+ ):
406
+ if self.not_declared_in_type_params(t.name):
407
+ if self.python_3_12_type_alias:
408
+ msg = message_registry.TYPE_PARAMETERS_SHOULD_BE_DECLARED.format(
409
+ f'"{t.name}"'
410
+ )
411
+ else:
412
+ msg = f'Type variable "{t.name}" is not included in type_params'
413
+ else:
414
+ msg = f'Can\'t use bound type variable "{t.name}" to define generic alias'
415
+ self.fail(msg, t, code=codes.VALID_TYPE)
416
+ return AnyType(TypeOfAny.from_error)
417
+ if (
418
+ isinstance(sym.node, TypeVarExpr)
419
+ and tvar_def is not None
420
+ and tvar_def in self.erase_tvar_defs
421
+ ):
422
+ # The caller should have already given a relevant error.
423
+ return AnyType(TypeOfAny.from_error)
424
+ if isinstance(sym.node, TypeVarExpr) and tvar_def is not None:
425
+ assert isinstance(tvar_def, TypeVarType)
426
+ if len(t.args) > 0:
427
+ self.fail(
428
+ f'Type variable "{t.name}" used with arguments', t, code=codes.VALID_TYPE
429
+ )
430
+ # Change the line number
431
+ return tvar_def.copy_modified(line=t.line, column=t.column)
432
+ if isinstance(sym.node, TypeVarTupleExpr) and (
433
+ tvar_def is not None
434
+ and self.defining_alias
435
+ and tvar_def not in self.allowed_alias_tvars
436
+ ):
437
+ if self.not_declared_in_type_params(t.name):
438
+ msg = f'Type variable "{t.name}" is not included in type_params'
439
+ else:
440
+ msg = f'Can\'t use bound type variable "{t.name}" to define generic alias'
441
+ self.fail(msg, t, code=codes.VALID_TYPE)
442
+ return AnyType(TypeOfAny.from_error)
443
+ if isinstance(sym.node, TypeVarTupleExpr):
444
+ if tvar_def is None:
445
+ if self.allow_unbound_tvars:
446
+ return t
447
+ if self.defining_alias and self.not_declared_in_type_params(t.name):
448
+ if self.python_3_12_type_alias:
449
+ msg = message_registry.TYPE_PARAMETERS_SHOULD_BE_DECLARED.format(
450
+ f'"{t.name}"'
451
+ )
452
+ else:
453
+ msg = f'TypeVarTuple "{t.name}" is not included in type_params'
454
+ else:
455
+ msg = f'TypeVarTuple "{t.name}" is unbound'
456
+ self.fail(msg, t, code=codes.VALID_TYPE)
457
+ return AnyType(TypeOfAny.from_error)
458
+ assert isinstance(tvar_def, TypeVarTupleType)
459
+ if self.allow_type_var_tuple != self.nesting_level:
460
+ self.fail(
461
+ f'TypeVarTuple "{t.name}" is only valid with an unpack',
462
+ t,
463
+ code=codes.VALID_TYPE,
464
+ )
465
+ return AnyType(TypeOfAny.from_error)
466
+ if len(t.args) > 0:
467
+ self.fail(
468
+ f'Type variable "{t.name}" used with arguments', t, code=codes.VALID_TYPE
469
+ )
470
+
471
+ # Change the line number
472
+ return TypeVarTupleType(
473
+ tvar_def.name,
474
+ tvar_def.fullname,
475
+ tvar_def.id,
476
+ tvar_def.upper_bound,
477
+ sym.node.tuple_fallback,
478
+ tvar_def.default,
479
+ line=t.line,
480
+ column=t.column,
481
+ )
482
+ special = self.try_analyze_special_unbound_type(t, fullname)
483
+ if special is not None:
484
+ return special
485
+ if isinstance(node, TypeAlias):
486
+ self.aliases_used.add(fullname)
487
+ an_args = self.anal_array(
488
+ t.args,
489
+ allow_param_spec=True,
490
+ allow_param_spec_literals=node.has_param_spec_type,
491
+ allow_unpack=True, # Fixed length unpacks can be used for non-variadic aliases.
492
+ )
493
+ if node.has_param_spec_type and len(node.alias_tvars) == 1:
494
+ an_args = self.pack_paramspec_args(an_args, t.empty_tuple_index)
495
+
496
+ disallow_any = self.options.disallow_any_generics and not self.is_typeshed_stub
497
+ res, used_default = instantiate_type_alias(
498
+ node,
499
+ an_args,
500
+ self.fail,
501
+ self.note,
502
+ node.no_args,
503
+ t,
504
+ self.options,
505
+ unexpanded_type=t,
506
+ disallow_any=disallow_any,
507
+ empty_tuple_index=t.empty_tuple_index,
508
+ analyzing_tvar_def=self.analyzing_tvar_def,
509
+ )
510
+ if self.analyzing_tvar_def and used_default and isinstance(res, TypeAliasType):
511
+ assert res.alias is not None
512
+ self.api.record_fixed_type(res.alias)
513
+ # The only case where instantiate_type_alias() can return an incorrect instance is
514
+ # when it is top-level instance, so no need to recurse.
515
+ if (
516
+ isinstance(res, ProperType)
517
+ and isinstance(res, Instance)
518
+ and not (self.defining_alias and self.nesting_level == 0)
519
+ and not validate_instance(res, self.fail, t.empty_tuple_index)
520
+ ):
521
+ used_default = fix_instance(
522
+ res,
523
+ self.fail,
524
+ self.note,
525
+ disallow_any=disallow_any,
526
+ options=self.options,
527
+ use_generic_error=True,
528
+ unexpanded_type=t,
529
+ analyzing_tvar_def=self.analyzing_tvar_def,
530
+ )
531
+ if self.analyzing_tvar_def and used_default:
532
+ self.api.record_fixed_type(res.type)
533
+ if node.eager:
534
+ res = get_proper_type(res)
535
+ return res
536
+ elif isinstance(node, TypeInfo):
537
+ return self.analyze_type_with_type_info(node, t.args, t, t.empty_tuple_index)
538
+ elif node.fullname in TYPE_ALIAS_NAMES:
539
+ return AnyType(TypeOfAny.special_form)
540
+ # Concatenate is an operator, no need for a proper type
541
+ elif node.fullname in CONCATENATE_TYPE_NAMES:
542
+ # We check the return type further up the stack for valid use locations
543
+ return self.apply_concatenate_operator(t)
544
+ else:
545
+ return self.analyze_unbound_type_without_type_info(t, sym, defining_literal)
546
+ else: # sym is None
547
+ return AnyType(TypeOfAny.special_form)
548
+
549
+ def pack_paramspec_args(self, an_args: Sequence[Type], empty_tuple_index: bool) -> list[Type]:
550
+ # "Aesthetic" ParamSpec literals for single ParamSpec: C[int, str] -> C[[int, str]].
551
+ # These do not support mypy_extensions VarArgs, etc. as they were already analyzed
552
+ # TODO: should these be re-analyzed to get rid of this inconsistency?
553
+ count = len(an_args)
554
+ if count == 0 and empty_tuple_index:
555
+ return [Parameters([], [], [])]
556
+ elif count == 0:
557
+ return []
558
+
559
+ if count == 1 and isinstance(get_proper_type(an_args[0]), AnyType):
560
+ # Single Any is interpreted as ..., rather that a single argument with Any type.
561
+ # I didn't find this in the PEP, but it sounds reasonable.
562
+ return list(an_args)
563
+ if any(isinstance(a, (Parameters, ParamSpecType)) for a in an_args):
564
+ if len(an_args) > 1:
565
+ first_wrong = next(
566
+ arg for arg in an_args if isinstance(arg, (Parameters, ParamSpecType))
567
+ )
568
+ self.fail(
569
+ "Nested parameter specifications are not allowed",
570
+ first_wrong,
571
+ code=codes.VALID_TYPE,
572
+ )
573
+ return [AnyType(TypeOfAny.from_error)]
574
+ return list(an_args)
575
+ first = an_args[0]
576
+ return [
577
+ Parameters(
578
+ an_args, [ARG_POS] * count, [None] * count, line=first.line, column=first.column
579
+ )
580
+ ]
581
+
582
+ def cannot_resolve_type(self, t: UnboundType) -> None:
583
+ # TODO: Move error message generation to messages.py. We'd first
584
+ # need access to MessageBuilder here. Also move the similar
585
+ # message generation logic in semanal.py.
586
+ self.api.fail(f'Cannot resolve name "{t.name}" (possible cyclic definition)', t)
587
+ if self.api.is_func_scope():
588
+ self.note("Recursive types are not allowed at function scope", t)
589
+
590
+ def apply_concatenate_operator(self, t: UnboundType) -> Type:
591
+ if len(t.args) == 0:
592
+ self.api.fail("Concatenate needs type arguments", t, code=codes.VALID_TYPE)
593
+ return AnyType(TypeOfAny.from_error)
594
+
595
+ # Last argument has to be ParamSpec or Ellipsis.
596
+ ps = self.anal_type(t.args[-1], allow_param_spec=True, allow_ellipsis=True)
597
+ if not isinstance(ps, (ParamSpecType, Parameters)):
598
+ if isinstance(ps, UnboundType) and self.allow_unbound_tvars:
599
+ sym = self.lookup_qualified(ps.name, t)
600
+ if sym is not None and isinstance(sym.node, ParamSpecExpr):
601
+ return ps
602
+ self.api.fail(
603
+ "The last parameter to Concatenate needs to be a ParamSpec",
604
+ t,
605
+ code=codes.VALID_TYPE,
606
+ )
607
+ return AnyType(TypeOfAny.from_error)
608
+ elif isinstance(ps, ParamSpecType) and ps.prefix.arg_types:
609
+ self.api.fail("Nested Concatenates are invalid", t, code=codes.VALID_TYPE)
610
+
611
+ args = self.anal_array(t.args[:-1])
612
+ pre = ps.prefix if isinstance(ps, ParamSpecType) else ps
613
+
614
+ # mypy can't infer this :(
615
+ names: list[str | None] = [None] * len(args)
616
+
617
+ pre = Parameters(
618
+ args + pre.arg_types,
619
+ [ARG_POS] * len(args) + pre.arg_kinds,
620
+ names + pre.arg_names,
621
+ line=t.line,
622
+ column=t.column,
623
+ )
624
+ return ps.copy_modified(prefix=pre) if isinstance(ps, ParamSpecType) else pre
625
+
626
+ def try_analyze_special_unbound_type(self, t: UnboundType, fullname: str) -> Type | None:
627
+ """Bind special type that is recognized through magic name such as 'typing.Any'.
628
+
629
+ Return the bound type if successful, and return None if the type is a normal type.
630
+ """
631
+ if fullname == "builtins.None":
632
+ return NoneType()
633
+ elif fullname == "typing.Any":
634
+ return AnyType(TypeOfAny.explicit, line=t.line, column=t.column)
635
+ elif fullname in FINAL_TYPE_NAMES:
636
+ if self.prohibit_special_class_field_types:
637
+ self.fail(
638
+ f"Final[...] can't be used inside a {self.prohibit_special_class_field_types}",
639
+ t,
640
+ code=codes.VALID_TYPE,
641
+ )
642
+ else:
643
+ if not self.allow_final:
644
+ self.fail(
645
+ "Final can be only used as an outermost qualifier in a variable annotation",
646
+ t,
647
+ code=codes.VALID_TYPE,
648
+ )
649
+ return AnyType(TypeOfAny.from_error)
650
+ elif fullname in TUPLE_NAMES:
651
+ # Tuple is special because it is involved in builtin import cycle
652
+ # and may be not ready when used.
653
+ sym = self.api.lookup_fully_qualified_or_none("builtins.tuple")
654
+ if not sym or isinstance(sym.node, PlaceholderNode):
655
+ if self.api.is_incomplete_namespace("builtins"):
656
+ self.api.record_incomplete_ref()
657
+ else:
658
+ self.fail('Name "tuple" is not defined', t)
659
+ return AnyType(TypeOfAny.special_form)
660
+ if len(t.args) == 0 and not t.empty_tuple_index:
661
+ # Bare 'Tuple' is same as 'tuple'
662
+ any_type = self.get_omitted_any(t)
663
+ return self.named_type("builtins.tuple", [any_type], line=t.line, column=t.column)
664
+ if len(t.args) == 2 and isinstance(t.args[1], EllipsisType):
665
+ # Tuple[T, ...] (uniform, variable-length tuple)
666
+ instance = self.named_type("builtins.tuple", [self.anal_type(t.args[0])])
667
+ instance.line = t.line
668
+ return instance
669
+ return self.tuple_type(
670
+ self.anal_array(t.args, allow_unpack=True), line=t.line, column=t.column
671
+ )
672
+ elif fullname == "typing.Union":
673
+ items = self.anal_array(t.args)
674
+ return UnionType.make_union(items, line=t.line, column=t.column)
675
+ elif fullname == "typing.Optional":
676
+ if len(t.args) != 1:
677
+ self.fail(
678
+ "Optional[...] must have exactly one type argument", t, code=codes.VALID_TYPE
679
+ )
680
+ return AnyType(TypeOfAny.from_error)
681
+ item = self.anal_type(t.args[0])
682
+ return make_optional_type(item)
683
+ elif fullname == "typing.Callable":
684
+ return self.analyze_callable_type(t)
685
+ elif fullname in TYPE_NAMES:
686
+ if len(t.args) == 0:
687
+ if fullname == "typing.Type":
688
+ any_type = self.get_omitted_any(t)
689
+ return TypeType(any_type, line=t.line, column=t.column)
690
+ else:
691
+ # To prevent assignment of 'builtins.type' inferred as 'builtins.object'
692
+ # See https://github.com/python/mypy/issues/9476 for more information
693
+ return None
694
+ type_str = "Type[...]" if fullname == "typing.Type" else "type[...]"
695
+ if len(t.args) != 1:
696
+ self.fail(
697
+ f"{type_str} must have exactly one type argument", t, code=codes.VALID_TYPE
698
+ )
699
+ item = self.anal_type(t.args[0])
700
+ bad_item_name = get_bad_type_type_item(item)
701
+ if bad_item_name:
702
+ self.fail(f'{type_str} can\'t contain "{bad_item_name}"', t, code=codes.VALID_TYPE)
703
+ item = AnyType(TypeOfAny.from_error)
704
+ return TypeType.make_normalized(item, line=t.line, column=t.column)
705
+ elif fullname in ("typing_extensions.TypeForm", "typing.TypeForm"):
706
+ if len(t.args) == 0:
707
+ any_type = self.get_omitted_any(t)
708
+ return TypeType(any_type, line=t.line, column=t.column, is_type_form=True)
709
+ if len(t.args) != 1:
710
+ type_str = "TypeForm[...]"
711
+ self.fail(
712
+ type_str + " must have exactly one type argument", t, code=codes.VALID_TYPE
713
+ )
714
+ item = self.anal_type(t.args[0])
715
+ return TypeType.make_normalized(item, line=t.line, column=t.column, is_type_form=True)
716
+ elif fullname == "typing.ClassVar":
717
+ if self.nesting_level > 0:
718
+ self.fail(
719
+ "Invalid type: ClassVar nested inside other type", t, code=codes.VALID_TYPE
720
+ )
721
+ if self.prohibit_special_class_field_types:
722
+ self.fail(
723
+ f"ClassVar[...] can't be used inside a {self.prohibit_special_class_field_types}",
724
+ t,
725
+ code=codes.VALID_TYPE,
726
+ )
727
+ if self.defining_alias:
728
+ self.fail(
729
+ "ClassVar[...] can't be used inside a type alias", t, code=codes.VALID_TYPE
730
+ )
731
+ if len(t.args) == 0:
732
+ return AnyType(TypeOfAny.from_omitted_generics, line=t.line, column=t.column)
733
+ if len(t.args) != 1:
734
+ self.fail(
735
+ "ClassVar[...] must have at most one type argument", t, code=codes.VALID_TYPE
736
+ )
737
+ return AnyType(TypeOfAny.from_error)
738
+ return self.anal_type(t.args[0], allow_final=self.options.python_version >= (3, 13))
739
+ elif fullname in NEVER_NAMES:
740
+ return UninhabitedType()
741
+ elif fullname in LITERAL_TYPE_NAMES:
742
+ return self.analyze_literal_type(t)
743
+ elif fullname in ANNOTATED_TYPE_NAMES:
744
+ if len(t.args) < 2:
745
+ self.fail(
746
+ "Annotated[...] must have exactly one type argument"
747
+ " and at least one annotation",
748
+ t,
749
+ code=codes.VALID_TYPE,
750
+ )
751
+ return AnyType(TypeOfAny.from_error)
752
+ return self.anal_type(
753
+ t.args[0], allow_typed_dict_special_forms=self.allow_typed_dict_special_forms
754
+ )
755
+ elif fullname in ("typing_extensions.Required", "typing.Required"):
756
+ if not self.allow_typed_dict_special_forms:
757
+ self.fail(
758
+ "Required[] can be only used in a TypedDict definition",
759
+ t,
760
+ code=codes.VALID_TYPE,
761
+ )
762
+ return AnyType(TypeOfAny.from_error)
763
+ if len(t.args) != 1:
764
+ self.fail(
765
+ "Required[] must have exactly one type argument", t, code=codes.VALID_TYPE
766
+ )
767
+ return AnyType(TypeOfAny.from_error)
768
+ return RequiredType(
769
+ self.anal_type(t.args[0], allow_typed_dict_special_forms=True), required=True
770
+ )
771
+ elif fullname in ("typing_extensions.NotRequired", "typing.NotRequired"):
772
+ if not self.allow_typed_dict_special_forms:
773
+ self.fail(
774
+ "NotRequired[] can be only used in a TypedDict definition",
775
+ t,
776
+ code=codes.VALID_TYPE,
777
+ )
778
+ return AnyType(TypeOfAny.from_error)
779
+ if len(t.args) != 1:
780
+ self.fail(
781
+ "NotRequired[] must have exactly one type argument", t, code=codes.VALID_TYPE
782
+ )
783
+ return AnyType(TypeOfAny.from_error)
784
+ return RequiredType(
785
+ self.anal_type(t.args[0], allow_typed_dict_special_forms=True), required=False
786
+ )
787
+ elif fullname in ("typing_extensions.ReadOnly", "typing.ReadOnly"):
788
+ if not self.allow_typed_dict_special_forms:
789
+ self.fail(
790
+ "ReadOnly[] can be only used in a TypedDict definition",
791
+ t,
792
+ code=codes.VALID_TYPE,
793
+ )
794
+ return AnyType(TypeOfAny.from_error)
795
+ if len(t.args) != 1:
796
+ self.fail(
797
+ '"ReadOnly[]" must have exactly one type argument', t, code=codes.VALID_TYPE
798
+ )
799
+ return AnyType(TypeOfAny.from_error)
800
+ return ReadOnlyType(self.anal_type(t.args[0], allow_typed_dict_special_forms=True))
801
+ elif (
802
+ self.anal_type_guard_arg(t, fullname) is not None
803
+ or self.anal_type_is_arg(t, fullname) is not None
804
+ ):
805
+ # In most contexts, TypeGuard[...] acts as an alias for bool (ignoring its args)
806
+ return self.named_type("builtins.bool")
807
+ elif fullname in UNPACK_TYPE_NAMES:
808
+ if len(t.args) != 1:
809
+ self.fail("Unpack[...] requires exactly one type argument", t)
810
+ return AnyType(TypeOfAny.from_error)
811
+ if not self.allow_unpack:
812
+ self.fail(message_registry.INVALID_UNPACK_POSITION, t, code=codes.VALID_TYPE)
813
+ return AnyType(TypeOfAny.from_error)
814
+ self.allow_type_var_tuple = self.nesting_level + 1
815
+ result = UnpackType(self.anal_type(t.args[0]), line=t.line, column=t.column)
816
+ self.allow_type_var_tuple = -1
817
+ return result
818
+ elif fullname in SELF_TYPE_NAMES:
819
+ if t.args:
820
+ self.fail("Self type cannot have type arguments", t)
821
+ if self.prohibit_self_type is not None:
822
+ self.fail(f"Self type cannot be used in {self.prohibit_self_type}", t)
823
+ return AnyType(TypeOfAny.from_error)
824
+ if self.api.type is None:
825
+ self.fail("Self type is only allowed in annotations within class definition", t)
826
+ return AnyType(TypeOfAny.from_error)
827
+ if self.api.type.has_base("builtins.type"):
828
+ self.fail("Self type cannot be used in a metaclass", t)
829
+ if self.api.type.self_type is not None:
830
+ if self.api.type.is_final or self.api.type.is_enum and self.api.type.enum_members:
831
+ return fill_typevars(self.api.type)
832
+ return self.api.type.self_type.copy_modified(line=t.line, column=t.column)
833
+ # TODO: verify this is unreachable and replace with an assert?
834
+ self.fail("Unexpected Self type", t)
835
+ return AnyType(TypeOfAny.from_error)
836
+ return None
837
+
838
+ def get_omitted_any(self, typ: Type, fullname: str | None = None) -> AnyType:
839
+ disallow_any = not self.is_typeshed_stub and self.options.disallow_any_generics
840
+ return get_omitted_any(disallow_any, self.fail, self.note, typ, self.options, fullname)
841
+
842
+ def check_and_warn_deprecated(self, info: TypeInfo, ctx: Context) -> None:
843
+ """Similar logic to `TypeChecker.check_deprecated` and `TypeChecker.warn_deprecated."""
844
+
845
+ if (
846
+ (deprecated := info.deprecated)
847
+ and not self.is_typeshed_stub
848
+ and not (self.api.type and (self.api.type.fullname == info.fullname))
849
+ and not any(
850
+ info.fullname == p or info.fullname.startswith(f"{p}.")
851
+ for p in self.options.deprecated_calls_exclude
852
+ )
853
+ ):
854
+ for imp in self.cur_mod_node.imports:
855
+ if isinstance(imp, ImportFrom) and any(info.name == n[0] for n in imp.names):
856
+ break
857
+ else:
858
+ warn = self.note if self.options.report_deprecated_as_note else self.fail
859
+ warn(deprecated, ctx, code=codes.DEPRECATED)
860
+
861
+ def analyze_type_with_type_info(
862
+ self, info: TypeInfo, args: Sequence[Type], ctx: Context, empty_tuple_index: bool
863
+ ) -> Type:
864
+ """Bind unbound type when were able to find target TypeInfo.
865
+
866
+ This handles simple cases like 'int', 'modname.UserClass[str]', etc.
867
+ """
868
+
869
+ self.check_and_warn_deprecated(info, ctx)
870
+
871
+ if len(args) > 0 and info.fullname == "builtins.tuple":
872
+ fallback = Instance(info, [AnyType(TypeOfAny.special_form)], ctx.line)
873
+ return TupleType(self.anal_array(args, allow_unpack=True), fallback, ctx.line)
874
+
875
+ # Analyze arguments and (usually) construct Instance type. The
876
+ # number of type arguments and their values are
877
+ # checked only later, since we do not always know the
878
+ # valid count at this point. Thus we may construct an
879
+ # Instance with an invalid number of type arguments.
880
+ #
881
+ # We allow ParamSpec literals based on a heuristic: it will be
882
+ # checked later anyways but the error message may be worse.
883
+ instance = Instance(
884
+ info,
885
+ self.anal_array(
886
+ args,
887
+ allow_param_spec=True,
888
+ allow_param_spec_literals=info.has_param_spec_type,
889
+ allow_unpack=True, # Fixed length tuples can be used for non-variadic types.
890
+ ),
891
+ ctx.line,
892
+ ctx.column,
893
+ )
894
+ instance.end_line = ctx.end_line
895
+ instance.end_column = ctx.end_column
896
+ if len(info.type_vars) == 1 and info.has_param_spec_type:
897
+ instance.args = tuple(self.pack_paramspec_args(instance.args, empty_tuple_index))
898
+
899
+ if info.fullname == "librt.vecs.vec" and not check_vec_type_args(
900
+ instance.args, ctx, self.api
901
+ ):
902
+ return AnyType(TypeOfAny.from_error)
903
+
904
+ # Check type argument count.
905
+ old_args = instance.args
906
+ instance.args = tuple(flatten_nested_tuples(instance.args))
907
+ if old_args and not instance.args:
908
+ empty_tuple_index = True
909
+ if not (self.defining_alias and self.nesting_level == 0) and not validate_instance(
910
+ instance, self.fail, empty_tuple_index
911
+ ):
912
+ used_default = fix_instance(
913
+ instance,
914
+ self.fail,
915
+ self.note,
916
+ disallow_any=self.options.disallow_any_generics and not self.is_typeshed_stub,
917
+ options=self.options,
918
+ analyzing_tvar_def=self.analyzing_tvar_def,
919
+ )
920
+ if self.analyzing_tvar_def and used_default:
921
+ self.api.record_fixed_type(info)
922
+
923
+ tup = info.tuple_type
924
+ if tup is not None:
925
+ # The class has a Tuple[...] base class so it will be
926
+ # represented as a tuple type.
927
+ if info.special_alias:
928
+ res, used_default = instantiate_type_alias(
929
+ info.special_alias,
930
+ self.anal_array(
931
+ args,
932
+ allow_unpack=True,
933
+ allow_param_spec=True,
934
+ allow_param_spec_literals=True,
935
+ ),
936
+ self.fail,
937
+ self.note,
938
+ False,
939
+ ctx,
940
+ self.options,
941
+ use_standard_error=True,
942
+ empty_tuple_index=empty_tuple_index,
943
+ analyzing_tvar_def=self.analyzing_tvar_def,
944
+ )
945
+ if self.analyzing_tvar_def and used_default:
946
+ # For convenience, we make default depend on the original TypeInfo,
947
+ # *not* on the special alias.
948
+ self.api.record_fixed_type(info)
949
+ return res
950
+ return tup.copy_modified(
951
+ items=self.anal_array(tup.items, allow_unpack=True), fallback=instance
952
+ )
953
+ td = info.typeddict_type
954
+ if td is not None:
955
+ # The class has a TypedDict[...] base class so it will be
956
+ # represented as a typeddict type.
957
+ if info.special_alias:
958
+ res, used_default = instantiate_type_alias(
959
+ info.special_alias,
960
+ self.anal_array(
961
+ args,
962
+ allow_unpack=True,
963
+ allow_param_spec=True,
964
+ allow_param_spec_literals=True,
965
+ ),
966
+ self.fail,
967
+ self.note,
968
+ False,
969
+ ctx,
970
+ self.options,
971
+ use_standard_error=True,
972
+ analyzing_tvar_def=self.analyzing_tvar_def,
973
+ )
974
+ if self.analyzing_tvar_def and used_default:
975
+ # For convenience, we make default depend on the original TypeInfo,
976
+ # *not* on the special alias.
977
+ self.api.record_fixed_type(info)
978
+ return res
979
+ # Create a named TypedDictType
980
+ return td.copy_modified(
981
+ item_types=self.anal_array(list(td.items.values())), fallback=instance
982
+ )
983
+
984
+ if info.fullname == "types.NoneType":
985
+ self.fail(
986
+ "NoneType should not be used as a type, please use None instead",
987
+ ctx,
988
+ code=codes.NONETYPE_TYPE,
989
+ )
990
+ return NoneType(ctx.line, ctx.column)
991
+
992
+ return instance
993
+
994
+ def analyze_unbound_type_without_type_info(
995
+ self, t: UnboundType, sym: SymbolTableNode, defining_literal: bool
996
+ ) -> Type:
997
+ """Figure out what an unbound type that doesn't refer to a TypeInfo node means.
998
+
999
+ This is something unusual. We try our best to find out what it is.
1000
+ """
1001
+ name = sym.fullname
1002
+ if name is None:
1003
+ assert sym.node is not None
1004
+ name = sym.node.name
1005
+ # Option 1:
1006
+ # Something with an Any type -- make it an alias for Any in a type
1007
+ # context. This is slightly problematic as it allows using the type 'Any'
1008
+ # as a base class -- however, this will fail soon at runtime so the problem
1009
+ # is pretty minor.
1010
+ if isinstance(sym.node, Var):
1011
+ typ = get_proper_type(sym.node.type)
1012
+ if isinstance(typ, AnyType):
1013
+ return AnyType(
1014
+ TypeOfAny.from_unimported_type, missing_import_name=typ.missing_import_name
1015
+ )
1016
+ elif self.allow_type_any:
1017
+ if isinstance(typ, Instance) and typ.type.fullname == "builtins.type":
1018
+ return AnyType(TypeOfAny.special_form)
1019
+ if isinstance(typ, TypeType) and isinstance(typ.item, AnyType):
1020
+ return AnyType(TypeOfAny.from_another_any, source_any=typ.item)
1021
+ # Option 2:
1022
+ # Unbound type variable. Currently these may be still valid,
1023
+ # for example when defining a generic type alias.
1024
+ unbound_tvar = (
1025
+ isinstance(sym.node, (TypeVarExpr, TypeVarTupleExpr))
1026
+ and self.tvar_scope.get_binding(sym) is None
1027
+ )
1028
+ if self.allow_unbound_tvars and unbound_tvar:
1029
+ return t
1030
+
1031
+ # Option 3:
1032
+ # Enum value. Note: we only want to return a LiteralType when
1033
+ # we're using this enum value specifically within context of
1034
+ # a "Literal[...]" type. So, if `defining_literal` is not set,
1035
+ # we bail out early with an error.
1036
+ #
1037
+ # If, in the distant future, we decide to permit things like
1038
+ # `def foo(x: Color.RED) -> None: ...`, we can remove that
1039
+ # check entirely.
1040
+ if (
1041
+ isinstance(sym.node, Var)
1042
+ and sym.node.info
1043
+ and sym.node.info.is_enum
1044
+ and sym.node.name in sym.node.info.enum_members
1045
+ ):
1046
+ value = sym.node.name
1047
+ base_enum_short_name = sym.node.info.name
1048
+ if not defining_literal:
1049
+ msg = message_registry.INVALID_TYPE_RAW_ENUM_VALUE.format(
1050
+ base_enum_short_name, value
1051
+ )
1052
+ self.fail(msg.value, t, code=msg.code)
1053
+ return AnyType(TypeOfAny.from_error)
1054
+ return LiteralType(
1055
+ value=value,
1056
+ fallback=Instance(sym.node.info, [], line=t.line, column=t.column),
1057
+ line=t.line,
1058
+ column=t.column,
1059
+ )
1060
+
1061
+ if isinstance(sym.node, Var) and sym.node.is_sentinel:
1062
+ typ = get_proper_type(sym.node.type)
1063
+ assert isinstance(typ, LiteralType)
1064
+ return LiteralType(
1065
+ value=typ.value, fallback=typ.fallback, line=t.line, column=t.column
1066
+ )
1067
+
1068
+ # None of the above options worked. We parse the args (if there are any)
1069
+ # to make sure there are no remaining semanal-only types, then give up.
1070
+ t = t.copy_modified(args=self.anal_array(t.args))
1071
+ # TODO: Move this message building logic to messages.py.
1072
+ notes: list[str] = []
1073
+ error_code = codes.VALID_TYPE
1074
+ if isinstance(sym.node, Var):
1075
+ notes.append(
1076
+ "See https://mypy.readthedocs.io/en/"
1077
+ "stable/common_issues.html#variables-vs-type-aliases"
1078
+ )
1079
+ message = 'Variable "{}" is not valid as a type'
1080
+ elif isinstance(sym.node, (SYMBOL_FUNCBASE_TYPES, Decorator)):
1081
+ message = 'Function "{}" is not valid as a type'
1082
+ if name == "builtins.any":
1083
+ notes.append('Perhaps you meant "typing.Any" instead of "any"?')
1084
+ elif name == "builtins.callable":
1085
+ notes.append('Perhaps you meant "typing.Callable" instead of "callable"?')
1086
+ else:
1087
+ notes.append('Perhaps you need "Callable[...]" or a callback protocol?')
1088
+ elif isinstance(sym.node, MypyFile):
1089
+ message = 'Module "{}" is not valid as a type'
1090
+ notes.append("Perhaps you meant to use a protocol matching the module structure?")
1091
+ elif unbound_tvar:
1092
+ assert isinstance(sym.node, TypeVarLikeExpr)
1093
+ if sym.node.is_new_style:
1094
+ # PEP 695 type parameters are never considered unbound -- they are undefined
1095
+ # in contexts where they aren't valid, such as in argument default values.
1096
+ message = 'Name "{}" is not defined'
1097
+ name = name.split(".")[-1]
1098
+ error_code = codes.NAME_DEFINED
1099
+ else:
1100
+ message = 'Type variable "{}" is unbound'
1101
+ short = name.split(".")[-1]
1102
+ notes.append(
1103
+ f'(Hint: Use "Generic[{short}]" or "Protocol[{short}]" base class'
1104
+ f' to bind "{short}" inside a class)'
1105
+ )
1106
+ notes.append(
1107
+ f'(Hint: Use "{short}" in function signature '
1108
+ f'to bind "{short}" inside a function)'
1109
+ )
1110
+ else:
1111
+ message = 'Cannot interpret reference "{}" as a type'
1112
+ if not defining_literal:
1113
+ # Literal check already gives a custom error. Avoid duplicating errors.
1114
+ self.fail(message.format(name), t, code=error_code)
1115
+ for note in notes:
1116
+ self.note(note, t, code=error_code)
1117
+
1118
+ # TODO: Would it be better to always return Any instead of UnboundType
1119
+ # in case of an error? On one hand, UnboundType has a name so error messages
1120
+ # are more detailed, on the other hand, some of them may be bogus,
1121
+ # see https://github.com/python/mypy/issues/4987.
1122
+ return t
1123
+
1124
+ def visit_any(self, t: AnyType) -> Type:
1125
+ return t
1126
+
1127
+ def visit_none_type(self, t: NoneType) -> Type:
1128
+ return t
1129
+
1130
+ def visit_uninhabited_type(self, t: UninhabitedType) -> Type:
1131
+ return t
1132
+
1133
+ def visit_erased_type(self, t: ErasedType) -> Type:
1134
+ # This type should exist only temporarily during type inference
1135
+ assert False, "Internal error: Unexpected erased type"
1136
+
1137
+ def visit_deleted_type(self, t: DeletedType) -> Type:
1138
+ return t
1139
+
1140
+ def visit_type_list(self, t: TypeList) -> Type:
1141
+ # Parameters literal (Z[[int, str, Whatever]])
1142
+ if self.allow_param_spec_literals:
1143
+ params = self.analyze_callable_args(t)
1144
+ if params:
1145
+ ts, kinds, names = params
1146
+ # bind these types
1147
+ return Parameters(self.anal_array(ts), kinds, names, line=t.line, column=t.column)
1148
+ else:
1149
+ return AnyType(TypeOfAny.from_error)
1150
+ else:
1151
+ self.fail(
1152
+ 'Bracketed expression "[...]" is not valid as a type', t, code=codes.VALID_TYPE
1153
+ )
1154
+ if len(t.items) == 1:
1155
+ self.note('Did you mean "List[...]"?', t)
1156
+ return AnyType(TypeOfAny.from_error)
1157
+
1158
+ def visit_callable_argument(self, t: CallableArgument) -> Type:
1159
+ self.fail("Invalid type", t, code=codes.VALID_TYPE)
1160
+ return AnyType(TypeOfAny.from_error)
1161
+
1162
+ def visit_instance(self, t: Instance) -> Type:
1163
+ return t
1164
+
1165
+ def visit_type_alias_type(self, t: TypeAliasType) -> Type:
1166
+ # TODO: should we do something here?
1167
+ return t
1168
+
1169
+ def visit_type_var(self, t: TypeVarType) -> Type:
1170
+ return t
1171
+
1172
+ def visit_param_spec(self, t: ParamSpecType) -> Type:
1173
+ return t
1174
+
1175
+ def visit_type_var_tuple(self, t: TypeVarTupleType) -> Type:
1176
+ return t
1177
+
1178
+ def visit_unpack_type(self, t: UnpackType) -> Type:
1179
+ if not self.allow_unpack:
1180
+ self.fail(message_registry.INVALID_UNPACK_POSITION, t.type, code=codes.VALID_TYPE)
1181
+ return AnyType(TypeOfAny.from_error)
1182
+ self.allow_type_var_tuple = self.nesting_level + 1
1183
+ result = UnpackType(self.anal_type(t.type), from_star_syntax=t.from_star_syntax)
1184
+ self.allow_type_var_tuple = -1
1185
+ return result
1186
+
1187
+ def visit_parameters(self, t: Parameters) -> Type:
1188
+ raise NotImplementedError("ParamSpec literals cannot have unbound TypeVars")
1189
+
1190
+ def visit_callable_type(
1191
+ self, t: CallableType, nested: bool = True, namespace: str = ""
1192
+ ) -> Type:
1193
+ # Every Callable can bind its own type variables, if they're not in the outer scope
1194
+ # TODO: attach namespace for nested free type variables (these appear in return type only).
1195
+ with self.tvar_scope_frame(namespace=namespace):
1196
+ unpacked_kwargs = t.unpack_kwargs
1197
+ if self.defining_alias:
1198
+ variables = t.variables
1199
+ else:
1200
+ variables, _ = self.bind_function_type_variables(t, t)
1201
+ type_guard = self.anal_type_guard(t.ret_type) if t.type_guard is None else t.type_guard
1202
+ type_is = self.anal_type_is(t.ret_type) if t.type_is is None else t.type_is
1203
+
1204
+ arg_kinds = t.arg_kinds
1205
+ arg_types = []
1206
+ param_spec_with_args = param_spec_with_kwargs = None
1207
+ param_spec_invalid = False
1208
+ for kind, ut in zip(arg_kinds, t.arg_types):
1209
+ if kind == ARG_STAR:
1210
+ param_spec_with_args, at = self.anal_star_arg_type(ut, kind, nested=nested)
1211
+ elif kind == ARG_STAR2:
1212
+ param_spec_with_kwargs, at = self.anal_star_arg_type(ut, kind, nested=nested)
1213
+ else:
1214
+ if param_spec_with_args:
1215
+ param_spec_invalid = True
1216
+ self.fail(
1217
+ "Arguments not allowed after ParamSpec.args", t, code=codes.VALID_TYPE
1218
+ )
1219
+ at = self.anal_type(ut, nested=nested, allow_unpack=False)
1220
+ if isinstance(at, Parameters):
1221
+ # A Parameters here comes from a misplaced Concatenate ending in
1222
+ # an explicit ellipsis, e.g. Callable[[Concatenate[int, ...]], None].
1223
+ self.fail(
1224
+ "Concatenate is only valid as the first argument to Callable",
1225
+ ut,
1226
+ code=codes.VALID_TYPE,
1227
+ )
1228
+ at = AnyType(TypeOfAny.from_error)
1229
+ arg_types.append(at)
1230
+
1231
+ if nested and arg_types:
1232
+ # If we've got a Callable[[Unpack[SomeTypedDict]], None], make sure
1233
+ # Unpack is interpreted as `**` and not as `*`.
1234
+ last = arg_types[-1]
1235
+ if isinstance(last, UnpackType):
1236
+ # TODO: it would be better to avoid this get_proper_type() call.
1237
+ p_at = get_proper_type(last.type)
1238
+ if isinstance(p_at, TypedDictType) and not last.from_star_syntax:
1239
+ # Automatically detect Unpack[Foo] in Callable as backwards
1240
+ # compatible syntax for **Foo, if Foo is a TypedDict.
1241
+ arg_kinds[-1] = ARG_STAR2
1242
+ arg_types[-1] = p_at
1243
+ unpacked_kwargs = True
1244
+ arg_types = self.check_unpacks_in_list(arg_types)
1245
+
1246
+ if not param_spec_invalid and param_spec_with_args != param_spec_with_kwargs:
1247
+ # If already invalid, do not report more errors - definition has
1248
+ # to be fixed anyway
1249
+ name = param_spec_with_args or param_spec_with_kwargs
1250
+ self.fail(
1251
+ f'ParamSpec must have "*args" typed as "{name}.args" and "**kwargs" typed as "{name}.kwargs"',
1252
+ t,
1253
+ code=codes.VALID_TYPE,
1254
+ )
1255
+ param_spec_invalid = True
1256
+
1257
+ if param_spec_invalid:
1258
+ if ARG_STAR in arg_kinds:
1259
+ arg_types[arg_kinds.index(ARG_STAR)] = AnyType(TypeOfAny.from_error)
1260
+ if ARG_STAR2 in arg_kinds:
1261
+ arg_types[arg_kinds.index(ARG_STAR2)] = AnyType(TypeOfAny.from_error)
1262
+
1263
+ # If there were multiple (invalid) unpacks, the arg types list will become shorter,
1264
+ # we need to trim the kinds/names as well to avoid crashes.
1265
+ arg_kinds = t.arg_kinds[: len(arg_types)]
1266
+ arg_names = t.arg_names[: len(arg_types)]
1267
+
1268
+ ret = t.copy_modified(
1269
+ arg_types=arg_types,
1270
+ arg_kinds=arg_kinds,
1271
+ arg_names=arg_names,
1272
+ ret_type=self.anal_type(t.ret_type, nested=nested),
1273
+ # If the fallback isn't filled in yet,
1274
+ # its type will be the falsey FakeInfo
1275
+ fallback=(t.fallback if t.fallback.type else self.named_type("builtins.function")),
1276
+ variables=self.anal_var_defs(variables),
1277
+ type_guard=type_guard,
1278
+ type_is=type_is,
1279
+ unpack_kwargs=unpacked_kwargs,
1280
+ )
1281
+ return ret
1282
+
1283
+ def anal_type_guard(self, t: Type) -> Type | None:
1284
+ if isinstance(t, UnboundType):
1285
+ sym = self.lookup_qualified(t.name, t)
1286
+ if sym is not None and sym.node is not None:
1287
+ return self.anal_type_guard_arg(t, sym.node.fullname)
1288
+ # TODO: What if it's an Instance? Then use t.type.fullname?
1289
+ return None
1290
+
1291
+ def anal_type_guard_arg(self, t: UnboundType, fullname: str) -> Type | None:
1292
+ if fullname in ("typing_extensions.TypeGuard", "typing.TypeGuard"):
1293
+ if len(t.args) != 1:
1294
+ self.fail(
1295
+ "TypeGuard must have exactly one type argument", t, code=codes.VALID_TYPE
1296
+ )
1297
+ return AnyType(TypeOfAny.from_error)
1298
+ return self.anal_type(t.args[0])
1299
+ return None
1300
+
1301
+ def anal_type_is(self, t: Type) -> Type | None:
1302
+ if isinstance(t, UnboundType):
1303
+ sym = self.lookup_qualified(t.name, t)
1304
+ if sym is not None and sym.node is not None:
1305
+ return self.anal_type_is_arg(t, sym.node.fullname)
1306
+ # TODO: What if it's an Instance? Then use t.type.fullname?
1307
+ return None
1308
+
1309
+ def anal_type_is_arg(self, t: UnboundType, fullname: str) -> Type | None:
1310
+ if fullname in ("typing_extensions.TypeIs", "typing.TypeIs"):
1311
+ if len(t.args) != 1:
1312
+ self.fail("TypeIs must have exactly one type argument", t, code=codes.VALID_TYPE)
1313
+ return AnyType(TypeOfAny.from_error)
1314
+ return self.anal_type(t.args[0])
1315
+ return None
1316
+
1317
+ def anal_star_arg_type(self, t: Type, kind: ArgKind, nested: bool) -> tuple[str | None, Type]:
1318
+ """Analyze signature argument type for *args and **kwargs argument."""
1319
+ if isinstance(t, UnboundType) and t.name and "." in t.name and not t.args:
1320
+ components = t.name.split(".")
1321
+ tvar_name = ".".join(components[:-1])
1322
+ sym = self.lookup_qualified(tvar_name, t)
1323
+ if sym is not None and isinstance(sym.node, ParamSpecExpr):
1324
+ tvar_def = self.tvar_scope.get_binding(sym)
1325
+ if isinstance(tvar_def, ParamSpecType):
1326
+ if kind == ARG_STAR:
1327
+ make_paramspec = paramspec_args
1328
+ if components[-1] != "args":
1329
+ self.fail(
1330
+ f'Use "{tvar_name}.args" for variadic "*" parameter',
1331
+ t,
1332
+ code=codes.VALID_TYPE,
1333
+ )
1334
+ elif kind == ARG_STAR2:
1335
+ make_paramspec = paramspec_kwargs
1336
+ if components[-1] != "kwargs":
1337
+ self.fail(
1338
+ f'Use "{tvar_name}.kwargs" for variadic "**" parameter',
1339
+ t,
1340
+ code=codes.VALID_TYPE,
1341
+ )
1342
+ else:
1343
+ assert False, kind
1344
+ return tvar_name, make_paramspec(
1345
+ tvar_def.name,
1346
+ tvar_def.fullname,
1347
+ tvar_def.id,
1348
+ named_type_func=self.named_type,
1349
+ line=t.line,
1350
+ column=t.column,
1351
+ )
1352
+ return None, self.anal_type(t, nested=nested, allow_unpack=True)
1353
+
1354
+ def visit_overloaded(self, t: Overloaded) -> Type:
1355
+ # Overloaded types are manually constructed in semanal.py by analyzing the
1356
+ # AST and combining together the Callable types this visitor converts.
1357
+ #
1358
+ # So if we're ever asked to reanalyze an Overloaded type, we know it's
1359
+ # fine to just return it as-is.
1360
+ return t
1361
+
1362
+ def visit_tuple_type(self, t: TupleType) -> Type:
1363
+ # Types such as (t1, t2, ...) only allowed in assignment statements. They'll
1364
+ # generate errors elsewhere, and Tuple[t1, t2, ...] must be used instead.
1365
+ if t.implicit and not self.allow_tuple_literal:
1366
+ self.fail("Syntax error in type annotation", t, code=codes.SYNTAX)
1367
+ if len(t.items) == 0:
1368
+ self.note(
1369
+ "Suggestion: Use Tuple[()] instead of () for an empty tuple, or "
1370
+ "None for a function without a return value",
1371
+ t,
1372
+ code=codes.SYNTAX,
1373
+ )
1374
+ elif len(t.items) == 1:
1375
+ self.note("Suggestion: Is there a spurious trailing comma?", t, code=codes.SYNTAX)
1376
+ else:
1377
+ self.note(
1378
+ "Suggestion: Use Tuple[T1, ..., Tn] instead of (T1, ..., Tn)",
1379
+ t,
1380
+ code=codes.SYNTAX,
1381
+ )
1382
+ return AnyType(TypeOfAny.from_error)
1383
+
1384
+ any_type = AnyType(TypeOfAny.special_form)
1385
+ # If the fallback isn't filled in yet, its type will be the falsey FakeInfo
1386
+ fallback = (
1387
+ t.partial_fallback
1388
+ if t.partial_fallback.type
1389
+ else self.named_type("builtins.tuple", [any_type])
1390
+ )
1391
+ return TupleType(self.anal_array(t.items, allow_unpack=True), fallback, t.line)
1392
+
1393
+ def visit_typeddict_type(self, t: TypedDictType) -> Type:
1394
+ req_keys = set()
1395
+ readonly_keys = set()
1396
+ items = {}
1397
+ for item_name, item_type in t.items.items():
1398
+ # TODO: rework
1399
+ analyzed = self.anal_type(item_type, allow_typed_dict_special_forms=True)
1400
+ if isinstance(analyzed, RequiredType):
1401
+ if analyzed.required:
1402
+ req_keys.add(item_name)
1403
+ analyzed = analyzed.item
1404
+ else:
1405
+ # Keys are required by default.
1406
+ req_keys.add(item_name)
1407
+ if isinstance(analyzed, ReadOnlyType):
1408
+ readonly_keys.add(item_name)
1409
+ analyzed = analyzed.item
1410
+ items[item_name] = analyzed
1411
+ if t.fallback.type is MISSING_FALLBACK: # anonymous/inline TypedDict
1412
+ if INLINE_TYPEDDICT not in self.options.enable_incomplete_feature:
1413
+ self.fail(
1414
+ "Inline TypedDict is experimental,"
1415
+ " must be enabled with --enable-incomplete-feature=InlineTypedDict",
1416
+ t,
1417
+ )
1418
+ is_closed = False
1419
+ required_keys = req_keys
1420
+ fallback = self.named_type("typing._TypedDict")
1421
+ for typ in t.extra_items_from:
1422
+ analyzed = self.analyze_type(typ)
1423
+ p_analyzed = get_proper_type(analyzed)
1424
+ if not isinstance(p_analyzed, TypedDictType):
1425
+ if not isinstance(p_analyzed, (AnyType, PlaceholderType)):
1426
+ self.fail("Can only merge-in other TypedDict", t, code=codes.VALID_TYPE)
1427
+ continue
1428
+ for sub_item_name, sub_item_type in p_analyzed.items.items():
1429
+ if sub_item_name in items:
1430
+ self.fail(TYPEDDICT_OVERRIDE_MERGE.format(sub_item_name), t)
1431
+ continue
1432
+ items[sub_item_name] = sub_item_type
1433
+ if sub_item_name in p_analyzed.required_keys:
1434
+ req_keys.add(sub_item_name)
1435
+ if sub_item_name in p_analyzed.readonly_keys:
1436
+ readonly_keys.add(sub_item_name)
1437
+ else:
1438
+ readonly_keys = t.readonly_keys
1439
+ required_keys = t.required_keys
1440
+ fallback = t.fallback
1441
+ is_closed = t.is_closed
1442
+ return TypedDictType(
1443
+ items, required_keys, readonly_keys, fallback, t.line, t.column, is_closed=is_closed
1444
+ )
1445
+
1446
+ def visit_raw_expression_type(self, t: RawExpressionType) -> Type:
1447
+ # We should never see a bare Literal. We synthesize these raw literals
1448
+ # in the earlier stages of semantic analysis, but those
1449
+ # "fake literals" should always be wrapped in an UnboundType
1450
+ # corresponding to 'Literal'.
1451
+ #
1452
+ # Note: if at some point in the distant future, we decide to
1453
+ # make signatures like "foo(x: 20) -> None" legal, we can change
1454
+ # this method so it generates and returns an actual LiteralType
1455
+ # instead.
1456
+
1457
+ if self.report_invalid_types:
1458
+ if t.base_type_name in ("builtins.int", "builtins.bool"):
1459
+ # The only time it makes sense to use an int or bool is inside of
1460
+ # a literal type.
1461
+ msg = f"Invalid type: try using Literal[{repr(t.literal_value)}] instead?"
1462
+ elif t.base_type_name in ("builtins.float", "builtins.complex"):
1463
+ # We special-case warnings for floats and complex numbers.
1464
+ msg = f"Invalid type: {t.simple_name()} literals cannot be used as a type"
1465
+ else:
1466
+ # And in all other cases, we default to a generic error message.
1467
+ # Note: the reason why we use a generic error message for strings
1468
+ # but not ints or bools is because whenever we see an out-of-place
1469
+ # string, it's unclear if the user meant to construct a literal type
1470
+ # or just misspelled a regular type. So we avoid guessing.
1471
+ msg = "Invalid type comment or annotation"
1472
+
1473
+ self.fail(msg, t, code=codes.VALID_TYPE)
1474
+ if t.note is not None:
1475
+ self.note(t.note, t, code=codes.VALID_TYPE)
1476
+
1477
+ return AnyType(TypeOfAny.from_error, line=t.line, column=t.column)
1478
+
1479
+ def visit_literal_type(self, t: LiteralType) -> Type:
1480
+ return t
1481
+
1482
+ def visit_union_type(self, t: UnionType) -> Type:
1483
+ return UnionType(self.anal_array(t.items), t.line, uses_pep604_syntax=t.uses_pep604_syntax)
1484
+
1485
+ def visit_partial_type(self, t: PartialType) -> Type:
1486
+ assert False, "Internal error: Unexpected partial type"
1487
+
1488
+ def visit_ellipsis_type(self, t: EllipsisType) -> Type:
1489
+ if self.allow_ellipsis or self.allow_param_spec_literals:
1490
+ any_type = AnyType(TypeOfAny.explicit)
1491
+ return Parameters(
1492
+ [any_type, any_type], [ARG_STAR, ARG_STAR2], [None, None], is_ellipsis_args=True
1493
+ )
1494
+ else:
1495
+ self.fail('Unexpected "..."', t)
1496
+ return AnyType(TypeOfAny.from_error)
1497
+
1498
+ def visit_type_type(self, t: TypeType) -> Type:
1499
+ return TypeType.make_normalized(
1500
+ self.anal_type(t.item), line=t.line, is_type_form=t.is_type_form
1501
+ )
1502
+
1503
+ def visit_placeholder_type(self, t: PlaceholderType) -> Type:
1504
+ n = (
1505
+ None
1506
+ # No dot in fullname indicates we are at function scope, and recursive
1507
+ # types are not supported there anyway, so we just give up.
1508
+ if not t.fullname or "." not in t.fullname
1509
+ else self.api.lookup_fully_qualified(t.fullname)
1510
+ )
1511
+ if not n or isinstance(n.node, PlaceholderNode):
1512
+ self.api.defer() # Still incomplete
1513
+ return t
1514
+ else:
1515
+ # TODO: Handle non-TypeInfo
1516
+ assert isinstance(n.node, TypeInfo)
1517
+ return self.analyze_type_with_type_info(n.node, t.args, t, False)
1518
+
1519
+ def analyze_callable_args_for_paramspec(
1520
+ self, callable_args: Type, ret_type: Type, fallback: Instance
1521
+ ) -> CallableType | None:
1522
+ """Construct a 'Callable[P, RET]', where P is ParamSpec, return None if we cannot."""
1523
+ if not isinstance(callable_args, UnboundType):
1524
+ return None
1525
+ sym = self.lookup_qualified(callable_args.name, callable_args)
1526
+ if sym is None:
1527
+ return None
1528
+ tvar_def = self.tvar_scope.get_binding(sym)
1529
+ if not isinstance(tvar_def, ParamSpecType):
1530
+ if (
1531
+ tvar_def is None
1532
+ and self.allow_unbound_tvars
1533
+ and isinstance(sym.node, ParamSpecExpr)
1534
+ ):
1535
+ # We are analyzing this type in runtime context (e.g. as type application).
1536
+ # If it is not valid as a type in this position an error will be given later.
1537
+ return callable_with_ellipsis(
1538
+ AnyType(TypeOfAny.explicit), ret_type=ret_type, fallback=fallback
1539
+ )
1540
+ return None
1541
+ elif (
1542
+ self.defining_alias
1543
+ and self.not_declared_in_type_params(tvar_def.name)
1544
+ and tvar_def not in self.allowed_alias_tvars
1545
+ ):
1546
+ if self.python_3_12_type_alias:
1547
+ msg = message_registry.TYPE_PARAMETERS_SHOULD_BE_DECLARED.format(
1548
+ f'"{tvar_def.name}"'
1549
+ )
1550
+ else:
1551
+ msg = f'ParamSpec "{tvar_def.name}" is not included in type_params'
1552
+ self.fail(msg, callable_args, code=codes.VALID_TYPE)
1553
+ return callable_with_ellipsis(
1554
+ AnyType(TypeOfAny.special_form), ret_type=ret_type, fallback=fallback
1555
+ )
1556
+
1557
+ return CallableType(
1558
+ [
1559
+ paramspec_args(
1560
+ tvar_def.name, tvar_def.fullname, tvar_def.id, named_type_func=self.named_type
1561
+ ),
1562
+ paramspec_kwargs(
1563
+ tvar_def.name, tvar_def.fullname, tvar_def.id, named_type_func=self.named_type
1564
+ ),
1565
+ ],
1566
+ [nodes.ARG_STAR, nodes.ARG_STAR2],
1567
+ [None, None],
1568
+ ret_type=ret_type,
1569
+ fallback=fallback,
1570
+ )
1571
+
1572
+ def analyze_callable_args_for_concatenate(
1573
+ self, callable_args: Type, ret_type: Type, fallback: Instance
1574
+ ) -> CallableType | AnyType | None:
1575
+ """Construct a 'Callable[C, RET]', where C is Concatenate[..., P], returning None if we
1576
+ cannot.
1577
+ """
1578
+ if not isinstance(callable_args, UnboundType):
1579
+ return None
1580
+ sym = self.lookup_qualified(callable_args.name, callable_args)
1581
+ if sym is None:
1582
+ return None
1583
+ if sym.node is None:
1584
+ return None
1585
+ if sym.node.fullname not in CONCATENATE_TYPE_NAMES:
1586
+ return None
1587
+
1588
+ tvar_def = self.anal_type(callable_args, allow_param_spec=True)
1589
+ if not isinstance(tvar_def, (ParamSpecType, Parameters)):
1590
+ if self.allow_unbound_tvars and isinstance(tvar_def, UnboundType):
1591
+ sym = self.lookup_qualified(tvar_def.name, callable_args)
1592
+ if sym is not None and isinstance(sym.node, ParamSpecExpr):
1593
+ # We are analyzing this type in runtime context (e.g. as type application).
1594
+ # If it is not valid as a type in this position an error will be given later.
1595
+ return callable_with_ellipsis(
1596
+ AnyType(TypeOfAny.explicit), ret_type=ret_type, fallback=fallback
1597
+ )
1598
+ # Error was already given, so prevent further errors.
1599
+ return AnyType(TypeOfAny.from_error)
1600
+ if isinstance(tvar_def, Parameters):
1601
+ # This comes from Concatenate[int, ...]
1602
+ return CallableType(
1603
+ arg_types=tvar_def.arg_types,
1604
+ arg_names=tvar_def.arg_names,
1605
+ arg_kinds=tvar_def.arg_kinds,
1606
+ ret_type=ret_type,
1607
+ fallback=fallback,
1608
+ from_concatenate=True,
1609
+ )
1610
+
1611
+ # ick, CallableType should take ParamSpecType
1612
+ prefix = tvar_def.prefix
1613
+ # we don't set the prefix here as generic arguments will get updated at some point
1614
+ # in the future. CallableType.param_spec() accounts for this.
1615
+ return CallableType(
1616
+ [
1617
+ *prefix.arg_types,
1618
+ paramspec_args(
1619
+ tvar_def.name, tvar_def.fullname, tvar_def.id, named_type_func=self.named_type
1620
+ ),
1621
+ paramspec_kwargs(
1622
+ tvar_def.name, tvar_def.fullname, tvar_def.id, named_type_func=self.named_type
1623
+ ),
1624
+ ],
1625
+ [*prefix.arg_kinds, nodes.ARG_STAR, nodes.ARG_STAR2],
1626
+ [*prefix.arg_names, None, None],
1627
+ ret_type=ret_type,
1628
+ fallback=fallback,
1629
+ from_concatenate=True,
1630
+ )
1631
+
1632
+ def analyze_callable_type(self, t: UnboundType) -> Type:
1633
+ fallback = self.named_type("builtins.function")
1634
+ if len(t.args) == 0:
1635
+ # Callable (bare). Treat as Callable[..., Any].
1636
+ any_type = self.get_omitted_any(t)
1637
+ ret = callable_with_ellipsis(any_type, any_type, fallback)
1638
+ elif len(t.args) == 2:
1639
+ callable_args = t.args[0]
1640
+ ret_type = t.args[1]
1641
+ if isinstance(callable_args, TypeList):
1642
+ # Callable[[ARG, ...], RET] (ordinary callable type)
1643
+ analyzed_args = self.analyze_callable_args(callable_args)
1644
+ if analyzed_args is None:
1645
+ return AnyType(TypeOfAny.from_error)
1646
+ args, kinds, names = analyzed_args
1647
+ ret = CallableType(args, kinds, names, ret_type=ret_type, fallback=fallback)
1648
+ elif isinstance(callable_args, EllipsisType):
1649
+ # Callable[..., RET] (with literal ellipsis; accept arbitrary arguments)
1650
+ ret = callable_with_ellipsis(
1651
+ AnyType(TypeOfAny.explicit), ret_type=ret_type, fallback=fallback
1652
+ )
1653
+ else:
1654
+ # Callable[P, RET] (where P is ParamSpec)
1655
+ with self.tvar_scope_frame(namespace=""):
1656
+ # Temporarily bind ParamSpecs to allow code like this:
1657
+ # my_fun: Callable[Q, Foo[Q]]
1658
+ # We usually do this later in visit_callable_type(), but the analysis
1659
+ # below happens at very early stage.
1660
+ variables = []
1661
+ for name, tvar_expr in self.find_type_var_likes(callable_args):
1662
+ variables.append(
1663
+ self.tvar_scope.bind_new(name, tvar_expr, self.fail_func, t)
1664
+ )
1665
+ maybe_ret = self.analyze_callable_args_for_paramspec(
1666
+ callable_args, ret_type, fallback
1667
+ ) or self.analyze_callable_args_for_concatenate(
1668
+ callable_args, ret_type, fallback
1669
+ )
1670
+ if isinstance(maybe_ret, CallableType):
1671
+ maybe_ret = maybe_ret.copy_modified(variables=variables)
1672
+ if maybe_ret is None:
1673
+ # Callable[?, RET] (where ? is something invalid)
1674
+ self.fail(
1675
+ "The first argument to Callable must be a "
1676
+ 'list of types, parameter specification, or "..."',
1677
+ t,
1678
+ code=codes.VALID_TYPE,
1679
+ )
1680
+ self.note(
1681
+ "See https://mypy.readthedocs.io/en/stable/kinds_of_types.html#callable-types-and-lambdas",
1682
+ t,
1683
+ )
1684
+ return AnyType(TypeOfAny.from_error)
1685
+ elif isinstance(maybe_ret, AnyType):
1686
+ return maybe_ret
1687
+ ret = maybe_ret
1688
+ else:
1689
+ if self.options.disallow_any_generics:
1690
+ self.fail('Please use "Callable[[<parameters>], <return type>]"', t)
1691
+ else:
1692
+ self.fail('Please use "Callable[[<parameters>], <return type>]" or "Callable"', t)
1693
+ return AnyType(TypeOfAny.from_error)
1694
+ assert isinstance(ret, CallableType)
1695
+ return ret.accept(self)
1696
+
1697
+ def refers_to_full_names(self, arg: UnboundType, names: Sequence[str]) -> bool:
1698
+ sym = self.lookup_qualified(arg.name, arg)
1699
+ if sym is not None:
1700
+ if sym.fullname in names:
1701
+ return True
1702
+ return False
1703
+
1704
+ def analyze_callable_args(
1705
+ self, arglist: TypeList
1706
+ ) -> tuple[list[Type], list[ArgKind], list[str | None]] | None:
1707
+ args: list[Type] = []
1708
+ kinds: list[ArgKind] = []
1709
+ names: list[str | None] = []
1710
+ seen_unpack = False
1711
+ unpack_types: list[Type] = []
1712
+ invalid_unpacks: list[Type] = []
1713
+ second_unpack_last = False
1714
+ for i, arg in enumerate(arglist.items):
1715
+ if isinstance(arg, CallableArgument):
1716
+ args.append(arg.typ)
1717
+ names.append(arg.name)
1718
+ if arg.constructor is None:
1719
+ return None
1720
+ found = self.lookup_qualified(arg.constructor, arg)
1721
+ if found is None:
1722
+ # Looking it up already put an error message in
1723
+ return None
1724
+ elif found.fullname not in ARG_KINDS_BY_CONSTRUCTOR:
1725
+ self.fail(f'Invalid argument constructor "{found.fullname}"', arg)
1726
+ return None
1727
+ else:
1728
+ assert found.fullname is not None
1729
+ kind = ARG_KINDS_BY_CONSTRUCTOR[found.fullname]
1730
+ kinds.append(kind)
1731
+ if arg.name is not None and kind.is_star():
1732
+ self.fail(f"{arg.constructor} arguments should not have names", arg)
1733
+ return None
1734
+ elif (
1735
+ isinstance(arg, UnboundType)
1736
+ and self.refers_to_full_names(arg, UNPACK_TYPE_NAMES)
1737
+ or isinstance(arg, UnpackType)
1738
+ ):
1739
+ if seen_unpack:
1740
+ # Multiple unpacks, preserve them, so we can give an error later.
1741
+ if i == len(arglist.items) - 1 and not invalid_unpacks:
1742
+ # Special case: if there are just two unpacks, and the second one appears
1743
+ # as last type argument, it can be still valid, if the second unpacked type
1744
+ # is a TypedDict. This should be checked by the caller.
1745
+ second_unpack_last = True
1746
+ invalid_unpacks.append(arg)
1747
+ continue
1748
+ seen_unpack = True
1749
+ unpack_types.append(arg)
1750
+ else:
1751
+ if seen_unpack:
1752
+ unpack_types.append(arg)
1753
+ else:
1754
+ args.append(arg)
1755
+ kinds.append(ARG_POS)
1756
+ names.append(None)
1757
+ if seen_unpack:
1758
+ if len(unpack_types) == 1:
1759
+ args.append(unpack_types[0])
1760
+ else:
1761
+ first = unpack_types[0]
1762
+ if isinstance(first, UnpackType):
1763
+ # UnpackType doesn't have its own line/column numbers,
1764
+ # so use the unpacked type for error messages.
1765
+ first = first.type
1766
+ args.append(
1767
+ UnpackType(self.tuple_type(unpack_types, line=first.line, column=first.column))
1768
+ )
1769
+ kinds.append(ARG_STAR)
1770
+ names.append(None)
1771
+ for arg in invalid_unpacks:
1772
+ args.append(arg)
1773
+ kinds.append(ARG_STAR2 if second_unpack_last else ARG_STAR)
1774
+ names.append(None)
1775
+ # Note that arglist below is only used for error context.
1776
+ check_param_names(names, [arglist] * len(args), self.fail, "Callable")
1777
+ check_arg_kinds(kinds, [arglist] * len(args), self.fail)
1778
+ return args, kinds, names
1779
+
1780
+ def analyze_literal_type(self, t: UnboundType) -> Type:
1781
+ if len(t.args) == 0:
1782
+ self.fail("Literal[...] must have at least one parameter", t, code=codes.VALID_TYPE)
1783
+ return AnyType(TypeOfAny.from_error)
1784
+
1785
+ output: list[Type] = []
1786
+ for i, arg in enumerate(t.args):
1787
+ analyzed_types = self.analyze_literal_param(i + 1, arg, t)
1788
+ if analyzed_types is None:
1789
+ return AnyType(TypeOfAny.from_error)
1790
+ else:
1791
+ output.extend(analyzed_types)
1792
+ return UnionType.make_union(output, line=t.line)
1793
+
1794
+ def analyze_literal_param(self, idx: int, arg: Type, ctx: Context) -> list[Type] | None:
1795
+ # This UnboundType was originally defined as a string.
1796
+ if (
1797
+ isinstance(arg, ProperType)
1798
+ and isinstance(arg, (UnboundType, UnionType))
1799
+ and arg.original_str_expr is not None
1800
+ ):
1801
+ assert arg.original_str_fallback is not None
1802
+ return [
1803
+ LiteralType(
1804
+ value=arg.original_str_expr,
1805
+ fallback=self.named_type(arg.original_str_fallback),
1806
+ line=arg.line,
1807
+ column=arg.column,
1808
+ )
1809
+ ]
1810
+
1811
+ # If arg is an UnboundType that was *not* originally defined as
1812
+ # a string, try expanding it in case it's a type alias or something.
1813
+ if isinstance(arg, UnboundType):
1814
+ self.nesting_level += 1
1815
+ try:
1816
+ arg = self.visit_unbound_type(arg, defining_literal=True)
1817
+ finally:
1818
+ self.nesting_level -= 1
1819
+
1820
+ # Literal[...] cannot contain Any. Give up and add an error message
1821
+ # (if we haven't already).
1822
+ arg = get_proper_type(arg)
1823
+ if isinstance(arg, AnyType):
1824
+ # Note: We can encounter Literals containing 'Any' under three circumstances:
1825
+ #
1826
+ # 1. If the user attempts use an explicit Any as a parameter
1827
+ # 2. If the user is trying to use an enum value imported from a module with
1828
+ # no type hints, giving it an implicit type of 'Any'
1829
+ # 3. If there's some other underlying problem with the parameter.
1830
+ #
1831
+ # We report an error in only the first two cases. In the third case, we assume
1832
+ # some other region of the code has already reported a more relevant error.
1833
+ #
1834
+ # TODO: Once we start adding support for enums, make sure we report a custom
1835
+ # error for case 2 as well.
1836
+ if arg.type_of_any not in (TypeOfAny.from_error, TypeOfAny.special_form):
1837
+ self.fail(
1838
+ f'Parameter {idx} of Literal[...] cannot be of type "Any"',
1839
+ ctx,
1840
+ code=codes.VALID_TYPE,
1841
+ )
1842
+ return None
1843
+ elif isinstance(arg, RawExpressionType):
1844
+ # A raw literal. Convert it directly into a literal if we can.
1845
+ if arg.literal_value is None:
1846
+ name = arg.simple_name()
1847
+ if name in ("float", "complex"):
1848
+ msg = f'Parameter {idx} of Literal[...] cannot be of type "{name}"'
1849
+ else:
1850
+ msg = "Invalid type: Literal[...] cannot contain arbitrary expressions"
1851
+ self.fail(msg, ctx, code=codes.VALID_TYPE)
1852
+ # Note: we deliberately ignore arg.note here: the extra info might normally be
1853
+ # helpful, but it generally won't make sense in the context of a Literal[...].
1854
+ return None
1855
+
1856
+ # Remap bytes and unicode into the appropriate type for the correct Python version
1857
+ fallback = self.named_type(arg.base_type_name)
1858
+ assert isinstance(fallback, Instance)
1859
+ return [LiteralType(arg.literal_value, fallback, line=arg.line, column=arg.column)]
1860
+ elif isinstance(arg, (NoneType, LiteralType)):
1861
+ # Types that we can just add directly to the literal/potential union of literals.
1862
+ return [arg]
1863
+ elif isinstance(arg, Instance) and arg.last_known_value is not None:
1864
+ # Types generated from declarations like "var: Final = 4".
1865
+ return [arg.last_known_value]
1866
+ elif isinstance(arg, UnionType):
1867
+ out = []
1868
+ for union_arg in arg.items:
1869
+ union_result = self.analyze_literal_param(idx, union_arg, ctx)
1870
+ if union_result is None:
1871
+ return None
1872
+ out.extend(union_result)
1873
+ return out
1874
+ else:
1875
+ self.fail(f"Parameter {idx} of Literal[...] is invalid", ctx, code=codes.VALID_TYPE)
1876
+ return None
1877
+
1878
+ def analyze_type(self, typ: Type) -> Type:
1879
+ return typ.accept(self)
1880
+
1881
+ def fail(self, msg: str, ctx: Context, *, code: ErrorCode | None = None) -> None:
1882
+ self.fail_func(msg, ctx, code=code)
1883
+
1884
+ def note(self, msg: str, ctx: Context, *, code: ErrorCode | None = None) -> None:
1885
+ self.note_func(msg, ctx, code=code)
1886
+
1887
+ @contextmanager
1888
+ def tvar_scope_frame(self, namespace: str) -> Iterator[None]:
1889
+ old_scope = self.tvar_scope
1890
+ self.tvar_scope = self.tvar_scope.method_frame(namespace)
1891
+ yield
1892
+ self.tvar_scope = old_scope
1893
+
1894
+ def find_type_var_likes(self, t: Type) -> TypeVarLikeList:
1895
+ visitor = FindTypeVarVisitor(self.api, self.tvar_scope)
1896
+ t.accept(visitor)
1897
+ return visitor.type_var_likes
1898
+
1899
+ def infer_type_variables(
1900
+ self, type: CallableType
1901
+ ) -> tuple[list[tuple[str, TypeVarLikeExpr]], bool]:
1902
+ """Infer type variables from a callable.
1903
+
1904
+ Return tuple with these items:
1905
+ - list of unique type variables referred to in a callable
1906
+ - whether there is a reference to the Self type
1907
+ """
1908
+ visitor = FindTypeVarVisitor(self.api, self.tvar_scope)
1909
+ for arg in type.arg_types:
1910
+ arg.accept(visitor)
1911
+
1912
+ # When finding type variables in the return type of a function, don't
1913
+ # look inside Callable types. Type variables only appearing in
1914
+ # functions in the return type belong to those functions, not the
1915
+ # function we're currently analyzing.
1916
+ visitor.include_callables = False
1917
+ type.ret_type.accept(visitor)
1918
+
1919
+ return visitor.type_var_likes, visitor.has_self_type
1920
+
1921
+ def bind_function_type_variables(
1922
+ self, fun_type: CallableType, defn: Context
1923
+ ) -> tuple[tuple[TypeVarLikeType, ...], bool]:
1924
+ """Find the type variables of the function type and bind them in our tvar_scope"""
1925
+ has_self_type = False
1926
+ if fun_type.variables:
1927
+ defs = []
1928
+ for var in fun_type.variables:
1929
+ if self.api.type and self.api.type.self_type and var == self.api.type.self_type:
1930
+ has_self_type = True
1931
+ continue
1932
+ var_node = self.lookup_qualified(var.name, defn)
1933
+ assert var_node, "Binding for function type variable not found within function"
1934
+ var_expr = var_node.node
1935
+ assert isinstance(var_expr, TypeVarLikeExpr)
1936
+ binding = self.tvar_scope.bind_new(var.name, var_expr, self.fail_func, fun_type)
1937
+ defs.append(binding)
1938
+ return tuple(defs), has_self_type
1939
+ typevars, has_self_type = self.infer_type_variables(fun_type)
1940
+ # Do not define a new type variable if already defined in scope.
1941
+ typevars = [
1942
+ (name, tvar) for name, tvar in typevars if not self.is_defined_type_var(name, defn)
1943
+ ]
1944
+ defs = []
1945
+ for name, tvar in typevars:
1946
+ if not self.tvar_scope.allow_binding(tvar.fullname):
1947
+ err_msg = message_registry.TYPE_VAR_REDECLARED_IN_NESTED_CLASS.format(name)
1948
+ self.fail(err_msg.value, defn, code=err_msg.code)
1949
+ binding = self.tvar_scope.bind_new(name, tvar, self.fail_func, fun_type)
1950
+ defs.append(binding)
1951
+
1952
+ return tuple(defs), has_self_type
1953
+
1954
+ def is_defined_type_var(self, tvar: str, context: Context) -> bool:
1955
+ tvar_node = self.lookup_qualified(tvar, context)
1956
+ if not tvar_node:
1957
+ return False
1958
+ return self.tvar_scope.get_binding(tvar_node) is not None
1959
+
1960
+ def anal_array(
1961
+ self,
1962
+ a: Iterable[Type],
1963
+ nested: bool = True,
1964
+ *,
1965
+ allow_param_spec: bool = False,
1966
+ allow_param_spec_literals: bool = False,
1967
+ allow_unpack: bool = False,
1968
+ ) -> list[Type]:
1969
+ old_allow_param_spec_literals = self.allow_param_spec_literals
1970
+ self.allow_param_spec_literals = allow_param_spec_literals
1971
+ res: list[Type] = []
1972
+ for t in a:
1973
+ res.append(
1974
+ self.anal_type(
1975
+ t, nested, allow_param_spec=allow_param_spec, allow_unpack=allow_unpack
1976
+ )
1977
+ )
1978
+ self.allow_param_spec_literals = old_allow_param_spec_literals
1979
+ return self.check_unpacks_in_list(res)
1980
+
1981
+ def anal_type(
1982
+ self,
1983
+ t: Type,
1984
+ nested: bool = True,
1985
+ *,
1986
+ allow_param_spec: bool = False,
1987
+ allow_unpack: bool = False,
1988
+ allow_ellipsis: bool = False,
1989
+ allow_typed_dict_special_forms: bool = False,
1990
+ allow_final: bool = False,
1991
+ ) -> Type:
1992
+ if nested:
1993
+ self.nesting_level += 1
1994
+ old_allow_typed_dict_special_forms = self.allow_typed_dict_special_forms
1995
+ self.allow_typed_dict_special_forms = allow_typed_dict_special_forms
1996
+ self.allow_final = allow_final
1997
+ old_allow_ellipsis = self.allow_ellipsis
1998
+ self.allow_ellipsis = allow_ellipsis
1999
+ old_allow_unpack = self.allow_unpack
2000
+ self.allow_unpack = allow_unpack
2001
+ try:
2002
+ analyzed = t.accept(self)
2003
+ finally:
2004
+ if nested:
2005
+ self.nesting_level -= 1
2006
+ self.allow_typed_dict_special_forms = old_allow_typed_dict_special_forms
2007
+ self.allow_ellipsis = old_allow_ellipsis
2008
+ self.allow_unpack = old_allow_unpack
2009
+ if (
2010
+ not allow_param_spec
2011
+ and isinstance(analyzed, ParamSpecType)
2012
+ and analyzed.flavor == ParamSpecFlavor.BARE
2013
+ ):
2014
+ if analyzed.prefix.arg_types:
2015
+ self.fail("Invalid location for Concatenate", t, code=codes.VALID_TYPE)
2016
+ self.note("You can use Concatenate as the first argument to Callable", t)
2017
+ analyzed = AnyType(TypeOfAny.from_error)
2018
+ else:
2019
+ self.fail(
2020
+ INVALID_PARAM_SPEC_LOCATION.format(format_type(analyzed, self.options)),
2021
+ t,
2022
+ code=codes.VALID_TYPE,
2023
+ )
2024
+ self.note(
2025
+ INVALID_PARAM_SPEC_LOCATION_NOTE.format(analyzed.name),
2026
+ t,
2027
+ code=codes.VALID_TYPE,
2028
+ )
2029
+ analyzed = AnyType(TypeOfAny.from_error)
2030
+ return analyzed
2031
+
2032
+ def anal_var_def(self, var_def: TypeVarLikeType) -> TypeVarLikeType:
2033
+ if isinstance(var_def, TypeVarType):
2034
+ return TypeVarType(
2035
+ name=var_def.name,
2036
+ fullname=var_def.fullname,
2037
+ id=var_def.id,
2038
+ values=self.anal_array(var_def.values),
2039
+ upper_bound=var_def.upper_bound.accept(self),
2040
+ default=var_def.default.accept(self),
2041
+ variance=var_def.variance,
2042
+ line=var_def.line,
2043
+ column=var_def.column,
2044
+ )
2045
+ else:
2046
+ return var_def
2047
+
2048
+ def anal_var_defs(self, var_defs: Sequence[TypeVarLikeType]) -> list[TypeVarLikeType]:
2049
+ return [self.anal_var_def(vd) for vd in var_defs]
2050
+
2051
+ def named_type(
2052
+ self, fullname: str, args: list[Type] | None = None, line: int = -1, column: int = -1
2053
+ ) -> Instance:
2054
+ node = self.lookup_fully_qualified(fullname)
2055
+ assert isinstance(node.node, TypeInfo)
2056
+ any_type = AnyType(TypeOfAny.special_form)
2057
+ if args is not None:
2058
+ args = self.check_unpacks_in_list(args)
2059
+ return Instance(
2060
+ node.node, args or [any_type] * len(node.node.defn.type_vars), line=line, column=column
2061
+ )
2062
+
2063
+ def check_unpacks_in_list(self, items: list[Type]) -> list[Type]:
2064
+ new_items: list[Type] = []
2065
+ num_unpacks = 0
2066
+ final_unpack = None
2067
+ for item in items:
2068
+ # TODO: handle forward references here, they appear as Unpack[Any].
2069
+ if isinstance(item, UnpackType) and not isinstance(
2070
+ get_proper_type(item.type), TupleType
2071
+ ):
2072
+ if not num_unpacks:
2073
+ new_items.append(item)
2074
+ num_unpacks += 1
2075
+ final_unpack = item
2076
+ else:
2077
+ new_items.append(item)
2078
+
2079
+ if num_unpacks > 1:
2080
+ assert final_unpack is not None
2081
+ self.fail("More than one variadic Unpack in a type is not allowed", final_unpack.type)
2082
+ return new_items
2083
+
2084
+ def tuple_type(self, items: list[Type], line: int, column: int) -> TupleType:
2085
+ any_type = AnyType(TypeOfAny.special_form)
2086
+ return TupleType(
2087
+ items, fallback=self.named_type("builtins.tuple", [any_type]), line=line, column=column
2088
+ )
2089
+
2090
+
2091
+ TypeVarLikeList = list[tuple[str, TypeVarLikeExpr]]
2092
+
2093
+
2094
+ class MsgCallback(Protocol):
2095
+ def __call__(
2096
+ self, __msg: str, __ctx: Context, *, code: ErrorCode | None = None
2097
+ ) -> ErrorInfo | None: ...
2098
+
2099
+
2100
+ def get_omitted_any(
2101
+ disallow_any: bool,
2102
+ fail: MsgCallback,
2103
+ note: MsgCallback,
2104
+ orig_type: Type,
2105
+ options: Options,
2106
+ fullname: str | None = None,
2107
+ unexpanded_type: Type | None = None,
2108
+ used_default: bool = False,
2109
+ ) -> AnyType:
2110
+ if disallow_any:
2111
+ typ = unexpanded_type or orig_type
2112
+ type_str = typ.name if isinstance(typ, UnboundType) else format_type_bare(typ, options)
2113
+
2114
+ fail(
2115
+ message_registry.BARE_GENERIC.format(quote_type_string(type_str)),
2116
+ typ,
2117
+ code=codes.TYPE_ARG,
2118
+ )
2119
+ if used_default:
2120
+ note(message_registry.NO_CYCLIC_DEFAULT, typ, code=codes.TYPE_ARG)
2121
+
2122
+ any_type = AnyType(TypeOfAny.from_error, line=typ.line, column=typ.column)
2123
+ else:
2124
+ any_type = AnyType(
2125
+ TypeOfAny.from_omitted_generics, line=orig_type.line, column=orig_type.column
2126
+ )
2127
+ return any_type
2128
+
2129
+
2130
+ def fix_type_var_tuple_argument(t: Instance) -> None:
2131
+ if t.type.has_type_var_tuple_type:
2132
+ args = list(t.args)
2133
+ assert t.type.type_var_tuple_prefix is not None
2134
+ tvt = t.type.defn.type_vars[t.type.type_var_tuple_prefix]
2135
+ assert isinstance(tvt, TypeVarTupleType)
2136
+ args[t.type.type_var_tuple_prefix] = UnpackType(
2137
+ Instance(tvt.tuple_fallback.type, [args[t.type.type_var_tuple_prefix]])
2138
+ )
2139
+ t.args = tuple(args)
2140
+
2141
+
2142
+ def fix_instance(
2143
+ t: Instance,
2144
+ fail: MsgCallback,
2145
+ note: MsgCallback,
2146
+ disallow_any: bool,
2147
+ options: Options,
2148
+ use_generic_error: bool = False,
2149
+ unexpanded_type: Type | None = None,
2150
+ analyzing_tvar_def: bool = False,
2151
+ ) -> bool:
2152
+ """Fix a malformed instance by replacing all type arguments with TypeVar default or Any.
2153
+
2154
+ Also emit a suitable error if this is not due to implicit Any's.
2155
+ """
2156
+ used_default = False
2157
+ arg_count = len(t.args)
2158
+ min_tv_count = sum(
2159
+ not tv.has_default() and not isinstance(tv, TypeVarTupleType)
2160
+ for tv in t.type.defn.type_vars
2161
+ )
2162
+ max_tv_count = len(t.type.type_vars)
2163
+ if arg_count < min_tv_count or arg_count > max_tv_count:
2164
+ # Don't use existing args if arg_count doesn't match
2165
+ if arg_count > max_tv_count:
2166
+ # Already wrong arg count error, don't emit missing type parameters error as well.
2167
+ disallow_any = False
2168
+ t.args = ()
2169
+
2170
+ args: list[Type] = list(t.args)
2171
+ any_type: AnyType | None = None
2172
+ env: dict[TypeVarId, Type] = {}
2173
+ tvt_no_default = False
2174
+
2175
+ for tv, arg in itertools.zip_longest(t.type.defn.type_vars, t.args, fillvalue=None):
2176
+ if tv is None:
2177
+ continue
2178
+ if arg is None:
2179
+ use_any = False
2180
+ if tv.has_default():
2181
+ arg = tv.default
2182
+ if analyzing_tvar_def:
2183
+ # Record the use of default only when analyzing another default.
2184
+ used_default = True
2185
+ if is_typevar_default_recursive(tv.fullname, t.type):
2186
+ # If this results in infinite recursion, use Any instead.
2187
+ use_any = True
2188
+ else:
2189
+ use_any = True
2190
+ if use_any:
2191
+ if any_type is None:
2192
+ fullname = None if use_generic_error else t.type.fullname
2193
+ any_type = get_omitted_any(
2194
+ disallow_any,
2195
+ fail,
2196
+ note,
2197
+ t,
2198
+ options,
2199
+ fullname,
2200
+ unexpanded_type,
2201
+ used_default,
2202
+ )
2203
+ arg = any_type
2204
+ else:
2205
+ assert arg is not None
2206
+ if use_any and isinstance(tv, TypeVarTupleType):
2207
+ tvt_no_default = True
2208
+ # Default such as *tuple[int, str] should be unpacked into individual items.
2209
+ if isinstance(arg, UnpackType) and isinstance(
2210
+ unpack := get_proper_type(arg.type), TupleType
2211
+ ):
2212
+ unpacked = unpack.items
2213
+ else:
2214
+ unpacked = [arg]
2215
+ for arg in unpacked:
2216
+ with state.strict_optional_set(True):
2217
+ # Gradually expand defaults, as they may depend on previous variables.
2218
+ if tv.has_default():
2219
+ arg = expand_type(arg, env)
2220
+ env[tv.id] = arg
2221
+ args.append(arg)
2222
+ else:
2223
+ env[tv.id] = arg
2224
+ t.args = tuple(args)
2225
+ if tvt_no_default:
2226
+ fix_type_var_tuple_argument(t)
2227
+ return used_default
2228
+
2229
+
2230
+ def instantiate_type_alias(
2231
+ node: TypeAlias,
2232
+ args: list[Type],
2233
+ fail: MsgCallback,
2234
+ note: MsgCallback,
2235
+ no_args: bool,
2236
+ ctx: Context,
2237
+ options: Options,
2238
+ *,
2239
+ unexpanded_type: Type | None = None,
2240
+ disallow_any: bool = False,
2241
+ use_standard_error: bool = False,
2242
+ empty_tuple_index: bool = False,
2243
+ analyzing_tvar_def: bool = False,
2244
+ ) -> tuple[Type, bool]:
2245
+ """Create an instance of a (generic) type alias from alias node and type arguments.
2246
+
2247
+ We are following the rules outlined in TypeAlias docstring.
2248
+ Here:
2249
+ node: type alias node (definition)
2250
+ args: type arguments (types to be substituted in place of type variables
2251
+ when expanding the alias)
2252
+ fail: error reporter callback
2253
+ no_args: whether original definition used a bare generic `A = List`
2254
+ ctx: context where expansion happens
2255
+ unexpanded_type, disallow_any, use_standard_error: used to customize error messages
2256
+ """
2257
+ # Type aliases are special, since they can be expanded during semantic analysis,
2258
+ # so we need to normalize them as soon as possible.
2259
+ # TODO: can this cause an infinite recursion?
2260
+ old_args = args
2261
+ args = flatten_nested_tuples(args)
2262
+ if old_args and not args:
2263
+ empty_tuple_index = True
2264
+ if any(unknown_unpack(a) for a in args):
2265
+ # This type is not ready to be validated, because of unknown total count.
2266
+ # Note that we keep the kind of Any for consistency.
2267
+ return set_any_tvars(node, [], ctx.line, ctx.column, options, special_form=True)
2268
+
2269
+ if (
2270
+ no_args
2271
+ and isinstance(node.target, ProperType)
2272
+ and isinstance(node.target, Instance)
2273
+ and node.target.type.fullname == "builtins.tuple"
2274
+ and len(args)
2275
+ ):
2276
+ no_args = False
2277
+
2278
+ max_tv_count = len(node.alias_tvars)
2279
+ act_len = len(args)
2280
+ if (
2281
+ max_tv_count > 0
2282
+ and act_len == 0
2283
+ and not (empty_tuple_index and node.tvar_tuple_index is not None)
2284
+ ):
2285
+ # Interpret bare Alias same as normal generic, i.e., Alias[Any, Any, ...]
2286
+ return set_any_tvars(
2287
+ node,
2288
+ args,
2289
+ ctx.line,
2290
+ ctx.column,
2291
+ options,
2292
+ disallow_any=disallow_any,
2293
+ fail=fail,
2294
+ note=note,
2295
+ unexpanded_type=unexpanded_type,
2296
+ analyzing_tvar_def=analyzing_tvar_def,
2297
+ )
2298
+ if max_tv_count == 0 and act_len == 0:
2299
+ if no_args:
2300
+ assert isinstance(node.target, Instance) # type: ignore[misc]
2301
+ # Note: this is the only case where we use an eager expansion. See more info about
2302
+ # no_args aliases like L = List in the docstring for TypeAlias class.
2303
+ return Instance(node.target.type, [], line=ctx.line, column=ctx.column), False
2304
+ return TypeAliasType(node, [], line=ctx.line, column=ctx.column), False
2305
+ if (
2306
+ max_tv_count == 0
2307
+ and act_len > 0
2308
+ and isinstance(node.target, Instance) # type: ignore[misc]
2309
+ and no_args
2310
+ ):
2311
+ tp = Instance(node.target.type, args)
2312
+ tp.line = ctx.line
2313
+ tp.column = ctx.column
2314
+ tp.end_line = ctx.end_line
2315
+ tp.end_column = ctx.end_column
2316
+ return tp, False
2317
+ if node.tvar_tuple_index is None:
2318
+ if any(isinstance(a, UnpackType) for a in args):
2319
+ # A variadic unpack in fixed size alias (fixed unpacks must be flattened by the caller)
2320
+ fail(message_registry.INVALID_UNPACK_POSITION, ctx, code=codes.VALID_TYPE)
2321
+ return set_any_tvars(node, [], ctx.line, ctx.column, options, from_error=True)
2322
+ min_tv_count = sum(not tv.has_default() for tv in node.alias_tvars)
2323
+ fill_typevars = act_len != max_tv_count
2324
+ correct = min_tv_count <= act_len <= max_tv_count
2325
+ else:
2326
+ min_tv_count = sum(
2327
+ not tv.has_default() and not isinstance(tv, TypeVarTupleType)
2328
+ for tv in node.alias_tvars
2329
+ )
2330
+ correct = act_len >= min_tv_count
2331
+ for a in args:
2332
+ if isinstance(a, UnpackType):
2333
+ unpacked = get_proper_type(a.type)
2334
+ if isinstance(unpacked, Instance) and unpacked.type.fullname == "builtins.tuple":
2335
+ # Variadic tuple is always correct.
2336
+ correct = True
2337
+ fill_typevars = not correct
2338
+ if fill_typevars:
2339
+ if not correct:
2340
+ if use_standard_error:
2341
+ # This is used if type alias is an internal representation of another type,
2342
+ # for example a generic TypedDict or NamedTuple.
2343
+ msg = wrong_type_arg_count(max_tv_count, max_tv_count, str(act_len), node.name)
2344
+ else:
2345
+ if node.tvar_tuple_index is not None:
2346
+ msg = (
2347
+ "Bad number of arguments for type alias,"
2348
+ f" expected at least {min_tv_count}, given {act_len}"
2349
+ )
2350
+ elif min_tv_count != max_tv_count:
2351
+ msg = (
2352
+ "Bad number of arguments for type alias,"
2353
+ f" expected between {min_tv_count} and {max_tv_count}, given {act_len}"
2354
+ )
2355
+ else:
2356
+ msg = (
2357
+ "Bad number of arguments for type alias,"
2358
+ f" expected {min_tv_count}, given {act_len}"
2359
+ )
2360
+ fail(msg, ctx, code=codes.TYPE_ARG)
2361
+ args = []
2362
+ return set_any_tvars(
2363
+ node,
2364
+ args,
2365
+ ctx.line,
2366
+ ctx.column,
2367
+ options,
2368
+ disallow_any=disallow_any,
2369
+ fail=fail,
2370
+ note=note,
2371
+ from_error=not correct,
2372
+ analyzing_tvar_def=analyzing_tvar_def,
2373
+ )
2374
+ elif node.tvar_tuple_index is not None:
2375
+ # We also need to check if we are not performing a type variable tuple split.
2376
+ unpack = find_unpack_in_list(args)
2377
+ if unpack is not None:
2378
+ unpack_arg = args[unpack]
2379
+ assert isinstance(unpack_arg, UnpackType)
2380
+ if isinstance(unpack_arg.type, TypeVarTupleType):
2381
+ exp_prefix = node.tvar_tuple_index
2382
+ act_prefix = unpack
2383
+ exp_suffix = len(node.alias_tvars) - node.tvar_tuple_index - 1
2384
+ act_suffix = len(args) - unpack - 1
2385
+ if act_prefix < exp_prefix or act_suffix < exp_suffix:
2386
+ fail("TypeVarTuple cannot be split", ctx, code=codes.TYPE_ARG)
2387
+ return set_any_tvars(node, [], ctx.line, ctx.column, options, from_error=True)
2388
+ # TODO: we need to check args validity w.r.t alias.alias_tvars.
2389
+ # Otherwise invalid instantiations will be allowed in runtime context.
2390
+ # Note: in type context, these will be still caught by semanal_typeargs.
2391
+ typ = TypeAliasType(node, args, ctx.line, ctx.column)
2392
+ assert typ.alias is not None
2393
+ # HACK: Implement FlexibleAlias[T, typ] by expanding it to typ here.
2394
+ if (
2395
+ isinstance(typ.alias.target, Instance) # type: ignore[misc]
2396
+ and typ.alias.target.type.fullname == "mypy_extensions.FlexibleAlias"
2397
+ ):
2398
+ exp = get_proper_type(typ)
2399
+ assert isinstance(exp, Instance)
2400
+ return exp.args[-1], False
2401
+ return typ, False
2402
+
2403
+
2404
+ def set_any_tvars(
2405
+ node: TypeAlias,
2406
+ args: list[Type],
2407
+ newline: int,
2408
+ newcolumn: int,
2409
+ options: Options,
2410
+ *,
2411
+ from_error: bool = False,
2412
+ disallow_any: bool = False,
2413
+ special_form: bool = False,
2414
+ fail: MsgCallback | None = None,
2415
+ note: MsgCallback | None = None,
2416
+ unexpanded_type: Type | None = None,
2417
+ analyzing_tvar_def: bool = False,
2418
+ ) -> tuple[TypeAliasType, bool]:
2419
+ used_default = False
2420
+ if from_error or disallow_any:
2421
+ type_of_any = TypeOfAny.from_error
2422
+ elif special_form:
2423
+ type_of_any = TypeOfAny.special_form
2424
+ else:
2425
+ type_of_any = TypeOfAny.from_omitted_generics
2426
+ any_type = AnyType(type_of_any, line=newline, column=newcolumn)
2427
+
2428
+ env: dict[TypeVarId, Type] = {}
2429
+ used_any_type = False
2430
+ for tv, arg in itertools.zip_longest(node.alias_tvars, args, fillvalue=None):
2431
+ if tv is None:
2432
+ continue
2433
+ if arg is None:
2434
+ if tv.has_default():
2435
+ arg = tv.default
2436
+ # Same as for instances, record and avoid infinite recursion.
2437
+ if analyzing_tvar_def:
2438
+ used_default = True
2439
+ if is_typevar_default_recursive(tv.fullname, node):
2440
+ arg = any_type
2441
+ used_any_type = True
2442
+ else:
2443
+ arg = any_type
2444
+ used_any_type = True
2445
+ if used_any_type and isinstance(tv, TypeVarTupleType):
2446
+ arg = UnpackType(Instance(tv.tuple_fallback.type, [any_type]))
2447
+ # Default such as *tuple[int, str] should be unpacked into individual items.
2448
+ if isinstance(arg, UnpackType) and isinstance(
2449
+ unpack := get_proper_type(arg.type), TupleType
2450
+ ):
2451
+ unpacked = unpack.items
2452
+ else:
2453
+ unpacked = [arg]
2454
+ for arg in unpacked:
2455
+ with state.strict_optional_set(options.strict_optional):
2456
+ # Gradually expand defaults, as they may depend on previous variables.
2457
+ if tv.has_default():
2458
+ arg = expand_type(arg, env)
2459
+ env[tv.id] = arg
2460
+ args.append(arg)
2461
+ else:
2462
+ env[tv.id] = arg
2463
+ t = TypeAliasType(node, args, newline, newcolumn)
2464
+
2465
+ if used_any_type and disallow_any and node.alias_tvars and not from_error:
2466
+ assert fail is not None
2467
+ if unexpanded_type:
2468
+ type_str = (
2469
+ unexpanded_type.name
2470
+ if isinstance(unexpanded_type, UnboundType)
2471
+ else format_type_bare(unexpanded_type, options)
2472
+ )
2473
+ else:
2474
+ type_str = node.name
2475
+
2476
+ fail(
2477
+ message_registry.BARE_GENERIC.format(quote_type_string(type_str)),
2478
+ Context(newline, newcolumn),
2479
+ code=codes.TYPE_ARG,
2480
+ )
2481
+ if used_default:
2482
+ assert note is not None
2483
+ note(
2484
+ message_registry.NO_CYCLIC_DEFAULT,
2485
+ Context(newline, newcolumn),
2486
+ code=codes.TYPE_ARG,
2487
+ )
2488
+ return t, used_default
2489
+
2490
+
2491
+ def is_typevar_default_recursive(tv_fname: str, start: TypeInfo | TypeAlias) -> bool:
2492
+ """Check if the type variable can lead to infinite recursion via defaults."""
2493
+ if tv_fname not in start.default_depends:
2494
+ return False
2495
+ todo = start.default_depends[tv_fname].copy()
2496
+ seen: set[TypeAlias | TypeInfo] = set()
2497
+ while todo:
2498
+ node = todo.pop()
2499
+ if node is start:
2500
+ return True
2501
+ if node in seen:
2502
+ # We don't return True here, since we are interested only in
2503
+ # recursion via the original type variable.
2504
+ continue
2505
+ seen.add(node)
2506
+ for dep_nodes in node.default_depends.values():
2507
+ todo |= dep_nodes
2508
+ return False
2509
+
2510
+
2511
+ class DivergingAliasDetector(TrivialSyntheticTypeTranslator):
2512
+ """See docstring of detect_diverging_alias() for details."""
2513
+
2514
+ # TODO: this doesn't really need to be a translator, but we don't have a trivial visitor.
2515
+ def __init__(self, seen_nodes: set[TypeAlias]) -> None:
2516
+ super().__init__()
2517
+ self.seen_nodes = seen_nodes
2518
+ self.diverging = False
2519
+
2520
+ def visit_type_alias_type(self, t: TypeAliasType) -> Type:
2521
+ assert t.alias is not None, f"Unfixed type alias {t.type_ref}"
2522
+ if t.alias in self.seen_nodes:
2523
+ for arg in t.args:
2524
+ if not (
2525
+ isinstance(arg, TypeVarLikeType)
2526
+ or isinstance(arg, UnpackType)
2527
+ and isinstance(arg.type, TypeVarLikeType)
2528
+ ) and has_type_vars(arg):
2529
+ self.diverging = True
2530
+ return t
2531
+ # All clear for this expansion chain.
2532
+ return t
2533
+ new_nodes = self.seen_nodes | {t.alias}
2534
+ visitor = DivergingAliasDetector(new_nodes)
2535
+ _ = get_proper_type(t).accept(visitor)
2536
+ if visitor.diverging:
2537
+ self.diverging = True
2538
+ return t
2539
+
2540
+
2541
+ def detect_diverging_alias(node: TypeAlias, target: Type) -> bool:
2542
+ """This detects type aliases that will diverge during type checking.
2543
+
2544
+ For example F = Something[..., F[List[T]]]. At each expansion step this will produce
2545
+ *new* type aliases: e.g. F[List[int]], F[List[List[int]]], etc. So we can't detect
2546
+ recursion. It is a known problem in the literature, recursive aliases and generic types
2547
+ don't always go well together. It looks like there is no known systematic solution yet.
2548
+
2549
+ # TODO: should we handle such aliases using type_recursion counter and some large limit?
2550
+ They may be handy in rare cases, e.g. to express a union of non-mixed nested lists:
2551
+ Nested = Union[T, Nested[List[T]]] ~> Union[T, List[T], List[List[T]], ...]
2552
+ """
2553
+ is_recursive = node._is_recursive
2554
+ if is_recursive is None:
2555
+ is_recursive = node in node.target.accept(CollectAliasesVisitor())
2556
+ if not is_recursive:
2557
+ # Fast path: this is not a recursive alias at all.
2558
+ return False
2559
+ # Note we only cache positive case, caching negative case is risky, as this type alias
2560
+ # (or more importantly any other alias it uses) may be not ready yet.
2561
+ node._is_recursive = True
2562
+ visitor = DivergingAliasDetector({node})
2563
+ _ = target.accept(visitor)
2564
+ return visitor.diverging
2565
+
2566
+
2567
+ def check_for_explicit_any(
2568
+ typ: Type | None,
2569
+ options: Options,
2570
+ is_typeshed_stub: bool,
2571
+ msg: MessageBuilder,
2572
+ context: Context,
2573
+ ) -> None:
2574
+ if options.disallow_any_explicit and not is_typeshed_stub and typ and has_explicit_any(typ):
2575
+ msg.explicit_any(context)
2576
+
2577
+
2578
+ def has_explicit_any(t: Type) -> bool:
2579
+ """
2580
+ Whether this type is or type it contains is an Any coming from explicit type annotation
2581
+ """
2582
+ return t.accept(HasExplicitAny())
2583
+
2584
+
2585
+ class HasExplicitAny(BoolTypeQuery):
2586
+ def __init__(self) -> None:
2587
+ super().__init__(ANY_STRATEGY)
2588
+
2589
+ def visit_any(self, t: AnyType) -> bool:
2590
+ return t.type_of_any == TypeOfAny.explicit
2591
+
2592
+ def visit_typeddict_type(self, t: TypedDictType) -> bool:
2593
+ # typeddict is checked during TypedDict declaration, so don't typecheck it here.
2594
+ return False
2595
+
2596
+
2597
+ def has_any_from_unimported_type(t: Type) -> bool:
2598
+ """Return true if this type is Any because an import was not followed.
2599
+
2600
+ If type t is such Any type or has type arguments that contain such Any type
2601
+ this function will return true.
2602
+ """
2603
+ return t.accept(HasAnyFromUnimportedType())
2604
+
2605
+
2606
+ class HasAnyFromUnimportedType(BoolTypeQuery):
2607
+ def __init__(self) -> None:
2608
+ super().__init__(ANY_STRATEGY)
2609
+
2610
+ def visit_any(self, t: AnyType) -> bool:
2611
+ return t.type_of_any == TypeOfAny.from_unimported_type
2612
+
2613
+ def visit_typeddict_type(self, t: TypedDictType) -> bool:
2614
+ # typeddict is checked during TypedDict declaration, so don't typecheck it here
2615
+ return False
2616
+
2617
+
2618
+ def collect_all_inner_types(t: Type) -> list[Type]:
2619
+ """
2620
+ Return all types that `t` contains
2621
+ """
2622
+ return t.accept(CollectAllInnerTypesQuery())
2623
+
2624
+
2625
+ class CollectAllInnerTypesQuery(TypeQuery[list[Type]]):
2626
+ def query_types(self, types: Iterable[Type]) -> list[Type]:
2627
+ return self.strategy([t.accept(self) for t in types]) + list(types)
2628
+
2629
+ def strategy(self, items: Iterable[list[Type]]) -> list[Type]:
2630
+ return list(itertools.chain.from_iterable(items))
2631
+
2632
+
2633
+ def make_optional_type(t: Type) -> Type:
2634
+ """Return the type corresponding to Optional[t].
2635
+
2636
+ Note that we can't use normal union simplification, since this function
2637
+ is called during semantic analysis and simplification only works during
2638
+ type checking.
2639
+ """
2640
+ if isinstance(t, ProperType) and isinstance(t, NoneType):
2641
+ return t
2642
+ elif isinstance(t, ProperType) and isinstance(t, UnionType):
2643
+ # Eagerly expanding aliases is not safe during semantic analysis.
2644
+ items = [item for item in t.items if not isinstance(get_proper_type(item), NoneType)]
2645
+ return UnionType(items + [NoneType()], t.line, t.column)
2646
+ else:
2647
+ return UnionType([t, NoneType()], t.line, t.column)
2648
+
2649
+
2650
+ def validate_instance(t: Instance, fail: MsgCallback, indexed: bool) -> bool:
2651
+ """Check if this is a well-formed instance with respect to argument count/positions."""
2652
+ # TODO: combine logic with instantiate_type_alias().
2653
+ if any(unknown_unpack(a) for a in t.args):
2654
+ # This type is not ready to be validated, because of unknown total count.
2655
+ # TODO: is it OK to fill with TypeOfAny.from_error instead of special form?
2656
+ return False
2657
+ empty_tuple_index = indexed and not t.args
2658
+ if t.type.has_type_var_tuple_type:
2659
+ min_tv_count = sum(
2660
+ not tv.has_default() and not isinstance(tv, TypeVarTupleType)
2661
+ for tv in t.type.defn.type_vars
2662
+ )
2663
+ correct = len(t.args) >= min_tv_count
2664
+ if any(
2665
+ isinstance(a, UnpackType) and isinstance(get_proper_type(a.type), Instance)
2666
+ for a in t.args
2667
+ ):
2668
+ correct = True
2669
+ if not t.args:
2670
+ if not (empty_tuple_index and len(t.type.type_vars) == 1):
2671
+ # The Any arguments should be set by the caller.
2672
+ if empty_tuple_index and min_tv_count:
2673
+ fail(
2674
+ f"At least {min_tv_count} type argument(s) expected, none given",
2675
+ t,
2676
+ code=codes.TYPE_ARG,
2677
+ )
2678
+ return False
2679
+ elif not correct:
2680
+ fail(
2681
+ f"Bad number of arguments, expected: at least {min_tv_count}, given: {len(t.args)}",
2682
+ t,
2683
+ code=codes.TYPE_ARG,
2684
+ )
2685
+ return False
2686
+ else:
2687
+ # We also need to check if we are not performing a type variable tuple split.
2688
+ unpack = find_unpack_in_list(t.args)
2689
+ if unpack is not None:
2690
+ unpack_arg = t.args[unpack]
2691
+ assert isinstance(unpack_arg, UnpackType)
2692
+ if isinstance(unpack_arg.type, TypeVarTupleType):
2693
+ assert t.type.type_var_tuple_prefix is not None
2694
+ assert t.type.type_var_tuple_suffix is not None
2695
+ exp_prefix = t.type.type_var_tuple_prefix
2696
+ act_prefix = unpack
2697
+ exp_suffix = t.type.type_var_tuple_suffix
2698
+ act_suffix = len(t.args) - unpack - 1
2699
+ if act_prefix < exp_prefix or act_suffix < exp_suffix:
2700
+ fail("TypeVarTuple cannot be split", t, code=codes.TYPE_ARG)
2701
+ return False
2702
+ elif any(isinstance(a, UnpackType) for a in t.args):
2703
+ # A variadic unpack in fixed size instance (fixed unpacks must be flattened by the caller)
2704
+ fail(message_registry.INVALID_UNPACK_POSITION, t, code=codes.VALID_TYPE)
2705
+ t.args = ()
2706
+ return False
2707
+ elif len(t.args) != len(t.type.type_vars):
2708
+ # Invalid number of type parameters.
2709
+ arg_count = len(t.args)
2710
+ min_tv_count = sum(not tv.has_default() for tv in t.type.defn.type_vars)
2711
+ max_tv_count = len(t.type.type_vars)
2712
+ if (arg_count or empty_tuple_index) and (
2713
+ arg_count < min_tv_count or arg_count > max_tv_count
2714
+ ):
2715
+ fail(
2716
+ wrong_type_arg_count(min_tv_count, max_tv_count, str(arg_count), t.type.name),
2717
+ t,
2718
+ code=codes.TYPE_ARG,
2719
+ )
2720
+ return False
2721
+ return True
2722
+
2723
+
2724
+ def find_self_type(typ: Type, lookup: Callable[[str], SymbolTableNode | None]) -> bool:
2725
+ return typ.accept(HasSelfType(lookup))
2726
+
2727
+
2728
+ class HasSelfType(BoolTypeQuery):
2729
+ def __init__(self, lookup: Callable[[str], SymbolTableNode | None]) -> None:
2730
+ self.lookup = lookup
2731
+ super().__init__(ANY_STRATEGY)
2732
+
2733
+ def visit_unbound_type(self, t: UnboundType) -> bool:
2734
+ sym = self.lookup(t.name)
2735
+ if sym and sym.fullname in SELF_TYPE_NAMES:
2736
+ return True
2737
+ return super().visit_unbound_type(t)
2738
+
2739
+
2740
+ def unknown_unpack(t: Type) -> bool:
2741
+ """Check if a given type is an unpack of an unknown type.
2742
+
2743
+ Unfortunately, there is no robust way to distinguish forward references from
2744
+ genuine undefined names here. But this worked well so far, although it looks
2745
+ quite fragile.
2746
+ """
2747
+ if isinstance(t, UnpackType):
2748
+ unpacked = get_proper_type(t.type)
2749
+ if isinstance(unpacked, AnyType) and unpacked.type_of_any == TypeOfAny.special_form:
2750
+ return True
2751
+ return False
2752
+
2753
+
2754
+ class FindTypeVarVisitor(SyntheticTypeVisitor[None]):
2755
+ """Type visitor that looks for type variable types and self types."""
2756
+
2757
+ def __init__(self, api: SemanticAnalyzerCoreInterface, scope: TypeVarLikeScope) -> None:
2758
+ self.api = api
2759
+ self.scope = scope
2760
+ self.type_var_likes: list[tuple[str, TypeVarLikeExpr]] = []
2761
+ self.has_self_type = False
2762
+ self.include_callables = True
2763
+
2764
+ def _seems_like_callable(self, type: UnboundType) -> bool:
2765
+ if not type.args:
2766
+ return False
2767
+ return isinstance(type.args[0], (EllipsisType, TypeList, ParamSpecType))
2768
+
2769
+ def visit_unbound_type(self, t: UnboundType) -> None:
2770
+ name = t.name
2771
+ node = self.api.lookup_qualified(name, t)
2772
+ if node and node.fullname in SELF_TYPE_NAMES:
2773
+ self.has_self_type = True
2774
+ if (
2775
+ node
2776
+ and isinstance(node.node, TypeVarLikeExpr)
2777
+ and self.scope.get_binding(node) is None
2778
+ ):
2779
+ if (name, node.node) not in self.type_var_likes:
2780
+ self.type_var_likes.append((name, node.node))
2781
+ elif not self.include_callables and self._seems_like_callable(t):
2782
+ if find_self_type(
2783
+ t, lambda name: self.api.lookup_qualified(name, t, suppress_errors=True)
2784
+ ):
2785
+ self.has_self_type = True
2786
+ return
2787
+ elif node and node.fullname in LITERAL_TYPE_NAMES:
2788
+ return
2789
+ elif node and node.fullname in ANNOTATED_TYPE_NAMES and t.args:
2790
+ # Don't query the second argument to Annotated for TypeVars
2791
+ self.process_types([t.args[0]])
2792
+ elif t.args:
2793
+ self.process_types(t.args)
2794
+
2795
+ def visit_type_list(self, t: TypeList) -> None:
2796
+ self.process_types(t.items)
2797
+
2798
+ def visit_callable_argument(self, t: CallableArgument) -> None:
2799
+ t.typ.accept(self)
2800
+
2801
+ def visit_any(self, t: AnyType) -> None:
2802
+ pass
2803
+
2804
+ def visit_uninhabited_type(self, t: UninhabitedType) -> None:
2805
+ pass
2806
+
2807
+ def visit_none_type(self, t: NoneType) -> None:
2808
+ pass
2809
+
2810
+ def visit_erased_type(self, t: ErasedType) -> None:
2811
+ pass
2812
+
2813
+ def visit_deleted_type(self, t: DeletedType) -> None:
2814
+ pass
2815
+
2816
+ def visit_type_var(self, t: TypeVarType) -> None:
2817
+ self.process_types([t.upper_bound, t.default] + t.values)
2818
+
2819
+ def visit_param_spec(self, t: ParamSpecType) -> None:
2820
+ self.process_types([t.upper_bound, t.default, t.prefix])
2821
+
2822
+ def visit_type_var_tuple(self, t: TypeVarTupleType) -> None:
2823
+ self.process_types([t.upper_bound, t.default])
2824
+
2825
+ def visit_unpack_type(self, t: UnpackType) -> None:
2826
+ self.process_types([t.type])
2827
+
2828
+ def visit_parameters(self, t: Parameters) -> None:
2829
+ self.process_types(t.arg_types)
2830
+
2831
+ def visit_partial_type(self, t: PartialType) -> None:
2832
+ pass
2833
+
2834
+ def visit_instance(self, t: Instance) -> None:
2835
+ self.process_types(t.args)
2836
+
2837
+ def visit_callable_type(self, t: CallableType) -> None:
2838
+ # FIX generics
2839
+ self.process_types(t.arg_types)
2840
+ t.ret_type.accept(self)
2841
+
2842
+ def visit_tuple_type(self, t: TupleType) -> None:
2843
+ self.process_types(t.items)
2844
+
2845
+ def visit_typeddict_type(self, t: TypedDictType) -> None:
2846
+ self.process_types(list(t.items.values()))
2847
+
2848
+ def visit_raw_expression_type(self, t: RawExpressionType) -> None:
2849
+ pass
2850
+
2851
+ def visit_literal_type(self, t: LiteralType) -> None:
2852
+ pass
2853
+
2854
+ def visit_union_type(self, t: UnionType) -> None:
2855
+ self.process_types(t.items)
2856
+
2857
+ def visit_overloaded(self, t: Overloaded) -> None:
2858
+ for it in t.items:
2859
+ it.accept(self)
2860
+
2861
+ def visit_type_type(self, t: TypeType) -> None:
2862
+ t.item.accept(self)
2863
+
2864
+ def visit_ellipsis_type(self, t: EllipsisType) -> None:
2865
+ pass
2866
+
2867
+ def visit_placeholder_type(self, t: PlaceholderType) -> None:
2868
+ return self.process_types(t.args)
2869
+
2870
+ def visit_type_alias_type(self, t: TypeAliasType) -> None:
2871
+ self.process_types(t.args)
2872
+
2873
+ def process_types(self, types: list[Type] | tuple[Type, ...]) -> None:
2874
+ # Redundant type check helps mypyc.
2875
+ if isinstance(types, list):
2876
+ for t in types:
2877
+ t.accept(self)
2878
+ else:
2879
+ for t in types:
2880
+ t.accept(self)
2881
+
2882
+
2883
+ class TypeVarDefaultTranslator(TrivialSyntheticTypeTranslator):
2884
+ """Type translate visitor that replaces UnboundTypes with in-scope TypeVars."""
2885
+
2886
+ def __init__(
2887
+ self, api: SemanticAnalyzerInterface, tvar_expr_name: str, context: Context
2888
+ ) -> None:
2889
+ super().__init__()
2890
+ self.api = api
2891
+ self.tvar_expr_name = tvar_expr_name
2892
+ self.context = context
2893
+
2894
+ def visit_unbound_type(self, t: UnboundType) -> Type:
2895
+ sym = self.api.lookup_qualified(t.name, t, suppress_errors=True)
2896
+ if sym is not None:
2897
+ if type_var := self.api.tvar_scope.get_binding(sym):
2898
+ return type_var
2899
+ if isinstance(sym.node, TypeVarLikeExpr):
2900
+ self.api.fail(
2901
+ f'Type parameter "{self.tvar_expr_name}" has a default type '
2902
+ "that refers to one or more type variables that are out of scope",
2903
+ self.context,
2904
+ )
2905
+ return AnyType(TypeOfAny.from_error)
2906
+ return super().visit_unbound_type(t)
2907
+
2908
+ def visit_type_alias_type(self, t: TypeAliasType) -> Type:
2909
+ # TypeAliasTypes are analyzed separately already, just return it
2910
+ return t
2911
+
2912
+
2913
+ def check_vec_type_args(
2914
+ args: tuple[Type, ...] | list[Type], ctx: Context, api: SemanticAnalyzerCoreInterface
2915
+ ) -> bool:
2916
+ """Report an error if type args for 'vec' are invalid.
2917
+
2918
+ Return False on error.
2919
+ """
2920
+ ok = True
2921
+ if len(args) != 1:
2922
+ ok = False
2923
+ else:
2924
+ arg = get_proper_type(args[0])
2925
+ if isinstance(arg, Instance):
2926
+ if arg.type.fullname == "builtins.int":
2927
+ # A fixed-width integer such as 'i64' must be used instead of plain 'int'
2928
+ ok = False
2929
+ elif isinstance(arg, UnionType):
2930
+ non_optional = None
2931
+ items = [get_proper_type(item) for item in arg.items]
2932
+ if len(items) != 2:
2933
+ ok = False
2934
+ elif isinstance(items[0], NoneType):
2935
+ if not check_vec_type_args([items[1]], ctx, api):
2936
+ # Error has already been reported so it's fine to return
2937
+ return False
2938
+ non_optional = items[1]
2939
+ elif isinstance(items[1], NoneType):
2940
+ if not check_vec_type_args([items[0]], ctx, api):
2941
+ # Error has already been reported so it's fine to return
2942
+ return False
2943
+ non_optional = items[0]
2944
+ else:
2945
+ ok = False
2946
+ if isinstance(non_optional, Instance) and (
2947
+ non_optional.type.fullname in MYPYC_NATIVE_INT_NAMES
2948
+ or non_optional.type.fullname
2949
+ in ("builtins.int", "builtins.float", "builtins.bool", "librt.vecs.vec")
2950
+ ):
2951
+ ok = False
2952
+ elif isinstance(arg, TypeVarType):
2953
+ # Generic vec types aren't supported in type checked Python code, but
2954
+ # they can be provided in libraries implemented in C (e.g. append).
2955
+ if not api.is_stub_file:
2956
+ ok = False
2957
+ else:
2958
+ ok = False
2959
+ if not ok:
2960
+ api.fail('Invalid item type for "vec"', ctx)
2961
+ return ok