jaclang 0.6.0__py3-none-any.whl → 0.6.5__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 +115 -7
- jaclang/cli/cmdreg.py +18 -6
- jaclang/compiler/.gitignore +1 -0
- jaclang/compiler/__init__.py +1 -0
- jaclang/compiler/absyntree.py +8 -9
- jaclang/compiler/compile.py +4 -4
- jaclang/compiler/jac.lark +1 -0
- jaclang/compiler/parser.py +16 -3
- jaclang/compiler/passes/main/def_impl_match_pass.py +8 -1
- jaclang/compiler/passes/main/fuse_typeinfo_pass.py +20 -8
- jaclang/compiler/passes/main/import_pass.py +78 -47
- jaclang/compiler/passes/main/pyast_gen_pass.py +6 -57
- jaclang/compiler/passes/main/pyast_load_pass.py +33 -6
- jaclang/compiler/passes/main/pyjac_ast_link_pass.py +218 -0
- jaclang/compiler/passes/main/schedules.py +2 -0
- jaclang/compiler/passes/main/sym_tab_build_pass.py +9 -3
- 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_import_pass.py +11 -0
- jaclang/compiler/passes/main/tests/test_type_check_pass.py +15 -0
- 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/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 +1 -0
- jaclang/compiler/tests/fixtures/staticcheck.jac +20 -0
- jaclang/compiler/tests/fixtures/stuff.jac +6 -0
- jaclang/core/aott.py +10 -1
- jaclang/core/construct.py +157 -21
- jaclang/core/importer.py +6 -2
- jaclang/core/memory.py +48 -0
- jaclang/core/shelve_storage.py +55 -0
- jaclang/langserve/__init__.py +1 -0
- jaclang/langserve/server.py +108 -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 +53 -0
- jaclang/plugin/__init__.py +1 -2
- jaclang/plugin/builtin.py +1 -1
- jaclang/plugin/default.py +97 -4
- jaclang/plugin/feature.py +28 -9
- jaclang/plugin/spec.py +45 -10
- 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/plugin/tests/test_jaseci.py +219 -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 +17 -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.6.5.dist-info/METADATA +106 -0
- jaclang-0.6.5.dist-info/RECORD +1476 -0
- jaclang-0.6.5.dist-info/WHEEL +4 -0
- jaclang-0.6.5.dist-info/entry_points.txt +3 -0
- jaclang/compiler/generated/jac_parser.py +0 -4069
- jaclang-0.6.0.dist-info/METADATA +0 -17
- jaclang-0.6.0.dist-info/RECORD +0 -426
- jaclang-0.6.0.dist-info/entry_points.txt +0 -2
- jaclang-0.6.0.dist-info/top_level.txt +0 -1
- /jaclang/{compiler/generated/__init__.py → vendor/attr/py.typed} +0 -0
- {jaclang-0.6.0.dist-info → jaclang/vendor/pluggy-1.5.0.dist-info}/WHEEL +0 -0
jaclang/vendor/mypy/checker.py
CHANGED
|
@@ -4,7 +4,7 @@ from __future__ import annotations
|
|
|
4
4
|
|
|
5
5
|
import itertools
|
|
6
6
|
from collections import defaultdict
|
|
7
|
-
from contextlib import
|
|
7
|
+
from contextlib import ExitStack, contextmanager
|
|
8
8
|
from typing import (
|
|
9
9
|
AbstractSet,
|
|
10
10
|
Callable,
|
|
@@ -157,11 +157,7 @@ from mypy.subtypes import (
|
|
|
157
157
|
)
|
|
158
158
|
from mypy.traverser import TraverserVisitor, all_return_statements, has_return_statement
|
|
159
159
|
from mypy.treetransform import TransformVisitor
|
|
160
|
-
from mypy.typeanal import
|
|
161
|
-
check_for_explicit_any,
|
|
162
|
-
has_any_from_unimported_type,
|
|
163
|
-
make_optional_type,
|
|
164
|
-
)
|
|
160
|
+
from mypy.typeanal import check_for_explicit_any, has_any_from_unimported_type, make_optional_type
|
|
165
161
|
from mypy.typeops import (
|
|
166
162
|
bind_self,
|
|
167
163
|
coerce_to_literal,
|
|
@@ -223,12 +219,7 @@ from mypy.types import (
|
|
|
223
219
|
is_literal_type,
|
|
224
220
|
is_named_instance,
|
|
225
221
|
)
|
|
226
|
-
from mypy.types_utils import
|
|
227
|
-
is_overlapping_none,
|
|
228
|
-
remove_optional,
|
|
229
|
-
store_argument_type,
|
|
230
|
-
strip_type,
|
|
231
|
-
)
|
|
222
|
+
from mypy.types_utils import is_overlapping_none, remove_optional, store_argument_type, strip_type
|
|
232
223
|
from mypy.typetraverser import TypeTraverserVisitor
|
|
233
224
|
from mypy.typevars import fill_typevars, fill_typevars_with_any, has_no_typevars
|
|
234
225
|
from mypy.util import is_dunder, is_sunder
|
|
@@ -503,10 +494,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
503
494
|
seq_str, all_.type, options=self.options
|
|
504
495
|
)
|
|
505
496
|
self.fail(
|
|
506
|
-
message_registry.ALL_MUST_BE_SEQ_STR.format(
|
|
507
|
-
str_seq_s, all_s
|
|
508
|
-
),
|
|
509
|
-
all_node,
|
|
497
|
+
message_registry.ALL_MUST_BE_SEQ_STR.format(str_seq_s, all_s), all_node
|
|
510
498
|
)
|
|
511
499
|
|
|
512
500
|
def check_second_pass(
|
|
@@ -538,22 +526,14 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
538
526
|
# print("XXX in pass %d, class %s, function %s" %
|
|
539
527
|
# (self.pass_num, type_name, node.fullname or node.name))
|
|
540
528
|
done.add(node)
|
|
541
|
-
with (
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
with (
|
|
547
|
-
self.scope.push_class(active_typeinfo)
|
|
548
|
-
if active_typeinfo
|
|
549
|
-
else nullcontext()
|
|
550
|
-
):
|
|
551
|
-
self.check_partial(node)
|
|
529
|
+
with ExitStack() as stack:
|
|
530
|
+
if active_typeinfo:
|
|
531
|
+
stack.enter_context(self.tscope.class_scope(active_typeinfo))
|
|
532
|
+
stack.enter_context(self.scope.push_class(active_typeinfo))
|
|
533
|
+
self.check_partial(node)
|
|
552
534
|
return True
|
|
553
535
|
|
|
554
|
-
def check_partial(
|
|
555
|
-
self, node: DeferredNodeType | FineGrainedDeferredNodeType
|
|
556
|
-
) -> None:
|
|
536
|
+
def check_partial(self, node: DeferredNodeType | FineGrainedDeferredNodeType) -> None:
|
|
557
537
|
if isinstance(node, MypyFile):
|
|
558
538
|
self.check_top_level(node)
|
|
559
539
|
else:
|
|
@@ -574,9 +554,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
574
554
|
assert not self.current_node_deferred
|
|
575
555
|
# TODO: Handle __all__
|
|
576
556
|
|
|
577
|
-
def defer_node(
|
|
578
|
-
self, node: DeferredNodeType, enclosing_class: TypeInfo | None
|
|
579
|
-
) -> None:
|
|
557
|
+
def defer_node(self, node: DeferredNodeType, enclosing_class: TypeInfo | None) -> None:
|
|
580
558
|
"""Defer a node for processing during next type-checking pass.
|
|
581
559
|
|
|
582
560
|
Args:
|
|
@@ -610,9 +588,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
610
588
|
try:
|
|
611
589
|
stmt.accept(self)
|
|
612
590
|
except Exception as err:
|
|
613
|
-
report_internal_error(
|
|
614
|
-
err, self.errors.file, stmt.line, self.errors, self.options
|
|
615
|
-
)
|
|
591
|
+
report_internal_error(err, self.errors.file, stmt.line, self.errors, self.options)
|
|
616
592
|
|
|
617
593
|
def accept_loop(
|
|
618
594
|
self,
|
|
@@ -629,9 +605,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
629
605
|
# The outer frame accumulates the results of all iterations
|
|
630
606
|
with self.binder.frame_context(can_skip=False, conditional_frame=True):
|
|
631
607
|
while True:
|
|
632
|
-
with self.binder.frame_context(
|
|
633
|
-
can_skip=True, break_frame=2, continue_frame=1
|
|
634
|
-
):
|
|
608
|
+
with self.binder.frame_context(can_skip=True, break_frame=2, continue_frame=1):
|
|
635
609
|
self.accept(body)
|
|
636
610
|
if not self.binder.last_pop_changed:
|
|
637
611
|
break
|
|
@@ -698,14 +672,10 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
698
672
|
and found_method_base_classes is not None
|
|
699
673
|
):
|
|
700
674
|
self.msg.no_overridable_method(defn.name, defn)
|
|
701
|
-
self.check_explicit_override_decorator(
|
|
702
|
-
defn, found_method_base_classes, defn.impl
|
|
703
|
-
)
|
|
675
|
+
self.check_explicit_override_decorator(defn, found_method_base_classes, defn.impl)
|
|
704
676
|
self.check_inplace_operator_method(defn)
|
|
705
677
|
|
|
706
|
-
def extract_callable_type(
|
|
707
|
-
self, inner_type: Type | None, ctx: Context
|
|
708
|
-
) -> CallableType | None:
|
|
678
|
+
def extract_callable_type(self, inner_type: Type | None, ctx: Context) -> CallableType | None:
|
|
709
679
|
"""Get type as seen by an overload item caller."""
|
|
710
680
|
inner_type = get_proper_type(inner_type)
|
|
711
681
|
outer_type: CallableType | None = None
|
|
@@ -776,9 +746,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
776
746
|
continue
|
|
777
747
|
|
|
778
748
|
if overload_can_never_match(sig1, sig2):
|
|
779
|
-
self.msg.overloaded_signature_will_never_match(
|
|
780
|
-
i + 1, i + j + 2, item2.func
|
|
781
|
-
)
|
|
749
|
+
self.msg.overloaded_signature_will_never_match(i + 1, i + j + 2, item2.func)
|
|
782
750
|
elif not is_descriptor_get:
|
|
783
751
|
# Note: we force mypy to check overload signatures in strict-optional mode
|
|
784
752
|
# so we don't incorrectly report errors when a user tries typing an overload
|
|
@@ -796,12 +764,8 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
796
764
|
current_class = self.scope.active_class()
|
|
797
765
|
type_vars = current_class.defn.type_vars if current_class else []
|
|
798
766
|
with state.strict_optional_set(True):
|
|
799
|
-
if is_unsafe_overlapping_overload_signatures(
|
|
800
|
-
|
|
801
|
-
):
|
|
802
|
-
self.msg.overloaded_signatures_overlap(
|
|
803
|
-
i + 1, i + j + 2, item.func
|
|
804
|
-
)
|
|
767
|
+
if is_unsafe_overlapping_overload_signatures(sig1, sig2, type_vars):
|
|
768
|
+
self.msg.overloaded_signatures_overlap(i + 1, i + j + 2, item.func)
|
|
805
769
|
|
|
806
770
|
if impl_type is not None:
|
|
807
771
|
assert defn.impl is not None
|
|
@@ -823,9 +787,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
823
787
|
return_constraint_direction=SUPERTYPE_OF,
|
|
824
788
|
)
|
|
825
789
|
if impl is None:
|
|
826
|
-
self.msg.overloaded_signatures_typevar_specific(
|
|
827
|
-
i + 1, defn.impl
|
|
828
|
-
)
|
|
790
|
+
self.msg.overloaded_signatures_typevar_specific(i + 1, defn.impl)
|
|
829
791
|
continue
|
|
830
792
|
else:
|
|
831
793
|
impl = impl_type
|
|
@@ -833,17 +795,11 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
833
795
|
# Prevent extra noise from inconsistent use of @classmethod by copying
|
|
834
796
|
# the first arg from the method being checked against.
|
|
835
797
|
if sig1.arg_types and defn.info:
|
|
836
|
-
impl = impl.copy_modified(
|
|
837
|
-
arg_types=[sig1.arg_types[0]] + impl.arg_types[1:]
|
|
838
|
-
)
|
|
798
|
+
impl = impl.copy_modified(arg_types=[sig1.arg_types[0]] + impl.arg_types[1:])
|
|
839
799
|
|
|
840
800
|
# Is the overload alternative's arguments subtypes of the implementation's?
|
|
841
801
|
if not is_callable_compatible(
|
|
842
|
-
impl,
|
|
843
|
-
sig1,
|
|
844
|
-
is_compat=is_subtype,
|
|
845
|
-
is_proper_subtype=False,
|
|
846
|
-
ignore_return=True,
|
|
802
|
+
impl, sig1, is_compat=is_subtype, is_proper_subtype=False, ignore_return=True
|
|
847
803
|
):
|
|
848
804
|
self.msg.overloaded_signatures_arg_specific(i + 1, defn.impl)
|
|
849
805
|
|
|
@@ -906,22 +862,15 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
906
862
|
typ = get_proper_type(typ)
|
|
907
863
|
if is_coroutine:
|
|
908
864
|
# This means we're in Python 3.5 or later.
|
|
909
|
-
at = self.named_generic_type(
|
|
910
|
-
"typing.Awaitable", [AnyType(TypeOfAny.special_form)]
|
|
911
|
-
)
|
|
865
|
+
at = self.named_generic_type("typing.Awaitable", [AnyType(TypeOfAny.special_form)])
|
|
912
866
|
if is_subtype(at, typ):
|
|
913
867
|
return True
|
|
914
868
|
else:
|
|
915
869
|
any_type = AnyType(TypeOfAny.special_form)
|
|
916
|
-
gt = self.named_generic_type(
|
|
917
|
-
"typing.Generator", [any_type, any_type, any_type]
|
|
918
|
-
)
|
|
870
|
+
gt = self.named_generic_type("typing.Generator", [any_type, any_type, any_type])
|
|
919
871
|
if is_subtype(gt, typ):
|
|
920
872
|
return True
|
|
921
|
-
return (
|
|
922
|
-
isinstance(typ, Instance)
|
|
923
|
-
and typ.type.fullname == "typing.AwaitableGenerator"
|
|
924
|
-
)
|
|
873
|
+
return isinstance(typ, Instance) and typ.type.fullname == "typing.AwaitableGenerator"
|
|
925
874
|
|
|
926
875
|
def is_async_generator_return_type(self, typ: Type) -> bool:
|
|
927
876
|
"""Is `typ` a valid type for an async generator?
|
|
@@ -944,10 +893,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
944
893
|
return AnyType(TypeOfAny.from_another_any, source_any=return_type)
|
|
945
894
|
elif isinstance(return_type, UnionType):
|
|
946
895
|
return make_simplified_union(
|
|
947
|
-
[
|
|
948
|
-
self.get_generator_yield_type(item, is_coroutine)
|
|
949
|
-
for item in return_type.items
|
|
950
|
-
]
|
|
896
|
+
[self.get_generator_yield_type(item, is_coroutine) for item in return_type.items]
|
|
951
897
|
)
|
|
952
898
|
elif not self.is_generator_return_type(
|
|
953
899
|
return_type, is_coroutine
|
|
@@ -981,10 +927,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
981
927
|
return AnyType(TypeOfAny.from_another_any, source_any=return_type)
|
|
982
928
|
elif isinstance(return_type, UnionType):
|
|
983
929
|
return make_simplified_union(
|
|
984
|
-
[
|
|
985
|
-
self.get_generator_receive_type(item, is_coroutine)
|
|
986
|
-
for item in return_type.items
|
|
987
|
-
]
|
|
930
|
+
[self.get_generator_receive_type(item, is_coroutine) for item in return_type.items]
|
|
988
931
|
)
|
|
989
932
|
elif not self.is_generator_return_type(
|
|
990
933
|
return_type, is_coroutine
|
|
@@ -999,16 +942,12 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
999
942
|
# Awaitable, AwaitableGenerator: tc is Any.
|
|
1000
943
|
return AnyType(TypeOfAny.special_form)
|
|
1001
944
|
elif (
|
|
1002
|
-
return_type.type.fullname
|
|
1003
|
-
in ("typing.Generator", "typing.AwaitableGenerator")
|
|
945
|
+
return_type.type.fullname in ("typing.Generator", "typing.AwaitableGenerator")
|
|
1004
946
|
and len(return_type.args) >= 3
|
|
1005
947
|
):
|
|
1006
948
|
# Generator: tc is args[1].
|
|
1007
949
|
return return_type.args[1]
|
|
1008
|
-
elif (
|
|
1009
|
-
return_type.type.fullname == "typing.AsyncGenerator"
|
|
1010
|
-
and len(return_type.args) >= 2
|
|
1011
|
-
):
|
|
950
|
+
elif return_type.type.fullname == "typing.AsyncGenerator" and len(return_type.args) >= 2:
|
|
1012
951
|
return return_type.args[1]
|
|
1013
952
|
else:
|
|
1014
953
|
# `return_type` is a supertype of Generator, so callers won't be able to send it
|
|
@@ -1019,9 +958,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
1019
958
|
return_type = get_proper_type(return_type)
|
|
1020
959
|
if isinstance(return_type, AnyType):
|
|
1021
960
|
return AnyType(TypeOfAny.from_another_any, source_any=return_type)
|
|
1022
|
-
assert isinstance(
|
|
1023
|
-
return_type, Instance
|
|
1024
|
-
), "Should only be called on coroutine functions."
|
|
961
|
+
assert isinstance(return_type, Instance), "Should only be called on coroutine functions."
|
|
1025
962
|
# Note: return type is the 3rd type parameter of Coroutine.
|
|
1026
963
|
return return_type.args[2]
|
|
1027
964
|
|
|
@@ -1033,10 +970,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
1033
970
|
return AnyType(TypeOfAny.from_another_any, source_any=return_type)
|
|
1034
971
|
elif isinstance(return_type, UnionType):
|
|
1035
972
|
return make_simplified_union(
|
|
1036
|
-
[
|
|
1037
|
-
self.get_generator_return_type(item, is_coroutine)
|
|
1038
|
-
for item in return_type.items
|
|
1039
|
-
]
|
|
973
|
+
[self.get_generator_return_type(item, is_coroutine) for item in return_type.items]
|
|
1040
974
|
)
|
|
1041
975
|
elif not self.is_generator_return_type(return_type, is_coroutine):
|
|
1042
976
|
# If the function doesn't have a proper Generator (or
|
|
@@ -1045,22 +979,19 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
1045
979
|
elif not isinstance(return_type, Instance):
|
|
1046
980
|
# Same as above, but written as a separate branch so the typechecker can understand.
|
|
1047
981
|
return AnyType(TypeOfAny.from_error)
|
|
1048
|
-
elif (
|
|
1049
|
-
return_type.type.fullname == "typing.Awaitable"
|
|
1050
|
-
and len(return_type.args) == 1
|
|
1051
|
-
):
|
|
982
|
+
elif return_type.type.fullname == "typing.Awaitable" and len(return_type.args) == 1:
|
|
1052
983
|
# Awaitable: tr is args[0].
|
|
1053
984
|
return return_type.args[0]
|
|
1054
985
|
elif (
|
|
1055
|
-
return_type.type.fullname
|
|
1056
|
-
in ("typing.Generator", "typing.AwaitableGenerator")
|
|
986
|
+
return_type.type.fullname in ("typing.Generator", "typing.AwaitableGenerator")
|
|
1057
987
|
and len(return_type.args) >= 3
|
|
1058
988
|
):
|
|
1059
989
|
# AwaitableGenerator, Generator: tr is args[2].
|
|
1060
990
|
return return_type.args[2]
|
|
1061
991
|
else:
|
|
1062
|
-
#
|
|
1063
|
-
|
|
992
|
+
# We have a supertype of Generator (Iterator, Iterable, object)
|
|
993
|
+
# Treat `Iterator[X]` as a shorthand for `Generator[X, Any, None]`.
|
|
994
|
+
return NoneType()
|
|
1064
995
|
|
|
1065
996
|
def visit_func_def(self, defn: FuncDef) -> None:
|
|
1066
997
|
if not self.recurse_into_functions:
|
|
@@ -1087,9 +1018,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
1087
1018
|
# Function definition overrides function definition.
|
|
1088
1019
|
old_type = self.function_type(defn.original_def)
|
|
1089
1020
|
if not is_same_type(new_type, old_type):
|
|
1090
|
-
self.msg.incompatible_conditional_function_def(
|
|
1091
|
-
defn, old_type, new_type
|
|
1092
|
-
)
|
|
1021
|
+
self.msg.incompatible_conditional_function_def(defn, old_type, new_type)
|
|
1093
1022
|
else:
|
|
1094
1023
|
# Function definition overrides a variable initialized via assignment or a
|
|
1095
1024
|
# decorated function.
|
|
@@ -1168,11 +1097,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
1168
1097
|
self.inferred_attribute_types = old_types
|
|
1169
1098
|
|
|
1170
1099
|
def check_func_def(
|
|
1171
|
-
self,
|
|
1172
|
-
defn: FuncItem,
|
|
1173
|
-
typ: CallableType,
|
|
1174
|
-
name: str | None,
|
|
1175
|
-
allow_empty: bool = False,
|
|
1100
|
+
self, defn: FuncItem, typ: CallableType, name: str | None, allow_empty: bool = False
|
|
1176
1101
|
) -> None:
|
|
1177
1102
|
"""Type check a function definition."""
|
|
1178
1103
|
# Expand type variables with value restrictions to ordinary types.
|
|
@@ -1199,10 +1124,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
1199
1124
|
and not self.dynamic_funcs[-1]
|
|
1200
1125
|
):
|
|
1201
1126
|
self.fail(
|
|
1202
|
-
message_registry.MUST_HAVE_NONE_RETURN_TYPE.format(
|
|
1203
|
-
fdef.name
|
|
1204
|
-
),
|
|
1205
|
-
item,
|
|
1127
|
+
message_registry.MUST_HAVE_NONE_RETURN_TYPE.format(fdef.name), item
|
|
1206
1128
|
)
|
|
1207
1129
|
|
|
1208
1130
|
# Check validity of __new__ signature
|
|
@@ -1214,21 +1136,13 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
1214
1136
|
if fdef.type and isinstance(fdef.type, CallableType):
|
|
1215
1137
|
ret_type = fdef.type.ret_type
|
|
1216
1138
|
if has_any_from_unimported_type(ret_type):
|
|
1217
|
-
self.msg.unimported_type_becomes_any(
|
|
1218
|
-
"Return type", ret_type, fdef
|
|
1219
|
-
)
|
|
1139
|
+
self.msg.unimported_type_becomes_any("Return type", ret_type, fdef)
|
|
1220
1140
|
for idx, arg_type in enumerate(fdef.type.arg_types):
|
|
1221
1141
|
if has_any_from_unimported_type(arg_type):
|
|
1222
1142
|
prefix = f'Argument {idx + 1} to "{fdef.name}"'
|
|
1223
|
-
self.msg.unimported_type_becomes_any(
|
|
1224
|
-
prefix, arg_type, fdef
|
|
1225
|
-
)
|
|
1143
|
+
self.msg.unimported_type_becomes_any(prefix, arg_type, fdef)
|
|
1226
1144
|
check_for_explicit_any(
|
|
1227
|
-
fdef.type,
|
|
1228
|
-
self.options,
|
|
1229
|
-
self.is_typeshed_stub,
|
|
1230
|
-
self.msg,
|
|
1231
|
-
context=fdef,
|
|
1145
|
+
fdef.type, self.options, self.is_typeshed_stub, self.msg, context=fdef
|
|
1232
1146
|
)
|
|
1233
1147
|
|
|
1234
1148
|
if name: # Special method names
|
|
@@ -1243,13 +1157,11 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
1243
1157
|
if isinstance(typ.ret_type, TypeVarType):
|
|
1244
1158
|
if typ.ret_type.variance == CONTRAVARIANT:
|
|
1245
1159
|
self.fail(
|
|
1246
|
-
message_registry.RETURN_TYPE_CANNOT_BE_CONTRAVARIANT,
|
|
1247
|
-
typ.ret_type,
|
|
1160
|
+
message_registry.RETURN_TYPE_CANNOT_BE_CONTRAVARIANT, typ.ret_type
|
|
1248
1161
|
)
|
|
1249
1162
|
self.check_unbound_return_typevar(typ)
|
|
1250
1163
|
elif (
|
|
1251
|
-
isinstance(original_typ.ret_type, TypeVarType)
|
|
1252
|
-
and original_typ.ret_type.values
|
|
1164
|
+
isinstance(original_typ.ret_type, TypeVarType) and original_typ.ret_type.values
|
|
1253
1165
|
):
|
|
1254
1166
|
# Since type vars with values are expanded, the return type is changed
|
|
1255
1167
|
# to a raw value. This is a hack to get it back.
|
|
@@ -1260,16 +1172,11 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
1260
1172
|
if defn.is_async_generator:
|
|
1261
1173
|
if not self.is_async_generator_return_type(typ.ret_type):
|
|
1262
1174
|
self.fail(
|
|
1263
|
-
message_registry.INVALID_RETURN_TYPE_FOR_ASYNC_GENERATOR,
|
|
1264
|
-
typ,
|
|
1175
|
+
message_registry.INVALID_RETURN_TYPE_FOR_ASYNC_GENERATOR, typ
|
|
1265
1176
|
)
|
|
1266
1177
|
else:
|
|
1267
|
-
if not self.is_generator_return_type(
|
|
1268
|
-
|
|
1269
|
-
):
|
|
1270
|
-
self.fail(
|
|
1271
|
-
message_registry.INVALID_RETURN_TYPE_FOR_GENERATOR, typ
|
|
1272
|
-
)
|
|
1178
|
+
if not self.is_generator_return_type(typ.ret_type, defn.is_coroutine):
|
|
1179
|
+
self.fail(message_registry.INVALID_RETURN_TYPE_FOR_GENERATOR, typ)
|
|
1273
1180
|
|
|
1274
1181
|
# Fix the type if decorated with `@types.coroutine` or `@asyncio.coroutine`.
|
|
1275
1182
|
if defn.is_awaitable_coroutine:
|
|
@@ -1297,6 +1204,22 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
1297
1204
|
# visible from *inside* of this function/method.
|
|
1298
1205
|
ref_type: Type | None = self.scope.active_self_type()
|
|
1299
1206
|
|
|
1207
|
+
if typ.type_is:
|
|
1208
|
+
arg_index = 0
|
|
1209
|
+
# For methods and classmethods, we want the second parameter
|
|
1210
|
+
if ref_type is not None and (not defn.is_static or defn.name == "__new__"):
|
|
1211
|
+
arg_index = 1
|
|
1212
|
+
if arg_index < len(typ.arg_types) and not is_subtype(
|
|
1213
|
+
typ.type_is, typ.arg_types[arg_index]
|
|
1214
|
+
):
|
|
1215
|
+
self.fail(
|
|
1216
|
+
message_registry.NARROWED_TYPE_NOT_SUBTYPE.format(
|
|
1217
|
+
format_type(typ.type_is, self.options),
|
|
1218
|
+
format_type(typ.arg_types[arg_index], self.options),
|
|
1219
|
+
),
|
|
1220
|
+
item,
|
|
1221
|
+
)
|
|
1222
|
+
|
|
1300
1223
|
# Store argument types.
|
|
1301
1224
|
for i in range(len(typ.arg_types)):
|
|
1302
1225
|
arg_type = typ.arg_types[i]
|
|
@@ -1312,12 +1235,8 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
1312
1235
|
if not is_same_type(arg_type, ref_type):
|
|
1313
1236
|
# This level of erasure matches the one in checkmember.check_self_arg(),
|
|
1314
1237
|
# better keep these two checks consistent.
|
|
1315
|
-
erased = get_proper_type(
|
|
1316
|
-
|
|
1317
|
-
)
|
|
1318
|
-
if not is_subtype(
|
|
1319
|
-
ref_type, erased, ignore_type_params=True
|
|
1320
|
-
):
|
|
1238
|
+
erased = get_proper_type(erase_typevars(erase_to_bound(arg_type)))
|
|
1239
|
+
if not is_subtype(ref_type, erased, ignore_type_params=True):
|
|
1321
1240
|
if (
|
|
1322
1241
|
isinstance(erased, Instance)
|
|
1323
1242
|
and erased.type.is_protocol
|
|
@@ -1343,19 +1262,13 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
1343
1262
|
# TODO: check recursively for inner type variables
|
|
1344
1263
|
if (
|
|
1345
1264
|
arg_type.variance == COVARIANT
|
|
1346
|
-
and defn.name
|
|
1347
|
-
not
|
|
1348
|
-
and not is_private(
|
|
1349
|
-
defn.name
|
|
1350
|
-
) # private methods are not inherited
|
|
1265
|
+
and defn.name not in ("__init__", "__new__", "__post_init__")
|
|
1266
|
+
and not is_private(defn.name) # private methods are not inherited
|
|
1351
1267
|
):
|
|
1352
1268
|
ctx: Context = arg_type
|
|
1353
1269
|
if ctx.line < 0:
|
|
1354
1270
|
ctx = typ
|
|
1355
|
-
self.fail(
|
|
1356
|
-
message_registry.FUNCTION_PARAMETER_CANNOT_BE_COVARIANT,
|
|
1357
|
-
ctx,
|
|
1358
|
-
)
|
|
1271
|
+
self.fail(message_registry.FUNCTION_PARAMETER_CANNOT_BE_COVARIANT, ctx)
|
|
1359
1272
|
# Need to store arguments again for the expanded item.
|
|
1360
1273
|
store_argument_type(item, i, typ, self.named_generic_type)
|
|
1361
1274
|
|
|
@@ -1372,11 +1285,8 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
1372
1285
|
for frame in old_binder.frames:
|
|
1373
1286
|
for key, narrowed_type in frame.types.items():
|
|
1374
1287
|
key_var = extract_var_from_literal_hash(key)
|
|
1375
|
-
if (
|
|
1376
|
-
key_var
|
|
1377
|
-
and not self.is_var_redefined_in_outer_context(
|
|
1378
|
-
key_var, defn.line
|
|
1379
|
-
)
|
|
1288
|
+
if key_var is not None and not self.is_var_redefined_in_outer_context(
|
|
1289
|
+
key_var, defn.line
|
|
1380
1290
|
):
|
|
1381
1291
|
# It seems safe to propagate the type narrowing to a nested scope.
|
|
1382
1292
|
if new_frame is None:
|
|
@@ -1423,8 +1333,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
1423
1333
|
(
|
|
1424
1334
|
not allow_empty
|
|
1425
1335
|
and not (
|
|
1426
|
-
isinstance(defn, FuncDef)
|
|
1427
|
-
and defn.abstract_status != NOT_ABSTRACT
|
|
1336
|
+
isinstance(defn, FuncDef) and defn.abstract_status != NOT_ABSTRACT
|
|
1428
1337
|
)
|
|
1429
1338
|
and not self.is_stub
|
|
1430
1339
|
)
|
|
@@ -1432,8 +1341,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
1432
1341
|
|
|
1433
1342
|
# Ignore plugin generated methods, these usually don't need any bodies.
|
|
1434
1343
|
if defn.info is not FUNC_NO_INFO and (
|
|
1435
|
-
defn.name not in defn.info.names
|
|
1436
|
-
or defn.info.names[defn.name].plugin_generated
|
|
1344
|
+
defn.name not in defn.info.names or defn.info.names[defn.name].plugin_generated
|
|
1437
1345
|
):
|
|
1438
1346
|
show_error = False
|
|
1439
1347
|
|
|
@@ -1580,17 +1488,12 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
1580
1488
|
return isinstance(t, AnyType) and t.type_of_any == TypeOfAny.unannotated
|
|
1581
1489
|
|
|
1582
1490
|
has_explicit_annotation = isinstance(fdef.type, CallableType) and any(
|
|
1583
|
-
not is_unannotated_any(t)
|
|
1584
|
-
for t in fdef.type.arg_types + [fdef.type.ret_type]
|
|
1491
|
+
not is_unannotated_any(t) for t in fdef.type.arg_types + [fdef.type.ret_type]
|
|
1585
1492
|
)
|
|
1586
1493
|
|
|
1587
1494
|
show_untyped = not self.is_typeshed_stub or self.options.warn_incomplete_stub
|
|
1588
|
-
check_incomplete_defs =
|
|
1589
|
-
|
|
1590
|
-
)
|
|
1591
|
-
if show_untyped and (
|
|
1592
|
-
self.options.disallow_untyped_defs or check_incomplete_defs
|
|
1593
|
-
):
|
|
1495
|
+
check_incomplete_defs = self.options.disallow_incomplete_defs and has_explicit_annotation
|
|
1496
|
+
if show_untyped and (self.options.disallow_untyped_defs or check_incomplete_defs):
|
|
1594
1497
|
if fdef.type is None and self.options.disallow_untyped_defs:
|
|
1595
1498
|
if not fdef.arguments or (
|
|
1596
1499
|
len(fdef.arguments) == 1
|
|
@@ -1636,8 +1539,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
1636
1539
|
"but must return a subtype of",
|
|
1637
1540
|
)
|
|
1638
1541
|
elif not isinstance(
|
|
1639
|
-
get_proper_type(bound_type.ret_type),
|
|
1640
|
-
(AnyType, Instance, TupleType, UninhabitedType),
|
|
1542
|
+
get_proper_type(bound_type.ret_type), (AnyType, Instance, TupleType, UninhabitedType)
|
|
1641
1543
|
):
|
|
1642
1544
|
self.fail(
|
|
1643
1545
|
message_registry.NON_INSTANCE_NEW_TYPE.format(
|
|
@@ -1657,11 +1559,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
1657
1559
|
)
|
|
1658
1560
|
|
|
1659
1561
|
def check_reverse_op_method(
|
|
1660
|
-
self,
|
|
1661
|
-
defn: FuncItem,
|
|
1662
|
-
reverse_type: CallableType,
|
|
1663
|
-
reverse_name: str,
|
|
1664
|
-
context: Context,
|
|
1562
|
+
self, defn: FuncItem, reverse_type: CallableType, reverse_name: str, context: Context
|
|
1665
1563
|
) -> None:
|
|
1666
1564
|
"""Check a reverse operator method such as __radd__."""
|
|
1667
1565
|
# Decides whether it's worth calling check_overlapping_op_methods().
|
|
@@ -1799,9 +1697,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
1799
1697
|
for forward_item in flatten_nested_unions([forward_type]):
|
|
1800
1698
|
forward_item = get_proper_type(forward_item)
|
|
1801
1699
|
if isinstance(forward_item, CallableType):
|
|
1802
|
-
if self.is_unsafe_overlapping_op(
|
|
1803
|
-
forward_item, forward_base, reverse_type
|
|
1804
|
-
):
|
|
1700
|
+
if self.is_unsafe_overlapping_op(forward_item, forward_base, reverse_type):
|
|
1805
1701
|
self.msg.operator_method_signatures_overlap(
|
|
1806
1702
|
reverse_class, reverse_name, forward_base, forward_name, context
|
|
1807
1703
|
)
|
|
@@ -1809,11 +1705,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
1809
1705
|
for item in forward_item.items:
|
|
1810
1706
|
if self.is_unsafe_overlapping_op(item, forward_base, reverse_type):
|
|
1811
1707
|
self.msg.operator_method_signatures_overlap(
|
|
1812
|
-
reverse_class,
|
|
1813
|
-
reverse_name,
|
|
1814
|
-
forward_base,
|
|
1815
|
-
forward_name,
|
|
1816
|
-
context,
|
|
1708
|
+
reverse_class, reverse_name, forward_base, forward_name, context
|
|
1817
1709
|
)
|
|
1818
1710
|
elif not isinstance(forward_item, AnyType):
|
|
1819
1711
|
self.msg.forward_operator_not_callable(forward_name, context)
|
|
@@ -1880,9 +1772,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
1880
1772
|
if cls.has_readable_member(other_method):
|
|
1881
1773
|
instance = fill_typevars(cls)
|
|
1882
1774
|
typ2 = get_proper_type(
|
|
1883
|
-
self.expr_checker.analyze_external_member_access(
|
|
1884
|
-
other_method, instance, defn
|
|
1885
|
-
)
|
|
1775
|
+
self.expr_checker.analyze_external_member_access(other_method, instance, defn)
|
|
1886
1776
|
)
|
|
1887
1777
|
fail = False
|
|
1888
1778
|
if isinstance(typ2, FunctionLike):
|
|
@@ -2052,18 +1942,11 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
2052
1942
|
self.msg.cant_override_final(name, base.name, defn)
|
|
2053
1943
|
# Second, final can't override anything writeable independently of types.
|
|
2054
1944
|
if defn.is_final:
|
|
2055
|
-
self.check_if_final_var_override_writable(
|
|
2056
|
-
name, base_attr.node, defn
|
|
2057
|
-
)
|
|
1945
|
+
self.check_if_final_var_override_writable(name, base_attr.node, defn)
|
|
2058
1946
|
found_base_method = True
|
|
2059
1947
|
|
|
2060
1948
|
# Check the type of override.
|
|
2061
|
-
if name not in (
|
|
2062
|
-
"__init__",
|
|
2063
|
-
"__new__",
|
|
2064
|
-
"__init_subclass__",
|
|
2065
|
-
"__post_init__",
|
|
2066
|
-
):
|
|
1949
|
+
if name not in ("__init__", "__new__", "__init_subclass__", "__post_init__"):
|
|
2067
1950
|
# Check method override
|
|
2068
1951
|
# (__init__, __new__, __init_subclass__ are special).
|
|
2069
1952
|
if self.check_method_override_for_base_with_name(defn, name, base):
|
|
@@ -2075,9 +1958,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
2075
1958
|
# always introduced safely if a base class defined __add__.
|
|
2076
1959
|
# TODO can't come up with an example where this is
|
|
2077
1960
|
# necessary; now it's "just in case"
|
|
2078
|
-
if self.check_method_override_for_base_with_name(
|
|
2079
|
-
defn, method, base
|
|
2080
|
-
):
|
|
1961
|
+
if self.check_method_override_for_base_with_name(defn, method, base):
|
|
2081
1962
|
return None
|
|
2082
1963
|
return found_base_method
|
|
2083
1964
|
|
|
@@ -2113,9 +1994,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
2113
1994
|
override_class = defn.func.is_class
|
|
2114
1995
|
typ = get_proper_type(typ)
|
|
2115
1996
|
if isinstance(typ, FunctionLike) and not is_static(context):
|
|
2116
|
-
typ = bind_self(
|
|
2117
|
-
typ, self.scope.active_self_type(), is_classmethod=override_class
|
|
2118
|
-
)
|
|
1997
|
+
typ = bind_self(typ, self.scope.active_self_type(), is_classmethod=override_class)
|
|
2119
1998
|
# Map the overridden method type to subtype context so that
|
|
2120
1999
|
# it can be checked for compatibility.
|
|
2121
2000
|
original_type = get_proper_type(base_attr.type)
|
|
@@ -2146,9 +2025,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
2146
2025
|
# Will always fail to typecheck below, since we know the node is a method
|
|
2147
2026
|
original_type = NoneType()
|
|
2148
2027
|
if isinstance(original_node, (FuncDef, OverloadedFuncDef)):
|
|
2149
|
-
original_class_or_static =
|
|
2150
|
-
original_node.is_class or original_node.is_static
|
|
2151
|
-
)
|
|
2028
|
+
original_class_or_static = original_node.is_class or original_node.is_static
|
|
2152
2029
|
elif isinstance(original_node, Decorator):
|
|
2153
2030
|
fdef = original_node.func
|
|
2154
2031
|
original_class_or_static = fdef.is_class or fdef.is_static
|
|
@@ -2156,37 +2033,37 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
2156
2033
|
original_class_or_static = False # a variable can't be class or static
|
|
2157
2034
|
|
|
2158
2035
|
if isinstance(original_type, FunctionLike):
|
|
2159
|
-
original_type = self.bind_and_map_method(
|
|
2160
|
-
base_attr, original_type, defn.info, base
|
|
2161
|
-
)
|
|
2036
|
+
original_type = self.bind_and_map_method(base_attr, original_type, defn.info, base)
|
|
2162
2037
|
if original_node and is_property(original_node):
|
|
2163
2038
|
original_type = get_property_type(original_type)
|
|
2164
2039
|
|
|
2165
|
-
if
|
|
2166
|
-
|
|
2167
|
-
if (
|
|
2168
|
-
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
)
|
|
2174
|
-
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2040
|
+
if is_property(defn):
|
|
2041
|
+
inner: FunctionLike | None
|
|
2042
|
+
if isinstance(typ, FunctionLike):
|
|
2043
|
+
inner = typ
|
|
2044
|
+
else:
|
|
2045
|
+
inner = self.extract_callable_type(typ, context)
|
|
2046
|
+
if inner is not None:
|
|
2047
|
+
typ = inner
|
|
2048
|
+
typ = get_property_type(typ)
|
|
2049
|
+
if (
|
|
2050
|
+
isinstance(original_node, Var)
|
|
2051
|
+
and not original_node.is_final
|
|
2052
|
+
and (not original_node.is_property or original_node.is_settable_property)
|
|
2053
|
+
and isinstance(defn, Decorator)
|
|
2054
|
+
):
|
|
2055
|
+
# We only give an error where no other similar errors will be given.
|
|
2056
|
+
if not isinstance(original_type, AnyType):
|
|
2057
|
+
self.msg.fail(
|
|
2058
|
+
"Cannot override writeable attribute with read-only property",
|
|
2059
|
+
# Give an error on function line to match old behaviour.
|
|
2060
|
+
defn.func,
|
|
2061
|
+
code=codes.OVERRIDE,
|
|
2062
|
+
)
|
|
2184
2063
|
|
|
2185
2064
|
if isinstance(original_type, AnyType) or isinstance(typ, AnyType):
|
|
2186
2065
|
pass
|
|
2187
|
-
elif isinstance(original_type, FunctionLike) and isinstance(
|
|
2188
|
-
typ, FunctionLike
|
|
2189
|
-
):
|
|
2066
|
+
elif isinstance(original_type, FunctionLike) and isinstance(typ, FunctionLike):
|
|
2190
2067
|
# Check that the types are compatible.
|
|
2191
2068
|
self.check_override(
|
|
2192
2069
|
typ,
|
|
@@ -2212,21 +2089,12 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
2212
2089
|
pass
|
|
2213
2090
|
else:
|
|
2214
2091
|
self.msg.signature_incompatible_with_supertype(
|
|
2215
|
-
defn.name,
|
|
2216
|
-
name,
|
|
2217
|
-
base.name,
|
|
2218
|
-
context,
|
|
2219
|
-
original=original_type,
|
|
2220
|
-
override=typ,
|
|
2092
|
+
defn.name, name, base.name, context, original=original_type, override=typ
|
|
2221
2093
|
)
|
|
2222
2094
|
return False
|
|
2223
2095
|
|
|
2224
2096
|
def bind_and_map_method(
|
|
2225
|
-
self,
|
|
2226
|
-
sym: SymbolTableNode,
|
|
2227
|
-
typ: FunctionLike,
|
|
2228
|
-
sub_info: TypeInfo,
|
|
2229
|
-
super_info: TypeInfo,
|
|
2097
|
+
self, sym: SymbolTableNode, typ: FunctionLike, sub_info: TypeInfo, super_info: TypeInfo
|
|
2230
2098
|
) -> FunctionLike:
|
|
2231
2099
|
"""Bind self-type and map type variables for a method.
|
|
2232
2100
|
|
|
@@ -2236,17 +2104,15 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
2236
2104
|
sub_info: class where the method is used
|
|
2237
2105
|
super_info: class where the method was defined
|
|
2238
2106
|
"""
|
|
2239
|
-
if isinstance(
|
|
2240
|
-
sym.node
|
|
2241
|
-
)
|
|
2107
|
+
if isinstance(sym.node, (FuncDef, OverloadedFuncDef, Decorator)) and not is_static(
|
|
2108
|
+
sym.node
|
|
2109
|
+
):
|
|
2242
2110
|
if isinstance(sym.node, Decorator):
|
|
2243
2111
|
is_class_method = sym.node.func.is_class
|
|
2244
2112
|
else:
|
|
2245
2113
|
is_class_method = sym.node.is_class
|
|
2246
2114
|
|
|
2247
|
-
mapped_typ = cast(
|
|
2248
|
-
FunctionLike, map_type_from_supertype(typ, sub_info, super_info)
|
|
2249
|
-
)
|
|
2115
|
+
mapped_typ = cast(FunctionLike, map_type_from_supertype(typ, sub_info, super_info))
|
|
2250
2116
|
active_self_type = self.scope.active_self_type()
|
|
2251
2117
|
if isinstance(mapped_typ, Overloaded) and active_self_type:
|
|
2252
2118
|
# If we have an overload, filter to overloads that match the self type.
|
|
@@ -2270,9 +2136,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
2270
2136
|
|
|
2271
2137
|
return bind_self(mapped_typ, active_self_type, is_class_method)
|
|
2272
2138
|
else:
|
|
2273
|
-
return cast(
|
|
2274
|
-
FunctionLike, map_type_from_supertype(typ, sub_info, super_info)
|
|
2275
|
-
)
|
|
2139
|
+
return cast(FunctionLike, map_type_from_supertype(typ, sub_info, super_info))
|
|
2276
2140
|
|
|
2277
2141
|
def get_op_other_domain(self, tp: FunctionLike) -> Type | None:
|
|
2278
2142
|
if isinstance(tp, CallableType):
|
|
@@ -2302,11 +2166,18 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
2302
2166
|
"""Check a method override with given signatures.
|
|
2303
2167
|
|
|
2304
2168
|
Arguments:
|
|
2305
|
-
override:
|
|
2306
|
-
original:
|
|
2307
|
-
name:
|
|
2308
|
-
|
|
2309
|
-
|
|
2169
|
+
override: The signature of the overriding method.
|
|
2170
|
+
original: The signature of the original supertype method.
|
|
2171
|
+
name: The name of the overriding method.
|
|
2172
|
+
Used primarily for generating error messages.
|
|
2173
|
+
name_in_super: The name of the overridden in the superclass.
|
|
2174
|
+
Used for generating error messages only.
|
|
2175
|
+
supertype: The name of the supertype.
|
|
2176
|
+
original_class_or_static: Indicates whether the original method (from the superclass)
|
|
2177
|
+
is either a class method or a static method.
|
|
2178
|
+
override_class_or_static: Indicates whether the overriding method (from the subclass)
|
|
2179
|
+
is either a class method or a static method.
|
|
2180
|
+
node: Context node.
|
|
2310
2181
|
"""
|
|
2311
2182
|
# Use boolean variable to clarify code.
|
|
2312
2183
|
fail = False
|
|
@@ -2328,11 +2199,11 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
2328
2199
|
if isinstance(override, FunctionLike):
|
|
2329
2200
|
if original_class_or_static and not override_class_or_static:
|
|
2330
2201
|
fail = True
|
|
2331
|
-
elif isinstance(original, CallableType) and isinstance(
|
|
2332
|
-
override, CallableType
|
|
2333
|
-
):
|
|
2202
|
+
elif isinstance(original, CallableType) and isinstance(override, CallableType):
|
|
2334
2203
|
if original.type_guard is not None and override.type_guard is None:
|
|
2335
2204
|
fail = True
|
|
2205
|
+
if original.type_is is not None and override.type_is is None:
|
|
2206
|
+
fail = True
|
|
2336
2207
|
|
|
2337
2208
|
if is_private(name):
|
|
2338
2209
|
fail = False
|
|
@@ -2377,9 +2248,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
2377
2248
|
arg_type_in_super = original.arg_types[i]
|
|
2378
2249
|
|
|
2379
2250
|
if isinstance(node, FuncDef):
|
|
2380
|
-
context: Context = node.arguments[
|
|
2381
|
-
i + len(override.bound_args)
|
|
2382
|
-
]
|
|
2251
|
+
context: Context = node.arguments[i + len(override.bound_args)]
|
|
2383
2252
|
else:
|
|
2384
2253
|
context = node
|
|
2385
2254
|
self.msg.argument_incompatible_with_supertype(
|
|
@@ -2396,12 +2265,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
2396
2265
|
|
|
2397
2266
|
if not is_subtype(erase_override(override.ret_type), original.ret_type):
|
|
2398
2267
|
self.msg.return_type_incompatible_with_supertype(
|
|
2399
|
-
name,
|
|
2400
|
-
name_in_super,
|
|
2401
|
-
supertype,
|
|
2402
|
-
original.ret_type,
|
|
2403
|
-
override.ret_type,
|
|
2404
|
-
node,
|
|
2268
|
+
name, name_in_super, supertype, original.ret_type, override.ret_type, node
|
|
2405
2269
|
)
|
|
2406
2270
|
emitted_msg = True
|
|
2407
2271
|
elif isinstance(override, Overloaded) and isinstance(original, Overloaded):
|
|
@@ -2428,12 +2292,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
2428
2292
|
if not emitted_msg:
|
|
2429
2293
|
# Fall back to generic incompatibility message.
|
|
2430
2294
|
self.msg.signature_incompatible_with_supertype(
|
|
2431
|
-
name,
|
|
2432
|
-
name_in_super,
|
|
2433
|
-
supertype,
|
|
2434
|
-
node,
|
|
2435
|
-
original=original,
|
|
2436
|
-
override=override,
|
|
2295
|
+
name, name_in_super, supertype, node, original=original, override=override
|
|
2437
2296
|
)
|
|
2438
2297
|
if op_method_wider_note:
|
|
2439
2298
|
self.note(
|
|
@@ -2472,21 +2331,15 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
2472
2331
|
typ = defn.info
|
|
2473
2332
|
for base in typ.mro[1:]:
|
|
2474
2333
|
if base.is_final:
|
|
2475
|
-
self.fail(
|
|
2476
|
-
|
|
2477
|
-
)
|
|
2478
|
-
with self.tscope.class_scope(defn.info), self.enter_partial_types(
|
|
2479
|
-
is_class=True
|
|
2480
|
-
):
|
|
2334
|
+
self.fail(message_registry.CANNOT_INHERIT_FROM_FINAL.format(base.name), defn)
|
|
2335
|
+
with self.tscope.class_scope(defn.info), self.enter_partial_types(is_class=True):
|
|
2481
2336
|
old_binder = self.binder
|
|
2482
2337
|
self.binder = ConditionalTypeBinder()
|
|
2483
2338
|
with self.binder.top_frame_context():
|
|
2484
2339
|
with self.scope.push_class(defn.info):
|
|
2485
2340
|
self.accept(defn.defs)
|
|
2486
2341
|
self.binder = old_binder
|
|
2487
|
-
if not (
|
|
2488
|
-
defn.info.typeddict_type or defn.info.tuple_type or defn.info.is_enum
|
|
2489
|
-
):
|
|
2342
|
+
if not (defn.info.typeddict_type or defn.info.tuple_type or defn.info.is_enum):
|
|
2490
2343
|
# If it is not a normal class (not a special form) check class keywords.
|
|
2491
2344
|
self.check_init_subclass(defn)
|
|
2492
2345
|
if not defn.has_incompatible_baseclass:
|
|
@@ -2595,9 +2448,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
2595
2448
|
call_expr.line = defn.line
|
|
2596
2449
|
call_expr.column = defn.column
|
|
2597
2450
|
call_expr.end_line = defn.end_line
|
|
2598
|
-
self.expr_checker.accept(
|
|
2599
|
-
call_expr, allow_none_return=True, always_allow_any=True
|
|
2600
|
-
)
|
|
2451
|
+
self.expr_checker.accept(call_expr, allow_none_return=True, always_allow_any=True)
|
|
2601
2452
|
# We are only interested in the first Base having __init_subclass__,
|
|
2602
2453
|
# all other bases have already been checked.
|
|
2603
2454
|
break
|
|
@@ -2613,9 +2464,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
2613
2464
|
):
|
|
2614
2465
|
# `__members__` will always be overwritten by `Enum` and is considered
|
|
2615
2466
|
# read-only so we disallow assigning a value to it
|
|
2616
|
-
self.fail(
|
|
2617
|
-
message_registry.ENUM_MEMBERS_ATTR_WILL_BE_OVERRIDEN, sym.node
|
|
2618
|
-
)
|
|
2467
|
+
self.fail(message_registry.ENUM_MEMBERS_ATTR_WILL_BE_OVERRIDEN, sym.node)
|
|
2619
2468
|
for base in defn.info.mro[1:-1]: # we don't need self and `object`
|
|
2620
2469
|
if base.is_enum and base.fullname not in ENUM_BASES:
|
|
2621
2470
|
self.check_final_enum(defn, base)
|
|
@@ -2626,9 +2475,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
2626
2475
|
def check_final_enum(self, defn: ClassDef, base: TypeInfo) -> None:
|
|
2627
2476
|
for sym in base.names.values():
|
|
2628
2477
|
if self.is_final_enum_value(sym):
|
|
2629
|
-
self.fail(
|
|
2630
|
-
f'Cannot extend enum with existing members: "{base.name}"', defn
|
|
2631
|
-
)
|
|
2478
|
+
self.fail(f'Cannot extend enum with existing members: "{base.name}"', defn)
|
|
2632
2479
|
break
|
|
2633
2480
|
|
|
2634
2481
|
def is_final_enum_value(self, sym: SymbolTableNode) -> bool:
|
|
@@ -2698,9 +2545,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
2698
2545
|
|
|
2699
2546
|
if base.type.is_enum:
|
|
2700
2547
|
# If we have an `Enum`, then we need to check all its bases.
|
|
2701
|
-
candidate = any(
|
|
2702
|
-
not b.is_enum and has_new_method(b) for b in base.type.mro[1:-1]
|
|
2703
|
-
)
|
|
2548
|
+
candidate = any(not b.is_enum and has_new_method(b) for b in base.type.mro[1:-1])
|
|
2704
2549
|
else:
|
|
2705
2550
|
candidate = has_new_method(base.type)
|
|
2706
2551
|
|
|
@@ -2787,9 +2632,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
2787
2632
|
with self.msg.filter_errors():
|
|
2788
2633
|
# Suppress any errors, they will be given when analyzing the corresponding node.
|
|
2789
2634
|
# Here we may have incorrect options and location context.
|
|
2790
|
-
return self.expr_checker.alias_type_in_runtime_context(
|
|
2791
|
-
sym.node, ctx=sym.node
|
|
2792
|
-
)
|
|
2635
|
+
return self.expr_checker.alias_type_in_runtime_context(sym.node, ctx=sym.node)
|
|
2793
2636
|
# TODO: handle more node kinds here.
|
|
2794
2637
|
return None
|
|
2795
2638
|
|
|
@@ -2834,9 +2677,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
2834
2677
|
if call and isinstance(second_type, FunctionLike):
|
|
2835
2678
|
second_sig = self.bind_and_map_method(second, second_type, ctx, base2)
|
|
2836
2679
|
ok = is_subtype(call, second_sig, ignore_pos_arg_names=True)
|
|
2837
|
-
elif isinstance(first_type, FunctionLike) and isinstance(
|
|
2838
|
-
second_type, FunctionLike
|
|
2839
|
-
):
|
|
2680
|
+
elif isinstance(first_type, FunctionLike) and isinstance(second_type, FunctionLike):
|
|
2840
2681
|
if first_type.is_type_obj() and second_type.is_type_obj():
|
|
2841
2682
|
# For class objects only check the subtype relationship of the classes,
|
|
2842
2683
|
# since we allow incompatible overrides of '__init__'/'__new__'
|
|
@@ -2851,13 +2692,9 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
2851
2692
|
ok = is_subtype(first_sig, second_sig, ignore_pos_arg_names=True)
|
|
2852
2693
|
elif first_type and second_type:
|
|
2853
2694
|
if isinstance(first.node, Var):
|
|
2854
|
-
first_type = expand_self_type(
|
|
2855
|
-
first.node, first_type, fill_typevars(ctx)
|
|
2856
|
-
)
|
|
2695
|
+
first_type = expand_self_type(first.node, first_type, fill_typevars(ctx))
|
|
2857
2696
|
if isinstance(second.node, Var):
|
|
2858
|
-
second_type = expand_self_type(
|
|
2859
|
-
second.node, second_type, fill_typevars(ctx)
|
|
2860
|
-
)
|
|
2697
|
+
second_type = expand_self_type(second.node, second_type, fill_typevars(ctx))
|
|
2861
2698
|
ok = is_equivalent(first_type, second_type)
|
|
2862
2699
|
if not ok:
|
|
2863
2700
|
second_node = base2[name].node
|
|
@@ -3010,9 +2847,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
3010
2847
|
# as X | Y.
|
|
3011
2848
|
if not (s.is_alias_def and self.is_stub):
|
|
3012
2849
|
with self.enter_final_context(s.is_final_def):
|
|
3013
|
-
self.check_assignment(
|
|
3014
|
-
s.lvalues[-1], s.rvalue, s.type is None, s.new_syntax
|
|
3015
|
-
)
|
|
2850
|
+
self.check_assignment(s.lvalues[-1], s.rvalue, s.type is None, s.new_syntax)
|
|
3016
2851
|
|
|
3017
2852
|
if s.is_alias_def:
|
|
3018
2853
|
self.check_type_alias_rvalue(s)
|
|
@@ -3030,9 +2865,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
3030
2865
|
)
|
|
3031
2866
|
else:
|
|
3032
2867
|
self.msg.unimported_type_becomes_any("Type of variable", s.type, s)
|
|
3033
|
-
check_for_explicit_any(
|
|
3034
|
-
s.type, self.options, self.is_typeshed_stub, self.msg, context=s
|
|
3035
|
-
)
|
|
2868
|
+
check_for_explicit_any(s.type, self.options, self.is_typeshed_stub, self.msg, context=s)
|
|
3036
2869
|
|
|
3037
2870
|
if len(s.lvalues) > 1:
|
|
3038
2871
|
# Chained assignment (e.g. x = y = ...).
|
|
@@ -3099,23 +2932,14 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
3099
2932
|
self.check_match_args(inferred, typ, lvalue)
|
|
3100
2933
|
if name == "__post_init__":
|
|
3101
2934
|
active_class = self.scope.active_class()
|
|
3102
|
-
if active_class and dataclasses_plugin.is_processed_dataclass(
|
|
3103
|
-
|
|
3104
|
-
):
|
|
3105
|
-
self.fail(
|
|
3106
|
-
message_registry.DATACLASS_POST_INIT_MUST_BE_A_FUNCTION,
|
|
3107
|
-
rvalue,
|
|
3108
|
-
)
|
|
2935
|
+
if active_class and dataclasses_plugin.is_processed_dataclass(active_class):
|
|
2936
|
+
self.fail(message_registry.DATACLASS_POST_INIT_MUST_BE_A_FUNCTION, rvalue)
|
|
3109
2937
|
|
|
3110
2938
|
# Defer PartialType's super type checking.
|
|
3111
2939
|
if (
|
|
3112
2940
|
isinstance(lvalue, RefExpr)
|
|
3113
|
-
and not (
|
|
3114
|
-
|
|
3115
|
-
)
|
|
3116
|
-
and not (
|
|
3117
|
-
isinstance(lvalue, NameExpr) and lvalue.name == "__match_args__"
|
|
3118
|
-
)
|
|
2941
|
+
and not (isinstance(lvalue_type, PartialType) and lvalue_type.type is None)
|
|
2942
|
+
and not (isinstance(lvalue, NameExpr) and lvalue.name == "__match_args__")
|
|
3119
2943
|
):
|
|
3120
2944
|
if self.check_compatibility_all_supers(lvalue, lvalue_type, rvalue):
|
|
3121
2945
|
# We hit an error on this line; don't check for any others
|
|
@@ -3134,19 +2958,13 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
3134
2958
|
return
|
|
3135
2959
|
|
|
3136
2960
|
var = lvalue_type.var
|
|
3137
|
-
if is_valid_inferred_type(
|
|
3138
|
-
rvalue_type, is_lvalue_final=var.is_final
|
|
3139
|
-
):
|
|
2961
|
+
if is_valid_inferred_type(rvalue_type, is_lvalue_final=var.is_final):
|
|
3140
2962
|
partial_types = self.find_partial_types(var)
|
|
3141
2963
|
if partial_types is not None:
|
|
3142
2964
|
if not self.current_node_deferred:
|
|
3143
2965
|
# Partial type can't be final, so strip any literal values.
|
|
3144
|
-
rvalue_type = remove_instance_last_known_values(
|
|
3145
|
-
|
|
3146
|
-
)
|
|
3147
|
-
inferred_type = make_simplified_union(
|
|
3148
|
-
[rvalue_type, NoneType()]
|
|
3149
|
-
)
|
|
2966
|
+
rvalue_type = remove_instance_last_known_values(rvalue_type)
|
|
2967
|
+
inferred_type = make_simplified_union([rvalue_type, NoneType()])
|
|
3150
2968
|
self.set_inferred_type(var, lvalue, inferred_type)
|
|
3151
2969
|
else:
|
|
3152
2970
|
var.type = None
|
|
@@ -3157,9 +2975,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
3157
2975
|
# an error will be reported elsewhere.
|
|
3158
2976
|
self.infer_partial_type(lvalue_type.var, lvalue, rvalue_type)
|
|
3159
2977
|
# Handle None PartialType's super type checking here, after it's resolved.
|
|
3160
|
-
if isinstance(
|
|
3161
|
-
lvalue, RefExpr
|
|
3162
|
-
) and self.check_compatibility_all_supers(
|
|
2978
|
+
if isinstance(lvalue, RefExpr) and self.check_compatibility_all_supers(
|
|
3163
2979
|
lvalue, lvalue_type, rvalue
|
|
3164
2980
|
):
|
|
3165
2981
|
# We hit an error on this line; don't check for any others
|
|
@@ -3177,11 +2993,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
3177
2993
|
isinstance(lvalue, MemberExpr) and lvalue.kind is None
|
|
3178
2994
|
): # Ignore member access to modules
|
|
3179
2995
|
instance_type = self.expr_checker.accept(lvalue.expr)
|
|
3180
|
-
(
|
|
3181
|
-
rvalue_type,
|
|
3182
|
-
lvalue_type,
|
|
3183
|
-
infer_lvalue_type,
|
|
3184
|
-
) = self.check_member_assignment(
|
|
2996
|
+
rvalue_type, lvalue_type, infer_lvalue_type = self.check_member_assignment(
|
|
3185
2997
|
instance_type, lvalue_type, rvalue, context=rvalue
|
|
3186
2998
|
)
|
|
3187
2999
|
else:
|
|
@@ -3212,9 +3024,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
3212
3024
|
lvalue_type = make_optional_type(lvalue_type)
|
|
3213
3025
|
self.set_inferred_type(lvalue.node, lvalue, lvalue_type)
|
|
3214
3026
|
|
|
3215
|
-
rvalue_type = self.check_simple_assignment(
|
|
3216
|
-
lvalue_type, rvalue, context=rvalue
|
|
3217
|
-
)
|
|
3027
|
+
rvalue_type = self.check_simple_assignment(lvalue_type, rvalue, context=rvalue)
|
|
3218
3028
|
|
|
3219
3029
|
# Special case: only non-abstract non-protocol classes can be assigned to
|
|
3220
3030
|
# variables with explicit type Type[A], where A is protocol or abstract.
|
|
@@ -3230,17 +3040,12 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
3230
3040
|
and isinstance(p_lvalue_type, TypeType)
|
|
3231
3041
|
and isinstance(p_lvalue_type.item, Instance)
|
|
3232
3042
|
and (
|
|
3233
|
-
p_lvalue_type.item.type.is_abstract
|
|
3234
|
-
or p_lvalue_type.item.type.is_protocol
|
|
3043
|
+
p_lvalue_type.item.type.is_abstract or p_lvalue_type.item.type.is_protocol
|
|
3235
3044
|
)
|
|
3236
3045
|
):
|
|
3237
3046
|
self.msg.concrete_only_assign(p_lvalue_type, rvalue)
|
|
3238
3047
|
return
|
|
3239
|
-
if (
|
|
3240
|
-
rvalue_type
|
|
3241
|
-
and infer_lvalue_type
|
|
3242
|
-
and not isinstance(lvalue_type, PartialType)
|
|
3243
|
-
):
|
|
3048
|
+
if rvalue_type and infer_lvalue_type and not isinstance(lvalue_type, PartialType):
|
|
3244
3049
|
# Don't use type binder for definitions of special forms, like named tuples.
|
|
3245
3050
|
if not (isinstance(lvalue, NameExpr) and lvalue.is_special_form):
|
|
3246
3051
|
self.binder.assign_type(lvalue, rvalue_type, lvalue_type, False)
|
|
@@ -3250,14 +3055,10 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
3250
3055
|
|
|
3251
3056
|
if inferred:
|
|
3252
3057
|
type_context = self.get_variable_type_context(inferred)
|
|
3253
|
-
rvalue_type = self.expr_checker.accept(
|
|
3254
|
-
rvalue, type_context=type_context
|
|
3255
|
-
)
|
|
3058
|
+
rvalue_type = self.expr_checker.accept(rvalue, type_context=type_context)
|
|
3256
3059
|
if not (
|
|
3257
3060
|
inferred.is_final
|
|
3258
|
-
or (
|
|
3259
|
-
isinstance(lvalue, NameExpr) and lvalue.name == "__match_args__"
|
|
3260
|
-
)
|
|
3061
|
+
or (isinstance(lvalue, NameExpr) and lvalue.name == "__match_args__")
|
|
3261
3062
|
):
|
|
3262
3063
|
rvalue_type = remove_instance_last_known_values(rvalue_type)
|
|
3263
3064
|
self.infer_variable_type(inferred, lvalue, rvalue_type, rvalue)
|
|
@@ -3273,9 +3074,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
3273
3074
|
base_type, base_node = self.lvalue_type_from_base(inferred, base)
|
|
3274
3075
|
if (
|
|
3275
3076
|
base_type
|
|
3276
|
-
and not (
|
|
3277
|
-
isinstance(base_node, Var) and base_node.invalid_partial_type
|
|
3278
|
-
)
|
|
3077
|
+
and not (isinstance(base_node, Var) and base_node.invalid_partial_type)
|
|
3279
3078
|
and not isinstance(base_type, PartialType)
|
|
3280
3079
|
):
|
|
3281
3080
|
type_contexts.append(base_type)
|
|
@@ -3320,10 +3119,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
3320
3119
|
if typ.type is None:
|
|
3321
3120
|
return
|
|
3322
3121
|
# Return if this is an unsupported augmented assignment.
|
|
3323
|
-
if (
|
|
3324
|
-
op != "="
|
|
3325
|
-
and (typ.type.fullname, op) not in self.partial_type_augmented_ops
|
|
3326
|
-
):
|
|
3122
|
+
if op != "=" and (typ.type.fullname, op) not in self.partial_type_augmented_ops:
|
|
3327
3123
|
return
|
|
3328
3124
|
# TODO: some logic here duplicates the None partial type counterpart
|
|
3329
3125
|
# inlined in check_assignment(), see #8043.
|
|
@@ -3353,15 +3149,11 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
3353
3149
|
for base in lvalue_node.info.mro[1:]:
|
|
3354
3150
|
tnode = base.names.get(lvalue_node.name)
|
|
3355
3151
|
if tnode is not None:
|
|
3356
|
-
if not self.check_compatibility_classvar_super(
|
|
3357
|
-
lvalue_node, base, tnode.node
|
|
3358
|
-
):
|
|
3152
|
+
if not self.check_compatibility_classvar_super(lvalue_node, base, tnode.node):
|
|
3359
3153
|
# Show only one error per variable
|
|
3360
3154
|
break
|
|
3361
3155
|
|
|
3362
|
-
if not self.check_compatibility_final_super(
|
|
3363
|
-
lvalue_node, base, tnode.node
|
|
3364
|
-
):
|
|
3156
|
+
if not self.check_compatibility_final_super(lvalue_node, base, tnode.node):
|
|
3365
3157
|
# Show only one error per variable
|
|
3366
3158
|
break
|
|
3367
3159
|
|
|
@@ -3373,8 +3165,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
3373
3165
|
# be compatible with a base class. We'll still check the type of "__slots__"
|
|
3374
3166
|
# against "object" as an exception.
|
|
3375
3167
|
if lvalue_node.allow_incompatible_override and not (
|
|
3376
|
-
lvalue_node.name == "__slots__"
|
|
3377
|
-
and base.fullname == "builtins.object"
|
|
3168
|
+
lvalue_node.name == "__slots__" and base.fullname == "builtins.object"
|
|
3378
3169
|
):
|
|
3379
3170
|
continue
|
|
3380
3171
|
|
|
@@ -3429,9 +3220,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
3429
3220
|
base_type = get_proper_type(base_type)
|
|
3430
3221
|
compare_type = get_proper_type(compare_type)
|
|
3431
3222
|
if compare_type:
|
|
3432
|
-
if isinstance(base_type, CallableType) and isinstance(
|
|
3433
|
-
compare_type, CallableType
|
|
3434
|
-
):
|
|
3223
|
+
if isinstance(base_type, CallableType) and isinstance(compare_type, CallableType):
|
|
3435
3224
|
base_static = is_node_static(base_node)
|
|
3436
3225
|
compare_static = is_node_static(compare_node)
|
|
3437
3226
|
|
|
@@ -3449,9 +3238,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
3449
3238
|
# methods: the former to the instance, the latter to the
|
|
3450
3239
|
# class
|
|
3451
3240
|
base_type = bind_self(base_type, self.scope.active_self_type())
|
|
3452
|
-
compare_type = bind_self(
|
|
3453
|
-
compare_type, self.scope.active_self_type()
|
|
3454
|
-
)
|
|
3241
|
+
compare_type = bind_self(compare_type, self.scope.active_self_type())
|
|
3455
3242
|
|
|
3456
3243
|
# If we are a static method, ensure to also tell the
|
|
3457
3244
|
# lvalue it now contains a static method
|
|
@@ -3494,9 +3281,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
3494
3281
|
base_node = base_var.node
|
|
3495
3282
|
base_type = base_var.type
|
|
3496
3283
|
if isinstance(base_node, Var) and base_type is not None:
|
|
3497
|
-
base_type = expand_self_type(
|
|
3498
|
-
base_node, base_type, fill_typevars(expr_node.info)
|
|
3499
|
-
)
|
|
3284
|
+
base_type = expand_self_type(base_node, base_type, fill_typevars(expr_node.info))
|
|
3500
3285
|
if isinstance(base_node, Decorator):
|
|
3501
3286
|
base_node = base_node.func
|
|
3502
3287
|
base_type = base_node.type
|
|
@@ -3504,9 +3289,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
3504
3289
|
if base_type:
|
|
3505
3290
|
if not has_no_typevars(base_type):
|
|
3506
3291
|
self_type = self.scope.active_self_type()
|
|
3507
|
-
assert
|
|
3508
|
-
self_type is not None
|
|
3509
|
-
), "Internal error: base lookup outside class"
|
|
3292
|
+
assert self_type is not None, "Internal error: base lookup outside class"
|
|
3510
3293
|
if isinstance(self_type, TupleType):
|
|
3511
3294
|
instance = tuple_fallback(self_type)
|
|
3512
3295
|
else:
|
|
@@ -3515,9 +3298,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
3515
3298
|
base_type = expand_type_by_instance(base_type, itype)
|
|
3516
3299
|
|
|
3517
3300
|
base_type = get_proper_type(base_type)
|
|
3518
|
-
if isinstance(base_type, CallableType) and isinstance(
|
|
3519
|
-
base_node, FuncDef
|
|
3520
|
-
):
|
|
3301
|
+
if isinstance(base_type, CallableType) and isinstance(base_node, FuncDef):
|
|
3521
3302
|
# If we are a property, return the Type of the return
|
|
3522
3303
|
# value, not the Callable
|
|
3523
3304
|
if base_node.is_property:
|
|
@@ -3539,14 +3320,10 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
3539
3320
|
if not isinstance(base_node, Var):
|
|
3540
3321
|
return True
|
|
3541
3322
|
if node.is_classvar and not base_node.is_classvar:
|
|
3542
|
-
self.fail(
|
|
3543
|
-
message_registry.CANNOT_OVERRIDE_INSTANCE_VAR.format(base.name), node
|
|
3544
|
-
)
|
|
3323
|
+
self.fail(message_registry.CANNOT_OVERRIDE_INSTANCE_VAR.format(base.name), node)
|
|
3545
3324
|
return False
|
|
3546
3325
|
elif not node.is_classvar and base_node.is_classvar:
|
|
3547
|
-
self.fail(
|
|
3548
|
-
message_registry.CANNOT_OVERRIDE_CLASS_VAR.format(base.name), node
|
|
3549
|
-
)
|
|
3326
|
+
self.fail(message_registry.CANNOT_OVERRIDE_CLASS_VAR.format(base.name), node)
|
|
3550
3327
|
return False
|
|
3551
3328
|
return True
|
|
3552
3329
|
|
|
@@ -3613,9 +3390,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
3613
3390
|
finally:
|
|
3614
3391
|
self._is_final_def = old_ctx
|
|
3615
3392
|
|
|
3616
|
-
def check_final(
|
|
3617
|
-
self, s: AssignmentStmt | OperatorAssignmentStmt | AssignmentExpr
|
|
3618
|
-
) -> None:
|
|
3393
|
+
def check_final(self, s: AssignmentStmt | OperatorAssignmentStmt | AssignmentExpr) -> None:
|
|
3619
3394
|
"""Check if this assignment does not assign to a final attribute.
|
|
3620
3395
|
|
|
3621
3396
|
This function performs the check only for name assignments at module
|
|
@@ -3637,10 +3412,11 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
3637
3412
|
if (
|
|
3638
3413
|
lv.node.final_unset_in_class
|
|
3639
3414
|
and not lv.node.final_set_in_init
|
|
3640
|
-
and not self.is_stub
|
|
3415
|
+
and not self.is_stub
|
|
3416
|
+
and # It is OK to skip initializer in stub files.
|
|
3641
3417
|
# Avoid extra error messages, if there is no type in Final[...],
|
|
3642
3418
|
# then we already reported the error about missing r.h.s.
|
|
3643
|
-
|
|
3419
|
+
isinstance(s, AssignmentStmt)
|
|
3644
3420
|
and s.type is not None
|
|
3645
3421
|
):
|
|
3646
3422
|
self.msg.final_without_value(s)
|
|
@@ -3659,9 +3435,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
3659
3435
|
# `check_compatibility_final_super()`.
|
|
3660
3436
|
if sym and isinstance(sym.node, Var):
|
|
3661
3437
|
if sym.node.is_final and not is_final_decl:
|
|
3662
|
-
self.msg.cant_assign_to_final(
|
|
3663
|
-
name, sym.node.info is None, s
|
|
3664
|
-
)
|
|
3438
|
+
self.msg.cant_assign_to_final(name, sym.node.info is None, s)
|
|
3665
3439
|
# ...but only once
|
|
3666
3440
|
break
|
|
3667
3441
|
if lv.node.is_final and not is_final_decl:
|
|
@@ -3695,8 +3469,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
3695
3469
|
return
|
|
3696
3470
|
|
|
3697
3471
|
self.fail(
|
|
3698
|
-
message_registry.NAME_NOT_IN_SLOTS.format(lvalue.name, inst.type.fullname),
|
|
3699
|
-
lvalue,
|
|
3472
|
+
message_registry.NAME_NOT_IN_SLOTS.format(lvalue.name, inst.type.fullname), lvalue
|
|
3700
3473
|
)
|
|
3701
3474
|
|
|
3702
3475
|
def is_assignable_slot(self, lvalue: Lvalue, typ: Type | None) -> bool:
|
|
@@ -3768,28 +3541,19 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
3768
3541
|
if isinstance(rval, StarExpr):
|
|
3769
3542
|
typs = get_proper_type(self.expr_checker.accept(rval.expr))
|
|
3770
3543
|
if self.type_is_iterable(typs) and isinstance(typs, Instance):
|
|
3771
|
-
if (
|
|
3772
|
-
|
|
3773
|
-
and iterable_type != self.iterable_item_type(typs, rvalue)
|
|
3544
|
+
if iterable_type is not None and iterable_type != self.iterable_item_type(
|
|
3545
|
+
typs, rvalue
|
|
3774
3546
|
):
|
|
3775
|
-
self.fail(
|
|
3776
|
-
message_registry.CONTIGUOUS_ITERABLE_EXPECTED, context
|
|
3777
|
-
)
|
|
3547
|
+
self.fail(message_registry.CONTIGUOUS_ITERABLE_EXPECTED, context)
|
|
3778
3548
|
else:
|
|
3779
3549
|
if last_idx is None or last_idx + 1 == idx_rval:
|
|
3780
3550
|
rvalues.append(rval)
|
|
3781
3551
|
last_idx = idx_rval
|
|
3782
3552
|
iterable_type = self.iterable_item_type(typs, rvalue)
|
|
3783
3553
|
else:
|
|
3784
|
-
self.fail(
|
|
3785
|
-
message_registry.CONTIGUOUS_ITERABLE_EXPECTED,
|
|
3786
|
-
context,
|
|
3787
|
-
)
|
|
3554
|
+
self.fail(message_registry.CONTIGUOUS_ITERABLE_EXPECTED, context)
|
|
3788
3555
|
else:
|
|
3789
|
-
self.fail(
|
|
3790
|
-
message_registry.ITERABLE_TYPE_EXPECTED.format(typs),
|
|
3791
|
-
context,
|
|
3792
|
-
)
|
|
3556
|
+
self.fail(message_registry.ITERABLE_TYPE_EXPECTED.format(typs), context)
|
|
3793
3557
|
else:
|
|
3794
3558
|
rvalues.append(rval)
|
|
3795
3559
|
iterable_start: int | None = None
|
|
@@ -3817,15 +3581,12 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
3817
3581
|
|
|
3818
3582
|
if self.check_rvalue_count_in_assignment(lvalues, len(rvalues), context):
|
|
3819
3583
|
star_index = next(
|
|
3820
|
-
(i for i, lv in enumerate(lvalues) if isinstance(lv, StarExpr)),
|
|
3821
|
-
len(lvalues),
|
|
3584
|
+
(i for i, lv in enumerate(lvalues) if isinstance(lv, StarExpr)), len(lvalues)
|
|
3822
3585
|
)
|
|
3823
3586
|
|
|
3824
3587
|
left_lvs = lvalues[:star_index]
|
|
3825
3588
|
star_lv = (
|
|
3826
|
-
cast(StarExpr, lvalues[star_index])
|
|
3827
|
-
if star_index != len(lvalues)
|
|
3828
|
-
else None
|
|
3589
|
+
cast(StarExpr, lvalues[star_index]) if star_index != len(lvalues) else None
|
|
3829
3590
|
)
|
|
3830
3591
|
right_lvs = lvalues[star_index + 1 :]
|
|
3831
3592
|
|
|
@@ -3857,13 +3618,9 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
3857
3618
|
self.fail("Variadic tuple unpacking requires a star target", context)
|
|
3858
3619
|
return False
|
|
3859
3620
|
if len(lvalues) > rvalue_count:
|
|
3860
|
-
self.fail(
|
|
3861
|
-
message_registry.TOO_MANY_TARGETS_FOR_VARIADIC_UNPACK, context
|
|
3862
|
-
)
|
|
3621
|
+
self.fail(message_registry.TOO_MANY_TARGETS_FOR_VARIADIC_UNPACK, context)
|
|
3863
3622
|
return False
|
|
3864
|
-
left_star_index = next(
|
|
3865
|
-
i for i, lv in enumerate(lvalues) if isinstance(lv, StarExpr)
|
|
3866
|
-
)
|
|
3623
|
+
left_star_index = next(i for i, lv in enumerate(lvalues) if isinstance(lv, StarExpr))
|
|
3867
3624
|
left_prefix = left_star_index
|
|
3868
3625
|
left_suffix = len(lvalues) - left_star_index - 1
|
|
3869
3626
|
right_prefix = rvalue_unpack
|
|
@@ -3874,15 +3631,11 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
3874
3631
|
# x, y, *xs, z = rv
|
|
3875
3632
|
# it is technically valid, but is tricky to reason about.
|
|
3876
3633
|
# TODO: support this (at least if the r.h.s. unpack is a homogeneous tuple).
|
|
3877
|
-
self.fail(
|
|
3878
|
-
message_registry.TOO_MANY_TARGETS_FOR_VARIADIC_UNPACK, context
|
|
3879
|
-
)
|
|
3634
|
+
self.fail(message_registry.TOO_MANY_TARGETS_FOR_VARIADIC_UNPACK, context)
|
|
3880
3635
|
return True
|
|
3881
3636
|
if any(isinstance(lvalue, StarExpr) for lvalue in lvalues):
|
|
3882
3637
|
if len(lvalues) - 1 > rvalue_count:
|
|
3883
|
-
self.msg.wrong_number_values_to_unpack(
|
|
3884
|
-
rvalue_count, len(lvalues) - 1, context
|
|
3885
|
-
)
|
|
3638
|
+
self.msg.wrong_number_values_to_unpack(rvalue_count, len(lvalues) - 1, context)
|
|
3886
3639
|
return False
|
|
3887
3640
|
elif rvalue_count != len(lvalues):
|
|
3888
3641
|
self.msg.wrong_number_values_to_unpack(rvalue_count, len(lvalues), context)
|
|
@@ -3930,21 +3683,13 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
3930
3683
|
self.check_assignment(lv, temp_node, infer_lvalue_type)
|
|
3931
3684
|
elif isinstance(rvalue_type, TupleType):
|
|
3932
3685
|
self.check_multi_assignment_from_tuple(
|
|
3933
|
-
lvalues,
|
|
3934
|
-
rvalue,
|
|
3935
|
-
rvalue_type,
|
|
3936
|
-
context,
|
|
3937
|
-
undefined_rvalue,
|
|
3938
|
-
infer_lvalue_type,
|
|
3686
|
+
lvalues, rvalue, rvalue_type, context, undefined_rvalue, infer_lvalue_type
|
|
3939
3687
|
)
|
|
3940
3688
|
elif isinstance(rvalue_type, UnionType):
|
|
3941
3689
|
self.check_multi_assignment_from_union(
|
|
3942
3690
|
lvalues, rvalue, rvalue_type, context, infer_lvalue_type
|
|
3943
3691
|
)
|
|
3944
|
-
elif (
|
|
3945
|
-
isinstance(rvalue_type, Instance)
|
|
3946
|
-
and rvalue_type.type.fullname == "builtins.str"
|
|
3947
|
-
):
|
|
3692
|
+
elif isinstance(rvalue_type, Instance) and rvalue_type.type.fullname == "builtins.str":
|
|
3948
3693
|
self.msg.unpacking_strings_disallowed(context)
|
|
3949
3694
|
else:
|
|
3950
3695
|
self.check_multi_assignment_from_iterable(
|
|
@@ -3972,9 +3717,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
3972
3717
|
for binder.
|
|
3973
3718
|
"""
|
|
3974
3719
|
self.no_partial_types = True
|
|
3975
|
-
transposed: tuple[list[Type], ...] = tuple(
|
|
3976
|
-
[] for _ in self.flatten_lvalues(lvalues)
|
|
3977
|
-
)
|
|
3720
|
+
transposed: tuple[list[Type], ...] = tuple([] for _ in self.flatten_lvalues(lvalues))
|
|
3978
3721
|
# Notify binder that we want to defer bindings and instead collect types.
|
|
3979
3722
|
with self.binder.accumulate_type_assignments() as assignments:
|
|
3980
3723
|
for item in rvalue_type.items:
|
|
@@ -3991,9 +3734,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
3991
3734
|
for t, lv in zip(transposed, self.flatten_lvalues(lvalues)):
|
|
3992
3735
|
# We can access _type_maps directly since temporary type maps are
|
|
3993
3736
|
# only created within expressions.
|
|
3994
|
-
t.append(
|
|
3995
|
-
self._type_maps[0].pop(lv, AnyType(TypeOfAny.special_form))
|
|
3996
|
-
)
|
|
3737
|
+
t.append(self._type_maps[0].pop(lv, AnyType(TypeOfAny.special_form)))
|
|
3997
3738
|
union_types = tuple(make_simplified_union(col) for col in transposed)
|
|
3998
3739
|
for expr, items in assignments.items():
|
|
3999
3740
|
# Bind a union of types collected in 'assignments' to every expression.
|
|
@@ -4048,16 +3789,11 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
4048
3789
|
lvalues, len(rvalue_type.items), context, rvalue_unpack=rvalue_unpack
|
|
4049
3790
|
):
|
|
4050
3791
|
star_index = next(
|
|
4051
|
-
(i for i, lv in enumerate(lvalues) if isinstance(lv, StarExpr)),
|
|
4052
|
-
len(lvalues),
|
|
3792
|
+
(i for i, lv in enumerate(lvalues) if isinstance(lv, StarExpr)), len(lvalues)
|
|
4053
3793
|
)
|
|
4054
3794
|
|
|
4055
3795
|
left_lvs = lvalues[:star_index]
|
|
4056
|
-
star_lv = (
|
|
4057
|
-
cast(StarExpr, lvalues[star_index])
|
|
4058
|
-
if star_index != len(lvalues)
|
|
4059
|
-
else None
|
|
4060
|
-
)
|
|
3796
|
+
star_lv = cast(StarExpr, lvalues[star_index]) if star_index != len(lvalues) else None
|
|
4061
3797
|
right_lvs = lvalues[star_index + 1 :]
|
|
4062
3798
|
|
|
4063
3799
|
if not undefined_rvalue:
|
|
@@ -4074,11 +3810,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
4074
3810
|
reinferred_rvalue_type = get_proper_type(relevant_items[0])
|
|
4075
3811
|
if isinstance(reinferred_rvalue_type, UnionType):
|
|
4076
3812
|
self.check_multi_assignment_from_union(
|
|
4077
|
-
lvalues,
|
|
4078
|
-
rvalue,
|
|
4079
|
-
reinferred_rvalue_type,
|
|
4080
|
-
context,
|
|
4081
|
-
infer_lvalue_type,
|
|
3813
|
+
lvalues, rvalue, reinferred_rvalue_type, context, infer_lvalue_type
|
|
4082
3814
|
)
|
|
4083
3815
|
return
|
|
4084
3816
|
if isinstance(reinferred_rvalue_type, AnyType):
|
|
@@ -4097,9 +3829,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
4097
3829
|
)
|
|
4098
3830
|
|
|
4099
3831
|
for lv, rv_type in zip(left_lvs, left_rv_types):
|
|
4100
|
-
self.check_assignment(
|
|
4101
|
-
lv, self.temp_node(rv_type, context), infer_lvalue_type
|
|
4102
|
-
)
|
|
3832
|
+
self.check_assignment(lv, self.temp_node(rv_type, context), infer_lvalue_type)
|
|
4103
3833
|
if star_lv:
|
|
4104
3834
|
list_expr = ListExpr(
|
|
4105
3835
|
[
|
|
@@ -4114,9 +3844,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
4114
3844
|
list_expr.set_line(context)
|
|
4115
3845
|
self.check_assignment(star_lv.expr, list_expr, infer_lvalue_type)
|
|
4116
3846
|
for lv, rv_type in zip(right_lvs, right_rv_types):
|
|
4117
|
-
self.check_assignment(
|
|
4118
|
-
lv, self.temp_node(rv_type, context), infer_lvalue_type
|
|
4119
|
-
)
|
|
3847
|
+
self.check_assignment(lv, self.temp_node(rv_type, context), infer_lvalue_type)
|
|
4120
3848
|
else:
|
|
4121
3849
|
# Store meaningful Any types for lvalues, errors are already given
|
|
4122
3850
|
# by check_rvalue_count_in_assignment()
|
|
@@ -4138,17 +3866,12 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
4138
3866
|
"builtins.list", [AnyType(TypeOfAny.from_error)]
|
|
4139
3867
|
)
|
|
4140
3868
|
|
|
4141
|
-
def lvalue_type_for_inference(
|
|
4142
|
-
self, lvalues: list[Lvalue], rvalue_type: TupleType
|
|
4143
|
-
) -> Type:
|
|
3869
|
+
def lvalue_type_for_inference(self, lvalues: list[Lvalue], rvalue_type: TupleType) -> Type:
|
|
4144
3870
|
star_index = next(
|
|
4145
|
-
(i for i, lv in enumerate(lvalues) if isinstance(lv, StarExpr)),
|
|
4146
|
-
len(lvalues),
|
|
3871
|
+
(i for i, lv in enumerate(lvalues) if isinstance(lv, StarExpr)), len(lvalues)
|
|
4147
3872
|
)
|
|
4148
3873
|
left_lvs = lvalues[:star_index]
|
|
4149
|
-
star_lv = (
|
|
4150
|
-
cast(StarExpr, lvalues[star_index]) if star_index != len(lvalues) else None
|
|
4151
|
-
)
|
|
3874
|
+
star_lv = cast(StarExpr, lvalues[star_index]) if star_index != len(lvalues) else None
|
|
4152
3875
|
right_lvs = lvalues[star_index + 1 :]
|
|
4153
3876
|
left_rv_types, star_rv_types, right_rv_types = self.split_around_star(
|
|
4154
3877
|
rvalue_type.items, star_index, len(lvalues)
|
|
@@ -4156,9 +3879,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
4156
3879
|
|
|
4157
3880
|
type_parameters: list[Type] = []
|
|
4158
3881
|
|
|
4159
|
-
def append_types_for_inference(
|
|
4160
|
-
lvs: list[Expression], rv_types: list[Type]
|
|
4161
|
-
) -> None:
|
|
3882
|
+
def append_types_for_inference(lvs: list[Expression], rv_types: list[Type]) -> None:
|
|
4162
3883
|
for lv, rv_type in zip(lvs, rv_types):
|
|
4163
3884
|
sub_lvalue_type, index_expr, inferred = self.check_lvalue(lv)
|
|
4164
3885
|
if sub_lvalue_type and not isinstance(sub_lvalue_type, PartialType):
|
|
@@ -4204,10 +3925,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
4204
3925
|
if isinstance(type, FunctionLike) and type.is_type_obj():
|
|
4205
3926
|
type = type.fallback
|
|
4206
3927
|
return is_subtype(
|
|
4207
|
-
type,
|
|
4208
|
-
self.named_generic_type(
|
|
4209
|
-
"typing.Iterable", [AnyType(TypeOfAny.special_form)]
|
|
4210
|
-
),
|
|
3928
|
+
type, self.named_generic_type("typing.Iterable", [AnyType(TypeOfAny.special_form)])
|
|
4211
3929
|
)
|
|
4212
3930
|
|
|
4213
3931
|
def check_multi_assignment_from_iterable(
|
|
@@ -4235,9 +3953,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
4235
3953
|
else:
|
|
4236
3954
|
self.msg.type_not_iterable(rvalue_type, context)
|
|
4237
3955
|
|
|
4238
|
-
def check_lvalue(
|
|
4239
|
-
self, lvalue: Lvalue
|
|
4240
|
-
) -> tuple[Type | None, IndexExpr | None, Var | None]:
|
|
3956
|
+
def check_lvalue(self, lvalue: Lvalue) -> tuple[Type | None, IndexExpr | None, Var | None]:
|
|
4241
3957
|
lvalue_type = None
|
|
4242
3958
|
index_lvalue = None
|
|
4243
3959
|
inferred = None
|
|
@@ -4307,18 +4023,14 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
4307
4023
|
# partial type which will be made more specific later. A partial type
|
|
4308
4024
|
# gets generated in assignment like 'x = []' where item type is not known.
|
|
4309
4025
|
if not self.infer_partial_type(name, lvalue, init_type):
|
|
4310
|
-
self.msg.need_annotation_for_var(
|
|
4311
|
-
name, context, self.options.python_version
|
|
4312
|
-
)
|
|
4026
|
+
self.msg.need_annotation_for_var(name, context, self.options.python_version)
|
|
4313
4027
|
self.set_inference_error_fallback_type(name, lvalue, init_type)
|
|
4314
4028
|
elif (
|
|
4315
4029
|
isinstance(lvalue, MemberExpr)
|
|
4316
4030
|
and self.inferred_attribute_types is not None
|
|
4317
4031
|
and lvalue.def_var
|
|
4318
4032
|
and lvalue.def_var in self.inferred_attribute_types
|
|
4319
|
-
and not is_same_type(
|
|
4320
|
-
self.inferred_attribute_types[lvalue.def_var], init_type
|
|
4321
|
-
)
|
|
4033
|
+
and not is_same_type(self.inferred_attribute_types[lvalue.def_var], init_type)
|
|
4322
4034
|
):
|
|
4323
4035
|
# Multiple, inconsistent types inferred for an attribute.
|
|
4324
4036
|
self.msg.need_annotation_for_var(name, context, self.options.python_version)
|
|
@@ -4408,18 +4120,13 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
4408
4120
|
if var not in self.var_decl_frames:
|
|
4409
4121
|
# Used for the hack to improve optional type inference in conditionals
|
|
4410
4122
|
self.var_decl_frames[var] = {frame.id for frame in self.binder.frames}
|
|
4411
|
-
if (
|
|
4412
|
-
isinstance(lvalue, MemberExpr)
|
|
4413
|
-
and self.inferred_attribute_types is not None
|
|
4414
|
-
):
|
|
4123
|
+
if isinstance(lvalue, MemberExpr) and self.inferred_attribute_types is not None:
|
|
4415
4124
|
# Store inferred attribute type so that we can check consistency afterwards.
|
|
4416
4125
|
if lvalue.def_var is not None:
|
|
4417
4126
|
self.inferred_attribute_types[lvalue.def_var] = type
|
|
4418
4127
|
self.store_type(lvalue, type)
|
|
4419
4128
|
|
|
4420
|
-
def set_inference_error_fallback_type(
|
|
4421
|
-
self, var: Var, lvalue: Lvalue, type: Type
|
|
4422
|
-
) -> None:
|
|
4129
|
+
def set_inference_error_fallback_type(self, var: Var, lvalue: Lvalue, type: Type) -> None:
|
|
4423
4130
|
"""Store best known type for variable if type inference failed.
|
|
4424
4131
|
|
|
4425
4132
|
If a program ignores error on type inference error, the variable should get some
|
|
@@ -4448,9 +4155,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
4448
4155
|
if isinstance(rvalue, (IntExpr, StrExpr, BytesExpr, FloatExpr, RefExpr)):
|
|
4449
4156
|
return True
|
|
4450
4157
|
if isinstance(rvalue, CallExpr):
|
|
4451
|
-
if isinstance(rvalue.callee, RefExpr) and isinstance(
|
|
4452
|
-
rvalue.callee.node, FuncBase
|
|
4453
|
-
):
|
|
4158
|
+
if isinstance(rvalue.callee, RefExpr) and isinstance(rvalue.callee.node, FuncBase):
|
|
4454
4159
|
typ = rvalue.callee.node.type
|
|
4455
4160
|
if isinstance(typ, CallableType):
|
|
4456
4161
|
return not typ.variables
|
|
@@ -4521,11 +4226,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
4521
4226
|
return rvalue_type
|
|
4522
4227
|
|
|
4523
4228
|
def check_member_assignment(
|
|
4524
|
-
self,
|
|
4525
|
-
instance_type: Type,
|
|
4526
|
-
attribute_type: Type,
|
|
4527
|
-
rvalue: Expression,
|
|
4528
|
-
context: Context,
|
|
4229
|
+
self, instance_type: Type, attribute_type: Type, rvalue: Expression, context: Context
|
|
4529
4230
|
) -> tuple[Type, Type, bool]:
|
|
4530
4231
|
"""Type member assignment.
|
|
4531
4232
|
|
|
@@ -4541,9 +4242,9 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
4541
4242
|
instance_type = get_proper_type(instance_type)
|
|
4542
4243
|
attribute_type = get_proper_type(attribute_type)
|
|
4543
4244
|
# Descriptors don't participate in class-attribute access
|
|
4544
|
-
if (
|
|
4545
|
-
|
|
4546
|
-
)
|
|
4245
|
+
if (isinstance(instance_type, FunctionLike) and instance_type.is_type_obj()) or isinstance(
|
|
4246
|
+
instance_type, TypeType
|
|
4247
|
+
):
|
|
4547
4248
|
rvalue_type = self.check_simple_assignment(attribute_type, rvalue, context)
|
|
4548
4249
|
return rvalue_type, attribute_type, True
|
|
4549
4250
|
|
|
@@ -4706,9 +4407,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
4706
4407
|
and not is_equivalent(value_type, var.type.value_type)
|
|
4707
4408
|
)
|
|
4708
4409
|
):
|
|
4709
|
-
var.type = self.named_generic_type(
|
|
4710
|
-
typename, [key_type, value_type]
|
|
4711
|
-
)
|
|
4410
|
+
var.type = self.named_generic_type(typename, [key_type, value_type])
|
|
4712
4411
|
del partial_types[var]
|
|
4713
4412
|
|
|
4714
4413
|
def type_requires_usage(self, typ: Type) -> tuple[str, ErrorCode] | None:
|
|
@@ -4729,16 +4428,12 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
4729
4428
|
return None
|
|
4730
4429
|
|
|
4731
4430
|
def visit_expression_stmt(self, s: ExpressionStmt) -> None:
|
|
4732
|
-
expr_type = self.expr_checker.accept(
|
|
4733
|
-
s.expr, allow_none_return=True, always_allow_any=True
|
|
4734
|
-
)
|
|
4431
|
+
expr_type = self.expr_checker.accept(s.expr, allow_none_return=True, always_allow_any=True)
|
|
4735
4432
|
error_note_and_code = self.type_requires_usage(expr_type)
|
|
4736
4433
|
if error_note_and_code:
|
|
4737
4434
|
error_note, code = error_note_and_code
|
|
4738
4435
|
self.fail(
|
|
4739
|
-
message_registry.TYPE_MUST_BE_USED.format(
|
|
4740
|
-
format_type(expr_type, self.options)
|
|
4741
|
-
),
|
|
4436
|
+
message_registry.TYPE_MUST_BE_USED.format(format_type(expr_type, self.options)),
|
|
4742
4437
|
s,
|
|
4743
4438
|
code=code,
|
|
4744
4439
|
)
|
|
@@ -4778,9 +4473,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
4778
4473
|
# E.g. `return f()` for some `f` that returns None. We allow
|
|
4779
4474
|
# this only if we're in a lambda or in a function that returns
|
|
4780
4475
|
# `None` or `Any`.
|
|
4781
|
-
allow_none_func_call =
|
|
4782
|
-
is_lambda or declared_none_return or declared_any_return
|
|
4783
|
-
)
|
|
4476
|
+
allow_none_func_call = is_lambda or declared_none_return or declared_any_return
|
|
4784
4477
|
|
|
4785
4478
|
# Return with a value.
|
|
4786
4479
|
typ = get_proper_type(
|
|
@@ -4799,9 +4492,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
4799
4492
|
if (
|
|
4800
4493
|
self.options.warn_return_any
|
|
4801
4494
|
and not self.current_node_deferred
|
|
4802
|
-
and not is_proper_subtype(
|
|
4803
|
-
AnyType(TypeOfAny.special_form), return_type
|
|
4804
|
-
)
|
|
4495
|
+
and not is_proper_subtype(AnyType(TypeOfAny.special_form), return_type)
|
|
4805
4496
|
and not (
|
|
4806
4497
|
defn.name in BINARY_MAGIC_METHODS
|
|
4807
4498
|
and is_literal_not_implemented(s.expr)
|
|
@@ -4853,9 +4544,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
4853
4544
|
"""Type check an if statement."""
|
|
4854
4545
|
# This frame records the knowledge from previous if/elif clauses not being taken.
|
|
4855
4546
|
# Fall-through to the original frame is handled explicitly in each block.
|
|
4856
|
-
with self.binder.frame_context(
|
|
4857
|
-
can_skip=False, conditional_frame=True, fall_through=0
|
|
4858
|
-
):
|
|
4547
|
+
with self.binder.frame_context(can_skip=False, conditional_frame=True, fall_through=0):
|
|
4859
4548
|
for e, b in zip(s.expr, s.body):
|
|
4860
4549
|
t = get_proper_type(self.expr_checker.accept(e))
|
|
4861
4550
|
|
|
@@ -4894,9 +4583,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
4894
4583
|
inplace, method = infer_operator_assignment_method(lvalue_type, s.op)
|
|
4895
4584
|
if inplace:
|
|
4896
4585
|
# There is __ifoo__, treat as x = x.__ifoo__(y)
|
|
4897
|
-
rvalue_type, method_type = self.expr_checker.check_op(
|
|
4898
|
-
method, lvalue_type, s.rvalue, s
|
|
4899
|
-
)
|
|
4586
|
+
rvalue_type, method_type = self.expr_checker.check_op(method, lvalue_type, s.rvalue, s)
|
|
4900
4587
|
if not is_subtype(rvalue_type, lvalue_type):
|
|
4901
4588
|
self.msg.incompatible_operator_assignment(s.op, s)
|
|
4902
4589
|
else:
|
|
@@ -4928,9 +4615,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
4928
4615
|
self.type_check_raise(s.from_expr, s, optional=True)
|
|
4929
4616
|
self.binder.unreachable()
|
|
4930
4617
|
|
|
4931
|
-
def type_check_raise(
|
|
4932
|
-
self, e: Expression, s: RaiseStmt, optional: bool = False
|
|
4933
|
-
) -> None:
|
|
4618
|
+
def type_check_raise(self, e: Expression, s: RaiseStmt, optional: bool = False) -> None:
|
|
4934
4619
|
typ = get_proper_type(self.expr_checker.accept(e))
|
|
4935
4620
|
if isinstance(typ, DeletedType):
|
|
4936
4621
|
self.msg.deleted_as_rvalue(typ, e)
|
|
@@ -4944,10 +4629,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
4944
4629
|
expected_type_items.append(NoneType())
|
|
4945
4630
|
|
|
4946
4631
|
self.check_subtype(
|
|
4947
|
-
typ,
|
|
4948
|
-
UnionType.make_union(expected_type_items),
|
|
4949
|
-
s,
|
|
4950
|
-
message_registry.INVALID_EXCEPTION,
|
|
4632
|
+
typ, UnionType.make_union(expected_type_items), s, message_registry.INVALID_EXCEPTION
|
|
4951
4633
|
)
|
|
4952
4634
|
|
|
4953
4635
|
if isinstance(typ, FunctionLike):
|
|
@@ -4998,17 +4680,11 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
4998
4680
|
# This frame will run the else block if the try fell through.
|
|
4999
4681
|
# In that case, control flow continues to the parent of what
|
|
5000
4682
|
# was the top frame on entry.
|
|
5001
|
-
with self.binder.frame_context(
|
|
5002
|
-
can_skip=False, fall_through=2, try_frame=try_frame
|
|
5003
|
-
):
|
|
4683
|
+
with self.binder.frame_context(can_skip=False, fall_through=2, try_frame=try_frame):
|
|
5004
4684
|
# This frame receives exit via exception, and runs exception handlers
|
|
5005
|
-
with self.binder.frame_context(
|
|
5006
|
-
can_skip=False, conditional_frame=True, fall_through=2
|
|
5007
|
-
):
|
|
4685
|
+
with self.binder.frame_context(can_skip=False, conditional_frame=True, fall_through=2):
|
|
5008
4686
|
# Finally, the body of the try statement
|
|
5009
|
-
with self.binder.frame_context(
|
|
5010
|
-
can_skip=False, fall_through=2, try_frame=True
|
|
5011
|
-
):
|
|
4687
|
+
with self.binder.frame_context(can_skip=False, fall_through=2, try_frame=True):
|
|
5012
4688
|
self.accept(s.body)
|
|
5013
4689
|
for i in range(len(s.handlers)):
|
|
5014
4690
|
with self.binder.frame_context(can_skip=True, fall_through=4):
|
|
@@ -5067,9 +4743,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
5067
4743
|
if is_star:
|
|
5068
4744
|
new_all_types: list[Type] = []
|
|
5069
4745
|
for typ in all_types:
|
|
5070
|
-
if is_proper_subtype(
|
|
5071
|
-
typ, self.named_type("builtins.BaseExceptionGroup")
|
|
5072
|
-
):
|
|
4746
|
+
if is_proper_subtype(typ, self.named_type("builtins.BaseExceptionGroup")):
|
|
5073
4747
|
self.fail(message_registry.INVALID_EXCEPTION_GROUP, n)
|
|
5074
4748
|
new_all_types.append(AnyType(TypeOfAny.from_error))
|
|
5075
4749
|
else:
|
|
@@ -5125,12 +4799,8 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
5125
4799
|
"""Analyse async iterable expression and return iterator and iterator item types."""
|
|
5126
4800
|
echk = self.expr_checker
|
|
5127
4801
|
iterable = echk.accept(expr)
|
|
5128
|
-
iterator = echk.check_method_call_by_name("__aiter__", iterable, [], [], expr)[
|
|
5129
|
-
|
|
5130
|
-
]
|
|
5131
|
-
awaitable = echk.check_method_call_by_name("__anext__", iterator, [], [], expr)[
|
|
5132
|
-
0
|
|
5133
|
-
]
|
|
4802
|
+
iterator = echk.check_method_call_by_name("__aiter__", iterable, [], [], expr)[0]
|
|
4803
|
+
awaitable = echk.check_method_call_by_name("__anext__", iterator, [], [], expr)[0]
|
|
5134
4804
|
item_type = echk.check_awaitable_expr(
|
|
5135
4805
|
awaitable, expr, message_registry.INCOMPATIBLE_TYPES_IN_ASYNC_FOR
|
|
5136
4806
|
)
|
|
@@ -5153,9 +4823,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
5153
4823
|
echk = self.expr_checker
|
|
5154
4824
|
iterable: Type
|
|
5155
4825
|
iterable = get_proper_type(type)
|
|
5156
|
-
iterator = echk.check_method_call_by_name(
|
|
5157
|
-
"__iter__", iterable, [], [], context
|
|
5158
|
-
)[0]
|
|
4826
|
+
iterator = echk.check_method_call_by_name("__iter__", iterable, [], [], context)[0]
|
|
5159
4827
|
|
|
5160
4828
|
if (
|
|
5161
4829
|
isinstance(iterable, TupleType)
|
|
@@ -5164,9 +4832,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
5164
4832
|
return iterator, tuple_fallback(iterable).args[0]
|
|
5165
4833
|
else:
|
|
5166
4834
|
# Non-tuple iterable.
|
|
5167
|
-
iterable = echk.check_method_call_by_name(
|
|
5168
|
-
"__next__", iterator, [], [], context
|
|
5169
|
-
)[0]
|
|
4835
|
+
iterable = echk.check_method_call_by_name("__next__", iterator, [], [], context)[0]
|
|
5170
4836
|
return iterator, iterable
|
|
5171
4837
|
|
|
5172
4838
|
def analyze_range_native_int_type(self, expr: Expression) -> Type | None:
|
|
@@ -5187,10 +4853,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
5187
4853
|
ok = True
|
|
5188
4854
|
for arg in expr.args:
|
|
5189
4855
|
argt = get_proper_type(self.lookup_type(arg))
|
|
5190
|
-
if (
|
|
5191
|
-
isinstance(argt, Instance)
|
|
5192
|
-
and argt.type.fullname in MYPYC_NATIVE_INT_NAMES
|
|
5193
|
-
):
|
|
4856
|
+
if isinstance(argt, Instance) and argt.type.fullname in MYPYC_NATIVE_INT_NAMES:
|
|
5194
4857
|
if native_int is None:
|
|
5195
4858
|
native_int = argt
|
|
5196
4859
|
elif argt != native_int:
|
|
@@ -5222,16 +4885,10 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
5222
4885
|
return None
|
|
5223
4886
|
|
|
5224
4887
|
def analyze_index_variables(
|
|
5225
|
-
self,
|
|
5226
|
-
index: Expression,
|
|
5227
|
-
item_type: Type,
|
|
5228
|
-
infer_lvalue_type: bool,
|
|
5229
|
-
context: Context,
|
|
4888
|
+
self, index: Expression, item_type: Type, infer_lvalue_type: bool, context: Context
|
|
5230
4889
|
) -> None:
|
|
5231
4890
|
"""Type check or infer for loop or list comprehension index vars."""
|
|
5232
|
-
self.check_assignment(
|
|
5233
|
-
index, self.temp_node(item_type, context), infer_lvalue_type
|
|
5234
|
-
)
|
|
4891
|
+
self.check_assignment(index, self.temp_node(item_type, context), infer_lvalue_type)
|
|
5235
4892
|
|
|
5236
4893
|
def visit_del_stmt(self, s: DelStmt) -> None:
|
|
5237
4894
|
if isinstance(s.expr, IndexExpr):
|
|
@@ -5286,12 +4943,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
5286
4943
|
fullname = self.expr_checker.method_fullname(object_type, d.name)
|
|
5287
4944
|
self.check_for_untyped_decorator(e.func, dec, d)
|
|
5288
4945
|
sig, t2 = self.expr_checker.check_call(
|
|
5289
|
-
dec,
|
|
5290
|
-
[temp],
|
|
5291
|
-
[nodes.ARG_POS],
|
|
5292
|
-
e,
|
|
5293
|
-
callable_name=fullname,
|
|
5294
|
-
object_type=object_type,
|
|
4946
|
+
dec, [temp], [nodes.ARG_POS], e, callable_name=fullname, object_type=object_type
|
|
5295
4947
|
)
|
|
5296
4948
|
self.check_untyped_after_decorator(sig, e.func)
|
|
5297
4949
|
sig = set_callable_name(sig, e.func)
|
|
@@ -5316,9 +4968,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
5316
4968
|
self.check_explicit_override_decorator(e.func, found_method_base_classes)
|
|
5317
4969
|
|
|
5318
4970
|
if e.func.info and e.func.name in ("__init__", "__new__"):
|
|
5319
|
-
if e.type and not isinstance(
|
|
5320
|
-
get_proper_type(e.type), (FunctionLike, AnyType)
|
|
5321
|
-
):
|
|
4971
|
+
if e.type and not isinstance(get_proper_type(e.type), (FunctionLike, AnyType)):
|
|
5322
4972
|
self.fail(message_registry.BAD_CONSTRUCTOR_TYPE, e)
|
|
5323
4973
|
|
|
5324
4974
|
def check_for_untyped_decorator(
|
|
@@ -5341,25 +4991,17 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
5341
4991
|
if (
|
|
5342
4992
|
isinstance(base_attr.node, OverloadedFuncDef)
|
|
5343
4993
|
and base_attr.node.is_property
|
|
5344
|
-
and cast(
|
|
5345
|
-
Decorator, base_attr.node.items[0]
|
|
5346
|
-
).var.is_settable_property
|
|
4994
|
+
and cast(Decorator, base_attr.node.items[0]).var.is_settable_property
|
|
5347
4995
|
):
|
|
5348
|
-
self.fail(
|
|
5349
|
-
message_registry.READ_ONLY_PROPERTY_OVERRIDES_READ_WRITE, e
|
|
5350
|
-
)
|
|
4996
|
+
self.fail(message_registry.READ_ONLY_PROPERTY_OVERRIDES_READ_WRITE, e)
|
|
5351
4997
|
|
|
5352
4998
|
def visit_with_stmt(self, s: WithStmt) -> None:
|
|
5353
4999
|
exceptions_maybe_suppressed = False
|
|
5354
5000
|
for expr, target in zip(s.expr, s.target):
|
|
5355
5001
|
if s.is_async:
|
|
5356
|
-
exit_ret_type = self.check_async_with_item(
|
|
5357
|
-
expr, target, s.unanalyzed_type is None
|
|
5358
|
-
)
|
|
5002
|
+
exit_ret_type = self.check_async_with_item(expr, target, s.unanalyzed_type is None)
|
|
5359
5003
|
else:
|
|
5360
|
-
exit_ret_type = self.check_with_item(
|
|
5361
|
-
expr, target, s.unanalyzed_type is None
|
|
5362
|
-
)
|
|
5004
|
+
exit_ret_type = self.check_with_item(expr, target, s.unanalyzed_type is None)
|
|
5363
5005
|
|
|
5364
5006
|
# Based on the return type, determine if this context manager 'swallows'
|
|
5365
5007
|
# exceptions or not. We determine this using a heuristic based on the
|
|
@@ -5438,6 +5080,19 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
5438
5080
|
return
|
|
5439
5081
|
|
|
5440
5082
|
def visit_match_stmt(self, s: MatchStmt) -> None:
|
|
5083
|
+
named_subject: Expression
|
|
5084
|
+
if isinstance(s.subject, CallExpr):
|
|
5085
|
+
# Create a dummy subject expression to handle cases where a match statement's subject
|
|
5086
|
+
# is not a literal value. This lets us correctly narrow types and check exhaustivity
|
|
5087
|
+
# This is hack!
|
|
5088
|
+
id = s.subject.callee.fullname if isinstance(s.subject.callee, RefExpr) else ""
|
|
5089
|
+
name = "dummy-match-" + id
|
|
5090
|
+
v = Var(name)
|
|
5091
|
+
named_subject = NameExpr(name)
|
|
5092
|
+
named_subject.node = v
|
|
5093
|
+
else:
|
|
5094
|
+
named_subject = s.subject
|
|
5095
|
+
|
|
5441
5096
|
with self.binder.frame_context(can_skip=False, fall_through=0):
|
|
5442
5097
|
subject_type = get_proper_type(self.expr_checker.accept(s.subject))
|
|
5443
5098
|
|
|
@@ -5449,16 +5104,14 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
5449
5104
|
# capture variable may depend on multiple patterns (it
|
|
5450
5105
|
# will be a union of all capture types). This pass ignores
|
|
5451
5106
|
# guard expressions.
|
|
5452
|
-
pattern_types = [
|
|
5453
|
-
self.pattern_checker.accept(p, subject_type) for p in s.patterns
|
|
5454
|
-
]
|
|
5107
|
+
pattern_types = [self.pattern_checker.accept(p, subject_type) for p in s.patterns]
|
|
5455
5108
|
type_maps: list[TypeMap] = [t.captures for t in pattern_types]
|
|
5456
5109
|
inferred_types = self.infer_variable_types_from_type_maps(type_maps)
|
|
5457
5110
|
|
|
5458
5111
|
# The second pass narrows down the types and type checks bodies.
|
|
5459
5112
|
for p, g, b in zip(s.patterns, s.guards, s.bodies):
|
|
5460
5113
|
current_subject_type = self.expr_checker.narrow_type_from_binder(
|
|
5461
|
-
|
|
5114
|
+
named_subject, subject_type
|
|
5462
5115
|
)
|
|
5463
5116
|
pattern_type = self.pattern_checker.accept(p, current_subject_type)
|
|
5464
5117
|
with self.binder.frame_context(can_skip=True, fall_through=2):
|
|
@@ -5469,12 +5122,13 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
5469
5122
|
else_map: TypeMap = {}
|
|
5470
5123
|
else:
|
|
5471
5124
|
pattern_map, else_map = conditional_types_to_typemaps(
|
|
5472
|
-
|
|
5473
|
-
)
|
|
5474
|
-
self.remove_capture_conflicts(
|
|
5475
|
-
pattern_type.captures, inferred_types
|
|
5125
|
+
named_subject, pattern_type.type, pattern_type.rest_type
|
|
5476
5126
|
)
|
|
5127
|
+
self.remove_capture_conflicts(pattern_type.captures, inferred_types)
|
|
5477
5128
|
self.push_type_map(pattern_map)
|
|
5129
|
+
if pattern_map:
|
|
5130
|
+
for expr, typ in pattern_map.items():
|
|
5131
|
+
self.push_type_map(self._get_recursive_sub_patterns_map(expr, typ))
|
|
5478
5132
|
self.push_type_map(pattern_type.captures)
|
|
5479
5133
|
if g is not None:
|
|
5480
5134
|
with self.binder.frame_context(can_skip=False, fall_through=3):
|
|
@@ -5496,11 +5150,10 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
5496
5150
|
for expr in list(type_map):
|
|
5497
5151
|
if not (
|
|
5498
5152
|
isinstance(expr, NameExpr)
|
|
5499
|
-
and expr.fullname
|
|
5500
|
-
== case_target.fullname
|
|
5153
|
+
and expr.fullname == case_target.fullname
|
|
5501
5154
|
):
|
|
5502
5155
|
continue
|
|
5503
|
-
type_map[
|
|
5156
|
+
type_map[named_subject] = type_map[expr]
|
|
5504
5157
|
|
|
5505
5158
|
self.push_type_map(guard_map)
|
|
5506
5159
|
self.accept(b)
|
|
@@ -5513,9 +5166,21 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
5513
5166
|
with self.binder.frame_context(can_skip=False, fall_through=2):
|
|
5514
5167
|
pass
|
|
5515
5168
|
|
|
5516
|
-
def
|
|
5517
|
-
self,
|
|
5518
|
-
) -> dict[
|
|
5169
|
+
def _get_recursive_sub_patterns_map(
|
|
5170
|
+
self, expr: Expression, typ: Type
|
|
5171
|
+
) -> dict[Expression, Type]:
|
|
5172
|
+
sub_patterns_map: dict[Expression, Type] = {}
|
|
5173
|
+
typ_ = get_proper_type(typ)
|
|
5174
|
+
if isinstance(expr, TupleExpr) and isinstance(typ_, TupleType):
|
|
5175
|
+
# When matching a tuple expression with a sequence pattern, narrow individual tuple items
|
|
5176
|
+
assert len(expr.items) == len(typ_.items)
|
|
5177
|
+
for item_expr, item_typ in zip(expr.items, typ_.items):
|
|
5178
|
+
sub_patterns_map[item_expr] = item_typ
|
|
5179
|
+
sub_patterns_map.update(self._get_recursive_sub_patterns_map(item_expr, item_typ))
|
|
5180
|
+
|
|
5181
|
+
return sub_patterns_map
|
|
5182
|
+
|
|
5183
|
+
def infer_variable_types_from_type_maps(self, type_maps: list[TypeMap]) -> dict[Var, Type]:
|
|
5519
5184
|
all_captures: dict[Var, list[tuple[NameExpr, Type]]] = defaultdict(list)
|
|
5520
5185
|
for tm in type_maps:
|
|
5521
5186
|
if tm is not None:
|
|
@@ -5550,22 +5215,16 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
5550
5215
|
# Infer the union type at the first occurrence
|
|
5551
5216
|
first_occurrence, _ = captures[0]
|
|
5552
5217
|
inferred_types[var] = new_type
|
|
5553
|
-
self.infer_variable_type(
|
|
5554
|
-
var, first_occurrence, new_type, first_occurrence
|
|
5555
|
-
)
|
|
5218
|
+
self.infer_variable_type(var, first_occurrence, new_type, first_occurrence)
|
|
5556
5219
|
return inferred_types
|
|
5557
5220
|
|
|
5558
|
-
def remove_capture_conflicts(
|
|
5559
|
-
self, type_map: TypeMap, inferred_types: dict[Var, Type]
|
|
5560
|
-
) -> None:
|
|
5221
|
+
def remove_capture_conflicts(self, type_map: TypeMap, inferred_types: dict[Var, Type]) -> None:
|
|
5561
5222
|
if type_map:
|
|
5562
5223
|
for expr, typ in list(type_map.items()):
|
|
5563
5224
|
if isinstance(expr, NameExpr):
|
|
5564
5225
|
node = expr.node
|
|
5565
5226
|
assert isinstance(node, Var)
|
|
5566
|
-
if node not in inferred_types or not is_subtype(
|
|
5567
|
-
typ, inferred_types[node]
|
|
5568
|
-
):
|
|
5227
|
+
if node not in inferred_types or not is_subtype(typ, inferred_types[node]):
|
|
5569
5228
|
del type_map[expr]
|
|
5570
5229
|
|
|
5571
5230
|
def make_fake_typeinfo(
|
|
@@ -5657,8 +5316,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
5657
5316
|
# use it for the real name that goes into the symbol table
|
|
5658
5317
|
# because it can have dots in it.
|
|
5659
5318
|
pretty_names_list = pretty_seq(
|
|
5660
|
-
format_type_distinctly(*base_classes, options=self.options, bare=True),
|
|
5661
|
-
"and",
|
|
5319
|
+
format_type_distinctly(*base_classes, options=self.options, bare=True), "and"
|
|
5662
5320
|
)
|
|
5663
5321
|
|
|
5664
5322
|
new_errors = []
|
|
@@ -5670,39 +5328,27 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
5670
5328
|
return None
|
|
5671
5329
|
|
|
5672
5330
|
try:
|
|
5673
|
-
info, full_name = _make_fake_typeinfo_and_full_name(
|
|
5674
|
-
base_classes, curr_module
|
|
5675
|
-
)
|
|
5331
|
+
info, full_name = _make_fake_typeinfo_and_full_name(base_classes, curr_module)
|
|
5676
5332
|
with self.msg.filter_errors() as local_errors:
|
|
5677
5333
|
self.check_multiple_inheritance(info)
|
|
5678
5334
|
if local_errors.has_new_errors():
|
|
5679
5335
|
# "class A(B, C)" unsafe, now check "class A(C, B)":
|
|
5680
5336
|
base_classes = _get_base_classes(instances[::-1])
|
|
5681
|
-
info, full_name = _make_fake_typeinfo_and_full_name(
|
|
5682
|
-
base_classes, curr_module
|
|
5683
|
-
)
|
|
5337
|
+
info, full_name = _make_fake_typeinfo_and_full_name(base_classes, curr_module)
|
|
5684
5338
|
with self.msg.filter_errors() as local_errors:
|
|
5685
5339
|
self.check_multiple_inheritance(info)
|
|
5686
5340
|
info.is_intersection = True
|
|
5687
5341
|
except MroError:
|
|
5688
|
-
errors.append(
|
|
5689
|
-
(pretty_names_list, "would have inconsistent method resolution order")
|
|
5690
|
-
)
|
|
5342
|
+
errors.append((pretty_names_list, "would have inconsistent method resolution order"))
|
|
5691
5343
|
return None
|
|
5692
5344
|
if local_errors.has_new_errors():
|
|
5693
|
-
errors.append(
|
|
5694
|
-
(pretty_names_list, "would have incompatible method signatures")
|
|
5695
|
-
)
|
|
5345
|
+
errors.append((pretty_names_list, "would have incompatible method signatures"))
|
|
5696
5346
|
return None
|
|
5697
5347
|
|
|
5698
5348
|
curr_module.names[full_name] = SymbolTableNode(GDEF, info)
|
|
5699
|
-
return Instance(
|
|
5700
|
-
info, [], extra_attrs=instances[0].extra_attrs or instances[1].extra_attrs
|
|
5701
|
-
)
|
|
5349
|
+
return Instance(info, [], extra_attrs=instances[0].extra_attrs or instances[1].extra_attrs)
|
|
5702
5350
|
|
|
5703
|
-
def intersect_instance_callable(
|
|
5704
|
-
self, typ: Instance, callable_type: CallableType
|
|
5705
|
-
) -> Instance:
|
|
5351
|
+
def intersect_instance_callable(self, typ: Instance, callable_type: CallableType) -> Instance:
|
|
5706
5352
|
"""Creates a fake type that represents the intersection of an Instance and a CallableType.
|
|
5707
5353
|
|
|
5708
5354
|
It operates by creating a bare-minimum dummy TypeInfo that
|
|
@@ -5714,15 +5360,11 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
5714
5360
|
# a unique name inside the symbol table of the current module.
|
|
5715
5361
|
cur_module = self.scope.stack[0]
|
|
5716
5362
|
assert isinstance(cur_module, MypyFile)
|
|
5717
|
-
gen_name = gen_unique_name(
|
|
5718
|
-
f"<callable subtype of {typ.type.name}>", cur_module.names
|
|
5719
|
-
)
|
|
5363
|
+
gen_name = gen_unique_name(f"<callable subtype of {typ.type.name}>", cur_module.names)
|
|
5720
5364
|
|
|
5721
5365
|
# Synthesize a fake TypeInfo
|
|
5722
5366
|
short_name = format_type_bare(typ, self.options)
|
|
5723
|
-
cdef, info = self.make_fake_typeinfo(
|
|
5724
|
-
cur_module.fullname, gen_name, short_name, [typ]
|
|
5725
|
-
)
|
|
5367
|
+
cdef, info = self.make_fake_typeinfo(cur_module.fullname, gen_name, short_name, [typ])
|
|
5726
5368
|
|
|
5727
5369
|
# Build up a fake FuncDef so we can populate the symbol table.
|
|
5728
5370
|
func_def = FuncDef("__call__", [], Block([]), callable_type)
|
|
@@ -5851,17 +5493,11 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
5851
5493
|
if isinstance(get_proper_type(current_type), AnyType):
|
|
5852
5494
|
return {}, {}
|
|
5853
5495
|
|
|
5854
|
-
callables, uncallables = self.partition_by_callable(
|
|
5855
|
-
current_type, unsound_partition=False
|
|
5856
|
-
)
|
|
5496
|
+
callables, uncallables = self.partition_by_callable(current_type, unsound_partition=False)
|
|
5857
5497
|
|
|
5858
5498
|
if callables and uncallables:
|
|
5859
|
-
callable_map = (
|
|
5860
|
-
|
|
5861
|
-
)
|
|
5862
|
-
uncallable_map = (
|
|
5863
|
-
{expr: UnionType.make_union(uncallables)} if uncallables else None
|
|
5864
|
-
)
|
|
5499
|
+
callable_map = {expr: UnionType.make_union(callables)} if callables else None
|
|
5500
|
+
uncallable_map = {expr: UnionType.make_union(uncallables)} if uncallables else None
|
|
5865
5501
|
return callable_map, uncallable_map
|
|
5866
5502
|
|
|
5867
5503
|
elif callables:
|
|
@@ -5893,8 +5529,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
5893
5529
|
if key in possible_iterable_type.required_keys:
|
|
5894
5530
|
if_types.append(possible_iterable_type)
|
|
5895
5531
|
elif (
|
|
5896
|
-
key in possible_iterable_type.items
|
|
5897
|
-
or not possible_iterable_type.is_final
|
|
5532
|
+
key in possible_iterable_type.items or not possible_iterable_type.is_final
|
|
5898
5533
|
):
|
|
5899
5534
|
if_types.append(possible_iterable_type)
|
|
5900
5535
|
else_types.append(possible_iterable_type)
|
|
@@ -5956,27 +5591,19 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
5956
5591
|
return format_type(t, self.options)
|
|
5957
5592
|
|
|
5958
5593
|
if isinstance(t, FunctionLike):
|
|
5959
|
-
self.fail(
|
|
5960
|
-
message_registry.FUNCTION_ALWAYS_TRUE.format(get_expr_name()), expr
|
|
5961
|
-
)
|
|
5594
|
+
self.fail(message_registry.FUNCTION_ALWAYS_TRUE.format(get_expr_name()), expr)
|
|
5962
5595
|
elif isinstance(t, UnionType):
|
|
5963
|
-
self.fail(
|
|
5964
|
-
message_registry.TYPE_ALWAYS_TRUE_UNIONTYPE.format(format_expr_type()),
|
|
5965
|
-
expr,
|
|
5966
|
-
)
|
|
5596
|
+
self.fail(message_registry.TYPE_ALWAYS_TRUE_UNIONTYPE.format(format_expr_type()), expr)
|
|
5967
5597
|
elif isinstance(t, Instance) and t.type.fullname == "typing.Iterable":
|
|
5968
5598
|
_, info = self.make_fake_typeinfo("typing", "Collection", "Collection", [])
|
|
5969
5599
|
self.fail(
|
|
5970
5600
|
message_registry.ITERABLE_ALWAYS_TRUE.format(
|
|
5971
|
-
format_expr_type(),
|
|
5972
|
-
format_type(Instance(info, t.args), self.options),
|
|
5601
|
+
format_expr_type(), format_type(Instance(info, t.args), self.options)
|
|
5973
5602
|
),
|
|
5974
5603
|
expr,
|
|
5975
5604
|
)
|
|
5976
5605
|
else:
|
|
5977
|
-
self.fail(
|
|
5978
|
-
message_registry.TYPE_ALWAYS_TRUE.format(format_expr_type()), expr
|
|
5979
|
-
)
|
|
5606
|
+
self.fail(message_registry.TYPE_ALWAYS_TRUE.format(format_expr_type()), expr)
|
|
5980
5607
|
|
|
5981
5608
|
def find_type_equals_check(
|
|
5982
5609
|
self, node: ComparisonExpr, expr_indices: list[int]
|
|
@@ -5991,9 +5618,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
5991
5618
|
|
|
5992
5619
|
def is_type_call(expr: CallExpr) -> bool:
|
|
5993
5620
|
"""Is expr a call to type with one argument?"""
|
|
5994
|
-
return (
|
|
5995
|
-
refers_to_fullname(expr.callee, "builtins.type") and len(expr.args) == 1
|
|
5996
|
-
)
|
|
5621
|
+
return refers_to_fullname(expr.callee, "builtins.type") and len(expr.args) == 1
|
|
5997
5622
|
|
|
5998
5623
|
# exprs that are being passed into type
|
|
5999
5624
|
exprs_in_type_calls: list[Expression] = []
|
|
@@ -6030,10 +5655,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
6030
5655
|
if_maps: list[TypeMap] = []
|
|
6031
5656
|
else_maps: list[TypeMap] = []
|
|
6032
5657
|
for expr in exprs_in_type_calls:
|
|
6033
|
-
(
|
|
6034
|
-
current_if_type,
|
|
6035
|
-
current_else_type,
|
|
6036
|
-
) = self.conditional_types_with_intersection(
|
|
5658
|
+
current_if_type, current_else_type = self.conditional_types_with_intersection(
|
|
6037
5659
|
self.lookup_type(expr), type_being_compared, expr
|
|
6038
5660
|
)
|
|
6039
5661
|
current_if_map, current_else_map = conditional_types_to_typemaps(
|
|
@@ -6064,7 +5686,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
6064
5686
|
def find_isinstance_check(self, node: Expression) -> tuple[TypeMap, TypeMap]:
|
|
6065
5687
|
"""Find any isinstance checks (within a chain of ands). Includes
|
|
6066
5688
|
implicit and explicit checks for None and calls to callable.
|
|
6067
|
-
Also includes TypeGuard functions.
|
|
5689
|
+
Also includes TypeGuard and TypeIs functions.
|
|
6068
5690
|
|
|
6069
5691
|
Return value is a map of variables to their types if the condition
|
|
6070
5692
|
is true and a map of variables to their types if the condition is false.
|
|
@@ -6095,9 +5717,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
6095
5717
|
return conditional_types_to_typemaps(
|
|
6096
5718
|
expr,
|
|
6097
5719
|
*self.conditional_types_with_intersection(
|
|
6098
|
-
self.lookup_type(expr),
|
|
6099
|
-
self.get_isinstance_type(node.args[1]),
|
|
6100
|
-
expr,
|
|
5720
|
+
self.lookup_type(expr), self.get_isinstance_type(node.args[1]), expr
|
|
6101
5721
|
),
|
|
6102
5722
|
)
|
|
6103
5723
|
elif refers_to_fullname(node.callee, "builtins.issubclass"):
|
|
@@ -6114,13 +5734,11 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
6114
5734
|
elif refers_to_fullname(node.callee, "builtins.hasattr"):
|
|
6115
5735
|
if len(node.args) != 2: # the error will be reported elsewhere
|
|
6116
5736
|
return {}, {}
|
|
6117
|
-
attr = try_getting_str_literals(
|
|
6118
|
-
node.args[1], self.lookup_type(node.args[1])
|
|
6119
|
-
)
|
|
5737
|
+
attr = try_getting_str_literals(node.args[1], self.lookup_type(node.args[1]))
|
|
6120
5738
|
if literal(expr) == LITERAL_TYPE and attr and len(attr) == 1:
|
|
6121
5739
|
return self.hasattr_type_maps(expr, self.lookup_type(expr), attr[0])
|
|
6122
5740
|
elif isinstance(node.callee, RefExpr):
|
|
6123
|
-
if node.callee.type_guard is not None:
|
|
5741
|
+
if node.callee.type_guard is not None or node.callee.type_is is not None:
|
|
6124
5742
|
# TODO: Follow *args, **kwargs
|
|
6125
5743
|
if node.arg_kinds[0] != nodes.ARG_POS:
|
|
6126
5744
|
# the first argument might be used as a kwarg
|
|
@@ -6146,8 +5764,11 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
6146
5764
|
# we want the idx-th variable to be narrowed
|
|
6147
5765
|
expr = collapse_walrus(node.args[idx])
|
|
6148
5766
|
else:
|
|
5767
|
+
kind = (
|
|
5768
|
+
"guard" if node.callee.type_guard is not None else "narrower"
|
|
5769
|
+
)
|
|
6149
5770
|
self.fail(
|
|
6150
|
-
message_registry.TYPE_GUARD_POS_ARG_REQUIRED, node
|
|
5771
|
+
message_registry.TYPE_GUARD_POS_ARG_REQUIRED.format(kind), node
|
|
6151
5772
|
)
|
|
6152
5773
|
return {}, {}
|
|
6153
5774
|
if literal(expr) == LITERAL_TYPE:
|
|
@@ -6156,7 +5777,18 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
6156
5777
|
# considered "always right" (i.e. even if the types are not overlapping).
|
|
6157
5778
|
# Also note that a care must be taken to unwrap this back at read places
|
|
6158
5779
|
# where we use this to narrow down declared type.
|
|
6159
|
-
|
|
5780
|
+
if node.callee.type_guard is not None:
|
|
5781
|
+
return {expr: TypeGuardedType(node.callee.type_guard)}, {}
|
|
5782
|
+
else:
|
|
5783
|
+
assert node.callee.type_is is not None
|
|
5784
|
+
return conditional_types_to_typemaps(
|
|
5785
|
+
expr,
|
|
5786
|
+
*self.conditional_types_with_intersection(
|
|
5787
|
+
self.lookup_type(expr),
|
|
5788
|
+
[TypeRange(node.callee.type_is, is_upper_bound=False)],
|
|
5789
|
+
expr,
|
|
5790
|
+
),
|
|
5791
|
+
)
|
|
6160
5792
|
elif isinstance(node, ComparisonExpr):
|
|
6161
5793
|
# Step 1: Obtain the types of each operand and whether or not we can
|
|
6162
5794
|
# narrow their types. (For example, we shouldn't try narrowing the
|
|
@@ -6235,17 +5867,13 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
6235
5867
|
def has_no_custom_eq_checks(t: Type) -> bool:
|
|
6236
5868
|
return not custom_special_method(
|
|
6237
5869
|
t, "__eq__", check_all=False
|
|
6238
|
-
) and not custom_special_method(
|
|
6239
|
-
t, "__ne__", check_all=False
|
|
6240
|
-
)
|
|
5870
|
+
) and not custom_special_method(t, "__ne__", check_all=False)
|
|
6241
5871
|
|
|
6242
5872
|
is_valid_target = is_exactly_literal_type
|
|
6243
5873
|
coerce_only_in_literal_context = True
|
|
6244
5874
|
|
|
6245
5875
|
expr_types = [operand_types[i] for i in expr_indices]
|
|
6246
|
-
should_narrow_by_identity = all(
|
|
6247
|
-
map(has_no_custom_eq_checks, expr_types)
|
|
6248
|
-
)
|
|
5876
|
+
should_narrow_by_identity = all(map(has_no_custom_eq_checks, expr_types))
|
|
6249
5877
|
|
|
6250
5878
|
if_map: TypeMap = {}
|
|
6251
5879
|
else_map: TypeMap = {}
|
|
@@ -6274,9 +5902,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
6274
5902
|
# If we haven't been able to narrow types yet, we might be dealing with a
|
|
6275
5903
|
# explicit type(x) == some_type check
|
|
6276
5904
|
if if_map == {} and else_map == {}:
|
|
6277
|
-
if_map, else_map = self.find_type_equals_check(
|
|
6278
|
-
node, expr_indices
|
|
6279
|
-
)
|
|
5905
|
+
if_map, else_map = self.find_type_equals_check(node, expr_indices)
|
|
6280
5906
|
elif operator in {"in", "not in"}:
|
|
6281
5907
|
assert len(expr_indices) == 2
|
|
6282
5908
|
left_index, right_index = expr_indices
|
|
@@ -6296,16 +5922,11 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
6296
5922
|
and not is_overlapping_none(collection_item_type)
|
|
6297
5923
|
and not (
|
|
6298
5924
|
isinstance(collection_item_type, Instance)
|
|
6299
|
-
and collection_item_type.type.fullname
|
|
6300
|
-
== "builtins.object"
|
|
6301
|
-
)
|
|
6302
|
-
and is_overlapping_erased_types(
|
|
6303
|
-
item_type, collection_item_type
|
|
5925
|
+
and collection_item_type.type.fullname == "builtins.object"
|
|
6304
5926
|
)
|
|
5927
|
+
and is_overlapping_erased_types(item_type, collection_item_type)
|
|
6305
5928
|
):
|
|
6306
|
-
if_map[operands[left_index]] = remove_optional(
|
|
6307
|
-
item_type
|
|
6308
|
-
)
|
|
5929
|
+
if_map[operands[left_index]] = remove_optional(item_type)
|
|
6309
5930
|
|
|
6310
5931
|
if right_index in narrowable_operand_index_to_hash:
|
|
6311
5932
|
if_type, else_type = self.conditional_types_for_iterable(
|
|
@@ -6338,25 +5959,19 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
6338
5959
|
else:
|
|
6339
5960
|
# Use meet for `and` maps to get correct results for chained checks
|
|
6340
5961
|
# like `if 1 < len(x) < 4: ...`
|
|
6341
|
-
return reduce_conditional_maps(
|
|
6342
|
-
self.find_tuple_len_narrowing(node), use_meet=True
|
|
6343
|
-
)
|
|
5962
|
+
return reduce_conditional_maps(self.find_tuple_len_narrowing(node), use_meet=True)
|
|
6344
5963
|
elif isinstance(node, AssignmentExpr):
|
|
6345
5964
|
if_map = {}
|
|
6346
5965
|
else_map = {}
|
|
6347
5966
|
|
|
6348
|
-
if_assignment_map, else_assignment_map = self.find_isinstance_check(
|
|
6349
|
-
node.target
|
|
6350
|
-
)
|
|
5967
|
+
if_assignment_map, else_assignment_map = self.find_isinstance_check(node.target)
|
|
6351
5968
|
|
|
6352
5969
|
if if_assignment_map is not None:
|
|
6353
5970
|
if_map.update(if_assignment_map)
|
|
6354
5971
|
if else_assignment_map is not None:
|
|
6355
5972
|
else_map.update(else_assignment_map)
|
|
6356
5973
|
|
|
6357
|
-
if_condition_map, else_condition_map = self.find_isinstance_check(
|
|
6358
|
-
node.value
|
|
6359
|
-
)
|
|
5974
|
+
if_condition_map, else_condition_map = self.find_isinstance_check(node.value)
|
|
6360
5975
|
|
|
6361
5976
|
if if_condition_map is not None:
|
|
6362
5977
|
if_map.update(if_condition_map)
|
|
@@ -6364,16 +5979,8 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
6364
5979
|
else_map.update(else_condition_map)
|
|
6365
5980
|
|
|
6366
5981
|
return (
|
|
6367
|
-
(
|
|
6368
|
-
|
|
6369
|
-
if if_assignment_map is None or if_condition_map is None
|
|
6370
|
-
else if_map
|
|
6371
|
-
),
|
|
6372
|
-
(
|
|
6373
|
-
None
|
|
6374
|
-
if else_assignment_map is None or else_condition_map is None
|
|
6375
|
-
else else_map
|
|
6376
|
-
),
|
|
5982
|
+
(None if if_assignment_map is None or if_condition_map is None else if_map),
|
|
5983
|
+
(None if else_assignment_map is None or else_condition_map is None else else_map),
|
|
6377
5984
|
)
|
|
6378
5985
|
elif isinstance(node, OpExpr) and node.op == "and":
|
|
6379
5986
|
left_if_vars, left_else_vars = self.find_isinstance_check(node.left)
|
|
@@ -6419,12 +6026,8 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
6419
6026
|
no_type = false_only(no_type)
|
|
6420
6027
|
else:
|
|
6421
6028
|
no_type = UninhabitedType()
|
|
6422
|
-
if_map = (
|
|
6423
|
-
|
|
6424
|
-
)
|
|
6425
|
-
else_map = (
|
|
6426
|
-
{node: no_type} if not isinstance(no_type, UninhabitedType) else None
|
|
6427
|
-
)
|
|
6029
|
+
if_map = {node: yes_type} if not isinstance(yes_type, UninhabitedType) else None
|
|
6030
|
+
else_map = {node: no_type} if not isinstance(no_type, UninhabitedType) else None
|
|
6428
6031
|
return if_map, else_map
|
|
6429
6032
|
|
|
6430
6033
|
# Restrict the type of the variable to True-ish/False-ish in the if and else branches
|
|
@@ -6436,9 +6039,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
6436
6039
|
if_type = true_only(vartype)
|
|
6437
6040
|
else_type = false_only(vartype)
|
|
6438
6041
|
if_map = {node: if_type} if not isinstance(if_type, UninhabitedType) else None
|
|
6439
|
-
else_map = (
|
|
6440
|
-
{node: else_type} if not isinstance(else_type, UninhabitedType) else None
|
|
6441
|
-
)
|
|
6042
|
+
else_map = {node: else_type} if not isinstance(else_type, UninhabitedType) else None
|
|
6442
6043
|
return if_map, else_map
|
|
6443
6044
|
|
|
6444
6045
|
def propagate_up_typemap_info(self, new_types: TypeMap) -> TypeMap:
|
|
@@ -6484,9 +6085,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
6484
6085
|
output_map[parent_expr] = proposed_parent_type
|
|
6485
6086
|
return output_map
|
|
6486
6087
|
|
|
6487
|
-
def refine_parent_types(
|
|
6488
|
-
self, expr: Expression, expr_type: Type
|
|
6489
|
-
) -> Mapping[Expression, Type]:
|
|
6088
|
+
def refine_parent_types(self, expr: Expression, expr_type: Type) -> Mapping[Expression, Type]:
|
|
6490
6089
|
"""Checks if the given expr is a 'lookup operation' into a union and iteratively refines
|
|
6491
6090
|
the parent types based on the 'expr_type'.
|
|
6492
6091
|
|
|
@@ -6547,9 +6146,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
6547
6146
|
return None
|
|
6548
6147
|
try:
|
|
6549
6148
|
assert str_literals is not None
|
|
6550
|
-
member_types = [
|
|
6551
|
-
new_parent_type.items[key] for key in str_literals
|
|
6552
|
-
]
|
|
6149
|
+
member_types = [new_parent_type.items[key] for key in str_literals]
|
|
6553
6150
|
except KeyError:
|
|
6554
6151
|
return None
|
|
6555
6152
|
return make_simplified_union(member_types)
|
|
@@ -6563,9 +6160,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
6563
6160
|
return None
|
|
6564
6161
|
try:
|
|
6565
6162
|
assert int_literals is not None
|
|
6566
|
-
member_types = [
|
|
6567
|
-
new_parent_type.items[key] for key in int_literals
|
|
6568
|
-
]
|
|
6163
|
+
member_types = [new_parent_type.items[key] for key in int_literals]
|
|
6569
6164
|
except IndexError:
|
|
6570
6165
|
return None
|
|
6571
6166
|
return make_simplified_union(member_types)
|
|
@@ -6654,9 +6249,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
6654
6249
|
isinstance(typ, Instance) and typ.type.is_enum
|
|
6655
6250
|
)
|
|
6656
6251
|
|
|
6657
|
-
should_coerce = any(
|
|
6658
|
-
should_coerce_inner(operand_types[i]) for i in chain_indices
|
|
6659
|
-
)
|
|
6252
|
+
should_coerce = any(should_coerce_inner(operand_types[i]) for i in chain_indices)
|
|
6660
6253
|
|
|
6661
6254
|
target: Type | None = None
|
|
6662
6255
|
possible_target_indices = []
|
|
@@ -6769,9 +6362,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
6769
6362
|
non_optional_types.append(typ)
|
|
6770
6363
|
|
|
6771
6364
|
# Make sure we have a mixture of optional and non-optional types.
|
|
6772
|
-
if len(non_optional_types) == 0 or len(non_optional_types) == len(
|
|
6773
|
-
chain_indices
|
|
6774
|
-
):
|
|
6365
|
+
if len(non_optional_types) == 0 or len(non_optional_types) == len(chain_indices):
|
|
6775
6366
|
return {}, {}
|
|
6776
6367
|
|
|
6777
6368
|
if_map = {}
|
|
@@ -6779,9 +6370,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
6779
6370
|
expr_type = operand_types[i]
|
|
6780
6371
|
if not is_overlapping_none(expr_type):
|
|
6781
6372
|
continue
|
|
6782
|
-
if any(
|
|
6783
|
-
is_overlapping_erased_types(expr_type, t) for t in non_optional_types
|
|
6784
|
-
):
|
|
6373
|
+
if any(is_overlapping_erased_types(expr_type, t) for t in non_optional_types):
|
|
6785
6374
|
if_map[operands[i]] = remove_optional(expr_type)
|
|
6786
6375
|
|
|
6787
6376
|
return if_map, {}
|
|
@@ -6839,9 +6428,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
6839
6428
|
return None
|
|
6840
6429
|
return proper_type.value
|
|
6841
6430
|
|
|
6842
|
-
def find_tuple_len_narrowing(
|
|
6843
|
-
self, node: ComparisonExpr
|
|
6844
|
-
) -> list[tuple[TypeMap, TypeMap]]:
|
|
6431
|
+
def find_tuple_len_narrowing(self, node: ComparisonExpr) -> list[tuple[TypeMap, TypeMap]]:
|
|
6845
6432
|
"""Top-level logic to find type restrictions from a length check on tuples.
|
|
6846
6433
|
|
|
6847
6434
|
We try to detect `if` checks like the following:
|
|
@@ -6910,9 +6497,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
6910
6497
|
# Avoid creating huge tuples from checks like if len(x) == 300.
|
|
6911
6498
|
continue
|
|
6912
6499
|
for tpl in tuples:
|
|
6913
|
-
yes_type, no_type = self.narrow_with_len(
|
|
6914
|
-
self.lookup_type(tpl), op, size
|
|
6915
|
-
)
|
|
6500
|
+
yes_type, no_type = self.narrow_with_len(self.lookup_type(tpl), op, size)
|
|
6916
6501
|
yes_map = None if yes_type is None else {tpl: yes_type}
|
|
6917
6502
|
no_map = None if no_type is None else {tpl: no_type}
|
|
6918
6503
|
type_maps.append((yes_map, no_map))
|
|
@@ -6936,9 +6521,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
6936
6521
|
type_maps.append((yes_map, no_map))
|
|
6937
6522
|
return type_maps
|
|
6938
6523
|
|
|
6939
|
-
def narrow_with_len(
|
|
6940
|
-
self, typ: Type, op: str, size: int
|
|
6941
|
-
) -> tuple[Type | None, Type | None]:
|
|
6524
|
+
def narrow_with_len(self, typ: Type, op: str, size: int) -> tuple[Type | None, Type | None]:
|
|
6942
6525
|
"""Dispatch tuple type narrowing logic depending on the kind of type we got."""
|
|
6943
6526
|
typ = get_proper_type(typ)
|
|
6944
6527
|
if isinstance(typ, TupleType):
|
|
@@ -7003,22 +6586,15 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
7003
6586
|
prefix = typ.items[:unpack_index]
|
|
7004
6587
|
suffix = typ.items[unpack_index + 1 :]
|
|
7005
6588
|
# TODO: also record max_len to avoid false negatives?
|
|
7006
|
-
unpack = UnpackType(
|
|
7007
|
-
unpacked.copy_modified(min_len=size - typ.length() + 1)
|
|
7008
|
-
)
|
|
6589
|
+
unpack = UnpackType(unpacked.copy_modified(min_len=size - typ.length() + 1))
|
|
7009
6590
|
return typ, typ.copy_modified(items=prefix + [unpack] + suffix)
|
|
7010
6591
|
return None, typ
|
|
7011
6592
|
else:
|
|
7012
|
-
yes_type, no_type = self.refine_tuple_type_with_len(
|
|
7013
|
-
typ, neg_ops[op], size
|
|
7014
|
-
)
|
|
6593
|
+
yes_type, no_type = self.refine_tuple_type_with_len(typ, neg_ops[op], size)
|
|
7015
6594
|
return no_type, yes_type
|
|
7016
6595
|
# Homogeneous variadic item is the case where we are most flexible. Essentially,
|
|
7017
6596
|
# we adjust the variadic item by "eating away" from it to satisfy the restriction.
|
|
7018
|
-
assert (
|
|
7019
|
-
isinstance(unpacked, Instance)
|
|
7020
|
-
and unpacked.type.fullname == "builtins.tuple"
|
|
7021
|
-
)
|
|
6597
|
+
assert isinstance(unpacked, Instance) and unpacked.type.fullname == "builtins.tuple"
|
|
7022
6598
|
min_len = typ.length() - 1
|
|
7023
6599
|
arg = unpacked.args[0]
|
|
7024
6600
|
prefix = typ.items[:unpack_index]
|
|
@@ -7026,10 +6602,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
7026
6602
|
if op in ("==", "is"):
|
|
7027
6603
|
if min_len <= size:
|
|
7028
6604
|
# TODO: return fixed union + prefixed variadic tuple for no_type?
|
|
7029
|
-
return (
|
|
7030
|
-
typ.copy_modified(items=prefix + [arg] * (size - min_len) + suffix),
|
|
7031
|
-
typ,
|
|
7032
|
-
)
|
|
6605
|
+
return typ.copy_modified(items=prefix + [arg] * (size - min_len) + suffix), typ
|
|
7033
6606
|
return None, typ
|
|
7034
6607
|
elif op in ("<", "<="):
|
|
7035
6608
|
if op == "<=":
|
|
@@ -7043,9 +6616,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
7043
6616
|
)
|
|
7044
6617
|
yes_items = []
|
|
7045
6618
|
for n in range(size - min_len):
|
|
7046
|
-
yes_items.append(
|
|
7047
|
-
typ.copy_modified(items=prefix + [arg] * n + suffix)
|
|
7048
|
-
)
|
|
6619
|
+
yes_items.append(typ.copy_modified(items=prefix + [arg] * n + suffix))
|
|
7049
6620
|
return UnionType.make_union(yes_items, typ.line, typ.column), no_type
|
|
7050
6621
|
return None, typ
|
|
7051
6622
|
else:
|
|
@@ -7070,25 +6641,19 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
7070
6641
|
size += 1
|
|
7071
6642
|
if allow_precise:
|
|
7072
6643
|
unpack = UnpackType(self.named_generic_type("builtins.tuple", [arg]))
|
|
7073
|
-
no_type: Type | None = TupleType(
|
|
7074
|
-
items=[arg] * size + [unpack], fallback=typ
|
|
7075
|
-
)
|
|
6644
|
+
no_type: Type | None = TupleType(items=[arg] * size + [unpack], fallback=typ)
|
|
7076
6645
|
else:
|
|
7077
6646
|
no_type = typ
|
|
7078
6647
|
if allow_precise:
|
|
7079
6648
|
items = []
|
|
7080
6649
|
for n in range(size):
|
|
7081
6650
|
items.append(TupleType([arg] * n, fallback=typ))
|
|
7082
|
-
yes_type: Type | None = UnionType.make_union(
|
|
7083
|
-
items, typ.line, typ.column
|
|
7084
|
-
)
|
|
6651
|
+
yes_type: Type | None = UnionType.make_union(items, typ.line, typ.column)
|
|
7085
6652
|
else:
|
|
7086
6653
|
yes_type = typ
|
|
7087
6654
|
return yes_type, no_type
|
|
7088
6655
|
else:
|
|
7089
|
-
yes_type, no_type = self.refine_instance_type_with_len(
|
|
7090
|
-
typ, neg_ops[op], size
|
|
7091
|
-
)
|
|
6656
|
+
yes_type, no_type = self.refine_instance_type_with_len(typ, neg_ops[op], size)
|
|
7092
6657
|
return no_type, yes_type
|
|
7093
6658
|
|
|
7094
6659
|
#
|
|
@@ -7179,28 +6744,19 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
7179
6744
|
self.msg.note(note, context, code=msg.code)
|
|
7180
6745
|
if note_msg:
|
|
7181
6746
|
self.note(note_msg, context, code=msg.code)
|
|
7182
|
-
self.msg.maybe_note_concatenate_pos_args(
|
|
7183
|
-
subtype, supertype, context, code=msg.code
|
|
7184
|
-
)
|
|
6747
|
+
self.msg.maybe_note_concatenate_pos_args(subtype, supertype, context, code=msg.code)
|
|
7185
6748
|
if (
|
|
7186
6749
|
isinstance(supertype, Instance)
|
|
7187
6750
|
and supertype.type.is_protocol
|
|
7188
6751
|
and isinstance(subtype, (CallableType, Instance, TupleType, TypedDictType))
|
|
7189
6752
|
):
|
|
7190
|
-
self.msg.report_protocol_problems(
|
|
7191
|
-
subtype, supertype, context, code=msg.code
|
|
7192
|
-
)
|
|
6753
|
+
self.msg.report_protocol_problems(subtype, supertype, context, code=msg.code)
|
|
7193
6754
|
if isinstance(supertype, CallableType) and isinstance(subtype, Instance):
|
|
7194
6755
|
call = find_member("__call__", subtype, subtype, is_operator=True)
|
|
7195
6756
|
if call:
|
|
7196
6757
|
self.msg.note_call(subtype, call, context, code=msg.code)
|
|
7197
|
-
if isinstance(subtype, (CallableType, Overloaded)) and isinstance(
|
|
7198
|
-
supertype
|
|
7199
|
-
):
|
|
7200
|
-
if (
|
|
7201
|
-
supertype.type.is_protocol
|
|
7202
|
-
and "__call__" in supertype.type.protocol_members
|
|
7203
|
-
):
|
|
6758
|
+
if isinstance(subtype, (CallableType, Overloaded)) and isinstance(supertype, Instance):
|
|
6759
|
+
if supertype.type.is_protocol and "__call__" in supertype.type.protocol_members:
|
|
7204
6760
|
call = find_member("__call__", supertype, subtype, is_operator=True)
|
|
7205
6761
|
assert call is not None
|
|
7206
6762
|
if not is_subtype(subtype, call, options=self.options):
|
|
@@ -7208,9 +6764,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
7208
6764
|
self.check_possible_missing_await(subtype, supertype, context, code=msg.code)
|
|
7209
6765
|
return False
|
|
7210
6766
|
|
|
7211
|
-
def get_precise_awaitable_type(
|
|
7212
|
-
self, typ: Type, local_errors: ErrorWatcher
|
|
7213
|
-
) -> Type | None:
|
|
6767
|
+
def get_precise_awaitable_type(self, typ: Type, local_errors: ErrorWatcher) -> Type | None:
|
|
7214
6768
|
"""If type implements Awaitable[X] with non-Any X, return X.
|
|
7215
6769
|
|
|
7216
6770
|
In all other cases return None. This method must be called in context
|
|
@@ -7342,9 +6896,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
7342
6896
|
- No otherwise.
|
|
7343
6897
|
"""
|
|
7344
6898
|
return (
|
|
7345
|
-
self.options.check_untyped_defs
|
|
7346
|
-
or not self.dynamic_funcs
|
|
7347
|
-
or not self.dynamic_funcs[-1]
|
|
6899
|
+
self.options.check_untyped_defs or not self.dynamic_funcs or not self.dynamic_funcs[-1]
|
|
7348
6900
|
)
|
|
7349
6901
|
|
|
7350
6902
|
def lookup(self, name: str) -> SymbolTableNode:
|
|
@@ -7368,9 +6920,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
7368
6920
|
n = self.modules[parts[0]]
|
|
7369
6921
|
for i in range(1, len(parts) - 1):
|
|
7370
6922
|
sym = n.names.get(parts[i])
|
|
7371
|
-
assert
|
|
7372
|
-
sym is not None
|
|
7373
|
-
), "Internal error: attempted lookup of unknown name"
|
|
6923
|
+
assert sym is not None, "Internal error: attempted lookup of unknown name"
|
|
7374
6924
|
assert isinstance(sym.node, MypyFile)
|
|
7375
6925
|
n = sym.node
|
|
7376
6926
|
last = parts[-1]
|
|
@@ -7402,9 +6952,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
7402
6952
|
Also report errors for (some) variables which still have partial
|
|
7403
6953
|
types, i.e. we couldn't infer a complete type.
|
|
7404
6954
|
"""
|
|
7405
|
-
is_local = (
|
|
7406
|
-
self.partial_types and self.partial_types[-1].is_local
|
|
7407
|
-
) or is_function
|
|
6955
|
+
is_local = (self.partial_types and self.partial_types[-1].is_local) or is_function
|
|
7408
6956
|
self.partial_types.append(PartialTypeScope({}, is_function, is_local))
|
|
7409
6957
|
yield
|
|
7410
6958
|
|
|
@@ -7412,9 +6960,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
7412
6960
|
# at the toplevel (with allow_untyped_globals) or if it is in an
|
|
7413
6961
|
# untyped function being checked with check_untyped_defs.
|
|
7414
6962
|
permissive = (self.options.allow_untyped_globals and not is_local) or (
|
|
7415
|
-
self.options.check_untyped_defs
|
|
7416
|
-
and self.dynamic_funcs
|
|
7417
|
-
and self.dynamic_funcs[-1]
|
|
6963
|
+
self.options.check_untyped_defs and self.dynamic_funcs and self.dynamic_funcs[-1]
|
|
7418
6964
|
)
|
|
7419
6965
|
|
|
7420
6966
|
partial_types, _, _ = self.partial_types.pop()
|
|
@@ -7447,9 +6993,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
7447
6993
|
var.type = NoneType()
|
|
7448
6994
|
else:
|
|
7449
6995
|
if var not in self.partial_reported and not permissive:
|
|
7450
|
-
self.msg.need_annotation_for_var(
|
|
7451
|
-
var, context, self.options.python_version
|
|
7452
|
-
)
|
|
6996
|
+
self.msg.need_annotation_for_var(var, context, self.options.python_version)
|
|
7453
6997
|
self.partial_reported.add(var)
|
|
7454
6998
|
if var.type:
|
|
7455
6999
|
fixed = fixup_partial_type(var.type)
|
|
@@ -7518,18 +7062,13 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
7518
7062
|
# for fine-grained incremental mode).
|
|
7519
7063
|
disallow_other_scopes = self.options.local_partial_types
|
|
7520
7064
|
|
|
7521
|
-
if (
|
|
7522
|
-
isinstance(var.type, PartialType)
|
|
7523
|
-
and var.type.type is not None
|
|
7524
|
-
and var.info
|
|
7525
|
-
):
|
|
7065
|
+
if isinstance(var.type, PartialType) and var.type.type is not None and var.info:
|
|
7526
7066
|
# This is an ugly hack to make partial generic self attributes behave
|
|
7527
7067
|
# as if --local-partial-types is always on (because it used to be like this).
|
|
7528
7068
|
disallow_other_scopes = True
|
|
7529
7069
|
|
|
7530
7070
|
scope_active = (
|
|
7531
|
-
not disallow_other_scopes
|
|
7532
|
-
or scope.is_local == self.partial_types[-1].is_local
|
|
7071
|
+
not disallow_other_scopes or scope.is_local == self.partial_types[-1].is_local
|
|
7533
7072
|
)
|
|
7534
7073
|
return scope_active, scope.is_local, scope.map
|
|
7535
7074
|
return False, False, None
|
|
@@ -7539,11 +7078,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
7539
7078
|
return TempNode(t, context=context)
|
|
7540
7079
|
|
|
7541
7080
|
def fail(
|
|
7542
|
-
self,
|
|
7543
|
-
msg: str | ErrorMessage,
|
|
7544
|
-
context: Context,
|
|
7545
|
-
*,
|
|
7546
|
-
code: ErrorCode | None = None,
|
|
7081
|
+
self, msg: str | ErrorMessage, context: Context, *, code: ErrorCode | None = None
|
|
7547
7082
|
) -> None:
|
|
7548
7083
|
"""Produce an error message."""
|
|
7549
7084
|
if isinstance(msg, ErrorMessage):
|
|
@@ -7569,9 +7104,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
7569
7104
|
self, it: Instance | CallableType | TypeType | Overloaded, context: Context
|
|
7570
7105
|
) -> Type:
|
|
7571
7106
|
if isinstance(it, Instance):
|
|
7572
|
-
iterable = map_instance_to_supertype(
|
|
7573
|
-
it, self.lookup_typeinfo("typing.Iterable")
|
|
7574
|
-
)
|
|
7107
|
+
iterable = map_instance_to_supertype(it, self.lookup_typeinfo("typing.Iterable"))
|
|
7575
7108
|
item_type = iterable.args[0]
|
|
7576
7109
|
if not isinstance(get_proper_type(item_type), AnyType):
|
|
7577
7110
|
# This relies on 'map_instance_to_supertype' returning 'Iterable[Any]'
|
|
@@ -7590,9 +7123,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
7590
7123
|
for expr, type in type_map.items():
|
|
7591
7124
|
self.binder.put(expr, type)
|
|
7592
7125
|
|
|
7593
|
-
def infer_issubclass_maps(
|
|
7594
|
-
self, node: CallExpr, expr: Expression
|
|
7595
|
-
) -> tuple[TypeMap, TypeMap]:
|
|
7126
|
+
def infer_issubclass_maps(self, node: CallExpr, expr: Expression) -> tuple[TypeMap, TypeMap]:
|
|
7596
7127
|
"""Infer type restrictions for an expression in issubclass call."""
|
|
7597
7128
|
vartype = self.lookup_type(expr)
|
|
7598
7129
|
type = self.get_isinstance_type(node.args[1])
|
|
@@ -7617,9 +7148,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
7617
7148
|
# Any other object whose type we don't know precisely
|
|
7618
7149
|
# for example, Any or a custom metaclass.
|
|
7619
7150
|
return {}, {} # unknown type
|
|
7620
|
-
yes_type, no_type = self.conditional_types_with_intersection(
|
|
7621
|
-
vartype, type, expr
|
|
7622
|
-
)
|
|
7151
|
+
yes_type, no_type = self.conditional_types_with_intersection(vartype, type, expr)
|
|
7623
7152
|
yes_map, no_map = conditional_types_to_typemaps(expr, yes_type, no_type)
|
|
7624
7153
|
yes_map, no_map = map(convert_to_typetype, (yes_map, no_map))
|
|
7625
7154
|
return yes_map, no_map
|
|
@@ -7635,11 +7164,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
7635
7164
|
|
|
7636
7165
|
@overload
|
|
7637
7166
|
def conditional_types_with_intersection(
|
|
7638
|
-
self,
|
|
7639
|
-
expr_type: Type,
|
|
7640
|
-
type_ranges: list[TypeRange] | None,
|
|
7641
|
-
ctx: Context,
|
|
7642
|
-
default: Type,
|
|
7167
|
+
self, expr_type: Type, type_ranges: list[TypeRange] | None, ctx: Context, default: Type
|
|
7643
7168
|
) -> tuple[Type, Type]: ...
|
|
7644
7169
|
|
|
7645
7170
|
def conditional_types_with_intersection(
|
|
@@ -7655,10 +7180,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
7655
7180
|
yes_type: Type | None = initial_types[0]
|
|
7656
7181
|
no_type: Type | None = initial_types[1]
|
|
7657
7182
|
|
|
7658
|
-
if (
|
|
7659
|
-
not isinstance(get_proper_type(yes_type), UninhabitedType)
|
|
7660
|
-
or type_ranges is None
|
|
7661
|
-
):
|
|
7183
|
+
if not isinstance(get_proper_type(yes_type), UninhabitedType) or type_ranges is None:
|
|
7662
7184
|
return yes_type, no_type
|
|
7663
7185
|
|
|
7664
7186
|
# If conditional_types was unable to successfully narrow the expr_type
|
|
@@ -7686,9 +7208,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
7686
7208
|
return yes_type, no_type
|
|
7687
7209
|
for t in possible_target_types:
|
|
7688
7210
|
if isinstance(t, NoneType):
|
|
7689
|
-
errors.append(
|
|
7690
|
-
(f'"{v.type.name}" and "NoneType"', '"NoneType" is final')
|
|
7691
|
-
)
|
|
7211
|
+
errors.append((f'"{v.type.name}" and "NoneType"', '"NoneType" is final'))
|
|
7692
7212
|
continue
|
|
7693
7213
|
intersection = self.intersect_instances((v, t), errors)
|
|
7694
7214
|
if intersection is None:
|
|
@@ -7779,9 +7299,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
7779
7299
|
|
|
7780
7300
|
parent_type = get_proper_type(parent_type)
|
|
7781
7301
|
member_type = get_proper_type(coerce_to_literal(member_type))
|
|
7782
|
-
if not isinstance(parent_type, FunctionLike) or not isinstance(
|
|
7783
|
-
member_type, LiteralType
|
|
7784
|
-
):
|
|
7302
|
+
if not isinstance(parent_type, FunctionLike) or not isinstance(member_type, LiteralType):
|
|
7785
7303
|
return False
|
|
7786
7304
|
|
|
7787
7305
|
if not parent_type.is_type_obj():
|
|
@@ -7812,9 +7330,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
7812
7330
|
fallback = typ.fallback.copy_with_extra_attr(name, any_type)
|
|
7813
7331
|
return typ.copy_modified(fallback=fallback)
|
|
7814
7332
|
if isinstance(typ, TypeType) and isinstance(typ.item, Instance):
|
|
7815
|
-
return TypeType.make_normalized(
|
|
7816
|
-
self.add_any_attribute_to_type(typ.item, name)
|
|
7817
|
-
)
|
|
7333
|
+
return TypeType.make_normalized(self.add_any_attribute_to_type(typ.item, name))
|
|
7818
7334
|
if isinstance(typ, TypeVarType):
|
|
7819
7335
|
return typ.copy_modified(
|
|
7820
7336
|
upper_bound=self.add_any_attribute_to_type(typ.upper_bound, name),
|
|
@@ -7823,8 +7339,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
7823
7339
|
if isinstance(typ, UnionType):
|
|
7824
7340
|
with_attr, without_attr = self.partition_union_by_attr(typ, name)
|
|
7825
7341
|
return make_simplified_union(
|
|
7826
|
-
with_attr
|
|
7827
|
-
+ [self.add_any_attribute_to_type(typ, name) for typ in without_attr]
|
|
7342
|
+
with_attr + [self.add_any_attribute_to_type(typ, name) for typ in without_attr]
|
|
7828
7343
|
)
|
|
7829
7344
|
return orig_typ
|
|
7830
7345
|
|
|
@@ -7869,11 +7384,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
7869
7384
|
p_typ = get_proper_type(typ)
|
|
7870
7385
|
if isinstance(p_typ, AnyType):
|
|
7871
7386
|
return False
|
|
7872
|
-
if (
|
|
7873
|
-
isinstance(p_typ, Instance)
|
|
7874
|
-
and p_typ.extra_attrs
|
|
7875
|
-
and p_typ.extra_attrs.mod_name
|
|
7876
|
-
):
|
|
7387
|
+
if isinstance(p_typ, Instance) and p_typ.extra_attrs and p_typ.extra_attrs.mod_name:
|
|
7877
7388
|
# Presence of module_symbol_table means this check will skip ModuleType.__getattr__
|
|
7878
7389
|
module_symbol_table = p_typ.type.names
|
|
7879
7390
|
else:
|
|
@@ -7895,9 +7406,7 @@ class TypeChecker(NodeVisitor[None], CheckerPluginInterface):
|
|
|
7895
7406
|
)
|
|
7896
7407
|
return not watcher.has_new_errors()
|
|
7897
7408
|
|
|
7898
|
-
def get_expression_type(
|
|
7899
|
-
self, node: Expression, type_context: Type | None = None
|
|
7900
|
-
) -> Type:
|
|
7409
|
+
def get_expression_type(self, node: Expression, type_context: Type | None = None) -> Type:
|
|
7901
7410
|
return self.expr_checker.accept(node, type_context=type_context)
|
|
7902
7411
|
|
|
7903
7412
|
|
|
@@ -7913,9 +7422,7 @@ class CollectArgTypeVarTypes(TypeTraverserVisitor):
|
|
|
7913
7422
|
|
|
7914
7423
|
@overload
|
|
7915
7424
|
def conditional_types(
|
|
7916
|
-
current_type: Type,
|
|
7917
|
-
proposed_type_ranges: list[TypeRange] | None,
|
|
7918
|
-
default: None = None,
|
|
7425
|
+
current_type: Type, proposed_type_ranges: list[TypeRange] | None, default: None = None
|
|
7919
7426
|
) -> tuple[Type | None, Type | None]: ...
|
|
7920
7427
|
|
|
7921
7428
|
|
|
@@ -7926,9 +7433,7 @@ def conditional_types(
|
|
|
7926
7433
|
|
|
7927
7434
|
|
|
7928
7435
|
def conditional_types(
|
|
7929
|
-
current_type: Type,
|
|
7930
|
-
proposed_type_ranges: list[TypeRange] | None,
|
|
7931
|
-
default: Type | None = None,
|
|
7436
|
+
current_type: Type, proposed_type_ranges: list[TypeRange] | None, default: Type | None = None
|
|
7932
7437
|
) -> tuple[Type | None, Type | None]:
|
|
7933
7438
|
"""Takes in the current type and a proposed type of an expression.
|
|
7934
7439
|
|
|
@@ -7959,10 +7464,7 @@ def conditional_types(
|
|
|
7959
7464
|
# Expression is always of one of the types in proposed_type_ranges
|
|
7960
7465
|
return default, UninhabitedType()
|
|
7961
7466
|
elif not is_overlapping_types(
|
|
7962
|
-
current_type,
|
|
7963
|
-
proposed_type,
|
|
7964
|
-
prohibit_none_typevar_overlap=True,
|
|
7965
|
-
ignore_promotions=True,
|
|
7467
|
+
current_type, proposed_type, prohibit_none_typevar_overlap=True, ignore_promotions=True
|
|
7966
7468
|
):
|
|
7967
7469
|
# Expression is never of any type in proposed_type_ranges
|
|
7968
7470
|
return UninhabitedType(), default
|
|
@@ -8012,20 +7514,12 @@ def gen_unique_name(base: str, table: SymbolTable) -> str:
|
|
|
8012
7514
|
|
|
8013
7515
|
def is_true_literal(n: Expression) -> bool:
|
|
8014
7516
|
"""Returns true if this expression is the 'True' literal/keyword."""
|
|
8015
|
-
return (
|
|
8016
|
-
refers_to_fullname(n, "builtins.True")
|
|
8017
|
-
or isinstance(n, IntExpr)
|
|
8018
|
-
and n.value != 0
|
|
8019
|
-
)
|
|
7517
|
+
return refers_to_fullname(n, "builtins.True") or isinstance(n, IntExpr) and n.value != 0
|
|
8020
7518
|
|
|
8021
7519
|
|
|
8022
7520
|
def is_false_literal(n: Expression) -> bool:
|
|
8023
7521
|
"""Returns true if this expression is the 'False' literal/keyword."""
|
|
8024
|
-
return (
|
|
8025
|
-
refers_to_fullname(n, "builtins.False")
|
|
8026
|
-
or isinstance(n, IntExpr)
|
|
8027
|
-
and n.value == 0
|
|
8028
|
-
)
|
|
7522
|
+
return refers_to_fullname(n, "builtins.False") or isinstance(n, IntExpr) and n.value == 0
|
|
8029
7523
|
|
|
8030
7524
|
|
|
8031
7525
|
def is_literal_none(n: Expression) -> bool:
|
|
@@ -8093,18 +7587,13 @@ def builtin_item_type(tp: Type) -> Type | None:
|
|
|
8093
7587
|
if isinstance(unpacked, TypeVarTupleType):
|
|
8094
7588
|
unpacked = get_proper_type(unpacked.upper_bound)
|
|
8095
7589
|
assert (
|
|
8096
|
-
isinstance(unpacked, Instance)
|
|
8097
|
-
and unpacked.type.fullname == "builtins.tuple"
|
|
7590
|
+
isinstance(unpacked, Instance) and unpacked.type.fullname == "builtins.tuple"
|
|
8098
7591
|
)
|
|
8099
7592
|
normalized_items.append(unpacked.args[0])
|
|
8100
7593
|
else:
|
|
8101
7594
|
normalized_items.append(it)
|
|
8102
|
-
if all(
|
|
8103
|
-
|
|
8104
|
-
):
|
|
8105
|
-
return make_simplified_union(
|
|
8106
|
-
normalized_items
|
|
8107
|
-
) # this type is not externally visible
|
|
7595
|
+
if all(not isinstance(it, AnyType) for it in get_proper_types(normalized_items)):
|
|
7596
|
+
return make_simplified_union(normalized_items) # this type is not externally visible
|
|
8108
7597
|
elif isinstance(tp, TypedDictType):
|
|
8109
7598
|
# TypedDict always has non-optional string keys. Find the key type from the Mapping
|
|
8110
7599
|
# base class.
|
|
@@ -8132,9 +7621,7 @@ def and_conditional_maps(m1: TypeMap, m2: TypeMap, use_meet: bool = False) -> Ty
|
|
|
8132
7621
|
result = m2.copy()
|
|
8133
7622
|
m2_keys = {literal_hash(n2) for n2 in m2}
|
|
8134
7623
|
for n1 in m1:
|
|
8135
|
-
if literal_hash(n1) not in m2_keys or isinstance(
|
|
8136
|
-
get_proper_type(m1[n1]), AnyType
|
|
8137
|
-
):
|
|
7624
|
+
if literal_hash(n1) not in m2_keys or isinstance(get_proper_type(m1[n1]), AnyType):
|
|
8138
7625
|
result[n1] = m1[n1]
|
|
8139
7626
|
if use_meet:
|
|
8140
7627
|
# For now, meet common keys only if specifically requested.
|
|
@@ -8147,9 +7634,7 @@ def and_conditional_maps(m1: TypeMap, m2: TypeMap, use_meet: bool = False) -> Ty
|
|
|
8147
7634
|
return result
|
|
8148
7635
|
|
|
8149
7636
|
|
|
8150
|
-
def or_conditional_maps(
|
|
8151
|
-
m1: TypeMap, m2: TypeMap, coalesce_any: bool = False
|
|
8152
|
-
) -> TypeMap:
|
|
7637
|
+
def or_conditional_maps(m1: TypeMap, m2: TypeMap, coalesce_any: bool = False) -> TypeMap:
|
|
8153
7638
|
"""Calculate what information we can learn from the truth of (e1 or e2)
|
|
8154
7639
|
in terms of the information that we can learn from the truth of e1 and
|
|
8155
7640
|
the truth of e2. If coalesce_any is True, consider Any a supertype when
|
|
@@ -8338,9 +7823,7 @@ def is_unsafe_overlapping_overload_signatures(
|
|
|
8338
7823
|
)
|
|
8339
7824
|
|
|
8340
7825
|
|
|
8341
|
-
def detach_callable(
|
|
8342
|
-
typ: CallableType, class_type_vars: list[TypeVarLikeType]
|
|
8343
|
-
) -> CallableType:
|
|
7826
|
+
def detach_callable(typ: CallableType, class_type_vars: list[TypeVarLikeType]) -> CallableType:
|
|
8344
7827
|
"""Ensures that the callable's type variables are 'detached' and independent of the context.
|
|
8345
7828
|
|
|
8346
7829
|
A callable normally keeps track of the type variables it uses within its 'variables' field.
|
|
@@ -8359,8 +7842,7 @@ def detach_callable(
|
|
|
8359
7842
|
for t in typ.arg_types + [typ.ret_type]:
|
|
8360
7843
|
seen_type_vars |= set(get_type_vars(t))
|
|
8361
7844
|
return typ.copy_modified(
|
|
8362
|
-
variables=list(typ.variables)
|
|
8363
|
-
+ [tv for tv in class_type_vars if tv in seen_type_vars]
|
|
7845
|
+
variables=list(typ.variables) + [tv for tv in class_type_vars if tv in seen_type_vars]
|
|
8364
7846
|
)
|
|
8365
7847
|
|
|
8366
7848
|
|
|
@@ -8380,15 +7862,10 @@ def overload_can_never_match(signature: CallableType, other: CallableType) -> bo
|
|
|
8380
7862
|
# returns `True`.
|
|
8381
7863
|
# TODO: find a cleaner solution instead of this ad-hoc erasure.
|
|
8382
7864
|
exp_signature = expand_type(
|
|
8383
|
-
signature,
|
|
8384
|
-
{tvar.id: erase_def_to_union_or_bound(tvar) for tvar in signature.variables},
|
|
7865
|
+
signature, {tvar.id: erase_def_to_union_or_bound(tvar) for tvar in signature.variables}
|
|
8385
7866
|
)
|
|
8386
7867
|
return is_callable_compatible(
|
|
8387
|
-
exp_signature,
|
|
8388
|
-
other,
|
|
8389
|
-
is_compat=is_more_precise,
|
|
8390
|
-
is_proper_subtype=True,
|
|
8391
|
-
ignore_return=True,
|
|
7868
|
+
exp_signature, other, is_compat=is_more_precise, is_proper_subtype=True, ignore_return=True
|
|
8392
7869
|
)
|
|
8393
7870
|
|
|
8394
7871
|
|
|
@@ -8399,18 +7876,13 @@ def is_more_general_arg_prefix(t: FunctionLike, s: FunctionLike) -> bool:
|
|
|
8399
7876
|
if isinstance(t, CallableType):
|
|
8400
7877
|
if isinstance(s, CallableType):
|
|
8401
7878
|
return is_callable_compatible(
|
|
8402
|
-
t,
|
|
8403
|
-
s,
|
|
8404
|
-
is_compat=is_proper_subtype,
|
|
8405
|
-
is_proper_subtype=True,
|
|
8406
|
-
ignore_return=True,
|
|
7879
|
+
t, s, is_compat=is_proper_subtype, is_proper_subtype=True, ignore_return=True
|
|
8407
7880
|
)
|
|
8408
7881
|
elif isinstance(t, FunctionLike):
|
|
8409
7882
|
if isinstance(s, FunctionLike):
|
|
8410
7883
|
if len(t.items) == len(s.items):
|
|
8411
7884
|
return all(
|
|
8412
|
-
is_same_arg_prefix(items, itemt)
|
|
8413
|
-
for items, itemt in zip(t.items, s.items)
|
|
7885
|
+
is_same_arg_prefix(items, itemt) for items, itemt in zip(t.items, s.items)
|
|
8414
7886
|
)
|
|
8415
7887
|
return False
|
|
8416
7888
|
|
|
@@ -8736,9 +8208,7 @@ def group_comparison_operands(
|
|
|
8736
8208
|
This function is currently only used to assist with type-narrowing refinements
|
|
8737
8209
|
and is extracted out to a helper function so we can unit test it.
|
|
8738
8210
|
"""
|
|
8739
|
-
groups: dict[str, DisjointDict[Key, int]] = {
|
|
8740
|
-
op: DisjointDict() for op in operators_to_group
|
|
8741
|
-
}
|
|
8211
|
+
groups: dict[str, DisjointDict[Key, int]] = {op: DisjointDict() for op in operators_to_group}
|
|
8742
8212
|
|
|
8743
8213
|
simplified_operator_list: list[tuple[str, list[int]]] = []
|
|
8744
8214
|
last_operator: str | None = None
|
|
@@ -8748,15 +8218,11 @@ def group_comparison_operands(
|
|
|
8748
8218
|
if last_operator is None:
|
|
8749
8219
|
last_operator = operator
|
|
8750
8220
|
|
|
8751
|
-
if current_indices and (
|
|
8752
|
-
operator != last_operator or operator not in operators_to_group
|
|
8753
|
-
):
|
|
8221
|
+
if current_indices and (operator != last_operator or operator not in operators_to_group):
|
|
8754
8222
|
# If some of the operands in the chain are assignable, defer adding it: we might
|
|
8755
8223
|
# end up needing to merge it with other chains that appear later.
|
|
8756
8224
|
if not current_hashes:
|
|
8757
|
-
simplified_operator_list.append(
|
|
8758
|
-
(last_operator, sorted(current_indices))
|
|
8759
|
-
)
|
|
8225
|
+
simplified_operator_list.append((last_operator, sorted(current_indices)))
|
|
8760
8226
|
else:
|
|
8761
8227
|
groups[last_operator].add_mapping(current_hashes, current_indices)
|
|
8762
8228
|
last_operator = operator
|
|
@@ -8858,9 +8324,7 @@ def is_subtype_no_promote(left: Type, right: Type) -> bool:
|
|
|
8858
8324
|
return is_subtype(left, right, ignore_promotions=True)
|
|
8859
8325
|
|
|
8860
8326
|
|
|
8861
|
-
def is_overlapping_types_no_promote_no_uninhabited_no_none(
|
|
8862
|
-
left: Type, right: Type
|
|
8863
|
-
) -> bool:
|
|
8327
|
+
def is_overlapping_types_no_promote_no_uninhabited_no_none(left: Type, right: Type) -> bool:
|
|
8864
8328
|
# For the purpose of unsafe overload checks we consider list[Never] and list[int]
|
|
8865
8329
|
# non-overlapping. This is consistent with how we treat list[int] and list[str] as
|
|
8866
8330
|
# non-overlapping, despite [] belongs to both. Also this will prevent false positives
|