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.
- jaclang/__init__.py +1 -9
- jaclang/cli/.gitignore +3 -0
- jaclang/cli/cli.md +190 -0
- jaclang/cli/cli.py +25 -4
- jaclang/compiler/.gitignore +1 -0
- jaclang/compiler/__init__.py +1 -0
- jaclang/compiler/absyntree.py +9 -7
- jaclang/compiler/compile.py +4 -4
- jaclang/compiler/jac.lark +1 -0
- jaclang/compiler/parser.py +28 -6
- jaclang/compiler/passes/main/def_impl_match_pass.py +4 -0
- jaclang/compiler/passes/main/fuse_typeinfo_pass.py +10 -1
- jaclang/compiler/passes/main/import_pass.py +47 -33
- jaclang/compiler/passes/main/pyast_load_pass.py +33 -6
- jaclang/compiler/passes/main/tests/fixtures/autoimpl.impl/getme.impl.jac +3 -0
- jaclang/compiler/passes/main/tests/fixtures/autoimpl.impl.jac +3 -0
- jaclang/compiler/passes/main/tests/fixtures/autoimpl.jac +9 -0
- jaclang/compiler/passes/main/tests/fixtures/autoimpl.something.else.impl.jac +3 -0
- jaclang/compiler/passes/main/tests/fixtures/base.jac +13 -0
- jaclang/compiler/passes/main/tests/fixtures/base2.jac +14 -0
- jaclang/compiler/passes/main/tests/fixtures/blip.jac +2 -0
- jaclang/compiler/passes/main/tests/fixtures/codegentext.jac +31 -0
- jaclang/compiler/passes/main/tests/fixtures/decls.jac +10 -0
- jaclang/compiler/passes/main/tests/fixtures/defs_and_uses.jac +44 -0
- jaclang/compiler/passes/main/tests/fixtures/fstrings.jac +4 -0
- jaclang/compiler/passes/main/tests/fixtures/func.jac +18 -0
- jaclang/compiler/passes/main/tests/fixtures/func2.jac +8 -0
- jaclang/compiler/passes/main/tests/fixtures/game1.jac +15 -0
- jaclang/compiler/passes/main/tests/fixtures/impl/defs1.jac +8 -0
- jaclang/compiler/passes/main/tests/fixtures/impl/defs2.jac +8 -0
- jaclang/compiler/passes/main/tests/fixtures/impl/imps.jac +11 -0
- jaclang/compiler/passes/main/tests/fixtures/multi_def_err.jac +7 -0
- jaclang/compiler/passes/main/tests/fixtures/registry.jac +36 -0
- jaclang/compiler/passes/main/tests/fixtures/type_info.jac +31 -0
- jaclang/compiler/passes/main/tests/test_type_check_pass.py +15 -0
- jaclang/compiler/passes/tool/jac_formatter_pass.py +2 -2
- jaclang/compiler/passes/tool/tests/fixtures/corelib.jac +480 -0
- jaclang/compiler/passes/tool/tests/fixtures/corelib_fmt.jac +480 -0
- jaclang/compiler/passes/tool/tests/fixtures/genai/essay_review.jac +36 -0
- jaclang/compiler/passes/tool/tests/fixtures/genai/expert_answer.jac +17 -0
- jaclang/compiler/passes/tool/tests/fixtures/genai/joke_gen.jac +32 -0
- jaclang/compiler/passes/tool/tests/fixtures/genai/odd_word_out.jac +27 -0
- jaclang/compiler/passes/tool/tests/fixtures/genai/personality_finder.jac +35 -0
- jaclang/compiler/passes/tool/tests/fixtures/genai/text_to_type.jac +25 -0
- jaclang/compiler/passes/tool/tests/fixtures/genai/translator.jac +13 -0
- jaclang/compiler/passes/tool/tests/fixtures/genai/wikipedia.jac +63 -0
- jaclang/compiler/passes/tool/tests/fixtures/multi_def_err.dot +39 -0
- jaclang/compiler/passes/tool/tests/fixtures/multi_def_err.jac +7 -0
- jaclang/compiler/passes/tool/tests/fixtures/multi_def_err.txt +20 -0
- jaclang/compiler/passes/tool/tests/fixtures/myca_formatted_code/ability_impl_long_comprehension.jac +15 -0
- jaclang/compiler/passes/tool/tests/fixtures/myca_formatted_code/call_with_many_parameters.jac +24 -0
- jaclang/compiler/passes/tool/tests/fixtures/myca_formatted_code/entry_main.jac +4 -0
- jaclang/compiler/passes/tool/tests/fixtures/myca_formatted_code/long_line_nested_dict_access.jac +10 -0
- jaclang/compiler/passes/tool/tests/fixtures/myca_formatted_code/multiline_fstrings.jac +16 -0
- jaclang/compiler/passes/tool/tests/fixtures/myca_formatted_code/nested_dict.jac +15 -0
- jaclang/compiler/passes/tool/tests/fixtures/myca_formatted_code/nested_loop_and_incrementer.jac +13 -0
- jaclang/compiler/passes/tool/tests/fixtures/myca_formatted_code/simple_walker.jac +25 -0
- jaclang/compiler/passes/tool/tests/fixtures/myca_formatted_code/try_block_and_walker_spawn_and_fstrings.jac +26 -0
- jaclang/compiler/passes/tool/tests/fixtures/myca_formatted_code/tuple_iteration_and_not_negation.jac +20 -0
- jaclang/compiler/passes/tool/tests/fixtures/myca_formatted_code/type_annotation.jac +3 -0
- jaclang/compiler/passes/tool/tests/fixtures/myca_formatted_code/walker_decl_only.jac +12 -0
- jaclang/compiler/passes/tool/tests/fixtures/myca_formatted_code/walker_with_default_values_types_and_docstrings.jac +18 -0
- jaclang/compiler/passes/tool/tests/fixtures/myca_formatted_code/walker_with_inline_ability_impl.jac +8 -0
- jaclang/compiler/passes/tool/tests/fixtures/simple_walk.jac +47 -0
- jaclang/compiler/passes/tool/tests/fixtures/simple_walk_fmt.jac +47 -0
- jaclang/compiler/passes/transform.py +13 -4
- jaclang/compiler/passes/utils/mypy_ast_build.py +8 -0
- jaclang/compiler/tests/fixtures/fam.jac +67 -0
- jaclang/compiler/tests/fixtures/hello_world.jac +5 -0
- jaclang/compiler/tests/fixtures/kwesc.jac +5 -0
- jaclang/compiler/tests/fixtures/mod_doc_test.jac +3 -0
- jaclang/compiler/tests/fixtures/staticcheck.jac +20 -0
- jaclang/compiler/tests/fixtures/stuff.jac +6 -0
- jaclang/langserve/__init__.py +1 -0
- jaclang/langserve/engine.py +287 -0
- jaclang/langserve/server.py +139 -0
- jaclang/langserve/tests/__init__.py +1 -0
- jaclang/langserve/tests/defaults.py +226 -0
- jaclang/langserve/tests/fixtures/hello.jac +1 -0
- jaclang/langserve/tests/pylsp_jsonrpc/__init__.py +2 -0
- jaclang/langserve/tests/pylsp_jsonrpc/dispatchers.py +37 -0
- jaclang/langserve/tests/pylsp_jsonrpc/endpoint.py +294 -0
- jaclang/langserve/tests/pylsp_jsonrpc/exceptions.py +114 -0
- jaclang/langserve/tests/pylsp_jsonrpc/streams.py +113 -0
- jaclang/langserve/tests/session.py +255 -0
- jaclang/langserve/tests/test_server.py +36 -0
- jaclang/langserve/utils.py +55 -0
- jaclang/plugin/default.py +1 -1
- jaclang/plugin/tests/fixtures/impl_match.jac +9 -0
- jaclang/plugin/tests/fixtures/impl_match_impl.jac +3 -0
- jaclang/plugin/tests/fixtures/simple_node_connection.jac +55 -0
- jaclang/plugin/tests/fixtures/simple_persistent.jac +41 -0
- jaclang/settings.py +5 -0
- jaclang/tests/fixtures/abc.jac +73 -0
- jaclang/tests/fixtures/access_checker.jac +19 -0
- jaclang/tests/fixtures/access_modifier.jac +49 -0
- jaclang/tests/fixtures/aott_raise.jac +25 -0
- jaclang/tests/fixtures/arithmetic_bug.jac +13 -0
- jaclang/tests/fixtures/assign_compr.jac +15 -0
- jaclang/tests/fixtures/assign_compr_dup.jac +15 -0
- jaclang/tests/fixtures/builtin_dotgen.jac +41 -0
- jaclang/tests/fixtures/chandra_bugs.jac +11 -0
- jaclang/tests/fixtures/chandra_bugs2.jac +26 -0
- jaclang/tests/fixtures/circle_pysolo.py +91 -0
- jaclang/tests/fixtures/deep/deeper/deep_outer_import.jac +9 -0
- jaclang/tests/fixtures/deep/deeper/deep_outer_import2.jac +9 -0
- jaclang/tests/fixtures/deep/deeper/snd_lev.jac +6 -0
- jaclang/tests/fixtures/deep/mycode.jac +4 -0
- jaclang/tests/fixtures/deep/one_lev.jac +6 -0
- jaclang/tests/fixtures/deep/one_lev_dup.jac +6 -0
- jaclang/tests/fixtures/deep/one_lev_dup_py.py +6 -0
- jaclang/tests/fixtures/deep_convert.jac +5 -0
- jaclang/tests/fixtures/deep_convo.py +6 -0
- jaclang/tests/fixtures/deep_import.jac +7 -0
- jaclang/tests/fixtures/deferred_field.jac +13 -0
- jaclang/tests/fixtures/disconn.jac +29 -0
- jaclang/tests/fixtures/edge_node_walk.jac +46 -0
- jaclang/tests/fixtures/edge_ops.jac +45 -0
- jaclang/tests/fixtures/edges_walk.jac +38 -0
- jaclang/tests/fixtures/enum_inside_archtype.jac +20 -0
- jaclang/tests/fixtures/err.jac +5 -0
- jaclang/tests/fixtures/err2.jac +5 -0
- jaclang/tests/fixtures/game1.jac +15 -0
- jaclang/tests/fixtures/gendot_bubble_sort.jac +77 -0
- jaclang/tests/fixtures/guess_game.jac +47 -0
- jaclang/tests/fixtures/has_goodness.jac +15 -0
- jaclang/tests/fixtures/hashcheck.jac +12 -0
- jaclang/tests/fixtures/hashcheck_dup.jac +12 -0
- jaclang/tests/fixtures/hello.jac +5 -0
- jaclang/tests/fixtures/hello_nc.jac +5 -0
- jaclang/tests/fixtures/ignore.jac +43 -0
- jaclang/tests/fixtures/ignore_dup.jac +43 -0
- jaclang/tests/fixtures/impl_grab.impl.jac +4 -0
- jaclang/tests/fixtures/impl_grab.jac +2 -0
- jaclang/tests/fixtures/inherit_check.jac +33 -0
- jaclang/tests/fixtures/jacsamp.jac +6 -0
- jaclang/tests/fixtures/jp_importer.jac +17 -0
- jaclang/tests/fixtures/lambda.jac +6 -0
- jaclang/tests/fixtures/maxfail_run_test.jac +5 -0
- jaclang/tests/fixtures/mtest.impl.jac +6 -0
- jaclang/tests/fixtures/mtest.jac +6 -0
- jaclang/tests/fixtures/needs_import.jac +18 -0
- jaclang/tests/fixtures/needs_import_1.jac +6 -0
- jaclang/tests/fixtures/needs_import_2.jac +6 -0
- jaclang/tests/fixtures/needs_import_3.jac +6 -0
- jaclang/tests/fixtures/needs_import_dup.jac +18 -0
- jaclang/tests/fixtures/package_import.jac +6 -0
- jaclang/tests/fixtures/pyfunc.py +11 -0
- jaclang/tests/fixtures/pyfunc_1.py +311 -0
- jaclang/tests/fixtures/pyfunc_2.py +279 -0
- jaclang/tests/fixtures/pyfunc_3.py +310 -0
- jaclang/tests/fixtures/random_check.jac +62 -0
- jaclang/tests/fixtures/raw_byte_string.jac +18 -0
- jaclang/tests/fixtures/registry.jac +37 -0
- jaclang/tests/fixtures/run_test.jac +5 -0
- jaclang/tests/fixtures/semstr.jac +33 -0
- jaclang/tests/fixtures/simple_archs.jac +26 -0
- jaclang/tests/fixtures/slice_vals.jac +7 -0
- jaclang/tests/fixtures/sub_abil_sep.jac +15 -0
- jaclang/tests/fixtures/sub_abil_sep_multilev.jac +17 -0
- jaclang/tests/fixtures/try_finally.jac +34 -0
- jaclang/tests/fixtures/tupleunpack.jac +6 -0
- jaclang/tests/fixtures/tuplytuples.jac +8 -0
- jaclang/tests/fixtures/type_info.jac +15 -0
- jaclang/tests/fixtures/with_context.jac +30 -0
- jaclang/tests/fixtures/with_llm_function.jac +33 -0
- jaclang/tests/fixtures/with_llm_lower.jac +45 -0
- jaclang/tests/fixtures/with_llm_method.jac +51 -0
- jaclang/tests/fixtures/with_llm_type.jac +52 -0
- jaclang/tests/test_cli.py +239 -0
- jaclang/tests/test_language.py +831 -0
- jaclang/tests/test_man_code.py +148 -0
- jaclang/tests/test_reference.py +95 -0
- jaclang/tests/test_settings.py +46 -0
- jaclang/utils/helpers.py +11 -0
- jaclang/utils/tests/test_lang_tools.py +17 -0
- jaclang/utils/treeprinter.py +12 -4
- jaclang/vendor/__init__.py +12 -1
- jaclang/vendor/attr/__init__.py +134 -0
- jaclang/vendor/attr/__init__.pyi +555 -0
- jaclang/vendor/attr/_cmp.py +150 -0
- jaclang/vendor/attr/_cmp.pyi +13 -0
- jaclang/vendor/attr/_compat.py +87 -0
- jaclang/vendor/attr/_config.py +31 -0
- jaclang/vendor/attr/_funcs.py +483 -0
- jaclang/vendor/attr/_make.py +3119 -0
- jaclang/vendor/attr/_next_gen.py +229 -0
- jaclang/vendor/attr/_typing_compat.pyi +15 -0
- jaclang/vendor/attr/_version_info.py +86 -0
- jaclang/vendor/attr/_version_info.pyi +9 -0
- jaclang/vendor/attr/converters.py +144 -0
- jaclang/vendor/attr/converters.pyi +13 -0
- jaclang/vendor/attr/exceptions.py +95 -0
- jaclang/vendor/attr/exceptions.pyi +17 -0
- jaclang/vendor/attr/filters.py +66 -0
- jaclang/vendor/attr/filters.pyi +6 -0
- jaclang/vendor/attr/setters.py +73 -0
- jaclang/vendor/attr/setters.pyi +19 -0
- jaclang/vendor/attr/validators.py +681 -0
- jaclang/vendor/attr/validators.pyi +88 -0
- jaclang/vendor/attrs/__init__.py +65 -0
- jaclang/vendor/attrs/__init__.pyi +67 -0
- jaclang/vendor/attrs/converters.py +3 -0
- jaclang/vendor/attrs/exceptions.py +3 -0
- jaclang/vendor/attrs/filters.py +3 -0
- jaclang/vendor/attrs/py.typed +0 -0
- jaclang/vendor/attrs/setters.py +3 -0
- jaclang/vendor/attrs/validators.py +3 -0
- jaclang/vendor/attrs-23.2.0.dist-info/METADATA +202 -0
- jaclang/vendor/attrs-23.2.0.dist-info/RECORD +35 -0
- jaclang/vendor/attrs-23.2.0.dist-info/WHEEL +4 -0
- jaclang/vendor/attrs-23.2.0.dist-info/licenses/LICENSE +21 -0
- jaclang/vendor/cattr/__init__.py +25 -0
- jaclang/vendor/cattr/converters.py +8 -0
- jaclang/vendor/cattr/disambiguators.py +3 -0
- jaclang/vendor/cattr/dispatch.py +3 -0
- jaclang/vendor/cattr/errors.py +15 -0
- jaclang/vendor/cattr/gen.py +21 -0
- jaclang/vendor/cattr/preconf/__init__.py +3 -0
- jaclang/vendor/cattr/preconf/bson.py +4 -0
- jaclang/vendor/cattr/preconf/json.py +4 -0
- jaclang/vendor/cattr/preconf/msgpack.py +4 -0
- jaclang/vendor/cattr/preconf/orjson.py +4 -0
- jaclang/vendor/cattr/preconf/pyyaml.py +4 -0
- jaclang/vendor/cattr/preconf/tomlkit.py +4 -0
- jaclang/vendor/cattr/preconf/ujson.py +4 -0
- jaclang/vendor/cattr/py.typed +0 -0
- jaclang/vendor/cattrs/__init__.py +55 -0
- jaclang/vendor/cattrs/_compat.py +465 -0
- jaclang/vendor/cattrs/_generics.py +22 -0
- jaclang/vendor/cattrs/converters.py +1101 -0
- jaclang/vendor/cattrs/disambiguators.py +132 -0
- jaclang/vendor/cattrs/dispatch.py +164 -0
- jaclang/vendor/cattrs/errors.py +129 -0
- jaclang/vendor/cattrs/fns.py +17 -0
- jaclang/vendor/cattrs/gen/__init__.py +890 -0
- jaclang/vendor/cattrs/gen/_consts.py +19 -0
- jaclang/vendor/cattrs/gen/_generics.py +43 -0
- jaclang/vendor/cattrs/gen/_lc.py +28 -0
- jaclang/vendor/cattrs/gen/_shared.py +51 -0
- jaclang/vendor/cattrs/gen/typeddicts.py +624 -0
- jaclang/vendor/cattrs/preconf/__init__.py +7 -0
- jaclang/vendor/cattrs/preconf/bson.py +107 -0
- jaclang/vendor/cattrs/preconf/cbor2.py +47 -0
- jaclang/vendor/cattrs/preconf/json.py +52 -0
- jaclang/vendor/cattrs/preconf/msgpack.py +51 -0
- jaclang/vendor/cattrs/preconf/orjson.py +82 -0
- jaclang/vendor/cattrs/preconf/pyyaml.py +60 -0
- jaclang/vendor/cattrs/preconf/tomlkit.py +85 -0
- jaclang/vendor/cattrs/preconf/ujson.py +52 -0
- jaclang/vendor/cattrs/py.typed +0 -0
- jaclang/vendor/cattrs/strategies/__init__.py +11 -0
- jaclang/vendor/cattrs/strategies/_class_methods.py +64 -0
- jaclang/vendor/cattrs/strategies/_subclasses.py +224 -0
- jaclang/vendor/cattrs/strategies/_unions.py +235 -0
- jaclang/vendor/cattrs/v.py +111 -0
- jaclang/vendor/cattrs-23.2.3.dist-info/METADATA +221 -0
- jaclang/vendor/cattrs-23.2.3.dist-info/RECORD +48 -0
- jaclang/vendor/cattrs-23.2.3.dist-info/WHEEL +4 -0
- jaclang/vendor/cattrs-23.2.3.dist-info/licenses/LICENSE +11 -0
- jaclang/vendor/lark/__init__.py +38 -38
- jaclang/vendor/lark/__pyinstaller/__init__.py +6 -7
- jaclang/vendor/lark/__pyinstaller/hook-lark.py +14 -14
- jaclang/vendor/lark/ast_utils.py +59 -70
- jaclang/vendor/lark/common.py +89 -113
- jaclang/vendor/lark/exceptions.py +292 -352
- jaclang/vendor/lark/grammar.py +130 -158
- jaclang/vendor/lark/grammars/common.lark +59 -59
- jaclang/vendor/lark/grammars/lark.lark +62 -62
- jaclang/vendor/lark/grammars/python.lark +302 -302
- jaclang/vendor/lark/grammars/unicode.lark +7 -7
- jaclang/vendor/lark/indenter.py +112 -118
- jaclang/vendor/lark/lark.py +661 -800
- jaclang/vendor/lark/lexer.py +678 -829
- jaclang/vendor/lark/load_grammar.py +1428 -1673
- jaclang/vendor/lark/parse_tree_builder.py +391 -466
- jaclang/vendor/lark/parser_frontends.py +257 -305
- jaclang/vendor/lark/parsers/cyk.py +340 -391
- jaclang/vendor/lark/parsers/earley.py +308 -385
- jaclang/vendor/lark/parsers/earley_common.py +42 -59
- jaclang/vendor/lark/parsers/earley_forest.py +810 -923
- jaclang/vendor/lark/parsers/grammar_analysis.py +203 -239
- jaclang/vendor/lark/parsers/lalr_analysis.py +332 -378
- jaclang/vendor/lark/parsers/lalr_interactive_parser.py +157 -171
- jaclang/vendor/lark/parsers/lalr_parser.py +122 -145
- jaclang/vendor/lark/parsers/lalr_parser_state.py +110 -141
- jaclang/vendor/lark/parsers/xearley.py +165 -209
- jaclang/vendor/lark/reconstruct.py +107 -131
- jaclang/vendor/lark/tools/__init__.py +71 -93
- jaclang/vendor/lark/tools/nearley.py +202 -240
- jaclang/vendor/lark/tools/serialize.py +32 -35
- jaclang/vendor/lark/tools/standalone.py +196 -225
- jaclang/vendor/lark/tree.py +272 -302
- jaclang/vendor/lark/tree_matcher.py +186 -194
- jaclang/vendor/lark/tree_templates.py +18 -26
- jaclang/vendor/lark/utils.py +361 -393
- jaclang/vendor/lark/visitors.py +593 -645
- jaclang/vendor/lark-1.1.9.dist-info/LICENSE +18 -0
- jaclang/vendor/lark-1.1.9.dist-info/METADATA +47 -0
- jaclang/vendor/lark-1.1.9.dist-info/RECORD +46 -0
- jaclang/vendor/lark-1.1.9.dist-info/WHEEL +5 -0
- jaclang/vendor/lark-1.1.9.dist-info/entry_points.txt +2 -0
- jaclang/vendor/lark-1.1.9.dist-info/top_level.txt +1 -0
- jaclang/vendor/lsprotocol/__init__.py +2 -0
- jaclang/vendor/lsprotocol/_hooks.py +1237 -0
- jaclang/vendor/lsprotocol/converters.py +17 -0
- jaclang/vendor/lsprotocol/py.typed +0 -0
- jaclang/vendor/lsprotocol/types.py +12898 -0
- jaclang/vendor/lsprotocol/validators.py +47 -0
- jaclang/vendor/lsprotocol-2023.0.1.dist-info/LICENSE +21 -0
- jaclang/vendor/lsprotocol-2023.0.1.dist-info/METADATA +65 -0
- jaclang/vendor/lsprotocol-2023.0.1.dist-info/RECORD +10 -0
- jaclang/vendor/lsprotocol-2023.0.1.dist-info/WHEEL +4 -0
- jaclang/vendor/mypy/api.py +1 -3
- jaclang/vendor/mypy/applytype.py +24 -24
- jaclang/vendor/mypy/argmap.py +5 -9
- jaclang/vendor/mypy/binder.py +11 -42
- jaclang/vendor/mypy/build.py +78 -260
- jaclang/vendor/mypy/checker.py +394 -930
- jaclang/vendor/mypy/checkexpr.py +210 -640
- jaclang/vendor/mypy/checkmember.py +44 -94
- jaclang/vendor/mypy/checkpattern.py +32 -104
- jaclang/vendor/mypy/checkstrformat.py +38 -131
- jaclang/vendor/mypy/config_parser.py +8 -31
- jaclang/vendor/mypy/constant_fold.py +1 -3
- jaclang/vendor/mypy/constraints.py +94 -253
- jaclang/vendor/mypy/copytype.py +3 -13
- jaclang/vendor/mypy/defaults.py +2 -4
- jaclang/vendor/mypy/dmypy/client.py +30 -102
- jaclang/vendor/mypy/dmypy_server.py +31 -118
- jaclang/vendor/mypy/erasetype.py +6 -18
- jaclang/vendor/mypy/errorcodes.py +26 -64
- jaclang/vendor/mypy/errors.py +23 -117
- jaclang/vendor/mypy/evalexpr.py +1 -3
- jaclang/vendor/mypy/expandtype.py +37 -40
- jaclang/vendor/mypy/exprtotype.py +14 -27
- jaclang/vendor/mypy/fastparse.py +66 -215
- jaclang/vendor/mypy/find_sources.py +4 -14
- jaclang/vendor/mypy/fixup.py +5 -10
- jaclang/vendor/mypy/indirection.py +1 -3
- jaclang/vendor/mypy/infer.py +2 -6
- jaclang/vendor/mypy/inspections.py +3 -13
- jaclang/vendor/mypy/ipc.py +7 -28
- jaclang/vendor/mypy/join.py +20 -39
- jaclang/vendor/mypy/literals.py +2 -10
- jaclang/vendor/mypy/main.py +39 -138
- jaclang/vendor/mypy/maptype.py +2 -6
- jaclang/vendor/mypy/meet.py +23 -77
- jaclang/vendor/mypy/message_registry.py +33 -88
- jaclang/vendor/mypy/messages.py +146 -447
- jaclang/vendor/mypy/metastore.py +2 -6
- jaclang/vendor/mypy/modulefinder.py +29 -76
- jaclang/vendor/mypy/moduleinspect.py +5 -17
- jaclang/vendor/mypy/mro.py +1 -3
- jaclang/vendor/mypy/nodes.py +35 -119
- jaclang/vendor/mypy/operators.py +2 -11
- jaclang/vendor/mypy/options.py +3 -9
- jaclang/vendor/mypy/parse.py +1 -3
- jaclang/vendor/mypy/plugin.py +25 -75
- jaclang/vendor/mypy/plugins/attrs.py +53 -119
- jaclang/vendor/mypy/plugins/common.py +9 -29
- jaclang/vendor/mypy/plugins/ctypes.py +5 -15
- jaclang/vendor/mypy/plugins/dataclasses.py +42 -107
- jaclang/vendor/mypy/plugins/default.py +26 -45
- jaclang/vendor/mypy/plugins/enums.py +4 -17
- jaclang/vendor/mypy/plugins/functools.py +2 -11
- jaclang/vendor/mypy/plugins/proper_plugin.py +2 -6
- jaclang/vendor/mypy/plugins/singledispatch.py +7 -33
- jaclang/vendor/mypy/reachability.py +2 -8
- jaclang/vendor/mypy/refinfo.py +1 -3
- jaclang/vendor/mypy/report.py +23 -52
- jaclang/vendor/mypy/semanal.py +385 -693
- jaclang/vendor/mypy/semanal_classprop.py +9 -34
- jaclang/vendor/mypy/semanal_enum.py +7 -19
- jaclang/vendor/mypy/semanal_infer.py +1 -3
- jaclang/vendor/mypy/semanal_main.py +5 -25
- jaclang/vendor/mypy/semanal_namedtuple.py +17 -56
- jaclang/vendor/mypy/semanal_newtype.py +8 -27
- jaclang/vendor/mypy/semanal_pass1.py +2 -6
- jaclang/vendor/mypy/semanal_shared.py +9 -27
- jaclang/vendor/mypy/semanal_typeargs.py +12 -41
- jaclang/vendor/mypy/semanal_typeddict.py +18 -59
- jaclang/vendor/mypy/server/astdiff.py +9 -34
- jaclang/vendor/mypy/server/astmerge.py +2 -6
- jaclang/vendor/mypy/server/deps.py +22 -71
- jaclang/vendor/mypy/server/mergecheck.py +1 -3
- jaclang/vendor/mypy/server/objgraph.py +2 -8
- jaclang/vendor/mypy/server/update.py +18 -54
- jaclang/vendor/mypy/solve.py +4 -17
- jaclang/vendor/mypy/split_namespace.py +1 -3
- jaclang/vendor/mypy/stats.py +6 -24
- jaclang/vendor/mypy/strconv.py +8 -31
- jaclang/vendor/mypy/stubdoc.py +8 -38
- jaclang/vendor/mypy/stubgen.py +79 -144
- jaclang/vendor/mypy/stubgenc.py +22 -69
- jaclang/vendor/mypy/stubtest.py +62 -167
- jaclang/vendor/mypy/stubutil.py +45 -61
- jaclang/vendor/mypy/subtypes.py +57 -133
- jaclang/vendor/mypy/suggestions.py +19 -53
- jaclang/vendor/mypy/test/data.py +13 -40
- jaclang/vendor/mypy/test/helpers.py +18 -43
- jaclang/vendor/mypy/test/meta/_pytest.py +2 -13
- jaclang/vendor/mypy/test/meta/test_parse_data.py +5 -9
- jaclang/vendor/mypy/test/meta/test_update_data.py +1 -3
- jaclang/vendor/mypy/test/test_find_sources.py +14 -32
- jaclang/vendor/mypy/test/test_ref_info.py +3 -9
- jaclang/vendor/mypy/test/testargs.py +1 -4
- jaclang/vendor/mypy/test/testcheck.py +14 -47
- jaclang/vendor/mypy/test/testcmdline.py +3 -14
- jaclang/vendor/mypy/test/testconstraints.py +8 -26
- jaclang/vendor/mypy/test/testdaemon.py +2 -9
- jaclang/vendor/mypy/test/testdeps.py +4 -12
- jaclang/vendor/mypy/test/testdiff.py +2 -6
- jaclang/vendor/mypy/test/testerrorstream.py +1 -3
- jaclang/vendor/mypy/test/testfinegrained.py +18 -56
- jaclang/vendor/mypy/test/testgraph.py +3 -18
- jaclang/vendor/mypy/test/testinfer.py +13 -55
- jaclang/vendor/mypy/test/testipc.py +3 -9
- jaclang/vendor/mypy/test/testmerge.py +5 -17
- jaclang/vendor/mypy/test/testmodulefinder.py +8 -30
- jaclang/vendor/mypy/test/testmypyc.py +1 -3
- jaclang/vendor/mypy/test/testparse.py +1 -3
- jaclang/vendor/mypy/test/testpep561.py +4 -13
- jaclang/vendor/mypy/test/testpythoneval.py +2 -6
- jaclang/vendor/mypy/test/testreports.py +1 -2
- jaclang/vendor/mypy/test/testsemanal.py +3 -10
- jaclang/vendor/mypy/test/testsolve.py +5 -15
- jaclang/vendor/mypy/test/teststubgen.py +69 -210
- jaclang/vendor/mypy/test/teststubtest.py +123 -163
- jaclang/vendor/mypy/test/testsubtypes.py +14 -34
- jaclang/vendor/mypy/test/testtransform.py +2 -8
- jaclang/vendor/mypy/test/testtypegen.py +2 -8
- jaclang/vendor/mypy/test/testtypes.py +77 -253
- jaclang/vendor/mypy/test/testutil.py +1 -3
- jaclang/vendor/mypy/test/typefixture.py +11 -38
- jaclang/vendor/mypy/test/update_data.py +4 -15
- jaclang/vendor/mypy/test/visitors.py +1 -9
- jaclang/vendor/mypy/treetransform.py +8 -25
- jaclang/vendor/mypy/tvar_scope.py +23 -3
- jaclang/vendor/mypy/type_visitor.py +3 -10
- jaclang/vendor/mypy/typeanal.py +183 -309
- jaclang/vendor/mypy/typeops.py +27 -73
- jaclang/vendor/mypy/types.py +77 -185
- jaclang/vendor/mypy/types_utils.py +7 -20
- jaclang/vendor/mypy/typeshed/LICENSE +237 -0
- jaclang/vendor/mypy/typeshed/stdlib/VERSIONS +309 -0
- jaclang/vendor/mypy/typeshed/stdlib/__future__.pyi +36 -0
- jaclang/vendor/mypy/typeshed/stdlib/__main__.pyi +3 -0
- jaclang/vendor/mypy/typeshed/stdlib/_ast.pyi +591 -0
- jaclang/vendor/mypy/typeshed/stdlib/_bisect.pyi +84 -0
- jaclang/vendor/mypy/typeshed/stdlib/_bootlocale.pyi +1 -0
- jaclang/vendor/mypy/typeshed/stdlib/_codecs.pyi +133 -0
- jaclang/vendor/mypy/typeshed/stdlib/_collections_abc.pyi +94 -0
- jaclang/vendor/mypy/typeshed/stdlib/_compat_pickle.pyi +8 -0
- jaclang/vendor/mypy/typeshed/stdlib/_compression.pyi +25 -0
- jaclang/vendor/mypy/typeshed/stdlib/_csv.pyi +90 -0
- jaclang/vendor/mypy/typeshed/stdlib/_ctypes.pyi +207 -0
- jaclang/vendor/mypy/typeshed/stdlib/_curses.pyi +566 -0
- jaclang/vendor/mypy/typeshed/stdlib/_decimal.pyi +281 -0
- jaclang/vendor/mypy/typeshed/stdlib/_dummy_thread.pyi +33 -0
- jaclang/vendor/mypy/typeshed/stdlib/_dummy_threading.pyi +164 -0
- jaclang/vendor/mypy/typeshed/stdlib/_heapq.pyi +11 -0
- jaclang/vendor/mypy/typeshed/stdlib/_imp.pyi +28 -0
- jaclang/vendor/mypy/typeshed/stdlib/_json.pyi +49 -0
- jaclang/vendor/mypy/typeshed/stdlib/_locale.pyi +100 -0
- jaclang/vendor/mypy/typeshed/stdlib/_lsprof.pyi +35 -0
- jaclang/vendor/mypy/typeshed/stdlib/_markupbase.pyi +16 -0
- jaclang/vendor/mypy/typeshed/stdlib/_msi.pyi +92 -0
- jaclang/vendor/mypy/typeshed/stdlib/_operator.pyi +147 -0
- jaclang/vendor/mypy/typeshed/stdlib/_osx_support.pyi +34 -0
- jaclang/vendor/mypy/typeshed/stdlib/_posixsubprocess.pyi +33 -0
- jaclang/vendor/mypy/typeshed/stdlib/_py_abc.pyi +14 -0
- jaclang/vendor/mypy/typeshed/stdlib/_pydecimal.pyi +43 -0
- jaclang/vendor/mypy/typeshed/stdlib/_random.pyi +12 -0
- jaclang/vendor/mypy/typeshed/stdlib/_sitebuiltins.pyi +16 -0
- jaclang/vendor/mypy/typeshed/stdlib/_socket.pyi +803 -0
- jaclang/vendor/mypy/typeshed/stdlib/_stat.pyi +103 -0
- jaclang/vendor/mypy/typeshed/stdlib/_thread.pyi +59 -0
- jaclang/vendor/mypy/typeshed/stdlib/_threading_local.pyi +17 -0
- jaclang/vendor/mypy/typeshed/stdlib/_tkinter.pyi +121 -0
- jaclang/vendor/mypy/typeshed/stdlib/_tracemalloc.pyi +17 -0
- jaclang/vendor/mypy/typeshed/stdlib/_typeshed/__init__.pyi +347 -0
- jaclang/vendor/mypy/typeshed/stdlib/_typeshed/dbapi.pyi +37 -0
- jaclang/vendor/mypy/typeshed/stdlib/_typeshed/wsgi.pyi +44 -0
- jaclang/vendor/mypy/typeshed/stdlib/_typeshed/xml.pyi +9 -0
- jaclang/vendor/mypy/typeshed/stdlib/_warnings.pyi +55 -0
- jaclang/vendor/mypy/typeshed/stdlib/_weakref.pyi +41 -0
- jaclang/vendor/mypy/typeshed/stdlib/_weakrefset.pyi +51 -0
- jaclang/vendor/mypy/typeshed/stdlib/_winapi.pyi +255 -0
- jaclang/vendor/mypy/typeshed/stdlib/abc.pyi +51 -0
- jaclang/vendor/mypy/typeshed/stdlib/aifc.pyi +91 -0
- jaclang/vendor/mypy/typeshed/stdlib/antigravity.pyi +3 -0
- jaclang/vendor/mypy/typeshed/stdlib/argparse.pyi +595 -0
- jaclang/vendor/mypy/typeshed/stdlib/array.pyi +92 -0
- jaclang/vendor/mypy/typeshed/stdlib/ast.pyi +277 -0
- jaclang/vendor/mypy/typeshed/stdlib/asynchat.pyi +21 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/__init__.pyi +41 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/base_events.pyi +440 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/base_futures.pyi +19 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/base_subprocess.pyi +63 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/base_tasks.pyi +9 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/constants.pyi +20 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/coroutines.pyi +26 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/events.pyi +580 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/exceptions.pyi +43 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/format_helpers.pyi +20 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/futures.pyi +57 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/locks.pyi +121 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/log.pyi +3 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/mixins.pyi +9 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/proactor_events.pyi +64 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/protocols.pyi +34 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/queues.pyi +47 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/runners.pyi +32 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/selector_events.pyi +8 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/sslproto.pyi +165 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/staggered.pyi +10 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/streams.pyi +153 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/subprocess.pyi +229 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/taskgroups.pyi +25 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/tasks.pyi +497 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/threads.pyi +9 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/timeouts.pyi +19 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/transports.pyi +47 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/trsock.pyi +94 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/unix_events.pyi +196 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/windows_events.pyi +85 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncio/windows_utils.pyi +49 -0
- jaclang/vendor/mypy/typeshed/stdlib/asyncore.pyi +90 -0
- jaclang/vendor/mypy/typeshed/stdlib/atexit.pyi +12 -0
- jaclang/vendor/mypy/typeshed/stdlib/audioop.pyi +43 -0
- jaclang/vendor/mypy/typeshed/stdlib/base64.pyi +59 -0
- jaclang/vendor/mypy/typeshed/stdlib/bdb.pyi +102 -0
- jaclang/vendor/mypy/typeshed/stdlib/binascii.pyi +36 -0
- jaclang/vendor/mypy/typeshed/stdlib/binhex.pyi +45 -0
- jaclang/vendor/mypy/typeshed/stdlib/bisect.pyi +4 -0
- jaclang/vendor/mypy/typeshed/stdlib/builtins.pyi +1936 -0
- jaclang/vendor/mypy/typeshed/stdlib/bz2.pyi +146 -0
- jaclang/vendor/mypy/typeshed/stdlib/cProfile.pyi +31 -0
- jaclang/vendor/mypy/typeshed/stdlib/calendar.pyi +208 -0
- jaclang/vendor/mypy/typeshed/stdlib/cgi.pyi +118 -0
- jaclang/vendor/mypy/typeshed/stdlib/cgitb.pyi +32 -0
- jaclang/vendor/mypy/typeshed/stdlib/chunk.pyi +20 -0
- jaclang/vendor/mypy/typeshed/stdlib/cmath.pyi +36 -0
- jaclang/vendor/mypy/typeshed/stdlib/cmd.pyi +45 -0
- jaclang/vendor/mypy/typeshed/stdlib/code.pyi +33 -0
- jaclang/vendor/mypy/typeshed/stdlib/codecs.pyi +285 -0
- jaclang/vendor/mypy/typeshed/stdlib/codeop.pyi +13 -0
- jaclang/vendor/mypy/typeshed/stdlib/collections/__init__.pyi +485 -0
- jaclang/vendor/mypy/typeshed/stdlib/collections/abc.pyi +2 -0
- jaclang/vendor/mypy/typeshed/stdlib/colorsys.pyi +13 -0
- jaclang/vendor/mypy/typeshed/stdlib/compileall.pyi +111 -0
- jaclang/vendor/mypy/typeshed/stdlib/concurrent/__init__.pyi +0 -0
- jaclang/vendor/mypy/typeshed/stdlib/concurrent/futures/__init__.pyi +32 -0
- jaclang/vendor/mypy/typeshed/stdlib/concurrent/futures/_base.pyi +126 -0
- jaclang/vendor/mypy/typeshed/stdlib/concurrent/futures/process.pyi +233 -0
- jaclang/vendor/mypy/typeshed/stdlib/concurrent/futures/thread.pyi +80 -0
- jaclang/vendor/mypy/typeshed/stdlib/configparser.pyi +313 -0
- jaclang/vendor/mypy/typeshed/stdlib/contextlib.pyi +208 -0
- jaclang/vendor/mypy/typeshed/stdlib/contextvars.pyi +63 -0
- jaclang/vendor/mypy/typeshed/stdlib/copy.pyi +16 -0
- jaclang/vendor/mypy/typeshed/stdlib/copyreg.pyi +21 -0
- jaclang/vendor/mypy/typeshed/stdlib/crypt.pyi +12 -0
- jaclang/vendor/mypy/typeshed/stdlib/csv.pyi +147 -0
- jaclang/vendor/mypy/typeshed/stdlib/ctypes/__init__.pyi +187 -0
- jaclang/vendor/mypy/typeshed/stdlib/ctypes/_endian.pyi +19 -0
- jaclang/vendor/mypy/typeshed/stdlib/ctypes/util.pyi +6 -0
- jaclang/vendor/mypy/typeshed/stdlib/ctypes/wintypes.pyi +298 -0
- jaclang/vendor/mypy/typeshed/stdlib/curses/__init__.pyi +22 -0
- jaclang/vendor/mypy/typeshed/stdlib/curses/ascii.pyi +62 -0
- jaclang/vendor/mypy/typeshed/stdlib/curses/has_key.pyi +1 -0
- jaclang/vendor/mypy/typeshed/stdlib/curses/panel.pyi +22 -0
- jaclang/vendor/mypy/typeshed/stdlib/curses/textpad.pyi +11 -0
- jaclang/vendor/mypy/typeshed/stdlib/dataclasses.pyi +315 -0
- jaclang/vendor/mypy/typeshed/stdlib/datetime.pyi +295 -0
- jaclang/vendor/mypy/typeshed/stdlib/dbm/__init__.pyi +95 -0
- jaclang/vendor/mypy/typeshed/stdlib/dbm/dumb.pyi +31 -0
- jaclang/vendor/mypy/typeshed/stdlib/dbm/gnu.pyi +41 -0
- jaclang/vendor/mypy/typeshed/stdlib/dbm/ndbm.pyi +37 -0
- jaclang/vendor/mypy/typeshed/stdlib/decimal.pyi +2 -0
- jaclang/vendor/mypy/typeshed/stdlib/difflib.pyi +140 -0
- jaclang/vendor/mypy/typeshed/stdlib/dis.pyi +144 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/__init__.pyi +5 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/archive_util.pyi +20 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/bcppcompiler.pyi +3 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/ccompiler.pyi +152 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/cmd.pyi +66 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/command/__init__.pyi +0 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/command/bdist.pyi +25 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/command/bdist_dumb.pyi +21 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/command/bdist_msi.pyi +45 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/command/bdist_packager.pyi +0 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/command/bdist_rpm.pyi +52 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/command/bdist_wininst.pyi +16 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/command/build.pyi +31 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/command/build_clib.pyi +27 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/command/build_ext.pyi +50 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/command/build_py.pyi +44 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/command/build_scripts.pyi +24 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/command/check.pyi +39 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/command/clean.pyi +17 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/command/config.pyi +83 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/command/install.pyi +63 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/command/install_data.pyi +19 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/command/install_egg_info.pyi +18 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/command/install_headers.pyi +16 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/command/install_lib.pyi +25 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/command/install_scripts.pyi +18 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/command/register.pyi +18 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/command/sdist.pyi +42 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/command/upload.pyi +17 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/config.pyi +17 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/core.pyi +57 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/cygwinccompiler.pyi +20 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/debug.pyi +1 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/dep_util.pyi +3 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/dir_util.pyi +13 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/dist.pyi +146 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/errors.pyi +19 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/extension.pyi +36 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/fancy_getopt.pyi +34 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/file_util.pyi +14 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/filelist.pyi +50 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/log.pyi +25 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/msvccompiler.pyi +3 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/spawn.pyi +2 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/sysconfig.pyi +31 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/text_file.pyi +21 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/unixccompiler.pyi +3 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/util.pyi +46 -0
- jaclang/vendor/mypy/typeshed/stdlib/distutils/version.pyi +36 -0
- jaclang/vendor/mypy/typeshed/stdlib/doctest.pyi +248 -0
- jaclang/vendor/mypy/typeshed/stdlib/dummy_threading.pyi +2 -0
- jaclang/vendor/mypy/typeshed/stdlib/email/__init__.pyi +29 -0
- jaclang/vendor/mypy/typeshed/stdlib/email/_header_value_parser.pyi +392 -0
- jaclang/vendor/mypy/typeshed/stdlib/email/_policybase.pyi +51 -0
- jaclang/vendor/mypy/typeshed/stdlib/email/base64mime.pyi +13 -0
- jaclang/vendor/mypy/typeshed/stdlib/email/charset.pyi +34 -0
- jaclang/vendor/mypy/typeshed/stdlib/email/contentmanager.pyi +11 -0
- jaclang/vendor/mypy/typeshed/stdlib/email/encoders.pyi +8 -0
- jaclang/vendor/mypy/typeshed/stdlib/email/errors.pyi +39 -0
- jaclang/vendor/mypy/typeshed/stdlib/email/feedparser.pyi +23 -0
- jaclang/vendor/mypy/typeshed/stdlib/email/generator.pyi +40 -0
- jaclang/vendor/mypy/typeshed/stdlib/email/header.pyi +31 -0
- jaclang/vendor/mypy/typeshed/stdlib/email/headerregistry.pyi +178 -0
- jaclang/vendor/mypy/typeshed/stdlib/email/iterators.pyi +12 -0
- jaclang/vendor/mypy/typeshed/stdlib/email/message.pyi +165 -0
- jaclang/vendor/mypy/typeshed/stdlib/email/mime/__init__.pyi +0 -0
- jaclang/vendor/mypy/typeshed/stdlib/email/mime/application.pyi +17 -0
- jaclang/vendor/mypy/typeshed/stdlib/email/mime/audio.pyi +17 -0
- jaclang/vendor/mypy/typeshed/stdlib/email/mime/base.pyi +8 -0
- jaclang/vendor/mypy/typeshed/stdlib/email/mime/image.pyi +17 -0
- jaclang/vendor/mypy/typeshed/stdlib/email/mime/message.pyi +8 -0
- jaclang/vendor/mypy/typeshed/stdlib/email/mime/multipart.pyi +18 -0
- jaclang/vendor/mypy/typeshed/stdlib/email/mime/nonmultipart.pyi +5 -0
- jaclang/vendor/mypy/typeshed/stdlib/email/mime/text.pyi +9 -0
- jaclang/vendor/mypy/typeshed/stdlib/email/parser.pyi +26 -0
- jaclang/vendor/mypy/typeshed/stdlib/email/policy.pyi +38 -0
- jaclang/vendor/mypy/typeshed/stdlib/email/quoprimime.pyi +28 -0
- jaclang/vendor/mypy/typeshed/stdlib/email/utils.pyi +70 -0
- jaclang/vendor/mypy/typeshed/stdlib/encodings/__init__.pyi +10 -0
- jaclang/vendor/mypy/typeshed/stdlib/encodings/utf_8.pyi +21 -0
- jaclang/vendor/mypy/typeshed/stdlib/encodings/utf_8_sig.pyi +22 -0
- jaclang/vendor/mypy/typeshed/stdlib/ensurepip/__init__.pyi +12 -0
- jaclang/vendor/mypy/typeshed/stdlib/enum.pyi +320 -0
- jaclang/vendor/mypy/typeshed/stdlib/errno.pyi +222 -0
- jaclang/vendor/mypy/typeshed/stdlib/faulthandler.pyi +13 -0
- jaclang/vendor/mypy/typeshed/stdlib/fcntl.pyi +127 -0
- jaclang/vendor/mypy/typeshed/stdlib/filecmp.pyi +57 -0
- jaclang/vendor/mypy/typeshed/stdlib/fileinput.pyi +213 -0
- jaclang/vendor/mypy/typeshed/stdlib/fnmatch.pyi +9 -0
- jaclang/vendor/mypy/typeshed/stdlib/formatter.pyi +88 -0
- jaclang/vendor/mypy/typeshed/stdlib/fractions.pyi +150 -0
- jaclang/vendor/mypy/typeshed/stdlib/ftplib.pyi +178 -0
- jaclang/vendor/mypy/typeshed/stdlib/functools.pyi +213 -0
- jaclang/vendor/mypy/typeshed/stdlib/gc.pyi +37 -0
- jaclang/vendor/mypy/typeshed/stdlib/genericpath.pyi +52 -0
- jaclang/vendor/mypy/typeshed/stdlib/getopt.pyi +11 -0
- jaclang/vendor/mypy/typeshed/stdlib/getpass.pyi +8 -0
- jaclang/vendor/mypy/typeshed/stdlib/gettext.pyi +169 -0
- jaclang/vendor/mypy/typeshed/stdlib/glob.pyi +42 -0
- jaclang/vendor/mypy/typeshed/stdlib/graphlib.pyi +28 -0
- jaclang/vendor/mypy/typeshed/stdlib/grp.pyi +22 -0
- jaclang/vendor/mypy/typeshed/stdlib/gzip.pyi +160 -0
- jaclang/vendor/mypy/typeshed/stdlib/hashlib.pyi +167 -0
- jaclang/vendor/mypy/typeshed/stdlib/heapq.pyi +17 -0
- jaclang/vendor/mypy/typeshed/stdlib/hmac.pyi +38 -0
- jaclang/vendor/mypy/typeshed/stdlib/html/__init__.pyi +6 -0
- jaclang/vendor/mypy/typeshed/stdlib/html/entities.pyi +6 -0
- jaclang/vendor/mypy/typeshed/stdlib/html/parser.pyi +34 -0
- jaclang/vendor/mypy/typeshed/stdlib/http/__init__.pyi +105 -0
- jaclang/vendor/mypy/typeshed/stdlib/http/client.pyi +259 -0
- jaclang/vendor/mypy/typeshed/stdlib/http/cookiejar.pyi +159 -0
- jaclang/vendor/mypy/typeshed/stdlib/http/cookies.pyi +60 -0
- jaclang/vendor/mypy/typeshed/stdlib/http/server.pyi +83 -0
- jaclang/vendor/mypy/typeshed/stdlib/imaplib.pyi +168 -0
- jaclang/vendor/mypy/typeshed/stdlib/imghdr.pyi +17 -0
- jaclang/vendor/mypy/typeshed/stdlib/imp.pyi +62 -0
- jaclang/vendor/mypy/typeshed/stdlib/importlib/__init__.pyi +24 -0
- jaclang/vendor/mypy/typeshed/stdlib/importlib/_abc.pyi +15 -0
- jaclang/vendor/mypy/typeshed/stdlib/importlib/abc.pyi +172 -0
- jaclang/vendor/mypy/typeshed/stdlib/importlib/machinery.pyi +179 -0
- jaclang/vendor/mypy/typeshed/stdlib/importlib/metadata/__init__.pyi +285 -0
- jaclang/vendor/mypy/typeshed/stdlib/importlib/metadata/_meta.pyi +49 -0
- jaclang/vendor/mypy/typeshed/stdlib/importlib/readers.pyi +68 -0
- jaclang/vendor/mypy/typeshed/stdlib/importlib/resources/__init__.pyi +46 -0
- jaclang/vendor/mypy/typeshed/stdlib/importlib/resources/abc.pyi +12 -0
- jaclang/vendor/mypy/typeshed/stdlib/importlib/resources/readers.pyi +14 -0
- jaclang/vendor/mypy/typeshed/stdlib/importlib/resources/simple.pyi +56 -0
- jaclang/vendor/mypy/typeshed/stdlib/importlib/simple.pyi +11 -0
- jaclang/vendor/mypy/typeshed/stdlib/importlib/util.pyi +43 -0
- jaclang/vendor/mypy/typeshed/stdlib/inspect.pyi +632 -0
- jaclang/vendor/mypy/typeshed/stdlib/io.pyi +238 -0
- jaclang/vendor/mypy/typeshed/stdlib/ipaddress.pyi +208 -0
- jaclang/vendor/mypy/typeshed/stdlib/itertools.pyi +273 -0
- jaclang/vendor/mypy/typeshed/stdlib/json/__init__.pyi +61 -0
- jaclang/vendor/mypy/typeshed/stdlib/json/decoder.pyi +32 -0
- jaclang/vendor/mypy/typeshed/stdlib/json/encoder.pyi +40 -0
- jaclang/vendor/mypy/typeshed/stdlib/json/tool.pyi +1 -0
- jaclang/vendor/mypy/typeshed/stdlib/keyword.pyi +21 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/__init__.pyi +0 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/btm_matcher.pyi +28 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixer_base.pyi +42 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/__init__.pyi +0 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_apply.pyi +8 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_asserts.pyi +10 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_basestring.pyi +8 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_buffer.pyi +8 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_dict.pyi +16 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_except.pyi +14 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_exec.pyi +8 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_execfile.pyi +8 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_exitfunc.pyi +13 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_filter.pyi +9 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_funcattrs.pyi +8 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_future.pyi +8 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_getcwdu.pyi +8 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_has_key.pyi +8 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_idioms.pyi +15 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_import.pyi +16 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_imports.pyi +21 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_imports2.pyi +6 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_input.pyi +11 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_intern.pyi +9 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_isinstance.pyi +8 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_itertools.pyi +9 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_itertools_imports.pyi +7 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_long.pyi +7 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_map.pyi +9 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_metaclass.pyi +17 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_methodattrs.pyi +10 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_ne.pyi +8 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_next.pyi +19 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_nonzero.pyi +8 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_numliterals.pyi +8 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_operator.pyi +12 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_paren.pyi +8 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_print.pyi +12 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_raise.pyi +8 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_raw_input.pyi +8 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_reduce.pyi +8 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_reload.pyi +9 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_renames.pyi +17 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_repr.pyi +8 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_set_literal.pyi +7 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_standarderror.pyi +8 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_sys_exc.pyi +9 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_throw.pyi +8 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_tuple_params.pyi +17 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_types.pyi +8 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_unicode.pyi +12 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_urllib.pyi +15 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_ws_comma.pyi +12 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_xrange.pyi +20 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_xreadlines.pyi +8 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/fixes/fix_zip.pyi +9 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/main.pyi +42 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/pgen2/__init__.pyi +9 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/pgen2/driver.pyi +27 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/pgen2/grammar.pyi +24 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/pgen2/literals.pyi +7 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/pgen2/parse.pyi +30 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/pgen2/pgen.pyi +50 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/pgen2/token.pyi +67 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/pgen2/tokenize.pyi +96 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/pygram.pyi +114 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/pytree.pyi +117 -0
- jaclang/vendor/mypy/typeshed/stdlib/lib2to3/refactor.pyi +82 -0
- jaclang/vendor/mypy/typeshed/stdlib/linecache.pyi +23 -0
- jaclang/vendor/mypy/typeshed/stdlib/locale.pyi +152 -0
- jaclang/vendor/mypy/typeshed/stdlib/logging/__init__.pyi +658 -0
- jaclang/vendor/mypy/typeshed/stdlib/logging/config.pyi +134 -0
- jaclang/vendor/mypy/typeshed/stdlib/logging/handlers.pyi +275 -0
- jaclang/vendor/mypy/typeshed/stdlib/lzma.pyi +197 -0
- jaclang/vendor/mypy/typeshed/stdlib/mailbox.pyi +256 -0
- jaclang/vendor/mypy/typeshed/stdlib/mailcap.pyi +11 -0
- jaclang/vendor/mypy/typeshed/stdlib/marshal.pyi +33 -0
- jaclang/vendor/mypy/typeshed/stdlib/math.pyi +125 -0
- jaclang/vendor/mypy/typeshed/stdlib/mimetypes.pyi +46 -0
- jaclang/vendor/mypy/typeshed/stdlib/mmap.pyi +113 -0
- jaclang/vendor/mypy/typeshed/stdlib/modulefinder.pyi +66 -0
- jaclang/vendor/mypy/typeshed/stdlib/msilib/__init__.pyi +177 -0
- jaclang/vendor/mypy/typeshed/stdlib/msilib/schema.pyi +94 -0
- jaclang/vendor/mypy/typeshed/stdlib/msilib/sequence.pyi +13 -0
- jaclang/vendor/mypy/typeshed/stdlib/msilib/text.pyi +7 -0
- jaclang/vendor/mypy/typeshed/stdlib/msvcrt.pyi +32 -0
- jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/__init__.pyi +90 -0
- jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/connection.pyi +75 -0
- jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/context.pyi +189 -0
- jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/dummy/__init__.pyi +77 -0
- jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/dummy/connection.pyi +39 -0
- jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/forkserver.pyi +31 -0
- jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/heap.pyi +36 -0
- jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/managers.pyi +212 -0
- jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/pool.pyi +103 -0
- jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/popen_fork.pyi +23 -0
- jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/popen_forkserver.pyi +16 -0
- jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/popen_spawn_posix.pyi +20 -0
- jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/popen_spawn_win32.pyi +30 -0
- jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/process.pyi +39 -0
- jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/queues.pyi +41 -0
- jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/reduction.pyi +90 -0
- jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/resource_sharer.pyi +20 -0
- jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/resource_tracker.pyi +18 -0
- jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/shared_memory.pyi +40 -0
- jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/sharedctypes.pyi +107 -0
- jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/spawn.pyi +32 -0
- jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/synchronize.pyi +54 -0
- jaclang/vendor/mypy/typeshed/stdlib/multiprocessing/util.pyi +98 -0
- jaclang/vendor/mypy/typeshed/stdlib/netrc.pyi +23 -0
- jaclang/vendor/mypy/typeshed/stdlib/nis.pyi +9 -0
- jaclang/vendor/mypy/typeshed/stdlib/nntplib.pyi +125 -0
- jaclang/vendor/mypy/typeshed/stdlib/nt.pyi +111 -0
- jaclang/vendor/mypy/typeshed/stdlib/ntpath.pyi +119 -0
- jaclang/vendor/mypy/typeshed/stdlib/nturl2path.pyi +2 -0
- jaclang/vendor/mypy/typeshed/stdlib/numbers.pyi +209 -0
- jaclang/vendor/mypy/typeshed/stdlib/opcode.pyi +59 -0
- jaclang/vendor/mypy/typeshed/stdlib/operator.pyi +110 -0
- jaclang/vendor/mypy/typeshed/stdlib/optparse.pyi +255 -0
- jaclang/vendor/mypy/typeshed/stdlib/os/__init__.pyi +1157 -0
- jaclang/vendor/mypy/typeshed/stdlib/os/path.pyi +8 -0
- jaclang/vendor/mypy/typeshed/stdlib/ossaudiodev.pyi +131 -0
- jaclang/vendor/mypy/typeshed/stdlib/parser.pyi +24 -0
- jaclang/vendor/mypy/typeshed/stdlib/pathlib.pyi +232 -0
- jaclang/vendor/mypy/typeshed/stdlib/pdb.pyi +181 -0
- jaclang/vendor/mypy/typeshed/stdlib/pickle.pyi +271 -0
- jaclang/vendor/mypy/typeshed/stdlib/pickletools.pyi +167 -0
- jaclang/vendor/mypy/typeshed/stdlib/pipes.pyi +16 -0
- jaclang/vendor/mypy/typeshed/stdlib/pkgutil.pyi +53 -0
- jaclang/vendor/mypy/typeshed/stdlib/platform.pyi +42 -0
- jaclang/vendor/mypy/typeshed/stdlib/plistlib.pyi +113 -0
- jaclang/vendor/mypy/typeshed/stdlib/poplib.pyi +71 -0
- jaclang/vendor/mypy/typeshed/stdlib/posix.pyi +361 -0
- jaclang/vendor/mypy/typeshed/stdlib/posixpath.pyi +161 -0
- jaclang/vendor/mypy/typeshed/stdlib/pprint.pyi +112 -0
- jaclang/vendor/mypy/typeshed/stdlib/profile.pyi +31 -0
- jaclang/vendor/mypy/typeshed/stdlib/pstats.pyi +80 -0
- jaclang/vendor/mypy/typeshed/stdlib/pty.pyi +19 -0
- jaclang/vendor/mypy/typeshed/stdlib/pwd.pyi +28 -0
- jaclang/vendor/mypy/typeshed/stdlib/py_compile.pyi +34 -0
- jaclang/vendor/mypy/typeshed/stdlib/pyclbr.pyi +74 -0
- jaclang/vendor/mypy/typeshed/stdlib/pydoc.pyi +261 -0
- jaclang/vendor/mypy/typeshed/stdlib/pydoc_data/__init__.pyi +0 -0
- jaclang/vendor/mypy/typeshed/stdlib/pydoc_data/topics.pyi +1 -0
- jaclang/vendor/mypy/typeshed/stdlib/pyexpat/__init__.pyi +85 -0
- jaclang/vendor/mypy/typeshed/stdlib/pyexpat/errors.pyi +49 -0
- jaclang/vendor/mypy/typeshed/stdlib/pyexpat/model.pyi +11 -0
- jaclang/vendor/mypy/typeshed/stdlib/queue.pyi +66 -0
- jaclang/vendor/mypy/typeshed/stdlib/quopri.pyi +11 -0
- jaclang/vendor/mypy/typeshed/stdlib/random.pyi +138 -0
- jaclang/vendor/mypy/typeshed/stdlib/re.pyi +290 -0
- jaclang/vendor/mypy/typeshed/stdlib/readline.pyi +36 -0
- jaclang/vendor/mypy/typeshed/stdlib/reprlib.pyi +65 -0
- jaclang/vendor/mypy/typeshed/stdlib/resource.pyi +94 -0
- jaclang/vendor/mypy/typeshed/stdlib/rlcompleter.pyi +9 -0
- jaclang/vendor/mypy/typeshed/stdlib/runpy.pyi +24 -0
- jaclang/vendor/mypy/typeshed/stdlib/sched.pyi +42 -0
- jaclang/vendor/mypy/typeshed/stdlib/secrets.pyi +15 -0
- jaclang/vendor/mypy/typeshed/stdlib/select.pyi +155 -0
- jaclang/vendor/mypy/typeshed/stdlib/selectors.pyi +67 -0
- jaclang/vendor/mypy/typeshed/stdlib/shelve.pyi +46 -0
- jaclang/vendor/mypy/typeshed/stdlib/shlex.pyi +63 -0
- jaclang/vendor/mypy/typeshed/stdlib/shutil.pyi +185 -0
- jaclang/vendor/mypy/typeshed/stdlib/signal.pyi +188 -0
- jaclang/vendor/mypy/typeshed/stdlib/site.pyi +27 -0
- jaclang/vendor/mypy/typeshed/stdlib/smtpd.pyi +91 -0
- jaclang/vendor/mypy/typeshed/stdlib/smtplib.pyi +204 -0
- jaclang/vendor/mypy/typeshed/stdlib/sndhdr.pyi +14 -0
- jaclang/vendor/mypy/typeshed/stdlib/socket.pyi +825 -0
- jaclang/vendor/mypy/typeshed/stdlib/socketserver.pyi +168 -0
- jaclang/vendor/mypy/typeshed/stdlib/spwd.pyi +41 -0
- jaclang/vendor/mypy/typeshed/stdlib/sqlite3/__init__.pyi +1 -0
- jaclang/vendor/mypy/typeshed/stdlib/sqlite3/dbapi2.pyi +551 -0
- jaclang/vendor/mypy/typeshed/stdlib/sre_compile.pyi +11 -0
- jaclang/vendor/mypy/typeshed/stdlib/sre_constants.pyi +130 -0
- jaclang/vendor/mypy/typeshed/stdlib/sre_parse.pyi +104 -0
- jaclang/vendor/mypy/typeshed/stdlib/ssl.pyi +537 -0
- jaclang/vendor/mypy/typeshed/stdlib/stat.pyi +1 -0
- jaclang/vendor/mypy/typeshed/stdlib/statistics.pyi +132 -0
- jaclang/vendor/mypy/typeshed/stdlib/string.pyi +83 -0
- jaclang/vendor/mypy/typeshed/stdlib/stringprep.pyi +27 -0
- jaclang/vendor/mypy/typeshed/stdlib/struct.pyi +26 -0
- jaclang/vendor/mypy/typeshed/stdlib/subprocess.pyi +2615 -0
- jaclang/vendor/mypy/typeshed/stdlib/sunau.pyi +86 -0
- jaclang/vendor/mypy/typeshed/stdlib/symbol.pyi +93 -0
- jaclang/vendor/mypy/typeshed/stdlib/symtable.pyi +58 -0
- jaclang/vendor/mypy/typeshed/stdlib/sys/__init__.pyi +373 -0
- jaclang/vendor/mypy/typeshed/stdlib/sys/_monitoring.pyi +52 -0
- jaclang/vendor/mypy/typeshed/stdlib/sysconfig.pyi +48 -0
- jaclang/vendor/mypy/typeshed/stdlib/syslog.pyi +46 -0
- jaclang/vendor/mypy/typeshed/stdlib/tabnanny.pyi +16 -0
- jaclang/vendor/mypy/typeshed/stdlib/tarfile.pyi +441 -0
- jaclang/vendor/mypy/typeshed/stdlib/telnetlib.pyi +122 -0
- jaclang/vendor/mypy/typeshed/stdlib/tempfile.pyi +477 -0
- jaclang/vendor/mypy/typeshed/stdlib/termios.pyi +267 -0
- jaclang/vendor/mypy/typeshed/stdlib/textwrap.pyi +103 -0
- jaclang/vendor/mypy/typeshed/stdlib/this.pyi +2 -0
- jaclang/vendor/mypy/typeshed/stdlib/threading.pyi +187 -0
- jaclang/vendor/mypy/typeshed/stdlib/time.pyi +108 -0
- jaclang/vendor/mypy/typeshed/stdlib/timeit.pyi +32 -0
- jaclang/vendor/mypy/typeshed/stdlib/tkinter/__init__.pyi +3654 -0
- jaclang/vendor/mypy/typeshed/stdlib/tkinter/colorchooser.pyi +20 -0
- jaclang/vendor/mypy/typeshed/stdlib/tkinter/commondialog.pyi +14 -0
- jaclang/vendor/mypy/typeshed/stdlib/tkinter/constants.pyi +80 -0
- jaclang/vendor/mypy/typeshed/stdlib/tkinter/dialog.pyi +16 -0
- jaclang/vendor/mypy/typeshed/stdlib/tkinter/dnd.pyi +20 -0
- jaclang/vendor/mypy/typeshed/stdlib/tkinter/filedialog.pyi +151 -0
- jaclang/vendor/mypy/typeshed/stdlib/tkinter/font.pyi +116 -0
- jaclang/vendor/mypy/typeshed/stdlib/tkinter/messagebox.pyi +44 -0
- jaclang/vendor/mypy/typeshed/stdlib/tkinter/scrolledtext.pyi +9 -0
- jaclang/vendor/mypy/typeshed/stdlib/tkinter/simpledialog.pyi +54 -0
- jaclang/vendor/mypy/typeshed/stdlib/tkinter/tix.pyi +299 -0
- jaclang/vendor/mypy/typeshed/stdlib/tkinter/ttk.pyi +1204 -0
- jaclang/vendor/mypy/typeshed/stdlib/token.pyi +159 -0
- jaclang/vendor/mypy/typeshed/stdlib/tokenize.pyi +177 -0
- jaclang/vendor/mypy/typeshed/stdlib/tomllib.pyi +10 -0
- jaclang/vendor/mypy/typeshed/stdlib/trace.pyi +79 -0
- jaclang/vendor/mypy/typeshed/stdlib/traceback.pyi +262 -0
- jaclang/vendor/mypy/typeshed/stdlib/tracemalloc.pyi +124 -0
- jaclang/vendor/mypy/typeshed/stdlib/tty.pyi +30 -0
- jaclang/vendor/mypy/typeshed/stdlib/turtle.pyi +713 -0
- jaclang/vendor/mypy/typeshed/stdlib/types.pyi +614 -0
- jaclang/vendor/mypy/typeshed/stdlib/typing.pyi +976 -0
- jaclang/vendor/mypy/typeshed/stdlib/typing_extensions.pyi +509 -0
- jaclang/vendor/mypy/typeshed/stdlib/unicodedata.pyi +73 -0
- jaclang/vendor/mypy/typeshed/stdlib/unittest/__init__.pyi +67 -0
- jaclang/vendor/mypy/typeshed/stdlib/unittest/_log.pyi +27 -0
- jaclang/vendor/mypy/typeshed/stdlib/unittest/async_case.pyi +21 -0
- jaclang/vendor/mypy/typeshed/stdlib/unittest/case.pyi +342 -0
- jaclang/vendor/mypy/typeshed/stdlib/unittest/loader.pyi +51 -0
- jaclang/vendor/mypy/typeshed/stdlib/unittest/main.pyi +69 -0
- jaclang/vendor/mypy/typeshed/stdlib/unittest/mock.pyi +430 -0
- jaclang/vendor/mypy/typeshed/stdlib/unittest/result.pyi +47 -0
- jaclang/vendor/mypy/typeshed/stdlib/unittest/runner.pyi +72 -0
- jaclang/vendor/mypy/typeshed/stdlib/unittest/signals.pyi +15 -0
- jaclang/vendor/mypy/typeshed/stdlib/unittest/suite.pyi +22 -0
- jaclang/vendor/mypy/typeshed/stdlib/unittest/util.pyi +23 -0
- jaclang/vendor/mypy/typeshed/stdlib/urllib/__init__.pyi +0 -0
- jaclang/vendor/mypy/typeshed/stdlib/urllib/error.pyi +23 -0
- jaclang/vendor/mypy/typeshed/stdlib/urllib/parse.pyi +210 -0
- jaclang/vendor/mypy/typeshed/stdlib/urllib/request.pyi +400 -0
- jaclang/vendor/mypy/typeshed/stdlib/urllib/response.pyi +43 -0
- jaclang/vendor/mypy/typeshed/stdlib/urllib/robotparser.pyi +20 -0
- jaclang/vendor/mypy/typeshed/stdlib/uu.pyi +13 -0
- jaclang/vendor/mypy/typeshed/stdlib/uuid.pyi +100 -0
- jaclang/vendor/mypy/typeshed/stdlib/warnings.pyi +112 -0
- jaclang/vendor/mypy/typeshed/stdlib/wave.pyi +85 -0
- jaclang/vendor/mypy/typeshed/stdlib/weakref.pyi +149 -0
- jaclang/vendor/mypy/typeshed/stdlib/webbrowser.pyi +74 -0
- jaclang/vendor/mypy/typeshed/stdlib/winreg.pyi +132 -0
- jaclang/vendor/mypy/typeshed/stdlib/winsound.pyi +28 -0
- jaclang/vendor/mypy/typeshed/stdlib/wsgiref/__init__.pyi +0 -0
- jaclang/vendor/mypy/typeshed/stdlib/wsgiref/handlers.pyi +91 -0
- jaclang/vendor/mypy/typeshed/stdlib/wsgiref/headers.pyi +26 -0
- jaclang/vendor/mypy/typeshed/stdlib/wsgiref/simple_server.pyi +37 -0
- jaclang/vendor/mypy/typeshed/stdlib/wsgiref/types.pyi +32 -0
- jaclang/vendor/mypy/typeshed/stdlib/wsgiref/util.pyi +24 -0
- jaclang/vendor/mypy/typeshed/stdlib/wsgiref/validate.pyi +50 -0
- jaclang/vendor/mypy/typeshed/stdlib/xdrlib.pyi +57 -0
- jaclang/vendor/mypy/typeshed/stdlib/xml/__init__.pyi +1 -0
- jaclang/vendor/mypy/typeshed/stdlib/xml/dom/NodeFilter.pyi +19 -0
- jaclang/vendor/mypy/typeshed/stdlib/xml/dom/__init__.pyi +69 -0
- jaclang/vendor/mypy/typeshed/stdlib/xml/dom/domreg.pyi +8 -0
- jaclang/vendor/mypy/typeshed/stdlib/xml/dom/expatbuilder.pyi +100 -0
- jaclang/vendor/mypy/typeshed/stdlib/xml/dom/minicompat.pyi +22 -0
- jaclang/vendor/mypy/typeshed/stdlib/xml/dom/minidom.pyi +404 -0
- jaclang/vendor/mypy/typeshed/stdlib/xml/dom/pulldom.pyi +94 -0
- jaclang/vendor/mypy/typeshed/stdlib/xml/dom/xmlbuilder.pyi +108 -0
- jaclang/vendor/mypy/typeshed/stdlib/xml/etree/ElementInclude.pyi +28 -0
- jaclang/vendor/mypy/typeshed/stdlib/xml/etree/ElementPath.pyi +34 -0
- jaclang/vendor/mypy/typeshed/stdlib/xml/etree/ElementTree.pyi +327 -0
- jaclang/vendor/mypy/typeshed/stdlib/xml/etree/__init__.pyi +0 -0
- jaclang/vendor/mypy/typeshed/stdlib/xml/etree/cElementTree.pyi +1 -0
- jaclang/vendor/mypy/typeshed/stdlib/xml/parsers/__init__.pyi +1 -0
- jaclang/vendor/mypy/typeshed/stdlib/xml/parsers/expat/__init__.pyi +1 -0
- jaclang/vendor/mypy/typeshed/stdlib/xml/parsers/expat/errors.pyi +1 -0
- jaclang/vendor/mypy/typeshed/stdlib/xml/parsers/expat/model.pyi +1 -0
- jaclang/vendor/mypy/typeshed/stdlib/xml/sax/__init__.pyi +25 -0
- jaclang/vendor/mypy/typeshed/stdlib/xml/sax/_exceptions.pyi +19 -0
- jaclang/vendor/mypy/typeshed/stdlib/xml/sax/handler.pyi +55 -0
- jaclang/vendor/mypy/typeshed/stdlib/xml/sax/saxutils.pyi +60 -0
- jaclang/vendor/mypy/typeshed/stdlib/xml/sax/xmlreader.pyi +87 -0
- jaclang/vendor/mypy/typeshed/stdlib/xmlrpc/__init__.pyi +0 -0
- jaclang/vendor/mypy/typeshed/stdlib/xmlrpc/client.pyi +296 -0
- jaclang/vendor/mypy/typeshed/stdlib/xmlrpc/server.pyi +143 -0
- jaclang/vendor/mypy/typeshed/stdlib/xxlimited.pyi +22 -0
- jaclang/vendor/mypy/typeshed/stdlib/zipapp.pyi +20 -0
- jaclang/vendor/mypy/typeshed/stdlib/zipfile/__init__.pyi +306 -0
- jaclang/vendor/mypy/typeshed/stdlib/zipfile/_path.pyi +95 -0
- jaclang/vendor/mypy/typeshed/stdlib/zipimport.pyi +32 -0
- jaclang/vendor/mypy/typeshed/stdlib/zlib.pyi +56 -0
- jaclang/vendor/mypy/typeshed/stdlib/zoneinfo/__init__.pyi +38 -0
- jaclang/vendor/mypy/typeshed/stubs/mypy-extensions/mypy_extensions.pyi +218 -0
- jaclang/vendor/mypy/typestate.py +5 -15
- jaclang/vendor/mypy/typetraverser.py +9 -3
- jaclang/vendor/mypy/typevars.py +2 -8
- jaclang/vendor/mypy/util.py +14 -45
- jaclang/vendor/mypy/version.py +1 -19
- jaclang/vendor/mypy/visitor.py +3 -9
- jaclang/vendor/mypy/xml/mypy-html.css +104 -0
- jaclang/vendor/mypy/xml/mypy-html.xslt +81 -0
- jaclang/vendor/mypy/xml/mypy-txt.xslt +100 -0
- jaclang/vendor/mypy/xml/mypy.xsd +50 -0
- jaclang/vendor/mypy-1.10.0.dist-info/LICENSE +229 -0
- jaclang/vendor/mypy-1.10.0.dist-info/METADATA +48 -0
- jaclang/vendor/mypy-1.10.0.dist-info/RECORD +1241 -0
- jaclang/vendor/mypy-1.10.0.dist-info/WHEEL +6 -0
- jaclang/vendor/mypy-1.10.0.dist-info/entry_points.txt +6 -0
- jaclang/vendor/mypy-1.10.0.dist-info/top_level.txt +3 -0
- jaclang/vendor/mypy_extensions-1.0.0.dist-info/LICENSE +27 -0
- jaclang/vendor/mypy_extensions-1.0.0.dist-info/METADATA +29 -0
- jaclang/vendor/mypy_extensions-1.0.0.dist-info/RECORD +6 -0
- jaclang/vendor/mypy_extensions-1.0.0.dist-info/WHEEL +5 -0
- jaclang/vendor/mypy_extensions-1.0.0.dist-info/top_level.txt +1 -0
- jaclang/vendor/mypy_extensions.py +21 -40
- jaclang/vendor/mypyc/README.md +133 -0
- jaclang/vendor/mypyc/__main__.py +1 -3
- jaclang/vendor/mypyc/analysis/attrdefined.py +6 -22
- jaclang/vendor/mypyc/analysis/dataflow.py +5 -3
- jaclang/vendor/mypyc/analysis/ircheck.py +13 -26
- jaclang/vendor/mypyc/analysis/selfleaks.py +4 -0
- jaclang/vendor/mypyc/build.py +6 -19
- jaclang/vendor/mypyc/codegen/emit.py +20 -73
- jaclang/vendor/mypyc/codegen/emitclass.py +22 -72
- jaclang/vendor/mypyc/codegen/emitfunc.py +20 -62
- jaclang/vendor/mypyc/codegen/emitmodule.py +50 -117
- jaclang/vendor/mypyc/codegen/emitwrapper.py +22 -78
- jaclang/vendor/mypyc/codegen/literals.py +1 -3
- jaclang/vendor/mypyc/common.py +1 -3
- jaclang/vendor/mypyc/doc/Makefile +20 -0
- jaclang/vendor/mypyc/doc/bool_operations.rst +27 -0
- jaclang/vendor/mypyc/doc/compilation_units.rst +20 -0
- jaclang/vendor/mypyc/doc/conf.py +59 -0
- jaclang/vendor/mypyc/doc/cpython-timings.md +25 -0
- jaclang/vendor/mypyc/doc/dev-intro.md +548 -0
- jaclang/vendor/mypyc/doc/dict_operations.rst +59 -0
- jaclang/vendor/mypyc/doc/differences_from_python.rst +332 -0
- jaclang/vendor/mypyc/doc/float_operations.rst +50 -0
- jaclang/vendor/mypyc/doc/future.md +42 -0
- jaclang/vendor/mypyc/doc/getting_started.rst +240 -0
- jaclang/vendor/mypyc/doc/index.rst +61 -0
- jaclang/vendor/mypyc/doc/int_operations.rst +162 -0
- jaclang/vendor/mypyc/doc/introduction.rst +150 -0
- jaclang/vendor/mypyc/doc/list_operations.rst +65 -0
- jaclang/vendor/mypyc/doc/make.bat +35 -0
- jaclang/vendor/mypyc/doc/native_classes.rst +206 -0
- jaclang/vendor/mypyc/doc/native_operations.rst +55 -0
- jaclang/vendor/mypyc/doc/performance_tips_and_tricks.rst +244 -0
- jaclang/vendor/mypyc/doc/set_operations.rst +47 -0
- jaclang/vendor/mypyc/doc/str_operations.rst +35 -0
- jaclang/vendor/mypyc/doc/tuple_operations.rst +33 -0
- jaclang/vendor/mypyc/doc/using_type_annotations.rst +398 -0
- jaclang/vendor/mypyc/external/googletest/LICENSE +28 -0
- jaclang/vendor/mypyc/external/googletest/README.md +280 -0
- jaclang/vendor/mypyc/external/googletest/include/gtest/gtest-death-test.h +294 -0
- jaclang/vendor/mypyc/external/googletest/include/gtest/gtest-message.h +250 -0
- jaclang/vendor/mypyc/external/googletest/include/gtest/gtest-param-test.h +1444 -0
- jaclang/vendor/mypyc/external/googletest/include/gtest/gtest-param-test.h.pump +510 -0
- jaclang/vendor/mypyc/external/googletest/include/gtest/gtest-printers.h +993 -0
- jaclang/vendor/mypyc/external/googletest/include/gtest/gtest-spi.h +232 -0
- jaclang/vendor/mypyc/external/googletest/include/gtest/gtest-test-part.h +179 -0
- jaclang/vendor/mypyc/external/googletest/include/gtest/gtest-typed-test.h +263 -0
- jaclang/vendor/mypyc/external/googletest/include/gtest/gtest.h +2236 -0
- jaclang/vendor/mypyc/external/googletest/include/gtest/gtest_pred_impl.h +358 -0
- jaclang/vendor/mypyc/external/googletest/include/gtest/gtest_prod.h +58 -0
- jaclang/vendor/mypyc/external/googletest/include/gtest/internal/custom/gtest-port.h +69 -0
- jaclang/vendor/mypyc/external/googletest/include/gtest/internal/custom/gtest-printers.h +42 -0
- jaclang/vendor/mypyc/external/googletest/include/gtest/internal/custom/gtest.h +41 -0
- jaclang/vendor/mypyc/external/googletest/include/gtest/internal/gtest-death-test-internal.h +319 -0
- jaclang/vendor/mypyc/external/googletest/include/gtest/internal/gtest-filepath.h +206 -0
- jaclang/vendor/mypyc/external/googletest/include/gtest/internal/gtest-internal.h +1238 -0
- jaclang/vendor/mypyc/external/googletest/include/gtest/internal/gtest-linked_ptr.h +243 -0
- jaclang/vendor/mypyc/external/googletest/include/gtest/internal/gtest-param-util-generated.h +5146 -0
- jaclang/vendor/mypyc/external/googletest/include/gtest/internal/gtest-param-util-generated.h.pump +286 -0
- jaclang/vendor/mypyc/external/googletest/include/gtest/internal/gtest-param-util.h +731 -0
- jaclang/vendor/mypyc/external/googletest/include/gtest/internal/gtest-port-arch.h +93 -0
- jaclang/vendor/mypyc/external/googletest/include/gtest/internal/gtest-port.h +2560 -0
- jaclang/vendor/mypyc/external/googletest/include/gtest/internal/gtest-string.h +167 -0
- jaclang/vendor/mypyc/external/googletest/include/gtest/internal/gtest-tuple.h +1020 -0
- jaclang/vendor/mypyc/external/googletest/include/gtest/internal/gtest-tuple.h.pump +347 -0
- jaclang/vendor/mypyc/external/googletest/include/gtest/internal/gtest-type-util.h +3331 -0
- jaclang/vendor/mypyc/external/googletest/include/gtest/internal/gtest-type-util.h.pump +297 -0
- jaclang/vendor/mypyc/external/googletest/make/Makefile +61 -0
- jaclang/vendor/mypyc/external/googletest/src/gtest-all.cc +48 -0
- jaclang/vendor/mypyc/external/googletest/src/gtest-death-test.cc +1342 -0
- jaclang/vendor/mypyc/external/googletest/src/gtest-filepath.cc +387 -0
- jaclang/vendor/mypyc/external/googletest/src/gtest-internal-inl.h +1183 -0
- jaclang/vendor/mypyc/external/googletest/src/gtest-port.cc +1259 -0
- jaclang/vendor/mypyc/external/googletest/src/gtest-printers.cc +373 -0
- jaclang/vendor/mypyc/external/googletest/src/gtest-test-part.cc +110 -0
- jaclang/vendor/mypyc/external/googletest/src/gtest-typed-test.cc +118 -0
- jaclang/vendor/mypyc/external/googletest/src/gtest.cc +5388 -0
- jaclang/vendor/mypyc/external/googletest/src/gtest_main.cc +38 -0
- jaclang/vendor/mypyc/ir/class_ir.py +8 -24
- jaclang/vendor/mypyc/ir/func_ir.py +3 -16
- jaclang/vendor/mypyc/ir/module_ir.py +2 -6
- jaclang/vendor/mypyc/ir/ops.py +103 -66
- jaclang/vendor/mypyc/ir/pprint.py +35 -55
- jaclang/vendor/mypyc/ir/rtypes.py +16 -48
- jaclang/vendor/mypyc/irbuild/ast_helpers.py +4 -1
- jaclang/vendor/mypyc/irbuild/builder.py +46 -148
- jaclang/vendor/mypyc/irbuild/callable_class.py +5 -19
- jaclang/vendor/mypyc/irbuild/classdef.py +27 -83
- jaclang/vendor/mypyc/irbuild/env_class.py +3 -9
- jaclang/vendor/mypyc/irbuild/expression.py +42 -100
- jaclang/vendor/mypyc/irbuild/for_helpers.py +56 -105
- jaclang/vendor/mypyc/irbuild/format_str_tokenizer.py +1 -4
- jaclang/vendor/mypyc/irbuild/function.py +40 -132
- jaclang/vendor/mypyc/irbuild/generator.py +14 -49
- jaclang/vendor/mypyc/irbuild/ll_builder.py +197 -426
- jaclang/vendor/mypyc/irbuild/mapper.py +2 -13
- jaclang/vendor/mypyc/irbuild/match.py +11 -36
- jaclang/vendor/mypyc/irbuild/nonlocalcontrol.py +2 -7
- jaclang/vendor/mypyc/irbuild/prebuildvisitor.py +1 -4
- jaclang/vendor/mypyc/irbuild/prepare.py +25 -83
- jaclang/vendor/mypyc/irbuild/specialize.py +22 -72
- jaclang/vendor/mypyc/irbuild/statement.py +30 -96
- jaclang/vendor/mypyc/irbuild/targets.py +1 -3
- jaclang/vendor/mypyc/irbuild/util.py +2 -8
- jaclang/vendor/mypyc/irbuild/vtable.py +1 -3
- jaclang/vendor/mypyc/lib-rt/CPy.h +638 -0
- jaclang/vendor/mypyc/lib-rt/bytes_ops.c +143 -0
- jaclang/vendor/mypyc/lib-rt/dict_ops.c +446 -0
- jaclang/vendor/mypyc/lib-rt/exc_ops.c +259 -0
- jaclang/vendor/mypyc/lib-rt/float_ops.c +192 -0
- jaclang/vendor/mypyc/lib-rt/generic_ops.c +64 -0
- jaclang/vendor/mypyc/lib-rt/getargs.c +450 -0
- jaclang/vendor/mypyc/lib-rt/getargsfast.c +569 -0
- jaclang/vendor/mypyc/lib-rt/init.c +13 -0
- jaclang/vendor/mypyc/lib-rt/int_ops.c +803 -0
- jaclang/vendor/mypyc/lib-rt/list_ops.c +335 -0
- jaclang/vendor/mypyc/lib-rt/misc_ops.c +942 -0
- jaclang/vendor/mypyc/lib-rt/module_shim.tmpl +18 -0
- jaclang/vendor/mypyc/lib-rt/mypyc_util.h +118 -0
- jaclang/vendor/mypyc/lib-rt/pythoncapi_compat.h +497 -0
- jaclang/vendor/mypyc/lib-rt/pythonsupport.h +533 -0
- jaclang/vendor/mypyc/lib-rt/set_ops.c +17 -0
- jaclang/vendor/mypyc/lib-rt/setup.py +70 -0
- jaclang/vendor/mypyc/lib-rt/str_ops.c +241 -0
- jaclang/vendor/mypyc/lib-rt/test_capi.cc +585 -0
- jaclang/vendor/mypyc/lib-rt/tuple_ops.c +61 -0
- jaclang/vendor/mypyc/lower/__init__.py +0 -0
- jaclang/vendor/mypyc/lower/int_ops.py +113 -0
- jaclang/vendor/mypyc/lower/list_ops.py +45 -0
- jaclang/vendor/mypyc/lower/misc_ops.py +12 -0
- jaclang/vendor/mypyc/lower/registry.py +26 -0
- jaclang/vendor/mypyc/options.py +1 -3
- jaclang/vendor/mypyc/primitives/dict_ops.py +1 -4
- jaclang/vendor/mypyc/primitives/exc_ops.py +3 -12
- jaclang/vendor/mypyc/primitives/int_ops.py +22 -32
- jaclang/vendor/mypyc/primitives/list_ops.py +10 -0
- jaclang/vendor/mypyc/primitives/misc_ops.py +28 -22
- jaclang/vendor/mypyc/primitives/registry.py +56 -19
- jaclang/vendor/mypyc/primitives/set_ops.py +1 -3
- jaclang/vendor/mypyc/rt_subtype.py +1 -2
- jaclang/vendor/mypyc/sametype.py +2 -5
- jaclang/vendor/mypyc/subtype.py +3 -12
- jaclang/vendor/mypyc/test/test_alwaysdefined.py +2 -6
- jaclang/vendor/mypyc/test/test_analysis.py +8 -24
- jaclang/vendor/mypyc/test/test_cheader.py +12 -4
- jaclang/vendor/mypyc/test/test_emit.py +4 -14
- jaclang/vendor/mypyc/test/test_emitclass.py +1 -8
- jaclang/vendor/mypyc/test/test_emitfunc.py +30 -77
- jaclang/vendor/mypyc/test/test_emitwrapper.py +1 -3
- jaclang/vendor/mypyc/test/test_exceptions.py +4 -12
- jaclang/vendor/mypyc/test/test_external.py +1 -5
- jaclang/vendor/mypyc/test/test_irbuild.py +2 -6
- jaclang/vendor/mypyc/test/test_ircheck.py +6 -17
- jaclang/vendor/mypyc/test/test_literals.py +1 -4
- jaclang/vendor/mypyc/test/test_lowering.py +56 -0
- jaclang/vendor/mypyc/test/test_namegen.py +1 -4
- jaclang/vendor/mypyc/test/test_optimizations.py +68 -0
- jaclang/vendor/mypyc/test/test_refcount.py +3 -9
- jaclang/vendor/mypyc/test/test_run.py +12 -38
- jaclang/vendor/mypyc/test/test_serialization.py +1 -3
- jaclang/vendor/mypyc/test/test_struct.py +3 -11
- jaclang/vendor/mypyc/test/test_tuplename.py +4 -13
- jaclang/vendor/mypyc/test/test_typeops.py +1 -4
- jaclang/vendor/mypyc/test/testutil.py +2 -6
- jaclang/vendor/mypyc/test-data/alwaysdefined.test +732 -0
- jaclang/vendor/mypyc/test-data/analysis.test +470 -0
- jaclang/vendor/mypyc/test-data/commandline.test +245 -0
- jaclang/vendor/mypyc/test-data/driver/driver.py +48 -0
- jaclang/vendor/mypyc/test-data/exceptions-freq.test +125 -0
- jaclang/vendor/mypyc/test-data/exceptions.test +699 -0
- jaclang/vendor/mypyc/test-data/fixtures/ir.py +373 -0
- jaclang/vendor/mypyc/test-data/fixtures/testutil.py +103 -0
- jaclang/vendor/mypyc/test-data/fixtures/typing-full.pyi +169 -0
- jaclang/vendor/mypyc/test-data/irbuild-any.test +236 -0
- jaclang/vendor/mypyc/test-data/irbuild-basic.test +3399 -0
- jaclang/vendor/mypyc/test-data/irbuild-bool.test +424 -0
- jaclang/vendor/mypyc/test-data/irbuild-bytes.test +181 -0
- jaclang/vendor/mypyc/test-data/irbuild-classes.test +1302 -0
- jaclang/vendor/mypyc/test-data/irbuild-constant-fold.test +480 -0
- jaclang/vendor/mypyc/test-data/irbuild-dict.test +584 -0
- jaclang/vendor/mypyc/test-data/irbuild-dunders.test +215 -0
- jaclang/vendor/mypyc/test-data/irbuild-float.test +497 -0
- jaclang/vendor/mypyc/test-data/irbuild-generics.test +150 -0
- jaclang/vendor/mypyc/test-data/irbuild-glue-methods.test +437 -0
- jaclang/vendor/mypyc/test-data/irbuild-i16.test +526 -0
- jaclang/vendor/mypyc/test-data/irbuild-i32.test +598 -0
- jaclang/vendor/mypyc/test-data/irbuild-i64.test +2144 -0
- jaclang/vendor/mypyc/test-data/irbuild-int.test +194 -0
- jaclang/vendor/mypyc/test-data/irbuild-isinstance.test +109 -0
- jaclang/vendor/mypyc/test-data/irbuild-lists.test +513 -0
- jaclang/vendor/mypyc/test-data/irbuild-match.test +1717 -0
- jaclang/vendor/mypyc/test-data/irbuild-math.test +64 -0
- jaclang/vendor/mypyc/test-data/irbuild-nested.test +807 -0
- jaclang/vendor/mypyc/test-data/irbuild-optional.test +536 -0
- jaclang/vendor/mypyc/test-data/irbuild-set.test +806 -0
- jaclang/vendor/mypyc/test-data/irbuild-singledispatch.test +257 -0
- jaclang/vendor/mypyc/test-data/irbuild-statements.test +1060 -0
- jaclang/vendor/mypyc/test-data/irbuild-str.test +312 -0
- jaclang/vendor/mypyc/test-data/irbuild-strip-asserts.test +12 -0
- jaclang/vendor/mypyc/test-data/irbuild-try.test +523 -0
- jaclang/vendor/mypyc/test-data/irbuild-tuple.test +386 -0
- jaclang/vendor/mypyc/test-data/irbuild-u8.test +543 -0
- jaclang/vendor/mypyc/test-data/irbuild-unreachable.test +241 -0
- jaclang/vendor/mypyc/test-data/irbuild-vectorcall.test +153 -0
- jaclang/vendor/mypyc/test-data/lowering-int.test +377 -0
- jaclang/vendor/mypyc/test-data/lowering-list.test +33 -0
- jaclang/vendor/mypyc/test-data/opt-copy-propagation.test +400 -0
- jaclang/vendor/mypyc/test-data/opt-flag-elimination.test +296 -0
- jaclang/vendor/mypyc/test-data/refcount.test +1482 -0
- jaclang/vendor/mypyc/test-data/run-async.test +173 -0
- jaclang/vendor/mypyc/test-data/run-attrs.test +318 -0
- jaclang/vendor/mypyc/test-data/run-bench.test +196 -0
- jaclang/vendor/mypyc/test-data/run-bools.test +229 -0
- jaclang/vendor/mypyc/test-data/run-bytes.test +302 -0
- jaclang/vendor/mypyc/test-data/run-classes.test +2505 -0
- jaclang/vendor/mypyc/test-data/run-dicts.test +334 -0
- jaclang/vendor/mypyc/test-data/run-dunders.test +945 -0
- jaclang/vendor/mypyc/test-data/run-exceptions.test +448 -0
- jaclang/vendor/mypyc/test-data/run-floats.test +516 -0
- jaclang/vendor/mypyc/test-data/run-functions.test +1310 -0
- jaclang/vendor/mypyc/test-data/run-generators.test +682 -0
- jaclang/vendor/mypyc/test-data/run-i16.test +338 -0
- jaclang/vendor/mypyc/test-data/run-i32.test +336 -0
- jaclang/vendor/mypyc/test-data/run-i64.test +1519 -0
- jaclang/vendor/mypyc/test-data/run-imports.test +265 -0
- jaclang/vendor/mypyc/test-data/run-integers.test +540 -0
- jaclang/vendor/mypyc/test-data/run-lists.test +411 -0
- jaclang/vendor/mypyc/test-data/run-loops.test +485 -0
- jaclang/vendor/mypyc/test-data/run-match.test +283 -0
- jaclang/vendor/mypyc/test-data/run-math.test +106 -0
- jaclang/vendor/mypyc/test-data/run-misc.test +1170 -0
- jaclang/vendor/mypyc/test-data/run-multimodule.test +887 -0
- jaclang/vendor/mypyc/test-data/run-mypy-sim.test +138 -0
- jaclang/vendor/mypyc/test-data/run-primitives.test +375 -0
- jaclang/vendor/mypyc/test-data/run-python37.test +159 -0
- jaclang/vendor/mypyc/test-data/run-python38.test +88 -0
- jaclang/vendor/mypyc/test-data/run-sets.test +150 -0
- jaclang/vendor/mypyc/test-data/run-singledispatch.test +698 -0
- jaclang/vendor/mypyc/test-data/run-strings.test +641 -0
- jaclang/vendor/mypyc/test-data/run-traits.test +411 -0
- jaclang/vendor/mypyc/test-data/run-tuples.test +258 -0
- jaclang/vendor/mypyc/test-data/run-u8.test +303 -0
- jaclang/vendor/mypyc/transform/copy_propagation.py +94 -0
- jaclang/vendor/mypyc/transform/exceptions.py +1 -5
- jaclang/vendor/mypyc/transform/flag_elimination.py +108 -0
- jaclang/vendor/mypyc/transform/ir_transform.py +368 -0
- jaclang/vendor/mypyc/transform/lower.py +33 -0
- jaclang/vendor/mypyc/transform/refcount.py +7 -30
- jaclang/vendor/mypyc/transform/uninit.py +4 -15
- jaclang/vendor/pluggy/__init__.py +15 -11
- jaclang/vendor/pluggy/_callers.py +34 -5
- jaclang/vendor/pluggy/_hooks.py +35 -7
- jaclang/vendor/pluggy/_manager.py +26 -3
- jaclang/vendor/pluggy/_result.py +0 -15
- jaclang/vendor/pluggy/_version.py +16 -0
- jaclang/vendor/pluggy/_warnings.py +27 -0
- jaclang/vendor/pluggy-1.5.0.dist-info/LICENSE +21 -0
- jaclang/vendor/pluggy-1.5.0.dist-info/METADATA +155 -0
- jaclang/vendor/pluggy-1.5.0.dist-info/RECORD +14 -0
- jaclang/vendor/pluggy-1.5.0.dist-info/top_level.txt +1 -0
- jaclang/vendor/pygls/__init__.py +25 -0
- jaclang/vendor/pygls/capabilities.py +460 -0
- jaclang/vendor/pygls/client.py +176 -0
- jaclang/vendor/pygls/constants.py +26 -0
- jaclang/vendor/pygls/exceptions.py +215 -0
- jaclang/vendor/pygls/feature_manager.py +244 -0
- jaclang/vendor/pygls/lsp/__init__.py +139 -0
- jaclang/vendor/pygls/lsp/client.py +1961 -0
- jaclang/vendor/pygls/progress.py +79 -0
- jaclang/vendor/pygls/protocol/__init__.py +78 -0
- jaclang/vendor/pygls/protocol/json_rpc.py +560 -0
- jaclang/vendor/pygls/protocol/language_server.py +569 -0
- jaclang/vendor/pygls/protocol/lsp_meta.py +51 -0
- jaclang/vendor/pygls/py.typed +2 -0
- jaclang/vendor/pygls/server.py +616 -0
- jaclang/vendor/pygls/uris.py +184 -0
- jaclang/vendor/pygls/workspace/__init__.py +97 -0
- jaclang/vendor/pygls/workspace/position_codec.py +206 -0
- jaclang/vendor/pygls/workspace/text_document.py +238 -0
- jaclang/vendor/pygls/workspace/workspace.py +323 -0
- jaclang/vendor/pygls-1.3.1.dist-info/LICENSE.txt +201 -0
- jaclang/vendor/pygls-1.3.1.dist-info/METADATA +105 -0
- jaclang/vendor/pygls-1.3.1.dist-info/RECORD +24 -0
- jaclang/vendor/pygls-1.3.1.dist-info/WHEEL +4 -0
- jaclang/vendor/typing_extensions-4.12.2.dist-info/LICENSE +279 -0
- jaclang/vendor/typing_extensions-4.12.2.dist-info/METADATA +67 -0
- jaclang/vendor/typing_extensions-4.12.2.dist-info/RECORD +5 -0
- jaclang/vendor/typing_extensions-4.12.2.dist-info/WHEEL +4 -0
- jaclang/vendor/typing_extensions.py +1209 -641
- jaclang-0.7.0.dist-info/METADATA +98 -0
- jaclang-0.7.0.dist-info/RECORD +1475 -0
- jaclang-0.7.0.dist-info/WHEEL +4 -0
- jaclang-0.7.0.dist-info/entry_points.txt +3 -0
- jaclang/compiler/generated/jac_parser.py +0 -4069
- jaclang/compiler/tests/test_workspace.py +0 -93
- jaclang/compiler/workspace.py +0 -234
- jaclang-0.6.1.dist-info/METADATA +0 -17
- jaclang-0.6.1.dist-info/RECORD +0 -430
- jaclang-0.6.1.dist-info/entry_points.txt +0 -2
- jaclang-0.6.1.dist-info/top_level.txt +0 -1
- /jaclang/{compiler/generated/__init__.py → vendor/attr/py.typed} +0 -0
- {jaclang-0.6.1.dist-info → jaclang/vendor/pluggy-1.5.0.dist-info}/WHEEL +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import abc
|
|
2
2
|
import collections
|
|
3
3
|
import collections.abc
|
|
4
|
+
import contextlib
|
|
4
5
|
import functools
|
|
5
6
|
import inspect
|
|
6
7
|
import operator
|
|
@@ -11,122 +12,131 @@ import warnings
|
|
|
11
12
|
|
|
12
13
|
__all__ = [
|
|
13
14
|
# Super-special typing primitives.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
'Any',
|
|
16
|
+
'ClassVar',
|
|
17
|
+
'Concatenate',
|
|
18
|
+
'Final',
|
|
19
|
+
'LiteralString',
|
|
20
|
+
'ParamSpec',
|
|
21
|
+
'ParamSpecArgs',
|
|
22
|
+
'ParamSpecKwargs',
|
|
23
|
+
'Self',
|
|
24
|
+
'Type',
|
|
25
|
+
'TypeVar',
|
|
26
|
+
'TypeVarTuple',
|
|
27
|
+
'Unpack',
|
|
28
|
+
|
|
27
29
|
# ABCs (from collections.abc).
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
30
|
+
'Awaitable',
|
|
31
|
+
'AsyncIterator',
|
|
32
|
+
'AsyncIterable',
|
|
33
|
+
'Coroutine',
|
|
34
|
+
'AsyncGenerator',
|
|
35
|
+
'AsyncContextManager',
|
|
36
|
+
'Buffer',
|
|
37
|
+
'ChainMap',
|
|
38
|
+
|
|
36
39
|
# Concrete collection types.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
40
|
+
'ContextManager',
|
|
41
|
+
'Counter',
|
|
42
|
+
'Deque',
|
|
43
|
+
'DefaultDict',
|
|
44
|
+
'NamedTuple',
|
|
45
|
+
'OrderedDict',
|
|
46
|
+
'TypedDict',
|
|
47
|
+
|
|
44
48
|
# Structural checks, a.k.a. protocols.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
'SupportsAbs',
|
|
50
|
+
'SupportsBytes',
|
|
51
|
+
'SupportsComplex',
|
|
52
|
+
'SupportsFloat',
|
|
53
|
+
'SupportsIndex',
|
|
54
|
+
'SupportsInt',
|
|
55
|
+
'SupportsRound',
|
|
56
|
+
|
|
52
57
|
# One-off things.
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
58
|
+
'Annotated',
|
|
59
|
+
'assert_never',
|
|
60
|
+
'assert_type',
|
|
61
|
+
'clear_overloads',
|
|
62
|
+
'dataclass_transform',
|
|
63
|
+
'deprecated',
|
|
64
|
+
'Doc',
|
|
65
|
+
'get_overloads',
|
|
66
|
+
'final',
|
|
67
|
+
'get_args',
|
|
68
|
+
'get_origin',
|
|
69
|
+
'get_original_bases',
|
|
70
|
+
'get_protocol_members',
|
|
71
|
+
'get_type_hints',
|
|
72
|
+
'IntVar',
|
|
73
|
+
'is_protocol',
|
|
74
|
+
'is_typeddict',
|
|
75
|
+
'Literal',
|
|
76
|
+
'NewType',
|
|
77
|
+
'overload',
|
|
78
|
+
'override',
|
|
79
|
+
'Protocol',
|
|
80
|
+
'reveal_type',
|
|
81
|
+
'runtime',
|
|
82
|
+
'runtime_checkable',
|
|
83
|
+
'Text',
|
|
84
|
+
'TypeAlias',
|
|
85
|
+
'TypeAliasType',
|
|
86
|
+
'TypeGuard',
|
|
87
|
+
'TypeIs',
|
|
88
|
+
'TYPE_CHECKING',
|
|
89
|
+
'Never',
|
|
90
|
+
'NoReturn',
|
|
91
|
+
'ReadOnly',
|
|
92
|
+
'Required',
|
|
93
|
+
'NotRequired',
|
|
94
|
+
|
|
87
95
|
# Pure aliases, have always been in typing
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
96
|
+
'AbstractSet',
|
|
97
|
+
'AnyStr',
|
|
98
|
+
'BinaryIO',
|
|
99
|
+
'Callable',
|
|
100
|
+
'Collection',
|
|
101
|
+
'Container',
|
|
102
|
+
'Dict',
|
|
103
|
+
'ForwardRef',
|
|
104
|
+
'FrozenSet',
|
|
105
|
+
'Generator',
|
|
106
|
+
'Generic',
|
|
107
|
+
'Hashable',
|
|
108
|
+
'IO',
|
|
109
|
+
'ItemsView',
|
|
110
|
+
'Iterable',
|
|
111
|
+
'Iterator',
|
|
112
|
+
'KeysView',
|
|
113
|
+
'List',
|
|
114
|
+
'Mapping',
|
|
115
|
+
'MappingView',
|
|
116
|
+
'Match',
|
|
117
|
+
'MutableMapping',
|
|
118
|
+
'MutableSequence',
|
|
119
|
+
'MutableSet',
|
|
120
|
+
'NoDefault',
|
|
121
|
+
'Optional',
|
|
122
|
+
'Pattern',
|
|
123
|
+
'Reversible',
|
|
124
|
+
'Sequence',
|
|
125
|
+
'Set',
|
|
126
|
+
'Sized',
|
|
127
|
+
'TextIO',
|
|
128
|
+
'Tuple',
|
|
129
|
+
'Union',
|
|
130
|
+
'ValuesView',
|
|
131
|
+
'cast',
|
|
132
|
+
'no_type_check',
|
|
133
|
+
'no_type_check_decorator',
|
|
125
134
|
]
|
|
126
135
|
|
|
127
136
|
# for backward compatibility
|
|
128
137
|
PEP_560 = True
|
|
129
138
|
GenericMeta = type
|
|
139
|
+
_PEP_696_IMPLEMENTED = sys.version_info >= (3, 13, 0, "beta")
|
|
130
140
|
|
|
131
141
|
# The functions below are modified copies of typing internal helpers.
|
|
132
142
|
# They are needed by _ProtocolMeta and they provide support for PEP 646.
|
|
@@ -140,73 +150,28 @@ class _Sentinel:
|
|
|
140
150
|
_marker = _Sentinel()
|
|
141
151
|
|
|
142
152
|
|
|
143
|
-
def _check_generic(cls, parameters, elen=_marker):
|
|
144
|
-
"""Check correct count for parameters of a generic cls (internal helper).
|
|
145
|
-
This gives a nice error message in case of count mismatch.
|
|
146
|
-
"""
|
|
147
|
-
if not elen:
|
|
148
|
-
raise TypeError(f"{cls} is not a generic class")
|
|
149
|
-
if elen is _marker:
|
|
150
|
-
if not hasattr(cls, "__parameters__") or not cls.__parameters__:
|
|
151
|
-
raise TypeError(f"{cls} is not a generic class")
|
|
152
|
-
elen = len(cls.__parameters__)
|
|
153
|
-
alen = len(parameters)
|
|
154
|
-
if alen != elen:
|
|
155
|
-
if hasattr(cls, "__parameters__"):
|
|
156
|
-
parameters = [p for p in cls.__parameters__ if not _is_unpack(p)]
|
|
157
|
-
num_tv_tuples = sum(isinstance(p, TypeVarTuple) for p in parameters)
|
|
158
|
-
if (num_tv_tuples > 0) and (alen >= elen - num_tv_tuples):
|
|
159
|
-
return
|
|
160
|
-
raise TypeError(
|
|
161
|
-
f"Too {'many' if alen > elen else 'few'} parameters for {cls};"
|
|
162
|
-
f" actual {alen}, expected {elen}"
|
|
163
|
-
)
|
|
164
|
-
|
|
165
|
-
|
|
166
153
|
if sys.version_info >= (3, 10):
|
|
167
|
-
|
|
168
154
|
def _should_collect_from_parameters(t):
|
|
169
155
|
return isinstance(
|
|
170
156
|
t, (typing._GenericAlias, _types.GenericAlias, _types.UnionType)
|
|
171
157
|
)
|
|
172
|
-
|
|
173
158
|
elif sys.version_info >= (3, 9):
|
|
174
|
-
|
|
175
159
|
def _should_collect_from_parameters(t):
|
|
176
160
|
return isinstance(t, (typing._GenericAlias, _types.GenericAlias))
|
|
177
|
-
|
|
178
161
|
else:
|
|
179
|
-
|
|
180
162
|
def _should_collect_from_parameters(t):
|
|
181
163
|
return isinstance(t, typing._GenericAlias) and not t._special
|
|
182
164
|
|
|
183
165
|
|
|
184
|
-
def _collect_type_vars(types, typevar_types=None):
|
|
185
|
-
"""Collect all type variable contained in types in order of
|
|
186
|
-
first appearance (lexicographic order). For example::
|
|
187
|
-
|
|
188
|
-
_collect_type_vars((T, List[S, T])) == (T, S)
|
|
189
|
-
"""
|
|
190
|
-
if typevar_types is None:
|
|
191
|
-
typevar_types = typing.TypeVar
|
|
192
|
-
tvars = []
|
|
193
|
-
for t in types:
|
|
194
|
-
if isinstance(t, typevar_types) and t not in tvars and not _is_unpack(t):
|
|
195
|
-
tvars.append(t)
|
|
196
|
-
if _should_collect_from_parameters(t):
|
|
197
|
-
tvars.extend([t for t in t.__parameters__ if t not in tvars])
|
|
198
|
-
return tuple(tvars)
|
|
199
|
-
|
|
200
|
-
|
|
201
166
|
NoReturn = typing.NoReturn
|
|
202
167
|
|
|
203
168
|
# Some unconstrained type variables. These are used by the container types.
|
|
204
169
|
# (These are not for export.)
|
|
205
|
-
T = typing.TypeVar(
|
|
206
|
-
KT = typing.TypeVar(
|
|
207
|
-
VT = typing.TypeVar(
|
|
208
|
-
T_co = typing.TypeVar(
|
|
209
|
-
T_contra = typing.TypeVar(
|
|
170
|
+
T = typing.TypeVar('T') # Any type.
|
|
171
|
+
KT = typing.TypeVar('KT') # Key type.
|
|
172
|
+
VT = typing.TypeVar('VT') # Value type.
|
|
173
|
+
T_co = typing.TypeVar('T_co', covariant=True) # Any type covariant containers.
|
|
174
|
+
T_contra = typing.TypeVar('T_contra', contravariant=True) # Ditto contravariant.
|
|
210
175
|
|
|
211
176
|
|
|
212
177
|
if sys.version_info >= (3, 11):
|
|
@@ -216,9 +181,7 @@ else:
|
|
|
216
181
|
class _AnyMeta(type):
|
|
217
182
|
def __instancecheck__(self, obj):
|
|
218
183
|
if self is Any:
|
|
219
|
-
raise TypeError(
|
|
220
|
-
"typing_extensions.Any cannot be used with isinstance()"
|
|
221
|
-
)
|
|
184
|
+
raise TypeError("typing_extensions.Any cannot be used with isinstance()")
|
|
222
185
|
return super().__instancecheck__(obj)
|
|
223
186
|
|
|
224
187
|
def __repr__(self):
|
|
@@ -235,7 +198,6 @@ else:
|
|
|
235
198
|
static type checkers. At runtime, Any should not be used with instance
|
|
236
199
|
checks.
|
|
237
200
|
"""
|
|
238
|
-
|
|
239
201
|
def __new__(cls, *args, **kwargs):
|
|
240
202
|
if cls is Any:
|
|
241
203
|
raise TypeError("Any cannot be instantiated")
|
|
@@ -247,7 +209,7 @@ ClassVar = typing.ClassVar
|
|
|
247
209
|
|
|
248
210
|
class _ExtensionsSpecialForm(typing._SpecialForm, _root=True):
|
|
249
211
|
def __repr__(self):
|
|
250
|
-
return
|
|
212
|
+
return 'typing_extensions.' + self._name
|
|
251
213
|
|
|
252
214
|
|
|
253
215
|
Final = typing.Final
|
|
@@ -298,7 +260,6 @@ def IntVar(name):
|
|
|
298
260
|
if sys.version_info >= (3, 10, 1):
|
|
299
261
|
Literal = typing.Literal
|
|
300
262
|
else:
|
|
301
|
-
|
|
302
263
|
def _flatten_literal_params(parameters):
|
|
303
264
|
"""An internal helper for Literal creation: flatten Literals among parameters"""
|
|
304
265
|
params = []
|
|
@@ -326,7 +287,7 @@ else:
|
|
|
326
287
|
|
|
327
288
|
class _LiteralForm(_ExtensionsSpecialForm, _root=True):
|
|
328
289
|
def __init__(self, doc: str):
|
|
329
|
-
self._name =
|
|
290
|
+
self._name = 'Literal'
|
|
330
291
|
self._doc = self.__doc__ = doc
|
|
331
292
|
|
|
332
293
|
def __getitem__(self, parameters):
|
|
@@ -354,8 +315,7 @@ else:
|
|
|
354
315
|
|
|
355
316
|
return _LiteralGenericAlias(self, parameters)
|
|
356
317
|
|
|
357
|
-
Literal = _LiteralForm(
|
|
358
|
-
doc="""\
|
|
318
|
+
Literal = _LiteralForm(doc="""\
|
|
359
319
|
A type that can be used to indicate to type checkers
|
|
360
320
|
that the corresponding value has a value literally equivalent
|
|
361
321
|
to the provided parameter. For example:
|
|
@@ -367,8 +327,7 @@ else:
|
|
|
367
327
|
|
|
368
328
|
Literal[...] cannot be subclassed. There is no runtime
|
|
369
329
|
checking verifying that the parameter is actually a value
|
|
370
|
-
instead of a type."""
|
|
371
|
-
)
|
|
330
|
+
instead of a type.""")
|
|
372
331
|
|
|
373
332
|
|
|
374
333
|
_overload_dummy = typing._overload_dummy
|
|
@@ -450,101 +409,162 @@ Coroutine = typing.Coroutine
|
|
|
450
409
|
AsyncIterable = typing.AsyncIterable
|
|
451
410
|
AsyncIterator = typing.AsyncIterator
|
|
452
411
|
Deque = typing.Deque
|
|
453
|
-
ContextManager = typing.ContextManager
|
|
454
|
-
AsyncContextManager = typing.AsyncContextManager
|
|
455
412
|
DefaultDict = typing.DefaultDict
|
|
456
413
|
OrderedDict = typing.OrderedDict
|
|
457
414
|
Counter = typing.Counter
|
|
458
415
|
ChainMap = typing.ChainMap
|
|
459
|
-
AsyncGenerator = typing.AsyncGenerator
|
|
460
416
|
Text = typing.Text
|
|
461
417
|
TYPE_CHECKING = typing.TYPE_CHECKING
|
|
462
418
|
|
|
463
419
|
|
|
420
|
+
if sys.version_info >= (3, 13, 0, "beta"):
|
|
421
|
+
from typing import AsyncContextManager, AsyncGenerator, ContextManager, Generator
|
|
422
|
+
else:
|
|
423
|
+
def _is_dunder(attr):
|
|
424
|
+
return attr.startswith('__') and attr.endswith('__')
|
|
425
|
+
|
|
426
|
+
# Python <3.9 doesn't have typing._SpecialGenericAlias
|
|
427
|
+
_special_generic_alias_base = getattr(
|
|
428
|
+
typing, "_SpecialGenericAlias", typing._GenericAlias
|
|
429
|
+
)
|
|
430
|
+
|
|
431
|
+
class _SpecialGenericAlias(_special_generic_alias_base, _root=True):
|
|
432
|
+
def __init__(self, origin, nparams, *, inst=True, name=None, defaults=()):
|
|
433
|
+
if _special_generic_alias_base is typing._GenericAlias:
|
|
434
|
+
# Python <3.9
|
|
435
|
+
self.__origin__ = origin
|
|
436
|
+
self._nparams = nparams
|
|
437
|
+
super().__init__(origin, nparams, special=True, inst=inst, name=name)
|
|
438
|
+
else:
|
|
439
|
+
# Python >= 3.9
|
|
440
|
+
super().__init__(origin, nparams, inst=inst, name=name)
|
|
441
|
+
self._defaults = defaults
|
|
442
|
+
|
|
443
|
+
def __setattr__(self, attr, val):
|
|
444
|
+
allowed_attrs = {'_name', '_inst', '_nparams', '_defaults'}
|
|
445
|
+
if _special_generic_alias_base is typing._GenericAlias:
|
|
446
|
+
# Python <3.9
|
|
447
|
+
allowed_attrs.add("__origin__")
|
|
448
|
+
if _is_dunder(attr) or attr in allowed_attrs:
|
|
449
|
+
object.__setattr__(self, attr, val)
|
|
450
|
+
else:
|
|
451
|
+
setattr(self.__origin__, attr, val)
|
|
452
|
+
|
|
453
|
+
@typing._tp_cache
|
|
454
|
+
def __getitem__(self, params):
|
|
455
|
+
if not isinstance(params, tuple):
|
|
456
|
+
params = (params,)
|
|
457
|
+
msg = "Parameters to generic types must be types."
|
|
458
|
+
params = tuple(typing._type_check(p, msg) for p in params)
|
|
459
|
+
if (
|
|
460
|
+
self._defaults
|
|
461
|
+
and len(params) < self._nparams
|
|
462
|
+
and len(params) + len(self._defaults) >= self._nparams
|
|
463
|
+
):
|
|
464
|
+
params = (*params, *self._defaults[len(params) - self._nparams:])
|
|
465
|
+
actual_len = len(params)
|
|
466
|
+
|
|
467
|
+
if actual_len != self._nparams:
|
|
468
|
+
if self._defaults:
|
|
469
|
+
expected = f"at least {self._nparams - len(self._defaults)}"
|
|
470
|
+
else:
|
|
471
|
+
expected = str(self._nparams)
|
|
472
|
+
if not self._nparams:
|
|
473
|
+
raise TypeError(f"{self} is not a generic class")
|
|
474
|
+
raise TypeError(
|
|
475
|
+
f"Too {'many' if actual_len > self._nparams else 'few'}"
|
|
476
|
+
f" arguments for {self};"
|
|
477
|
+
f" actual {actual_len}, expected {expected}"
|
|
478
|
+
)
|
|
479
|
+
return self.copy_with(params)
|
|
480
|
+
|
|
481
|
+
_NoneType = type(None)
|
|
482
|
+
Generator = _SpecialGenericAlias(
|
|
483
|
+
collections.abc.Generator, 3, defaults=(_NoneType, _NoneType)
|
|
484
|
+
)
|
|
485
|
+
AsyncGenerator = _SpecialGenericAlias(
|
|
486
|
+
collections.abc.AsyncGenerator, 2, defaults=(_NoneType,)
|
|
487
|
+
)
|
|
488
|
+
ContextManager = _SpecialGenericAlias(
|
|
489
|
+
contextlib.AbstractContextManager,
|
|
490
|
+
2,
|
|
491
|
+
name="ContextManager",
|
|
492
|
+
defaults=(typing.Optional[bool],)
|
|
493
|
+
)
|
|
494
|
+
AsyncContextManager = _SpecialGenericAlias(
|
|
495
|
+
contextlib.AbstractAsyncContextManager,
|
|
496
|
+
2,
|
|
497
|
+
name="AsyncContextManager",
|
|
498
|
+
defaults=(typing.Optional[bool],)
|
|
499
|
+
)
|
|
500
|
+
|
|
501
|
+
|
|
464
502
|
_PROTO_ALLOWLIST = {
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
"Iterable",
|
|
469
|
-
"Iterator",
|
|
470
|
-
"AsyncIterable",
|
|
471
|
-
"Hashable",
|
|
472
|
-
"Sized",
|
|
473
|
-
"Container",
|
|
474
|
-
"Collection",
|
|
475
|
-
"Reversible",
|
|
476
|
-
"Buffer",
|
|
503
|
+
'collections.abc': [
|
|
504
|
+
'Callable', 'Awaitable', 'Iterable', 'Iterator', 'AsyncIterable',
|
|
505
|
+
'Hashable', 'Sized', 'Container', 'Collection', 'Reversible', 'Buffer',
|
|
477
506
|
],
|
|
478
|
-
|
|
479
|
-
|
|
507
|
+
'contextlib': ['AbstractContextManager', 'AbstractAsyncContextManager'],
|
|
508
|
+
'typing_extensions': ['Buffer'],
|
|
480
509
|
}
|
|
481
510
|
|
|
482
511
|
|
|
483
|
-
_EXCLUDED_ATTRS = {
|
|
484
|
-
"
|
|
485
|
-
"
|
|
486
|
-
"__weakref__",
|
|
487
|
-
"_is_protocol",
|
|
488
|
-
"_is_runtime_protocol",
|
|
489
|
-
"__dict__",
|
|
490
|
-
"__slots__",
|
|
491
|
-
"__parameters__",
|
|
492
|
-
"__orig_bases__",
|
|
493
|
-
"__module__",
|
|
494
|
-
"_MutableMapping__marker",
|
|
495
|
-
"__doc__",
|
|
496
|
-
"__subclasshook__",
|
|
497
|
-
"__orig_class__",
|
|
498
|
-
"__init__",
|
|
499
|
-
"__new__",
|
|
500
|
-
"__protocol_attrs__",
|
|
501
|
-
"__callable_proto_members_only__",
|
|
512
|
+
_EXCLUDED_ATTRS = frozenset(typing.EXCLUDED_ATTRIBUTES) | {
|
|
513
|
+
"__match_args__", "__protocol_attrs__", "__non_callable_proto_members__",
|
|
514
|
+
"__final__",
|
|
502
515
|
}
|
|
503
516
|
|
|
504
|
-
if sys.version_info >= (3, 9):
|
|
505
|
-
_EXCLUDED_ATTRS.add("__class_getitem__")
|
|
506
|
-
|
|
507
|
-
if sys.version_info >= (3, 12):
|
|
508
|
-
_EXCLUDED_ATTRS.add("__type_params__")
|
|
509
|
-
|
|
510
|
-
_EXCLUDED_ATTRS = frozenset(_EXCLUDED_ATTRS)
|
|
511
|
-
|
|
512
517
|
|
|
513
518
|
def _get_protocol_attrs(cls):
|
|
514
519
|
attrs = set()
|
|
515
520
|
for base in cls.__mro__[:-1]: # without object
|
|
516
|
-
if base.__name__ in {
|
|
521
|
+
if base.__name__ in {'Protocol', 'Generic'}:
|
|
517
522
|
continue
|
|
518
|
-
annotations = getattr(base,
|
|
523
|
+
annotations = getattr(base, '__annotations__', {})
|
|
519
524
|
for attr in (*base.__dict__, *annotations):
|
|
520
|
-
if not attr.startswith(
|
|
525
|
+
if (not attr.startswith('_abc_') and attr not in _EXCLUDED_ATTRS):
|
|
521
526
|
attrs.add(attr)
|
|
522
527
|
return attrs
|
|
523
528
|
|
|
524
529
|
|
|
525
530
|
def _caller(depth=2):
|
|
526
531
|
try:
|
|
527
|
-
return sys._getframe(depth).f_globals.get(
|
|
532
|
+
return sys._getframe(depth).f_globals.get('__name__', '__main__')
|
|
528
533
|
except (AttributeError, ValueError): # For platforms without _getframe()
|
|
529
534
|
return None
|
|
530
535
|
|
|
531
536
|
|
|
532
|
-
#
|
|
533
|
-
#
|
|
534
|
-
if sys.version_info >= (3,
|
|
537
|
+
# `__match_args__` attribute was removed from protocol members in 3.13,
|
|
538
|
+
# we want to backport this change to older Python versions.
|
|
539
|
+
if sys.version_info >= (3, 13):
|
|
535
540
|
Protocol = typing.Protocol
|
|
536
541
|
else:
|
|
537
|
-
|
|
538
542
|
def _allow_reckless_class_checks(depth=3):
|
|
539
543
|
"""Allow instance and class checks for special stdlib modules.
|
|
540
544
|
The abc and functools modules indiscriminately call isinstance() and
|
|
541
545
|
issubclass() on the whole MRO of a user class, which may contain protocols.
|
|
542
546
|
"""
|
|
543
|
-
return _caller(depth) in {
|
|
547
|
+
return _caller(depth) in {'abc', 'functools', None}
|
|
544
548
|
|
|
545
549
|
def _no_init(self, *args, **kwargs):
|
|
546
550
|
if type(self)._is_protocol:
|
|
547
|
-
raise TypeError(
|
|
551
|
+
raise TypeError('Protocols cannot be instantiated')
|
|
552
|
+
|
|
553
|
+
def _type_check_issubclass_arg_1(arg):
|
|
554
|
+
"""Raise TypeError if `arg` is not an instance of `type`
|
|
555
|
+
in `issubclass(arg, <protocol>)`.
|
|
556
|
+
|
|
557
|
+
In most cases, this is verified by type.__subclasscheck__.
|
|
558
|
+
Checking it again unnecessarily would slow down issubclass() checks,
|
|
559
|
+
so, we don't perform this check unless we absolutely have to.
|
|
560
|
+
|
|
561
|
+
For various error paths, however,
|
|
562
|
+
we want to ensure that *this* error message is shown to the user
|
|
563
|
+
where relevant, rather than a typing.py-specific error message.
|
|
564
|
+
"""
|
|
565
|
+
if not isinstance(arg, type):
|
|
566
|
+
# Same error message as for issubclass(1, int).
|
|
567
|
+
raise TypeError('issubclass() arg 1 must be a class')
|
|
548
568
|
|
|
549
569
|
# Inheriting from typing._ProtocolMeta isn't actually desirable,
|
|
550
570
|
# but is necessary to allow typing.Protocol and typing_extensions.Protocol
|
|
@@ -576,34 +596,30 @@ else:
|
|
|
576
596
|
abc.ABCMeta.__init__(cls, *args, **kwargs)
|
|
577
597
|
if getattr(cls, "_is_protocol", False):
|
|
578
598
|
cls.__protocol_attrs__ = _get_protocol_attrs(cls)
|
|
579
|
-
# PEP 544 prohibits using issubclass()
|
|
580
|
-
# with protocols that have non-method members.
|
|
581
|
-
cls.__callable_proto_members_only__ = all(
|
|
582
|
-
callable(getattr(cls, attr, None))
|
|
583
|
-
for attr in cls.__protocol_attrs__
|
|
584
|
-
)
|
|
585
599
|
|
|
586
600
|
def __subclasscheck__(cls, other):
|
|
587
601
|
if cls is Protocol:
|
|
588
602
|
return type.__subclasscheck__(cls, other)
|
|
589
603
|
if (
|
|
590
|
-
getattr(cls,
|
|
604
|
+
getattr(cls, '_is_protocol', False)
|
|
591
605
|
and not _allow_reckless_class_checks()
|
|
592
606
|
):
|
|
593
|
-
if not
|
|
594
|
-
|
|
595
|
-
raise TypeError(
|
|
607
|
+
if not getattr(cls, '_is_runtime_protocol', False):
|
|
608
|
+
_type_check_issubclass_arg_1(other)
|
|
609
|
+
raise TypeError(
|
|
610
|
+
"Instance and class checks can only be used with "
|
|
611
|
+
"@runtime_checkable protocols"
|
|
612
|
+
)
|
|
596
613
|
if (
|
|
597
|
-
|
|
614
|
+
# this attribute is set by @runtime_checkable:
|
|
615
|
+
cls.__non_callable_proto_members__
|
|
598
616
|
and cls.__dict__.get("__subclasshook__") is _proto_hook
|
|
599
617
|
):
|
|
618
|
+
_type_check_issubclass_arg_1(other)
|
|
619
|
+
non_method_attrs = sorted(cls.__non_callable_proto_members__)
|
|
600
620
|
raise TypeError(
|
|
601
|
-
"Protocols with non-method members don't support issubclass()"
|
|
602
|
-
|
|
603
|
-
if not getattr(cls, "_is_runtime_protocol", False):
|
|
604
|
-
raise TypeError(
|
|
605
|
-
"Instance and class checks can only be used with "
|
|
606
|
-
"@runtime_checkable protocols"
|
|
621
|
+
"Protocols with non-method members don't support issubclass()."
|
|
622
|
+
f" Non-method members: {str(non_method_attrs)[1:-1]}."
|
|
607
623
|
)
|
|
608
624
|
return abc.ABCMeta.__subclasscheck__(cls, other)
|
|
609
625
|
|
|
@@ -617,13 +633,11 @@ else:
|
|
|
617
633
|
return abc.ABCMeta.__instancecheck__(cls, instance)
|
|
618
634
|
|
|
619
635
|
if (
|
|
620
|
-
not getattr(cls,
|
|
621
|
-
|
|
636
|
+
not getattr(cls, '_is_runtime_protocol', False) and
|
|
637
|
+
not _allow_reckless_class_checks()
|
|
622
638
|
):
|
|
623
|
-
raise TypeError(
|
|
624
|
-
|
|
625
|
-
" @runtime_checkable protocols"
|
|
626
|
-
)
|
|
639
|
+
raise TypeError("Instance and class checks can only be used with"
|
|
640
|
+
" @runtime_checkable protocols")
|
|
627
641
|
|
|
628
642
|
if abc.ABCMeta.__instancecheck__(cls, instance):
|
|
629
643
|
return True
|
|
@@ -633,7 +647,8 @@ else:
|
|
|
633
647
|
val = inspect.getattr_static(instance, attr)
|
|
634
648
|
except AttributeError:
|
|
635
649
|
break
|
|
636
|
-
|
|
650
|
+
# this attribute is set by @runtime_checkable:
|
|
651
|
+
if val is None and attr not in cls.__non_callable_proto_members__:
|
|
637
652
|
break
|
|
638
653
|
else:
|
|
639
654
|
return True
|
|
@@ -656,7 +671,7 @@ else:
|
|
|
656
671
|
|
|
657
672
|
@classmethod
|
|
658
673
|
def _proto_hook(cls, other):
|
|
659
|
-
if not cls.__dict__.get(
|
|
674
|
+
if not cls.__dict__.get('_is_protocol', False):
|
|
660
675
|
return NotImplemented
|
|
661
676
|
|
|
662
677
|
for attr in cls.__protocol_attrs__:
|
|
@@ -668,7 +683,7 @@ else:
|
|
|
668
683
|
break
|
|
669
684
|
|
|
670
685
|
# ...or in annotations, if it is a sub-protocol.
|
|
671
|
-
annotations = getattr(base,
|
|
686
|
+
annotations = getattr(base, '__annotations__', {})
|
|
672
687
|
if (
|
|
673
688
|
isinstance(annotations, collections.abc.Mapping)
|
|
674
689
|
and attr in annotations
|
|
@@ -689,11 +704,11 @@ else:
|
|
|
689
704
|
super().__init_subclass__(*args, **kwargs)
|
|
690
705
|
|
|
691
706
|
# Determine if this is a protocol or a concrete subclass.
|
|
692
|
-
if not cls.__dict__.get(
|
|
707
|
+
if not cls.__dict__.get('_is_protocol', False):
|
|
693
708
|
cls._is_protocol = any(b is Protocol for b in cls.__bases__)
|
|
694
709
|
|
|
695
710
|
# Set (or override) the protocol subclass hook.
|
|
696
|
-
if
|
|
711
|
+
if '__subclasshook__' not in cls.__dict__:
|
|
697
712
|
cls.__subclasshook__ = _proto_hook
|
|
698
713
|
|
|
699
714
|
# Prohibit instantiation for protocol classes
|
|
@@ -701,8 +716,63 @@ else:
|
|
|
701
716
|
cls.__init__ = _no_init
|
|
702
717
|
|
|
703
718
|
|
|
719
|
+
if sys.version_info >= (3, 13):
|
|
720
|
+
runtime_checkable = typing.runtime_checkable
|
|
721
|
+
else:
|
|
722
|
+
def runtime_checkable(cls):
|
|
723
|
+
"""Mark a protocol class as a runtime protocol.
|
|
724
|
+
|
|
725
|
+
Such protocol can be used with isinstance() and issubclass().
|
|
726
|
+
Raise TypeError if applied to a non-protocol class.
|
|
727
|
+
This allows a simple-minded structural check very similar to
|
|
728
|
+
one trick ponies in collections.abc such as Iterable.
|
|
729
|
+
|
|
730
|
+
For example::
|
|
731
|
+
|
|
732
|
+
@runtime_checkable
|
|
733
|
+
class Closable(Protocol):
|
|
734
|
+
def close(self): ...
|
|
735
|
+
|
|
736
|
+
assert isinstance(open('/some/file'), Closable)
|
|
737
|
+
|
|
738
|
+
Warning: this will check only the presence of the required methods,
|
|
739
|
+
not their type signatures!
|
|
740
|
+
"""
|
|
741
|
+
if not issubclass(cls, typing.Generic) or not getattr(cls, '_is_protocol', False):
|
|
742
|
+
raise TypeError(f'@runtime_checkable can be only applied to protocol classes,'
|
|
743
|
+
f' got {cls!r}')
|
|
744
|
+
cls._is_runtime_protocol = True
|
|
745
|
+
|
|
746
|
+
# typing.Protocol classes on <=3.11 break if we execute this block,
|
|
747
|
+
# because typing.Protocol classes on <=3.11 don't have a
|
|
748
|
+
# `__protocol_attrs__` attribute, and this block relies on the
|
|
749
|
+
# `__protocol_attrs__` attribute. Meanwhile, typing.Protocol classes on 3.12.2+
|
|
750
|
+
# break if we *don't* execute this block, because *they* assume that all
|
|
751
|
+
# protocol classes have a `__non_callable_proto_members__` attribute
|
|
752
|
+
# (which this block sets)
|
|
753
|
+
if isinstance(cls, _ProtocolMeta) or sys.version_info >= (3, 12, 2):
|
|
754
|
+
# PEP 544 prohibits using issubclass()
|
|
755
|
+
# with protocols that have non-method members.
|
|
756
|
+
# See gh-113320 for why we compute this attribute here,
|
|
757
|
+
# rather than in `_ProtocolMeta.__init__`
|
|
758
|
+
cls.__non_callable_proto_members__ = set()
|
|
759
|
+
for attr in cls.__protocol_attrs__:
|
|
760
|
+
try:
|
|
761
|
+
is_callable = callable(getattr(cls, attr, None))
|
|
762
|
+
except Exception as e:
|
|
763
|
+
raise TypeError(
|
|
764
|
+
f"Failed to determine whether protocol member {attr!r} "
|
|
765
|
+
"is a method member"
|
|
766
|
+
) from e
|
|
767
|
+
else:
|
|
768
|
+
if not is_callable:
|
|
769
|
+
cls.__non_callable_proto_members__.add(attr)
|
|
770
|
+
|
|
771
|
+
return cls
|
|
772
|
+
|
|
773
|
+
|
|
704
774
|
# The "runtime" alias exists for backwards compatibility.
|
|
705
|
-
runtime = runtime_checkable
|
|
775
|
+
runtime = runtime_checkable
|
|
706
776
|
|
|
707
777
|
|
|
708
778
|
# Our version of runtime-checkable protocols is faster on Python 3.8-3.11
|
|
@@ -715,11 +785,9 @@ if sys.version_info >= (3, 12):
|
|
|
715
785
|
SupportsAbs = typing.SupportsAbs
|
|
716
786
|
SupportsRound = typing.SupportsRound
|
|
717
787
|
else:
|
|
718
|
-
|
|
719
788
|
@runtime_checkable
|
|
720
789
|
class SupportsInt(Protocol):
|
|
721
790
|
"""An ABC with one abstract method __int__."""
|
|
722
|
-
|
|
723
791
|
__slots__ = ()
|
|
724
792
|
|
|
725
793
|
@abc.abstractmethod
|
|
@@ -729,7 +797,6 @@ else:
|
|
|
729
797
|
@runtime_checkable
|
|
730
798
|
class SupportsFloat(Protocol):
|
|
731
799
|
"""An ABC with one abstract method __float__."""
|
|
732
|
-
|
|
733
800
|
__slots__ = ()
|
|
734
801
|
|
|
735
802
|
@abc.abstractmethod
|
|
@@ -739,7 +806,6 @@ else:
|
|
|
739
806
|
@runtime_checkable
|
|
740
807
|
class SupportsComplex(Protocol):
|
|
741
808
|
"""An ABC with one abstract method __complex__."""
|
|
742
|
-
|
|
743
809
|
__slots__ = ()
|
|
744
810
|
|
|
745
811
|
@abc.abstractmethod
|
|
@@ -749,7 +815,6 @@ else:
|
|
|
749
815
|
@runtime_checkable
|
|
750
816
|
class SupportsBytes(Protocol):
|
|
751
817
|
"""An ABC with one abstract method __bytes__."""
|
|
752
|
-
|
|
753
818
|
__slots__ = ()
|
|
754
819
|
|
|
755
820
|
@abc.abstractmethod
|
|
@@ -769,7 +834,6 @@ else:
|
|
|
769
834
|
"""
|
|
770
835
|
An ABC with one abstract method __abs__ that is covariant in its return type.
|
|
771
836
|
"""
|
|
772
|
-
|
|
773
837
|
__slots__ = ()
|
|
774
838
|
|
|
775
839
|
@abc.abstractmethod
|
|
@@ -781,7 +845,6 @@ else:
|
|
|
781
845
|
"""
|
|
782
846
|
An ABC with one abstract method __round__ that is covariant in its return type.
|
|
783
847
|
"""
|
|
784
|
-
|
|
785
848
|
__slots__ = ()
|
|
786
849
|
|
|
787
850
|
@abc.abstractmethod
|
|
@@ -794,18 +857,21 @@ def _ensure_subclassable(mro_entries):
|
|
|
794
857
|
if sys.implementation.name == "pypy" and sys.version_info < (3, 9):
|
|
795
858
|
cls_dict = {
|
|
796
859
|
"__call__": staticmethod(func),
|
|
797
|
-
"__mro_entries__": staticmethod(mro_entries)
|
|
860
|
+
"__mro_entries__": staticmethod(mro_entries)
|
|
798
861
|
}
|
|
799
862
|
t = type(func.__name__, (), cls_dict)
|
|
800
863
|
return functools.update_wrapper(t(), func)
|
|
801
864
|
else:
|
|
802
865
|
func.__mro_entries__ = mro_entries
|
|
803
866
|
return func
|
|
804
|
-
|
|
805
867
|
return inner
|
|
806
868
|
|
|
807
869
|
|
|
808
|
-
|
|
870
|
+
# Update this to something like >=3.13.0b1 if and when
|
|
871
|
+
# PEP 728 is implemented in CPython
|
|
872
|
+
_PEP_728_IMPLEMENTED = False
|
|
873
|
+
|
|
874
|
+
if _PEP_728_IMPLEMENTED:
|
|
809
875
|
# The standard library TypedDict in Python 3.8 does not store runtime information
|
|
810
876
|
# about which (if any) keys are optional. See https://bugs.python.org/issue38834
|
|
811
877
|
# The standard library TypedDict in Python 3.9.0/1 does not honour the "total"
|
|
@@ -816,6 +882,8 @@ if sys.version_info >= (3, 13):
|
|
|
816
882
|
# Aaaand on 3.12 we add __orig_bases__ to TypedDict
|
|
817
883
|
# to enable better runtime introspection.
|
|
818
884
|
# On 3.13 we deprecate some odd ways of creating TypedDicts.
|
|
885
|
+
# Also on 3.13, PEP 705 adds the ReadOnly[] qualifier.
|
|
886
|
+
# PEP 728 (still pending) makes more changes.
|
|
819
887
|
TypedDict = typing.TypedDict
|
|
820
888
|
_TypedDictMeta = typing._TypedDictMeta
|
|
821
889
|
is_typeddict = typing.is_typeddict
|
|
@@ -823,8 +891,29 @@ else:
|
|
|
823
891
|
# 3.10.0 and later
|
|
824
892
|
_TAKES_MODULE = "module" in inspect.signature(typing._type_check).parameters
|
|
825
893
|
|
|
894
|
+
def _get_typeddict_qualifiers(annotation_type):
|
|
895
|
+
while True:
|
|
896
|
+
annotation_origin = get_origin(annotation_type)
|
|
897
|
+
if annotation_origin is Annotated:
|
|
898
|
+
annotation_args = get_args(annotation_type)
|
|
899
|
+
if annotation_args:
|
|
900
|
+
annotation_type = annotation_args[0]
|
|
901
|
+
else:
|
|
902
|
+
break
|
|
903
|
+
elif annotation_origin is Required:
|
|
904
|
+
yield Required
|
|
905
|
+
annotation_type, = get_args(annotation_type)
|
|
906
|
+
elif annotation_origin is NotRequired:
|
|
907
|
+
yield NotRequired
|
|
908
|
+
annotation_type, = get_args(annotation_type)
|
|
909
|
+
elif annotation_origin is ReadOnly:
|
|
910
|
+
yield ReadOnly
|
|
911
|
+
annotation_type, = get_args(annotation_type)
|
|
912
|
+
else:
|
|
913
|
+
break
|
|
914
|
+
|
|
826
915
|
class _TypedDictMeta(type):
|
|
827
|
-
def __new__(cls, name, bases, ns, total=True):
|
|
916
|
+
def __new__(cls, name, bases, ns, *, total=True, closed=False):
|
|
828
917
|
"""Create new typed dict class object.
|
|
829
918
|
|
|
830
919
|
This method is called when TypedDict is subclassed,
|
|
@@ -834,10 +923,8 @@ else:
|
|
|
834
923
|
"""
|
|
835
924
|
for base in bases:
|
|
836
925
|
if type(base) is not _TypedDictMeta and base is not typing.Generic:
|
|
837
|
-
raise TypeError(
|
|
838
|
-
|
|
839
|
-
"and a non-TypedDict base class"
|
|
840
|
-
)
|
|
926
|
+
raise TypeError('cannot inherit from both a TypedDict type '
|
|
927
|
+
'and a non-TypedDict base class')
|
|
841
928
|
|
|
842
929
|
if any(issubclass(b, typing.Generic) for b in bases):
|
|
843
930
|
generic_base = (typing.Generic,)
|
|
@@ -846,18 +933,22 @@ else:
|
|
|
846
933
|
|
|
847
934
|
# typing.py generally doesn't let you inherit from plain Generic, unless
|
|
848
935
|
# the name of the class happens to be "Protocol"
|
|
849
|
-
tp_dict = type.__new__(
|
|
850
|
-
_TypedDictMeta, "Protocol", (*generic_base, dict), ns
|
|
851
|
-
)
|
|
936
|
+
tp_dict = type.__new__(_TypedDictMeta, "Protocol", (*generic_base, dict), ns)
|
|
852
937
|
tp_dict.__name__ = name
|
|
853
938
|
if tp_dict.__qualname__ == "Protocol":
|
|
854
939
|
tp_dict.__qualname__ = name
|
|
855
940
|
|
|
856
|
-
if not hasattr(tp_dict,
|
|
941
|
+
if not hasattr(tp_dict, '__orig_bases__'):
|
|
857
942
|
tp_dict.__orig_bases__ = bases
|
|
858
943
|
|
|
859
944
|
annotations = {}
|
|
860
|
-
|
|
945
|
+
if "__annotations__" in ns:
|
|
946
|
+
own_annotations = ns["__annotations__"]
|
|
947
|
+
elif "__annotate__" in ns:
|
|
948
|
+
# TODO: Use inspect.VALUE here, and make the annotations lazily evaluated
|
|
949
|
+
own_annotations = ns["__annotate__"](1)
|
|
950
|
+
else:
|
|
951
|
+
own_annotations = {}
|
|
861
952
|
msg = "TypedDict('Name', {f0: t0, f1: t1, ...}); each t must be a type"
|
|
862
953
|
if _TAKES_MODULE:
|
|
863
954
|
own_annotations = {
|
|
@@ -866,53 +957,86 @@ else:
|
|
|
866
957
|
}
|
|
867
958
|
else:
|
|
868
959
|
own_annotations = {
|
|
869
|
-
n: typing._type_check(tp, msg)
|
|
960
|
+
n: typing._type_check(tp, msg)
|
|
961
|
+
for n, tp in own_annotations.items()
|
|
870
962
|
}
|
|
871
963
|
required_keys = set()
|
|
872
964
|
optional_keys = set()
|
|
965
|
+
readonly_keys = set()
|
|
966
|
+
mutable_keys = set()
|
|
967
|
+
extra_items_type = None
|
|
873
968
|
|
|
874
969
|
for base in bases:
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
970
|
+
base_dict = base.__dict__
|
|
971
|
+
|
|
972
|
+
annotations.update(base_dict.get('__annotations__', {}))
|
|
973
|
+
required_keys.update(base_dict.get('__required_keys__', ()))
|
|
974
|
+
optional_keys.update(base_dict.get('__optional_keys__', ()))
|
|
975
|
+
readonly_keys.update(base_dict.get('__readonly_keys__', ()))
|
|
976
|
+
mutable_keys.update(base_dict.get('__mutable_keys__', ()))
|
|
977
|
+
base_extra_items_type = base_dict.get('__extra_items__', None)
|
|
978
|
+
if base_extra_items_type is not None:
|
|
979
|
+
extra_items_type = base_extra_items_type
|
|
980
|
+
|
|
981
|
+
if closed and extra_items_type is None:
|
|
982
|
+
extra_items_type = Never
|
|
983
|
+
if closed and "__extra_items__" in own_annotations:
|
|
984
|
+
annotation_type = own_annotations.pop("__extra_items__")
|
|
985
|
+
qualifiers = set(_get_typeddict_qualifiers(annotation_type))
|
|
986
|
+
if Required in qualifiers:
|
|
987
|
+
raise TypeError(
|
|
988
|
+
"Special key __extra_items__ does not support "
|
|
989
|
+
"Required"
|
|
990
|
+
)
|
|
991
|
+
if NotRequired in qualifiers:
|
|
992
|
+
raise TypeError(
|
|
993
|
+
"Special key __extra_items__ does not support "
|
|
994
|
+
"NotRequired"
|
|
995
|
+
)
|
|
996
|
+
extra_items_type = annotation_type
|
|
878
997
|
|
|
879
998
|
annotations.update(own_annotations)
|
|
880
999
|
for annotation_key, annotation_type in own_annotations.items():
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
if annotation_args:
|
|
885
|
-
annotation_type = annotation_args[0]
|
|
886
|
-
annotation_origin = get_origin(annotation_type)
|
|
887
|
-
|
|
888
|
-
if annotation_origin is Required:
|
|
1000
|
+
qualifiers = set(_get_typeddict_qualifiers(annotation_type))
|
|
1001
|
+
|
|
1002
|
+
if Required in qualifiers:
|
|
889
1003
|
required_keys.add(annotation_key)
|
|
890
|
-
elif
|
|
1004
|
+
elif NotRequired in qualifiers:
|
|
891
1005
|
optional_keys.add(annotation_key)
|
|
892
1006
|
elif total:
|
|
893
1007
|
required_keys.add(annotation_key)
|
|
894
1008
|
else:
|
|
895
1009
|
optional_keys.add(annotation_key)
|
|
1010
|
+
if ReadOnly in qualifiers:
|
|
1011
|
+
mutable_keys.discard(annotation_key)
|
|
1012
|
+
readonly_keys.add(annotation_key)
|
|
1013
|
+
else:
|
|
1014
|
+
mutable_keys.add(annotation_key)
|
|
1015
|
+
readonly_keys.discard(annotation_key)
|
|
896
1016
|
|
|
897
1017
|
tp_dict.__annotations__ = annotations
|
|
898
1018
|
tp_dict.__required_keys__ = frozenset(required_keys)
|
|
899
1019
|
tp_dict.__optional_keys__ = frozenset(optional_keys)
|
|
900
|
-
|
|
1020
|
+
tp_dict.__readonly_keys__ = frozenset(readonly_keys)
|
|
1021
|
+
tp_dict.__mutable_keys__ = frozenset(mutable_keys)
|
|
1022
|
+
if not hasattr(tp_dict, '__total__'):
|
|
901
1023
|
tp_dict.__total__ = total
|
|
1024
|
+
tp_dict.__closed__ = closed
|
|
1025
|
+
tp_dict.__extra_items__ = extra_items_type
|
|
902
1026
|
return tp_dict
|
|
903
1027
|
|
|
904
1028
|
__call__ = dict # static method
|
|
905
1029
|
|
|
906
1030
|
def __subclasscheck__(cls, other):
|
|
907
1031
|
# Typed dicts are only for static structural subtyping.
|
|
908
|
-
raise TypeError(
|
|
1032
|
+
raise TypeError('TypedDict does not support instance and class checks')
|
|
909
1033
|
|
|
910
1034
|
__instancecheck__ = __subclasscheck__
|
|
911
1035
|
|
|
912
|
-
_TypedDict = type.__new__(_TypedDictMeta,
|
|
1036
|
+
_TypedDict = type.__new__(_TypedDictMeta, 'TypedDict', (), {})
|
|
913
1037
|
|
|
914
1038
|
@_ensure_subclassable(lambda bases: (_TypedDict,))
|
|
915
|
-
def TypedDict(typename, fields=_marker, /, *, total=True, **kwargs):
|
|
1039
|
+
def TypedDict(typename, fields=_marker, /, *, total=True, closed=False, **kwargs):
|
|
916
1040
|
"""A simple typed namespace. At runtime it is equivalent to a plain dict.
|
|
917
1041
|
|
|
918
1042
|
TypedDict creates a dictionary type such that a type checker will expect all
|
|
@@ -967,21 +1091,21 @@ else:
|
|
|
967
1091
|
|
|
968
1092
|
example = f"`{typename} = TypedDict({typename!r}, {{}})`"
|
|
969
1093
|
deprecation_msg = (
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
)
|
|
975
|
-
+ example
|
|
976
|
-
+ "."
|
|
977
|
-
)
|
|
1094
|
+
f"{deprecated_thing} is deprecated and will be disallowed in "
|
|
1095
|
+
"Python 3.15. To create a TypedDict class with 0 fields "
|
|
1096
|
+
"using the functional syntax, pass an empty dictionary, e.g. "
|
|
1097
|
+
) + example + "."
|
|
978
1098
|
warnings.warn(deprecation_msg, DeprecationWarning, stacklevel=2)
|
|
1099
|
+
if closed is not False and closed is not True:
|
|
1100
|
+
kwargs["closed"] = closed
|
|
1101
|
+
closed = False
|
|
979
1102
|
fields = kwargs
|
|
980
1103
|
elif kwargs:
|
|
981
|
-
raise TypeError(
|
|
982
|
-
|
|
983
|
-
)
|
|
1104
|
+
raise TypeError("TypedDict takes either a dict or keyword arguments,"
|
|
1105
|
+
" but not both")
|
|
984
1106
|
if kwargs:
|
|
1107
|
+
if sys.version_info >= (3, 13):
|
|
1108
|
+
raise TypeError("TypedDict takes no keyword arguments")
|
|
985
1109
|
warnings.warn(
|
|
986
1110
|
"The kwargs-based syntax for TypedDict definitions is deprecated "
|
|
987
1111
|
"in Python 3.11, will be removed in Python 3.13, and may not be "
|
|
@@ -990,13 +1114,13 @@ else:
|
|
|
990
1114
|
stacklevel=2,
|
|
991
1115
|
)
|
|
992
1116
|
|
|
993
|
-
ns = {
|
|
1117
|
+
ns = {'__annotations__': dict(fields)}
|
|
994
1118
|
module = _caller()
|
|
995
1119
|
if module is not None:
|
|
996
1120
|
# Setting correct module is necessary to make typed dict classes pickleable.
|
|
997
|
-
ns[
|
|
1121
|
+
ns['__module__'] = module
|
|
998
1122
|
|
|
999
|
-
td = _TypedDictMeta(typename, (), ns, total=total)
|
|
1123
|
+
td = _TypedDictMeta(typename, (), ns, total=total, closed=closed)
|
|
1000
1124
|
td.__orig_bases__ = (TypedDict,)
|
|
1001
1125
|
return td
|
|
1002
1126
|
|
|
@@ -1026,7 +1150,6 @@ if hasattr(typing, "assert_type"):
|
|
|
1026
1150
|
assert_type = typing.assert_type
|
|
1027
1151
|
|
|
1028
1152
|
else:
|
|
1029
|
-
|
|
1030
1153
|
def assert_type(val, typ, /):
|
|
1031
1154
|
"""Assert (to the type checker) that the value is of the given type.
|
|
1032
1155
|
|
|
@@ -1043,15 +1166,15 @@ else:
|
|
|
1043
1166
|
return val
|
|
1044
1167
|
|
|
1045
1168
|
|
|
1046
|
-
if hasattr(typing, "
|
|
1169
|
+
if hasattr(typing, "ReadOnly"): # 3.13+
|
|
1047
1170
|
get_type_hints = typing.get_type_hints
|
|
1048
|
-
else: # <=3.
|
|
1171
|
+
else: # <=3.13
|
|
1049
1172
|
# replaces _strip_annotations()
|
|
1050
1173
|
def _strip_extras(t):
|
|
1051
1174
|
"""Strips Annotated, Required and NotRequired from a given type."""
|
|
1052
1175
|
if isinstance(t, _AnnotatedAlias):
|
|
1053
1176
|
return _strip_extras(t.__origin__)
|
|
1054
|
-
if hasattr(t, "__origin__") and t.__origin__ in (Required, NotRequired):
|
|
1177
|
+
if hasattr(t, "__origin__") and t.__origin__ in (Required, NotRequired, ReadOnly):
|
|
1055
1178
|
return _strip_extras(t.__args__[0])
|
|
1056
1179
|
if isinstance(t, typing._GenericAlias):
|
|
1057
1180
|
stripped_args = tuple(_strip_extras(a) for a in t.__args__)
|
|
@@ -1115,14 +1238,13 @@ else: # <=3.10
|
|
|
1115
1238
|
|
|
1116
1239
|
|
|
1117
1240
|
# Python 3.9+ has PEP 593 (Annotated)
|
|
1118
|
-
if hasattr(typing,
|
|
1241
|
+
if hasattr(typing, 'Annotated'):
|
|
1119
1242
|
Annotated = typing.Annotated
|
|
1120
1243
|
# Not exported and not a public API, but needed for get_origin() and get_args()
|
|
1121
1244
|
# to work.
|
|
1122
1245
|
_AnnotatedAlias = typing._AnnotatedAlias
|
|
1123
1246
|
# 3.8
|
|
1124
1247
|
else:
|
|
1125
|
-
|
|
1126
1248
|
class _AnnotatedAlias(typing._GenericAlias, _root=True):
|
|
1127
1249
|
"""Runtime representation of an annotated type.
|
|
1128
1250
|
|
|
@@ -1131,7 +1253,6 @@ else:
|
|
|
1131
1253
|
instantiating is the same as instantiating the underlying type, binding
|
|
1132
1254
|
it to types is also the same.
|
|
1133
1255
|
"""
|
|
1134
|
-
|
|
1135
1256
|
def __init__(self, origin, metadata):
|
|
1136
1257
|
if isinstance(origin, _AnnotatedAlias):
|
|
1137
1258
|
metadata = origin.__metadata__ + metadata
|
|
@@ -1145,13 +1266,13 @@ else:
|
|
|
1145
1266
|
return _AnnotatedAlias(new_type, self.__metadata__)
|
|
1146
1267
|
|
|
1147
1268
|
def __repr__(self):
|
|
1148
|
-
return (
|
|
1149
|
-
|
|
1150
|
-
f"{', '.join(repr(a) for a in self.__metadata__)}]"
|
|
1151
|
-
)
|
|
1269
|
+
return (f"typing_extensions.Annotated[{typing._type_repr(self.__origin__)}, "
|
|
1270
|
+
f"{', '.join(repr(a) for a in self.__metadata__)}]")
|
|
1152
1271
|
|
|
1153
1272
|
def __reduce__(self):
|
|
1154
|
-
return operator.getitem, (
|
|
1273
|
+
return operator.getitem, (
|
|
1274
|
+
Annotated, (self.__origin__, *self.__metadata__)
|
|
1275
|
+
)
|
|
1155
1276
|
|
|
1156
1277
|
def __eq__(self, other):
|
|
1157
1278
|
if not isinstance(other, _AnnotatedAlias):
|
|
@@ -1204,11 +1325,9 @@ else:
|
|
|
1204
1325
|
@typing._tp_cache
|
|
1205
1326
|
def __class_getitem__(cls, params):
|
|
1206
1327
|
if not isinstance(params, tuple) or len(params) < 2:
|
|
1207
|
-
raise TypeError(
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
"annotation)."
|
|
1211
|
-
)
|
|
1328
|
+
raise TypeError("Annotated[...] should be used "
|
|
1329
|
+
"with at least two arguments (a type and an "
|
|
1330
|
+
"annotation).")
|
|
1212
1331
|
allowed_special_forms = (ClassVar, Final)
|
|
1213
1332
|
if get_origin(params[0]) in allowed_special_forms:
|
|
1214
1333
|
origin = params[0]
|
|
@@ -1219,8 +1338,9 @@ else:
|
|
|
1219
1338
|
return _AnnotatedAlias(origin, metadata)
|
|
1220
1339
|
|
|
1221
1340
|
def __init_subclass__(cls, *args, **kwargs):
|
|
1222
|
-
raise TypeError(
|
|
1223
|
-
|
|
1341
|
+
raise TypeError(
|
|
1342
|
+
f"Cannot subclass {cls.__module__}.Annotated"
|
|
1343
|
+
)
|
|
1224
1344
|
|
|
1225
1345
|
# Python 3.8 has get_origin() and get_args() but those implementations aren't
|
|
1226
1346
|
# Annotated-aware, so we can't use those. Python 3.9's versions don't support
|
|
@@ -1258,16 +1378,8 @@ else:
|
|
|
1258
1378
|
"""
|
|
1259
1379
|
if isinstance(tp, _AnnotatedAlias):
|
|
1260
1380
|
return Annotated
|
|
1261
|
-
if isinstance(
|
|
1262
|
-
|
|
1263
|
-
(
|
|
1264
|
-
typing._GenericAlias,
|
|
1265
|
-
_typing_GenericAlias,
|
|
1266
|
-
_BaseGenericAlias,
|
|
1267
|
-
ParamSpecArgs,
|
|
1268
|
-
ParamSpecKwargs,
|
|
1269
|
-
),
|
|
1270
|
-
):
|
|
1381
|
+
if isinstance(tp, (typing._GenericAlias, _typing_GenericAlias, _BaseGenericAlias,
|
|
1382
|
+
ParamSpecArgs, ParamSpecKwargs)):
|
|
1271
1383
|
return tp.__origin__
|
|
1272
1384
|
if tp is typing.Generic:
|
|
1273
1385
|
return typing.Generic
|
|
@@ -1285,7 +1397,7 @@ else:
|
|
|
1285
1397
|
get_args(Callable[[], T][int]) == ([], int)
|
|
1286
1398
|
"""
|
|
1287
1399
|
if isinstance(tp, _AnnotatedAlias):
|
|
1288
|
-
return (tp.__origin__,
|
|
1400
|
+
return (tp.__origin__, *tp.__metadata__)
|
|
1289
1401
|
if isinstance(tp, (typing._GenericAlias, _typing_GenericAlias)):
|
|
1290
1402
|
if getattr(tp, "_special", False):
|
|
1291
1403
|
return ()
|
|
@@ -1297,11 +1409,10 @@ else:
|
|
|
1297
1409
|
|
|
1298
1410
|
|
|
1299
1411
|
# 3.10+
|
|
1300
|
-
if hasattr(typing,
|
|
1412
|
+
if hasattr(typing, 'TypeAlias'):
|
|
1301
1413
|
TypeAlias = typing.TypeAlias
|
|
1302
1414
|
# 3.9
|
|
1303
1415
|
elif sys.version_info[:2] >= (3, 9):
|
|
1304
|
-
|
|
1305
1416
|
@_ExtensionsSpecialForm
|
|
1306
1417
|
def TypeAlias(self, parameters):
|
|
1307
1418
|
"""Special marker indicating that an assignment should
|
|
@@ -1315,12 +1426,10 @@ elif sys.version_info[:2] >= (3, 9):
|
|
|
1315
1426
|
It's invalid when used anywhere except as in the example above.
|
|
1316
1427
|
"""
|
|
1317
1428
|
raise TypeError(f"{self} is not subscriptable")
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
1429
|
# 3.8
|
|
1321
1430
|
else:
|
|
1322
1431
|
TypeAlias = _ExtensionsSpecialForm(
|
|
1323
|
-
|
|
1432
|
+
'TypeAlias',
|
|
1324
1433
|
doc="""Special marker indicating that an assignment should
|
|
1325
1434
|
be recognized as a proper type alias definition by type
|
|
1326
1435
|
checkers.
|
|
@@ -1330,30 +1439,47 @@ else:
|
|
|
1330
1439
|
Predicate: TypeAlias = Callable[..., bool]
|
|
1331
1440
|
|
|
1332
1441
|
It's invalid when used anywhere except as in the example
|
|
1333
|
-
above."""
|
|
1442
|
+
above."""
|
|
1334
1443
|
)
|
|
1335
1444
|
|
|
1336
1445
|
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
)
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
else:
|
|
1346
|
-
type_param.__default__ = typing._type_check(
|
|
1347
|
-
default, "Default must be a type"
|
|
1446
|
+
if hasattr(typing, "NoDefault"):
|
|
1447
|
+
NoDefault = typing.NoDefault
|
|
1448
|
+
else:
|
|
1449
|
+
class NoDefaultTypeMeta(type):
|
|
1450
|
+
def __setattr__(cls, attr, value):
|
|
1451
|
+
# TypeError is consistent with the behavior of NoneType
|
|
1452
|
+
raise TypeError(
|
|
1453
|
+
f"cannot set {attr!r} attribute of immutable type {cls.__name__!r}"
|
|
1348
1454
|
)
|
|
1349
|
-
|
|
1350
|
-
|
|
1455
|
+
|
|
1456
|
+
class NoDefaultType(metaclass=NoDefaultTypeMeta):
|
|
1457
|
+
"""The type of the NoDefault singleton."""
|
|
1458
|
+
|
|
1459
|
+
__slots__ = ()
|
|
1460
|
+
|
|
1461
|
+
def __new__(cls):
|
|
1462
|
+
return globals().get("NoDefault") or object.__new__(cls)
|
|
1463
|
+
|
|
1464
|
+
def __repr__(self):
|
|
1465
|
+
return "typing_extensions.NoDefault"
|
|
1466
|
+
|
|
1467
|
+
def __reduce__(self):
|
|
1468
|
+
return "NoDefault"
|
|
1469
|
+
|
|
1470
|
+
NoDefault = NoDefaultType()
|
|
1471
|
+
del NoDefaultType, NoDefaultTypeMeta
|
|
1472
|
+
|
|
1473
|
+
|
|
1474
|
+
def _set_default(type_param, default):
|
|
1475
|
+
type_param.has_default = lambda: default is not NoDefault
|
|
1476
|
+
type_param.__default__ = default
|
|
1351
1477
|
|
|
1352
1478
|
|
|
1353
1479
|
def _set_module(typevarlike):
|
|
1354
1480
|
# for pickling:
|
|
1355
1481
|
def_mod = _caller(depth=3)
|
|
1356
|
-
if def_mod !=
|
|
1482
|
+
if def_mod != 'typing_extensions':
|
|
1357
1483
|
typevarlike.__module__ = def_mod
|
|
1358
1484
|
|
|
1359
1485
|
|
|
@@ -1370,61 +1496,56 @@ class _TypeVarLikeMeta(type):
|
|
|
1370
1496
|
return isinstance(__instance, cls._backported_typevarlike)
|
|
1371
1497
|
|
|
1372
1498
|
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
*constraints,
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
)
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
if infer_variance and (covariant or contravariant):
|
|
1408
|
-
raise ValueError("Variance cannot be specified with infer_variance.")
|
|
1409
|
-
typevar.__infer_variance__ = infer_variance
|
|
1410
|
-
_set_default(typevar, default)
|
|
1411
|
-
_set_module(typevar)
|
|
1412
|
-
return typevar
|
|
1499
|
+
if _PEP_696_IMPLEMENTED:
|
|
1500
|
+
from typing import TypeVar
|
|
1501
|
+
else:
|
|
1502
|
+
# Add default and infer_variance parameters from PEP 696 and 695
|
|
1503
|
+
class TypeVar(metaclass=_TypeVarLikeMeta):
|
|
1504
|
+
"""Type variable."""
|
|
1505
|
+
|
|
1506
|
+
_backported_typevarlike = typing.TypeVar
|
|
1507
|
+
|
|
1508
|
+
def __new__(cls, name, *constraints, bound=None,
|
|
1509
|
+
covariant=False, contravariant=False,
|
|
1510
|
+
default=NoDefault, infer_variance=False):
|
|
1511
|
+
if hasattr(typing, "TypeAliasType"):
|
|
1512
|
+
# PEP 695 implemented (3.12+), can pass infer_variance to typing.TypeVar
|
|
1513
|
+
typevar = typing.TypeVar(name, *constraints, bound=bound,
|
|
1514
|
+
covariant=covariant, contravariant=contravariant,
|
|
1515
|
+
infer_variance=infer_variance)
|
|
1516
|
+
else:
|
|
1517
|
+
typevar = typing.TypeVar(name, *constraints, bound=bound,
|
|
1518
|
+
covariant=covariant, contravariant=contravariant)
|
|
1519
|
+
if infer_variance and (covariant or contravariant):
|
|
1520
|
+
raise ValueError("Variance cannot be specified with infer_variance.")
|
|
1521
|
+
typevar.__infer_variance__ = infer_variance
|
|
1522
|
+
|
|
1523
|
+
_set_default(typevar, default)
|
|
1524
|
+
_set_module(typevar)
|
|
1525
|
+
|
|
1526
|
+
def _tvar_prepare_subst(alias, args):
|
|
1527
|
+
if (
|
|
1528
|
+
typevar.has_default()
|
|
1529
|
+
and alias.__parameters__.index(typevar) == len(args)
|
|
1530
|
+
):
|
|
1531
|
+
args += (typevar.__default__,)
|
|
1532
|
+
return args
|
|
1413
1533
|
|
|
1414
|
-
|
|
1415
|
-
|
|
1534
|
+
typevar.__typing_prepare_subst__ = _tvar_prepare_subst
|
|
1535
|
+
return typevar
|
|
1536
|
+
|
|
1537
|
+
def __init_subclass__(cls) -> None:
|
|
1538
|
+
raise TypeError(f"type '{__name__}.TypeVar' is not an acceptable base type")
|
|
1416
1539
|
|
|
1417
1540
|
|
|
1418
1541
|
# Python 3.10+ has PEP 612
|
|
1419
|
-
if hasattr(typing,
|
|
1542
|
+
if hasattr(typing, 'ParamSpecArgs'):
|
|
1420
1543
|
ParamSpecArgs = typing.ParamSpecArgs
|
|
1421
1544
|
ParamSpecKwargs = typing.ParamSpecKwargs
|
|
1422
1545
|
# 3.8-3.9
|
|
1423
1546
|
else:
|
|
1424
|
-
|
|
1425
1547
|
class _Immutable:
|
|
1426
1548
|
"""Mixin to indicate that object should not be copied."""
|
|
1427
|
-
|
|
1428
1549
|
__slots__ = ()
|
|
1429
1550
|
|
|
1430
1551
|
def __copy__(self):
|
|
@@ -1445,7 +1566,6 @@ else:
|
|
|
1445
1566
|
This type is meant for runtime introspection and has no special meaning to
|
|
1446
1567
|
static type checkers.
|
|
1447
1568
|
"""
|
|
1448
|
-
|
|
1449
1569
|
def __init__(self, origin):
|
|
1450
1570
|
self.__origin__ = origin
|
|
1451
1571
|
|
|
@@ -1469,7 +1589,6 @@ else:
|
|
|
1469
1589
|
This type is meant for runtime introspection and has no special meaning to
|
|
1470
1590
|
static type checkers.
|
|
1471
1591
|
"""
|
|
1472
|
-
|
|
1473
1592
|
def __init__(self, origin):
|
|
1474
1593
|
self.__origin__ = origin
|
|
1475
1594
|
|
|
@@ -1482,51 +1601,61 @@ else:
|
|
|
1482
1601
|
return self.__origin__ == other.__origin__
|
|
1483
1602
|
|
|
1484
1603
|
|
|
1604
|
+
if _PEP_696_IMPLEMENTED:
|
|
1605
|
+
from typing import ParamSpec
|
|
1606
|
+
|
|
1485
1607
|
# 3.10+
|
|
1486
|
-
|
|
1608
|
+
elif hasattr(typing, 'ParamSpec'):
|
|
1609
|
+
|
|
1487
1610
|
# Add default parameter - PEP 696
|
|
1488
1611
|
class ParamSpec(metaclass=_TypeVarLikeMeta):
|
|
1489
1612
|
"""Parameter specification."""
|
|
1490
1613
|
|
|
1491
1614
|
_backported_typevarlike = typing.ParamSpec
|
|
1492
1615
|
|
|
1493
|
-
def __new__(
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
*,
|
|
1497
|
-
bound=None,
|
|
1498
|
-
covariant=False,
|
|
1499
|
-
contravariant=False,
|
|
1500
|
-
infer_variance=False,
|
|
1501
|
-
default=_marker,
|
|
1502
|
-
):
|
|
1616
|
+
def __new__(cls, name, *, bound=None,
|
|
1617
|
+
covariant=False, contravariant=False,
|
|
1618
|
+
infer_variance=False, default=NoDefault):
|
|
1503
1619
|
if hasattr(typing, "TypeAliasType"):
|
|
1504
1620
|
# PEP 695 implemented, can pass infer_variance to typing.TypeVar
|
|
1505
|
-
paramspec = typing.ParamSpec(
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
contravariant=contravariant,
|
|
1510
|
-
infer_variance=infer_variance,
|
|
1511
|
-
)
|
|
1621
|
+
paramspec = typing.ParamSpec(name, bound=bound,
|
|
1622
|
+
covariant=covariant,
|
|
1623
|
+
contravariant=contravariant,
|
|
1624
|
+
infer_variance=infer_variance)
|
|
1512
1625
|
else:
|
|
1513
|
-
paramspec = typing.ParamSpec(
|
|
1514
|
-
|
|
1515
|
-
|
|
1626
|
+
paramspec = typing.ParamSpec(name, bound=bound,
|
|
1627
|
+
covariant=covariant,
|
|
1628
|
+
contravariant=contravariant)
|
|
1516
1629
|
paramspec.__infer_variance__ = infer_variance
|
|
1517
1630
|
|
|
1518
1631
|
_set_default(paramspec, default)
|
|
1519
1632
|
_set_module(paramspec)
|
|
1633
|
+
|
|
1634
|
+
def _paramspec_prepare_subst(alias, args):
|
|
1635
|
+
params = alias.__parameters__
|
|
1636
|
+
i = params.index(paramspec)
|
|
1637
|
+
if i == len(args) and paramspec.has_default():
|
|
1638
|
+
args = [*args, paramspec.__default__]
|
|
1639
|
+
if i >= len(args):
|
|
1640
|
+
raise TypeError(f"Too few arguments for {alias}")
|
|
1641
|
+
# Special case where Z[[int, str, bool]] == Z[int, str, bool] in PEP 612.
|
|
1642
|
+
if len(params) == 1 and not typing._is_param_expr(args[0]):
|
|
1643
|
+
assert i == 0
|
|
1644
|
+
args = (args,)
|
|
1645
|
+
# Convert lists to tuples to help other libraries cache the results.
|
|
1646
|
+
elif isinstance(args[i], list):
|
|
1647
|
+
args = (*args[:i], tuple(args[i]), *args[i + 1:])
|
|
1648
|
+
return args
|
|
1649
|
+
|
|
1650
|
+
paramspec.__typing_prepare_subst__ = _paramspec_prepare_subst
|
|
1520
1651
|
return paramspec
|
|
1521
1652
|
|
|
1522
1653
|
def __init_subclass__(cls) -> None:
|
|
1523
|
-
raise TypeError(
|
|
1524
|
-
f"type '{__name__}.ParamSpec' is not an acceptable base type"
|
|
1525
|
-
)
|
|
1526
|
-
|
|
1654
|
+
raise TypeError(f"type '{__name__}.ParamSpec' is not an acceptable base type")
|
|
1527
1655
|
|
|
1528
1656
|
# 3.8-3.9
|
|
1529
1657
|
else:
|
|
1658
|
+
|
|
1530
1659
|
# Inherits from list as a workaround for Callable checks in Python < 3.9.2.
|
|
1531
1660
|
class ParamSpec(list, _DefaultMixin):
|
|
1532
1661
|
"""Parameter specification variable.
|
|
@@ -1586,41 +1715,33 @@ else:
|
|
|
1586
1715
|
def kwargs(self):
|
|
1587
1716
|
return ParamSpecKwargs(self)
|
|
1588
1717
|
|
|
1589
|
-
def __init__(
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
*,
|
|
1593
|
-
bound=None,
|
|
1594
|
-
covariant=False,
|
|
1595
|
-
contravariant=False,
|
|
1596
|
-
infer_variance=False,
|
|
1597
|
-
default=_marker,
|
|
1598
|
-
):
|
|
1599
|
-
super().__init__([self])
|
|
1718
|
+
def __init__(self, name, *, bound=None, covariant=False, contravariant=False,
|
|
1719
|
+
infer_variance=False, default=NoDefault):
|
|
1720
|
+
list.__init__(self, [self])
|
|
1600
1721
|
self.__name__ = name
|
|
1601
1722
|
self.__covariant__ = bool(covariant)
|
|
1602
1723
|
self.__contravariant__ = bool(contravariant)
|
|
1603
1724
|
self.__infer_variance__ = bool(infer_variance)
|
|
1604
1725
|
if bound:
|
|
1605
|
-
self.__bound__ = typing._type_check(bound,
|
|
1726
|
+
self.__bound__ = typing._type_check(bound, 'Bound must be a type.')
|
|
1606
1727
|
else:
|
|
1607
1728
|
self.__bound__ = None
|
|
1608
1729
|
_DefaultMixin.__init__(self, default)
|
|
1609
1730
|
|
|
1610
1731
|
# for pickling:
|
|
1611
1732
|
def_mod = _caller()
|
|
1612
|
-
if def_mod !=
|
|
1733
|
+
if def_mod != 'typing_extensions':
|
|
1613
1734
|
self.__module__ = def_mod
|
|
1614
1735
|
|
|
1615
1736
|
def __repr__(self):
|
|
1616
1737
|
if self.__infer_variance__:
|
|
1617
|
-
prefix =
|
|
1738
|
+
prefix = ''
|
|
1618
1739
|
elif self.__covariant__:
|
|
1619
|
-
prefix =
|
|
1740
|
+
prefix = '+'
|
|
1620
1741
|
elif self.__contravariant__:
|
|
1621
|
-
prefix =
|
|
1742
|
+
prefix = '-'
|
|
1622
1743
|
else:
|
|
1623
|
-
prefix =
|
|
1744
|
+
prefix = '~'
|
|
1624
1745
|
return prefix + self.__name__
|
|
1625
1746
|
|
|
1626
1747
|
def __hash__(self):
|
|
@@ -1638,9 +1759,10 @@ else:
|
|
|
1638
1759
|
|
|
1639
1760
|
|
|
1640
1761
|
# 3.8-3.9
|
|
1641
|
-
if not hasattr(typing,
|
|
1762
|
+
if not hasattr(typing, 'Concatenate'):
|
|
1642
1763
|
# Inherits from list as a workaround for Callable checks in Python < 3.9.2.
|
|
1643
1764
|
class _ConcatenateGenericAlias(list):
|
|
1765
|
+
|
|
1644
1766
|
# Trick Generic into looking into this for __parameters__.
|
|
1645
1767
|
__class__ = typing._GenericAlias
|
|
1646
1768
|
|
|
@@ -1654,10 +1776,8 @@ if not hasattr(typing, "Concatenate"):
|
|
|
1654
1776
|
|
|
1655
1777
|
def __repr__(self):
|
|
1656
1778
|
_type_repr = typing._type_repr
|
|
1657
|
-
return (
|
|
1658
|
-
|
|
1659
|
-
f'[{", ".join(_type_repr(arg) for arg in self.__args__)}]'
|
|
1660
|
-
)
|
|
1779
|
+
return (f'{_type_repr(self.__origin__)}'
|
|
1780
|
+
f'[{", ".join(_type_repr(arg) for arg in self.__args__)}]')
|
|
1661
1781
|
|
|
1662
1782
|
def __hash__(self):
|
|
1663
1783
|
return hash((self.__origin__, self.__args__))
|
|
@@ -1669,9 +1789,7 @@ if not hasattr(typing, "Concatenate"):
|
|
|
1669
1789
|
@property
|
|
1670
1790
|
def __parameters__(self):
|
|
1671
1791
|
return tuple(
|
|
1672
|
-
tp
|
|
1673
|
-
for tp in self.__args__
|
|
1674
|
-
if isinstance(tp, (typing.TypeVar, ParamSpec))
|
|
1792
|
+
tp for tp in self.__args__ if isinstance(tp, (typing.TypeVar, ParamSpec))
|
|
1675
1793
|
)
|
|
1676
1794
|
|
|
1677
1795
|
|
|
@@ -1683,21 +1801,19 @@ def _concatenate_getitem(self, parameters):
|
|
|
1683
1801
|
if not isinstance(parameters, tuple):
|
|
1684
1802
|
parameters = (parameters,)
|
|
1685
1803
|
if not isinstance(parameters[-1], ParamSpec):
|
|
1686
|
-
raise TypeError(
|
|
1687
|
-
|
|
1688
|
-
)
|
|
1804
|
+
raise TypeError("The last parameter to Concatenate should be a "
|
|
1805
|
+
"ParamSpec variable.")
|
|
1689
1806
|
msg = "Concatenate[arg, ...]: each arg must be a type."
|
|
1690
1807
|
parameters = tuple(typing._type_check(p, msg) for p in parameters)
|
|
1691
1808
|
return _ConcatenateGenericAlias(self, parameters)
|
|
1692
1809
|
|
|
1693
1810
|
|
|
1694
1811
|
# 3.10+
|
|
1695
|
-
if hasattr(typing,
|
|
1812
|
+
if hasattr(typing, 'Concatenate'):
|
|
1696
1813
|
Concatenate = typing.Concatenate
|
|
1697
|
-
_ConcatenateGenericAlias = typing._ConcatenateGenericAlias
|
|
1814
|
+
_ConcatenateGenericAlias = typing._ConcatenateGenericAlias
|
|
1698
1815
|
# 3.9
|
|
1699
1816
|
elif sys.version_info[:2] >= (3, 9):
|
|
1700
|
-
|
|
1701
1817
|
@_ExtensionsSpecialForm
|
|
1702
1818
|
def Concatenate(self, parameters):
|
|
1703
1819
|
"""Used in conjunction with ``ParamSpec`` and ``Callable`` to represent a
|
|
@@ -1711,17 +1827,14 @@ elif sys.version_info[:2] >= (3, 9):
|
|
|
1711
1827
|
See PEP 612 for detailed information.
|
|
1712
1828
|
"""
|
|
1713
1829
|
return _concatenate_getitem(self, parameters)
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
1830
|
# 3.8
|
|
1717
1831
|
else:
|
|
1718
|
-
|
|
1719
1832
|
class _ConcatenateForm(_ExtensionsSpecialForm, _root=True):
|
|
1720
1833
|
def __getitem__(self, parameters):
|
|
1721
1834
|
return _concatenate_getitem(self, parameters)
|
|
1722
1835
|
|
|
1723
1836
|
Concatenate = _ConcatenateForm(
|
|
1724
|
-
|
|
1837
|
+
'Concatenate',
|
|
1725
1838
|
doc="""Used in conjunction with ``ParamSpec`` and ``Callable`` to represent a
|
|
1726
1839
|
higher order function which adds, removes or transforms parameters of a
|
|
1727
1840
|
callable.
|
|
@@ -1731,15 +1844,13 @@ else:
|
|
|
1731
1844
|
Callable[Concatenate[int, P], int]
|
|
1732
1845
|
|
|
1733
1846
|
See PEP 612 for detailed information.
|
|
1734
|
-
"""
|
|
1735
|
-
)
|
|
1847
|
+
""")
|
|
1736
1848
|
|
|
1737
1849
|
# 3.10+
|
|
1738
|
-
if hasattr(typing,
|
|
1850
|
+
if hasattr(typing, 'TypeGuard'):
|
|
1739
1851
|
TypeGuard = typing.TypeGuard
|
|
1740
1852
|
# 3.9
|
|
1741
1853
|
elif sys.version_info[:2] >= (3, 9):
|
|
1742
|
-
|
|
1743
1854
|
@_ExtensionsSpecialForm
|
|
1744
1855
|
def TypeGuard(self, parameters):
|
|
1745
1856
|
"""Special typing form used to annotate the return type of a user-defined
|
|
@@ -1784,22 +1895,18 @@ elif sys.version_info[:2] >= (3, 9):
|
|
|
1784
1895
|
``TypeGuard`` also works with type variables. For more information, see
|
|
1785
1896
|
PEP 647 (User-Defined Type Guards).
|
|
1786
1897
|
"""
|
|
1787
|
-
item = typing._type_check(parameters, f
|
|
1898
|
+
item = typing._type_check(parameters, f'{self} accepts only a single type.')
|
|
1788
1899
|
return typing._GenericAlias(self, (item,))
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
1900
|
# 3.8
|
|
1792
1901
|
else:
|
|
1793
|
-
|
|
1794
1902
|
class _TypeGuardForm(_ExtensionsSpecialForm, _root=True):
|
|
1795
1903
|
def __getitem__(self, parameters):
|
|
1796
|
-
item = typing._type_check(
|
|
1797
|
-
|
|
1798
|
-
)
|
|
1904
|
+
item = typing._type_check(parameters,
|
|
1905
|
+
f'{self._name} accepts only a single type')
|
|
1799
1906
|
return typing._GenericAlias(self, (item,))
|
|
1800
1907
|
|
|
1801
1908
|
TypeGuard = _TypeGuardForm(
|
|
1802
|
-
|
|
1909
|
+
'TypeGuard',
|
|
1803
1910
|
doc="""Special typing form used to annotate the return type of a user-defined
|
|
1804
1911
|
type guard function. ``TypeGuard`` only accepts a single type argument.
|
|
1805
1912
|
At runtime, functions marked this way should return a boolean.
|
|
@@ -1841,13 +1948,104 @@ else:
|
|
|
1841
1948
|
|
|
1842
1949
|
``TypeGuard`` also works with type variables. For more information, see
|
|
1843
1950
|
PEP 647 (User-Defined Type Guards).
|
|
1844
|
-
"""
|
|
1845
|
-
|
|
1951
|
+
""")
|
|
1952
|
+
|
|
1953
|
+
# 3.13+
|
|
1954
|
+
if hasattr(typing, 'TypeIs'):
|
|
1955
|
+
TypeIs = typing.TypeIs
|
|
1956
|
+
# 3.9
|
|
1957
|
+
elif sys.version_info[:2] >= (3, 9):
|
|
1958
|
+
@_ExtensionsSpecialForm
|
|
1959
|
+
def TypeIs(self, parameters):
|
|
1960
|
+
"""Special typing form used to annotate the return type of a user-defined
|
|
1961
|
+
type narrower function. ``TypeIs`` only accepts a single type argument.
|
|
1962
|
+
At runtime, functions marked this way should return a boolean.
|
|
1963
|
+
|
|
1964
|
+
``TypeIs`` aims to benefit *type narrowing* -- a technique used by static
|
|
1965
|
+
type checkers to determine a more precise type of an expression within a
|
|
1966
|
+
program's code flow. Usually type narrowing is done by analyzing
|
|
1967
|
+
conditional code flow and applying the narrowing to a block of code. The
|
|
1968
|
+
conditional expression here is sometimes referred to as a "type guard".
|
|
1969
|
+
|
|
1970
|
+
Sometimes it would be convenient to use a user-defined boolean function
|
|
1971
|
+
as a type guard. Such a function should use ``TypeIs[...]`` as its
|
|
1972
|
+
return type to alert static type checkers to this intention.
|
|
1973
|
+
|
|
1974
|
+
Using ``-> TypeIs`` tells the static type checker that for a given
|
|
1975
|
+
function:
|
|
1976
|
+
|
|
1977
|
+
1. The return value is a boolean.
|
|
1978
|
+
2. If the return value is ``True``, the type of its argument
|
|
1979
|
+
is the intersection of the type inside ``TypeGuard`` and the argument's
|
|
1980
|
+
previously known type.
|
|
1981
|
+
|
|
1982
|
+
For example::
|
|
1983
|
+
|
|
1984
|
+
def is_awaitable(val: object) -> TypeIs[Awaitable[Any]]:
|
|
1985
|
+
return hasattr(val, '__await__')
|
|
1986
|
+
|
|
1987
|
+
def f(val: Union[int, Awaitable[int]]) -> int:
|
|
1988
|
+
if is_awaitable(val):
|
|
1989
|
+
assert_type(val, Awaitable[int])
|
|
1990
|
+
else:
|
|
1991
|
+
assert_type(val, int)
|
|
1992
|
+
|
|
1993
|
+
``TypeIs`` also works with type variables. For more information, see
|
|
1994
|
+
PEP 742 (Narrowing types with TypeIs).
|
|
1995
|
+
"""
|
|
1996
|
+
item = typing._type_check(parameters, f'{self} accepts only a single type.')
|
|
1997
|
+
return typing._GenericAlias(self, (item,))
|
|
1998
|
+
# 3.8
|
|
1999
|
+
else:
|
|
2000
|
+
class _TypeIsForm(_ExtensionsSpecialForm, _root=True):
|
|
2001
|
+
def __getitem__(self, parameters):
|
|
2002
|
+
item = typing._type_check(parameters,
|
|
2003
|
+
f'{self._name} accepts only a single type')
|
|
2004
|
+
return typing._GenericAlias(self, (item,))
|
|
2005
|
+
|
|
2006
|
+
TypeIs = _TypeIsForm(
|
|
2007
|
+
'TypeIs',
|
|
2008
|
+
doc="""Special typing form used to annotate the return type of a user-defined
|
|
2009
|
+
type narrower function. ``TypeIs`` only accepts a single type argument.
|
|
2010
|
+
At runtime, functions marked this way should return a boolean.
|
|
2011
|
+
|
|
2012
|
+
``TypeIs`` aims to benefit *type narrowing* -- a technique used by static
|
|
2013
|
+
type checkers to determine a more precise type of an expression within a
|
|
2014
|
+
program's code flow. Usually type narrowing is done by analyzing
|
|
2015
|
+
conditional code flow and applying the narrowing to a block of code. The
|
|
2016
|
+
conditional expression here is sometimes referred to as a "type guard".
|
|
2017
|
+
|
|
2018
|
+
Sometimes it would be convenient to use a user-defined boolean function
|
|
2019
|
+
as a type guard. Such a function should use ``TypeIs[...]`` as its
|
|
2020
|
+
return type to alert static type checkers to this intention.
|
|
2021
|
+
|
|
2022
|
+
Using ``-> TypeIs`` tells the static type checker that for a given
|
|
2023
|
+
function:
|
|
2024
|
+
|
|
2025
|
+
1. The return value is a boolean.
|
|
2026
|
+
2. If the return value is ``True``, the type of its argument
|
|
2027
|
+
is the intersection of the type inside ``TypeGuard`` and the argument's
|
|
2028
|
+
previously known type.
|
|
2029
|
+
|
|
2030
|
+
For example::
|
|
2031
|
+
|
|
2032
|
+
def is_awaitable(val: object) -> TypeIs[Awaitable[Any]]:
|
|
2033
|
+
return hasattr(val, '__await__')
|
|
2034
|
+
|
|
2035
|
+
def f(val: Union[int, Awaitable[int]]) -> int:
|
|
2036
|
+
if is_awaitable(val):
|
|
2037
|
+
assert_type(val, Awaitable[int])
|
|
2038
|
+
else:
|
|
2039
|
+
assert_type(val, int)
|
|
2040
|
+
|
|
2041
|
+
``TypeIs`` also works with type variables. For more information, see
|
|
2042
|
+
PEP 742 (Narrowing types with TypeIs).
|
|
2043
|
+
""")
|
|
1846
2044
|
|
|
1847
2045
|
|
|
1848
2046
|
# Vendored from cpython typing._SpecialFrom
|
|
1849
2047
|
class _SpecialForm(typing._Final, _root=True):
|
|
1850
|
-
__slots__ = (
|
|
2048
|
+
__slots__ = ('_name', '__doc__', '_getitem')
|
|
1851
2049
|
|
|
1852
2050
|
def __init__(self, getitem):
|
|
1853
2051
|
self._getitem = getitem
|
|
@@ -1855,7 +2053,7 @@ class _SpecialForm(typing._Final, _root=True):
|
|
|
1855
2053
|
self.__doc__ = getitem.__doc__
|
|
1856
2054
|
|
|
1857
2055
|
def __getattr__(self, item):
|
|
1858
|
-
if item in {
|
|
2056
|
+
if item in {'__name__', '__qualname__'}:
|
|
1859
2057
|
return self._name
|
|
1860
2058
|
|
|
1861
2059
|
raise AttributeError(item)
|
|
@@ -1864,7 +2062,7 @@ class _SpecialForm(typing._Final, _root=True):
|
|
|
1864
2062
|
raise TypeError(f"Cannot subclass {self!r}")
|
|
1865
2063
|
|
|
1866
2064
|
def __repr__(self):
|
|
1867
|
-
return f
|
|
2065
|
+
return f'typing_extensions.{self._name}'
|
|
1868
2066
|
|
|
1869
2067
|
def __reduce__(self):
|
|
1870
2068
|
return self._name
|
|
@@ -1892,14 +2090,13 @@ class _SpecialForm(typing._Final, _root=True):
|
|
|
1892
2090
|
if hasattr(typing, "LiteralString"): # 3.11+
|
|
1893
2091
|
LiteralString = typing.LiteralString
|
|
1894
2092
|
else:
|
|
1895
|
-
|
|
1896
2093
|
@_SpecialForm
|
|
1897
2094
|
def LiteralString(self, params):
|
|
1898
2095
|
"""Represents an arbitrary literal string.
|
|
1899
2096
|
|
|
1900
2097
|
Example::
|
|
1901
2098
|
|
|
1902
|
-
from
|
|
2099
|
+
from typing_extensions import LiteralString
|
|
1903
2100
|
|
|
1904
2101
|
def query(sql: LiteralString) -> ...:
|
|
1905
2102
|
...
|
|
@@ -1916,7 +2113,6 @@ else:
|
|
|
1916
2113
|
if hasattr(typing, "Self"): # 3.11+
|
|
1917
2114
|
Self = typing.Self
|
|
1918
2115
|
else:
|
|
1919
|
-
|
|
1920
2116
|
@_SpecialForm
|
|
1921
2117
|
def Self(self, params):
|
|
1922
2118
|
"""Used to spell the type of "self" in classes.
|
|
@@ -1938,7 +2134,6 @@ else:
|
|
|
1938
2134
|
if hasattr(typing, "Never"): # 3.11+
|
|
1939
2135
|
Never = typing.Never
|
|
1940
2136
|
else:
|
|
1941
|
-
|
|
1942
2137
|
@_SpecialForm
|
|
1943
2138
|
def Never(self, params):
|
|
1944
2139
|
"""The bottom type, a type that has no members.
|
|
@@ -1946,7 +2141,7 @@ else:
|
|
|
1946
2141
|
This can be used to define a function that should never be
|
|
1947
2142
|
called, or a function that never returns::
|
|
1948
2143
|
|
|
1949
|
-
from
|
|
2144
|
+
from typing_extensions import Never
|
|
1950
2145
|
|
|
1951
2146
|
def never_call_me(arg: Never) -> None:
|
|
1952
2147
|
pass
|
|
@@ -1966,11 +2161,10 @@ else:
|
|
|
1966
2161
|
raise TypeError(f"{self} is not subscriptable")
|
|
1967
2162
|
|
|
1968
2163
|
|
|
1969
|
-
if hasattr(typing,
|
|
2164
|
+
if hasattr(typing, 'Required'): # 3.11+
|
|
1970
2165
|
Required = typing.Required
|
|
1971
2166
|
NotRequired = typing.NotRequired
|
|
1972
2167
|
elif sys.version_info[:2] >= (3, 9): # 3.9-3.10
|
|
1973
|
-
|
|
1974
2168
|
@_ExtensionsSpecialForm
|
|
1975
2169
|
def Required(self, parameters):
|
|
1976
2170
|
"""A special typing construct to mark a key of a total=False TypedDict
|
|
@@ -1988,9 +2182,7 @@ elif sys.version_info[:2] >= (3, 9): # 3.9-3.10
|
|
|
1988
2182
|
There is no runtime checking that a required key is actually provided
|
|
1989
2183
|
when instantiating a related TypedDict.
|
|
1990
2184
|
"""
|
|
1991
|
-
item = typing._type_check(
|
|
1992
|
-
parameters, f"{self._name} accepts only a single type."
|
|
1993
|
-
)
|
|
2185
|
+
item = typing._type_check(parameters, f'{self._name} accepts only a single type.')
|
|
1994
2186
|
return typing._GenericAlias(self, (item,))
|
|
1995
2187
|
|
|
1996
2188
|
@_ExtensionsSpecialForm
|
|
@@ -2007,22 +2199,18 @@ elif sys.version_info[:2] >= (3, 9): # 3.9-3.10
|
|
|
2007
2199
|
year=1999,
|
|
2008
2200
|
)
|
|
2009
2201
|
"""
|
|
2010
|
-
item = typing._type_check(
|
|
2011
|
-
parameters, f"{self._name} accepts only a single type."
|
|
2012
|
-
)
|
|
2202
|
+
item = typing._type_check(parameters, f'{self._name} accepts only a single type.')
|
|
2013
2203
|
return typing._GenericAlias(self, (item,))
|
|
2014
2204
|
|
|
2015
2205
|
else: # 3.8
|
|
2016
|
-
|
|
2017
2206
|
class _RequiredForm(_ExtensionsSpecialForm, _root=True):
|
|
2018
2207
|
def __getitem__(self, parameters):
|
|
2019
|
-
item = typing._type_check(
|
|
2020
|
-
|
|
2021
|
-
)
|
|
2208
|
+
item = typing._type_check(parameters,
|
|
2209
|
+
f'{self._name} accepts only a single type.')
|
|
2022
2210
|
return typing._GenericAlias(self, (item,))
|
|
2023
2211
|
|
|
2024
2212
|
Required = _RequiredForm(
|
|
2025
|
-
|
|
2213
|
+
'Required',
|
|
2026
2214
|
doc="""A special typing construct to mark a key of a total=False TypedDict
|
|
2027
2215
|
as required. For example:
|
|
2028
2216
|
|
|
@@ -2037,10 +2225,9 @@ else: # 3.8
|
|
|
2037
2225
|
|
|
2038
2226
|
There is no runtime checking that a required key is actually provided
|
|
2039
2227
|
when instantiating a related TypedDict.
|
|
2040
|
-
"""
|
|
2041
|
-
)
|
|
2228
|
+
""")
|
|
2042
2229
|
NotRequired = _RequiredForm(
|
|
2043
|
-
|
|
2230
|
+
'NotRequired',
|
|
2044
2231
|
doc="""A special typing construct to mark a key of a TypedDict as
|
|
2045
2232
|
potentially missing. For example:
|
|
2046
2233
|
|
|
@@ -2052,8 +2239,54 @@ else: # 3.8
|
|
|
2052
2239
|
title='The Matrix', # typechecker error if key is omitted
|
|
2053
2240
|
year=1999,
|
|
2054
2241
|
)
|
|
2055
|
-
"""
|
|
2056
|
-
|
|
2242
|
+
""")
|
|
2243
|
+
|
|
2244
|
+
|
|
2245
|
+
if hasattr(typing, 'ReadOnly'):
|
|
2246
|
+
ReadOnly = typing.ReadOnly
|
|
2247
|
+
elif sys.version_info[:2] >= (3, 9): # 3.9-3.12
|
|
2248
|
+
@_ExtensionsSpecialForm
|
|
2249
|
+
def ReadOnly(self, parameters):
|
|
2250
|
+
"""A special typing construct to mark an item of a TypedDict as read-only.
|
|
2251
|
+
|
|
2252
|
+
For example:
|
|
2253
|
+
|
|
2254
|
+
class Movie(TypedDict):
|
|
2255
|
+
title: ReadOnly[str]
|
|
2256
|
+
year: int
|
|
2257
|
+
|
|
2258
|
+
def mutate_movie(m: Movie) -> None:
|
|
2259
|
+
m["year"] = 1992 # allowed
|
|
2260
|
+
m["title"] = "The Matrix" # typechecker error
|
|
2261
|
+
|
|
2262
|
+
There is no runtime checking for this property.
|
|
2263
|
+
"""
|
|
2264
|
+
item = typing._type_check(parameters, f'{self._name} accepts only a single type.')
|
|
2265
|
+
return typing._GenericAlias(self, (item,))
|
|
2266
|
+
|
|
2267
|
+
else: # 3.8
|
|
2268
|
+
class _ReadOnlyForm(_ExtensionsSpecialForm, _root=True):
|
|
2269
|
+
def __getitem__(self, parameters):
|
|
2270
|
+
item = typing._type_check(parameters,
|
|
2271
|
+
f'{self._name} accepts only a single type.')
|
|
2272
|
+
return typing._GenericAlias(self, (item,))
|
|
2273
|
+
|
|
2274
|
+
ReadOnly = _ReadOnlyForm(
|
|
2275
|
+
'ReadOnly',
|
|
2276
|
+
doc="""A special typing construct to mark a key of a TypedDict as read-only.
|
|
2277
|
+
|
|
2278
|
+
For example:
|
|
2279
|
+
|
|
2280
|
+
class Movie(TypedDict):
|
|
2281
|
+
title: ReadOnly[str]
|
|
2282
|
+
year: int
|
|
2283
|
+
|
|
2284
|
+
def mutate_movie(m: Movie) -> None:
|
|
2285
|
+
m["year"] = 1992 # allowed
|
|
2286
|
+
m["title"] = "The Matrix" # typechecker error
|
|
2287
|
+
|
|
2288
|
+
There is no runtime checking for this propery.
|
|
2289
|
+
""")
|
|
2057
2290
|
|
|
2058
2291
|
|
|
2059
2292
|
_UNPACK_DOC = """\
|
|
@@ -2105,7 +2338,6 @@ if sys.version_info >= (3, 12): # PEP 692 changed the repr of Unpack[]
|
|
|
2105
2338
|
return get_origin(obj) is Unpack
|
|
2106
2339
|
|
|
2107
2340
|
elif sys.version_info[:2] >= (3, 9): # 3.9+
|
|
2108
|
-
|
|
2109
2341
|
class _UnpackSpecialForm(_ExtensionsSpecialForm, _root=True):
|
|
2110
2342
|
def __init__(self, getitem):
|
|
2111
2343
|
super().__init__(getitem)
|
|
@@ -2114,52 +2346,119 @@ elif sys.version_info[:2] >= (3, 9): # 3.9+
|
|
|
2114
2346
|
class _UnpackAlias(typing._GenericAlias, _root=True):
|
|
2115
2347
|
__class__ = typing.TypeVar
|
|
2116
2348
|
|
|
2349
|
+
@property
|
|
2350
|
+
def __typing_unpacked_tuple_args__(self):
|
|
2351
|
+
assert self.__origin__ is Unpack
|
|
2352
|
+
assert len(self.__args__) == 1
|
|
2353
|
+
arg, = self.__args__
|
|
2354
|
+
if isinstance(arg, (typing._GenericAlias, _types.GenericAlias)):
|
|
2355
|
+
if arg.__origin__ is not tuple:
|
|
2356
|
+
raise TypeError("Unpack[...] must be used with a tuple type")
|
|
2357
|
+
return arg.__args__
|
|
2358
|
+
return None
|
|
2359
|
+
|
|
2117
2360
|
@_UnpackSpecialForm
|
|
2118
2361
|
def Unpack(self, parameters):
|
|
2119
|
-
item = typing._type_check(
|
|
2120
|
-
parameters, f"{self._name} accepts only a single type."
|
|
2121
|
-
)
|
|
2362
|
+
item = typing._type_check(parameters, f'{self._name} accepts only a single type.')
|
|
2122
2363
|
return _UnpackAlias(self, (item,))
|
|
2123
2364
|
|
|
2124
2365
|
def _is_unpack(obj):
|
|
2125
2366
|
return isinstance(obj, _UnpackAlias)
|
|
2126
2367
|
|
|
2127
2368
|
else: # 3.8
|
|
2128
|
-
|
|
2129
2369
|
class _UnpackAlias(typing._GenericAlias, _root=True):
|
|
2130
2370
|
__class__ = typing.TypeVar
|
|
2131
2371
|
|
|
2132
2372
|
class _UnpackForm(_ExtensionsSpecialForm, _root=True):
|
|
2133
2373
|
def __getitem__(self, parameters):
|
|
2134
|
-
item = typing._type_check(
|
|
2135
|
-
|
|
2136
|
-
)
|
|
2374
|
+
item = typing._type_check(parameters,
|
|
2375
|
+
f'{self._name} accepts only a single type.')
|
|
2137
2376
|
return _UnpackAlias(self, (item,))
|
|
2138
2377
|
|
|
2139
|
-
Unpack = _UnpackForm(
|
|
2378
|
+
Unpack = _UnpackForm('Unpack', doc=_UNPACK_DOC)
|
|
2140
2379
|
|
|
2141
2380
|
def _is_unpack(obj):
|
|
2142
2381
|
return isinstance(obj, _UnpackAlias)
|
|
2143
2382
|
|
|
2144
2383
|
|
|
2145
|
-
if
|
|
2384
|
+
if _PEP_696_IMPLEMENTED:
|
|
2385
|
+
from typing import TypeVarTuple
|
|
2386
|
+
|
|
2387
|
+
elif hasattr(typing, "TypeVarTuple"): # 3.11+
|
|
2388
|
+
|
|
2389
|
+
def _unpack_args(*args):
|
|
2390
|
+
newargs = []
|
|
2391
|
+
for arg in args:
|
|
2392
|
+
subargs = getattr(arg, '__typing_unpacked_tuple_args__', None)
|
|
2393
|
+
if subargs is not None and not (subargs and subargs[-1] is ...):
|
|
2394
|
+
newargs.extend(subargs)
|
|
2395
|
+
else:
|
|
2396
|
+
newargs.append(arg)
|
|
2397
|
+
return newargs
|
|
2398
|
+
|
|
2146
2399
|
# Add default parameter - PEP 696
|
|
2147
2400
|
class TypeVarTuple(metaclass=_TypeVarLikeMeta):
|
|
2148
2401
|
"""Type variable tuple."""
|
|
2149
2402
|
|
|
2150
2403
|
_backported_typevarlike = typing.TypeVarTuple
|
|
2151
2404
|
|
|
2152
|
-
def __new__(cls, name, *, default=
|
|
2405
|
+
def __new__(cls, name, *, default=NoDefault):
|
|
2153
2406
|
tvt = typing.TypeVarTuple(name)
|
|
2154
2407
|
_set_default(tvt, default)
|
|
2155
2408
|
_set_module(tvt)
|
|
2409
|
+
|
|
2410
|
+
def _typevartuple_prepare_subst(alias, args):
|
|
2411
|
+
params = alias.__parameters__
|
|
2412
|
+
typevartuple_index = params.index(tvt)
|
|
2413
|
+
for param in params[typevartuple_index + 1:]:
|
|
2414
|
+
if isinstance(param, TypeVarTuple):
|
|
2415
|
+
raise TypeError(
|
|
2416
|
+
f"More than one TypeVarTuple parameter in {alias}"
|
|
2417
|
+
)
|
|
2418
|
+
|
|
2419
|
+
alen = len(args)
|
|
2420
|
+
plen = len(params)
|
|
2421
|
+
left = typevartuple_index
|
|
2422
|
+
right = plen - typevartuple_index - 1
|
|
2423
|
+
var_tuple_index = None
|
|
2424
|
+
fillarg = None
|
|
2425
|
+
for k, arg in enumerate(args):
|
|
2426
|
+
if not isinstance(arg, type):
|
|
2427
|
+
subargs = getattr(arg, '__typing_unpacked_tuple_args__', None)
|
|
2428
|
+
if subargs and len(subargs) == 2 and subargs[-1] is ...:
|
|
2429
|
+
if var_tuple_index is not None:
|
|
2430
|
+
raise TypeError(
|
|
2431
|
+
"More than one unpacked "
|
|
2432
|
+
"arbitrary-length tuple argument"
|
|
2433
|
+
)
|
|
2434
|
+
var_tuple_index = k
|
|
2435
|
+
fillarg = subargs[0]
|
|
2436
|
+
if var_tuple_index is not None:
|
|
2437
|
+
left = min(left, var_tuple_index)
|
|
2438
|
+
right = min(right, alen - var_tuple_index - 1)
|
|
2439
|
+
elif left + right > alen:
|
|
2440
|
+
raise TypeError(f"Too few arguments for {alias};"
|
|
2441
|
+
f" actual {alen}, expected at least {plen - 1}")
|
|
2442
|
+
if left == alen - right and tvt.has_default():
|
|
2443
|
+
replacement = _unpack_args(tvt.__default__)
|
|
2444
|
+
else:
|
|
2445
|
+
replacement = args[left: alen - right]
|
|
2446
|
+
|
|
2447
|
+
return (
|
|
2448
|
+
*args[:left],
|
|
2449
|
+
*([fillarg] * (typevartuple_index - left)),
|
|
2450
|
+
replacement,
|
|
2451
|
+
*([fillarg] * (plen - right - left - typevartuple_index - 1)),
|
|
2452
|
+
*args[alen - right:],
|
|
2453
|
+
)
|
|
2454
|
+
|
|
2455
|
+
tvt.__typing_prepare_subst__ = _typevartuple_prepare_subst
|
|
2156
2456
|
return tvt
|
|
2157
2457
|
|
|
2158
2458
|
def __init_subclass__(self, *args, **kwds):
|
|
2159
2459
|
raise TypeError("Cannot subclass special typing classes")
|
|
2160
2460
|
|
|
2161
2461
|
else: # <=3.10
|
|
2162
|
-
|
|
2163
2462
|
class TypeVarTuple(_DefaultMixin):
|
|
2164
2463
|
"""Type variable tuple.
|
|
2165
2464
|
|
|
@@ -2210,13 +2509,13 @@ else: # <=3.10
|
|
|
2210
2509
|
def __iter__(self):
|
|
2211
2510
|
yield self.__unpacked__
|
|
2212
2511
|
|
|
2213
|
-
def __init__(self, name, *, default=
|
|
2512
|
+
def __init__(self, name, *, default=NoDefault):
|
|
2214
2513
|
self.__name__ = name
|
|
2215
2514
|
_DefaultMixin.__init__(self, default)
|
|
2216
2515
|
|
|
2217
2516
|
# for pickling:
|
|
2218
2517
|
def_mod = _caller()
|
|
2219
|
-
if def_mod !=
|
|
2518
|
+
if def_mod != 'typing_extensions':
|
|
2220
2519
|
self.__module__ = def_mod
|
|
2221
2520
|
|
|
2222
2521
|
self.__unpacked__ = Unpack[self]
|
|
@@ -2234,14 +2533,13 @@ else: # <=3.10
|
|
|
2234
2533
|
return self.__name__
|
|
2235
2534
|
|
|
2236
2535
|
def __init_subclass__(self, *args, **kwds):
|
|
2237
|
-
if
|
|
2536
|
+
if '_root' not in kwds:
|
|
2238
2537
|
raise TypeError("Cannot subclass special typing classes")
|
|
2239
2538
|
|
|
2240
2539
|
|
|
2241
2540
|
if hasattr(typing, "reveal_type"): # 3.11+
|
|
2242
2541
|
reveal_type = typing.reveal_type
|
|
2243
2542
|
else: # <=3.10
|
|
2244
|
-
|
|
2245
2543
|
def reveal_type(obj: T, /) -> T:
|
|
2246
2544
|
"""Reveal the inferred type of a variable.
|
|
2247
2545
|
|
|
@@ -2262,10 +2560,15 @@ else: # <=3.10
|
|
|
2262
2560
|
return obj
|
|
2263
2561
|
|
|
2264
2562
|
|
|
2563
|
+
if hasattr(typing, "_ASSERT_NEVER_REPR_MAX_LENGTH"): # 3.11+
|
|
2564
|
+
_ASSERT_NEVER_REPR_MAX_LENGTH = typing._ASSERT_NEVER_REPR_MAX_LENGTH
|
|
2565
|
+
else: # <=3.10
|
|
2566
|
+
_ASSERT_NEVER_REPR_MAX_LENGTH = 100
|
|
2567
|
+
|
|
2568
|
+
|
|
2265
2569
|
if hasattr(typing, "assert_never"): # 3.11+
|
|
2266
2570
|
assert_never = typing.assert_never
|
|
2267
2571
|
else: # <=3.10
|
|
2268
|
-
|
|
2269
2572
|
def assert_never(arg: Never, /) -> Never:
|
|
2270
2573
|
"""Assert to the type checker that a line of code is unreachable.
|
|
2271
2574
|
|
|
@@ -2286,14 +2589,16 @@ else: # <=3.10
|
|
|
2286
2589
|
At runtime, this throws an exception when called.
|
|
2287
2590
|
|
|
2288
2591
|
"""
|
|
2289
|
-
|
|
2592
|
+
value = repr(arg)
|
|
2593
|
+
if len(value) > _ASSERT_NEVER_REPR_MAX_LENGTH:
|
|
2594
|
+
value = value[:_ASSERT_NEVER_REPR_MAX_LENGTH] + '...'
|
|
2595
|
+
raise AssertionError(f"Expected code to be unreachable, but got: {value}")
|
|
2290
2596
|
|
|
2291
2597
|
|
|
2292
2598
|
if sys.version_info >= (3, 12): # 3.12+
|
|
2293
2599
|
# dataclass_transform exists in 3.11 but lacks the frozen_default parameter
|
|
2294
2600
|
dataclass_transform = typing.dataclass_transform
|
|
2295
2601
|
else: # <=3.11
|
|
2296
|
-
|
|
2297
2602
|
def dataclass_transform(
|
|
2298
2603
|
*,
|
|
2299
2604
|
eq_default: bool = True,
|
|
@@ -2301,7 +2606,8 @@ else: # <=3.11
|
|
|
2301
2606
|
kw_only_default: bool = False,
|
|
2302
2607
|
frozen_default: bool = False,
|
|
2303
2608
|
field_specifiers: typing.Tuple[
|
|
2304
|
-
typing.Union[typing.Type[typing.Any], typing.Callable[..., typing.Any]],
|
|
2609
|
+
typing.Union[typing.Type[typing.Any], typing.Callable[..., typing.Any]],
|
|
2610
|
+
...
|
|
2305
2611
|
] = (),
|
|
2306
2612
|
**kwargs: typing.Any,
|
|
2307
2613
|
) -> typing.Callable[[T], T]:
|
|
@@ -2310,7 +2616,7 @@ else: # <=3.11
|
|
|
2310
2616
|
|
|
2311
2617
|
Example:
|
|
2312
2618
|
|
|
2313
|
-
from
|
|
2619
|
+
from typing_extensions import dataclass_transform
|
|
2314
2620
|
|
|
2315
2621
|
_T = TypeVar("_T")
|
|
2316
2622
|
|
|
@@ -2366,7 +2672,6 @@ else: # <=3.11
|
|
|
2366
2672
|
See PEP 681 for details.
|
|
2367
2673
|
|
|
2368
2674
|
"""
|
|
2369
|
-
|
|
2370
2675
|
def decorator(cls_or_fn):
|
|
2371
2676
|
cls_or_fn.__dataclass_transform__ = {
|
|
2372
2677
|
"eq_default": eq_default,
|
|
@@ -2377,7 +2682,6 @@ else: # <=3.11
|
|
|
2377
2682
|
"kwargs": kwargs,
|
|
2378
2683
|
}
|
|
2379
2684
|
return cls_or_fn
|
|
2380
|
-
|
|
2381
2685
|
return decorator
|
|
2382
2686
|
|
|
2383
2687
|
|
|
@@ -2392,7 +2696,7 @@ else: # <=3.11
|
|
|
2392
2696
|
Usage:
|
|
2393
2697
|
|
|
2394
2698
|
class Base:
|
|
2395
|
-
def method(self) -> None:
|
|
2699
|
+
def method(self) -> None:
|
|
2396
2700
|
pass
|
|
2397
2701
|
|
|
2398
2702
|
class Child(Base):
|
|
@@ -2422,20 +2726,17 @@ else: # <=3.11
|
|
|
2422
2726
|
return arg
|
|
2423
2727
|
|
|
2424
2728
|
|
|
2425
|
-
if hasattr(
|
|
2426
|
-
deprecated =
|
|
2729
|
+
if hasattr(warnings, "deprecated"):
|
|
2730
|
+
deprecated = warnings.deprecated
|
|
2427
2731
|
else:
|
|
2428
2732
|
_T = typing.TypeVar("_T")
|
|
2429
2733
|
|
|
2430
|
-
|
|
2431
|
-
msg: str,
|
|
2432
|
-
/,
|
|
2433
|
-
*,
|
|
2434
|
-
category: typing.Optional[typing.Type[Warning]] = DeprecationWarning,
|
|
2435
|
-
stacklevel: int = 1,
|
|
2436
|
-
) -> typing.Callable[[_T], _T]:
|
|
2734
|
+
class deprecated:
|
|
2437
2735
|
"""Indicate that a class, function or overload is deprecated.
|
|
2438
2736
|
|
|
2737
|
+
When this decorator is applied to an object, the type checker
|
|
2738
|
+
will generate a diagnostic on usage of the deprecated object.
|
|
2739
|
+
|
|
2439
2740
|
Usage:
|
|
2440
2741
|
|
|
2441
2742
|
@deprecated("Use B instead")
|
|
@@ -2452,50 +2753,99 @@ else:
|
|
|
2452
2753
|
@overload
|
|
2453
2754
|
def g(x: str) -> int: ...
|
|
2454
2755
|
|
|
2455
|
-
|
|
2456
|
-
|
|
2457
|
-
|
|
2458
|
-
|
|
2459
|
-
|
|
2460
|
-
for classes, on instantiation. If the ``category`` is ``None``,
|
|
2461
|
-
no warning is emitted. The ``stacklevel`` determines where the
|
|
2756
|
+
The warning specified by *category* will be emitted at runtime
|
|
2757
|
+
on use of deprecated objects. For functions, that happens on calls;
|
|
2758
|
+
for classes, on instantiation and on creation of subclasses.
|
|
2759
|
+
If the *category* is ``None``, no warning is emitted at runtime.
|
|
2760
|
+
The *stacklevel* determines where the
|
|
2462
2761
|
warning is emitted. If it is ``1`` (the default), the warning
|
|
2463
2762
|
is emitted at the direct caller of the deprecated object; if it
|
|
2464
2763
|
is higher, it is emitted further up the stack.
|
|
2764
|
+
Static type checker behavior is not affected by the *category*
|
|
2765
|
+
and *stacklevel* arguments.
|
|
2465
2766
|
|
|
2466
|
-
The decorator
|
|
2467
|
-
attribute on the decorated object
|
|
2468
|
-
|
|
2767
|
+
The deprecation message passed to the decorator is saved in the
|
|
2768
|
+
``__deprecated__`` attribute on the decorated object.
|
|
2769
|
+
If applied to an overload, the decorator
|
|
2469
2770
|
must be after the ``@overload`` decorator for the attribute to
|
|
2470
2771
|
exist on the overload as returned by ``get_overloads()``.
|
|
2471
2772
|
|
|
2472
2773
|
See PEP 702 for details.
|
|
2473
2774
|
|
|
2474
2775
|
"""
|
|
2475
|
-
|
|
2476
|
-
|
|
2776
|
+
def __init__(
|
|
2777
|
+
self,
|
|
2778
|
+
message: str,
|
|
2779
|
+
/,
|
|
2780
|
+
*,
|
|
2781
|
+
category: typing.Optional[typing.Type[Warning]] = DeprecationWarning,
|
|
2782
|
+
stacklevel: int = 1,
|
|
2783
|
+
) -> None:
|
|
2784
|
+
if not isinstance(message, str):
|
|
2785
|
+
raise TypeError(
|
|
2786
|
+
"Expected an object of type str for 'message', not "
|
|
2787
|
+
f"{type(message).__name__!r}"
|
|
2788
|
+
)
|
|
2789
|
+
self.message = message
|
|
2790
|
+
self.category = category
|
|
2791
|
+
self.stacklevel = stacklevel
|
|
2792
|
+
|
|
2793
|
+
def __call__(self, arg: _T, /) -> _T:
|
|
2794
|
+
# Make sure the inner functions created below don't
|
|
2795
|
+
# retain a reference to self.
|
|
2796
|
+
msg = self.message
|
|
2797
|
+
category = self.category
|
|
2798
|
+
stacklevel = self.stacklevel
|
|
2477
2799
|
if category is None:
|
|
2478
2800
|
arg.__deprecated__ = msg
|
|
2479
2801
|
return arg
|
|
2480
2802
|
elif isinstance(arg, type):
|
|
2803
|
+
import functools
|
|
2804
|
+
from types import MethodType
|
|
2805
|
+
|
|
2481
2806
|
original_new = arg.__new__
|
|
2482
|
-
has_init = arg.__init__ is not object.__init__
|
|
2483
2807
|
|
|
2484
2808
|
@functools.wraps(original_new)
|
|
2485
2809
|
def __new__(cls, *args, **kwargs):
|
|
2486
|
-
|
|
2810
|
+
if cls is arg:
|
|
2811
|
+
warnings.warn(msg, category=category, stacklevel=stacklevel + 1)
|
|
2487
2812
|
if original_new is not object.__new__:
|
|
2488
2813
|
return original_new(cls, *args, **kwargs)
|
|
2489
2814
|
# Mirrors a similar check in object.__new__.
|
|
2490
|
-
elif
|
|
2815
|
+
elif cls.__init__ is object.__init__ and (args or kwargs):
|
|
2491
2816
|
raise TypeError(f"{cls.__name__}() takes no arguments")
|
|
2492
2817
|
else:
|
|
2493
2818
|
return original_new(cls)
|
|
2494
2819
|
|
|
2495
2820
|
arg.__new__ = staticmethod(__new__)
|
|
2821
|
+
|
|
2822
|
+
original_init_subclass = arg.__init_subclass__
|
|
2823
|
+
# We need slightly different behavior if __init_subclass__
|
|
2824
|
+
# is a bound method (likely if it was implemented in Python)
|
|
2825
|
+
if isinstance(original_init_subclass, MethodType):
|
|
2826
|
+
original_init_subclass = original_init_subclass.__func__
|
|
2827
|
+
|
|
2828
|
+
@functools.wraps(original_init_subclass)
|
|
2829
|
+
def __init_subclass__(*args, **kwargs):
|
|
2830
|
+
warnings.warn(msg, category=category, stacklevel=stacklevel + 1)
|
|
2831
|
+
return original_init_subclass(*args, **kwargs)
|
|
2832
|
+
|
|
2833
|
+
arg.__init_subclass__ = classmethod(__init_subclass__)
|
|
2834
|
+
# Or otherwise, which likely means it's a builtin such as
|
|
2835
|
+
# object's implementation of __init_subclass__.
|
|
2836
|
+
else:
|
|
2837
|
+
@functools.wraps(original_init_subclass)
|
|
2838
|
+
def __init_subclass__(*args, **kwargs):
|
|
2839
|
+
warnings.warn(msg, category=category, stacklevel=stacklevel + 1)
|
|
2840
|
+
return original_init_subclass(*args, **kwargs)
|
|
2841
|
+
|
|
2842
|
+
arg.__init_subclass__ = __init_subclass__
|
|
2843
|
+
|
|
2496
2844
|
arg.__deprecated__ = __new__.__deprecated__ = msg
|
|
2845
|
+
__init_subclass__.__deprecated__ = msg
|
|
2497
2846
|
return arg
|
|
2498
2847
|
elif callable(arg):
|
|
2848
|
+
import functools
|
|
2499
2849
|
|
|
2500
2850
|
@functools.wraps(arg)
|
|
2501
2851
|
def wrapper(*args, **kwargs):
|
|
@@ -2510,8 +2860,6 @@ else:
|
|
|
2510
2860
|
f"a class or callable, not {arg!r}"
|
|
2511
2861
|
)
|
|
2512
2862
|
|
|
2513
|
-
return decorator
|
|
2514
|
-
|
|
2515
2863
|
|
|
2516
2864
|
# We have to do some monkey patching to deal with the dual nature of
|
|
2517
2865
|
# Unpack/TypeVarTuple:
|
|
@@ -2521,10 +2869,222 @@ else:
|
|
|
2521
2869
|
# counting generic parameters, so that when we subscript a generic,
|
|
2522
2870
|
# the runtime doesn't try to substitute the Unpack with the subscripted type.
|
|
2523
2871
|
if not hasattr(typing, "TypeVarTuple"):
|
|
2524
|
-
|
|
2872
|
+
def _check_generic(cls, parameters, elen=_marker):
|
|
2873
|
+
"""Check correct count for parameters of a generic cls (internal helper).
|
|
2874
|
+
|
|
2875
|
+
This gives a nice error message in case of count mismatch.
|
|
2876
|
+
"""
|
|
2877
|
+
if not elen:
|
|
2878
|
+
raise TypeError(f"{cls} is not a generic class")
|
|
2879
|
+
if elen is _marker:
|
|
2880
|
+
if not hasattr(cls, "__parameters__") or not cls.__parameters__:
|
|
2881
|
+
raise TypeError(f"{cls} is not a generic class")
|
|
2882
|
+
elen = len(cls.__parameters__)
|
|
2883
|
+
alen = len(parameters)
|
|
2884
|
+
if alen != elen:
|
|
2885
|
+
expect_val = elen
|
|
2886
|
+
if hasattr(cls, "__parameters__"):
|
|
2887
|
+
parameters = [p for p in cls.__parameters__ if not _is_unpack(p)]
|
|
2888
|
+
num_tv_tuples = sum(isinstance(p, TypeVarTuple) for p in parameters)
|
|
2889
|
+
if (num_tv_tuples > 0) and (alen >= elen - num_tv_tuples):
|
|
2890
|
+
return
|
|
2891
|
+
|
|
2892
|
+
# deal with TypeVarLike defaults
|
|
2893
|
+
# required TypeVarLikes cannot appear after a defaulted one.
|
|
2894
|
+
if alen < elen:
|
|
2895
|
+
# since we validate TypeVarLike default in _collect_type_vars
|
|
2896
|
+
# or _collect_parameters we can safely check parameters[alen]
|
|
2897
|
+
if (
|
|
2898
|
+
getattr(parameters[alen], '__default__', NoDefault)
|
|
2899
|
+
is not NoDefault
|
|
2900
|
+
):
|
|
2901
|
+
return
|
|
2902
|
+
|
|
2903
|
+
num_default_tv = sum(getattr(p, '__default__', NoDefault)
|
|
2904
|
+
is not NoDefault for p in parameters)
|
|
2905
|
+
|
|
2906
|
+
elen -= num_default_tv
|
|
2907
|
+
|
|
2908
|
+
expect_val = f"at least {elen}"
|
|
2909
|
+
|
|
2910
|
+
things = "arguments" if sys.version_info >= (3, 10) else "parameters"
|
|
2911
|
+
raise TypeError(f"Too {'many' if alen > elen else 'few'} {things}"
|
|
2912
|
+
f" for {cls}; actual {alen}, expected {expect_val}")
|
|
2913
|
+
else:
|
|
2914
|
+
# Python 3.11+
|
|
2915
|
+
|
|
2916
|
+
def _check_generic(cls, parameters, elen):
|
|
2917
|
+
"""Check correct count for parameters of a generic cls (internal helper).
|
|
2918
|
+
|
|
2919
|
+
This gives a nice error message in case of count mismatch.
|
|
2920
|
+
"""
|
|
2921
|
+
if not elen:
|
|
2922
|
+
raise TypeError(f"{cls} is not a generic class")
|
|
2923
|
+
alen = len(parameters)
|
|
2924
|
+
if alen != elen:
|
|
2925
|
+
expect_val = elen
|
|
2926
|
+
if hasattr(cls, "__parameters__"):
|
|
2927
|
+
parameters = [p for p in cls.__parameters__ if not _is_unpack(p)]
|
|
2928
|
+
|
|
2929
|
+
# deal with TypeVarLike defaults
|
|
2930
|
+
# required TypeVarLikes cannot appear after a defaulted one.
|
|
2931
|
+
if alen < elen:
|
|
2932
|
+
# since we validate TypeVarLike default in _collect_type_vars
|
|
2933
|
+
# or _collect_parameters we can safely check parameters[alen]
|
|
2934
|
+
if (
|
|
2935
|
+
getattr(parameters[alen], '__default__', NoDefault)
|
|
2936
|
+
is not NoDefault
|
|
2937
|
+
):
|
|
2938
|
+
return
|
|
2939
|
+
|
|
2940
|
+
num_default_tv = sum(getattr(p, '__default__', NoDefault)
|
|
2941
|
+
is not NoDefault for p in parameters)
|
|
2942
|
+
|
|
2943
|
+
elen -= num_default_tv
|
|
2944
|
+
|
|
2945
|
+
expect_val = f"at least {elen}"
|
|
2946
|
+
|
|
2947
|
+
raise TypeError(f"Too {'many' if alen > elen else 'few'} arguments"
|
|
2948
|
+
f" for {cls}; actual {alen}, expected {expect_val}")
|
|
2949
|
+
|
|
2950
|
+
if not _PEP_696_IMPLEMENTED:
|
|
2525
2951
|
typing._check_generic = _check_generic
|
|
2526
2952
|
|
|
2527
2953
|
|
|
2954
|
+
def _has_generic_or_protocol_as_origin() -> bool:
|
|
2955
|
+
try:
|
|
2956
|
+
frame = sys._getframe(2)
|
|
2957
|
+
# - Catch AttributeError: not all Python implementations have sys._getframe()
|
|
2958
|
+
# - Catch ValueError: maybe we're called from an unexpected module
|
|
2959
|
+
# and the call stack isn't deep enough
|
|
2960
|
+
except (AttributeError, ValueError):
|
|
2961
|
+
return False # err on the side of leniency
|
|
2962
|
+
else:
|
|
2963
|
+
# If we somehow get invoked from outside typing.py,
|
|
2964
|
+
# also err on the side of leniency
|
|
2965
|
+
if frame.f_globals.get("__name__") != "typing":
|
|
2966
|
+
return False
|
|
2967
|
+
origin = frame.f_locals.get("origin")
|
|
2968
|
+
# Cannot use "in" because origin may be an object with a buggy __eq__ that
|
|
2969
|
+
# throws an error.
|
|
2970
|
+
return origin is typing.Generic or origin is Protocol or origin is typing.Protocol
|
|
2971
|
+
|
|
2972
|
+
|
|
2973
|
+
_TYPEVARTUPLE_TYPES = {TypeVarTuple, getattr(typing, "TypeVarTuple", None)}
|
|
2974
|
+
|
|
2975
|
+
|
|
2976
|
+
def _is_unpacked_typevartuple(x) -> bool:
|
|
2977
|
+
if get_origin(x) is not Unpack:
|
|
2978
|
+
return False
|
|
2979
|
+
args = get_args(x)
|
|
2980
|
+
return (
|
|
2981
|
+
bool(args)
|
|
2982
|
+
and len(args) == 1
|
|
2983
|
+
and type(args[0]) in _TYPEVARTUPLE_TYPES
|
|
2984
|
+
)
|
|
2985
|
+
|
|
2986
|
+
|
|
2987
|
+
# Python 3.11+ _collect_type_vars was renamed to _collect_parameters
|
|
2988
|
+
if hasattr(typing, '_collect_type_vars'):
|
|
2989
|
+
def _collect_type_vars(types, typevar_types=None):
|
|
2990
|
+
"""Collect all type variable contained in types in order of
|
|
2991
|
+
first appearance (lexicographic order). For example::
|
|
2992
|
+
|
|
2993
|
+
_collect_type_vars((T, List[S, T])) == (T, S)
|
|
2994
|
+
"""
|
|
2995
|
+
if typevar_types is None:
|
|
2996
|
+
typevar_types = typing.TypeVar
|
|
2997
|
+
tvars = []
|
|
2998
|
+
|
|
2999
|
+
# A required TypeVarLike cannot appear after a TypeVarLike with a default
|
|
3000
|
+
# if it was a direct call to `Generic[]` or `Protocol[]`
|
|
3001
|
+
enforce_default_ordering = _has_generic_or_protocol_as_origin()
|
|
3002
|
+
default_encountered = False
|
|
3003
|
+
|
|
3004
|
+
# Also, a TypeVarLike with a default cannot appear after a TypeVarTuple
|
|
3005
|
+
type_var_tuple_encountered = False
|
|
3006
|
+
|
|
3007
|
+
for t in types:
|
|
3008
|
+
if _is_unpacked_typevartuple(t):
|
|
3009
|
+
type_var_tuple_encountered = True
|
|
3010
|
+
elif isinstance(t, typevar_types) and t not in tvars:
|
|
3011
|
+
if enforce_default_ordering:
|
|
3012
|
+
has_default = getattr(t, '__default__', NoDefault) is not NoDefault
|
|
3013
|
+
if has_default:
|
|
3014
|
+
if type_var_tuple_encountered:
|
|
3015
|
+
raise TypeError('Type parameter with a default'
|
|
3016
|
+
' follows TypeVarTuple')
|
|
3017
|
+
default_encountered = True
|
|
3018
|
+
elif default_encountered:
|
|
3019
|
+
raise TypeError(f'Type parameter {t!r} without a default'
|
|
3020
|
+
' follows type parameter with a default')
|
|
3021
|
+
|
|
3022
|
+
tvars.append(t)
|
|
3023
|
+
if _should_collect_from_parameters(t):
|
|
3024
|
+
tvars.extend([t for t in t.__parameters__ if t not in tvars])
|
|
3025
|
+
return tuple(tvars)
|
|
3026
|
+
|
|
3027
|
+
typing._collect_type_vars = _collect_type_vars
|
|
3028
|
+
else:
|
|
3029
|
+
def _collect_parameters(args):
|
|
3030
|
+
"""Collect all type variables and parameter specifications in args
|
|
3031
|
+
in order of first appearance (lexicographic order).
|
|
3032
|
+
|
|
3033
|
+
For example::
|
|
3034
|
+
|
|
3035
|
+
assert _collect_parameters((T, Callable[P, T])) == (T, P)
|
|
3036
|
+
"""
|
|
3037
|
+
parameters = []
|
|
3038
|
+
|
|
3039
|
+
# A required TypeVarLike cannot appear after a TypeVarLike with default
|
|
3040
|
+
# if it was a direct call to `Generic[]` or `Protocol[]`
|
|
3041
|
+
enforce_default_ordering = _has_generic_or_protocol_as_origin()
|
|
3042
|
+
default_encountered = False
|
|
3043
|
+
|
|
3044
|
+
# Also, a TypeVarLike with a default cannot appear after a TypeVarTuple
|
|
3045
|
+
type_var_tuple_encountered = False
|
|
3046
|
+
|
|
3047
|
+
for t in args:
|
|
3048
|
+
if isinstance(t, type):
|
|
3049
|
+
# We don't want __parameters__ descriptor of a bare Python class.
|
|
3050
|
+
pass
|
|
3051
|
+
elif isinstance(t, tuple):
|
|
3052
|
+
# `t` might be a tuple, when `ParamSpec` is substituted with
|
|
3053
|
+
# `[T, int]`, or `[int, *Ts]`, etc.
|
|
3054
|
+
for x in t:
|
|
3055
|
+
for collected in _collect_parameters([x]):
|
|
3056
|
+
if collected not in parameters:
|
|
3057
|
+
parameters.append(collected)
|
|
3058
|
+
elif hasattr(t, '__typing_subst__'):
|
|
3059
|
+
if t not in parameters:
|
|
3060
|
+
if enforce_default_ordering:
|
|
3061
|
+
has_default = (
|
|
3062
|
+
getattr(t, '__default__', NoDefault) is not NoDefault
|
|
3063
|
+
)
|
|
3064
|
+
|
|
3065
|
+
if type_var_tuple_encountered and has_default:
|
|
3066
|
+
raise TypeError('Type parameter with a default'
|
|
3067
|
+
' follows TypeVarTuple')
|
|
3068
|
+
|
|
3069
|
+
if has_default:
|
|
3070
|
+
default_encountered = True
|
|
3071
|
+
elif default_encountered:
|
|
3072
|
+
raise TypeError(f'Type parameter {t!r} without a default'
|
|
3073
|
+
' follows type parameter with a default')
|
|
3074
|
+
|
|
3075
|
+
parameters.append(t)
|
|
3076
|
+
else:
|
|
3077
|
+
if _is_unpacked_typevartuple(t):
|
|
3078
|
+
type_var_tuple_encountered = True
|
|
3079
|
+
for x in getattr(t, '__parameters__', ()):
|
|
3080
|
+
if x not in parameters:
|
|
3081
|
+
parameters.append(x)
|
|
3082
|
+
|
|
3083
|
+
return tuple(parameters)
|
|
3084
|
+
|
|
3085
|
+
if not _PEP_696_IMPLEMENTED:
|
|
3086
|
+
typing._collect_parameters = _collect_parameters
|
|
3087
|
+
|
|
2528
3088
|
# Backport typing.NamedTuple as it exists in Python 3.13.
|
|
2529
3089
|
# In 3.11, the ability to define generic `NamedTuple`s was supported.
|
|
2530
3090
|
# This was explicitly disallowed in 3.9-3.10, and only half-worked in <=3.8.
|
|
@@ -2533,14 +3093,12 @@ if not hasattr(typing, "TypeVarTuple"):
|
|
|
2533
3093
|
if sys.version_info >= (3, 13):
|
|
2534
3094
|
NamedTuple = typing.NamedTuple
|
|
2535
3095
|
else:
|
|
2536
|
-
|
|
2537
3096
|
def _make_nmtuple(name, types, module, defaults=()):
|
|
2538
3097
|
fields = [n for n, t in types]
|
|
2539
|
-
annotations = {
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
|
|
2543
|
-
nm_tpl = collections.namedtuple(name, fields, defaults=defaults, module=module)
|
|
3098
|
+
annotations = {n: typing._type_check(t, f"field {n} annotation must be a type")
|
|
3099
|
+
for n, t in types}
|
|
3100
|
+
nm_tpl = collections.namedtuple(name, fields,
|
|
3101
|
+
defaults=defaults, module=module)
|
|
2544
3102
|
nm_tpl.__annotations__ = nm_tpl.__new__.__annotations__ = annotations
|
|
2545
3103
|
# The `_field_types` attribute was removed in 3.9;
|
|
2546
3104
|
# in earlier versions, it is the same as the `__annotations__` attribute
|
|
@@ -2549,9 +3107,7 @@ else:
|
|
|
2549
3107
|
return nm_tpl
|
|
2550
3108
|
|
|
2551
3109
|
_prohibited_namedtuple_fields = typing._prohibited
|
|
2552
|
-
_special_namedtuple_fields = frozenset(
|
|
2553
|
-
{"__module__", "__name__", "__annotations__"}
|
|
2554
|
-
)
|
|
3110
|
+
_special_namedtuple_fields = frozenset({'__module__', '__name__', '__annotations__'})
|
|
2555
3111
|
|
|
2556
3112
|
class _NamedTupleMeta(type):
|
|
2557
3113
|
def __new__(cls, typename, bases, ns):
|
|
@@ -2559,49 +3115,71 @@ else:
|
|
|
2559
3115
|
for base in bases:
|
|
2560
3116
|
if base is not _NamedTuple and base is not typing.Generic:
|
|
2561
3117
|
raise TypeError(
|
|
2562
|
-
|
|
2563
|
-
)
|
|
3118
|
+
'can only inherit from a NamedTuple type and Generic')
|
|
2564
3119
|
bases = tuple(tuple if base is _NamedTuple else base for base in bases)
|
|
2565
|
-
|
|
3120
|
+
if "__annotations__" in ns:
|
|
3121
|
+
types = ns["__annotations__"]
|
|
3122
|
+
elif "__annotate__" in ns:
|
|
3123
|
+
# TODO: Use inspect.VALUE here, and make the annotations lazily evaluated
|
|
3124
|
+
types = ns["__annotate__"](1)
|
|
3125
|
+
else:
|
|
3126
|
+
types = {}
|
|
2566
3127
|
default_names = []
|
|
2567
3128
|
for field_name in types:
|
|
2568
3129
|
if field_name in ns:
|
|
2569
3130
|
default_names.append(field_name)
|
|
2570
3131
|
elif default_names:
|
|
2571
|
-
raise TypeError(
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
f"{', '.join(default_names)}"
|
|
2576
|
-
)
|
|
3132
|
+
raise TypeError(f"Non-default namedtuple field {field_name} "
|
|
3133
|
+
f"cannot follow default field"
|
|
3134
|
+
f"{'s' if len(default_names) > 1 else ''} "
|
|
3135
|
+
f"{', '.join(default_names)}")
|
|
2577
3136
|
nm_tpl = _make_nmtuple(
|
|
2578
|
-
typename,
|
|
2579
|
-
types.items(),
|
|
3137
|
+
typename, types.items(),
|
|
2580
3138
|
defaults=[ns[n] for n in default_names],
|
|
2581
|
-
module=ns[
|
|
3139
|
+
module=ns['__module__']
|
|
2582
3140
|
)
|
|
2583
3141
|
nm_tpl.__bases__ = bases
|
|
2584
3142
|
if typing.Generic in bases:
|
|
2585
|
-
if hasattr(typing,
|
|
2586
|
-
nm_tpl.__class_getitem__ = classmethod(
|
|
2587
|
-
typing._generic_class_getitem
|
|
2588
|
-
)
|
|
3143
|
+
if hasattr(typing, '_generic_class_getitem'): # 3.12+
|
|
3144
|
+
nm_tpl.__class_getitem__ = classmethod(typing._generic_class_getitem)
|
|
2589
3145
|
else:
|
|
2590
3146
|
class_getitem = typing.Generic.__class_getitem__.__func__
|
|
2591
3147
|
nm_tpl.__class_getitem__ = classmethod(class_getitem)
|
|
2592
3148
|
# update from user namespace without overriding special namedtuple attributes
|
|
2593
|
-
for key in ns:
|
|
3149
|
+
for key, val in ns.items():
|
|
2594
3150
|
if key in _prohibited_namedtuple_fields:
|
|
2595
3151
|
raise AttributeError("Cannot overwrite NamedTuple attribute " + key)
|
|
2596
|
-
elif
|
|
2597
|
-
|
|
2598
|
-
|
|
2599
|
-
|
|
3152
|
+
elif key not in _special_namedtuple_fields:
|
|
3153
|
+
if key not in nm_tpl._fields:
|
|
3154
|
+
setattr(nm_tpl, key, ns[key])
|
|
3155
|
+
try:
|
|
3156
|
+
set_name = type(val).__set_name__
|
|
3157
|
+
except AttributeError:
|
|
3158
|
+
pass
|
|
3159
|
+
else:
|
|
3160
|
+
try:
|
|
3161
|
+
set_name(val, nm_tpl, key)
|
|
3162
|
+
except BaseException as e:
|
|
3163
|
+
msg = (
|
|
3164
|
+
f"Error calling __set_name__ on {type(val).__name__!r} "
|
|
3165
|
+
f"instance {key!r} in {typename!r}"
|
|
3166
|
+
)
|
|
3167
|
+
# BaseException.add_note() existed on py311,
|
|
3168
|
+
# but the __set_name__ machinery didn't start
|
|
3169
|
+
# using add_note() until py312.
|
|
3170
|
+
# Making sure exceptions are raised in the same way
|
|
3171
|
+
# as in "normal" classes seems most important here.
|
|
3172
|
+
if sys.version_info >= (3, 12):
|
|
3173
|
+
e.add_note(msg)
|
|
3174
|
+
raise
|
|
3175
|
+
else:
|
|
3176
|
+
raise RuntimeError(msg) from e
|
|
3177
|
+
|
|
2600
3178
|
if typing.Generic in bases:
|
|
2601
3179
|
nm_tpl.__init_subclass__()
|
|
2602
3180
|
return nm_tpl
|
|
2603
3181
|
|
|
2604
|
-
_NamedTuple = type.__new__(_NamedTupleMeta,
|
|
3182
|
+
_NamedTuple = type.__new__(_NamedTupleMeta, 'NamedTuple', (), {})
|
|
2605
3183
|
|
|
2606
3184
|
def _namedtuple_mro_entries(bases):
|
|
2607
3185
|
assert NamedTuple in bases
|
|
@@ -2639,15 +3217,11 @@ else:
|
|
|
2639
3217
|
deprecated_thing = "Failing to pass a value for the 'fields' parameter"
|
|
2640
3218
|
example = f"`{typename} = NamedTuple({typename!r}, [])`"
|
|
2641
3219
|
deprecation_msg = (
|
|
2642
|
-
|
|
2643
|
-
|
|
2644
|
-
|
|
2645
|
-
|
|
2646
|
-
|
|
2647
|
-
)
|
|
2648
|
-
+ example
|
|
2649
|
-
+ "."
|
|
2650
|
-
)
|
|
3220
|
+
"{name} is deprecated and will be disallowed in Python {remove}. "
|
|
3221
|
+
"To create a NamedTuple class with 0 fields "
|
|
3222
|
+
"using the functional syntax, "
|
|
3223
|
+
"pass an empty list, e.g. "
|
|
3224
|
+
) + example + "."
|
|
2651
3225
|
elif fields is None:
|
|
2652
3226
|
if kwargs:
|
|
2653
3227
|
raise TypeError(
|
|
@@ -2658,20 +3232,14 @@ else:
|
|
|
2658
3232
|
deprecated_thing = "Passing `None` as the 'fields' parameter"
|
|
2659
3233
|
example = f"`{typename} = NamedTuple({typename!r}, [])`"
|
|
2660
3234
|
deprecation_msg = (
|
|
2661
|
-
|
|
2662
|
-
|
|
2663
|
-
|
|
2664
|
-
|
|
2665
|
-
|
|
2666
|
-
)
|
|
2667
|
-
+ example
|
|
2668
|
-
+ "."
|
|
2669
|
-
)
|
|
3235
|
+
"{name} is deprecated and will be disallowed in Python {remove}. "
|
|
3236
|
+
"To create a NamedTuple class with 0 fields "
|
|
3237
|
+
"using the functional syntax, "
|
|
3238
|
+
"pass an empty list, e.g. "
|
|
3239
|
+
) + example + "."
|
|
2670
3240
|
elif kwargs:
|
|
2671
|
-
raise TypeError(
|
|
2672
|
-
|
|
2673
|
-
" can be provided to NamedTuple, not both"
|
|
2674
|
-
)
|
|
3241
|
+
raise TypeError("Either list of fields or keywords"
|
|
3242
|
+
" can be provided to NamedTuple, not both")
|
|
2675
3243
|
if fields is _marker or fields is None:
|
|
2676
3244
|
warnings.warn(
|
|
2677
3245
|
deprecation_msg.format(name=deprecated_thing, remove="3.15"),
|
|
@@ -2687,8 +3255,7 @@ else:
|
|
|
2687
3255
|
if hasattr(collections.abc, "Buffer"):
|
|
2688
3256
|
Buffer = collections.abc.Buffer
|
|
2689
3257
|
else:
|
|
2690
|
-
|
|
2691
|
-
class Buffer(abc.ABC):
|
|
3258
|
+
class Buffer(abc.ABC): # noqa: B024
|
|
2692
3259
|
"""Base class for classes that implement the buffer protocol.
|
|
2693
3260
|
|
|
2694
3261
|
The buffer protocol allows Python objects to expose a low-level
|
|
@@ -2718,14 +3285,13 @@ else:
|
|
|
2718
3285
|
if hasattr(_types, "get_original_bases"):
|
|
2719
3286
|
get_original_bases = _types.get_original_bases
|
|
2720
3287
|
else:
|
|
2721
|
-
|
|
2722
3288
|
def get_original_bases(cls, /):
|
|
2723
3289
|
"""Return the class's "original" bases prior to modification by `__mro_entries__`.
|
|
2724
3290
|
|
|
2725
3291
|
Examples::
|
|
2726
3292
|
|
|
2727
3293
|
from typing import TypeVar, Generic
|
|
2728
|
-
from
|
|
3294
|
+
from typing_extensions import NamedTuple, TypedDict
|
|
2729
3295
|
|
|
2730
3296
|
T = TypeVar("T")
|
|
2731
3297
|
class Foo(Generic[T]): ...
|
|
@@ -2744,7 +3310,7 @@ else:
|
|
|
2744
3310
|
return cls.__dict__.get("__orig_bases__", cls.__bases__)
|
|
2745
3311
|
except AttributeError:
|
|
2746
3312
|
raise TypeError(
|
|
2747
|
-
f
|
|
3313
|
+
f'Expected an instance of type, not {type(cls).__name__!r}'
|
|
2748
3314
|
) from None
|
|
2749
3315
|
|
|
2750
3316
|
|
|
@@ -2753,7 +3319,6 @@ else:
|
|
|
2753
3319
|
if sys.version_info >= (3, 11):
|
|
2754
3320
|
NewType = typing.NewType
|
|
2755
3321
|
else:
|
|
2756
|
-
|
|
2757
3322
|
class NewType:
|
|
2758
3323
|
"""NewType creates simple unique types with almost zero
|
|
2759
3324
|
runtime overhead. NewType(name, tp) is considered a subtype of tp
|
|
@@ -2773,12 +3338,12 @@ else:
|
|
|
2773
3338
|
|
|
2774
3339
|
def __init__(self, name, tp):
|
|
2775
3340
|
self.__qualname__ = name
|
|
2776
|
-
if
|
|
2777
|
-
name = name.rpartition(
|
|
3341
|
+
if '.' in name:
|
|
3342
|
+
name = name.rpartition('.')[-1]
|
|
2778
3343
|
self.__name__ = name
|
|
2779
3344
|
self.__supertype__ = tp
|
|
2780
3345
|
def_mod = _caller()
|
|
2781
|
-
if def_mod !=
|
|
3346
|
+
if def_mod != 'typing_extensions':
|
|
2782
3347
|
self.__module__ = def_mod
|
|
2783
3348
|
|
|
2784
3349
|
def __mro_entries__(self, bases):
|
|
@@ -2798,7 +3363,7 @@ else:
|
|
|
2798
3363
|
return (Dummy,)
|
|
2799
3364
|
|
|
2800
3365
|
def __repr__(self):
|
|
2801
|
-
return f
|
|
3366
|
+
return f'{self.__module__}.{self.__qualname__}'
|
|
2802
3367
|
|
|
2803
3368
|
def __reduce__(self):
|
|
2804
3369
|
return self.__qualname__
|
|
@@ -2817,18 +3382,14 @@ else:
|
|
|
2817
3382
|
if hasattr(typing, "TypeAliasType"):
|
|
2818
3383
|
TypeAliasType = typing.TypeAliasType
|
|
2819
3384
|
else:
|
|
2820
|
-
|
|
2821
3385
|
def _is_unionable(obj):
|
|
2822
3386
|
"""Corresponds to is_unionable() in unionobject.c in CPython."""
|
|
2823
|
-
return obj is None or isinstance(
|
|
2824
|
-
|
|
2825
|
-
|
|
2826
|
-
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
TypeAliasType,
|
|
2830
|
-
),
|
|
2831
|
-
)
|
|
3387
|
+
return obj is None or isinstance(obj, (
|
|
3388
|
+
type,
|
|
3389
|
+
_types.GenericAlias,
|
|
3390
|
+
_types.UnionType,
|
|
3391
|
+
TypeAliasType,
|
|
3392
|
+
))
|
|
2832
3393
|
|
|
2833
3394
|
class TypeAliasType:
|
|
2834
3395
|
"""Create named, parameterized type aliases.
|
|
@@ -2872,7 +3433,7 @@ else:
|
|
|
2872
3433
|
parameters.append(type_param)
|
|
2873
3434
|
self.__parameters__ = tuple(parameters)
|
|
2874
3435
|
def_mod = _caller()
|
|
2875
|
-
if def_mod !=
|
|
3436
|
+
if def_mod != 'typing_extensions':
|
|
2876
3437
|
self.__module__ = def_mod
|
|
2877
3438
|
# Setting this attribute closes the TypeAliasType from further modification
|
|
2878
3439
|
self.__name__ = name
|
|
@@ -2889,12 +3450,7 @@ else:
|
|
|
2889
3450
|
# Match the Python 3.12 error messages exactly
|
|
2890
3451
|
if name == "__name__":
|
|
2891
3452
|
raise AttributeError("readonly attribute")
|
|
2892
|
-
elif name in {
|
|
2893
|
-
"__value__",
|
|
2894
|
-
"__type_params__",
|
|
2895
|
-
"__parameters__",
|
|
2896
|
-
"__module__",
|
|
2897
|
-
}:
|
|
3453
|
+
elif name in {"__value__", "__type_params__", "__parameters__", "__module__"}:
|
|
2898
3454
|
raise AttributeError(
|
|
2899
3455
|
f"attribute '{name}' of 'typing.TypeAliasType' objects "
|
|
2900
3456
|
"is not writable"
|
|
@@ -2912,7 +3468,7 @@ else:
|
|
|
2912
3468
|
parameters = (parameters,)
|
|
2913
3469
|
parameters = [
|
|
2914
3470
|
typing._type_check(
|
|
2915
|
-
item, f
|
|
3471
|
+
item, f'Subscripting {self.__name__} requires a type.'
|
|
2916
3472
|
)
|
|
2917
3473
|
for item in parameters
|
|
2918
3474
|
]
|
|
@@ -2932,7 +3488,6 @@ else:
|
|
|
2932
3488
|
raise TypeError("Type alias is not callable")
|
|
2933
3489
|
|
|
2934
3490
|
if sys.version_info >= (3, 10):
|
|
2935
|
-
|
|
2936
3491
|
def __or__(self, right):
|
|
2937
3492
|
# For forward compatibility with 3.12, reject Unions
|
|
2938
3493
|
# that are not accepted by the built-in Union.
|
|
@@ -2950,13 +3505,12 @@ if hasattr(typing, "is_protocol"):
|
|
|
2950
3505
|
is_protocol = typing.is_protocol
|
|
2951
3506
|
get_protocol_members = typing.get_protocol_members
|
|
2952
3507
|
else:
|
|
2953
|
-
|
|
2954
3508
|
def is_protocol(tp: type, /) -> bool:
|
|
2955
3509
|
"""Return True if the given type is a Protocol.
|
|
2956
3510
|
|
|
2957
3511
|
Example::
|
|
2958
3512
|
|
|
2959
|
-
>>> from
|
|
3513
|
+
>>> from typing_extensions import Protocol, is_protocol
|
|
2960
3514
|
>>> class P(Protocol):
|
|
2961
3515
|
... def a(self) -> str: ...
|
|
2962
3516
|
... b: int
|
|
@@ -2967,7 +3521,7 @@ else:
|
|
|
2967
3521
|
"""
|
|
2968
3522
|
return (
|
|
2969
3523
|
isinstance(tp, type)
|
|
2970
|
-
and getattr(tp,
|
|
3524
|
+
and getattr(tp, '_is_protocol', False)
|
|
2971
3525
|
and tp is not Protocol
|
|
2972
3526
|
and tp is not typing.Protocol
|
|
2973
3527
|
)
|
|
@@ -2977,7 +3531,7 @@ else:
|
|
|
2977
3531
|
|
|
2978
3532
|
Example::
|
|
2979
3533
|
|
|
2980
|
-
>>> from
|
|
3534
|
+
>>> from typing_extensions import Protocol, get_protocol_members
|
|
2981
3535
|
>>> class P(Protocol):
|
|
2982
3536
|
... def a(self) -> str: ...
|
|
2983
3537
|
... b: int
|
|
@@ -2987,8 +3541,8 @@ else:
|
|
|
2987
3541
|
Raise a TypeError for arguments that are not Protocols.
|
|
2988
3542
|
"""
|
|
2989
3543
|
if not is_protocol(tp):
|
|
2990
|
-
raise TypeError(f
|
|
2991
|
-
if hasattr(tp,
|
|
3544
|
+
raise TypeError(f'{tp!r} is not a Protocol')
|
|
3545
|
+
if hasattr(tp, '__protocol_attrs__'):
|
|
2992
3546
|
return frozenset(tp.__protocol_attrs__)
|
|
2993
3547
|
return frozenset(_get_protocol_attrs(tp))
|
|
2994
3548
|
|
|
@@ -2996,7 +3550,6 @@ else:
|
|
|
2996
3550
|
if hasattr(typing, "Doc"):
|
|
2997
3551
|
Doc = typing.Doc
|
|
2998
3552
|
else:
|
|
2999
|
-
|
|
3000
3553
|
class Doc:
|
|
3001
3554
|
"""Define the documentation of a type annotation using ``Annotated``, to be
|
|
3002
3555
|
used in class attributes, function and method parameters, return values,
|
|
@@ -3011,10 +3564,9 @@ else:
|
|
|
3011
3564
|
|
|
3012
3565
|
Example::
|
|
3013
3566
|
|
|
3014
|
-
>>> from
|
|
3567
|
+
>>> from typing_extensions import Annotated, Doc
|
|
3015
3568
|
>>> def hi(to: Annotated[str, Doc("Who to say hi to")]) -> None: ...
|
|
3016
3569
|
"""
|
|
3017
|
-
|
|
3018
3570
|
def __init__(self, documentation: str, /) -> None:
|
|
3019
3571
|
self.documentation = documentation
|
|
3020
3572
|
|
|
@@ -3030,6 +3582,23 @@ else:
|
|
|
3030
3582
|
return self.documentation == other.documentation
|
|
3031
3583
|
|
|
3032
3584
|
|
|
3585
|
+
_CapsuleType = getattr(_types, "CapsuleType", None)
|
|
3586
|
+
|
|
3587
|
+
if _CapsuleType is None:
|
|
3588
|
+
try:
|
|
3589
|
+
import _socket
|
|
3590
|
+
except ImportError:
|
|
3591
|
+
pass
|
|
3592
|
+
else:
|
|
3593
|
+
_CAPI = getattr(_socket, "CAPI", None)
|
|
3594
|
+
if _CAPI is not None:
|
|
3595
|
+
_CapsuleType = type(_CAPI)
|
|
3596
|
+
|
|
3597
|
+
if _CapsuleType is not None:
|
|
3598
|
+
CapsuleType = _CapsuleType
|
|
3599
|
+
__all__.append("CapsuleType")
|
|
3600
|
+
|
|
3601
|
+
|
|
3033
3602
|
# Aliases for items that have always been in typing.
|
|
3034
3603
|
# Explicitly assign these (rather than using `from typing import *` at the top),
|
|
3035
3604
|
# so that we get a CI error if one of these is deleted from typing.py
|
|
@@ -3043,7 +3612,6 @@ Container = typing.Container
|
|
|
3043
3612
|
Dict = typing.Dict
|
|
3044
3613
|
ForwardRef = typing.ForwardRef
|
|
3045
3614
|
FrozenSet = typing.FrozenSet
|
|
3046
|
-
Generator = typing.Generator
|
|
3047
3615
|
Generic = typing.Generic
|
|
3048
3616
|
Hashable = typing.Hashable
|
|
3049
3617
|
IO = typing.IO
|