jaclang 0.6.1__py3-none-any.whl → 0.7.0__py3-none-any.whl

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.

Potentially problematic release.


This version of jaclang might be problematic. Click here for more details.

Files changed (1337) hide show
  1. jaclang/__init__.py +1 -9
  2. jaclang/cli/.gitignore +3 -0
  3. jaclang/cli/cli.md +190 -0
  4. jaclang/cli/cli.py +25 -4
  5. jaclang/compiler/.gitignore +1 -0
  6. jaclang/compiler/__init__.py +1 -0
  7. jaclang/compiler/absyntree.py +9 -7
  8. jaclang/compiler/compile.py +4 -4
  9. jaclang/compiler/jac.lark +1 -0
  10. jaclang/compiler/parser.py +28 -6
  11. jaclang/compiler/passes/main/def_impl_match_pass.py +4 -0
  12. jaclang/compiler/passes/main/fuse_typeinfo_pass.py +10 -1
  13. jaclang/compiler/passes/main/import_pass.py +47 -33
  14. jaclang/compiler/passes/main/pyast_load_pass.py +33 -6
  15. jaclang/compiler/passes/main/tests/fixtures/autoimpl.impl/getme.impl.jac +3 -0
  16. jaclang/compiler/passes/main/tests/fixtures/autoimpl.impl.jac +3 -0
  17. jaclang/compiler/passes/main/tests/fixtures/autoimpl.jac +9 -0
  18. jaclang/compiler/passes/main/tests/fixtures/autoimpl.something.else.impl.jac +3 -0
  19. jaclang/compiler/passes/main/tests/fixtures/base.jac +13 -0
  20. jaclang/compiler/passes/main/tests/fixtures/base2.jac +14 -0
  21. jaclang/compiler/passes/main/tests/fixtures/blip.jac +2 -0
  22. jaclang/compiler/passes/main/tests/fixtures/codegentext.jac +31 -0
  23. jaclang/compiler/passes/main/tests/fixtures/decls.jac +10 -0
  24. jaclang/compiler/passes/main/tests/fixtures/defs_and_uses.jac +44 -0
  25. jaclang/compiler/passes/main/tests/fixtures/fstrings.jac +4 -0
  26. jaclang/compiler/passes/main/tests/fixtures/func.jac +18 -0
  27. jaclang/compiler/passes/main/tests/fixtures/func2.jac +8 -0
  28. jaclang/compiler/passes/main/tests/fixtures/game1.jac +15 -0
  29. jaclang/compiler/passes/main/tests/fixtures/impl/defs1.jac +8 -0
  30. jaclang/compiler/passes/main/tests/fixtures/impl/defs2.jac +8 -0
  31. jaclang/compiler/passes/main/tests/fixtures/impl/imps.jac +11 -0
  32. jaclang/compiler/passes/main/tests/fixtures/multi_def_err.jac +7 -0
  33. jaclang/compiler/passes/main/tests/fixtures/registry.jac +36 -0
  34. jaclang/compiler/passes/main/tests/fixtures/type_info.jac +31 -0
  35. jaclang/compiler/passes/main/tests/test_type_check_pass.py +15 -0
  36. jaclang/compiler/passes/tool/jac_formatter_pass.py +2 -2
  37. jaclang/compiler/passes/tool/tests/fixtures/corelib.jac +480 -0
  38. jaclang/compiler/passes/tool/tests/fixtures/corelib_fmt.jac +480 -0
  39. jaclang/compiler/passes/tool/tests/fixtures/genai/essay_review.jac +36 -0
  40. jaclang/compiler/passes/tool/tests/fixtures/genai/expert_answer.jac +17 -0
  41. jaclang/compiler/passes/tool/tests/fixtures/genai/joke_gen.jac +32 -0
  42. jaclang/compiler/passes/tool/tests/fixtures/genai/odd_word_out.jac +27 -0
  43. jaclang/compiler/passes/tool/tests/fixtures/genai/personality_finder.jac +35 -0
  44. jaclang/compiler/passes/tool/tests/fixtures/genai/text_to_type.jac +25 -0
  45. jaclang/compiler/passes/tool/tests/fixtures/genai/translator.jac +13 -0
  46. jaclang/compiler/passes/tool/tests/fixtures/genai/wikipedia.jac +63 -0
  47. jaclang/compiler/passes/tool/tests/fixtures/multi_def_err.dot +39 -0
  48. jaclang/compiler/passes/tool/tests/fixtures/multi_def_err.jac +7 -0
  49. jaclang/compiler/passes/tool/tests/fixtures/multi_def_err.txt +20 -0
  50. jaclang/compiler/passes/tool/tests/fixtures/myca_formatted_code/ability_impl_long_comprehension.jac +15 -0
  51. jaclang/compiler/passes/tool/tests/fixtures/myca_formatted_code/call_with_many_parameters.jac +24 -0
  52. jaclang/compiler/passes/tool/tests/fixtures/myca_formatted_code/entry_main.jac +4 -0
  53. jaclang/compiler/passes/tool/tests/fixtures/myca_formatted_code/long_line_nested_dict_access.jac +10 -0
  54. jaclang/compiler/passes/tool/tests/fixtures/myca_formatted_code/multiline_fstrings.jac +16 -0
  55. jaclang/compiler/passes/tool/tests/fixtures/myca_formatted_code/nested_dict.jac +15 -0
  56. jaclang/compiler/passes/tool/tests/fixtures/myca_formatted_code/nested_loop_and_incrementer.jac +13 -0
  57. jaclang/compiler/passes/tool/tests/fixtures/myca_formatted_code/simple_walker.jac +25 -0
  58. jaclang/compiler/passes/tool/tests/fixtures/myca_formatted_code/try_block_and_walker_spawn_and_fstrings.jac +26 -0
  59. jaclang/compiler/passes/tool/tests/fixtures/myca_formatted_code/tuple_iteration_and_not_negation.jac +20 -0
  60. jaclang/compiler/passes/tool/tests/fixtures/myca_formatted_code/type_annotation.jac +3 -0
  61. jaclang/compiler/passes/tool/tests/fixtures/myca_formatted_code/walker_decl_only.jac +12 -0
  62. jaclang/compiler/passes/tool/tests/fixtures/myca_formatted_code/walker_with_default_values_types_and_docstrings.jac +18 -0
  63. jaclang/compiler/passes/tool/tests/fixtures/myca_formatted_code/walker_with_inline_ability_impl.jac +8 -0
  64. jaclang/compiler/passes/tool/tests/fixtures/simple_walk.jac +47 -0
  65. jaclang/compiler/passes/tool/tests/fixtures/simple_walk_fmt.jac +47 -0
  66. jaclang/compiler/passes/transform.py +13 -4
  67. jaclang/compiler/passes/utils/mypy_ast_build.py +8 -0
  68. jaclang/compiler/tests/fixtures/fam.jac +67 -0
  69. jaclang/compiler/tests/fixtures/hello_world.jac +5 -0
  70. jaclang/compiler/tests/fixtures/kwesc.jac +5 -0
  71. jaclang/compiler/tests/fixtures/mod_doc_test.jac +3 -0
  72. jaclang/compiler/tests/fixtures/staticcheck.jac +20 -0
  73. jaclang/compiler/tests/fixtures/stuff.jac +6 -0
  74. jaclang/langserve/__init__.py +1 -0
  75. jaclang/langserve/engine.py +287 -0
  76. jaclang/langserve/server.py +139 -0
  77. jaclang/langserve/tests/__init__.py +1 -0
  78. jaclang/langserve/tests/defaults.py +226 -0
  79. jaclang/langserve/tests/fixtures/hello.jac +1 -0
  80. jaclang/langserve/tests/pylsp_jsonrpc/__init__.py +2 -0
  81. jaclang/langserve/tests/pylsp_jsonrpc/dispatchers.py +37 -0
  82. jaclang/langserve/tests/pylsp_jsonrpc/endpoint.py +294 -0
  83. jaclang/langserve/tests/pylsp_jsonrpc/exceptions.py +114 -0
  84. jaclang/langserve/tests/pylsp_jsonrpc/streams.py +113 -0
  85. jaclang/langserve/tests/session.py +255 -0
  86. jaclang/langserve/tests/test_server.py +36 -0
  87. jaclang/langserve/utils.py +55 -0
  88. jaclang/plugin/default.py +1 -1
  89. jaclang/plugin/tests/fixtures/impl_match.jac +9 -0
  90. jaclang/plugin/tests/fixtures/impl_match_impl.jac +3 -0
  91. jaclang/plugin/tests/fixtures/simple_node_connection.jac +55 -0
  92. jaclang/plugin/tests/fixtures/simple_persistent.jac +41 -0
  93. jaclang/settings.py +5 -0
  94. jaclang/tests/fixtures/abc.jac +73 -0
  95. jaclang/tests/fixtures/access_checker.jac +19 -0
  96. jaclang/tests/fixtures/access_modifier.jac +49 -0
  97. jaclang/tests/fixtures/aott_raise.jac +25 -0
  98. jaclang/tests/fixtures/arithmetic_bug.jac +13 -0
  99. jaclang/tests/fixtures/assign_compr.jac +15 -0
  100. jaclang/tests/fixtures/assign_compr_dup.jac +15 -0
  101. jaclang/tests/fixtures/builtin_dotgen.jac +41 -0
  102. jaclang/tests/fixtures/chandra_bugs.jac +11 -0
  103. jaclang/tests/fixtures/chandra_bugs2.jac +26 -0
  104. jaclang/tests/fixtures/circle_pysolo.py +91 -0
  105. jaclang/tests/fixtures/deep/deeper/deep_outer_import.jac +9 -0
  106. jaclang/tests/fixtures/deep/deeper/deep_outer_import2.jac +9 -0
  107. jaclang/tests/fixtures/deep/deeper/snd_lev.jac +6 -0
  108. jaclang/tests/fixtures/deep/mycode.jac +4 -0
  109. jaclang/tests/fixtures/deep/one_lev.jac +6 -0
  110. jaclang/tests/fixtures/deep/one_lev_dup.jac +6 -0
  111. jaclang/tests/fixtures/deep/one_lev_dup_py.py +6 -0
  112. jaclang/tests/fixtures/deep_convert.jac +5 -0
  113. jaclang/tests/fixtures/deep_convo.py +6 -0
  114. jaclang/tests/fixtures/deep_import.jac +7 -0
  115. jaclang/tests/fixtures/deferred_field.jac +13 -0
  116. jaclang/tests/fixtures/disconn.jac +29 -0
  117. jaclang/tests/fixtures/edge_node_walk.jac +46 -0
  118. jaclang/tests/fixtures/edge_ops.jac +45 -0
  119. jaclang/tests/fixtures/edges_walk.jac +38 -0
  120. jaclang/tests/fixtures/enum_inside_archtype.jac +20 -0
  121. jaclang/tests/fixtures/err.jac +5 -0
  122. jaclang/tests/fixtures/err2.jac +5 -0
  123. jaclang/tests/fixtures/game1.jac +15 -0
  124. jaclang/tests/fixtures/gendot_bubble_sort.jac +77 -0
  125. jaclang/tests/fixtures/guess_game.jac +47 -0
  126. jaclang/tests/fixtures/has_goodness.jac +15 -0
  127. jaclang/tests/fixtures/hashcheck.jac +12 -0
  128. jaclang/tests/fixtures/hashcheck_dup.jac +12 -0
  129. jaclang/tests/fixtures/hello.jac +5 -0
  130. jaclang/tests/fixtures/hello_nc.jac +5 -0
  131. jaclang/tests/fixtures/ignore.jac +43 -0
  132. jaclang/tests/fixtures/ignore_dup.jac +43 -0
  133. jaclang/tests/fixtures/impl_grab.impl.jac +4 -0
  134. jaclang/tests/fixtures/impl_grab.jac +2 -0
  135. jaclang/tests/fixtures/inherit_check.jac +33 -0
  136. jaclang/tests/fixtures/jacsamp.jac +6 -0
  137. jaclang/tests/fixtures/jp_importer.jac +17 -0
  138. jaclang/tests/fixtures/lambda.jac +6 -0
  139. jaclang/tests/fixtures/maxfail_run_test.jac +5 -0
  140. jaclang/tests/fixtures/mtest.impl.jac +6 -0
  141. jaclang/tests/fixtures/mtest.jac +6 -0
  142. jaclang/tests/fixtures/needs_import.jac +18 -0
  143. jaclang/tests/fixtures/needs_import_1.jac +6 -0
  144. jaclang/tests/fixtures/needs_import_2.jac +6 -0
  145. jaclang/tests/fixtures/needs_import_3.jac +6 -0
  146. jaclang/tests/fixtures/needs_import_dup.jac +18 -0
  147. jaclang/tests/fixtures/package_import.jac +6 -0
  148. jaclang/tests/fixtures/pyfunc.py +11 -0
  149. jaclang/tests/fixtures/pyfunc_1.py +311 -0
  150. jaclang/tests/fixtures/pyfunc_2.py +279 -0
  151. jaclang/tests/fixtures/pyfunc_3.py +310 -0
  152. jaclang/tests/fixtures/random_check.jac +62 -0
  153. jaclang/tests/fixtures/raw_byte_string.jac +18 -0
  154. jaclang/tests/fixtures/registry.jac +37 -0
  155. jaclang/tests/fixtures/run_test.jac +5 -0
  156. jaclang/tests/fixtures/semstr.jac +33 -0
  157. jaclang/tests/fixtures/simple_archs.jac +26 -0
  158. jaclang/tests/fixtures/slice_vals.jac +7 -0
  159. jaclang/tests/fixtures/sub_abil_sep.jac +15 -0
  160. jaclang/tests/fixtures/sub_abil_sep_multilev.jac +17 -0
  161. jaclang/tests/fixtures/try_finally.jac +34 -0
  162. jaclang/tests/fixtures/tupleunpack.jac +6 -0
  163. jaclang/tests/fixtures/tuplytuples.jac +8 -0
  164. jaclang/tests/fixtures/type_info.jac +15 -0
  165. jaclang/tests/fixtures/with_context.jac +30 -0
  166. jaclang/tests/fixtures/with_llm_function.jac +33 -0
  167. jaclang/tests/fixtures/with_llm_lower.jac +45 -0
  168. jaclang/tests/fixtures/with_llm_method.jac +51 -0
  169. jaclang/tests/fixtures/with_llm_type.jac +52 -0
  170. jaclang/tests/test_cli.py +239 -0
  171. jaclang/tests/test_language.py +831 -0
  172. jaclang/tests/test_man_code.py +148 -0
  173. jaclang/tests/test_reference.py +95 -0
  174. jaclang/tests/test_settings.py +46 -0
  175. jaclang/utils/helpers.py +11 -0
  176. jaclang/utils/tests/test_lang_tools.py +17 -0
  177. jaclang/utils/treeprinter.py +12 -4
  178. jaclang/vendor/__init__.py +12 -1
  179. jaclang/vendor/attr/__init__.py +134 -0
  180. jaclang/vendor/attr/__init__.pyi +555 -0
  181. jaclang/vendor/attr/_cmp.py +150 -0
  182. jaclang/vendor/attr/_cmp.pyi +13 -0
  183. jaclang/vendor/attr/_compat.py +87 -0
  184. jaclang/vendor/attr/_config.py +31 -0
  185. jaclang/vendor/attr/_funcs.py +483 -0
  186. jaclang/vendor/attr/_make.py +3119 -0
  187. jaclang/vendor/attr/_next_gen.py +229 -0
  188. jaclang/vendor/attr/_typing_compat.pyi +15 -0
  189. jaclang/vendor/attr/_version_info.py +86 -0
  190. jaclang/vendor/attr/_version_info.pyi +9 -0
  191. jaclang/vendor/attr/converters.py +144 -0
  192. jaclang/vendor/attr/converters.pyi +13 -0
  193. jaclang/vendor/attr/exceptions.py +95 -0
  194. jaclang/vendor/attr/exceptions.pyi +17 -0
  195. jaclang/vendor/attr/filters.py +66 -0
  196. jaclang/vendor/attr/filters.pyi +6 -0
  197. jaclang/vendor/attr/setters.py +73 -0
  198. jaclang/vendor/attr/setters.pyi +19 -0
  199. jaclang/vendor/attr/validators.py +681 -0
  200. jaclang/vendor/attr/validators.pyi +88 -0
  201. jaclang/vendor/attrs/__init__.py +65 -0
  202. jaclang/vendor/attrs/__init__.pyi +67 -0
  203. jaclang/vendor/attrs/converters.py +3 -0
  204. jaclang/vendor/attrs/exceptions.py +3 -0
  205. jaclang/vendor/attrs/filters.py +3 -0
  206. jaclang/vendor/attrs/py.typed +0 -0
  207. jaclang/vendor/attrs/setters.py +3 -0
  208. jaclang/vendor/attrs/validators.py +3 -0
  209. jaclang/vendor/attrs-23.2.0.dist-info/METADATA +202 -0
  210. jaclang/vendor/attrs-23.2.0.dist-info/RECORD +35 -0
  211. jaclang/vendor/attrs-23.2.0.dist-info/WHEEL +4 -0
  212. jaclang/vendor/attrs-23.2.0.dist-info/licenses/LICENSE +21 -0
  213. jaclang/vendor/cattr/__init__.py +25 -0
  214. jaclang/vendor/cattr/converters.py +8 -0
  215. jaclang/vendor/cattr/disambiguators.py +3 -0
  216. jaclang/vendor/cattr/dispatch.py +3 -0
  217. jaclang/vendor/cattr/errors.py +15 -0
  218. jaclang/vendor/cattr/gen.py +21 -0
  219. jaclang/vendor/cattr/preconf/__init__.py +3 -0
  220. jaclang/vendor/cattr/preconf/bson.py +4 -0
  221. jaclang/vendor/cattr/preconf/json.py +4 -0
  222. jaclang/vendor/cattr/preconf/msgpack.py +4 -0
  223. jaclang/vendor/cattr/preconf/orjson.py +4 -0
  224. jaclang/vendor/cattr/preconf/pyyaml.py +4 -0
  225. jaclang/vendor/cattr/preconf/tomlkit.py +4 -0
  226. jaclang/vendor/cattr/preconf/ujson.py +4 -0
  227. jaclang/vendor/cattr/py.typed +0 -0
  228. jaclang/vendor/cattrs/__init__.py +55 -0
  229. jaclang/vendor/cattrs/_compat.py +465 -0
  230. jaclang/vendor/cattrs/_generics.py +22 -0
  231. jaclang/vendor/cattrs/converters.py +1101 -0
  232. jaclang/vendor/cattrs/disambiguators.py +132 -0
  233. jaclang/vendor/cattrs/dispatch.py +164 -0
  234. jaclang/vendor/cattrs/errors.py +129 -0
  235. jaclang/vendor/cattrs/fns.py +17 -0
  236. jaclang/vendor/cattrs/gen/__init__.py +890 -0
  237. jaclang/vendor/cattrs/gen/_consts.py +19 -0
  238. jaclang/vendor/cattrs/gen/_generics.py +43 -0
  239. jaclang/vendor/cattrs/gen/_lc.py +28 -0
  240. jaclang/vendor/cattrs/gen/_shared.py +51 -0
  241. jaclang/vendor/cattrs/gen/typeddicts.py +624 -0
  242. jaclang/vendor/cattrs/preconf/__init__.py +7 -0
  243. jaclang/vendor/cattrs/preconf/bson.py +107 -0
  244. jaclang/vendor/cattrs/preconf/cbor2.py +47 -0
  245. jaclang/vendor/cattrs/preconf/json.py +52 -0
  246. jaclang/vendor/cattrs/preconf/msgpack.py +51 -0
  247. jaclang/vendor/cattrs/preconf/orjson.py +82 -0
  248. jaclang/vendor/cattrs/preconf/pyyaml.py +60 -0
  249. jaclang/vendor/cattrs/preconf/tomlkit.py +85 -0
  250. jaclang/vendor/cattrs/preconf/ujson.py +52 -0
  251. jaclang/vendor/cattrs/py.typed +0 -0
  252. jaclang/vendor/cattrs/strategies/__init__.py +11 -0
  253. jaclang/vendor/cattrs/strategies/_class_methods.py +64 -0
  254. jaclang/vendor/cattrs/strategies/_subclasses.py +224 -0
  255. jaclang/vendor/cattrs/strategies/_unions.py +235 -0
  256. jaclang/vendor/cattrs/v.py +111 -0
  257. jaclang/vendor/cattrs-23.2.3.dist-info/METADATA +221 -0
  258. jaclang/vendor/cattrs-23.2.3.dist-info/RECORD +48 -0
  259. jaclang/vendor/cattrs-23.2.3.dist-info/WHEEL +4 -0
  260. jaclang/vendor/cattrs-23.2.3.dist-info/licenses/LICENSE +11 -0
  261. jaclang/vendor/lark/__init__.py +38 -38
  262. jaclang/vendor/lark/__pyinstaller/__init__.py +6 -7
  263. jaclang/vendor/lark/__pyinstaller/hook-lark.py +14 -14
  264. jaclang/vendor/lark/ast_utils.py +59 -70
  265. jaclang/vendor/lark/common.py +89 -113
  266. jaclang/vendor/lark/exceptions.py +292 -352
  267. jaclang/vendor/lark/grammar.py +130 -158
  268. jaclang/vendor/lark/grammars/common.lark +59 -59
  269. jaclang/vendor/lark/grammars/lark.lark +62 -62
  270. jaclang/vendor/lark/grammars/python.lark +302 -302
  271. jaclang/vendor/lark/grammars/unicode.lark +7 -7
  272. jaclang/vendor/lark/indenter.py +112 -118
  273. jaclang/vendor/lark/lark.py +661 -800
  274. jaclang/vendor/lark/lexer.py +678 -829
  275. jaclang/vendor/lark/load_grammar.py +1428 -1673
  276. jaclang/vendor/lark/parse_tree_builder.py +391 -466
  277. jaclang/vendor/lark/parser_frontends.py +257 -305
  278. jaclang/vendor/lark/parsers/cyk.py +340 -391
  279. jaclang/vendor/lark/parsers/earley.py +308 -385
  280. jaclang/vendor/lark/parsers/earley_common.py +42 -59
  281. jaclang/vendor/lark/parsers/earley_forest.py +810 -923
  282. jaclang/vendor/lark/parsers/grammar_analysis.py +203 -239
  283. jaclang/vendor/lark/parsers/lalr_analysis.py +332 -378
  284. jaclang/vendor/lark/parsers/lalr_interactive_parser.py +157 -171
  285. jaclang/vendor/lark/parsers/lalr_parser.py +122 -145
  286. jaclang/vendor/lark/parsers/lalr_parser_state.py +110 -141
  287. jaclang/vendor/lark/parsers/xearley.py +165 -209
  288. jaclang/vendor/lark/reconstruct.py +107 -131
  289. jaclang/vendor/lark/tools/__init__.py +71 -93
  290. jaclang/vendor/lark/tools/nearley.py +202 -240
  291. jaclang/vendor/lark/tools/serialize.py +32 -35
  292. jaclang/vendor/lark/tools/standalone.py +196 -225
  293. jaclang/vendor/lark/tree.py +272 -302
  294. jaclang/vendor/lark/tree_matcher.py +186 -194
  295. jaclang/vendor/lark/tree_templates.py +18 -26
  296. jaclang/vendor/lark/utils.py +361 -393
  297. jaclang/vendor/lark/visitors.py +593 -645
  298. jaclang/vendor/lark-1.1.9.dist-info/LICENSE +18 -0
  299. jaclang/vendor/lark-1.1.9.dist-info/METADATA +47 -0
  300. jaclang/vendor/lark-1.1.9.dist-info/RECORD +46 -0
  301. jaclang/vendor/lark-1.1.9.dist-info/WHEEL +5 -0
  302. jaclang/vendor/lark-1.1.9.dist-info/entry_points.txt +2 -0
  303. jaclang/vendor/lark-1.1.9.dist-info/top_level.txt +1 -0
  304. jaclang/vendor/lsprotocol/__init__.py +2 -0
  305. jaclang/vendor/lsprotocol/_hooks.py +1237 -0
  306. jaclang/vendor/lsprotocol/converters.py +17 -0
  307. jaclang/vendor/lsprotocol/py.typed +0 -0
  308. jaclang/vendor/lsprotocol/types.py +12898 -0
  309. jaclang/vendor/lsprotocol/validators.py +47 -0
  310. jaclang/vendor/lsprotocol-2023.0.1.dist-info/LICENSE +21 -0
  311. jaclang/vendor/lsprotocol-2023.0.1.dist-info/METADATA +65 -0
  312. jaclang/vendor/lsprotocol-2023.0.1.dist-info/RECORD +10 -0
  313. jaclang/vendor/lsprotocol-2023.0.1.dist-info/WHEEL +4 -0
  314. jaclang/vendor/mypy/api.py +1 -3
  315. jaclang/vendor/mypy/applytype.py +24 -24
  316. jaclang/vendor/mypy/argmap.py +5 -9
  317. jaclang/vendor/mypy/binder.py +11 -42
  318. jaclang/vendor/mypy/build.py +78 -260
  319. jaclang/vendor/mypy/checker.py +394 -930
  320. jaclang/vendor/mypy/checkexpr.py +210 -640
  321. jaclang/vendor/mypy/checkmember.py +44 -94
  322. jaclang/vendor/mypy/checkpattern.py +32 -104
  323. jaclang/vendor/mypy/checkstrformat.py +38 -131
  324. jaclang/vendor/mypy/config_parser.py +8 -31
  325. jaclang/vendor/mypy/constant_fold.py +1 -3
  326. jaclang/vendor/mypy/constraints.py +94 -253
  327. jaclang/vendor/mypy/copytype.py +3 -13
  328. jaclang/vendor/mypy/defaults.py +2 -4
  329. jaclang/vendor/mypy/dmypy/client.py +30 -102
  330. jaclang/vendor/mypy/dmypy_server.py +31 -118
  331. jaclang/vendor/mypy/erasetype.py +6 -18
  332. jaclang/vendor/mypy/errorcodes.py +26 -64
  333. jaclang/vendor/mypy/errors.py +23 -117
  334. jaclang/vendor/mypy/evalexpr.py +1 -3
  335. jaclang/vendor/mypy/expandtype.py +37 -40
  336. jaclang/vendor/mypy/exprtotype.py +14 -27
  337. jaclang/vendor/mypy/fastparse.py +66 -215
  338. jaclang/vendor/mypy/find_sources.py +4 -14
  339. jaclang/vendor/mypy/fixup.py +5 -10
  340. jaclang/vendor/mypy/indirection.py +1 -3
  341. jaclang/vendor/mypy/infer.py +2 -6
  342. jaclang/vendor/mypy/inspections.py +3 -13
  343. jaclang/vendor/mypy/ipc.py +7 -28
  344. jaclang/vendor/mypy/join.py +20 -39
  345. jaclang/vendor/mypy/literals.py +2 -10
  346. jaclang/vendor/mypy/main.py +39 -138
  347. jaclang/vendor/mypy/maptype.py +2 -6
  348. jaclang/vendor/mypy/meet.py +23 -77
  349. jaclang/vendor/mypy/message_registry.py +33 -88
  350. jaclang/vendor/mypy/messages.py +146 -447
  351. jaclang/vendor/mypy/metastore.py +2 -6
  352. jaclang/vendor/mypy/modulefinder.py +29 -76
  353. jaclang/vendor/mypy/moduleinspect.py +5 -17
  354. jaclang/vendor/mypy/mro.py +1 -3
  355. jaclang/vendor/mypy/nodes.py +35 -119
  356. jaclang/vendor/mypy/operators.py +2 -11
  357. jaclang/vendor/mypy/options.py +3 -9
  358. jaclang/vendor/mypy/parse.py +1 -3
  359. jaclang/vendor/mypy/plugin.py +25 -75
  360. jaclang/vendor/mypy/plugins/attrs.py +53 -119
  361. jaclang/vendor/mypy/plugins/common.py +9 -29
  362. jaclang/vendor/mypy/plugins/ctypes.py +5 -15
  363. jaclang/vendor/mypy/plugins/dataclasses.py +42 -107
  364. jaclang/vendor/mypy/plugins/default.py +26 -45
  365. jaclang/vendor/mypy/plugins/enums.py +4 -17
  366. jaclang/vendor/mypy/plugins/functools.py +2 -11
  367. jaclang/vendor/mypy/plugins/proper_plugin.py +2 -6
  368. jaclang/vendor/mypy/plugins/singledispatch.py +7 -33
  369. jaclang/vendor/mypy/reachability.py +2 -8
  370. jaclang/vendor/mypy/refinfo.py +1 -3
  371. jaclang/vendor/mypy/report.py +23 -52
  372. jaclang/vendor/mypy/semanal.py +385 -693
  373. jaclang/vendor/mypy/semanal_classprop.py +9 -34
  374. jaclang/vendor/mypy/semanal_enum.py +7 -19
  375. jaclang/vendor/mypy/semanal_infer.py +1 -3
  376. jaclang/vendor/mypy/semanal_main.py +5 -25
  377. jaclang/vendor/mypy/semanal_namedtuple.py +17 -56
  378. jaclang/vendor/mypy/semanal_newtype.py +8 -27
  379. jaclang/vendor/mypy/semanal_pass1.py +2 -6
  380. jaclang/vendor/mypy/semanal_shared.py +9 -27
  381. jaclang/vendor/mypy/semanal_typeargs.py +12 -41
  382. jaclang/vendor/mypy/semanal_typeddict.py +18 -59
  383. jaclang/vendor/mypy/server/astdiff.py +9 -34
  384. jaclang/vendor/mypy/server/astmerge.py +2 -6
  385. jaclang/vendor/mypy/server/deps.py +22 -71
  386. jaclang/vendor/mypy/server/mergecheck.py +1 -3
  387. jaclang/vendor/mypy/server/objgraph.py +2 -8
  388. jaclang/vendor/mypy/server/update.py +18 -54
  389. jaclang/vendor/mypy/solve.py +4 -17
  390. jaclang/vendor/mypy/split_namespace.py +1 -3
  391. jaclang/vendor/mypy/stats.py +6 -24
  392. jaclang/vendor/mypy/strconv.py +8 -31
  393. jaclang/vendor/mypy/stubdoc.py +8 -38
  394. jaclang/vendor/mypy/stubgen.py +79 -144
  395. jaclang/vendor/mypy/stubgenc.py +22 -69
  396. jaclang/vendor/mypy/stubtest.py +62 -167
  397. jaclang/vendor/mypy/stubutil.py +45 -61
  398. jaclang/vendor/mypy/subtypes.py +57 -133
  399. jaclang/vendor/mypy/suggestions.py +19 -53
  400. jaclang/vendor/mypy/test/data.py +13 -40
  401. jaclang/vendor/mypy/test/helpers.py +18 -43
  402. jaclang/vendor/mypy/test/meta/_pytest.py +2 -13
  403. jaclang/vendor/mypy/test/meta/test_parse_data.py +5 -9
  404. jaclang/vendor/mypy/test/meta/test_update_data.py +1 -3
  405. jaclang/vendor/mypy/test/test_find_sources.py +14 -32
  406. jaclang/vendor/mypy/test/test_ref_info.py +3 -9
  407. jaclang/vendor/mypy/test/testargs.py +1 -4
  408. jaclang/vendor/mypy/test/testcheck.py +14 -47
  409. jaclang/vendor/mypy/test/testcmdline.py +3 -14
  410. jaclang/vendor/mypy/test/testconstraints.py +8 -26
  411. jaclang/vendor/mypy/test/testdaemon.py +2 -9
  412. jaclang/vendor/mypy/test/testdeps.py +4 -12
  413. jaclang/vendor/mypy/test/testdiff.py +2 -6
  414. jaclang/vendor/mypy/test/testerrorstream.py +1 -3
  415. jaclang/vendor/mypy/test/testfinegrained.py +18 -56
  416. jaclang/vendor/mypy/test/testgraph.py +3 -18
  417. jaclang/vendor/mypy/test/testinfer.py +13 -55
  418. jaclang/vendor/mypy/test/testipc.py +3 -9
  419. jaclang/vendor/mypy/test/testmerge.py +5 -17
  420. jaclang/vendor/mypy/test/testmodulefinder.py +8 -30
  421. jaclang/vendor/mypy/test/testmypyc.py +1 -3
  422. jaclang/vendor/mypy/test/testparse.py +1 -3
  423. jaclang/vendor/mypy/test/testpep561.py +4 -13
  424. jaclang/vendor/mypy/test/testpythoneval.py +2 -6
  425. jaclang/vendor/mypy/test/testreports.py +1 -2
  426. jaclang/vendor/mypy/test/testsemanal.py +3 -10
  427. jaclang/vendor/mypy/test/testsolve.py +5 -15
  428. jaclang/vendor/mypy/test/teststubgen.py +69 -210
  429. jaclang/vendor/mypy/test/teststubtest.py +123 -163
  430. jaclang/vendor/mypy/test/testsubtypes.py +14 -34
  431. jaclang/vendor/mypy/test/testtransform.py +2 -8
  432. jaclang/vendor/mypy/test/testtypegen.py +2 -8
  433. jaclang/vendor/mypy/test/testtypes.py +77 -253
  434. jaclang/vendor/mypy/test/testutil.py +1 -3
  435. jaclang/vendor/mypy/test/typefixture.py +11 -38
  436. jaclang/vendor/mypy/test/update_data.py +4 -15
  437. jaclang/vendor/mypy/test/visitors.py +1 -9
  438. jaclang/vendor/mypy/treetransform.py +8 -25
  439. jaclang/vendor/mypy/tvar_scope.py +23 -3
  440. jaclang/vendor/mypy/type_visitor.py +3 -10
  441. jaclang/vendor/mypy/typeanal.py +183 -309
  442. jaclang/vendor/mypy/typeops.py +27 -73
  443. jaclang/vendor/mypy/types.py +77 -185
  444. jaclang/vendor/mypy/types_utils.py +7 -20
  445. jaclang/vendor/mypy/typeshed/LICENSE +237 -0
  446. jaclang/vendor/mypy/typeshed/stdlib/VERSIONS +309 -0
  447. jaclang/vendor/mypy/typeshed/stdlib/__future__.pyi +36 -0
  448. jaclang/vendor/mypy/typeshed/stdlib/__main__.pyi +3 -0
  449. jaclang/vendor/mypy/typeshed/stdlib/_ast.pyi +591 -0
  450. jaclang/vendor/mypy/typeshed/stdlib/_bisect.pyi +84 -0
  451. jaclang/vendor/mypy/typeshed/stdlib/_bootlocale.pyi +1 -0
  452. jaclang/vendor/mypy/typeshed/stdlib/_codecs.pyi +133 -0
  453. jaclang/vendor/mypy/typeshed/stdlib/_collections_abc.pyi +94 -0
  454. jaclang/vendor/mypy/typeshed/stdlib/_compat_pickle.pyi +8 -0
  455. jaclang/vendor/mypy/typeshed/stdlib/_compression.pyi +25 -0
  456. jaclang/vendor/mypy/typeshed/stdlib/_csv.pyi +90 -0
  457. jaclang/vendor/mypy/typeshed/stdlib/_ctypes.pyi +207 -0
  458. jaclang/vendor/mypy/typeshed/stdlib/_curses.pyi +566 -0
  459. jaclang/vendor/mypy/typeshed/stdlib/_decimal.pyi +281 -0
  460. jaclang/vendor/mypy/typeshed/stdlib/_dummy_thread.pyi +33 -0
  461. jaclang/vendor/mypy/typeshed/stdlib/_dummy_threading.pyi +164 -0
  462. jaclang/vendor/mypy/typeshed/stdlib/_heapq.pyi +11 -0
  463. jaclang/vendor/mypy/typeshed/stdlib/_imp.pyi +28 -0
  464. jaclang/vendor/mypy/typeshed/stdlib/_json.pyi +49 -0
  465. jaclang/vendor/mypy/typeshed/stdlib/_locale.pyi +100 -0
  466. jaclang/vendor/mypy/typeshed/stdlib/_lsprof.pyi +35 -0
  467. jaclang/vendor/mypy/typeshed/stdlib/_markupbase.pyi +16 -0
  468. jaclang/vendor/mypy/typeshed/stdlib/_msi.pyi +92 -0
  469. jaclang/vendor/mypy/typeshed/stdlib/_operator.pyi +147 -0
  470. jaclang/vendor/mypy/typeshed/stdlib/_osx_support.pyi +34 -0
  471. jaclang/vendor/mypy/typeshed/stdlib/_posixsubprocess.pyi +33 -0
  472. jaclang/vendor/mypy/typeshed/stdlib/_py_abc.pyi +14 -0
  473. jaclang/vendor/mypy/typeshed/stdlib/_pydecimal.pyi +43 -0
  474. jaclang/vendor/mypy/typeshed/stdlib/_random.pyi +12 -0
  475. jaclang/vendor/mypy/typeshed/stdlib/_sitebuiltins.pyi +16 -0
  476. jaclang/vendor/mypy/typeshed/stdlib/_socket.pyi +803 -0
  477. jaclang/vendor/mypy/typeshed/stdlib/_stat.pyi +103 -0
  478. jaclang/vendor/mypy/typeshed/stdlib/_thread.pyi +59 -0
  479. jaclang/vendor/mypy/typeshed/stdlib/_threading_local.pyi +17 -0
  480. jaclang/vendor/mypy/typeshed/stdlib/_tkinter.pyi +121 -0
  481. jaclang/vendor/mypy/typeshed/stdlib/_tracemalloc.pyi +17 -0
  482. jaclang/vendor/mypy/typeshed/stdlib/_typeshed/__init__.pyi +347 -0
  483. jaclang/vendor/mypy/typeshed/stdlib/_typeshed/dbapi.pyi +37 -0
  484. jaclang/vendor/mypy/typeshed/stdlib/_typeshed/wsgi.pyi +44 -0
  485. jaclang/vendor/mypy/typeshed/stdlib/_typeshed/xml.pyi +9 -0
  486. jaclang/vendor/mypy/typeshed/stdlib/_warnings.pyi +55 -0
  487. jaclang/vendor/mypy/typeshed/stdlib/_weakref.pyi +41 -0
  488. jaclang/vendor/mypy/typeshed/stdlib/_weakrefset.pyi +51 -0
  489. jaclang/vendor/mypy/typeshed/stdlib/_winapi.pyi +255 -0
  490. jaclang/vendor/mypy/typeshed/stdlib/abc.pyi +51 -0
  491. jaclang/vendor/mypy/typeshed/stdlib/aifc.pyi +91 -0
  492. jaclang/vendor/mypy/typeshed/stdlib/antigravity.pyi +3 -0
  493. jaclang/vendor/mypy/typeshed/stdlib/argparse.pyi +595 -0
  494. jaclang/vendor/mypy/typeshed/stdlib/array.pyi +92 -0
  495. jaclang/vendor/mypy/typeshed/stdlib/ast.pyi +277 -0
  496. jaclang/vendor/mypy/typeshed/stdlib/asynchat.pyi +21 -0
  497. jaclang/vendor/mypy/typeshed/stdlib/asyncio/__init__.pyi +41 -0
  498. jaclang/vendor/mypy/typeshed/stdlib/asyncio/base_events.pyi +440 -0
  499. jaclang/vendor/mypy/typeshed/stdlib/asyncio/base_futures.pyi +19 -0
  500. jaclang/vendor/mypy/typeshed/stdlib/asyncio/base_subprocess.pyi +63 -0
  501. jaclang/vendor/mypy/typeshed/stdlib/asyncio/base_tasks.pyi +9 -0
  502. jaclang/vendor/mypy/typeshed/stdlib/asyncio/constants.pyi +20 -0
  503. jaclang/vendor/mypy/typeshed/stdlib/asyncio/coroutines.pyi +26 -0
  504. jaclang/vendor/mypy/typeshed/stdlib/asyncio/events.pyi +580 -0
  505. jaclang/vendor/mypy/typeshed/stdlib/asyncio/exceptions.pyi +43 -0
  506. jaclang/vendor/mypy/typeshed/stdlib/asyncio/format_helpers.pyi +20 -0
  507. jaclang/vendor/mypy/typeshed/stdlib/asyncio/futures.pyi +57 -0
  508. jaclang/vendor/mypy/typeshed/stdlib/asyncio/locks.pyi +121 -0
  509. jaclang/vendor/mypy/typeshed/stdlib/asyncio/log.pyi +3 -0
  510. jaclang/vendor/mypy/typeshed/stdlib/asyncio/mixins.pyi +9 -0
  511. jaclang/vendor/mypy/typeshed/stdlib/asyncio/proactor_events.pyi +64 -0
  512. jaclang/vendor/mypy/typeshed/stdlib/asyncio/protocols.pyi +34 -0
  513. jaclang/vendor/mypy/typeshed/stdlib/asyncio/queues.pyi +47 -0
  514. jaclang/vendor/mypy/typeshed/stdlib/asyncio/runners.pyi +32 -0
  515. jaclang/vendor/mypy/typeshed/stdlib/asyncio/selector_events.pyi +8 -0
  516. jaclang/vendor/mypy/typeshed/stdlib/asyncio/sslproto.pyi +165 -0
  517. jaclang/vendor/mypy/typeshed/stdlib/asyncio/staggered.pyi +10 -0
  518. jaclang/vendor/mypy/typeshed/stdlib/asyncio/streams.pyi +153 -0
  519. jaclang/vendor/mypy/typeshed/stdlib/asyncio/subprocess.pyi +229 -0
  520. jaclang/vendor/mypy/typeshed/stdlib/asyncio/taskgroups.pyi +25 -0
  521. jaclang/vendor/mypy/typeshed/stdlib/asyncio/tasks.pyi +497 -0
  522. jaclang/vendor/mypy/typeshed/stdlib/asyncio/threads.pyi +9 -0
  523. jaclang/vendor/mypy/typeshed/stdlib/asyncio/timeouts.pyi +19 -0
  524. jaclang/vendor/mypy/typeshed/stdlib/asyncio/transports.pyi +47 -0
  525. jaclang/vendor/mypy/typeshed/stdlib/asyncio/trsock.pyi +94 -0
  526. jaclang/vendor/mypy/typeshed/stdlib/asyncio/unix_events.pyi +196 -0
  527. jaclang/vendor/mypy/typeshed/stdlib/asyncio/windows_events.pyi +85 -0
  528. jaclang/vendor/mypy/typeshed/stdlib/asyncio/windows_utils.pyi +49 -0
  529. jaclang/vendor/mypy/typeshed/stdlib/asyncore.pyi +90 -0
  530. jaclang/vendor/mypy/typeshed/stdlib/atexit.pyi +12 -0
  531. jaclang/vendor/mypy/typeshed/stdlib/audioop.pyi +43 -0
  532. jaclang/vendor/mypy/typeshed/stdlib/base64.pyi +59 -0
  533. jaclang/vendor/mypy/typeshed/stdlib/bdb.pyi +102 -0
  534. jaclang/vendor/mypy/typeshed/stdlib/binascii.pyi +36 -0
  535. jaclang/vendor/mypy/typeshed/stdlib/binhex.pyi +45 -0
  536. jaclang/vendor/mypy/typeshed/stdlib/bisect.pyi +4 -0
  537. jaclang/vendor/mypy/typeshed/stdlib/builtins.pyi +1936 -0
  538. jaclang/vendor/mypy/typeshed/stdlib/bz2.pyi +146 -0
  539. jaclang/vendor/mypy/typeshed/stdlib/cProfile.pyi +31 -0
  540. jaclang/vendor/mypy/typeshed/stdlib/calendar.pyi +208 -0
  541. jaclang/vendor/mypy/typeshed/stdlib/cgi.pyi +118 -0
  542. jaclang/vendor/mypy/typeshed/stdlib/cgitb.pyi +32 -0
  543. jaclang/vendor/mypy/typeshed/stdlib/chunk.pyi +20 -0
  544. jaclang/vendor/mypy/typeshed/stdlib/cmath.pyi +36 -0
  545. jaclang/vendor/mypy/typeshed/stdlib/cmd.pyi +45 -0
  546. jaclang/vendor/mypy/typeshed/stdlib/code.pyi +33 -0
  547. jaclang/vendor/mypy/typeshed/stdlib/codecs.pyi +285 -0
  548. jaclang/vendor/mypy/typeshed/stdlib/codeop.pyi +13 -0
  549. jaclang/vendor/mypy/typeshed/stdlib/collections/__init__.pyi +485 -0
  550. jaclang/vendor/mypy/typeshed/stdlib/collections/abc.pyi +2 -0
  551. jaclang/vendor/mypy/typeshed/stdlib/colorsys.pyi +13 -0
  552. jaclang/vendor/mypy/typeshed/stdlib/compileall.pyi +111 -0
  553. jaclang/vendor/mypy/typeshed/stdlib/concurrent/__init__.pyi +0 -0
  554. jaclang/vendor/mypy/typeshed/stdlib/concurrent/futures/__init__.pyi +32 -0
  555. jaclang/vendor/mypy/typeshed/stdlib/concurrent/futures/_base.pyi +126 -0
  556. jaclang/vendor/mypy/typeshed/stdlib/concurrent/futures/process.pyi +233 -0
  557. jaclang/vendor/mypy/typeshed/stdlib/concurrent/futures/thread.pyi +80 -0
  558. jaclang/vendor/mypy/typeshed/stdlib/configparser.pyi +313 -0
  559. jaclang/vendor/mypy/typeshed/stdlib/contextlib.pyi +208 -0
  560. jaclang/vendor/mypy/typeshed/stdlib/contextvars.pyi +63 -0
  561. jaclang/vendor/mypy/typeshed/stdlib/copy.pyi +16 -0
  562. jaclang/vendor/mypy/typeshed/stdlib/copyreg.pyi +21 -0
  563. jaclang/vendor/mypy/typeshed/stdlib/crypt.pyi +12 -0
  564. jaclang/vendor/mypy/typeshed/stdlib/csv.pyi +147 -0
  565. jaclang/vendor/mypy/typeshed/stdlib/ctypes/__init__.pyi +187 -0
  566. jaclang/vendor/mypy/typeshed/stdlib/ctypes/_endian.pyi +19 -0
  567. jaclang/vendor/mypy/typeshed/stdlib/ctypes/util.pyi +6 -0
  568. jaclang/vendor/mypy/typeshed/stdlib/ctypes/wintypes.pyi +298 -0
  569. jaclang/vendor/mypy/typeshed/stdlib/curses/__init__.pyi +22 -0
  570. jaclang/vendor/mypy/typeshed/stdlib/curses/ascii.pyi +62 -0
  571. jaclang/vendor/mypy/typeshed/stdlib/curses/has_key.pyi +1 -0
  572. jaclang/vendor/mypy/typeshed/stdlib/curses/panel.pyi +22 -0
  573. jaclang/vendor/mypy/typeshed/stdlib/curses/textpad.pyi +11 -0
  574. jaclang/vendor/mypy/typeshed/stdlib/dataclasses.pyi +315 -0
  575. jaclang/vendor/mypy/typeshed/stdlib/datetime.pyi +295 -0
  576. jaclang/vendor/mypy/typeshed/stdlib/dbm/__init__.pyi +95 -0
  577. jaclang/vendor/mypy/typeshed/stdlib/dbm/dumb.pyi +31 -0
  578. jaclang/vendor/mypy/typeshed/stdlib/dbm/gnu.pyi +41 -0
  579. jaclang/vendor/mypy/typeshed/stdlib/dbm/ndbm.pyi +37 -0
  580. jaclang/vendor/mypy/typeshed/stdlib/decimal.pyi +2 -0
  581. jaclang/vendor/mypy/typeshed/stdlib/difflib.pyi +140 -0
  582. jaclang/vendor/mypy/typeshed/stdlib/dis.pyi +144 -0
  583. jaclang/vendor/mypy/typeshed/stdlib/distutils/__init__.pyi +5 -0
  584. jaclang/vendor/mypy/typeshed/stdlib/distutils/archive_util.pyi +20 -0
  585. jaclang/vendor/mypy/typeshed/stdlib/distutils/bcppcompiler.pyi +3 -0
  586. jaclang/vendor/mypy/typeshed/stdlib/distutils/ccompiler.pyi +152 -0
  587. jaclang/vendor/mypy/typeshed/stdlib/distutils/cmd.pyi +66 -0
  588. jaclang/vendor/mypy/typeshed/stdlib/distutils/command/__init__.pyi +0 -0
  589. jaclang/vendor/mypy/typeshed/stdlib/distutils/command/bdist.pyi +25 -0
  590. jaclang/vendor/mypy/typeshed/stdlib/distutils/command/bdist_dumb.pyi +21 -0
  591. jaclang/vendor/mypy/typeshed/stdlib/distutils/command/bdist_msi.pyi +45 -0
  592. jaclang/vendor/mypy/typeshed/stdlib/distutils/command/bdist_packager.pyi +0 -0
  593. jaclang/vendor/mypy/typeshed/stdlib/distutils/command/bdist_rpm.pyi +52 -0
  594. jaclang/vendor/mypy/typeshed/stdlib/distutils/command/bdist_wininst.pyi +16 -0
  595. jaclang/vendor/mypy/typeshed/stdlib/distutils/command/build.pyi +31 -0
  596. jaclang/vendor/mypy/typeshed/stdlib/distutils/command/build_clib.pyi +27 -0
  597. jaclang/vendor/mypy/typeshed/stdlib/distutils/command/build_ext.pyi +50 -0
  598. jaclang/vendor/mypy/typeshed/stdlib/distutils/command/build_py.pyi +44 -0
  599. jaclang/vendor/mypy/typeshed/stdlib/distutils/command/build_scripts.pyi +24 -0
  600. jaclang/vendor/mypy/typeshed/stdlib/distutils/command/check.pyi +39 -0
  601. jaclang/vendor/mypy/typeshed/stdlib/distutils/command/clean.pyi +17 -0
  602. jaclang/vendor/mypy/typeshed/stdlib/distutils/command/config.pyi +83 -0
  603. jaclang/vendor/mypy/typeshed/stdlib/distutils/command/install.pyi +63 -0
  604. jaclang/vendor/mypy/typeshed/stdlib/distutils/command/install_data.pyi +19 -0
  605. jaclang/vendor/mypy/typeshed/stdlib/distutils/command/install_egg_info.pyi +18 -0
  606. jaclang/vendor/mypy/typeshed/stdlib/distutils/command/install_headers.pyi +16 -0
  607. jaclang/vendor/mypy/typeshed/stdlib/distutils/command/install_lib.pyi +25 -0
  608. jaclang/vendor/mypy/typeshed/stdlib/distutils/command/install_scripts.pyi +18 -0
  609. jaclang/vendor/mypy/typeshed/stdlib/distutils/command/register.pyi +18 -0
  610. jaclang/vendor/mypy/typeshed/stdlib/distutils/command/sdist.pyi +42 -0
  611. jaclang/vendor/mypy/typeshed/stdlib/distutils/command/upload.pyi +17 -0
  612. jaclang/vendor/mypy/typeshed/stdlib/distutils/config.pyi +17 -0
  613. jaclang/vendor/mypy/typeshed/stdlib/distutils/core.pyi +57 -0
  614. jaclang/vendor/mypy/typeshed/stdlib/distutils/cygwinccompiler.pyi +20 -0
  615. jaclang/vendor/mypy/typeshed/stdlib/distutils/debug.pyi +1 -0
  616. jaclang/vendor/mypy/typeshed/stdlib/distutils/dep_util.pyi +3 -0
  617. jaclang/vendor/mypy/typeshed/stdlib/distutils/dir_util.pyi +13 -0
  618. jaclang/vendor/mypy/typeshed/stdlib/distutils/dist.pyi +146 -0
  619. jaclang/vendor/mypy/typeshed/stdlib/distutils/errors.pyi +19 -0
  620. jaclang/vendor/mypy/typeshed/stdlib/distutils/extension.pyi +36 -0
  621. jaclang/vendor/mypy/typeshed/stdlib/distutils/fancy_getopt.pyi +34 -0
  622. jaclang/vendor/mypy/typeshed/stdlib/distutils/file_util.pyi +14 -0
  623. jaclang/vendor/mypy/typeshed/stdlib/distutils/filelist.pyi +50 -0
  624. jaclang/vendor/mypy/typeshed/stdlib/distutils/log.pyi +25 -0
  625. jaclang/vendor/mypy/typeshed/stdlib/distutils/msvccompiler.pyi +3 -0
  626. jaclang/vendor/mypy/typeshed/stdlib/distutils/spawn.pyi +2 -0
  627. jaclang/vendor/mypy/typeshed/stdlib/distutils/sysconfig.pyi +31 -0
  628. jaclang/vendor/mypy/typeshed/stdlib/distutils/text_file.pyi +21 -0
  629. jaclang/vendor/mypy/typeshed/stdlib/distutils/unixccompiler.pyi +3 -0
  630. jaclang/vendor/mypy/typeshed/stdlib/distutils/util.pyi +46 -0
  631. jaclang/vendor/mypy/typeshed/stdlib/distutils/version.pyi +36 -0
  632. jaclang/vendor/mypy/typeshed/stdlib/doctest.pyi +248 -0
  633. jaclang/vendor/mypy/typeshed/stdlib/dummy_threading.pyi +2 -0
  634. jaclang/vendor/mypy/typeshed/stdlib/email/__init__.pyi +29 -0
  635. jaclang/vendor/mypy/typeshed/stdlib/email/_header_value_parser.pyi +392 -0
  636. jaclang/vendor/mypy/typeshed/stdlib/email/_policybase.pyi +51 -0
  637. jaclang/vendor/mypy/typeshed/stdlib/email/base64mime.pyi +13 -0
  638. jaclang/vendor/mypy/typeshed/stdlib/email/charset.pyi +34 -0
  639. jaclang/vendor/mypy/typeshed/stdlib/email/contentmanager.pyi +11 -0
  640. jaclang/vendor/mypy/typeshed/stdlib/email/encoders.pyi +8 -0
  641. jaclang/vendor/mypy/typeshed/stdlib/email/errors.pyi +39 -0
  642. jaclang/vendor/mypy/typeshed/stdlib/email/feedparser.pyi +23 -0
  643. jaclang/vendor/mypy/typeshed/stdlib/email/generator.pyi +40 -0
  644. jaclang/vendor/mypy/typeshed/stdlib/email/header.pyi +31 -0
  645. jaclang/vendor/mypy/typeshed/stdlib/email/headerregistry.pyi +178 -0
  646. jaclang/vendor/mypy/typeshed/stdlib/email/iterators.pyi +12 -0
  647. jaclang/vendor/mypy/typeshed/stdlib/email/message.pyi +165 -0
  648. jaclang/vendor/mypy/typeshed/stdlib/email/mime/__init__.pyi +0 -0
  649. jaclang/vendor/mypy/typeshed/stdlib/email/mime/application.pyi +17 -0
  650. jaclang/vendor/mypy/typeshed/stdlib/email/mime/audio.pyi +17 -0
  651. jaclang/vendor/mypy/typeshed/stdlib/email/mime/base.pyi +8 -0
  652. jaclang/vendor/mypy/typeshed/stdlib/email/mime/image.pyi +17 -0
  653. jaclang/vendor/mypy/typeshed/stdlib/email/mime/message.pyi +8 -0
  654. jaclang/vendor/mypy/typeshed/stdlib/email/mime/multipart.pyi +18 -0
  655. jaclang/vendor/mypy/typeshed/stdlib/email/mime/nonmultipart.pyi +5 -0
  656. jaclang/vendor/mypy/typeshed/stdlib/email/mime/text.pyi +9 -0
  657. jaclang/vendor/mypy/typeshed/stdlib/email/parser.pyi +26 -0
  658. jaclang/vendor/mypy/typeshed/stdlib/email/policy.pyi +38 -0
  659. jaclang/vendor/mypy/typeshed/stdlib/email/quoprimime.pyi +28 -0
  660. jaclang/vendor/mypy/typeshed/stdlib/email/utils.pyi +70 -0
  661. jaclang/vendor/mypy/typeshed/stdlib/encodings/__init__.pyi +10 -0
  662. jaclang/vendor/mypy/typeshed/stdlib/encodings/utf_8.pyi +21 -0
  663. jaclang/vendor/mypy/typeshed/stdlib/encodings/utf_8_sig.pyi +22 -0
  664. jaclang/vendor/mypy/typeshed/stdlib/ensurepip/__init__.pyi +12 -0
  665. jaclang/vendor/mypy/typeshed/stdlib/enum.pyi +320 -0
  666. jaclang/vendor/mypy/typeshed/stdlib/errno.pyi +222 -0
  667. jaclang/vendor/mypy/typeshed/stdlib/faulthandler.pyi +13 -0
  668. jaclang/vendor/mypy/typeshed/stdlib/fcntl.pyi +127 -0
  669. jaclang/vendor/mypy/typeshed/stdlib/filecmp.pyi +57 -0
  670. jaclang/vendor/mypy/typeshed/stdlib/fileinput.pyi +213 -0
  671. jaclang/vendor/mypy/typeshed/stdlib/fnmatch.pyi +9 -0
  672. jaclang/vendor/mypy/typeshed/stdlib/formatter.pyi +88 -0
  673. jaclang/vendor/mypy/typeshed/stdlib/fractions.pyi +150 -0
  674. jaclang/vendor/mypy/typeshed/stdlib/ftplib.pyi +178 -0
  675. jaclang/vendor/mypy/typeshed/stdlib/functools.pyi +213 -0
  676. jaclang/vendor/mypy/typeshed/stdlib/gc.pyi +37 -0
  677. jaclang/vendor/mypy/typeshed/stdlib/genericpath.pyi +52 -0
  678. jaclang/vendor/mypy/typeshed/stdlib/getopt.pyi +11 -0
  679. jaclang/vendor/mypy/typeshed/stdlib/getpass.pyi +8 -0
  680. jaclang/vendor/mypy/typeshed/stdlib/gettext.pyi +169 -0
  681. jaclang/vendor/mypy/typeshed/stdlib/glob.pyi +42 -0
  682. jaclang/vendor/mypy/typeshed/stdlib/graphlib.pyi +28 -0
  683. jaclang/vendor/mypy/typeshed/stdlib/grp.pyi +22 -0
  684. jaclang/vendor/mypy/typeshed/stdlib/gzip.pyi +160 -0
  685. jaclang/vendor/mypy/typeshed/stdlib/hashlib.pyi +167 -0
  686. jaclang/vendor/mypy/typeshed/stdlib/heapq.pyi +17 -0
  687. jaclang/vendor/mypy/typeshed/stdlib/hmac.pyi +38 -0
  688. jaclang/vendor/mypy/typeshed/stdlib/html/__init__.pyi +6 -0
  689. jaclang/vendor/mypy/typeshed/stdlib/html/entities.pyi +6 -0
  690. jaclang/vendor/mypy/typeshed/stdlib/html/parser.pyi +34 -0
  691. jaclang/vendor/mypy/typeshed/stdlib/http/__init__.pyi +105 -0
  692. jaclang/vendor/mypy/typeshed/stdlib/http/client.pyi +259 -0
  693. jaclang/vendor/mypy/typeshed/stdlib/http/cookiejar.pyi +159 -0
  694. jaclang/vendor/mypy/typeshed/stdlib/http/cookies.pyi +60 -0
  695. jaclang/vendor/mypy/typeshed/stdlib/http/server.pyi +83 -0
  696. jaclang/vendor/mypy/typeshed/stdlib/imaplib.pyi +168 -0
  697. jaclang/vendor/mypy/typeshed/stdlib/imghdr.pyi +17 -0
  698. jaclang/vendor/mypy/typeshed/stdlib/imp.pyi +62 -0
  699. jaclang/vendor/mypy/typeshed/stdlib/importlib/__init__.pyi +24 -0
  700. jaclang/vendor/mypy/typeshed/stdlib/importlib/_abc.pyi +15 -0
  701. jaclang/vendor/mypy/typeshed/stdlib/importlib/abc.pyi +172 -0
  702. jaclang/vendor/mypy/typeshed/stdlib/importlib/machinery.pyi +179 -0
  703. jaclang/vendor/mypy/typeshed/stdlib/importlib/metadata/__init__.pyi +285 -0
  704. jaclang/vendor/mypy/typeshed/stdlib/importlib/metadata/_meta.pyi +49 -0
  705. jaclang/vendor/mypy/typeshed/stdlib/importlib/readers.pyi +68 -0
  706. jaclang/vendor/mypy/typeshed/stdlib/importlib/resources/__init__.pyi +46 -0
  707. jaclang/vendor/mypy/typeshed/stdlib/importlib/resources/abc.pyi +12 -0
  708. jaclang/vendor/mypy/typeshed/stdlib/importlib/resources/readers.pyi +14 -0
  709. jaclang/vendor/mypy/typeshed/stdlib/importlib/resources/simple.pyi +56 -0
  710. jaclang/vendor/mypy/typeshed/stdlib/importlib/simple.pyi +11 -0
  711. jaclang/vendor/mypy/typeshed/stdlib/importlib/util.pyi +43 -0
  712. jaclang/vendor/mypy/typeshed/stdlib/inspect.pyi +632 -0
  713. jaclang/vendor/mypy/typeshed/stdlib/io.pyi +238 -0
  714. jaclang/vendor/mypy/typeshed/stdlib/ipaddress.pyi +208 -0
  715. jaclang/vendor/mypy/typeshed/stdlib/itertools.pyi +273 -0
  716. jaclang/vendor/mypy/typeshed/stdlib/json/__init__.pyi +61 -0
  717. jaclang/vendor/mypy/typeshed/stdlib/json/decoder.pyi +32 -0
  718. jaclang/vendor/mypy/typeshed/stdlib/json/encoder.pyi +40 -0
  719. jaclang/vendor/mypy/typeshed/stdlib/json/tool.pyi +1 -0
  720. jaclang/vendor/mypy/typeshed/stdlib/keyword.pyi +21 -0
  721. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/__init__.pyi +0 -0
  722. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/btm_matcher.pyi +28 -0
  723. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixer_base.pyi +42 -0
  724. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/__init__.pyi +0 -0
  725. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_apply.pyi +8 -0
  726. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_asserts.pyi +10 -0
  727. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_basestring.pyi +8 -0
  728. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_buffer.pyi +8 -0
  729. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_dict.pyi +16 -0
  730. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_except.pyi +14 -0
  731. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_exec.pyi +8 -0
  732. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_execfile.pyi +8 -0
  733. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_exitfunc.pyi +13 -0
  734. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_filter.pyi +9 -0
  735. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_funcattrs.pyi +8 -0
  736. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_future.pyi +8 -0
  737. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_getcwdu.pyi +8 -0
  738. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_has_key.pyi +8 -0
  739. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_idioms.pyi +15 -0
  740. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_import.pyi +16 -0
  741. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_imports.pyi +21 -0
  742. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_imports2.pyi +6 -0
  743. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_input.pyi +11 -0
  744. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_intern.pyi +9 -0
  745. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_isinstance.pyi +8 -0
  746. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_itertools.pyi +9 -0
  747. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_itertools_imports.pyi +7 -0
  748. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_long.pyi +7 -0
  749. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_map.pyi +9 -0
  750. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_metaclass.pyi +17 -0
  751. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_methodattrs.pyi +10 -0
  752. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_ne.pyi +8 -0
  753. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_next.pyi +19 -0
  754. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_nonzero.pyi +8 -0
  755. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_numliterals.pyi +8 -0
  756. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_operator.pyi +12 -0
  757. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_paren.pyi +8 -0
  758. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_print.pyi +12 -0
  759. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_raise.pyi +8 -0
  760. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_raw_input.pyi +8 -0
  761. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_reduce.pyi +8 -0
  762. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_reload.pyi +9 -0
  763. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_renames.pyi +17 -0
  764. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_repr.pyi +8 -0
  765. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_set_literal.pyi +7 -0
  766. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_standarderror.pyi +8 -0
  767. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_sys_exc.pyi +9 -0
  768. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_throw.pyi +8 -0
  769. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_tuple_params.pyi +17 -0
  770. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_types.pyi +8 -0
  771. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_unicode.pyi +12 -0
  772. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_urllib.pyi +15 -0
  773. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_ws_comma.pyi +12 -0
  774. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_xrange.pyi +20 -0
  775. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_xreadlines.pyi +8 -0
  776. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_zip.pyi +9 -0
  777. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/main.pyi +42 -0
  778. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/pgen2/__init__.pyi +9 -0
  779. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/pgen2/driver.pyi +27 -0
  780. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/pgen2/grammar.pyi +24 -0
  781. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/pgen2/literals.pyi +7 -0
  782. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/pgen2/parse.pyi +30 -0
  783. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/pgen2/pgen.pyi +50 -0
  784. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/pgen2/token.pyi +67 -0
  785. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/pgen2/tokenize.pyi +96 -0
  786. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/pygram.pyi +114 -0
  787. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/pytree.pyi +117 -0
  788. jaclang/vendor/mypy/typeshed/stdlib/lib2to3/refactor.pyi +82 -0
  789. jaclang/vendor/mypy/typeshed/stdlib/linecache.pyi +23 -0
  790. jaclang/vendor/mypy/typeshed/stdlib/locale.pyi +152 -0
  791. jaclang/vendor/mypy/typeshed/stdlib/logging/__init__.pyi +658 -0
  792. jaclang/vendor/mypy/typeshed/stdlib/logging/config.pyi +134 -0
  793. jaclang/vendor/mypy/typeshed/stdlib/logging/handlers.pyi +275 -0
  794. jaclang/vendor/mypy/typeshed/stdlib/lzma.pyi +197 -0
  795. jaclang/vendor/mypy/typeshed/stdlib/mailbox.pyi +256 -0
  796. jaclang/vendor/mypy/typeshed/stdlib/mailcap.pyi +11 -0
  797. jaclang/vendor/mypy/typeshed/stdlib/marshal.pyi +33 -0
  798. jaclang/vendor/mypy/typeshed/stdlib/math.pyi +125 -0
  799. jaclang/vendor/mypy/typeshed/stdlib/mimetypes.pyi +46 -0
  800. jaclang/vendor/mypy/typeshed/stdlib/mmap.pyi +113 -0
  801. jaclang/vendor/mypy/typeshed/stdlib/modulefinder.pyi +66 -0
  802. jaclang/vendor/mypy/typeshed/stdlib/msilib/__init__.pyi +177 -0
  803. jaclang/vendor/mypy/typeshed/stdlib/msilib/schema.pyi +94 -0
  804. jaclang/vendor/mypy/typeshed/stdlib/msilib/sequence.pyi +13 -0
  805. jaclang/vendor/mypy/typeshed/stdlib/msilib/text.pyi +7 -0
  806. jaclang/vendor/mypy/typeshed/stdlib/msvcrt.pyi +32 -0
  807. jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/__init__.pyi +90 -0
  808. jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/connection.pyi +75 -0
  809. jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/context.pyi +189 -0
  810. jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/dummy/__init__.pyi +77 -0
  811. jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/dummy/connection.pyi +39 -0
  812. jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/forkserver.pyi +31 -0
  813. jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/heap.pyi +36 -0
  814. jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/managers.pyi +212 -0
  815. jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/pool.pyi +103 -0
  816. jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/popen_fork.pyi +23 -0
  817. jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/popen_forkserver.pyi +16 -0
  818. jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/popen_spawn_posix.pyi +20 -0
  819. jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/popen_spawn_win32.pyi +30 -0
  820. jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/process.pyi +39 -0
  821. jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/queues.pyi +41 -0
  822. jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/reduction.pyi +90 -0
  823. jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/resource_sharer.pyi +20 -0
  824. jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/resource_tracker.pyi +18 -0
  825. jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/shared_memory.pyi +40 -0
  826. jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/sharedctypes.pyi +107 -0
  827. jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/spawn.pyi +32 -0
  828. jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/synchronize.pyi +54 -0
  829. jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/util.pyi +98 -0
  830. jaclang/vendor/mypy/typeshed/stdlib/netrc.pyi +23 -0
  831. jaclang/vendor/mypy/typeshed/stdlib/nis.pyi +9 -0
  832. jaclang/vendor/mypy/typeshed/stdlib/nntplib.pyi +125 -0
  833. jaclang/vendor/mypy/typeshed/stdlib/nt.pyi +111 -0
  834. jaclang/vendor/mypy/typeshed/stdlib/ntpath.pyi +119 -0
  835. jaclang/vendor/mypy/typeshed/stdlib/nturl2path.pyi +2 -0
  836. jaclang/vendor/mypy/typeshed/stdlib/numbers.pyi +209 -0
  837. jaclang/vendor/mypy/typeshed/stdlib/opcode.pyi +59 -0
  838. jaclang/vendor/mypy/typeshed/stdlib/operator.pyi +110 -0
  839. jaclang/vendor/mypy/typeshed/stdlib/optparse.pyi +255 -0
  840. jaclang/vendor/mypy/typeshed/stdlib/os/__init__.pyi +1157 -0
  841. jaclang/vendor/mypy/typeshed/stdlib/os/path.pyi +8 -0
  842. jaclang/vendor/mypy/typeshed/stdlib/ossaudiodev.pyi +131 -0
  843. jaclang/vendor/mypy/typeshed/stdlib/parser.pyi +24 -0
  844. jaclang/vendor/mypy/typeshed/stdlib/pathlib.pyi +232 -0
  845. jaclang/vendor/mypy/typeshed/stdlib/pdb.pyi +181 -0
  846. jaclang/vendor/mypy/typeshed/stdlib/pickle.pyi +271 -0
  847. jaclang/vendor/mypy/typeshed/stdlib/pickletools.pyi +167 -0
  848. jaclang/vendor/mypy/typeshed/stdlib/pipes.pyi +16 -0
  849. jaclang/vendor/mypy/typeshed/stdlib/pkgutil.pyi +53 -0
  850. jaclang/vendor/mypy/typeshed/stdlib/platform.pyi +42 -0
  851. jaclang/vendor/mypy/typeshed/stdlib/plistlib.pyi +113 -0
  852. jaclang/vendor/mypy/typeshed/stdlib/poplib.pyi +71 -0
  853. jaclang/vendor/mypy/typeshed/stdlib/posix.pyi +361 -0
  854. jaclang/vendor/mypy/typeshed/stdlib/posixpath.pyi +161 -0
  855. jaclang/vendor/mypy/typeshed/stdlib/pprint.pyi +112 -0
  856. jaclang/vendor/mypy/typeshed/stdlib/profile.pyi +31 -0
  857. jaclang/vendor/mypy/typeshed/stdlib/pstats.pyi +80 -0
  858. jaclang/vendor/mypy/typeshed/stdlib/pty.pyi +19 -0
  859. jaclang/vendor/mypy/typeshed/stdlib/pwd.pyi +28 -0
  860. jaclang/vendor/mypy/typeshed/stdlib/py_compile.pyi +34 -0
  861. jaclang/vendor/mypy/typeshed/stdlib/pyclbr.pyi +74 -0
  862. jaclang/vendor/mypy/typeshed/stdlib/pydoc.pyi +261 -0
  863. jaclang/vendor/mypy/typeshed/stdlib/pydoc_data/__init__.pyi +0 -0
  864. jaclang/vendor/mypy/typeshed/stdlib/pydoc_data/topics.pyi +1 -0
  865. jaclang/vendor/mypy/typeshed/stdlib/pyexpat/__init__.pyi +85 -0
  866. jaclang/vendor/mypy/typeshed/stdlib/pyexpat/errors.pyi +49 -0
  867. jaclang/vendor/mypy/typeshed/stdlib/pyexpat/model.pyi +11 -0
  868. jaclang/vendor/mypy/typeshed/stdlib/queue.pyi +66 -0
  869. jaclang/vendor/mypy/typeshed/stdlib/quopri.pyi +11 -0
  870. jaclang/vendor/mypy/typeshed/stdlib/random.pyi +138 -0
  871. jaclang/vendor/mypy/typeshed/stdlib/re.pyi +290 -0
  872. jaclang/vendor/mypy/typeshed/stdlib/readline.pyi +36 -0
  873. jaclang/vendor/mypy/typeshed/stdlib/reprlib.pyi +65 -0
  874. jaclang/vendor/mypy/typeshed/stdlib/resource.pyi +94 -0
  875. jaclang/vendor/mypy/typeshed/stdlib/rlcompleter.pyi +9 -0
  876. jaclang/vendor/mypy/typeshed/stdlib/runpy.pyi +24 -0
  877. jaclang/vendor/mypy/typeshed/stdlib/sched.pyi +42 -0
  878. jaclang/vendor/mypy/typeshed/stdlib/secrets.pyi +15 -0
  879. jaclang/vendor/mypy/typeshed/stdlib/select.pyi +155 -0
  880. jaclang/vendor/mypy/typeshed/stdlib/selectors.pyi +67 -0
  881. jaclang/vendor/mypy/typeshed/stdlib/shelve.pyi +46 -0
  882. jaclang/vendor/mypy/typeshed/stdlib/shlex.pyi +63 -0
  883. jaclang/vendor/mypy/typeshed/stdlib/shutil.pyi +185 -0
  884. jaclang/vendor/mypy/typeshed/stdlib/signal.pyi +188 -0
  885. jaclang/vendor/mypy/typeshed/stdlib/site.pyi +27 -0
  886. jaclang/vendor/mypy/typeshed/stdlib/smtpd.pyi +91 -0
  887. jaclang/vendor/mypy/typeshed/stdlib/smtplib.pyi +204 -0
  888. jaclang/vendor/mypy/typeshed/stdlib/sndhdr.pyi +14 -0
  889. jaclang/vendor/mypy/typeshed/stdlib/socket.pyi +825 -0
  890. jaclang/vendor/mypy/typeshed/stdlib/socketserver.pyi +168 -0
  891. jaclang/vendor/mypy/typeshed/stdlib/spwd.pyi +41 -0
  892. jaclang/vendor/mypy/typeshed/stdlib/sqlite3/__init__.pyi +1 -0
  893. jaclang/vendor/mypy/typeshed/stdlib/sqlite3/dbapi2.pyi +551 -0
  894. jaclang/vendor/mypy/typeshed/stdlib/sre_compile.pyi +11 -0
  895. jaclang/vendor/mypy/typeshed/stdlib/sre_constants.pyi +130 -0
  896. jaclang/vendor/mypy/typeshed/stdlib/sre_parse.pyi +104 -0
  897. jaclang/vendor/mypy/typeshed/stdlib/ssl.pyi +537 -0
  898. jaclang/vendor/mypy/typeshed/stdlib/stat.pyi +1 -0
  899. jaclang/vendor/mypy/typeshed/stdlib/statistics.pyi +132 -0
  900. jaclang/vendor/mypy/typeshed/stdlib/string.pyi +83 -0
  901. jaclang/vendor/mypy/typeshed/stdlib/stringprep.pyi +27 -0
  902. jaclang/vendor/mypy/typeshed/stdlib/struct.pyi +26 -0
  903. jaclang/vendor/mypy/typeshed/stdlib/subprocess.pyi +2615 -0
  904. jaclang/vendor/mypy/typeshed/stdlib/sunau.pyi +86 -0
  905. jaclang/vendor/mypy/typeshed/stdlib/symbol.pyi +93 -0
  906. jaclang/vendor/mypy/typeshed/stdlib/symtable.pyi +58 -0
  907. jaclang/vendor/mypy/typeshed/stdlib/sys/__init__.pyi +373 -0
  908. jaclang/vendor/mypy/typeshed/stdlib/sys/_monitoring.pyi +52 -0
  909. jaclang/vendor/mypy/typeshed/stdlib/sysconfig.pyi +48 -0
  910. jaclang/vendor/mypy/typeshed/stdlib/syslog.pyi +46 -0
  911. jaclang/vendor/mypy/typeshed/stdlib/tabnanny.pyi +16 -0
  912. jaclang/vendor/mypy/typeshed/stdlib/tarfile.pyi +441 -0
  913. jaclang/vendor/mypy/typeshed/stdlib/telnetlib.pyi +122 -0
  914. jaclang/vendor/mypy/typeshed/stdlib/tempfile.pyi +477 -0
  915. jaclang/vendor/mypy/typeshed/stdlib/termios.pyi +267 -0
  916. jaclang/vendor/mypy/typeshed/stdlib/textwrap.pyi +103 -0
  917. jaclang/vendor/mypy/typeshed/stdlib/this.pyi +2 -0
  918. jaclang/vendor/mypy/typeshed/stdlib/threading.pyi +187 -0
  919. jaclang/vendor/mypy/typeshed/stdlib/time.pyi +108 -0
  920. jaclang/vendor/mypy/typeshed/stdlib/timeit.pyi +32 -0
  921. jaclang/vendor/mypy/typeshed/stdlib/tkinter/__init__.pyi +3654 -0
  922. jaclang/vendor/mypy/typeshed/stdlib/tkinter/colorchooser.pyi +20 -0
  923. jaclang/vendor/mypy/typeshed/stdlib/tkinter/commondialog.pyi +14 -0
  924. jaclang/vendor/mypy/typeshed/stdlib/tkinter/constants.pyi +80 -0
  925. jaclang/vendor/mypy/typeshed/stdlib/tkinter/dialog.pyi +16 -0
  926. jaclang/vendor/mypy/typeshed/stdlib/tkinter/dnd.pyi +20 -0
  927. jaclang/vendor/mypy/typeshed/stdlib/tkinter/filedialog.pyi +151 -0
  928. jaclang/vendor/mypy/typeshed/stdlib/tkinter/font.pyi +116 -0
  929. jaclang/vendor/mypy/typeshed/stdlib/tkinter/messagebox.pyi +44 -0
  930. jaclang/vendor/mypy/typeshed/stdlib/tkinter/scrolledtext.pyi +9 -0
  931. jaclang/vendor/mypy/typeshed/stdlib/tkinter/simpledialog.pyi +54 -0
  932. jaclang/vendor/mypy/typeshed/stdlib/tkinter/tix.pyi +299 -0
  933. jaclang/vendor/mypy/typeshed/stdlib/tkinter/ttk.pyi +1204 -0
  934. jaclang/vendor/mypy/typeshed/stdlib/token.pyi +159 -0
  935. jaclang/vendor/mypy/typeshed/stdlib/tokenize.pyi +177 -0
  936. jaclang/vendor/mypy/typeshed/stdlib/tomllib.pyi +10 -0
  937. jaclang/vendor/mypy/typeshed/stdlib/trace.pyi +79 -0
  938. jaclang/vendor/mypy/typeshed/stdlib/traceback.pyi +262 -0
  939. jaclang/vendor/mypy/typeshed/stdlib/tracemalloc.pyi +124 -0
  940. jaclang/vendor/mypy/typeshed/stdlib/tty.pyi +30 -0
  941. jaclang/vendor/mypy/typeshed/stdlib/turtle.pyi +713 -0
  942. jaclang/vendor/mypy/typeshed/stdlib/types.pyi +614 -0
  943. jaclang/vendor/mypy/typeshed/stdlib/typing.pyi +976 -0
  944. jaclang/vendor/mypy/typeshed/stdlib/typing_extensions.pyi +509 -0
  945. jaclang/vendor/mypy/typeshed/stdlib/unicodedata.pyi +73 -0
  946. jaclang/vendor/mypy/typeshed/stdlib/unittest/__init__.pyi +67 -0
  947. jaclang/vendor/mypy/typeshed/stdlib/unittest/_log.pyi +27 -0
  948. jaclang/vendor/mypy/typeshed/stdlib/unittest/async_case.pyi +21 -0
  949. jaclang/vendor/mypy/typeshed/stdlib/unittest/case.pyi +342 -0
  950. jaclang/vendor/mypy/typeshed/stdlib/unittest/loader.pyi +51 -0
  951. jaclang/vendor/mypy/typeshed/stdlib/unittest/main.pyi +69 -0
  952. jaclang/vendor/mypy/typeshed/stdlib/unittest/mock.pyi +430 -0
  953. jaclang/vendor/mypy/typeshed/stdlib/unittest/result.pyi +47 -0
  954. jaclang/vendor/mypy/typeshed/stdlib/unittest/runner.pyi +72 -0
  955. jaclang/vendor/mypy/typeshed/stdlib/unittest/signals.pyi +15 -0
  956. jaclang/vendor/mypy/typeshed/stdlib/unittest/suite.pyi +22 -0
  957. jaclang/vendor/mypy/typeshed/stdlib/unittest/util.pyi +23 -0
  958. jaclang/vendor/mypy/typeshed/stdlib/urllib/__init__.pyi +0 -0
  959. jaclang/vendor/mypy/typeshed/stdlib/urllib/error.pyi +23 -0
  960. jaclang/vendor/mypy/typeshed/stdlib/urllib/parse.pyi +210 -0
  961. jaclang/vendor/mypy/typeshed/stdlib/urllib/request.pyi +400 -0
  962. jaclang/vendor/mypy/typeshed/stdlib/urllib/response.pyi +43 -0
  963. jaclang/vendor/mypy/typeshed/stdlib/urllib/robotparser.pyi +20 -0
  964. jaclang/vendor/mypy/typeshed/stdlib/uu.pyi +13 -0
  965. jaclang/vendor/mypy/typeshed/stdlib/uuid.pyi +100 -0
  966. jaclang/vendor/mypy/typeshed/stdlib/warnings.pyi +112 -0
  967. jaclang/vendor/mypy/typeshed/stdlib/wave.pyi +85 -0
  968. jaclang/vendor/mypy/typeshed/stdlib/weakref.pyi +149 -0
  969. jaclang/vendor/mypy/typeshed/stdlib/webbrowser.pyi +74 -0
  970. jaclang/vendor/mypy/typeshed/stdlib/winreg.pyi +132 -0
  971. jaclang/vendor/mypy/typeshed/stdlib/winsound.pyi +28 -0
  972. jaclang/vendor/mypy/typeshed/stdlib/wsgiref/__init__.pyi +0 -0
  973. jaclang/vendor/mypy/typeshed/stdlib/wsgiref/handlers.pyi +91 -0
  974. jaclang/vendor/mypy/typeshed/stdlib/wsgiref/headers.pyi +26 -0
  975. jaclang/vendor/mypy/typeshed/stdlib/wsgiref/simple_server.pyi +37 -0
  976. jaclang/vendor/mypy/typeshed/stdlib/wsgiref/types.pyi +32 -0
  977. jaclang/vendor/mypy/typeshed/stdlib/wsgiref/util.pyi +24 -0
  978. jaclang/vendor/mypy/typeshed/stdlib/wsgiref/validate.pyi +50 -0
  979. jaclang/vendor/mypy/typeshed/stdlib/xdrlib.pyi +57 -0
  980. jaclang/vendor/mypy/typeshed/stdlib/xml/__init__.pyi +1 -0
  981. jaclang/vendor/mypy/typeshed/stdlib/xml/dom/NodeFilter.pyi +19 -0
  982. jaclang/vendor/mypy/typeshed/stdlib/xml/dom/__init__.pyi +69 -0
  983. jaclang/vendor/mypy/typeshed/stdlib/xml/dom/domreg.pyi +8 -0
  984. jaclang/vendor/mypy/typeshed/stdlib/xml/dom/expatbuilder.pyi +100 -0
  985. jaclang/vendor/mypy/typeshed/stdlib/xml/dom/minicompat.pyi +22 -0
  986. jaclang/vendor/mypy/typeshed/stdlib/xml/dom/minidom.pyi +404 -0
  987. jaclang/vendor/mypy/typeshed/stdlib/xml/dom/pulldom.pyi +94 -0
  988. jaclang/vendor/mypy/typeshed/stdlib/xml/dom/xmlbuilder.pyi +108 -0
  989. jaclang/vendor/mypy/typeshed/stdlib/xml/etree/ElementInclude.pyi +28 -0
  990. jaclang/vendor/mypy/typeshed/stdlib/xml/etree/ElementPath.pyi +34 -0
  991. jaclang/vendor/mypy/typeshed/stdlib/xml/etree/ElementTree.pyi +327 -0
  992. jaclang/vendor/mypy/typeshed/stdlib/xml/etree/__init__.pyi +0 -0
  993. jaclang/vendor/mypy/typeshed/stdlib/xml/etree/cElementTree.pyi +1 -0
  994. jaclang/vendor/mypy/typeshed/stdlib/xml/parsers/__init__.pyi +1 -0
  995. jaclang/vendor/mypy/typeshed/stdlib/xml/parsers/expat/__init__.pyi +1 -0
  996. jaclang/vendor/mypy/typeshed/stdlib/xml/parsers/expat/errors.pyi +1 -0
  997. jaclang/vendor/mypy/typeshed/stdlib/xml/parsers/expat/model.pyi +1 -0
  998. jaclang/vendor/mypy/typeshed/stdlib/xml/sax/__init__.pyi +25 -0
  999. jaclang/vendor/mypy/typeshed/stdlib/xml/sax/_exceptions.pyi +19 -0
  1000. jaclang/vendor/mypy/typeshed/stdlib/xml/sax/handler.pyi +55 -0
  1001. jaclang/vendor/mypy/typeshed/stdlib/xml/sax/saxutils.pyi +60 -0
  1002. jaclang/vendor/mypy/typeshed/stdlib/xml/sax/xmlreader.pyi +87 -0
  1003. jaclang/vendor/mypy/typeshed/stdlib/xmlrpc/__init__.pyi +0 -0
  1004. jaclang/vendor/mypy/typeshed/stdlib/xmlrpc/client.pyi +296 -0
  1005. jaclang/vendor/mypy/typeshed/stdlib/xmlrpc/server.pyi +143 -0
  1006. jaclang/vendor/mypy/typeshed/stdlib/xxlimited.pyi +22 -0
  1007. jaclang/vendor/mypy/typeshed/stdlib/zipapp.pyi +20 -0
  1008. jaclang/vendor/mypy/typeshed/stdlib/zipfile/__init__.pyi +306 -0
  1009. jaclang/vendor/mypy/typeshed/stdlib/zipfile/_path.pyi +95 -0
  1010. jaclang/vendor/mypy/typeshed/stdlib/zipimport.pyi +32 -0
  1011. jaclang/vendor/mypy/typeshed/stdlib/zlib.pyi +56 -0
  1012. jaclang/vendor/mypy/typeshed/stdlib/zoneinfo/__init__.pyi +38 -0
  1013. jaclang/vendor/mypy/typeshed/stubs/mypy-extensions/mypy_extensions.pyi +218 -0
  1014. jaclang/vendor/mypy/typestate.py +5 -15
  1015. jaclang/vendor/mypy/typetraverser.py +9 -3
  1016. jaclang/vendor/mypy/typevars.py +2 -8
  1017. jaclang/vendor/mypy/util.py +14 -45
  1018. jaclang/vendor/mypy/version.py +1 -19
  1019. jaclang/vendor/mypy/visitor.py +3 -9
  1020. jaclang/vendor/mypy/xml/mypy-html.css +104 -0
  1021. jaclang/vendor/mypy/xml/mypy-html.xslt +81 -0
  1022. jaclang/vendor/mypy/xml/mypy-txt.xslt +100 -0
  1023. jaclang/vendor/mypy/xml/mypy.xsd +50 -0
  1024. jaclang/vendor/mypy-1.10.0.dist-info/LICENSE +229 -0
  1025. jaclang/vendor/mypy-1.10.0.dist-info/METADATA +48 -0
  1026. jaclang/vendor/mypy-1.10.0.dist-info/RECORD +1241 -0
  1027. jaclang/vendor/mypy-1.10.0.dist-info/WHEEL +6 -0
  1028. jaclang/vendor/mypy-1.10.0.dist-info/entry_points.txt +6 -0
  1029. jaclang/vendor/mypy-1.10.0.dist-info/top_level.txt +3 -0
  1030. jaclang/vendor/mypy_extensions-1.0.0.dist-info/LICENSE +27 -0
  1031. jaclang/vendor/mypy_extensions-1.0.0.dist-info/METADATA +29 -0
  1032. jaclang/vendor/mypy_extensions-1.0.0.dist-info/RECORD +6 -0
  1033. jaclang/vendor/mypy_extensions-1.0.0.dist-info/WHEEL +5 -0
  1034. jaclang/vendor/mypy_extensions-1.0.0.dist-info/top_level.txt +1 -0
  1035. jaclang/vendor/mypy_extensions.py +21 -40
  1036. jaclang/vendor/mypyc/README.md +133 -0
  1037. jaclang/vendor/mypyc/__main__.py +1 -3
  1038. jaclang/vendor/mypyc/analysis/attrdefined.py +6 -22
  1039. jaclang/vendor/mypyc/analysis/dataflow.py +5 -3
  1040. jaclang/vendor/mypyc/analysis/ircheck.py +13 -26
  1041. jaclang/vendor/mypyc/analysis/selfleaks.py +4 -0
  1042. jaclang/vendor/mypyc/build.py +6 -19
  1043. jaclang/vendor/mypyc/codegen/emit.py +20 -73
  1044. jaclang/vendor/mypyc/codegen/emitclass.py +22 -72
  1045. jaclang/vendor/mypyc/codegen/emitfunc.py +20 -62
  1046. jaclang/vendor/mypyc/codegen/emitmodule.py +50 -117
  1047. jaclang/vendor/mypyc/codegen/emitwrapper.py +22 -78
  1048. jaclang/vendor/mypyc/codegen/literals.py +1 -3
  1049. jaclang/vendor/mypyc/common.py +1 -3
  1050. jaclang/vendor/mypyc/doc/Makefile +20 -0
  1051. jaclang/vendor/mypyc/doc/bool_operations.rst +27 -0
  1052. jaclang/vendor/mypyc/doc/compilation_units.rst +20 -0
  1053. jaclang/vendor/mypyc/doc/conf.py +59 -0
  1054. jaclang/vendor/mypyc/doc/cpython-timings.md +25 -0
  1055. jaclang/vendor/mypyc/doc/dev-intro.md +548 -0
  1056. jaclang/vendor/mypyc/doc/dict_operations.rst +59 -0
  1057. jaclang/vendor/mypyc/doc/differences_from_python.rst +332 -0
  1058. jaclang/vendor/mypyc/doc/float_operations.rst +50 -0
  1059. jaclang/vendor/mypyc/doc/future.md +42 -0
  1060. jaclang/vendor/mypyc/doc/getting_started.rst +240 -0
  1061. jaclang/vendor/mypyc/doc/index.rst +61 -0
  1062. jaclang/vendor/mypyc/doc/int_operations.rst +162 -0
  1063. jaclang/vendor/mypyc/doc/introduction.rst +150 -0
  1064. jaclang/vendor/mypyc/doc/list_operations.rst +65 -0
  1065. jaclang/vendor/mypyc/doc/make.bat +35 -0
  1066. jaclang/vendor/mypyc/doc/native_classes.rst +206 -0
  1067. jaclang/vendor/mypyc/doc/native_operations.rst +55 -0
  1068. jaclang/vendor/mypyc/doc/performance_tips_and_tricks.rst +244 -0
  1069. jaclang/vendor/mypyc/doc/set_operations.rst +47 -0
  1070. jaclang/vendor/mypyc/doc/str_operations.rst +35 -0
  1071. jaclang/vendor/mypyc/doc/tuple_operations.rst +33 -0
  1072. jaclang/vendor/mypyc/doc/using_type_annotations.rst +398 -0
  1073. jaclang/vendor/mypyc/external/googletest/LICENSE +28 -0
  1074. jaclang/vendor/mypyc/external/googletest/README.md +280 -0
  1075. jaclang/vendor/mypyc/external/googletest/include/gtest/gtest-death-test.h +294 -0
  1076. jaclang/vendor/mypyc/external/googletest/include/gtest/gtest-message.h +250 -0
  1077. jaclang/vendor/mypyc/external/googletest/include/gtest/gtest-param-test.h +1444 -0
  1078. jaclang/vendor/mypyc/external/googletest/include/gtest/gtest-param-test.h.pump +510 -0
  1079. jaclang/vendor/mypyc/external/googletest/include/gtest/gtest-printers.h +993 -0
  1080. jaclang/vendor/mypyc/external/googletest/include/gtest/gtest-spi.h +232 -0
  1081. jaclang/vendor/mypyc/external/googletest/include/gtest/gtest-test-part.h +179 -0
  1082. jaclang/vendor/mypyc/external/googletest/include/gtest/gtest-typed-test.h +263 -0
  1083. jaclang/vendor/mypyc/external/googletest/include/gtest/gtest.h +2236 -0
  1084. jaclang/vendor/mypyc/external/googletest/include/gtest/gtest_pred_impl.h +358 -0
  1085. jaclang/vendor/mypyc/external/googletest/include/gtest/gtest_prod.h +58 -0
  1086. jaclang/vendor/mypyc/external/googletest/include/gtest/internal/custom/gtest-port.h +69 -0
  1087. jaclang/vendor/mypyc/external/googletest/include/gtest/internal/custom/gtest-printers.h +42 -0
  1088. jaclang/vendor/mypyc/external/googletest/include/gtest/internal/custom/gtest.h +41 -0
  1089. jaclang/vendor/mypyc/external/googletest/include/gtest/internal/gtest-death-test-internal.h +319 -0
  1090. jaclang/vendor/mypyc/external/googletest/include/gtest/internal/gtest-filepath.h +206 -0
  1091. jaclang/vendor/mypyc/external/googletest/include/gtest/internal/gtest-internal.h +1238 -0
  1092. jaclang/vendor/mypyc/external/googletest/include/gtest/internal/gtest-linked_ptr.h +243 -0
  1093. jaclang/vendor/mypyc/external/googletest/include/gtest/internal/gtest-param-util-generated.h +5146 -0
  1094. jaclang/vendor/mypyc/external/googletest/include/gtest/internal/gtest-param-util-generated.h.pump +286 -0
  1095. jaclang/vendor/mypyc/external/googletest/include/gtest/internal/gtest-param-util.h +731 -0
  1096. jaclang/vendor/mypyc/external/googletest/include/gtest/internal/gtest-port-arch.h +93 -0
  1097. jaclang/vendor/mypyc/external/googletest/include/gtest/internal/gtest-port.h +2560 -0
  1098. jaclang/vendor/mypyc/external/googletest/include/gtest/internal/gtest-string.h +167 -0
  1099. jaclang/vendor/mypyc/external/googletest/include/gtest/internal/gtest-tuple.h +1020 -0
  1100. jaclang/vendor/mypyc/external/googletest/include/gtest/internal/gtest-tuple.h.pump +347 -0
  1101. jaclang/vendor/mypyc/external/googletest/include/gtest/internal/gtest-type-util.h +3331 -0
  1102. jaclang/vendor/mypyc/external/googletest/include/gtest/internal/gtest-type-util.h.pump +297 -0
  1103. jaclang/vendor/mypyc/external/googletest/make/Makefile +61 -0
  1104. jaclang/vendor/mypyc/external/googletest/src/gtest-all.cc +48 -0
  1105. jaclang/vendor/mypyc/external/googletest/src/gtest-death-test.cc +1342 -0
  1106. jaclang/vendor/mypyc/external/googletest/src/gtest-filepath.cc +387 -0
  1107. jaclang/vendor/mypyc/external/googletest/src/gtest-internal-inl.h +1183 -0
  1108. jaclang/vendor/mypyc/external/googletest/src/gtest-port.cc +1259 -0
  1109. jaclang/vendor/mypyc/external/googletest/src/gtest-printers.cc +373 -0
  1110. jaclang/vendor/mypyc/external/googletest/src/gtest-test-part.cc +110 -0
  1111. jaclang/vendor/mypyc/external/googletest/src/gtest-typed-test.cc +118 -0
  1112. jaclang/vendor/mypyc/external/googletest/src/gtest.cc +5388 -0
  1113. jaclang/vendor/mypyc/external/googletest/src/gtest_main.cc +38 -0
  1114. jaclang/vendor/mypyc/ir/class_ir.py +8 -24
  1115. jaclang/vendor/mypyc/ir/func_ir.py +3 -16
  1116. jaclang/vendor/mypyc/ir/module_ir.py +2 -6
  1117. jaclang/vendor/mypyc/ir/ops.py +103 -66
  1118. jaclang/vendor/mypyc/ir/pprint.py +35 -55
  1119. jaclang/vendor/mypyc/ir/rtypes.py +16 -48
  1120. jaclang/vendor/mypyc/irbuild/ast_helpers.py +4 -1
  1121. jaclang/vendor/mypyc/irbuild/builder.py +46 -148
  1122. jaclang/vendor/mypyc/irbuild/callable_class.py +5 -19
  1123. jaclang/vendor/mypyc/irbuild/classdef.py +27 -83
  1124. jaclang/vendor/mypyc/irbuild/env_class.py +3 -9
  1125. jaclang/vendor/mypyc/irbuild/expression.py +42 -100
  1126. jaclang/vendor/mypyc/irbuild/for_helpers.py +56 -105
  1127. jaclang/vendor/mypyc/irbuild/format_str_tokenizer.py +1 -4
  1128. jaclang/vendor/mypyc/irbuild/function.py +40 -132
  1129. jaclang/vendor/mypyc/irbuild/generator.py +14 -49
  1130. jaclang/vendor/mypyc/irbuild/ll_builder.py +197 -426
  1131. jaclang/vendor/mypyc/irbuild/mapper.py +2 -13
  1132. jaclang/vendor/mypyc/irbuild/match.py +11 -36
  1133. jaclang/vendor/mypyc/irbuild/nonlocalcontrol.py +2 -7
  1134. jaclang/vendor/mypyc/irbuild/prebuildvisitor.py +1 -4
  1135. jaclang/vendor/mypyc/irbuild/prepare.py +25 -83
  1136. jaclang/vendor/mypyc/irbuild/specialize.py +22 -72
  1137. jaclang/vendor/mypyc/irbuild/statement.py +30 -96
  1138. jaclang/vendor/mypyc/irbuild/targets.py +1 -3
  1139. jaclang/vendor/mypyc/irbuild/util.py +2 -8
  1140. jaclang/vendor/mypyc/irbuild/vtable.py +1 -3
  1141. jaclang/vendor/mypyc/lib-rt/CPy.h +638 -0
  1142. jaclang/vendor/mypyc/lib-rt/bytes_ops.c +143 -0
  1143. jaclang/vendor/mypyc/lib-rt/dict_ops.c +446 -0
  1144. jaclang/vendor/mypyc/lib-rt/exc_ops.c +259 -0
  1145. jaclang/vendor/mypyc/lib-rt/float_ops.c +192 -0
  1146. jaclang/vendor/mypyc/lib-rt/generic_ops.c +64 -0
  1147. jaclang/vendor/mypyc/lib-rt/getargs.c +450 -0
  1148. jaclang/vendor/mypyc/lib-rt/getargsfast.c +569 -0
  1149. jaclang/vendor/mypyc/lib-rt/init.c +13 -0
  1150. jaclang/vendor/mypyc/lib-rt/int_ops.c +803 -0
  1151. jaclang/vendor/mypyc/lib-rt/list_ops.c +335 -0
  1152. jaclang/vendor/mypyc/lib-rt/misc_ops.c +942 -0
  1153. jaclang/vendor/mypyc/lib-rt/module_shim.tmpl +18 -0
  1154. jaclang/vendor/mypyc/lib-rt/mypyc_util.h +118 -0
  1155. jaclang/vendor/mypyc/lib-rt/pythoncapi_compat.h +497 -0
  1156. jaclang/vendor/mypyc/lib-rt/pythonsupport.h +533 -0
  1157. jaclang/vendor/mypyc/lib-rt/set_ops.c +17 -0
  1158. jaclang/vendor/mypyc/lib-rt/setup.py +70 -0
  1159. jaclang/vendor/mypyc/lib-rt/str_ops.c +241 -0
  1160. jaclang/vendor/mypyc/lib-rt/test_capi.cc +585 -0
  1161. jaclang/vendor/mypyc/lib-rt/tuple_ops.c +61 -0
  1162. jaclang/vendor/mypyc/lower/__init__.py +0 -0
  1163. jaclang/vendor/mypyc/lower/int_ops.py +113 -0
  1164. jaclang/vendor/mypyc/lower/list_ops.py +45 -0
  1165. jaclang/vendor/mypyc/lower/misc_ops.py +12 -0
  1166. jaclang/vendor/mypyc/lower/registry.py +26 -0
  1167. jaclang/vendor/mypyc/options.py +1 -3
  1168. jaclang/vendor/mypyc/primitives/dict_ops.py +1 -4
  1169. jaclang/vendor/mypyc/primitives/exc_ops.py +3 -12
  1170. jaclang/vendor/mypyc/primitives/int_ops.py +22 -32
  1171. jaclang/vendor/mypyc/primitives/list_ops.py +10 -0
  1172. jaclang/vendor/mypyc/primitives/misc_ops.py +28 -22
  1173. jaclang/vendor/mypyc/primitives/registry.py +56 -19
  1174. jaclang/vendor/mypyc/primitives/set_ops.py +1 -3
  1175. jaclang/vendor/mypyc/rt_subtype.py +1 -2
  1176. jaclang/vendor/mypyc/sametype.py +2 -5
  1177. jaclang/vendor/mypyc/subtype.py +3 -12
  1178. jaclang/vendor/mypyc/test/test_alwaysdefined.py +2 -6
  1179. jaclang/vendor/mypyc/test/test_analysis.py +8 -24
  1180. jaclang/vendor/mypyc/test/test_cheader.py +12 -4
  1181. jaclang/vendor/mypyc/test/test_emit.py +4 -14
  1182. jaclang/vendor/mypyc/test/test_emitclass.py +1 -8
  1183. jaclang/vendor/mypyc/test/test_emitfunc.py +30 -77
  1184. jaclang/vendor/mypyc/test/test_emitwrapper.py +1 -3
  1185. jaclang/vendor/mypyc/test/test_exceptions.py +4 -12
  1186. jaclang/vendor/mypyc/test/test_external.py +1 -5
  1187. jaclang/vendor/mypyc/test/test_irbuild.py +2 -6
  1188. jaclang/vendor/mypyc/test/test_ircheck.py +6 -17
  1189. jaclang/vendor/mypyc/test/test_literals.py +1 -4
  1190. jaclang/vendor/mypyc/test/test_lowering.py +56 -0
  1191. jaclang/vendor/mypyc/test/test_namegen.py +1 -4
  1192. jaclang/vendor/mypyc/test/test_optimizations.py +68 -0
  1193. jaclang/vendor/mypyc/test/test_refcount.py +3 -9
  1194. jaclang/vendor/mypyc/test/test_run.py +12 -38
  1195. jaclang/vendor/mypyc/test/test_serialization.py +1 -3
  1196. jaclang/vendor/mypyc/test/test_struct.py +3 -11
  1197. jaclang/vendor/mypyc/test/test_tuplename.py +4 -13
  1198. jaclang/vendor/mypyc/test/test_typeops.py +1 -4
  1199. jaclang/vendor/mypyc/test/testutil.py +2 -6
  1200. jaclang/vendor/mypyc/test-data/alwaysdefined.test +732 -0
  1201. jaclang/vendor/mypyc/test-data/analysis.test +470 -0
  1202. jaclang/vendor/mypyc/test-data/commandline.test +245 -0
  1203. jaclang/vendor/mypyc/test-data/driver/driver.py +48 -0
  1204. jaclang/vendor/mypyc/test-data/exceptions-freq.test +125 -0
  1205. jaclang/vendor/mypyc/test-data/exceptions.test +699 -0
  1206. jaclang/vendor/mypyc/test-data/fixtures/ir.py +373 -0
  1207. jaclang/vendor/mypyc/test-data/fixtures/testutil.py +103 -0
  1208. jaclang/vendor/mypyc/test-data/fixtures/typing-full.pyi +169 -0
  1209. jaclang/vendor/mypyc/test-data/irbuild-any.test +236 -0
  1210. jaclang/vendor/mypyc/test-data/irbuild-basic.test +3399 -0
  1211. jaclang/vendor/mypyc/test-data/irbuild-bool.test +424 -0
  1212. jaclang/vendor/mypyc/test-data/irbuild-bytes.test +181 -0
  1213. jaclang/vendor/mypyc/test-data/irbuild-classes.test +1302 -0
  1214. jaclang/vendor/mypyc/test-data/irbuild-constant-fold.test +480 -0
  1215. jaclang/vendor/mypyc/test-data/irbuild-dict.test +584 -0
  1216. jaclang/vendor/mypyc/test-data/irbuild-dunders.test +215 -0
  1217. jaclang/vendor/mypyc/test-data/irbuild-float.test +497 -0
  1218. jaclang/vendor/mypyc/test-data/irbuild-generics.test +150 -0
  1219. jaclang/vendor/mypyc/test-data/irbuild-glue-methods.test +437 -0
  1220. jaclang/vendor/mypyc/test-data/irbuild-i16.test +526 -0
  1221. jaclang/vendor/mypyc/test-data/irbuild-i32.test +598 -0
  1222. jaclang/vendor/mypyc/test-data/irbuild-i64.test +2144 -0
  1223. jaclang/vendor/mypyc/test-data/irbuild-int.test +194 -0
  1224. jaclang/vendor/mypyc/test-data/irbuild-isinstance.test +109 -0
  1225. jaclang/vendor/mypyc/test-data/irbuild-lists.test +513 -0
  1226. jaclang/vendor/mypyc/test-data/irbuild-match.test +1717 -0
  1227. jaclang/vendor/mypyc/test-data/irbuild-math.test +64 -0
  1228. jaclang/vendor/mypyc/test-data/irbuild-nested.test +807 -0
  1229. jaclang/vendor/mypyc/test-data/irbuild-optional.test +536 -0
  1230. jaclang/vendor/mypyc/test-data/irbuild-set.test +806 -0
  1231. jaclang/vendor/mypyc/test-data/irbuild-singledispatch.test +257 -0
  1232. jaclang/vendor/mypyc/test-data/irbuild-statements.test +1060 -0
  1233. jaclang/vendor/mypyc/test-data/irbuild-str.test +312 -0
  1234. jaclang/vendor/mypyc/test-data/irbuild-strip-asserts.test +12 -0
  1235. jaclang/vendor/mypyc/test-data/irbuild-try.test +523 -0
  1236. jaclang/vendor/mypyc/test-data/irbuild-tuple.test +386 -0
  1237. jaclang/vendor/mypyc/test-data/irbuild-u8.test +543 -0
  1238. jaclang/vendor/mypyc/test-data/irbuild-unreachable.test +241 -0
  1239. jaclang/vendor/mypyc/test-data/irbuild-vectorcall.test +153 -0
  1240. jaclang/vendor/mypyc/test-data/lowering-int.test +377 -0
  1241. jaclang/vendor/mypyc/test-data/lowering-list.test +33 -0
  1242. jaclang/vendor/mypyc/test-data/opt-copy-propagation.test +400 -0
  1243. jaclang/vendor/mypyc/test-data/opt-flag-elimination.test +296 -0
  1244. jaclang/vendor/mypyc/test-data/refcount.test +1482 -0
  1245. jaclang/vendor/mypyc/test-data/run-async.test +173 -0
  1246. jaclang/vendor/mypyc/test-data/run-attrs.test +318 -0
  1247. jaclang/vendor/mypyc/test-data/run-bench.test +196 -0
  1248. jaclang/vendor/mypyc/test-data/run-bools.test +229 -0
  1249. jaclang/vendor/mypyc/test-data/run-bytes.test +302 -0
  1250. jaclang/vendor/mypyc/test-data/run-classes.test +2505 -0
  1251. jaclang/vendor/mypyc/test-data/run-dicts.test +334 -0
  1252. jaclang/vendor/mypyc/test-data/run-dunders.test +945 -0
  1253. jaclang/vendor/mypyc/test-data/run-exceptions.test +448 -0
  1254. jaclang/vendor/mypyc/test-data/run-floats.test +516 -0
  1255. jaclang/vendor/mypyc/test-data/run-functions.test +1310 -0
  1256. jaclang/vendor/mypyc/test-data/run-generators.test +682 -0
  1257. jaclang/vendor/mypyc/test-data/run-i16.test +338 -0
  1258. jaclang/vendor/mypyc/test-data/run-i32.test +336 -0
  1259. jaclang/vendor/mypyc/test-data/run-i64.test +1519 -0
  1260. jaclang/vendor/mypyc/test-data/run-imports.test +265 -0
  1261. jaclang/vendor/mypyc/test-data/run-integers.test +540 -0
  1262. jaclang/vendor/mypyc/test-data/run-lists.test +411 -0
  1263. jaclang/vendor/mypyc/test-data/run-loops.test +485 -0
  1264. jaclang/vendor/mypyc/test-data/run-match.test +283 -0
  1265. jaclang/vendor/mypyc/test-data/run-math.test +106 -0
  1266. jaclang/vendor/mypyc/test-data/run-misc.test +1170 -0
  1267. jaclang/vendor/mypyc/test-data/run-multimodule.test +887 -0
  1268. jaclang/vendor/mypyc/test-data/run-mypy-sim.test +138 -0
  1269. jaclang/vendor/mypyc/test-data/run-primitives.test +375 -0
  1270. jaclang/vendor/mypyc/test-data/run-python37.test +159 -0
  1271. jaclang/vendor/mypyc/test-data/run-python38.test +88 -0
  1272. jaclang/vendor/mypyc/test-data/run-sets.test +150 -0
  1273. jaclang/vendor/mypyc/test-data/run-singledispatch.test +698 -0
  1274. jaclang/vendor/mypyc/test-data/run-strings.test +641 -0
  1275. jaclang/vendor/mypyc/test-data/run-traits.test +411 -0
  1276. jaclang/vendor/mypyc/test-data/run-tuples.test +258 -0
  1277. jaclang/vendor/mypyc/test-data/run-u8.test +303 -0
  1278. jaclang/vendor/mypyc/transform/copy_propagation.py +94 -0
  1279. jaclang/vendor/mypyc/transform/exceptions.py +1 -5
  1280. jaclang/vendor/mypyc/transform/flag_elimination.py +108 -0
  1281. jaclang/vendor/mypyc/transform/ir_transform.py +368 -0
  1282. jaclang/vendor/mypyc/transform/lower.py +33 -0
  1283. jaclang/vendor/mypyc/transform/refcount.py +7 -30
  1284. jaclang/vendor/mypyc/transform/uninit.py +4 -15
  1285. jaclang/vendor/pluggy/__init__.py +15 -11
  1286. jaclang/vendor/pluggy/_callers.py +34 -5
  1287. jaclang/vendor/pluggy/_hooks.py +35 -7
  1288. jaclang/vendor/pluggy/_manager.py +26 -3
  1289. jaclang/vendor/pluggy/_result.py +0 -15
  1290. jaclang/vendor/pluggy/_version.py +16 -0
  1291. jaclang/vendor/pluggy/_warnings.py +27 -0
  1292. jaclang/vendor/pluggy-1.5.0.dist-info/LICENSE +21 -0
  1293. jaclang/vendor/pluggy-1.5.0.dist-info/METADATA +155 -0
  1294. jaclang/vendor/pluggy-1.5.0.dist-info/RECORD +14 -0
  1295. jaclang/vendor/pluggy-1.5.0.dist-info/top_level.txt +1 -0
  1296. jaclang/vendor/pygls/__init__.py +25 -0
  1297. jaclang/vendor/pygls/capabilities.py +460 -0
  1298. jaclang/vendor/pygls/client.py +176 -0
  1299. jaclang/vendor/pygls/constants.py +26 -0
  1300. jaclang/vendor/pygls/exceptions.py +215 -0
  1301. jaclang/vendor/pygls/feature_manager.py +244 -0
  1302. jaclang/vendor/pygls/lsp/__init__.py +139 -0
  1303. jaclang/vendor/pygls/lsp/client.py +1961 -0
  1304. jaclang/vendor/pygls/progress.py +79 -0
  1305. jaclang/vendor/pygls/protocol/__init__.py +78 -0
  1306. jaclang/vendor/pygls/protocol/json_rpc.py +560 -0
  1307. jaclang/vendor/pygls/protocol/language_server.py +569 -0
  1308. jaclang/vendor/pygls/protocol/lsp_meta.py +51 -0
  1309. jaclang/vendor/pygls/py.typed +2 -0
  1310. jaclang/vendor/pygls/server.py +616 -0
  1311. jaclang/vendor/pygls/uris.py +184 -0
  1312. jaclang/vendor/pygls/workspace/__init__.py +97 -0
  1313. jaclang/vendor/pygls/workspace/position_codec.py +206 -0
  1314. jaclang/vendor/pygls/workspace/text_document.py +238 -0
  1315. jaclang/vendor/pygls/workspace/workspace.py +323 -0
  1316. jaclang/vendor/pygls-1.3.1.dist-info/LICENSE.txt +201 -0
  1317. jaclang/vendor/pygls-1.3.1.dist-info/METADATA +105 -0
  1318. jaclang/vendor/pygls-1.3.1.dist-info/RECORD +24 -0
  1319. jaclang/vendor/pygls-1.3.1.dist-info/WHEEL +4 -0
  1320. jaclang/vendor/typing_extensions-4.12.2.dist-info/LICENSE +279 -0
  1321. jaclang/vendor/typing_extensions-4.12.2.dist-info/METADATA +67 -0
  1322. jaclang/vendor/typing_extensions-4.12.2.dist-info/RECORD +5 -0
  1323. jaclang/vendor/typing_extensions-4.12.2.dist-info/WHEEL +4 -0
  1324. jaclang/vendor/typing_extensions.py +1209 -641
  1325. jaclang-0.7.0.dist-info/METADATA +98 -0
  1326. jaclang-0.7.0.dist-info/RECORD +1475 -0
  1327. jaclang-0.7.0.dist-info/WHEEL +4 -0
  1328. jaclang-0.7.0.dist-info/entry_points.txt +3 -0
  1329. jaclang/compiler/generated/jac_parser.py +0 -4069
  1330. jaclang/compiler/tests/test_workspace.py +0 -93
  1331. jaclang/compiler/workspace.py +0 -234
  1332. jaclang-0.6.1.dist-info/METADATA +0 -17
  1333. jaclang-0.6.1.dist-info/RECORD +0 -430
  1334. jaclang-0.6.1.dist-info/entry_points.txt +0 -2
  1335. jaclang-0.6.1.dist-info/top_level.txt +0 -1
  1336. /jaclang/{compiler/generated/__init__.py → vendor/attr/py.typed} +0 -0
  1337. {jaclang-0.6.1.dist-info → jaclang/vendor/pluggy-1.5.0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,3119 @@
1
+ # SPDX-License-Identifier: MIT
2
+
3
+ import contextlib
4
+ import copy
5
+ import enum
6
+ import functools
7
+ import inspect
8
+ import itertools
9
+ import linecache
10
+ import sys
11
+ import types
12
+ import typing
13
+
14
+ from operator import itemgetter
15
+
16
+ # We need to import _compat itself in addition to the _compat members to avoid
17
+ # having the thread-local in the globals here.
18
+ from . import _compat, _config, setters
19
+ from ._compat import (
20
+ PY310,
21
+ PY_3_8_PLUS,
22
+ _AnnotationExtractor,
23
+ get_generic_base,
24
+ )
25
+ from .exceptions import (
26
+ DefaultAlreadySetError,
27
+ FrozenInstanceError,
28
+ NotAnAttrsClassError,
29
+ UnannotatedAttributeError,
30
+ )
31
+
32
+
33
+ # This is used at least twice, so cache it here.
34
+ _obj_setattr = object.__setattr__
35
+ _init_converter_pat = "__attr_converter_%s"
36
+ _init_factory_pat = "__attr_factory_%s"
37
+ _classvar_prefixes = (
38
+ "typing.ClassVar",
39
+ "t.ClassVar",
40
+ "ClassVar",
41
+ "typing_extensions.ClassVar",
42
+ )
43
+ # we don't use a double-underscore prefix because that triggers
44
+ # name mangling when trying to create a slot for the field
45
+ # (when slots=True)
46
+ _hash_cache_field = "_attrs_cached_hash"
47
+
48
+ _empty_metadata_singleton = types.MappingProxyType({})
49
+
50
+ # Unique object for unequivocal getattr() defaults.
51
+ _sentinel = object()
52
+
53
+ _ng_default_on_setattr = setters.pipe(setters.convert, setters.validate)
54
+
55
+
56
+ class _Nothing(enum.Enum):
57
+ """
58
+ Sentinel to indicate the lack of a value when ``None`` is ambiguous.
59
+
60
+ If extending attrs, you can use ``typing.Literal[NOTHING]`` to show
61
+ that a value may be ``NOTHING``.
62
+
63
+ .. versionchanged:: 21.1.0 ``bool(NOTHING)`` is now False.
64
+ .. versionchanged:: 22.2.0 ``NOTHING`` is now an ``enum.Enum`` variant.
65
+ """
66
+
67
+ NOTHING = enum.auto()
68
+
69
+ def __repr__(self):
70
+ return "NOTHING"
71
+
72
+ def __bool__(self):
73
+ return False
74
+
75
+
76
+ NOTHING = _Nothing.NOTHING
77
+ """
78
+ Sentinel to indicate the lack of a value when ``None`` is ambiguous.
79
+ """
80
+
81
+
82
+ class _CacheHashWrapper(int):
83
+ """
84
+ An integer subclass that pickles / copies as None
85
+
86
+ This is used for non-slots classes with ``cache_hash=True``, to avoid
87
+ serializing a potentially (even likely) invalid hash value. Since ``None``
88
+ is the default value for uncalculated hashes, whenever this is copied,
89
+ the copy's value for the hash should automatically reset.
90
+
91
+ See GH #613 for more details.
92
+ """
93
+
94
+ def __reduce__(self, _none_constructor=type(None), _args=()): # noqa: B008
95
+ return _none_constructor, _args
96
+
97
+
98
+ def attrib(
99
+ default=NOTHING,
100
+ validator=None,
101
+ repr=True,
102
+ cmp=None,
103
+ hash=None,
104
+ init=True,
105
+ metadata=None,
106
+ type=None,
107
+ converter=None,
108
+ factory=None,
109
+ kw_only=False,
110
+ eq=None,
111
+ order=None,
112
+ on_setattr=None,
113
+ alias=None,
114
+ ):
115
+ """
116
+ Create a new attribute on a class.
117
+
118
+ .. warning::
119
+
120
+ Does *not* do anything unless the class is also decorated with `attr.s`
121
+ / `attrs.define` / and so on!
122
+
123
+ Please consider using `attrs.field` in new code (``attr.ib`` will *never*
124
+ go away, though).
125
+
126
+ :param default: A value that is used if an *attrs*-generated ``__init__``
127
+ is used and no value is passed while instantiating or the attribute is
128
+ excluded using ``init=False``.
129
+
130
+ If the value is an instance of `attrs.Factory`, its callable will be
131
+ used to construct a new value (useful for mutable data types like lists
132
+ or dicts).
133
+
134
+ If a default is not set (or set manually to `attrs.NOTHING`), a value
135
+ *must* be supplied when instantiating; otherwise a `TypeError` will be
136
+ raised.
137
+
138
+ The default can also be set using decorator notation as shown below.
139
+
140
+ .. seealso:: `defaults`
141
+
142
+ :param callable factory: Syntactic sugar for
143
+ ``default=attr.Factory(factory)``.
144
+
145
+ :param validator: `callable` that is called by *attrs*-generated
146
+ ``__init__`` methods after the instance has been initialized. They
147
+ receive the initialized instance, the :func:`~attrs.Attribute`, and the
148
+ passed value.
149
+
150
+ The return value is *not* inspected so the validator has to throw an
151
+ exception itself.
152
+
153
+ If a `list` is passed, its items are treated as validators and must all
154
+ pass.
155
+
156
+ Validators can be globally disabled and re-enabled using
157
+ `attrs.validators.get_disabled` / `attrs.validators.set_disabled`.
158
+
159
+ The validator can also be set using decorator notation as shown below.
160
+
161
+ .. seealso:: :ref:`validators`
162
+
163
+ :type validator: `callable` or a `list` of `callable`\\ s.
164
+
165
+ :param repr: Include this attribute in the generated ``__repr__`` method.
166
+ If ``True``, include the attribute; if ``False``, omit it. By default,
167
+ the built-in ``repr()`` function is used. To override how the attribute
168
+ value is formatted, pass a ``callable`` that takes a single value and
169
+ returns a string. Note that the resulting string is used as-is, i.e. it
170
+ will be used directly *instead* of calling ``repr()`` (the default).
171
+ :type repr: a `bool` or a `callable` to use a custom function.
172
+
173
+ :param eq: If ``True`` (default), include this attribute in the generated
174
+ ``__eq__`` and ``__ne__`` methods that check two instances for
175
+ equality. To override how the attribute value is compared, pass a
176
+ ``callable`` that takes a single value and returns the value to be
177
+ compared.
178
+
179
+ .. seealso:: `comparison`
180
+ :type eq: a `bool` or a `callable`.
181
+
182
+ :param order: If ``True`` (default), include this attributes in the
183
+ generated ``__lt__``, ``__le__``, ``__gt__`` and ``__ge__`` methods. To
184
+ override how the attribute value is ordered, pass a ``callable`` that
185
+ takes a single value and returns the value to be ordered.
186
+
187
+ .. seealso:: `comparison`
188
+ :type order: a `bool` or a `callable`.
189
+
190
+ :param cmp: Setting *cmp* is equivalent to setting *eq* and *order* to the
191
+ same value. Must not be mixed with *eq* or *order*.
192
+
193
+ .. seealso:: `comparison`
194
+ :type cmp: a `bool` or a `callable`.
195
+
196
+ :param bool | None hash: Include this attribute in the generated
197
+ ``__hash__`` method. If ``None`` (default), mirror *eq*'s value. This
198
+ is the correct behavior according the Python spec. Setting this value
199
+ to anything else than ``None`` is *discouraged*.
200
+
201
+ .. seealso:: `hashing`
202
+ :param bool init: Include this attribute in the generated ``__init__``
203
+ method. It is possible to set this to ``False`` and set a default
204
+ value. In that case this attributed is unconditionally initialized
205
+ with the specified default value or factory.
206
+
207
+ .. seealso:: `init`
208
+ :param callable converter: `callable` that is called by *attrs*-generated
209
+ ``__init__`` methods to convert attribute's value to the desired
210
+ format. It is given the passed-in value, and the returned value will
211
+ be used as the new value of the attribute. The value is converted
212
+ before being passed to the validator, if any.
213
+
214
+ .. seealso:: :ref:`converters`
215
+ :param dict | None metadata: An arbitrary mapping, to be used by
216
+ third-party components. See `extending-metadata`.
217
+
218
+ :param type: The type of the attribute. Nowadays, the preferred method to
219
+ specify the type is using a variable annotation (see :pep:`526`). This
220
+ argument is provided for backward compatibility. Regardless of the
221
+ approach used, the type will be stored on ``Attribute.type``.
222
+
223
+ Please note that *attrs* doesn't do anything with this metadata by
224
+ itself. You can use it as part of your own code or for `static type
225
+ checking <types>`.
226
+ :param bool kw_only: Make this attribute keyword-only in the generated
227
+ ``__init__`` (if ``init`` is ``False``, this parameter is ignored).
228
+ :param on_setattr: Allows to overwrite the *on_setattr* setting from
229
+ `attr.s`. If left `None`, the *on_setattr* value from `attr.s` is used.
230
+ Set to `attrs.setters.NO_OP` to run **no** `setattr` hooks for this
231
+ attribute -- regardless of the setting in `attr.s`.
232
+ :type on_setattr: `callable`, or a list of callables, or `None`, or
233
+ `attrs.setters.NO_OP`
234
+ :param str | None alias: Override this attribute's parameter name in the
235
+ generated ``__init__`` method. If left `None`, default to ``name``
236
+ stripped of leading underscores. See `private-attributes`.
237
+
238
+ .. versionadded:: 15.2.0 *convert*
239
+ .. versionadded:: 16.3.0 *metadata*
240
+ .. versionchanged:: 17.1.0 *validator* can be a ``list`` now.
241
+ .. versionchanged:: 17.1.0
242
+ *hash* is ``None`` and therefore mirrors *eq* by default.
243
+ .. versionadded:: 17.3.0 *type*
244
+ .. deprecated:: 17.4.0 *convert*
245
+ .. versionadded:: 17.4.0 *converter* as a replacement for the deprecated
246
+ *convert* to achieve consistency with other noun-based arguments.
247
+ .. versionadded:: 18.1.0
248
+ ``factory=f`` is syntactic sugar for ``default=attr.Factory(f)``.
249
+ .. versionadded:: 18.2.0 *kw_only*
250
+ .. versionchanged:: 19.2.0 *convert* keyword argument removed.
251
+ .. versionchanged:: 19.2.0 *repr* also accepts a custom callable.
252
+ .. deprecated:: 19.2.0 *cmp* Removal on or after 2021-06-01.
253
+ .. versionadded:: 19.2.0 *eq* and *order*
254
+ .. versionadded:: 20.1.0 *on_setattr*
255
+ .. versionchanged:: 20.3.0 *kw_only* backported to Python 2
256
+ .. versionchanged:: 21.1.0
257
+ *eq*, *order*, and *cmp* also accept a custom callable
258
+ .. versionchanged:: 21.1.0 *cmp* undeprecated
259
+ .. versionadded:: 22.2.0 *alias*
260
+ """
261
+ eq, eq_key, order, order_key = _determine_attrib_eq_order(
262
+ cmp, eq, order, True
263
+ )
264
+
265
+ if hash is not None and hash is not True and hash is not False:
266
+ msg = "Invalid value for hash. Must be True, False, or None."
267
+ raise TypeError(msg)
268
+
269
+ if factory is not None:
270
+ if default is not NOTHING:
271
+ msg = (
272
+ "The `default` and `factory` arguments are mutually exclusive."
273
+ )
274
+ raise ValueError(msg)
275
+ if not callable(factory):
276
+ msg = "The `factory` argument must be a callable."
277
+ raise ValueError(msg)
278
+ default = Factory(factory)
279
+
280
+ if metadata is None:
281
+ metadata = {}
282
+
283
+ # Apply syntactic sugar by auto-wrapping.
284
+ if isinstance(on_setattr, (list, tuple)):
285
+ on_setattr = setters.pipe(*on_setattr)
286
+
287
+ if validator and isinstance(validator, (list, tuple)):
288
+ validator = and_(*validator)
289
+
290
+ if converter and isinstance(converter, (list, tuple)):
291
+ converter = pipe(*converter)
292
+
293
+ return _CountingAttr(
294
+ default=default,
295
+ validator=validator,
296
+ repr=repr,
297
+ cmp=None,
298
+ hash=hash,
299
+ init=init,
300
+ converter=converter,
301
+ metadata=metadata,
302
+ type=type,
303
+ kw_only=kw_only,
304
+ eq=eq,
305
+ eq_key=eq_key,
306
+ order=order,
307
+ order_key=order_key,
308
+ on_setattr=on_setattr,
309
+ alias=alias,
310
+ )
311
+
312
+
313
+ def _compile_and_eval(script, globs, locs=None, filename=""):
314
+ """
315
+ "Exec" the script with the given global (globs) and local (locs) variables.
316
+ """
317
+ bytecode = compile(script, filename, "exec")
318
+ eval(bytecode, globs, locs)
319
+
320
+
321
+ def _make_method(name, script, filename, globs):
322
+ """
323
+ Create the method with the script given and return the method object.
324
+ """
325
+ locs = {}
326
+
327
+ # In order of debuggers like PDB being able to step through the code,
328
+ # we add a fake linecache entry.
329
+ count = 1
330
+ base_filename = filename
331
+ while True:
332
+ linecache_tuple = (
333
+ len(script),
334
+ None,
335
+ script.splitlines(True),
336
+ filename,
337
+ )
338
+ old_val = linecache.cache.setdefault(filename, linecache_tuple)
339
+ if old_val == linecache_tuple:
340
+ break
341
+
342
+ filename = f"{base_filename[:-1]}-{count}>"
343
+ count += 1
344
+
345
+ _compile_and_eval(script, globs, locs, filename)
346
+
347
+ return locs[name]
348
+
349
+
350
+ def _make_attr_tuple_class(cls_name, attr_names):
351
+ """
352
+ Create a tuple subclass to hold `Attribute`s for an `attrs` class.
353
+
354
+ The subclass is a bare tuple with properties for names.
355
+
356
+ class MyClassAttributes(tuple):
357
+ __slots__ = ()
358
+ x = property(itemgetter(0))
359
+ """
360
+ attr_class_name = f"{cls_name}Attributes"
361
+ attr_class_template = [
362
+ f"class {attr_class_name}(tuple):",
363
+ " __slots__ = ()",
364
+ ]
365
+ if attr_names:
366
+ for i, attr_name in enumerate(attr_names):
367
+ attr_class_template.append(
368
+ f" {attr_name} = _attrs_property(_attrs_itemgetter({i}))"
369
+ )
370
+ else:
371
+ attr_class_template.append(" pass")
372
+ globs = {"_attrs_itemgetter": itemgetter, "_attrs_property": property}
373
+ _compile_and_eval("\n".join(attr_class_template), globs)
374
+ return globs[attr_class_name]
375
+
376
+
377
+ # Tuple class for extracted attributes from a class definition.
378
+ # `base_attrs` is a subset of `attrs`.
379
+ _Attributes = _make_attr_tuple_class(
380
+ "_Attributes",
381
+ [
382
+ # all attributes to build dunder methods for
383
+ "attrs",
384
+ # attributes that have been inherited
385
+ "base_attrs",
386
+ # map inherited attributes to their originating classes
387
+ "base_attrs_map",
388
+ ],
389
+ )
390
+
391
+
392
+ def _is_class_var(annot):
393
+ """
394
+ Check whether *annot* is a typing.ClassVar.
395
+
396
+ The string comparison hack is used to avoid evaluating all string
397
+ annotations which would put attrs-based classes at a performance
398
+ disadvantage compared to plain old classes.
399
+ """
400
+ annot = str(annot)
401
+
402
+ # Annotation can be quoted.
403
+ if annot.startswith(("'", '"')) and annot.endswith(("'", '"')):
404
+ annot = annot[1:-1]
405
+
406
+ return annot.startswith(_classvar_prefixes)
407
+
408
+
409
+ def _has_own_attribute(cls, attrib_name):
410
+ """
411
+ Check whether *cls* defines *attrib_name* (and doesn't just inherit it).
412
+ """
413
+ attr = getattr(cls, attrib_name, _sentinel)
414
+ if attr is _sentinel:
415
+ return False
416
+
417
+ for base_cls in cls.__mro__[1:]:
418
+ a = getattr(base_cls, attrib_name, None)
419
+ if attr is a:
420
+ return False
421
+
422
+ return True
423
+
424
+
425
+ def _get_annotations(cls):
426
+ """
427
+ Get annotations for *cls*.
428
+ """
429
+ if _has_own_attribute(cls, "__annotations__"):
430
+ return cls.__annotations__
431
+
432
+ return {}
433
+
434
+
435
+ def _collect_base_attrs(cls, taken_attr_names):
436
+ """
437
+ Collect attr.ibs from base classes of *cls*, except *taken_attr_names*.
438
+ """
439
+ base_attrs = []
440
+ base_attr_map = {} # A dictionary of base attrs to their classes.
441
+
442
+ # Traverse the MRO and collect attributes.
443
+ for base_cls in reversed(cls.__mro__[1:-1]):
444
+ for a in getattr(base_cls, "__attrs_attrs__", []):
445
+ if a.inherited or a.name in taken_attr_names:
446
+ continue
447
+
448
+ a = a.evolve(inherited=True) # noqa: PLW2901
449
+ base_attrs.append(a)
450
+ base_attr_map[a.name] = base_cls
451
+
452
+ # For each name, only keep the freshest definition i.e. the furthest at the
453
+ # back. base_attr_map is fine because it gets overwritten with every new
454
+ # instance.
455
+ filtered = []
456
+ seen = set()
457
+ for a in reversed(base_attrs):
458
+ if a.name in seen:
459
+ continue
460
+ filtered.insert(0, a)
461
+ seen.add(a.name)
462
+
463
+ return filtered, base_attr_map
464
+
465
+
466
+ def _collect_base_attrs_broken(cls, taken_attr_names):
467
+ """
468
+ Collect attr.ibs from base classes of *cls*, except *taken_attr_names*.
469
+
470
+ N.B. *taken_attr_names* will be mutated.
471
+
472
+ Adhere to the old incorrect behavior.
473
+
474
+ Notably it collects from the front and considers inherited attributes which
475
+ leads to the buggy behavior reported in #428.
476
+ """
477
+ base_attrs = []
478
+ base_attr_map = {} # A dictionary of base attrs to their classes.
479
+
480
+ # Traverse the MRO and collect attributes.
481
+ for base_cls in cls.__mro__[1:-1]:
482
+ for a in getattr(base_cls, "__attrs_attrs__", []):
483
+ if a.name in taken_attr_names:
484
+ continue
485
+
486
+ a = a.evolve(inherited=True) # noqa: PLW2901
487
+ taken_attr_names.add(a.name)
488
+ base_attrs.append(a)
489
+ base_attr_map[a.name] = base_cls
490
+
491
+ return base_attrs, base_attr_map
492
+
493
+
494
+ def _transform_attrs(
495
+ cls, these, auto_attribs, kw_only, collect_by_mro, field_transformer
496
+ ):
497
+ """
498
+ Transform all `_CountingAttr`s on a class into `Attribute`s.
499
+
500
+ If *these* is passed, use that and don't look for them on the class.
501
+
502
+ *collect_by_mro* is True, collect them in the correct MRO order, otherwise
503
+ use the old -- incorrect -- order. See #428.
504
+
505
+ Return an `_Attributes`.
506
+ """
507
+ cd = cls.__dict__
508
+ anns = _get_annotations(cls)
509
+
510
+ if these is not None:
511
+ ca_list = list(these.items())
512
+ elif auto_attribs is True:
513
+ ca_names = {
514
+ name
515
+ for name, attr in cd.items()
516
+ if isinstance(attr, _CountingAttr)
517
+ }
518
+ ca_list = []
519
+ annot_names = set()
520
+ for attr_name, type in anns.items():
521
+ if _is_class_var(type):
522
+ continue
523
+ annot_names.add(attr_name)
524
+ a = cd.get(attr_name, NOTHING)
525
+
526
+ if not isinstance(a, _CountingAttr):
527
+ a = attrib() if a is NOTHING else attrib(default=a)
528
+ ca_list.append((attr_name, a))
529
+
530
+ unannotated = ca_names - annot_names
531
+ if len(unannotated) > 0:
532
+ raise UnannotatedAttributeError(
533
+ "The following `attr.ib`s lack a type annotation: "
534
+ + ", ".join(
535
+ sorted(unannotated, key=lambda n: cd.get(n).counter)
536
+ )
537
+ + "."
538
+ )
539
+ else:
540
+ ca_list = sorted(
541
+ (
542
+ (name, attr)
543
+ for name, attr in cd.items()
544
+ if isinstance(attr, _CountingAttr)
545
+ ),
546
+ key=lambda e: e[1].counter,
547
+ )
548
+
549
+ own_attrs = [
550
+ Attribute.from_counting_attr(
551
+ name=attr_name, ca=ca, type=anns.get(attr_name)
552
+ )
553
+ for attr_name, ca in ca_list
554
+ ]
555
+
556
+ if collect_by_mro:
557
+ base_attrs, base_attr_map = _collect_base_attrs(
558
+ cls, {a.name for a in own_attrs}
559
+ )
560
+ else:
561
+ base_attrs, base_attr_map = _collect_base_attrs_broken(
562
+ cls, {a.name for a in own_attrs}
563
+ )
564
+
565
+ if kw_only:
566
+ own_attrs = [a.evolve(kw_only=True) for a in own_attrs]
567
+ base_attrs = [a.evolve(kw_only=True) for a in base_attrs]
568
+
569
+ attrs = base_attrs + own_attrs
570
+
571
+ # Mandatory vs non-mandatory attr order only matters when they are part of
572
+ # the __init__ signature and when they aren't kw_only (which are moved to
573
+ # the end and can be mandatory or non-mandatory in any order, as they will
574
+ # be specified as keyword args anyway). Check the order of those attrs:
575
+ had_default = False
576
+ for a in (a for a in attrs if a.init is not False and a.kw_only is False):
577
+ if had_default is True and a.default is NOTHING:
578
+ msg = f"No mandatory attributes allowed after an attribute with a default value or factory. Attribute in question: {a!r}"
579
+ raise ValueError(msg)
580
+
581
+ if had_default is False and a.default is not NOTHING:
582
+ had_default = True
583
+
584
+ if field_transformer is not None:
585
+ attrs = field_transformer(cls, attrs)
586
+
587
+ # Resolve default field alias after executing field_transformer.
588
+ # This allows field_transformer to differentiate between explicit vs
589
+ # default aliases and supply their own defaults.
590
+ attrs = [
591
+ a.evolve(alias=_default_init_alias_for(a.name)) if not a.alias else a
592
+ for a in attrs
593
+ ]
594
+
595
+ # Create AttrsClass *after* applying the field_transformer since it may
596
+ # add or remove attributes!
597
+ attr_names = [a.name for a in attrs]
598
+ AttrsClass = _make_attr_tuple_class(cls.__name__, attr_names)
599
+
600
+ return _Attributes((AttrsClass(attrs), base_attrs, base_attr_map))
601
+
602
+
603
+ def _make_cached_property_getattr(
604
+ cached_properties,
605
+ original_getattr,
606
+ cls,
607
+ ):
608
+ lines = [
609
+ # Wrapped to get `__class__` into closure cell for super()
610
+ # (It will be replaced with the newly constructed class after construction).
611
+ "def wrapper():",
612
+ " __class__ = _cls",
613
+ " def __getattr__(self, item, cached_properties=cached_properties, original_getattr=original_getattr, _cached_setattr_get=_cached_setattr_get):",
614
+ " func = cached_properties.get(item)",
615
+ " if func is not None:",
616
+ " result = func(self)",
617
+ " _setter = _cached_setattr_get(self)",
618
+ " _setter(item, result)",
619
+ " return result",
620
+ ]
621
+ if original_getattr is not None:
622
+ lines.append(
623
+ " return original_getattr(self, item)",
624
+ )
625
+ else:
626
+ lines.extend(
627
+ [
628
+ " if hasattr(super(), '__getattr__'):",
629
+ " return super().__getattr__(item)",
630
+ " original_error = f\"'{self.__class__.__name__}' object has no attribute '{item}'\"",
631
+ " raise AttributeError(original_error)",
632
+ ]
633
+ )
634
+
635
+ lines.extend(
636
+ [
637
+ " return __getattr__",
638
+ "__getattr__ = wrapper()",
639
+ ]
640
+ )
641
+
642
+ unique_filename = _generate_unique_filename(cls, "getattr")
643
+
644
+ glob = {
645
+ "cached_properties": cached_properties,
646
+ "_cached_setattr_get": _obj_setattr.__get__,
647
+ "_cls": cls,
648
+ "original_getattr": original_getattr,
649
+ }
650
+
651
+ return _make_method(
652
+ "__getattr__",
653
+ "\n".join(lines),
654
+ unique_filename,
655
+ glob,
656
+ )
657
+
658
+
659
+ def _frozen_setattrs(self, name, value):
660
+ """
661
+ Attached to frozen classes as __setattr__.
662
+ """
663
+ if isinstance(self, BaseException) and name in (
664
+ "__cause__",
665
+ "__context__",
666
+ "__traceback__",
667
+ ):
668
+ BaseException.__setattr__(self, name, value)
669
+ return
670
+
671
+ raise FrozenInstanceError()
672
+
673
+
674
+ def _frozen_delattrs(self, name):
675
+ """
676
+ Attached to frozen classes as __delattr__.
677
+ """
678
+ raise FrozenInstanceError()
679
+
680
+
681
+ class _ClassBuilder:
682
+ """
683
+ Iteratively build *one* class.
684
+ """
685
+
686
+ __slots__ = (
687
+ "_attr_names",
688
+ "_attrs",
689
+ "_base_attr_map",
690
+ "_base_names",
691
+ "_cache_hash",
692
+ "_cls",
693
+ "_cls_dict",
694
+ "_delete_attribs",
695
+ "_frozen",
696
+ "_has_pre_init",
697
+ "_pre_init_has_args",
698
+ "_has_post_init",
699
+ "_is_exc",
700
+ "_on_setattr",
701
+ "_slots",
702
+ "_weakref_slot",
703
+ "_wrote_own_setattr",
704
+ "_has_custom_setattr",
705
+ )
706
+
707
+ def __init__(
708
+ self,
709
+ cls,
710
+ these,
711
+ slots,
712
+ frozen,
713
+ weakref_slot,
714
+ getstate_setstate,
715
+ auto_attribs,
716
+ kw_only,
717
+ cache_hash,
718
+ is_exc,
719
+ collect_by_mro,
720
+ on_setattr,
721
+ has_custom_setattr,
722
+ field_transformer,
723
+ ):
724
+ attrs, base_attrs, base_map = _transform_attrs(
725
+ cls,
726
+ these,
727
+ auto_attribs,
728
+ kw_only,
729
+ collect_by_mro,
730
+ field_transformer,
731
+ )
732
+
733
+ self._cls = cls
734
+ self._cls_dict = dict(cls.__dict__) if slots else {}
735
+ self._attrs = attrs
736
+ self._base_names = {a.name for a in base_attrs}
737
+ self._base_attr_map = base_map
738
+ self._attr_names = tuple(a.name for a in attrs)
739
+ self._slots = slots
740
+ self._frozen = frozen
741
+ self._weakref_slot = weakref_slot
742
+ self._cache_hash = cache_hash
743
+ self._has_pre_init = bool(getattr(cls, "__attrs_pre_init__", False))
744
+ self._pre_init_has_args = False
745
+ if self._has_pre_init:
746
+ # Check if the pre init method has more arguments than just `self`
747
+ # We want to pass arguments if pre init expects arguments
748
+ pre_init_func = cls.__attrs_pre_init__
749
+ pre_init_signature = inspect.signature(pre_init_func)
750
+ self._pre_init_has_args = len(pre_init_signature.parameters) > 1
751
+ self._has_post_init = bool(getattr(cls, "__attrs_post_init__", False))
752
+ self._delete_attribs = not bool(these)
753
+ self._is_exc = is_exc
754
+ self._on_setattr = on_setattr
755
+
756
+ self._has_custom_setattr = has_custom_setattr
757
+ self._wrote_own_setattr = False
758
+
759
+ self._cls_dict["__attrs_attrs__"] = self._attrs
760
+
761
+ if frozen:
762
+ self._cls_dict["__setattr__"] = _frozen_setattrs
763
+ self._cls_dict["__delattr__"] = _frozen_delattrs
764
+
765
+ self._wrote_own_setattr = True
766
+ elif on_setattr in (
767
+ _ng_default_on_setattr,
768
+ setters.validate,
769
+ setters.convert,
770
+ ):
771
+ has_validator = has_converter = False
772
+ for a in attrs:
773
+ if a.validator is not None:
774
+ has_validator = True
775
+ if a.converter is not None:
776
+ has_converter = True
777
+
778
+ if has_validator and has_converter:
779
+ break
780
+ if (
781
+ (
782
+ on_setattr == _ng_default_on_setattr
783
+ and not (has_validator or has_converter)
784
+ )
785
+ or (on_setattr == setters.validate and not has_validator)
786
+ or (on_setattr == setters.convert and not has_converter)
787
+ ):
788
+ # If class-level on_setattr is set to convert + validate, but
789
+ # there's no field to convert or validate, pretend like there's
790
+ # no on_setattr.
791
+ self._on_setattr = None
792
+
793
+ if getstate_setstate:
794
+ (
795
+ self._cls_dict["__getstate__"],
796
+ self._cls_dict["__setstate__"],
797
+ ) = self._make_getstate_setstate()
798
+
799
+ def __repr__(self):
800
+ return f"<_ClassBuilder(cls={self._cls.__name__})>"
801
+
802
+ if PY310:
803
+ import abc
804
+
805
+ def build_class(self):
806
+ """
807
+ Finalize class based on the accumulated configuration.
808
+
809
+ Builder cannot be used after calling this method.
810
+ """
811
+ if self._slots is True:
812
+ return self._create_slots_class()
813
+
814
+ return self.abc.update_abstractmethods(
815
+ self._patch_original_class()
816
+ )
817
+
818
+ else:
819
+
820
+ def build_class(self):
821
+ """
822
+ Finalize class based on the accumulated configuration.
823
+
824
+ Builder cannot be used after calling this method.
825
+ """
826
+ if self._slots is True:
827
+ return self._create_slots_class()
828
+
829
+ return self._patch_original_class()
830
+
831
+ def _patch_original_class(self):
832
+ """
833
+ Apply accumulated methods and return the class.
834
+ """
835
+ cls = self._cls
836
+ base_names = self._base_names
837
+
838
+ # Clean class of attribute definitions (`attr.ib()`s).
839
+ if self._delete_attribs:
840
+ for name in self._attr_names:
841
+ if (
842
+ name not in base_names
843
+ and getattr(cls, name, _sentinel) is not _sentinel
844
+ ):
845
+ # An AttributeError can happen if a base class defines a
846
+ # class variable and we want to set an attribute with the
847
+ # same name by using only a type annotation.
848
+ with contextlib.suppress(AttributeError):
849
+ delattr(cls, name)
850
+
851
+ # Attach our dunder methods.
852
+ for name, value in self._cls_dict.items():
853
+ setattr(cls, name, value)
854
+
855
+ # If we've inherited an attrs __setattr__ and don't write our own,
856
+ # reset it to object's.
857
+ if not self._wrote_own_setattr and getattr(
858
+ cls, "__attrs_own_setattr__", False
859
+ ):
860
+ cls.__attrs_own_setattr__ = False
861
+
862
+ if not self._has_custom_setattr:
863
+ cls.__setattr__ = _obj_setattr
864
+
865
+ return cls
866
+
867
+ def _create_slots_class(self):
868
+ """
869
+ Build and return a new class with a `__slots__` attribute.
870
+ """
871
+ cd = {
872
+ k: v
873
+ for k, v in self._cls_dict.items()
874
+ if k not in (*tuple(self._attr_names), "__dict__", "__weakref__")
875
+ }
876
+
877
+ # If our class doesn't have its own implementation of __setattr__
878
+ # (either from the user or by us), check the bases, if one of them has
879
+ # an attrs-made __setattr__, that needs to be reset. We don't walk the
880
+ # MRO because we only care about our immediate base classes.
881
+ # XXX: This can be confused by subclassing a slotted attrs class with
882
+ # XXX: a non-attrs class and subclass the resulting class with an attrs
883
+ # XXX: class. See `test_slotted_confused` for details. For now that's
884
+ # XXX: OK with us.
885
+ if not self._wrote_own_setattr:
886
+ cd["__attrs_own_setattr__"] = False
887
+
888
+ if not self._has_custom_setattr:
889
+ for base_cls in self._cls.__bases__:
890
+ if base_cls.__dict__.get("__attrs_own_setattr__", False):
891
+ cd["__setattr__"] = _obj_setattr
892
+ break
893
+
894
+ # Traverse the MRO to collect existing slots
895
+ # and check for an existing __weakref__.
896
+ existing_slots = {}
897
+ weakref_inherited = False
898
+ for base_cls in self._cls.__mro__[1:-1]:
899
+ if base_cls.__dict__.get("__weakref__", None) is not None:
900
+ weakref_inherited = True
901
+ existing_slots.update(
902
+ {
903
+ name: getattr(base_cls, name)
904
+ for name in getattr(base_cls, "__slots__", [])
905
+ }
906
+ )
907
+
908
+ base_names = set(self._base_names)
909
+
910
+ names = self._attr_names
911
+ if (
912
+ self._weakref_slot
913
+ and "__weakref__" not in getattr(self._cls, "__slots__", ())
914
+ and "__weakref__" not in names
915
+ and not weakref_inherited
916
+ ):
917
+ names += ("__weakref__",)
918
+
919
+ if PY_3_8_PLUS:
920
+ cached_properties = {
921
+ name: cached_property.func
922
+ for name, cached_property in cd.items()
923
+ if isinstance(cached_property, functools.cached_property)
924
+ }
925
+ else:
926
+ # `functools.cached_property` was introduced in 3.8.
927
+ # So can't be used before this.
928
+ cached_properties = {}
929
+
930
+ # Collect methods with a `__class__` reference that are shadowed in the new class.
931
+ # To know to update them.
932
+ additional_closure_functions_to_update = []
933
+ if cached_properties:
934
+ # Add cached properties to names for slotting.
935
+ names += tuple(cached_properties.keys())
936
+
937
+ for name in cached_properties:
938
+ # Clear out function from class to avoid clashing.
939
+ del cd[name]
940
+
941
+ class_annotations = _get_annotations(self._cls)
942
+ for name, func in cached_properties.items():
943
+ annotation = inspect.signature(func).return_annotation
944
+ if annotation is not inspect.Parameter.empty:
945
+ class_annotations[name] = annotation
946
+
947
+ original_getattr = cd.get("__getattr__")
948
+ if original_getattr is not None:
949
+ additional_closure_functions_to_update.append(original_getattr)
950
+
951
+ cd["__getattr__"] = _make_cached_property_getattr(
952
+ cached_properties, original_getattr, self._cls
953
+ )
954
+
955
+ # We only add the names of attributes that aren't inherited.
956
+ # Setting __slots__ to inherited attributes wastes memory.
957
+ slot_names = [name for name in names if name not in base_names]
958
+
959
+ # There are slots for attributes from current class
960
+ # that are defined in parent classes.
961
+ # As their descriptors may be overridden by a child class,
962
+ # we collect them here and update the class dict
963
+ reused_slots = {
964
+ slot: slot_descriptor
965
+ for slot, slot_descriptor in existing_slots.items()
966
+ if slot in slot_names
967
+ }
968
+ slot_names = [name for name in slot_names if name not in reused_slots]
969
+ cd.update(reused_slots)
970
+ if self._cache_hash:
971
+ slot_names.append(_hash_cache_field)
972
+
973
+ cd["__slots__"] = tuple(slot_names)
974
+
975
+ cd["__qualname__"] = self._cls.__qualname__
976
+
977
+ # Create new class based on old class and our methods.
978
+ cls = type(self._cls)(self._cls.__name__, self._cls.__bases__, cd)
979
+
980
+ # The following is a fix for
981
+ # <https://github.com/python-attrs/attrs/issues/102>.
982
+ # If a method mentions `__class__` or uses the no-arg super(), the
983
+ # compiler will bake a reference to the class in the method itself
984
+ # as `method.__closure__`. Since we replace the class with a
985
+ # clone, we rewrite these references so it keeps working.
986
+ for item in itertools.chain(
987
+ cls.__dict__.values(), additional_closure_functions_to_update
988
+ ):
989
+ if isinstance(item, (classmethod, staticmethod)):
990
+ # Class- and staticmethods hide their functions inside.
991
+ # These might need to be rewritten as well.
992
+ closure_cells = getattr(item.__func__, "__closure__", None)
993
+ elif isinstance(item, property):
994
+ # Workaround for property `super()` shortcut (PY3-only).
995
+ # There is no universal way for other descriptors.
996
+ closure_cells = getattr(item.fget, "__closure__", None)
997
+ else:
998
+ closure_cells = getattr(item, "__closure__", None)
999
+
1000
+ if not closure_cells: # Catch None or the empty list.
1001
+ continue
1002
+ for cell in closure_cells:
1003
+ try:
1004
+ match = cell.cell_contents is self._cls
1005
+ except ValueError: # noqa: PERF203
1006
+ # ValueError: Cell is empty
1007
+ pass
1008
+ else:
1009
+ if match:
1010
+ cell.cell_contents = cls
1011
+ return cls
1012
+
1013
+ def add_repr(self, ns):
1014
+ self._cls_dict["__repr__"] = self._add_method_dunders(
1015
+ _make_repr(self._attrs, ns, self._cls)
1016
+ )
1017
+ return self
1018
+
1019
+ def add_str(self):
1020
+ repr = self._cls_dict.get("__repr__")
1021
+ if repr is None:
1022
+ msg = "__str__ can only be generated if a __repr__ exists."
1023
+ raise ValueError(msg)
1024
+
1025
+ def __str__(self):
1026
+ return self.__repr__()
1027
+
1028
+ self._cls_dict["__str__"] = self._add_method_dunders(__str__)
1029
+ return self
1030
+
1031
+ def _make_getstate_setstate(self):
1032
+ """
1033
+ Create custom __setstate__ and __getstate__ methods.
1034
+ """
1035
+ # __weakref__ is not writable.
1036
+ state_attr_names = tuple(
1037
+ an for an in self._attr_names if an != "__weakref__"
1038
+ )
1039
+
1040
+ def slots_getstate(self):
1041
+ """
1042
+ Automatically created by attrs.
1043
+ """
1044
+ return {name: getattr(self, name) for name in state_attr_names}
1045
+
1046
+ hash_caching_enabled = self._cache_hash
1047
+
1048
+ def slots_setstate(self, state):
1049
+ """
1050
+ Automatically created by attrs.
1051
+ """
1052
+ __bound_setattr = _obj_setattr.__get__(self)
1053
+ if isinstance(state, tuple):
1054
+ # Backward compatibility with attrs instances pickled with
1055
+ # attrs versions before v22.2.0 which stored tuples.
1056
+ for name, value in zip(state_attr_names, state):
1057
+ __bound_setattr(name, value)
1058
+ else:
1059
+ for name in state_attr_names:
1060
+ if name in state:
1061
+ __bound_setattr(name, state[name])
1062
+
1063
+ # The hash code cache is not included when the object is
1064
+ # serialized, but it still needs to be initialized to None to
1065
+ # indicate that the first call to __hash__ should be a cache
1066
+ # miss.
1067
+ if hash_caching_enabled:
1068
+ __bound_setattr(_hash_cache_field, None)
1069
+
1070
+ return slots_getstate, slots_setstate
1071
+
1072
+ def make_unhashable(self):
1073
+ self._cls_dict["__hash__"] = None
1074
+ return self
1075
+
1076
+ def add_hash(self):
1077
+ self._cls_dict["__hash__"] = self._add_method_dunders(
1078
+ _make_hash(
1079
+ self._cls,
1080
+ self._attrs,
1081
+ frozen=self._frozen,
1082
+ cache_hash=self._cache_hash,
1083
+ )
1084
+ )
1085
+
1086
+ return self
1087
+
1088
+ def add_init(self):
1089
+ self._cls_dict["__init__"] = self._add_method_dunders(
1090
+ _make_init(
1091
+ self._cls,
1092
+ self._attrs,
1093
+ self._has_pre_init,
1094
+ self._pre_init_has_args,
1095
+ self._has_post_init,
1096
+ self._frozen,
1097
+ self._slots,
1098
+ self._cache_hash,
1099
+ self._base_attr_map,
1100
+ self._is_exc,
1101
+ self._on_setattr,
1102
+ attrs_init=False,
1103
+ )
1104
+ )
1105
+
1106
+ return self
1107
+
1108
+ def add_match_args(self):
1109
+ self._cls_dict["__match_args__"] = tuple(
1110
+ field.name
1111
+ for field in self._attrs
1112
+ if field.init and not field.kw_only
1113
+ )
1114
+
1115
+ def add_attrs_init(self):
1116
+ self._cls_dict["__attrs_init__"] = self._add_method_dunders(
1117
+ _make_init(
1118
+ self._cls,
1119
+ self._attrs,
1120
+ self._has_pre_init,
1121
+ self._pre_init_has_args,
1122
+ self._has_post_init,
1123
+ self._frozen,
1124
+ self._slots,
1125
+ self._cache_hash,
1126
+ self._base_attr_map,
1127
+ self._is_exc,
1128
+ self._on_setattr,
1129
+ attrs_init=True,
1130
+ )
1131
+ )
1132
+
1133
+ return self
1134
+
1135
+ def add_eq(self):
1136
+ cd = self._cls_dict
1137
+
1138
+ cd["__eq__"] = self._add_method_dunders(
1139
+ _make_eq(self._cls, self._attrs)
1140
+ )
1141
+ cd["__ne__"] = self._add_method_dunders(_make_ne())
1142
+
1143
+ return self
1144
+
1145
+ def add_order(self):
1146
+ cd = self._cls_dict
1147
+
1148
+ cd["__lt__"], cd["__le__"], cd["__gt__"], cd["__ge__"] = (
1149
+ self._add_method_dunders(meth)
1150
+ for meth in _make_order(self._cls, self._attrs)
1151
+ )
1152
+
1153
+ return self
1154
+
1155
+ def add_setattr(self):
1156
+ if self._frozen:
1157
+ return self
1158
+
1159
+ sa_attrs = {}
1160
+ for a in self._attrs:
1161
+ on_setattr = a.on_setattr or self._on_setattr
1162
+ if on_setattr and on_setattr is not setters.NO_OP:
1163
+ sa_attrs[a.name] = a, on_setattr
1164
+
1165
+ if not sa_attrs:
1166
+ return self
1167
+
1168
+ if self._has_custom_setattr:
1169
+ # We need to write a __setattr__ but there already is one!
1170
+ msg = "Can't combine custom __setattr__ with on_setattr hooks."
1171
+ raise ValueError(msg)
1172
+
1173
+ # docstring comes from _add_method_dunders
1174
+ def __setattr__(self, name, val):
1175
+ try:
1176
+ a, hook = sa_attrs[name]
1177
+ except KeyError:
1178
+ nval = val
1179
+ else:
1180
+ nval = hook(self, a, val)
1181
+
1182
+ _obj_setattr(self, name, nval)
1183
+
1184
+ self._cls_dict["__attrs_own_setattr__"] = True
1185
+ self._cls_dict["__setattr__"] = self._add_method_dunders(__setattr__)
1186
+ self._wrote_own_setattr = True
1187
+
1188
+ return self
1189
+
1190
+ def _add_method_dunders(self, method):
1191
+ """
1192
+ Add __module__ and __qualname__ to a *method* if possible.
1193
+ """
1194
+ with contextlib.suppress(AttributeError):
1195
+ method.__module__ = self._cls.__module__
1196
+
1197
+ with contextlib.suppress(AttributeError):
1198
+ method.__qualname__ = f"{self._cls.__qualname__}.{method.__name__}"
1199
+
1200
+ with contextlib.suppress(AttributeError):
1201
+ method.__doc__ = (
1202
+ "Method generated by attrs for class "
1203
+ f"{self._cls.__qualname__}."
1204
+ )
1205
+
1206
+ return method
1207
+
1208
+
1209
+ def _determine_attrs_eq_order(cmp, eq, order, default_eq):
1210
+ """
1211
+ Validate the combination of *cmp*, *eq*, and *order*. Derive the effective
1212
+ values of eq and order. If *eq* is None, set it to *default_eq*.
1213
+ """
1214
+ if cmp is not None and any((eq is not None, order is not None)):
1215
+ msg = "Don't mix `cmp` with `eq' and `order`."
1216
+ raise ValueError(msg)
1217
+
1218
+ # cmp takes precedence due to bw-compatibility.
1219
+ if cmp is not None:
1220
+ return cmp, cmp
1221
+
1222
+ # If left None, equality is set to the specified default and ordering
1223
+ # mirrors equality.
1224
+ if eq is None:
1225
+ eq = default_eq
1226
+
1227
+ if order is None:
1228
+ order = eq
1229
+
1230
+ if eq is False and order is True:
1231
+ msg = "`order` can only be True if `eq` is True too."
1232
+ raise ValueError(msg)
1233
+
1234
+ return eq, order
1235
+
1236
+
1237
+ def _determine_attrib_eq_order(cmp, eq, order, default_eq):
1238
+ """
1239
+ Validate the combination of *cmp*, *eq*, and *order*. Derive the effective
1240
+ values of eq and order. If *eq* is None, set it to *default_eq*.
1241
+ """
1242
+ if cmp is not None and any((eq is not None, order is not None)):
1243
+ msg = "Don't mix `cmp` with `eq' and `order`."
1244
+ raise ValueError(msg)
1245
+
1246
+ def decide_callable_or_boolean(value):
1247
+ """
1248
+ Decide whether a key function is used.
1249
+ """
1250
+ if callable(value):
1251
+ value, key = True, value
1252
+ else:
1253
+ key = None
1254
+ return value, key
1255
+
1256
+ # cmp takes precedence due to bw-compatibility.
1257
+ if cmp is not None:
1258
+ cmp, cmp_key = decide_callable_or_boolean(cmp)
1259
+ return cmp, cmp_key, cmp, cmp_key
1260
+
1261
+ # If left None, equality is set to the specified default and ordering
1262
+ # mirrors equality.
1263
+ if eq is None:
1264
+ eq, eq_key = default_eq, None
1265
+ else:
1266
+ eq, eq_key = decide_callable_or_boolean(eq)
1267
+
1268
+ if order is None:
1269
+ order, order_key = eq, eq_key
1270
+ else:
1271
+ order, order_key = decide_callable_or_boolean(order)
1272
+
1273
+ if eq is False and order is True:
1274
+ msg = "`order` can only be True if `eq` is True too."
1275
+ raise ValueError(msg)
1276
+
1277
+ return eq, eq_key, order, order_key
1278
+
1279
+
1280
+ def _determine_whether_to_implement(
1281
+ cls, flag, auto_detect, dunders, default=True
1282
+ ):
1283
+ """
1284
+ Check whether we should implement a set of methods for *cls*.
1285
+
1286
+ *flag* is the argument passed into @attr.s like 'init', *auto_detect* the
1287
+ same as passed into @attr.s and *dunders* is a tuple of attribute names
1288
+ whose presence signal that the user has implemented it themselves.
1289
+
1290
+ Return *default* if no reason for either for or against is found.
1291
+ """
1292
+ if flag is True or flag is False:
1293
+ return flag
1294
+
1295
+ if flag is None and auto_detect is False:
1296
+ return default
1297
+
1298
+ # Logically, flag is None and auto_detect is True here.
1299
+ for dunder in dunders:
1300
+ if _has_own_attribute(cls, dunder):
1301
+ return False
1302
+
1303
+ return default
1304
+
1305
+
1306
+ def attrs(
1307
+ maybe_cls=None,
1308
+ these=None,
1309
+ repr_ns=None,
1310
+ repr=None,
1311
+ cmp=None,
1312
+ hash=None,
1313
+ init=None,
1314
+ slots=False,
1315
+ frozen=False,
1316
+ weakref_slot=True,
1317
+ str=False,
1318
+ auto_attribs=False,
1319
+ kw_only=False,
1320
+ cache_hash=False,
1321
+ auto_exc=False,
1322
+ eq=None,
1323
+ order=None,
1324
+ auto_detect=False,
1325
+ collect_by_mro=False,
1326
+ getstate_setstate=None,
1327
+ on_setattr=None,
1328
+ field_transformer=None,
1329
+ match_args=True,
1330
+ unsafe_hash=None,
1331
+ ):
1332
+ r"""
1333
+ A class decorator that adds :term:`dunder methods` according to the
1334
+ specified attributes using `attr.ib` or the *these* argument.
1335
+
1336
+ Please consider using `attrs.define` / `attrs.frozen` in new code
1337
+ (``attr.s`` will *never* go away, though).
1338
+
1339
+ :param these: A dictionary of name to `attr.ib` mappings. This is useful
1340
+ to avoid the definition of your attributes within the class body
1341
+ because you can't (e.g. if you want to add ``__repr__`` methods to
1342
+ Django models) or don't want to.
1343
+
1344
+ If *these* is not ``None``, *attrs* will *not* search the class body
1345
+ for attributes and will *not* remove any attributes from it.
1346
+
1347
+ The order is deduced from the order of the attributes inside *these*.
1348
+
1349
+ :type these: `dict` of `str` to `attr.ib`
1350
+
1351
+ :param str repr_ns: When using nested classes, there's no way in Python 2
1352
+ to automatically detect that. Therefore it's possible to set the
1353
+ namespace explicitly for a more meaningful ``repr`` output.
1354
+ :param bool auto_detect: Instead of setting the *init*, *repr*, *eq*,
1355
+ *order*, and *hash* arguments explicitly, assume they are set to
1356
+ ``True`` **unless any** of the involved methods for one of the
1357
+ arguments is implemented in the *current* class (i.e. it is *not*
1358
+ inherited from some base class).
1359
+
1360
+ So for example by implementing ``__eq__`` on a class yourself, *attrs*
1361
+ will deduce ``eq=False`` and will create *neither* ``__eq__`` *nor*
1362
+ ``__ne__`` (but Python classes come with a sensible ``__ne__`` by
1363
+ default, so it *should* be enough to only implement ``__eq__`` in most
1364
+ cases).
1365
+
1366
+ .. warning::
1367
+
1368
+ If you prevent *attrs* from creating the ordering methods for you
1369
+ (``order=False``, e.g. by implementing ``__le__``), it becomes
1370
+ *your* responsibility to make sure its ordering is sound. The best
1371
+ way is to use the `functools.total_ordering` decorator.
1372
+
1373
+
1374
+ Passing ``True`` or ``False`` to *init*, *repr*, *eq*, *order*, *cmp*,
1375
+ or *hash* overrides whatever *auto_detect* would determine.
1376
+
1377
+ :param bool repr: Create a ``__repr__`` method with a human readable
1378
+ representation of *attrs* attributes..
1379
+ :param bool str: Create a ``__str__`` method that is identical to
1380
+ ``__repr__``. This is usually not necessary except for `Exception`\ s.
1381
+ :param bool | None eq: If ``True`` or ``None`` (default), add ``__eq__``
1382
+ and ``__ne__`` methods that check two instances for equality.
1383
+
1384
+ They compare the instances as if they were tuples of their *attrs*
1385
+ attributes if and only if the types of both classes are *identical*!
1386
+
1387
+ .. seealso:: `comparison`
1388
+ :param bool | None order: If ``True``, add ``__lt__``, ``__le__``,
1389
+ ``__gt__``, and ``__ge__`` methods that behave like *eq* above and
1390
+ allow instances to be ordered. If ``None`` (default) mirror value of
1391
+ *eq*.
1392
+
1393
+ .. seealso:: `comparison`
1394
+ :param bool | None cmp: Setting *cmp* is equivalent to setting *eq* and
1395
+ *order* to the same value. Must not be mixed with *eq* or *order*.
1396
+
1397
+ .. seealso:: `comparison`
1398
+ :param bool | None unsafe_hash: If ``None`` (default), the ``__hash__``
1399
+ method is generated according how *eq* and *frozen* are set.
1400
+
1401
+ 1. If *both* are True, *attrs* will generate a ``__hash__`` for you.
1402
+ 2. If *eq* is True and *frozen* is False, ``__hash__`` will be set to
1403
+ None, marking it unhashable (which it is).
1404
+ 3. If *eq* is False, ``__hash__`` will be left untouched meaning the
1405
+ ``__hash__`` method of the base class will be used (if base class is
1406
+ ``object``, this means it will fall back to id-based hashing.).
1407
+
1408
+ Although not recommended, you can decide for yourself and force *attrs*
1409
+ to create one (e.g. if the class is immutable even though you didn't
1410
+ freeze it programmatically) by passing ``True`` or not. Both of these
1411
+ cases are rather special and should be used carefully.
1412
+
1413
+ .. seealso::
1414
+
1415
+ - Our documentation on `hashing`,
1416
+ - Python's documentation on `object.__hash__`,
1417
+ - and the `GitHub issue that led to the default \
1418
+ behavior <https://github.com/python-attrs/attrs/issues/136>`_ for
1419
+ more details.
1420
+
1421
+ :param bool | None hash: Alias for *unsafe_hash*. *unsafe_hash* takes
1422
+ precedence.
1423
+ :param bool init: Create a ``__init__`` method that initializes the *attrs*
1424
+ attributes. Leading underscores are stripped for the argument name. If
1425
+ a ``__attrs_pre_init__`` method exists on the class, it will be called
1426
+ before the class is initialized. If a ``__attrs_post_init__`` method
1427
+ exists on the class, it will be called after the class is fully
1428
+ initialized.
1429
+
1430
+ If ``init`` is ``False``, an ``__attrs_init__`` method will be injected
1431
+ instead. This allows you to define a custom ``__init__`` method that
1432
+ can do pre-init work such as ``super().__init__()``, and then call
1433
+ ``__attrs_init__()`` and ``__attrs_post_init__()``.
1434
+
1435
+ .. seealso:: `init`
1436
+ :param bool slots: Create a :term:`slotted class <slotted classes>` that's
1437
+ more memory-efficient. Slotted classes are generally superior to the
1438
+ default dict classes, but have some gotchas you should know about, so
1439
+ we encourage you to read the :term:`glossary entry <slotted classes>`.
1440
+ :param bool frozen: Make instances immutable after initialization. If
1441
+ someone attempts to modify a frozen instance,
1442
+ `attrs.exceptions.FrozenInstanceError` is raised.
1443
+
1444
+ .. note::
1445
+
1446
+ 1. This is achieved by installing a custom ``__setattr__`` method
1447
+ on your class, so you can't implement your own.
1448
+
1449
+ 2. True immutability is impossible in Python.
1450
+
1451
+ 3. This *does* have a minor a runtime performance `impact
1452
+ <how-frozen>` when initializing new instances. In other words:
1453
+ ``__init__`` is slightly slower with ``frozen=True``.
1454
+
1455
+ 4. If a class is frozen, you cannot modify ``self`` in
1456
+ ``__attrs_post_init__`` or a self-written ``__init__``. You can
1457
+ circumvent that limitation by using ``object.__setattr__(self,
1458
+ "attribute_name", value)``.
1459
+
1460
+ 5. Subclasses of a frozen class are frozen too.
1461
+
1462
+ :param bool weakref_slot: Make instances weak-referenceable. This has no
1463
+ effect unless ``slots`` is also enabled.
1464
+ :param bool auto_attribs: If ``True``, collect :pep:`526`-annotated
1465
+ attributes from the class body.
1466
+
1467
+ In this case, you **must** annotate every field. If *attrs* encounters
1468
+ a field that is set to an `attr.ib` but lacks a type annotation, an
1469
+ `attr.exceptions.UnannotatedAttributeError` is raised. Use
1470
+ ``field_name: typing.Any = attr.ib(...)`` if you don't want to set a
1471
+ type.
1472
+
1473
+ If you assign a value to those attributes (e.g. ``x: int = 42``), that
1474
+ value becomes the default value like if it were passed using
1475
+ ``attr.ib(default=42)``. Passing an instance of `attrs.Factory` also
1476
+ works as expected in most cases (see warning below).
1477
+
1478
+ Attributes annotated as `typing.ClassVar`, and attributes that are
1479
+ neither annotated nor set to an `attr.ib` are **ignored**.
1480
+
1481
+ .. warning::
1482
+ For features that use the attribute name to create decorators (e.g.
1483
+ :ref:`validators <validators>`), you still *must* assign `attr.ib`
1484
+ to them. Otherwise Python will either not find the name or try to
1485
+ use the default value to call e.g. ``validator`` on it.
1486
+
1487
+ These errors can be quite confusing and probably the most common bug
1488
+ report on our bug tracker.
1489
+
1490
+ :param bool kw_only: Make all attributes keyword-only in the generated
1491
+ ``__init__`` (if ``init`` is ``False``, this parameter is ignored).
1492
+ :param bool cache_hash: Ensure that the object's hash code is computed only
1493
+ once and stored on the object. If this is set to ``True``, hashing
1494
+ must be either explicitly or implicitly enabled for this class. If the
1495
+ hash code is cached, avoid any reassignments of fields involved in hash
1496
+ code computation or mutations of the objects those fields point to
1497
+ after object creation. If such changes occur, the behavior of the
1498
+ object's hash code is undefined.
1499
+ :param bool auto_exc: If the class subclasses `BaseException` (which
1500
+ implicitly includes any subclass of any exception), the following
1501
+ happens to behave like a well-behaved Python exceptions class:
1502
+
1503
+ - the values for *eq*, *order*, and *hash* are ignored and the
1504
+ instances compare and hash by the instance's ids (N.B. *attrs* will
1505
+ *not* remove existing implementations of ``__hash__`` or the equality
1506
+ methods. It just won't add own ones.),
1507
+ - all attributes that are either passed into ``__init__`` or have a
1508
+ default value are additionally available as a tuple in the ``args``
1509
+ attribute,
1510
+ - the value of *str* is ignored leaving ``__str__`` to base classes.
1511
+ :param bool collect_by_mro: Setting this to `True` fixes the way *attrs*
1512
+ collects attributes from base classes. The default behavior is
1513
+ incorrect in certain cases of multiple inheritance. It should be on by
1514
+ default but is kept off for backward-compatibility.
1515
+
1516
+ .. seealso::
1517
+ Issue `#428 <https://github.com/python-attrs/attrs/issues/428>`_
1518
+
1519
+ :param bool | None getstate_setstate:
1520
+ .. note::
1521
+ This is usually only interesting for slotted classes and you should
1522
+ probably just set *auto_detect* to `True`.
1523
+
1524
+ If `True`, ``__getstate__`` and ``__setstate__`` are generated and
1525
+ attached to the class. This is necessary for slotted classes to be
1526
+ pickleable. If left `None`, it's `True` by default for slotted classes
1527
+ and ``False`` for dict classes.
1528
+
1529
+ If *auto_detect* is `True`, and *getstate_setstate* is left `None`, and
1530
+ **either** ``__getstate__`` or ``__setstate__`` is detected directly on
1531
+ the class (i.e. not inherited), it is set to `False` (this is usually
1532
+ what you want).
1533
+
1534
+ :param on_setattr: A callable that is run whenever the user attempts to set
1535
+ an attribute (either by assignment like ``i.x = 42`` or by using
1536
+ `setattr` like ``setattr(i, "x", 42)``). It receives the same arguments
1537
+ as validators: the instance, the attribute that is being modified, and
1538
+ the new value.
1539
+
1540
+ If no exception is raised, the attribute is set to the return value of
1541
+ the callable.
1542
+
1543
+ If a list of callables is passed, they're automatically wrapped in an
1544
+ `attrs.setters.pipe`.
1545
+ :type on_setattr: `callable`, or a list of callables, or `None`, or
1546
+ `attrs.setters.NO_OP`
1547
+
1548
+ :param callable | None field_transformer:
1549
+ A function that is called with the original class object and all fields
1550
+ right before *attrs* finalizes the class. You can use this, e.g., to
1551
+ automatically add converters or validators to fields based on their
1552
+ types.
1553
+
1554
+ .. seealso:: `transform-fields`
1555
+
1556
+ :param bool match_args:
1557
+ If `True` (default), set ``__match_args__`` on the class to support
1558
+ :pep:`634` (Structural Pattern Matching). It is a tuple of all
1559
+ non-keyword-only ``__init__`` parameter names on Python 3.10 and later.
1560
+ Ignored on older Python versions.
1561
+
1562
+ .. versionadded:: 16.0.0 *slots*
1563
+ .. versionadded:: 16.1.0 *frozen*
1564
+ .. versionadded:: 16.3.0 *str*
1565
+ .. versionadded:: 16.3.0 Support for ``__attrs_post_init__``.
1566
+ .. versionchanged:: 17.1.0
1567
+ *hash* supports ``None`` as value which is also the default now.
1568
+ .. versionadded:: 17.3.0 *auto_attribs*
1569
+ .. versionchanged:: 18.1.0
1570
+ If *these* is passed, no attributes are deleted from the class body.
1571
+ .. versionchanged:: 18.1.0 If *these* is ordered, the order is retained.
1572
+ .. versionadded:: 18.2.0 *weakref_slot*
1573
+ .. deprecated:: 18.2.0
1574
+ ``__lt__``, ``__le__``, ``__gt__``, and ``__ge__`` now raise a
1575
+ `DeprecationWarning` if the classes compared are subclasses of
1576
+ each other. ``__eq`` and ``__ne__`` never tried to compared subclasses
1577
+ to each other.
1578
+ .. versionchanged:: 19.2.0
1579
+ ``__lt__``, ``__le__``, ``__gt__``, and ``__ge__`` now do not consider
1580
+ subclasses comparable anymore.
1581
+ .. versionadded:: 18.2.0 *kw_only*
1582
+ .. versionadded:: 18.2.0 *cache_hash*
1583
+ .. versionadded:: 19.1.0 *auto_exc*
1584
+ .. deprecated:: 19.2.0 *cmp* Removal on or after 2021-06-01.
1585
+ .. versionadded:: 19.2.0 *eq* and *order*
1586
+ .. versionadded:: 20.1.0 *auto_detect*
1587
+ .. versionadded:: 20.1.0 *collect_by_mro*
1588
+ .. versionadded:: 20.1.0 *getstate_setstate*
1589
+ .. versionadded:: 20.1.0 *on_setattr*
1590
+ .. versionadded:: 20.3.0 *field_transformer*
1591
+ .. versionchanged:: 21.1.0
1592
+ ``init=False`` injects ``__attrs_init__``
1593
+ .. versionchanged:: 21.1.0 Support for ``__attrs_pre_init__``
1594
+ .. versionchanged:: 21.1.0 *cmp* undeprecated
1595
+ .. versionadded:: 21.3.0 *match_args*
1596
+ .. versionadded:: 22.2.0
1597
+ *unsafe_hash* as an alias for *hash* (for :pep:`681` compliance).
1598
+ """
1599
+ eq_, order_ = _determine_attrs_eq_order(cmp, eq, order, None)
1600
+
1601
+ # unsafe_hash takes precedence due to PEP 681.
1602
+ if unsafe_hash is not None:
1603
+ hash = unsafe_hash
1604
+
1605
+ if isinstance(on_setattr, (list, tuple)):
1606
+ on_setattr = setters.pipe(*on_setattr)
1607
+
1608
+ def wrap(cls):
1609
+ is_frozen = frozen or _has_frozen_base_class(cls)
1610
+ is_exc = auto_exc is True and issubclass(cls, BaseException)
1611
+ has_own_setattr = auto_detect and _has_own_attribute(
1612
+ cls, "__setattr__"
1613
+ )
1614
+
1615
+ if has_own_setattr and is_frozen:
1616
+ msg = "Can't freeze a class with a custom __setattr__."
1617
+ raise ValueError(msg)
1618
+
1619
+ builder = _ClassBuilder(
1620
+ cls,
1621
+ these,
1622
+ slots,
1623
+ is_frozen,
1624
+ weakref_slot,
1625
+ _determine_whether_to_implement(
1626
+ cls,
1627
+ getstate_setstate,
1628
+ auto_detect,
1629
+ ("__getstate__", "__setstate__"),
1630
+ default=slots,
1631
+ ),
1632
+ auto_attribs,
1633
+ kw_only,
1634
+ cache_hash,
1635
+ is_exc,
1636
+ collect_by_mro,
1637
+ on_setattr,
1638
+ has_own_setattr,
1639
+ field_transformer,
1640
+ )
1641
+ if _determine_whether_to_implement(
1642
+ cls, repr, auto_detect, ("__repr__",)
1643
+ ):
1644
+ builder.add_repr(repr_ns)
1645
+ if str is True:
1646
+ builder.add_str()
1647
+
1648
+ eq = _determine_whether_to_implement(
1649
+ cls, eq_, auto_detect, ("__eq__", "__ne__")
1650
+ )
1651
+ if not is_exc and eq is True:
1652
+ builder.add_eq()
1653
+ if not is_exc and _determine_whether_to_implement(
1654
+ cls, order_, auto_detect, ("__lt__", "__le__", "__gt__", "__ge__")
1655
+ ):
1656
+ builder.add_order()
1657
+
1658
+ builder.add_setattr()
1659
+
1660
+ nonlocal hash
1661
+ if (
1662
+ hash is None
1663
+ and auto_detect is True
1664
+ and _has_own_attribute(cls, "__hash__")
1665
+ ):
1666
+ hash = False
1667
+
1668
+ if hash is not True and hash is not False and hash is not None:
1669
+ # Can't use `hash in` because 1 == True for example.
1670
+ msg = "Invalid value for hash. Must be True, False, or None."
1671
+ raise TypeError(msg)
1672
+
1673
+ if hash is False or (hash is None and eq is False) or is_exc:
1674
+ # Don't do anything. Should fall back to __object__'s __hash__
1675
+ # which is by id.
1676
+ if cache_hash:
1677
+ msg = "Invalid value for cache_hash. To use hash caching, hashing must be either explicitly or implicitly enabled."
1678
+ raise TypeError(msg)
1679
+ elif hash is True or (
1680
+ hash is None and eq is True and is_frozen is True
1681
+ ):
1682
+ # Build a __hash__ if told so, or if it's safe.
1683
+ builder.add_hash()
1684
+ else:
1685
+ # Raise TypeError on attempts to hash.
1686
+ if cache_hash:
1687
+ msg = "Invalid value for cache_hash. To use hash caching, hashing must be either explicitly or implicitly enabled."
1688
+ raise TypeError(msg)
1689
+ builder.make_unhashable()
1690
+
1691
+ if _determine_whether_to_implement(
1692
+ cls, init, auto_detect, ("__init__",)
1693
+ ):
1694
+ builder.add_init()
1695
+ else:
1696
+ builder.add_attrs_init()
1697
+ if cache_hash:
1698
+ msg = "Invalid value for cache_hash. To use hash caching, init must be True."
1699
+ raise TypeError(msg)
1700
+
1701
+ if (
1702
+ PY310
1703
+ and match_args
1704
+ and not _has_own_attribute(cls, "__match_args__")
1705
+ ):
1706
+ builder.add_match_args()
1707
+
1708
+ return builder.build_class()
1709
+
1710
+ # maybe_cls's type depends on the usage of the decorator. It's a class
1711
+ # if it's used as `@attrs` but ``None`` if used as `@attrs()`.
1712
+ if maybe_cls is None:
1713
+ return wrap
1714
+
1715
+ return wrap(maybe_cls)
1716
+
1717
+
1718
+ _attrs = attrs
1719
+ """
1720
+ Internal alias so we can use it in functions that take an argument called
1721
+ *attrs*.
1722
+ """
1723
+
1724
+
1725
+ def _has_frozen_base_class(cls):
1726
+ """
1727
+ Check whether *cls* has a frozen ancestor by looking at its
1728
+ __setattr__.
1729
+ """
1730
+ return cls.__setattr__ is _frozen_setattrs
1731
+
1732
+
1733
+ def _generate_unique_filename(cls, func_name):
1734
+ """
1735
+ Create a "filename" suitable for a function being generated.
1736
+ """
1737
+ return (
1738
+ f"<attrs generated {func_name} {cls.__module__}."
1739
+ f"{getattr(cls, '__qualname__', cls.__name__)}>"
1740
+ )
1741
+
1742
+
1743
+ def _make_hash(cls, attrs, frozen, cache_hash):
1744
+ attrs = tuple(
1745
+ a for a in attrs if a.hash is True or (a.hash is None and a.eq is True)
1746
+ )
1747
+
1748
+ tab = " "
1749
+
1750
+ unique_filename = _generate_unique_filename(cls, "hash")
1751
+ type_hash = hash(unique_filename)
1752
+ # If eq is custom generated, we need to include the functions in globs
1753
+ globs = {}
1754
+
1755
+ hash_def = "def __hash__(self"
1756
+ hash_func = "hash(("
1757
+ closing_braces = "))"
1758
+ if not cache_hash:
1759
+ hash_def += "):"
1760
+ else:
1761
+ hash_def += ", *"
1762
+
1763
+ hash_def += ", _cache_wrapper=__import__('attr._make')._make._CacheHashWrapper):"
1764
+ hash_func = "_cache_wrapper(" + hash_func
1765
+ closing_braces += ")"
1766
+
1767
+ method_lines = [hash_def]
1768
+
1769
+ def append_hash_computation_lines(prefix, indent):
1770
+ """
1771
+ Generate the code for actually computing the hash code.
1772
+ Below this will either be returned directly or used to compute
1773
+ a value which is then cached, depending on the value of cache_hash
1774
+ """
1775
+
1776
+ method_lines.extend(
1777
+ [
1778
+ indent + prefix + hash_func,
1779
+ indent + f" {type_hash},",
1780
+ ]
1781
+ )
1782
+
1783
+ for a in attrs:
1784
+ if a.eq_key:
1785
+ cmp_name = f"_{a.name}_key"
1786
+ globs[cmp_name] = a.eq_key
1787
+ method_lines.append(
1788
+ indent + f" {cmp_name}(self.{a.name}),"
1789
+ )
1790
+ else:
1791
+ method_lines.append(indent + f" self.{a.name},")
1792
+
1793
+ method_lines.append(indent + " " + closing_braces)
1794
+
1795
+ if cache_hash:
1796
+ method_lines.append(tab + f"if self.{_hash_cache_field} is None:")
1797
+ if frozen:
1798
+ append_hash_computation_lines(
1799
+ f"object.__setattr__(self, '{_hash_cache_field}', ", tab * 2
1800
+ )
1801
+ method_lines.append(tab * 2 + ")") # close __setattr__
1802
+ else:
1803
+ append_hash_computation_lines(
1804
+ f"self.{_hash_cache_field} = ", tab * 2
1805
+ )
1806
+ method_lines.append(tab + f"return self.{_hash_cache_field}")
1807
+ else:
1808
+ append_hash_computation_lines("return ", tab)
1809
+
1810
+ script = "\n".join(method_lines)
1811
+ return _make_method("__hash__", script, unique_filename, globs)
1812
+
1813
+
1814
+ def _add_hash(cls, attrs):
1815
+ """
1816
+ Add a hash method to *cls*.
1817
+ """
1818
+ cls.__hash__ = _make_hash(cls, attrs, frozen=False, cache_hash=False)
1819
+ return cls
1820
+
1821
+
1822
+ def _make_ne():
1823
+ """
1824
+ Create __ne__ method.
1825
+ """
1826
+
1827
+ def __ne__(self, other):
1828
+ """
1829
+ Check equality and either forward a NotImplemented or
1830
+ return the result negated.
1831
+ """
1832
+ result = self.__eq__(other)
1833
+ if result is NotImplemented:
1834
+ return NotImplemented
1835
+
1836
+ return not result
1837
+
1838
+ return __ne__
1839
+
1840
+
1841
+ def _make_eq(cls, attrs):
1842
+ """
1843
+ Create __eq__ method for *cls* with *attrs*.
1844
+ """
1845
+ attrs = [a for a in attrs if a.eq]
1846
+
1847
+ unique_filename = _generate_unique_filename(cls, "eq")
1848
+ lines = [
1849
+ "def __eq__(self, other):",
1850
+ " if other.__class__ is not self.__class__:",
1851
+ " return NotImplemented",
1852
+ ]
1853
+
1854
+ # We can't just do a big self.x = other.x and... clause due to
1855
+ # irregularities like nan == nan is false but (nan,) == (nan,) is true.
1856
+ globs = {}
1857
+ if attrs:
1858
+ lines.append(" return (")
1859
+ others = [" ) == ("]
1860
+ for a in attrs:
1861
+ if a.eq_key:
1862
+ cmp_name = f"_{a.name}_key"
1863
+ # Add the key function to the global namespace
1864
+ # of the evaluated function.
1865
+ globs[cmp_name] = a.eq_key
1866
+ lines.append(f" {cmp_name}(self.{a.name}),")
1867
+ others.append(f" {cmp_name}(other.{a.name}),")
1868
+ else:
1869
+ lines.append(f" self.{a.name},")
1870
+ others.append(f" other.{a.name},")
1871
+
1872
+ lines += [*others, " )"]
1873
+ else:
1874
+ lines.append(" return True")
1875
+
1876
+ script = "\n".join(lines)
1877
+
1878
+ return _make_method("__eq__", script, unique_filename, globs)
1879
+
1880
+
1881
+ def _make_order(cls, attrs):
1882
+ """
1883
+ Create ordering methods for *cls* with *attrs*.
1884
+ """
1885
+ attrs = [a for a in attrs if a.order]
1886
+
1887
+ def attrs_to_tuple(obj):
1888
+ """
1889
+ Save us some typing.
1890
+ """
1891
+ return tuple(
1892
+ key(value) if key else value
1893
+ for value, key in (
1894
+ (getattr(obj, a.name), a.order_key) for a in attrs
1895
+ )
1896
+ )
1897
+
1898
+ def __lt__(self, other):
1899
+ """
1900
+ Automatically created by attrs.
1901
+ """
1902
+ if other.__class__ is self.__class__:
1903
+ return attrs_to_tuple(self) < attrs_to_tuple(other)
1904
+
1905
+ return NotImplemented
1906
+
1907
+ def __le__(self, other):
1908
+ """
1909
+ Automatically created by attrs.
1910
+ """
1911
+ if other.__class__ is self.__class__:
1912
+ return attrs_to_tuple(self) <= attrs_to_tuple(other)
1913
+
1914
+ return NotImplemented
1915
+
1916
+ def __gt__(self, other):
1917
+ """
1918
+ Automatically created by attrs.
1919
+ """
1920
+ if other.__class__ is self.__class__:
1921
+ return attrs_to_tuple(self) > attrs_to_tuple(other)
1922
+
1923
+ return NotImplemented
1924
+
1925
+ def __ge__(self, other):
1926
+ """
1927
+ Automatically created by attrs.
1928
+ """
1929
+ if other.__class__ is self.__class__:
1930
+ return attrs_to_tuple(self) >= attrs_to_tuple(other)
1931
+
1932
+ return NotImplemented
1933
+
1934
+ return __lt__, __le__, __gt__, __ge__
1935
+
1936
+
1937
+ def _add_eq(cls, attrs=None):
1938
+ """
1939
+ Add equality methods to *cls* with *attrs*.
1940
+ """
1941
+ if attrs is None:
1942
+ attrs = cls.__attrs_attrs__
1943
+
1944
+ cls.__eq__ = _make_eq(cls, attrs)
1945
+ cls.__ne__ = _make_ne()
1946
+
1947
+ return cls
1948
+
1949
+
1950
+ def _make_repr(attrs, ns, cls):
1951
+ unique_filename = _generate_unique_filename(cls, "repr")
1952
+ # Figure out which attributes to include, and which function to use to
1953
+ # format them. The a.repr value can be either bool or a custom
1954
+ # callable.
1955
+ attr_names_with_reprs = tuple(
1956
+ (a.name, (repr if a.repr is True else a.repr), a.init)
1957
+ for a in attrs
1958
+ if a.repr is not False
1959
+ )
1960
+ globs = {
1961
+ name + "_repr": r for name, r, _ in attr_names_with_reprs if r != repr
1962
+ }
1963
+ globs["_compat"] = _compat
1964
+ globs["AttributeError"] = AttributeError
1965
+ globs["NOTHING"] = NOTHING
1966
+ attribute_fragments = []
1967
+ for name, r, i in attr_names_with_reprs:
1968
+ accessor = (
1969
+ "self." + name if i else 'getattr(self, "' + name + '", NOTHING)'
1970
+ )
1971
+ fragment = (
1972
+ "%s={%s!r}" % (name, accessor)
1973
+ if r == repr
1974
+ else "%s={%s_repr(%s)}" % (name, name, accessor)
1975
+ )
1976
+ attribute_fragments.append(fragment)
1977
+ repr_fragment = ", ".join(attribute_fragments)
1978
+
1979
+ if ns is None:
1980
+ cls_name_fragment = '{self.__class__.__qualname__.rsplit(">.", 1)[-1]}'
1981
+ else:
1982
+ cls_name_fragment = ns + ".{self.__class__.__name__}"
1983
+
1984
+ lines = [
1985
+ "def __repr__(self):",
1986
+ " try:",
1987
+ " already_repring = _compat.repr_context.already_repring",
1988
+ " except AttributeError:",
1989
+ " already_repring = {id(self),}",
1990
+ " _compat.repr_context.already_repring = already_repring",
1991
+ " else:",
1992
+ " if id(self) in already_repring:",
1993
+ " return '...'",
1994
+ " else:",
1995
+ " already_repring.add(id(self))",
1996
+ " try:",
1997
+ f" return f'{cls_name_fragment}({repr_fragment})'",
1998
+ " finally:",
1999
+ " already_repring.remove(id(self))",
2000
+ ]
2001
+
2002
+ return _make_method(
2003
+ "__repr__", "\n".join(lines), unique_filename, globs=globs
2004
+ )
2005
+
2006
+
2007
+ def _add_repr(cls, ns=None, attrs=None):
2008
+ """
2009
+ Add a repr method to *cls*.
2010
+ """
2011
+ if attrs is None:
2012
+ attrs = cls.__attrs_attrs__
2013
+
2014
+ cls.__repr__ = _make_repr(attrs, ns, cls)
2015
+ return cls
2016
+
2017
+
2018
+ def fields(cls):
2019
+ """
2020
+ Return the tuple of *attrs* attributes for a class.
2021
+
2022
+ The tuple also allows accessing the fields by their names (see below for
2023
+ examples).
2024
+
2025
+ :param type cls: Class to introspect.
2026
+
2027
+ :raise TypeError: If *cls* is not a class.
2028
+ :raise attrs.exceptions.NotAnAttrsClassError: If *cls* is not an *attrs*
2029
+ class.
2030
+
2031
+ :rtype: tuple (with name accessors) of `attrs.Attribute`
2032
+
2033
+ .. versionchanged:: 16.2.0 Returned tuple allows accessing the fields
2034
+ by name.
2035
+ .. versionchanged:: 23.1.0 Add support for generic classes.
2036
+ """
2037
+ generic_base = get_generic_base(cls)
2038
+
2039
+ if generic_base is None and not isinstance(cls, type):
2040
+ msg = "Passed object must be a class."
2041
+ raise TypeError(msg)
2042
+
2043
+ attrs = getattr(cls, "__attrs_attrs__", None)
2044
+
2045
+ if attrs is None:
2046
+ if generic_base is not None:
2047
+ attrs = getattr(generic_base, "__attrs_attrs__", None)
2048
+ if attrs is not None:
2049
+ # Even though this is global state, stick it on here to speed
2050
+ # it up. We rely on `cls` being cached for this to be
2051
+ # efficient.
2052
+ cls.__attrs_attrs__ = attrs
2053
+ return attrs
2054
+ msg = f"{cls!r} is not an attrs-decorated class."
2055
+ raise NotAnAttrsClassError(msg)
2056
+
2057
+ return attrs
2058
+
2059
+
2060
+ def fields_dict(cls):
2061
+ """
2062
+ Return an ordered dictionary of *attrs* attributes for a class, whose
2063
+ keys are the attribute names.
2064
+
2065
+ :param type cls: Class to introspect.
2066
+
2067
+ :raise TypeError: If *cls* is not a class.
2068
+ :raise attrs.exceptions.NotAnAttrsClassError: If *cls* is not an *attrs*
2069
+ class.
2070
+
2071
+ :rtype: dict
2072
+
2073
+ .. versionadded:: 18.1.0
2074
+ """
2075
+ if not isinstance(cls, type):
2076
+ msg = "Passed object must be a class."
2077
+ raise TypeError(msg)
2078
+ attrs = getattr(cls, "__attrs_attrs__", None)
2079
+ if attrs is None:
2080
+ msg = f"{cls!r} is not an attrs-decorated class."
2081
+ raise NotAnAttrsClassError(msg)
2082
+ return {a.name: a for a in attrs}
2083
+
2084
+
2085
+ def validate(inst):
2086
+ """
2087
+ Validate all attributes on *inst* that have a validator.
2088
+
2089
+ Leaves all exceptions through.
2090
+
2091
+ :param inst: Instance of a class with *attrs* attributes.
2092
+ """
2093
+ if _config._run_validators is False:
2094
+ return
2095
+
2096
+ for a in fields(inst.__class__):
2097
+ v = a.validator
2098
+ if v is not None:
2099
+ v(inst, a, getattr(inst, a.name))
2100
+
2101
+
2102
+ def _is_slot_cls(cls):
2103
+ return "__slots__" in cls.__dict__
2104
+
2105
+
2106
+ def _is_slot_attr(a_name, base_attr_map):
2107
+ """
2108
+ Check if the attribute name comes from a slot class.
2109
+ """
2110
+ return a_name in base_attr_map and _is_slot_cls(base_attr_map[a_name])
2111
+
2112
+
2113
+ def _make_init(
2114
+ cls,
2115
+ attrs,
2116
+ pre_init,
2117
+ pre_init_has_args,
2118
+ post_init,
2119
+ frozen,
2120
+ slots,
2121
+ cache_hash,
2122
+ base_attr_map,
2123
+ is_exc,
2124
+ cls_on_setattr,
2125
+ attrs_init,
2126
+ ):
2127
+ has_cls_on_setattr = (
2128
+ cls_on_setattr is not None and cls_on_setattr is not setters.NO_OP
2129
+ )
2130
+
2131
+ if frozen and has_cls_on_setattr:
2132
+ msg = "Frozen classes can't use on_setattr."
2133
+ raise ValueError(msg)
2134
+
2135
+ needs_cached_setattr = cache_hash or frozen
2136
+ filtered_attrs = []
2137
+ attr_dict = {}
2138
+ for a in attrs:
2139
+ if not a.init and a.default is NOTHING:
2140
+ continue
2141
+
2142
+ filtered_attrs.append(a)
2143
+ attr_dict[a.name] = a
2144
+
2145
+ if a.on_setattr is not None:
2146
+ if frozen is True:
2147
+ msg = "Frozen classes can't use on_setattr."
2148
+ raise ValueError(msg)
2149
+
2150
+ needs_cached_setattr = True
2151
+ elif has_cls_on_setattr and a.on_setattr is not setters.NO_OP:
2152
+ needs_cached_setattr = True
2153
+
2154
+ unique_filename = _generate_unique_filename(cls, "init")
2155
+
2156
+ script, globs, annotations = _attrs_to_init_script(
2157
+ filtered_attrs,
2158
+ frozen,
2159
+ slots,
2160
+ pre_init,
2161
+ pre_init_has_args,
2162
+ post_init,
2163
+ cache_hash,
2164
+ base_attr_map,
2165
+ is_exc,
2166
+ needs_cached_setattr,
2167
+ has_cls_on_setattr,
2168
+ attrs_init,
2169
+ )
2170
+ if cls.__module__ in sys.modules:
2171
+ # This makes typing.get_type_hints(CLS.__init__) resolve string types.
2172
+ globs.update(sys.modules[cls.__module__].__dict__)
2173
+
2174
+ globs.update({"NOTHING": NOTHING, "attr_dict": attr_dict})
2175
+
2176
+ if needs_cached_setattr:
2177
+ # Save the lookup overhead in __init__ if we need to circumvent
2178
+ # setattr hooks.
2179
+ globs["_cached_setattr_get"] = _obj_setattr.__get__
2180
+
2181
+ init = _make_method(
2182
+ "__attrs_init__" if attrs_init else "__init__",
2183
+ script,
2184
+ unique_filename,
2185
+ globs,
2186
+ )
2187
+ init.__annotations__ = annotations
2188
+
2189
+ return init
2190
+
2191
+
2192
+ def _setattr(attr_name, value_var, has_on_setattr):
2193
+ """
2194
+ Use the cached object.setattr to set *attr_name* to *value_var*.
2195
+ """
2196
+ return f"_setattr('{attr_name}', {value_var})"
2197
+
2198
+
2199
+ def _setattr_with_converter(attr_name, value_var, has_on_setattr):
2200
+ """
2201
+ Use the cached object.setattr to set *attr_name* to *value_var*, but run
2202
+ its converter first.
2203
+ """
2204
+ return "_setattr('%s', %s(%s))" % (
2205
+ attr_name,
2206
+ _init_converter_pat % (attr_name,),
2207
+ value_var,
2208
+ )
2209
+
2210
+
2211
+ def _assign(attr_name, value, has_on_setattr):
2212
+ """
2213
+ Unless *attr_name* has an on_setattr hook, use normal assignment. Otherwise
2214
+ relegate to _setattr.
2215
+ """
2216
+ if has_on_setattr:
2217
+ return _setattr(attr_name, value, True)
2218
+
2219
+ return f"self.{attr_name} = {value}"
2220
+
2221
+
2222
+ def _assign_with_converter(attr_name, value_var, has_on_setattr):
2223
+ """
2224
+ Unless *attr_name* has an on_setattr hook, use normal assignment after
2225
+ conversion. Otherwise relegate to _setattr_with_converter.
2226
+ """
2227
+ if has_on_setattr:
2228
+ return _setattr_with_converter(attr_name, value_var, True)
2229
+
2230
+ return "self.%s = %s(%s)" % (
2231
+ attr_name,
2232
+ _init_converter_pat % (attr_name,),
2233
+ value_var,
2234
+ )
2235
+
2236
+
2237
+ def _attrs_to_init_script(
2238
+ attrs,
2239
+ frozen,
2240
+ slots,
2241
+ pre_init,
2242
+ pre_init_has_args,
2243
+ post_init,
2244
+ cache_hash,
2245
+ base_attr_map,
2246
+ is_exc,
2247
+ needs_cached_setattr,
2248
+ has_cls_on_setattr,
2249
+ attrs_init,
2250
+ ):
2251
+ """
2252
+ Return a script of an initializer for *attrs* and a dict of globals.
2253
+
2254
+ The globals are expected by the generated script.
2255
+
2256
+ If *frozen* is True, we cannot set the attributes directly so we use
2257
+ a cached ``object.__setattr__``.
2258
+ """
2259
+ lines = []
2260
+ if pre_init:
2261
+ lines.append("self.__attrs_pre_init__()")
2262
+
2263
+ if needs_cached_setattr:
2264
+ lines.append(
2265
+ # Circumvent the __setattr__ descriptor to save one lookup per
2266
+ # assignment.
2267
+ # Note _setattr will be used again below if cache_hash is True
2268
+ "_setattr = _cached_setattr_get(self)"
2269
+ )
2270
+
2271
+ if frozen is True:
2272
+ if slots is True:
2273
+ fmt_setter = _setattr
2274
+ fmt_setter_with_converter = _setattr_with_converter
2275
+ else:
2276
+ # Dict frozen classes assign directly to __dict__.
2277
+ # But only if the attribute doesn't come from an ancestor slot
2278
+ # class.
2279
+ # Note _inst_dict will be used again below if cache_hash is True
2280
+ lines.append("_inst_dict = self.__dict__")
2281
+
2282
+ def fmt_setter(attr_name, value_var, has_on_setattr):
2283
+ if _is_slot_attr(attr_name, base_attr_map):
2284
+ return _setattr(attr_name, value_var, has_on_setattr)
2285
+
2286
+ return f"_inst_dict['{attr_name}'] = {value_var}"
2287
+
2288
+ def fmt_setter_with_converter(
2289
+ attr_name, value_var, has_on_setattr
2290
+ ):
2291
+ if has_on_setattr or _is_slot_attr(attr_name, base_attr_map):
2292
+ return _setattr_with_converter(
2293
+ attr_name, value_var, has_on_setattr
2294
+ )
2295
+
2296
+ return "_inst_dict['%s'] = %s(%s)" % (
2297
+ attr_name,
2298
+ _init_converter_pat % (attr_name,),
2299
+ value_var,
2300
+ )
2301
+
2302
+ else:
2303
+ # Not frozen.
2304
+ fmt_setter = _assign
2305
+ fmt_setter_with_converter = _assign_with_converter
2306
+
2307
+ args = []
2308
+ kw_only_args = []
2309
+ attrs_to_validate = []
2310
+
2311
+ # This is a dictionary of names to validator and converter callables.
2312
+ # Injecting this into __init__ globals lets us avoid lookups.
2313
+ names_for_globals = {}
2314
+ annotations = {"return": None}
2315
+
2316
+ for a in attrs:
2317
+ if a.validator:
2318
+ attrs_to_validate.append(a)
2319
+
2320
+ attr_name = a.name
2321
+ has_on_setattr = a.on_setattr is not None or (
2322
+ a.on_setattr is not setters.NO_OP and has_cls_on_setattr
2323
+ )
2324
+ # a.alias is set to maybe-mangled attr_name in _ClassBuilder if not
2325
+ # explicitly provided
2326
+ arg_name = a.alias
2327
+
2328
+ has_factory = isinstance(a.default, Factory)
2329
+ maybe_self = "self" if has_factory and a.default.takes_self else ""
2330
+
2331
+ if a.init is False:
2332
+ if has_factory:
2333
+ init_factory_name = _init_factory_pat % (a.name,)
2334
+ if a.converter is not None:
2335
+ lines.append(
2336
+ fmt_setter_with_converter(
2337
+ attr_name,
2338
+ init_factory_name + f"({maybe_self})",
2339
+ has_on_setattr,
2340
+ )
2341
+ )
2342
+ conv_name = _init_converter_pat % (a.name,)
2343
+ names_for_globals[conv_name] = a.converter
2344
+ else:
2345
+ lines.append(
2346
+ fmt_setter(
2347
+ attr_name,
2348
+ init_factory_name + f"({maybe_self})",
2349
+ has_on_setattr,
2350
+ )
2351
+ )
2352
+ names_for_globals[init_factory_name] = a.default.factory
2353
+ elif a.converter is not None:
2354
+ lines.append(
2355
+ fmt_setter_with_converter(
2356
+ attr_name,
2357
+ f"attr_dict['{attr_name}'].default",
2358
+ has_on_setattr,
2359
+ )
2360
+ )
2361
+ conv_name = _init_converter_pat % (a.name,)
2362
+ names_for_globals[conv_name] = a.converter
2363
+ else:
2364
+ lines.append(
2365
+ fmt_setter(
2366
+ attr_name,
2367
+ f"attr_dict['{attr_name}'].default",
2368
+ has_on_setattr,
2369
+ )
2370
+ )
2371
+ elif a.default is not NOTHING and not has_factory:
2372
+ arg = f"{arg_name}=attr_dict['{attr_name}'].default"
2373
+ if a.kw_only:
2374
+ kw_only_args.append(arg)
2375
+ else:
2376
+ args.append(arg)
2377
+
2378
+ if a.converter is not None:
2379
+ lines.append(
2380
+ fmt_setter_with_converter(
2381
+ attr_name, arg_name, has_on_setattr
2382
+ )
2383
+ )
2384
+ names_for_globals[
2385
+ _init_converter_pat % (a.name,)
2386
+ ] = a.converter
2387
+ else:
2388
+ lines.append(fmt_setter(attr_name, arg_name, has_on_setattr))
2389
+
2390
+ elif has_factory:
2391
+ arg = f"{arg_name}=NOTHING"
2392
+ if a.kw_only:
2393
+ kw_only_args.append(arg)
2394
+ else:
2395
+ args.append(arg)
2396
+ lines.append(f"if {arg_name} is not NOTHING:")
2397
+
2398
+ init_factory_name = _init_factory_pat % (a.name,)
2399
+ if a.converter is not None:
2400
+ lines.append(
2401
+ " "
2402
+ + fmt_setter_with_converter(
2403
+ attr_name, arg_name, has_on_setattr
2404
+ )
2405
+ )
2406
+ lines.append("else:")
2407
+ lines.append(
2408
+ " "
2409
+ + fmt_setter_with_converter(
2410
+ attr_name,
2411
+ init_factory_name + "(" + maybe_self + ")",
2412
+ has_on_setattr,
2413
+ )
2414
+ )
2415
+ names_for_globals[
2416
+ _init_converter_pat % (a.name,)
2417
+ ] = a.converter
2418
+ else:
2419
+ lines.append(
2420
+ " " + fmt_setter(attr_name, arg_name, has_on_setattr)
2421
+ )
2422
+ lines.append("else:")
2423
+ lines.append(
2424
+ " "
2425
+ + fmt_setter(
2426
+ attr_name,
2427
+ init_factory_name + "(" + maybe_self + ")",
2428
+ has_on_setattr,
2429
+ )
2430
+ )
2431
+ names_for_globals[init_factory_name] = a.default.factory
2432
+ else:
2433
+ if a.kw_only:
2434
+ kw_only_args.append(arg_name)
2435
+ else:
2436
+ args.append(arg_name)
2437
+
2438
+ if a.converter is not None:
2439
+ lines.append(
2440
+ fmt_setter_with_converter(
2441
+ attr_name, arg_name, has_on_setattr
2442
+ )
2443
+ )
2444
+ names_for_globals[
2445
+ _init_converter_pat % (a.name,)
2446
+ ] = a.converter
2447
+ else:
2448
+ lines.append(fmt_setter(attr_name, arg_name, has_on_setattr))
2449
+
2450
+ if a.init is True:
2451
+ if a.type is not None and a.converter is None:
2452
+ annotations[arg_name] = a.type
2453
+ elif a.converter is not None:
2454
+ # Try to get the type from the converter.
2455
+ t = _AnnotationExtractor(a.converter).get_first_param_type()
2456
+ if t:
2457
+ annotations[arg_name] = t
2458
+
2459
+ if attrs_to_validate: # we can skip this if there are no validators.
2460
+ names_for_globals["_config"] = _config
2461
+ lines.append("if _config._run_validators is True:")
2462
+ for a in attrs_to_validate:
2463
+ val_name = "__attr_validator_" + a.name
2464
+ attr_name = "__attr_" + a.name
2465
+ lines.append(f" {val_name}(self, {attr_name}, self.{a.name})")
2466
+ names_for_globals[val_name] = a.validator
2467
+ names_for_globals[attr_name] = a
2468
+
2469
+ if post_init:
2470
+ lines.append("self.__attrs_post_init__()")
2471
+
2472
+ # because this is set only after __attrs_post_init__ is called, a crash
2473
+ # will result if post-init tries to access the hash code. This seemed
2474
+ # preferable to setting this beforehand, in which case alteration to
2475
+ # field values during post-init combined with post-init accessing the
2476
+ # hash code would result in silent bugs.
2477
+ if cache_hash:
2478
+ if frozen:
2479
+ if slots: # noqa: SIM108
2480
+ # if frozen and slots, then _setattr defined above
2481
+ init_hash_cache = "_setattr('%s', %s)"
2482
+ else:
2483
+ # if frozen and not slots, then _inst_dict defined above
2484
+ init_hash_cache = "_inst_dict['%s'] = %s"
2485
+ else:
2486
+ init_hash_cache = "self.%s = %s"
2487
+ lines.append(init_hash_cache % (_hash_cache_field, "None"))
2488
+
2489
+ # For exceptions we rely on BaseException.__init__ for proper
2490
+ # initialization.
2491
+ if is_exc:
2492
+ vals = ",".join(f"self.{a.name}" for a in attrs if a.init)
2493
+
2494
+ lines.append(f"BaseException.__init__(self, {vals})")
2495
+
2496
+ args = ", ".join(args)
2497
+ pre_init_args = args
2498
+ if kw_only_args:
2499
+ args += "%s*, %s" % (
2500
+ ", " if args else "", # leading comma
2501
+ ", ".join(kw_only_args), # kw_only args
2502
+ )
2503
+ pre_init_kw_only_args = ", ".join(
2504
+ ["%s=%s" % (kw_arg, kw_arg) for kw_arg in kw_only_args]
2505
+ )
2506
+ pre_init_args += (
2507
+ ", " if pre_init_args else ""
2508
+ ) # handle only kwargs and no regular args
2509
+ pre_init_args += pre_init_kw_only_args
2510
+
2511
+ if pre_init and pre_init_has_args:
2512
+ # If pre init method has arguments, pass same arguments as `__init__`
2513
+ lines[0] = "self.__attrs_pre_init__(%s)" % pre_init_args
2514
+
2515
+ return (
2516
+ "def %s(self, %s):\n %s\n"
2517
+ % (
2518
+ ("__attrs_init__" if attrs_init else "__init__"),
2519
+ args,
2520
+ "\n ".join(lines) if lines else "pass",
2521
+ ),
2522
+ names_for_globals,
2523
+ annotations,
2524
+ )
2525
+
2526
+
2527
+ def _default_init_alias_for(name: str) -> str:
2528
+ """
2529
+ The default __init__ parameter name for a field.
2530
+
2531
+ This performs private-name adjustment via leading-unscore stripping,
2532
+ and is the default value of Attribute.alias if not provided.
2533
+ """
2534
+
2535
+ return name.lstrip("_")
2536
+
2537
+
2538
+ class Attribute:
2539
+ """
2540
+ *Read-only* representation of an attribute.
2541
+
2542
+ .. warning::
2543
+
2544
+ You should never instantiate this class yourself.
2545
+
2546
+ The class has *all* arguments of `attr.ib` (except for ``factory``
2547
+ which is only syntactic sugar for ``default=Factory(...)`` plus the
2548
+ following:
2549
+
2550
+ - ``name`` (`str`): The name of the attribute.
2551
+ - ``alias`` (`str`): The __init__ parameter name of the attribute, after
2552
+ any explicit overrides and default private-attribute-name handling.
2553
+ - ``inherited`` (`bool`): Whether or not that attribute has been inherited
2554
+ from a base class.
2555
+ - ``eq_key`` and ``order_key`` (`typing.Callable` or `None`): The callables
2556
+ that are used for comparing and ordering objects by this attribute,
2557
+ respectively. These are set by passing a callable to `attr.ib`'s ``eq``,
2558
+ ``order``, or ``cmp`` arguments. See also :ref:`comparison customization
2559
+ <custom-comparison>`.
2560
+
2561
+ Instances of this class are frequently used for introspection purposes
2562
+ like:
2563
+
2564
+ - `fields` returns a tuple of them.
2565
+ - Validators get them passed as the first argument.
2566
+ - The :ref:`field transformer <transform-fields>` hook receives a list of
2567
+ them.
2568
+ - The ``alias`` property exposes the __init__ parameter name of the field,
2569
+ with any overrides and default private-attribute handling applied.
2570
+
2571
+
2572
+ .. versionadded:: 20.1.0 *inherited*
2573
+ .. versionadded:: 20.1.0 *on_setattr*
2574
+ .. versionchanged:: 20.2.0 *inherited* is not taken into account for
2575
+ equality checks and hashing anymore.
2576
+ .. versionadded:: 21.1.0 *eq_key* and *order_key*
2577
+ .. versionadded:: 22.2.0 *alias*
2578
+
2579
+ For the full version history of the fields, see `attr.ib`.
2580
+ """
2581
+
2582
+ __slots__ = (
2583
+ "name",
2584
+ "default",
2585
+ "validator",
2586
+ "repr",
2587
+ "eq",
2588
+ "eq_key",
2589
+ "order",
2590
+ "order_key",
2591
+ "hash",
2592
+ "init",
2593
+ "metadata",
2594
+ "type",
2595
+ "converter",
2596
+ "kw_only",
2597
+ "inherited",
2598
+ "on_setattr",
2599
+ "alias",
2600
+ )
2601
+
2602
+ def __init__(
2603
+ self,
2604
+ name,
2605
+ default,
2606
+ validator,
2607
+ repr,
2608
+ cmp, # XXX: unused, remove along with other cmp code.
2609
+ hash,
2610
+ init,
2611
+ inherited,
2612
+ metadata=None,
2613
+ type=None,
2614
+ converter=None,
2615
+ kw_only=False,
2616
+ eq=None,
2617
+ eq_key=None,
2618
+ order=None,
2619
+ order_key=None,
2620
+ on_setattr=None,
2621
+ alias=None,
2622
+ ):
2623
+ eq, eq_key, order, order_key = _determine_attrib_eq_order(
2624
+ cmp, eq_key or eq, order_key or order, True
2625
+ )
2626
+
2627
+ # Cache this descriptor here to speed things up later.
2628
+ bound_setattr = _obj_setattr.__get__(self)
2629
+
2630
+ # Despite the big red warning, people *do* instantiate `Attribute`
2631
+ # themselves.
2632
+ bound_setattr("name", name)
2633
+ bound_setattr("default", default)
2634
+ bound_setattr("validator", validator)
2635
+ bound_setattr("repr", repr)
2636
+ bound_setattr("eq", eq)
2637
+ bound_setattr("eq_key", eq_key)
2638
+ bound_setattr("order", order)
2639
+ bound_setattr("order_key", order_key)
2640
+ bound_setattr("hash", hash)
2641
+ bound_setattr("init", init)
2642
+ bound_setattr("converter", converter)
2643
+ bound_setattr(
2644
+ "metadata",
2645
+ (
2646
+ types.MappingProxyType(dict(metadata)) # Shallow copy
2647
+ if metadata
2648
+ else _empty_metadata_singleton
2649
+ ),
2650
+ )
2651
+ bound_setattr("type", type)
2652
+ bound_setattr("kw_only", kw_only)
2653
+ bound_setattr("inherited", inherited)
2654
+ bound_setattr("on_setattr", on_setattr)
2655
+ bound_setattr("alias", alias)
2656
+
2657
+ def __setattr__(self, name, value):
2658
+ raise FrozenInstanceError()
2659
+
2660
+ @classmethod
2661
+ def from_counting_attr(cls, name, ca, type=None):
2662
+ # type holds the annotated value. deal with conflicts:
2663
+ if type is None:
2664
+ type = ca.type
2665
+ elif ca.type is not None:
2666
+ msg = "Type annotation and type argument cannot both be present"
2667
+ raise ValueError(msg)
2668
+ inst_dict = {
2669
+ k: getattr(ca, k)
2670
+ for k in Attribute.__slots__
2671
+ if k
2672
+ not in (
2673
+ "name",
2674
+ "validator",
2675
+ "default",
2676
+ "type",
2677
+ "inherited",
2678
+ ) # exclude methods and deprecated alias
2679
+ }
2680
+ return cls(
2681
+ name=name,
2682
+ validator=ca._validator,
2683
+ default=ca._default,
2684
+ type=type,
2685
+ cmp=None,
2686
+ inherited=False,
2687
+ **inst_dict,
2688
+ )
2689
+
2690
+ # Don't use attrs.evolve since fields(Attribute) doesn't work
2691
+ def evolve(self, **changes):
2692
+ """
2693
+ Copy *self* and apply *changes*.
2694
+
2695
+ This works similarly to `attrs.evolve` but that function does not work
2696
+ with `Attribute`.
2697
+
2698
+ It is mainly meant to be used for `transform-fields`.
2699
+
2700
+ .. versionadded:: 20.3.0
2701
+ """
2702
+ new = copy.copy(self)
2703
+
2704
+ new._setattrs(changes.items())
2705
+
2706
+ return new
2707
+
2708
+ # Don't use _add_pickle since fields(Attribute) doesn't work
2709
+ def __getstate__(self):
2710
+ """
2711
+ Play nice with pickle.
2712
+ """
2713
+ return tuple(
2714
+ getattr(self, name) if name != "metadata" else dict(self.metadata)
2715
+ for name in self.__slots__
2716
+ )
2717
+
2718
+ def __setstate__(self, state):
2719
+ """
2720
+ Play nice with pickle.
2721
+ """
2722
+ self._setattrs(zip(self.__slots__, state))
2723
+
2724
+ def _setattrs(self, name_values_pairs):
2725
+ bound_setattr = _obj_setattr.__get__(self)
2726
+ for name, value in name_values_pairs:
2727
+ if name != "metadata":
2728
+ bound_setattr(name, value)
2729
+ else:
2730
+ bound_setattr(
2731
+ name,
2732
+ types.MappingProxyType(dict(value))
2733
+ if value
2734
+ else _empty_metadata_singleton,
2735
+ )
2736
+
2737
+
2738
+ _a = [
2739
+ Attribute(
2740
+ name=name,
2741
+ default=NOTHING,
2742
+ validator=None,
2743
+ repr=True,
2744
+ cmp=None,
2745
+ eq=True,
2746
+ order=False,
2747
+ hash=(name != "metadata"),
2748
+ init=True,
2749
+ inherited=False,
2750
+ alias=_default_init_alias_for(name),
2751
+ )
2752
+ for name in Attribute.__slots__
2753
+ ]
2754
+
2755
+ Attribute = _add_hash(
2756
+ _add_eq(
2757
+ _add_repr(Attribute, attrs=_a),
2758
+ attrs=[a for a in _a if a.name != "inherited"],
2759
+ ),
2760
+ attrs=[a for a in _a if a.hash and a.name != "inherited"],
2761
+ )
2762
+
2763
+
2764
+ class _CountingAttr:
2765
+ """
2766
+ Intermediate representation of attributes that uses a counter to preserve
2767
+ the order in which the attributes have been defined.
2768
+
2769
+ *Internal* data structure of the attrs library. Running into is most
2770
+ likely the result of a bug like a forgotten `@attr.s` decorator.
2771
+ """
2772
+
2773
+ __slots__ = (
2774
+ "counter",
2775
+ "_default",
2776
+ "repr",
2777
+ "eq",
2778
+ "eq_key",
2779
+ "order",
2780
+ "order_key",
2781
+ "hash",
2782
+ "init",
2783
+ "metadata",
2784
+ "_validator",
2785
+ "converter",
2786
+ "type",
2787
+ "kw_only",
2788
+ "on_setattr",
2789
+ "alias",
2790
+ )
2791
+ __attrs_attrs__ = (
2792
+ *tuple(
2793
+ Attribute(
2794
+ name=name,
2795
+ alias=_default_init_alias_for(name),
2796
+ default=NOTHING,
2797
+ validator=None,
2798
+ repr=True,
2799
+ cmp=None,
2800
+ hash=True,
2801
+ init=True,
2802
+ kw_only=False,
2803
+ eq=True,
2804
+ eq_key=None,
2805
+ order=False,
2806
+ order_key=None,
2807
+ inherited=False,
2808
+ on_setattr=None,
2809
+ )
2810
+ for name in (
2811
+ "counter",
2812
+ "_default",
2813
+ "repr",
2814
+ "eq",
2815
+ "order",
2816
+ "hash",
2817
+ "init",
2818
+ "on_setattr",
2819
+ "alias",
2820
+ )
2821
+ ),
2822
+ Attribute(
2823
+ name="metadata",
2824
+ alias="metadata",
2825
+ default=None,
2826
+ validator=None,
2827
+ repr=True,
2828
+ cmp=None,
2829
+ hash=False,
2830
+ init=True,
2831
+ kw_only=False,
2832
+ eq=True,
2833
+ eq_key=None,
2834
+ order=False,
2835
+ order_key=None,
2836
+ inherited=False,
2837
+ on_setattr=None,
2838
+ ),
2839
+ )
2840
+ cls_counter = 0
2841
+
2842
+ def __init__(
2843
+ self,
2844
+ default,
2845
+ validator,
2846
+ repr,
2847
+ cmp,
2848
+ hash,
2849
+ init,
2850
+ converter,
2851
+ metadata,
2852
+ type,
2853
+ kw_only,
2854
+ eq,
2855
+ eq_key,
2856
+ order,
2857
+ order_key,
2858
+ on_setattr,
2859
+ alias,
2860
+ ):
2861
+ _CountingAttr.cls_counter += 1
2862
+ self.counter = _CountingAttr.cls_counter
2863
+ self._default = default
2864
+ self._validator = validator
2865
+ self.converter = converter
2866
+ self.repr = repr
2867
+ self.eq = eq
2868
+ self.eq_key = eq_key
2869
+ self.order = order
2870
+ self.order_key = order_key
2871
+ self.hash = hash
2872
+ self.init = init
2873
+ self.metadata = metadata
2874
+ self.type = type
2875
+ self.kw_only = kw_only
2876
+ self.on_setattr = on_setattr
2877
+ self.alias = alias
2878
+
2879
+ def validator(self, meth):
2880
+ """
2881
+ Decorator that adds *meth* to the list of validators.
2882
+
2883
+ Returns *meth* unchanged.
2884
+
2885
+ .. versionadded:: 17.1.0
2886
+ """
2887
+ if self._validator is None:
2888
+ self._validator = meth
2889
+ else:
2890
+ self._validator = and_(self._validator, meth)
2891
+ return meth
2892
+
2893
+ def default(self, meth):
2894
+ """
2895
+ Decorator that allows to set the default for an attribute.
2896
+
2897
+ Returns *meth* unchanged.
2898
+
2899
+ :raises DefaultAlreadySetError: If default has been set before.
2900
+
2901
+ .. versionadded:: 17.1.0
2902
+ """
2903
+ if self._default is not NOTHING:
2904
+ raise DefaultAlreadySetError()
2905
+
2906
+ self._default = Factory(meth, takes_self=True)
2907
+
2908
+ return meth
2909
+
2910
+
2911
+ _CountingAttr = _add_eq(_add_repr(_CountingAttr))
2912
+
2913
+
2914
+ class Factory:
2915
+ """
2916
+ Stores a factory callable.
2917
+
2918
+ If passed as the default value to `attrs.field`, the factory is used to
2919
+ generate a new value.
2920
+
2921
+ :param callable factory: A callable that takes either none or exactly one
2922
+ mandatory positional argument depending on *takes_self*.
2923
+ :param bool takes_self: Pass the partially initialized instance that is
2924
+ being initialized as a positional argument.
2925
+
2926
+ .. versionadded:: 17.1.0 *takes_self*
2927
+ """
2928
+
2929
+ __slots__ = ("factory", "takes_self")
2930
+
2931
+ def __init__(self, factory, takes_self=False):
2932
+ self.factory = factory
2933
+ self.takes_self = takes_self
2934
+
2935
+ def __getstate__(self):
2936
+ """
2937
+ Play nice with pickle.
2938
+ """
2939
+ return tuple(getattr(self, name) for name in self.__slots__)
2940
+
2941
+ def __setstate__(self, state):
2942
+ """
2943
+ Play nice with pickle.
2944
+ """
2945
+ for name, value in zip(self.__slots__, state):
2946
+ setattr(self, name, value)
2947
+
2948
+
2949
+ _f = [
2950
+ Attribute(
2951
+ name=name,
2952
+ default=NOTHING,
2953
+ validator=None,
2954
+ repr=True,
2955
+ cmp=None,
2956
+ eq=True,
2957
+ order=False,
2958
+ hash=True,
2959
+ init=True,
2960
+ inherited=False,
2961
+ )
2962
+ for name in Factory.__slots__
2963
+ ]
2964
+
2965
+ Factory = _add_hash(_add_eq(_add_repr(Factory, attrs=_f), attrs=_f), attrs=_f)
2966
+
2967
+
2968
+ def make_class(
2969
+ name, attrs, bases=(object,), class_body=None, **attributes_arguments
2970
+ ):
2971
+ r"""
2972
+ A quick way to create a new class called *name* with *attrs*.
2973
+
2974
+ :param str name: The name for the new class.
2975
+
2976
+ :param attrs: A list of names or a dictionary of mappings of names to
2977
+ `attr.ib`\ s / `attrs.field`\ s.
2978
+
2979
+ The order is deduced from the order of the names or attributes inside
2980
+ *attrs*. Otherwise the order of the definition of the attributes is
2981
+ used.
2982
+ :type attrs: `list` or `dict`
2983
+
2984
+ :param tuple bases: Classes that the new class will subclass.
2985
+
2986
+ :param dict class_body: An optional dictionary of class attributes for the new class.
2987
+
2988
+ :param attributes_arguments: Passed unmodified to `attr.s`.
2989
+
2990
+ :return: A new class with *attrs*.
2991
+ :rtype: type
2992
+
2993
+ .. versionadded:: 17.1.0 *bases*
2994
+ .. versionchanged:: 18.1.0 If *attrs* is ordered, the order is retained.
2995
+ .. versionchanged:: 23.2.0 *class_body*
2996
+ """
2997
+ if isinstance(attrs, dict):
2998
+ cls_dict = attrs
2999
+ elif isinstance(attrs, (list, tuple)):
3000
+ cls_dict = {a: attrib() for a in attrs}
3001
+ else:
3002
+ msg = "attrs argument must be a dict or a list."
3003
+ raise TypeError(msg)
3004
+
3005
+ pre_init = cls_dict.pop("__attrs_pre_init__", None)
3006
+ post_init = cls_dict.pop("__attrs_post_init__", None)
3007
+ user_init = cls_dict.pop("__init__", None)
3008
+
3009
+ body = {}
3010
+ if class_body is not None:
3011
+ body.update(class_body)
3012
+ if pre_init is not None:
3013
+ body["__attrs_pre_init__"] = pre_init
3014
+ if post_init is not None:
3015
+ body["__attrs_post_init__"] = post_init
3016
+ if user_init is not None:
3017
+ body["__init__"] = user_init
3018
+
3019
+ type_ = types.new_class(name, bases, {}, lambda ns: ns.update(body))
3020
+
3021
+ # For pickling to work, the __module__ variable needs to be set to the
3022
+ # frame where the class is created. Bypass this step in environments where
3023
+ # sys._getframe is not defined (Jython for example) or sys._getframe is not
3024
+ # defined for arguments greater than 0 (IronPython).
3025
+ with contextlib.suppress(AttributeError, ValueError):
3026
+ type_.__module__ = sys._getframe(1).f_globals.get(
3027
+ "__name__", "__main__"
3028
+ )
3029
+
3030
+ # We do it here for proper warnings with meaningful stacklevel.
3031
+ cmp = attributes_arguments.pop("cmp", None)
3032
+ (
3033
+ attributes_arguments["eq"],
3034
+ attributes_arguments["order"],
3035
+ ) = _determine_attrs_eq_order(
3036
+ cmp,
3037
+ attributes_arguments.get("eq"),
3038
+ attributes_arguments.get("order"),
3039
+ True,
3040
+ )
3041
+
3042
+ return _attrs(these=cls_dict, **attributes_arguments)(type_)
3043
+
3044
+
3045
+ # These are required by within this module so we define them here and merely
3046
+ # import into .validators / .converters.
3047
+
3048
+
3049
+ @attrs(slots=True, hash=True)
3050
+ class _AndValidator:
3051
+ """
3052
+ Compose many validators to a single one.
3053
+ """
3054
+
3055
+ _validators = attrib()
3056
+
3057
+ def __call__(self, inst, attr, value):
3058
+ for v in self._validators:
3059
+ v(inst, attr, value)
3060
+
3061
+
3062
+ def and_(*validators):
3063
+ """
3064
+ A validator that composes multiple validators into one.
3065
+
3066
+ When called on a value, it runs all wrapped validators.
3067
+
3068
+ :param callables validators: Arbitrary number of validators.
3069
+
3070
+ .. versionadded:: 17.1.0
3071
+ """
3072
+ vals = []
3073
+ for validator in validators:
3074
+ vals.extend(
3075
+ validator._validators
3076
+ if isinstance(validator, _AndValidator)
3077
+ else [validator]
3078
+ )
3079
+
3080
+ return _AndValidator(tuple(vals))
3081
+
3082
+
3083
+ def pipe(*converters):
3084
+ """
3085
+ A converter that composes multiple converters into one.
3086
+
3087
+ When called on a value, it runs all wrapped converters, returning the
3088
+ *last* value.
3089
+
3090
+ Type annotations will be inferred from the wrapped converters', if
3091
+ they have any.
3092
+
3093
+ :param callables converters: Arbitrary number of converters.
3094
+
3095
+ .. versionadded:: 20.1.0
3096
+ """
3097
+
3098
+ def pipe_converter(val):
3099
+ for converter in converters:
3100
+ val = converter(val)
3101
+
3102
+ return val
3103
+
3104
+ if not converters:
3105
+ # If the converter list is empty, pipe_converter is the identity.
3106
+ A = typing.TypeVar("A")
3107
+ pipe_converter.__annotations__ = {"val": A, "return": A}
3108
+ else:
3109
+ # Get parameter type from first converter.
3110
+ t = _AnnotationExtractor(converters[0]).get_first_param_type()
3111
+ if t:
3112
+ pipe_converter.__annotations__["val"] = t
3113
+
3114
+ # Get return type from last converter.
3115
+ rt = _AnnotationExtractor(converters[-1]).get_return_type()
3116
+ if rt:
3117
+ pipe_converter.__annotations__["return"] = rt
3118
+
3119
+ return pipe_converter