@gnost-cli/darwin-arm64 0.0.1 → 0.5.1-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/bundle/_internal/6ec57f84c680d3a3778b__mypyc.cpython-312-darwin.so +4 -0
- package/bundle/_internal/Python +0 -0
- package/bundle/_internal/Python.framework/Python +0 -0
- package/bundle/_internal/Python.framework/Resources/Info.plist +30 -0
- package/bundle/_internal/Python.framework/Versions/3.12/Python +0 -0
- package/bundle/_internal/Python.framework/Versions/3.12/Resources/Info.plist +30 -0
- package/bundle/_internal/Python.framework/Versions/Current/Python +0 -0
- package/bundle/_internal/Python.framework/Versions/Current/Resources/Info.plist +30 -0
- package/bundle/_internal/ast_serialize/ast_serialize.abi3.so +0 -0
- package/bundle/_internal/bandit/__init__.py +20 -0
- package/bundle/_internal/bandit/__main__.py +17 -0
- package/bundle/_internal/bandit/blacklists/__init__.py +0 -0
- package/bundle/_internal/bandit/blacklists/calls.py +670 -0
- package/bundle/_internal/bandit/blacklists/imports.py +425 -0
- package/bundle/_internal/bandit/blacklists/utils.py +17 -0
- package/bundle/_internal/bandit/cli/__init__.py +0 -0
- package/bundle/_internal/bandit/cli/baseline.py +252 -0
- package/bundle/_internal/bandit/cli/config_generator.py +207 -0
- package/bundle/_internal/bandit/cli/main.py +701 -0
- package/bundle/_internal/bandit/core/__init__.py +15 -0
- package/bundle/_internal/bandit/core/blacklisting.py +72 -0
- package/bundle/_internal/bandit/core/config.py +271 -0
- package/bundle/_internal/bandit/core/constants.py +40 -0
- package/bundle/_internal/bandit/core/context.py +316 -0
- package/bundle/_internal/bandit/core/docs_utils.py +54 -0
- package/bundle/_internal/bandit/core/extension_loader.py +114 -0
- package/bundle/_internal/bandit/core/issue.py +245 -0
- package/bundle/_internal/bandit/core/manager.py +499 -0
- package/bundle/_internal/bandit/core/meta_ast.py +44 -0
- package/bundle/_internal/bandit/core/metrics.py +106 -0
- package/bundle/_internal/bandit/core/node_visitor.py +297 -0
- package/bundle/_internal/bandit/core/test_properties.py +83 -0
- package/bundle/_internal/bandit/core/test_set.py +114 -0
- package/bundle/_internal/bandit/core/tester.py +168 -0
- package/bundle/_internal/bandit/core/utils.py +398 -0
- package/bundle/_internal/bandit/formatters/__init__.py +0 -0
- package/bundle/_internal/bandit/formatters/csv.py +82 -0
- package/bundle/_internal/bandit/formatters/custom.py +161 -0
- package/bundle/_internal/bandit/formatters/html.py +394 -0
- package/bundle/_internal/bandit/formatters/json.py +155 -0
- package/bundle/_internal/bandit/formatters/sarif.py +374 -0
- package/bundle/_internal/bandit/formatters/screen.py +244 -0
- package/bundle/_internal/bandit/formatters/text.py +200 -0
- package/bundle/_internal/bandit/formatters/utils.py +14 -0
- package/bundle/_internal/bandit/formatters/xml.py +97 -0
- package/bundle/_internal/bandit/formatters/yaml.py +126 -0
- package/bundle/_internal/bandit/plugins/__init__.py +0 -0
- package/bundle/_internal/bandit/plugins/app_debug.py +63 -0
- package/bundle/_internal/bandit/plugins/asserts.py +83 -0
- package/bundle/_internal/bandit/plugins/crypto_request_no_cert_validation.py +75 -0
- package/bundle/_internal/bandit/plugins/django_sql_injection.py +155 -0
- package/bundle/_internal/bandit/plugins/django_xss.py +287 -0
- package/bundle/_internal/bandit/plugins/exec.py +55 -0
- package/bundle/_internal/bandit/plugins/general_bad_file_permissions.py +99 -0
- package/bundle/_internal/bandit/plugins/general_bind_all_interfaces.py +52 -0
- package/bundle/_internal/bandit/plugins/general_hardcoded_password.py +282 -0
- package/bundle/_internal/bandit/plugins/general_hardcoded_tmp.py +79 -0
- package/bundle/_internal/bandit/plugins/hashlib_insecure_functions.py +121 -0
- package/bundle/_internal/bandit/plugins/huggingface_unsafe_download.py +166 -0
- package/bundle/_internal/bandit/plugins/injection_paramiko.py +63 -0
- package/bundle/_internal/bandit/plugins/injection_shell.py +706 -0
- package/bundle/_internal/bandit/plugins/injection_sql.py +143 -0
- package/bundle/_internal/bandit/plugins/injection_wildcard.py +144 -0
- package/bundle/_internal/bandit/plugins/insecure_ssl_tls.py +285 -0
- package/bundle/_internal/bandit/plugins/jinja2_templates.py +134 -0
- package/bundle/_internal/bandit/plugins/logging_config_insecure_listen.py +58 -0
- package/bundle/_internal/bandit/plugins/mako_templates.py +69 -0
- package/bundle/_internal/bandit/plugins/markupsafe_markup_xss.py +118 -0
- package/bundle/_internal/bandit/plugins/pytorch_load.py +77 -0
- package/bundle/_internal/bandit/plugins/request_without_timeout.py +84 -0
- package/bundle/_internal/bandit/plugins/snmp_security_check.py +110 -0
- package/bundle/_internal/bandit/plugins/ssh_no_host_key_verification.py +76 -0
- package/bundle/_internal/bandit/plugins/tarfile_unsafe_members.py +121 -0
- package/bundle/_internal/bandit/plugins/trojansource.py +82 -0
- package/bundle/_internal/bandit/plugins/try_except_continue.py +108 -0
- package/bundle/_internal/bandit/plugins/try_except_pass.py +106 -0
- package/bundle/_internal/bandit/plugins/weak_cryptographic_key.py +165 -0
- package/bundle/_internal/bandit/plugins/yaml_load.py +76 -0
- package/bundle/_internal/bandit-1.9.4.dist-info/INSTALLER +1 -0
- package/bundle/_internal/bandit-1.9.4.dist-info/METADATA +212 -0
- package/bundle/_internal/bandit-1.9.4.dist-info/RECORD +150 -0
- package/bundle/_internal/bandit-1.9.4.dist-info/WHEEL +5 -0
- package/bundle/_internal/bandit-1.9.4.dist-info/entry_points.txt +63 -0
- package/bundle/_internal/bandit-1.9.4.dist-info/licenses/LICENSE +175 -0
- package/bundle/_internal/bandit-1.9.4.dist-info/pbr.json +1 -0
- package/bundle/_internal/bandit-1.9.4.dist-info/top_level.txt +1 -0
- package/bundle/_internal/base_library.zip +0 -0
- package/bundle/_internal/bin/ruff +0 -0
- package/bundle/_internal/gnost/__init__.py +1 -0
- package/bundle/_internal/gnost/analysis/__init__.py +0 -0
- package/bundle/_internal/gnost/analysis/analyzers/__init__.py +11 -0
- package/bundle/_internal/gnost/analysis/analyzers/maintainability_analyzer.py +901 -0
- package/bundle/_internal/gnost/analysis/analyzers/observability_analyzer.py +592 -0
- package/bundle/_internal/gnost/analysis/analyzers/readability_analyzer.py +968 -0
- package/bundle/_internal/gnost/analysis/analyzers/robustness_analyzer.py +944 -0
- package/bundle/_internal/gnost/analysis/config/mypy.ini +4 -0
- package/bundle/_internal/gnost/analysis/core/__init__.py +0 -0
- package/bundle/_internal/gnost/analysis/core/aggregator.py +584 -0
- package/bundle/_internal/gnost/analysis/core/engine.py +430 -0
- package/bundle/_internal/gnost/analysis/core/file_utils.py +209 -0
- package/bundle/_internal/gnost/analysis/core/interfaces.py +304 -0
- package/bundle/_internal/gnost/analysis/core/models.py +479 -0
- package/bundle/_internal/gnost/analysis/core/tool_runner.py +153 -0
- package/bundle/_internal/gnost/analysis/core/transformers.py +779 -0
- package/bundle/_internal/gnost/analysis/utils/__init__.py +0 -0
- package/bundle/_internal/gnost/analysis/utils/analyze.py +132 -0
- package/bundle/_internal/gnost/analysis/utils/df_handling.py +215 -0
- package/bundle/_internal/gnost/analysis/utils/duplicate_code.py +42 -0
- package/bundle/_internal/gnost/analysis/utils/extract.py +172 -0
- package/bundle/_internal/gnost/analysis/utils/mi.py +130 -0
- package/bundle/_internal/gnost/analysis/utils/tool_command.py +63 -0
- package/bundle/_internal/gnost/cli/__init__.py +3 -0
- package/bundle/_internal/gnost/cli/app.py +696 -0
- package/bundle/_internal/gnost/cli/commands/__init__.py +3 -0
- package/bundle/_internal/gnost/cli/commands/analysis.py +190 -0
- package/bundle/_internal/gnost/cli/commands/onboard.py +507 -0
- package/bundle/_internal/gnost/cli/commands/show.py +70 -0
- package/bundle/_internal/gnost/config/__init__.py +0 -0
- package/bundle/_internal/gnost/config/languages.py +10 -0
- package/bundle/_internal/gnost/config/settings.py +240 -0
- package/bundle/_internal/gnost/core/__init__.py +0 -0
- package/bundle/_internal/gnost/core/callgraph.py +399 -0
- package/bundle/_internal/gnost/core/caution.py +315 -0
- package/bundle/_internal/gnost/core/cycles.py +148 -0
- package/bundle/_internal/gnost/core/flow.py +204 -0
- package/bundle/_internal/gnost/core/graph.py +108 -0
- package/bundle/_internal/gnost/core/insight_builder.py +164 -0
- package/bundle/_internal/gnost/core/ranker.py +119 -0
- package/bundle/_internal/gnost/core/resolver.py +304 -0
- package/bundle/_internal/gnost/languages/base.py +108 -0
- package/bundle/_internal/gnost/languages/java.py +104 -0
- package/bundle/_internal/gnost/languages/javascript.py +153 -0
- package/bundle/_internal/gnost/languages/manifests.py +45 -0
- package/bundle/_internal/gnost/languages/python.py +318 -0
- package/bundle/_internal/gnost/languages/typescript.py +6 -0
- package/bundle/_internal/gnost/models/__init__.py +0 -0
- package/bundle/_internal/gnost/models/insights.py +68 -0
- package/bundle/_internal/gnost/reporters/__init__.py +3 -0
- package/bundle/_internal/gnost/reporters/analysis_html.py +1292 -0
- package/bundle/_internal/gnost/reporters/diagram_viewer.py +153 -0
- package/bundle/_internal/gnost/reporters/files.py +18 -0
- package/bundle/_internal/gnost/reporters/folders.py +18 -0
- package/bundle/_internal/gnost/reporters/insights_json.py +189 -0
- package/bundle/_internal/gnost/reporters/loc_summary.py +19 -0
- package/bundle/_internal/gnost/reporters/markdown.py +372 -0
- package/bundle/_internal/gnost/reporters/mermaid.py +543 -0
- package/bundle/_internal/gnost/reporters/mermaid_graph.py +309 -0
- package/bundle/_internal/gnost/reporters/readme.py +81 -0
- package/bundle/_internal/gnost/reporters/stats.py +13 -0
- package/bundle/_internal/gnost/reporters/summary.py +223 -0
- package/bundle/_internal/gnost/reporters/templates/analyzer_guides.json +247 -0
- package/bundle/_internal/gnost/reporters/templates/analyzer_guides_layout.html +9 -0
- package/bundle/_internal/gnost/reporters/templates/graph_viewer.html +427 -0
- package/bundle/_internal/gnost/reporters/vendor/THIRD_PARTY_NOTICES.md +205 -0
- package/bundle/_internal/gnost/reporters/vendor/cose-base.js +3214 -0
- package/bundle/_internal/gnost/reporters/vendor/cytoscape-fcose.js +1549 -0
- package/bundle/_internal/gnost/reporters/vendor/cytoscape.min.js +32 -0
- package/bundle/_internal/gnost/reporters/vendor/layout-base.js +5230 -0
- package/bundle/_internal/gnost/reporters/vendor/marked.min.js +6 -0
- package/bundle/_internal/gnost/reporters/vendor/mermaid.min.js +2314 -0
- package/bundle/_internal/gnost/reporters/vendor/svg-pan-zoom.min.js +3 -0
- package/bundle/_internal/gnost/reporters/vendor/vendor.json +44 -0
- package/bundle/_internal/gnost/routes/__init__.py +45 -0
- package/bundle/_internal/gnost/routes/java.py +72 -0
- package/bundle/_internal/gnost/routes/javascript.py +275 -0
- package/bundle/_internal/gnost/routes/models.py +58 -0
- package/bundle/_internal/gnost/routes/python.py +429 -0
- package/bundle/_internal/gnost/scanner/__init__.py +4 -0
- package/bundle/_internal/gnost/scanner/classify.py +13 -0
- package/bundle/_internal/gnost/scanner/engine.py +169 -0
- package/bundle/_internal/gnost/scanner/filters.py +197 -0
- package/bundle/_internal/gnost/scanner/loc.py +93 -0
- package/bundle/_internal/gnost/scanner/models.py +27 -0
- package/bundle/_internal/gnost/schemas/insights.schema.json +517 -0
- package/bundle/_internal/gnost/utils/__init__.py +0 -0
- package/bundle/_internal/gnost/utils/logger.py +85 -0
- package/bundle/_internal/gnost/utils/paths.py +29 -0
- package/bundle/_internal/gnost/utils/printer.py +46 -0
- package/bundle/_internal/gnost/utils/progress.py +20 -0
- package/bundle/_internal/gnost-0.5.1rc2.dist-info/INSTALLER +1 -0
- package/bundle/_internal/gnost-0.5.1rc2.dist-info/METADATA +130 -0
- package/bundle/_internal/gnost-0.5.1rc2.dist-info/RECORD +178 -0
- package/bundle/_internal/gnost-0.5.1rc2.dist-info/REQUESTED +0 -0
- package/bundle/_internal/gnost-0.5.1rc2.dist-info/WHEEL +5 -0
- package/bundle/_internal/gnost-0.5.1rc2.dist-info/direct_url.json +1 -0
- package/bundle/_internal/gnost-0.5.1rc2.dist-info/entry_points.txt +2 -0
- package/bundle/_internal/gnost-0.5.1rc2.dist-info/licenses/LICENSE +21 -0
- package/bundle/_internal/gnost-0.5.1rc2.dist-info/top_level.txt +1 -0
- package/bundle/_internal/libcrypto.3.dylib +0 -0
- package/bundle/_internal/libncurses.6.dylib +0 -0
- package/bundle/_internal/librt/base64.cpython-312-darwin.so +0 -0
- package/bundle/_internal/librt/internal.cpython-312-darwin.so +0 -0
- package/bundle/_internal/libssl.3.dylib +0 -0
- package/bundle/_internal/mypy/__init__.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/__init__.py +1 -0
- package/bundle/_internal/mypy/__main__.py +52 -0
- package/bundle/_internal/mypy/api.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/api.py +95 -0
- package/bundle/_internal/mypy/applytype.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/applytype.py +317 -0
- package/bundle/_internal/mypy/argmap.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/argmap.py +269 -0
- package/bundle/_internal/mypy/binder.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/binder.py +710 -0
- package/bundle/_internal/mypy/bogus_type.py +27 -0
- package/bundle/_internal/mypy/build.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/build.py +5533 -0
- package/bundle/_internal/mypy/build_worker/__init__.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/build_worker/__init__.py +0 -0
- package/bundle/_internal/mypy/build_worker/__main__.py +6 -0
- package/bundle/_internal/mypy/build_worker/worker.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/build_worker/worker.py +379 -0
- package/bundle/_internal/mypy/cache.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/cache.py +626 -0
- package/bundle/_internal/mypy/checker.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/checker.py +10110 -0
- package/bundle/_internal/mypy/checker_shared.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/checker_shared.py +377 -0
- package/bundle/_internal/mypy/checker_state.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/checker_state.py +30 -0
- package/bundle/_internal/mypy/checkexpr.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/checkexpr.py +7018 -0
- package/bundle/_internal/mypy/checkmember.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/checkmember.py +1593 -0
- package/bundle/_internal/mypy/checkpattern.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/checkpattern.py +883 -0
- package/bundle/_internal/mypy/checkstrformat.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/checkstrformat.py +1103 -0
- package/bundle/_internal/mypy/config_parser.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/config_parser.py +749 -0
- package/bundle/_internal/mypy/constant_fold.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/constant_fold.py +187 -0
- package/bundle/_internal/mypy/constraints.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/constraints.py +1748 -0
- package/bundle/_internal/mypy/copytype.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/copytype.py +137 -0
- package/bundle/_internal/mypy/defaults.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/defaults.py +67 -0
- package/bundle/_internal/mypy/dmypy/__init__.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/dmypy/__init__.py +0 -0
- package/bundle/_internal/mypy/dmypy/__main__.py +6 -0
- package/bundle/_internal/mypy/dmypy/client.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/dmypy/client.py +732 -0
- package/bundle/_internal/mypy/dmypy_os.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/dmypy_os.py +43 -0
- package/bundle/_internal/mypy/dmypy_server.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/dmypy_server.py +1132 -0
- package/bundle/_internal/mypy/dmypy_util.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/dmypy_util.py +117 -0
- package/bundle/_internal/mypy/erasetype.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/erasetype.py +301 -0
- package/bundle/_internal/mypy/error_formatter.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/error_formatter.py +39 -0
- package/bundle/_internal/mypy/errorcodes.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/errorcodes.py +340 -0
- package/bundle/_internal/mypy/errors.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/errors.py +1468 -0
- package/bundle/_internal/mypy/evalexpr.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/evalexpr.py +211 -0
- package/bundle/_internal/mypy/expandtype.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/expandtype.py +662 -0
- package/bundle/_internal/mypy/exportjson.py +616 -0
- package/bundle/_internal/mypy/exprtotype.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/exprtotype.py +285 -0
- package/bundle/_internal/mypy/fastparse.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/fastparse.py +2267 -0
- package/bundle/_internal/mypy/find_sources.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/find_sources.py +257 -0
- package/bundle/_internal/mypy/fixup.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/fixup.py +438 -0
- package/bundle/_internal/mypy/freetree.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/freetree.py +23 -0
- package/bundle/_internal/mypy/fscache.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/fscache.py +312 -0
- package/bundle/_internal/mypy/fswatcher.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/fswatcher.py +106 -0
- package/bundle/_internal/mypy/gclogger.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/gclogger.py +48 -0
- package/bundle/_internal/mypy/git.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/git.py +69 -0
- package/bundle/_internal/mypy/graph_utils.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/graph_utils.py +161 -0
- package/bundle/_internal/mypy/indirection.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/indirection.py +176 -0
- package/bundle/_internal/mypy/infer.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/infer.py +80 -0
- package/bundle/_internal/mypy/inspections.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/inspections.py +626 -0
- package/bundle/_internal/mypy/ipc.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/ipc.py +508 -0
- package/bundle/_internal/mypy/join.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/join.py +962 -0
- package/bundle/_internal/mypy/known_modules.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/known_modules.py +174 -0
- package/bundle/_internal/mypy/literals.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/literals.py +327 -0
- package/bundle/_internal/mypy/lookup.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/lookup.py +80 -0
- package/bundle/_internal/mypy/main.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/main.py +1793 -0
- package/bundle/_internal/mypy/maptype.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/maptype.py +109 -0
- package/bundle/_internal/mypy/meet.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/meet.py +1371 -0
- package/bundle/_internal/mypy/memprofile.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/memprofile.py +122 -0
- package/bundle/_internal/mypy/message_registry.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/message_registry.py +378 -0
- package/bundle/_internal/mypy/messages.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/messages.py +3535 -0
- package/bundle/_internal/mypy/metastore.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/metastore.py +278 -0
- package/bundle/_internal/mypy/mixedtraverser.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/mixedtraverser.py +147 -0
- package/bundle/_internal/mypy/modulefinder.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/modulefinder.py +1008 -0
- package/bundle/_internal/mypy/moduleinspect.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/moduleinspect.py +184 -0
- package/bundle/_internal/mypy/modules_state.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/modules_state.py +20 -0
- package/bundle/_internal/mypy/mro.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/mro.py +62 -0
- package/bundle/_internal/mypy/nativeparse.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/nativeparse.py +2199 -0
- package/bundle/_internal/mypy/nodes.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/nodes.py +5608 -0
- package/bundle/_internal/mypy/operators.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/operators.py +126 -0
- package/bundle/_internal/mypy/options.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/options.py +678 -0
- package/bundle/_internal/mypy/parse.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/parse.py +135 -0
- package/bundle/_internal/mypy/partially_defined.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/partially_defined.py +703 -0
- package/bundle/_internal/mypy/patterns.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/patterns.py +162 -0
- package/bundle/_internal/mypy/plugin.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/plugin.py +945 -0
- package/bundle/_internal/mypy/plugins/__init__.py +0 -0
- package/bundle/_internal/mypy/plugins/attrs.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/plugins/attrs.py +1179 -0
- package/bundle/_internal/mypy/plugins/common.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/plugins/common.py +441 -0
- package/bundle/_internal/mypy/plugins/constants.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/plugins/constants.py +20 -0
- package/bundle/_internal/mypy/plugins/ctypes.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/plugins/ctypes.py +245 -0
- package/bundle/_internal/mypy/plugins/dataclasses.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/plugins/dataclasses.py +1135 -0
- package/bundle/_internal/mypy/plugins/default.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/plugins/default.py +612 -0
- package/bundle/_internal/mypy/plugins/enums.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/plugins/enums.py +299 -0
- package/bundle/_internal/mypy/plugins/functools.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/plugins/functools.py +399 -0
- package/bundle/_internal/mypy/plugins/proper_plugin.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/plugins/proper_plugin.py +178 -0
- package/bundle/_internal/mypy/plugins/singledispatch.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/plugins/singledispatch.py +212 -0
- package/bundle/_internal/mypy/py.typed +1 -0
- package/bundle/_internal/mypy/pyinfo.py +79 -0
- package/bundle/_internal/mypy/reachability.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/reachability.py +388 -0
- package/bundle/_internal/mypy/refinfo.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/refinfo.py +92 -0
- package/bundle/_internal/mypy/renaming.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/renaming.py +583 -0
- package/bundle/_internal/mypy/report.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/report.py +930 -0
- package/bundle/_internal/mypy/scope.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/scope.py +125 -0
- package/bundle/_internal/mypy/semanal.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/semanal.py +8674 -0
- package/bundle/_internal/mypy/semanal_classprop.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/semanal_classprop.py +188 -0
- package/bundle/_internal/mypy/semanal_enum.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/semanal_enum.py +259 -0
- package/bundle/_internal/mypy/semanal_infer.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/semanal_infer.py +135 -0
- package/bundle/_internal/mypy/semanal_main.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/semanal_main.py +542 -0
- package/bundle/_internal/mypy/semanal_namedtuple.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/semanal_namedtuple.py +679 -0
- package/bundle/_internal/mypy/semanal_newtype.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/semanal_newtype.py +272 -0
- package/bundle/_internal/mypy/semanal_pass1.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/semanal_pass1.py +159 -0
- package/bundle/_internal/mypy/semanal_shared.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/semanal_shared.py +499 -0
- package/bundle/_internal/mypy/semanal_typeargs.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/semanal_typeargs.py +309 -0
- package/bundle/_internal/mypy/semanal_typeddict.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/semanal_typeddict.py +826 -0
- package/bundle/_internal/mypy/server/__init__.py +0 -0
- package/bundle/_internal/mypy/server/astdiff.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/server/astdiff.py +552 -0
- package/bundle/_internal/mypy/server/astmerge.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/server/astmerge.py +583 -0
- package/bundle/_internal/mypy/server/aststrip.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/server/aststrip.py +255 -0
- package/bundle/_internal/mypy/server/deps.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/server/deps.py +1153 -0
- package/bundle/_internal/mypy/server/mergecheck.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/server/mergecheck.py +84 -0
- package/bundle/_internal/mypy/server/objgraph.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/server/objgraph.py +101 -0
- package/bundle/_internal/mypy/server/subexpr.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/server/subexpr.py +208 -0
- package/bundle/_internal/mypy/server/target.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/server/target.py +11 -0
- package/bundle/_internal/mypy/server/trigger.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/server/trigger.py +26 -0
- package/bundle/_internal/mypy/server/update.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/server/update.py +1372 -0
- package/bundle/_internal/mypy/sharedparse.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/sharedparse.py +114 -0
- package/bundle/_internal/mypy/solve.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/solve.py +602 -0
- package/bundle/_internal/mypy/split_namespace.py +35 -0
- package/bundle/_internal/mypy/state.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/state.py +29 -0
- package/bundle/_internal/mypy/stats.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/stats.py +494 -0
- package/bundle/_internal/mypy/strconv.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/strconv.py +707 -0
- package/bundle/_internal/mypy/stubdoc.py +545 -0
- package/bundle/_internal/mypy/stubgen.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/stubgen.py +2064 -0
- package/bundle/_internal/mypy/stubgenc.py +1046 -0
- package/bundle/_internal/mypy/stubinfo.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/stubinfo.py +321 -0
- package/bundle/_internal/mypy/stubtest.py +2676 -0
- package/bundle/_internal/mypy/stubutil.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/stubutil.py +895 -0
- package/bundle/_internal/mypy/subtypes.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/subtypes.py +2572 -0
- package/bundle/_internal/mypy/suggestions.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/suggestions.py +1068 -0
- package/bundle/_internal/mypy/test/__init__.py +0 -0
- package/bundle/_internal/mypy/test/config.py +31 -0
- package/bundle/_internal/mypy/test/data.py +864 -0
- package/bundle/_internal/mypy/test/helpers.py +546 -0
- package/bundle/_internal/mypy/test/meta/__init__.py +0 -0
- package/bundle/_internal/mypy/test/meta/_pytest.py +72 -0
- package/bundle/_internal/mypy/test/meta/test_diff_helper.py +47 -0
- package/bundle/_internal/mypy/test/meta/test_parse_data.py +69 -0
- package/bundle/_internal/mypy/test/meta/test_update_data.py +131 -0
- package/bundle/_internal/mypy/test/test_config_parser.py +130 -0
- package/bundle/_internal/mypy/test/test_diff_cache.py +209 -0
- package/bundle/_internal/mypy/test/test_find_sources.py +376 -0
- package/bundle/_internal/mypy/test/test_nativeparse.py +306 -0
- package/bundle/_internal/mypy/test/test_ref_info.py +46 -0
- package/bundle/_internal/mypy/test/testapi.py +45 -0
- package/bundle/_internal/mypy/test/testargs.py +202 -0
- package/bundle/_internal/mypy/test/testcheck.py +360 -0
- package/bundle/_internal/mypy/test/testcmdline.py +162 -0
- package/bundle/_internal/mypy/test/testconstraints.py +134 -0
- package/bundle/_internal/mypy/test/testdaemon.py +132 -0
- package/bundle/_internal/mypy/test/testdeps.py +85 -0
- package/bundle/_internal/mypy/test/testdiff.py +70 -0
- package/bundle/_internal/mypy/test/testerrorstream.py +46 -0
- package/bundle/_internal/mypy/test/testexportjson.py +104 -0
- package/bundle/_internal/mypy/test/testfinegrained.py +453 -0
- package/bundle/_internal/mypy/test/testfinegrainedcache.py +18 -0
- package/bundle/_internal/mypy/test/testformatter.py +85 -0
- package/bundle/_internal/mypy/test/testfscache.py +100 -0
- package/bundle/_internal/mypy/test/testgraph.py +138 -0
- package/bundle/_internal/mypy/test/testinfer.py +373 -0
- package/bundle/_internal/mypy/test/testipc.py +154 -0
- package/bundle/_internal/mypy/test/testmerge.py +235 -0
- package/bundle/_internal/mypy/test/testmodulefinder.py +284 -0
- package/bundle/_internal/mypy/test/testmypyc.py +26 -0
- package/bundle/_internal/mypy/test/testoutput.py +64 -0
- package/bundle/_internal/mypy/test/testparse.py +131 -0
- package/bundle/_internal/mypy/test/testpep561.py +174 -0
- package/bundle/_internal/mypy/test/testpythoneval.py +116 -0
- package/bundle/_internal/mypy/test/testreports.py +59 -0
- package/bundle/_internal/mypy/test/testsemanal.py +219 -0
- package/bundle/_internal/mypy/test/testsolve.py +287 -0
- package/bundle/_internal/mypy/test/teststubgen.py +1650 -0
- package/bundle/_internal/mypy/test/teststubinfo.py +24 -0
- package/bundle/_internal/mypy/test/teststubtest.py +3417 -0
- package/bundle/_internal/mypy/test/testsubtypes.py +306 -0
- package/bundle/_internal/mypy/test/testtransform.py +64 -0
- package/bundle/_internal/mypy/test/testtypegen.py +83 -0
- package/bundle/_internal/mypy/test/testtypes.py +1666 -0
- package/bundle/_internal/mypy/test/testutil.py +111 -0
- package/bundle/_internal/mypy/test/typefixture.py +419 -0
- package/bundle/_internal/mypy/test/update_data.py +87 -0
- package/bundle/_internal/mypy/test/visitors.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/test/visitors.py +77 -0
- package/bundle/_internal/mypy/traverser.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/traverser.py +1106 -0
- package/bundle/_internal/mypy/treetransform.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/treetransform.py +820 -0
- package/bundle/_internal/mypy/tvar_scope.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/tvar_scope.py +154 -0
- package/bundle/_internal/mypy/type_visitor.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/type_visitor.py +630 -0
- package/bundle/_internal/mypy/typeanal.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/typeanal.py +2961 -0
- package/bundle/_internal/mypy/typeops.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/typeops.py +1355 -0
- package/bundle/_internal/mypy/types.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/types.py +4639 -0
- package/bundle/_internal/mypy/types_utils.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/types_utils.py +183 -0
- package/bundle/_internal/mypy/typeshed/LICENSE +237 -0
- package/bundle/_internal/mypy/typeshed/stdlib/VERSIONS +349 -0
- package/bundle/_internal/mypy/typeshed/stdlib/__future__.pyi +36 -0
- package/bundle/_internal/mypy/typeshed/stdlib/__main__.pyi +1 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_ast.pyi +141 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_asyncio.pyi +114 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_bisect.pyi +103 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_blake2.pyi +119 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_bz2.pyi +24 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_codecs.pyi +125 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_collections_abc.pyi +105 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_compat_pickle.pyi +10 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_compression.pyi +39 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_contextvars.pyi +69 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_csv.pyi +116 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_ctypes.pyi +375 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_curses.pyi +583 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_curses_panel.pyi +27 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_dbm.pyi +46 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_decimal.pyi +73 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_frozen_importlib.pyi +121 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_frozen_importlib_external.pyi +218 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_gdbm.pyi +50 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_hashlib.pyi +127 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_heapq.pyi +18 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_imp.pyi +30 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_interpchannels.pyi +86 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_interpqueues.pyi +31 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_interpreters.pyi +68 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_io.pyi +330 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_json.pyi +59 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_locale.pyi +121 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_lsprof.pyi +34 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_lzma.pyi +71 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_markupbase.pyi +10 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_msi.pyi +97 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_multibytecodec.pyi +49 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_operator.pyi +130 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_osx_support.pyi +34 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_pickle.pyi +114 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_posixsubprocess.pyi +59 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_py_abc.pyi +14 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_pydecimal.pyi +50 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_queue.pyi +18 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_random.pyi +14 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_remote_debugging.pyi +186 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_sitebuiltins.pyi +18 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_socket.pyi +966 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_sqlite3.pyi +311 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_ssl.pyi +303 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_stat.pyi +119 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_struct.pyi +24 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_thread.pyi +125 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_threading_local.pyi +24 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_tkinter.pyi +156 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_tracemalloc.pyi +13 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_typeshed/README.md +34 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_typeshed/__init__.pyi +415 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_typeshed/_type_checker_internals.pyi +102 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_typeshed/dbapi.pyi +36 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_typeshed/importlib.pyi +18 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_typeshed/wsgi.pyi +43 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_typeshed/xml.pyi +9 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_warnings.pyi +54 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_weakref.pyi +15 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_weakrefset.pyi +49 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_winapi.pyi +319 -0
- package/bundle/_internal/mypy/typeshed/stdlib/_zstd.pyi +102 -0
- package/bundle/_internal/mypy/typeshed/stdlib/abc.pyi +50 -0
- package/bundle/_internal/mypy/typeshed/stdlib/aifc.pyi +79 -0
- package/bundle/_internal/mypy/typeshed/stdlib/annotationlib.pyi +156 -0
- package/bundle/_internal/mypy/typeshed/stdlib/antigravity.pyi +3 -0
- package/bundle/_internal/mypy/typeshed/stdlib/argparse.pyi +866 -0
- package/bundle/_internal/mypy/typeshed/stdlib/array.pyi +113 -0
- package/bundle/_internal/mypy/typeshed/stdlib/ast.pyi +2199 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asynchat.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/__init__.pyi +1022 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/base_events.pyi +607 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/base_futures.pyi +17 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/base_subprocess.pyi +62 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/base_tasks.pyi +17 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/constants.pyi +20 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/coroutines.pyi +45 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/events.pyi +803 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/exceptions.pyi +44 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/format_helpers.pyi +31 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/futures.pyi +19 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/graph.pyi +29 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/locks.pyi +83 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/log.pyi +3 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/mixins.pyi +9 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/proactor_events.pyi +53 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/protocols.pyi +39 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/queues.pyi +45 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/runners.pyi +41 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/selector_events.pyi +10 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/sslproto.pyi +164 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/staggered.pyi +10 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/streams.pyi +124 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/subprocess.pyi +166 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/taskgroups.pyi +41 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/tasks.pyi +315 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/threads.pyi +9 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/timeouts.pyi +20 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/tools.pyi +51 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/transports.pyi +57 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/trsock.pyi +137 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/unix_events.pyi +277 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/windows_events.pyi +122 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncio/windows_utils.pyi +49 -0
- package/bundle/_internal/mypy/typeshed/stdlib/asyncore.pyi +91 -0
- package/bundle/_internal/mypy/typeshed/stdlib/atexit.pyi +11 -0
- package/bundle/_internal/mypy/typeshed/stdlib/audioop.pyi +44 -0
- package/bundle/_internal/mypy/typeshed/stdlib/base64.pyi +124 -0
- package/bundle/_internal/mypy/typeshed/stdlib/bdb.pyi +139 -0
- package/bundle/_internal/mypy/typeshed/stdlib/binascii.pyi +102 -0
- package/bundle/_internal/mypy/typeshed/stdlib/binhex.pyi +44 -0
- package/bundle/_internal/mypy/typeshed/stdlib/bisect.pyi +4 -0
- package/bundle/_internal/mypy/typeshed/stdlib/builtins.pyi +2470 -0
- package/bundle/_internal/mypy/typeshed/stdlib/bz2.pyi +121 -0
- package/bundle/_internal/mypy/typeshed/stdlib/cProfile.pyi +33 -0
- package/bundle/_internal/mypy/typeshed/stdlib/calendar.pyi +249 -0
- package/bundle/_internal/mypy/typeshed/stdlib/cgi.pyi +120 -0
- package/bundle/_internal/mypy/typeshed/stdlib/cgitb.pyi +32 -0
- package/bundle/_internal/mypy/typeshed/stdlib/chunk.pyi +20 -0
- package/bundle/_internal/mypy/typeshed/stdlib/cmath.pyi +36 -0
- package/bundle/_internal/mypy/typeshed/stdlib/cmd.pyi +46 -0
- package/bundle/_internal/mypy/typeshed/stdlib/code.pyi +55 -0
- package/bundle/_internal/mypy/typeshed/stdlib/codecs.pyi +357 -0
- package/bundle/_internal/mypy/typeshed/stdlib/codeop.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/collections/__init__.pyi +565 -0
- package/bundle/_internal/mypy/typeshed/stdlib/collections/abc.pyi +2 -0
- package/bundle/_internal/mypy/typeshed/stdlib/colorsys.pyi +15 -0
- package/bundle/_internal/mypy/typeshed/stdlib/compileall.pyi +51 -0
- package/bundle/_internal/mypy/typeshed/stdlib/compression/__init__.pyi +0 -0
- package/bundle/_internal/mypy/typeshed/stdlib/compression/_common/__init__.pyi +0 -0
- package/bundle/_internal/mypy/typeshed/stdlib/compression/_common/_streams.pyi +37 -0
- package/bundle/_internal/mypy/typeshed/stdlib/compression/bz2.pyi +1 -0
- package/bundle/_internal/mypy/typeshed/stdlib/compression/gzip.pyi +1 -0
- package/bundle/_internal/mypy/typeshed/stdlib/compression/lzma.pyi +1 -0
- package/bundle/_internal/mypy/typeshed/stdlib/compression/zlib.pyi +1 -0
- package/bundle/_internal/mypy/typeshed/stdlib/compression/zstd/__init__.pyi +94 -0
- package/bundle/_internal/mypy/typeshed/stdlib/compression/zstd/_zstdfile.pyi +117 -0
- package/bundle/_internal/mypy/typeshed/stdlib/concurrent/__init__.pyi +0 -0
- package/bundle/_internal/mypy/typeshed/stdlib/concurrent/futures/__init__.pyi +71 -0
- package/bundle/_internal/mypy/typeshed/stdlib/concurrent/futures/_base.pyi +119 -0
- package/bundle/_internal/mypy/typeshed/stdlib/concurrent/futures/interpreter.pyi +82 -0
- package/bundle/_internal/mypy/typeshed/stdlib/concurrent/futures/process.pyi +248 -0
- package/bundle/_internal/mypy/typeshed/stdlib/concurrent/futures/thread.pyi +143 -0
- package/bundle/_internal/mypy/typeshed/stdlib/concurrent/interpreters/__init__.pyi +68 -0
- package/bundle/_internal/mypy/typeshed/stdlib/concurrent/interpreters/_crossinterp.pyi +30 -0
- package/bundle/_internal/mypy/typeshed/stdlib/concurrent/interpreters/_queues.pyi +74 -0
- package/bundle/_internal/mypy/typeshed/stdlib/configparser.pyi +509 -0
- package/bundle/_internal/mypy/typeshed/stdlib/contextlib.pyi +211 -0
- package/bundle/_internal/mypy/typeshed/stdlib/contextvars.pyi +3 -0
- package/bundle/_internal/mypy/typeshed/stdlib/copy.pyi +37 -0
- package/bundle/_internal/mypy/typeshed/stdlib/copyreg.pyi +20 -0
- package/bundle/_internal/mypy/typeshed/stdlib/crypt.pyi +26 -0
- package/bundle/_internal/mypy/typeshed/stdlib/csv.pyi +153 -0
- package/bundle/_internal/mypy/typeshed/stdlib/ctypes/__init__.pyi +394 -0
- package/bundle/_internal/mypy/typeshed/stdlib/ctypes/_endian.pyi +16 -0
- package/bundle/_internal/mypy/typeshed/stdlib/ctypes/macholib/__init__.pyi +3 -0
- package/bundle/_internal/mypy/typeshed/stdlib/ctypes/macholib/dyld.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/ctypes/macholib/dylib.pyi +14 -0
- package/bundle/_internal/mypy/typeshed/stdlib/ctypes/macholib/framework.pyi +14 -0
- package/bundle/_internal/mypy/typeshed/stdlib/ctypes/util.pyi +11 -0
- package/bundle/_internal/mypy/typeshed/stdlib/ctypes/wintypes.pyi +321 -0
- package/bundle/_internal/mypy/typeshed/stdlib/curses/__init__.pyi +38 -0
- package/bundle/_internal/mypy/typeshed/stdlib/curses/ascii.pyi +62 -0
- package/bundle/_internal/mypy/typeshed/stdlib/curses/has_key.pyi +1 -0
- package/bundle/_internal/mypy/typeshed/stdlib/curses/panel.pyi +1 -0
- package/bundle/_internal/mypy/typeshed/stdlib/curses/textpad.pyi +11 -0
- package/bundle/_internal/mypy/typeshed/stdlib/dataclasses.pyi +401 -0
- package/bundle/_internal/mypy/typeshed/stdlib/datetime.pyi +381 -0
- package/bundle/_internal/mypy/typeshed/stdlib/dbm/__init__.pyi +105 -0
- package/bundle/_internal/mypy/typeshed/stdlib/dbm/dumb.pyi +41 -0
- package/bundle/_internal/mypy/typeshed/stdlib/dbm/gnu.pyi +1 -0
- package/bundle/_internal/mypy/typeshed/stdlib/dbm/ndbm.pyi +1 -0
- package/bundle/_internal/mypy/typeshed/stdlib/dbm/sqlite3.pyi +34 -0
- package/bundle/_internal/mypy/typeshed/stdlib/decimal.pyi +278 -0
- package/bundle/_internal/mypy/typeshed/stdlib/difflib.pyi +157 -0
- package/bundle/_internal/mypy/typeshed/stdlib/dis.pyi +302 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/__init__.pyi +5 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/_msvccompiler.pyi +13 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/archive_util.pyi +36 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/bcppcompiler.pyi +3 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/ccompiler.pyi +182 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/cmd.pyi +238 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/__init__.pyi +41 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/bdist.pyi +27 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/bdist_dumb.pyi +22 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/bdist_msi.pyi +45 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/bdist_packager.pyi +0 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/bdist_rpm.pyi +53 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/build.pyi +34 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/build_clib.pyi +29 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/build_ext.pyi +52 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/build_py.pyi +45 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/build_scripts.pyi +25 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/check.pyi +39 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/clean.pyi +18 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/config.pyi +84 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/install.pyi +67 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/install_data.pyi +20 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/install_egg_info.pyi +19 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/install_headers.pyi +17 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/install_lib.pyi +26 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/install_scripts.pyi +19 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/register.pyi +20 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/sdist.pyi +45 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/command/upload.pyi +18 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/config.pyi +17 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/core.pyi +58 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/cygwinccompiler.pyi +20 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/debug.pyi +3 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/dep_util.pyi +14 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/dir_util.pyi +23 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/dist.pyi +318 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/errors.pyi +19 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/extension.pyi +36 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/fancy_getopt.pyi +45 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/file_util.pyi +40 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/filelist.pyi +61 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/log.pyi +26 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/msvccompiler.pyi +3 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/spawn.pyi +10 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/sysconfig.pyi +32 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/text_file.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/unixccompiler.pyi +3 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/util.pyi +53 -0
- package/bundle/_internal/mypy/typeshed/stdlib/distutils/version.pyi +36 -0
- package/bundle/_internal/mypy/typeshed/stdlib/doctest.pyi +265 -0
- package/bundle/_internal/mypy/typeshed/stdlib/email/__init__.pyi +68 -0
- package/bundle/_internal/mypy/typeshed/stdlib/email/_header_value_parser.pyi +415 -0
- package/bundle/_internal/mypy/typeshed/stdlib/email/_policybase.pyi +80 -0
- package/bundle/_internal/mypy/typeshed/stdlib/email/base64mime.pyi +13 -0
- package/bundle/_internal/mypy/typeshed/stdlib/email/charset.pyi +44 -0
- package/bundle/_internal/mypy/typeshed/stdlib/email/contentmanager.pyi +11 -0
- package/bundle/_internal/mypy/typeshed/stdlib/email/encoders.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/email/errors.pyi +38 -0
- package/bundle/_internal/mypy/typeshed/stdlib/email/feedparser.pyi +24 -0
- package/bundle/_internal/mypy/typeshed/stdlib/email/generator.pyi +79 -0
- package/bundle/_internal/mypy/typeshed/stdlib/email/header.pyi +32 -0
- package/bundle/_internal/mypy/typeshed/stdlib/email/headerregistry.pyi +196 -0
- package/bundle/_internal/mypy/typeshed/stdlib/email/iterators.pyi +15 -0
- package/bundle/_internal/mypy/typeshed/stdlib/email/message.pyi +191 -0
- package/bundle/_internal/mypy/typeshed/stdlib/email/mime/__init__.pyi +0 -0
- package/bundle/_internal/mypy/typeshed/stdlib/email/mime/application.pyi +17 -0
- package/bundle/_internal/mypy/typeshed/stdlib/email/mime/audio.pyi +17 -0
- package/bundle/_internal/mypy/typeshed/stdlib/email/mime/base.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/email/mime/image.pyi +17 -0
- package/bundle/_internal/mypy/typeshed/stdlib/email/mime/message.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/email/mime/multipart.pyi +18 -0
- package/bundle/_internal/mypy/typeshed/stdlib/email/mime/nonmultipart.pyi +5 -0
- package/bundle/_internal/mypy/typeshed/stdlib/email/mime/text.pyi +9 -0
- package/bundle/_internal/mypy/typeshed/stdlib/email/parser.pyi +42 -0
- package/bundle/_internal/mypy/typeshed/stdlib/email/policy.pyi +78 -0
- package/bundle/_internal/mypy/typeshed/stdlib/email/quoprimime.pyi +28 -0
- package/bundle/_internal/mypy/typeshed/stdlib/email/utils.pyi +72 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/__init__.pyi +15 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/aliases.pyi +1 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/ascii.pyi +30 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/base64_codec.pyi +26 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/big5.pyi +23 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/big5hkscs.pyi +23 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/bz2_codec.pyi +26 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/charmap.pyi +33 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp037.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp1006.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp1026.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp1125.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp1140.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp1250.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp1251.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp1252.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp1253.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp1254.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp1255.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp1256.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp1257.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp1258.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp273.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp424.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp437.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp500.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp720.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp737.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp775.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp850.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp852.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp855.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp856.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp857.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp858.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp860.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp861.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp862.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp863.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp864.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp865.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp866.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp869.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp874.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp875.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp932.pyi +23 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp949.pyi +23 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/cp950.pyi +23 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/euc_jis_2004.pyi +23 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/euc_jisx0213.pyi +23 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/euc_jp.pyi +23 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/euc_kr.pyi +23 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/gb18030.pyi +23 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/gb2312.pyi +23 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/gbk.pyi +23 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/hex_codec.pyi +26 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/hp_roman8.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/hz.pyi +23 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/idna.pyi +26 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso2022_jp.pyi +23 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso2022_jp_1.pyi +23 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso2022_jp_2.pyi +23 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso2022_jp_2004.pyi +23 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso2022_jp_3.pyi +23 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso2022_jp_ext.pyi +23 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso2022_kr.pyi +23 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso8859_1.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso8859_10.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso8859_11.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso8859_13.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso8859_14.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso8859_15.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso8859_16.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso8859_2.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso8859_3.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso8859_4.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso8859_5.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso8859_6.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso8859_7.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso8859_8.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/iso8859_9.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/johab.pyi +23 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/koi8_r.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/koi8_t.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/koi8_u.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/kz1048.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/latin_1.pyi +30 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/mac_arabic.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/mac_croatian.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/mac_cyrillic.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/mac_farsi.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/mac_greek.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/mac_iceland.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/mac_latin2.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/mac_roman.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/mac_romanian.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/mac_turkish.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/mbcs.pyi +28 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/oem.pyi +28 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/palmos.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/ptcp154.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/punycode.pyi +33 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/quopri_codec.pyi +26 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/raw_unicode_escape.pyi +23 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/rot_13.pyi +23 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/shift_jis.pyi +23 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/shift_jis_2004.pyi +23 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/shift_jisx0213.pyi +23 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/tis_620.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/undefined.pyi +20 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/unicode_escape.pyi +23 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/utf_16.pyi +20 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/utf_16_be.pyi +26 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/utf_16_le.pyi +26 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/utf_32.pyi +20 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/utf_32_be.pyi +26 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/utf_32_le.pyi +26 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/utf_7.pyi +26 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/utf_8.pyi +26 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/utf_8_sig.pyi +22 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/uu_codec.pyi +28 -0
- package/bundle/_internal/mypy/typeshed/stdlib/encodings/zlib_codec.pyi +26 -0
- package/bundle/_internal/mypy/typeshed/stdlib/ensurepip/__init__.pyi +12 -0
- package/bundle/_internal/mypy/typeshed/stdlib/enum.pyi +374 -0
- package/bundle/_internal/mypy/typeshed/stdlib/errno.pyi +227 -0
- package/bundle/_internal/mypy/typeshed/stdlib/faulthandler.pyi +61 -0
- package/bundle/_internal/mypy/typeshed/stdlib/fcntl.pyi +157 -0
- package/bundle/_internal/mypy/typeshed/stdlib/filecmp.pyi +65 -0
- package/bundle/_internal/mypy/typeshed/stdlib/fileinput.pyi +141 -0
- package/bundle/_internal/mypy/typeshed/stdlib/fnmatch.pyi +16 -0
- package/bundle/_internal/mypy/typeshed/stdlib/fractions.pyi +185 -0
- package/bundle/_internal/mypy/typeshed/stdlib/ftplib.pyi +174 -0
- package/bundle/_internal/mypy/typeshed/stdlib/functools.pyi +287 -0
- package/bundle/_internal/mypy/typeshed/stdlib/gc.pyi +32 -0
- package/bundle/_internal/mypy/typeshed/stdlib/genericpath.pyi +98 -0
- package/bundle/_internal/mypy/typeshed/stdlib/getopt.pyi +27 -0
- package/bundle/_internal/mypy/typeshed/stdlib/getpass.pyi +14 -0
- package/bundle/_internal/mypy/typeshed/stdlib/gettext.pyi +190 -0
- package/bundle/_internal/mypy/typeshed/stdlib/glob.pyi +50 -0
- package/bundle/_internal/mypy/typeshed/stdlib/graphlib.pyi +29 -0
- package/bundle/_internal/mypy/typeshed/stdlib/grp.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/gzip.pyi +181 -0
- package/bundle/_internal/mypy/typeshed/stdlib/hashlib.pyi +112 -0
- package/bundle/_internal/mypy/typeshed/stdlib/heapq.pyi +32 -0
- package/bundle/_internal/mypy/typeshed/stdlib/hmac.pyi +33 -0
- package/bundle/_internal/mypy/typeshed/stdlib/html/__init__.pyi +7 -0
- package/bundle/_internal/mypy/typeshed/stdlib/html/entities.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/html/parser.pyi +40 -0
- package/bundle/_internal/mypy/typeshed/stdlib/http/__init__.pyi +118 -0
- package/bundle/_internal/mypy/typeshed/stdlib/http/client.pyi +318 -0
- package/bundle/_internal/mypy/typeshed/stdlib/http/cookiejar.pyi +158 -0
- package/bundle/_internal/mypy/typeshed/stdlib/http/cookies.pyi +57 -0
- package/bundle/_internal/mypy/typeshed/stdlib/http/server.pyi +139 -0
- package/bundle/_internal/mypy/typeshed/stdlib/imaplib.pyi +212 -0
- package/bundle/_internal/mypy/typeshed/stdlib/imghdr.pyi +18 -0
- package/bundle/_internal/mypy/typeshed/stdlib/imp.pyi +63 -0
- package/bundle/_internal/mypy/typeshed/stdlib/importlib/__init__.pyi +17 -0
- package/bundle/_internal/mypy/typeshed/stdlib/importlib/_abc.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/importlib/_bootstrap.pyi +2 -0
- package/bundle/_internal/mypy/typeshed/stdlib/importlib/_bootstrap_external.pyi +2 -0
- package/bundle/_internal/mypy/typeshed/stdlib/importlib/abc.pyi +165 -0
- package/bundle/_internal/mypy/typeshed/stdlib/importlib/machinery.pyi +43 -0
- package/bundle/_internal/mypy/typeshed/stdlib/importlib/metadata/__init__.pyi +310 -0
- package/bundle/_internal/mypy/typeshed/stdlib/importlib/metadata/_meta.pyi +65 -0
- package/bundle/_internal/mypy/typeshed/stdlib/importlib/metadata/diagnose.pyi +2 -0
- package/bundle/_internal/mypy/typeshed/stdlib/importlib/readers.pyi +69 -0
- package/bundle/_internal/mypy/typeshed/stdlib/importlib/resources/__init__.pyi +81 -0
- package/bundle/_internal/mypy/typeshed/stdlib/importlib/resources/_common.pyi +48 -0
- package/bundle/_internal/mypy/typeshed/stdlib/importlib/resources/_functional.pyi +35 -0
- package/bundle/_internal/mypy/typeshed/stdlib/importlib/resources/abc.pyi +64 -0
- package/bundle/_internal/mypy/typeshed/stdlib/importlib/resources/readers.pyi +14 -0
- package/bundle/_internal/mypy/typeshed/stdlib/importlib/resources/simple.pyi +59 -0
- package/bundle/_internal/mypy/typeshed/stdlib/importlib/simple.pyi +11 -0
- package/bundle/_internal/mypy/typeshed/stdlib/importlib/util.pyi +75 -0
- package/bundle/_internal/mypy/typeshed/stdlib/inspect.pyi +749 -0
- package/bundle/_internal/mypy/typeshed/stdlib/io.pyi +75 -0
- package/bundle/_internal/mypy/typeshed/stdlib/ipaddress.pyi +249 -0
- package/bundle/_internal/mypy/typeshed/stdlib/itertools.pyi +376 -0
- package/bundle/_internal/mypy/typeshed/stdlib/json/__init__.pyi +93 -0
- package/bundle/_internal/mypy/typeshed/stdlib/json/decoder.pyi +50 -0
- package/bundle/_internal/mypy/typeshed/stdlib/json/encoder.pyi +40 -0
- package/bundle/_internal/mypy/typeshed/stdlib/json/scanner.pyi +7 -0
- package/bundle/_internal/mypy/typeshed/stdlib/json/tool.pyi +1 -0
- package/bundle/_internal/mypy/typeshed/stdlib/keyword.pyi +16 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/__init__.pyi +0 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/btm_matcher.pyi +28 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixer_base.pyi +42 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/__init__.pyi +0 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_apply.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_asserts.pyi +10 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_basestring.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_buffer.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_dict.pyi +16 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_except.pyi +14 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_exec.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_execfile.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_exitfunc.pyi +13 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_filter.pyi +9 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_funcattrs.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_future.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_getcwdu.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_has_key.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_idioms.pyi +15 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_import.pyi +16 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_imports.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_imports2.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_input.pyi +11 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_intern.pyi +9 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_isinstance.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_itertools.pyi +9 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_itertools_imports.pyi +7 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_long.pyi +7 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_map.pyi +9 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_metaclass.pyi +17 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_methodattrs.pyi +10 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_ne.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_next.pyi +19 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_nonzero.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_numliterals.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_operator.pyi +12 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_paren.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_print.pyi +12 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_raise.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_raw_input.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_reduce.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_reload.pyi +9 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_renames.pyi +17 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_repr.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_set_literal.pyi +7 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_standarderror.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_sys_exc.pyi +9 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_throw.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_tuple_params.pyi +16 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_types.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_unicode.pyi +12 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_urllib.pyi +15 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_ws_comma.pyi +12 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_xrange.pyi +20 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_xreadlines.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/fixes/fix_zip.pyi +9 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/main.pyi +42 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/pgen2/__init__.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/pgen2/driver.pyi +27 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/pgen2/grammar.pyi +25 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/pgen2/literals.pyi +7 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/pgen2/parse.pyi +30 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/pgen2/pgen.pyi +53 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/pgen2/token.pyi +69 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/pgen2/tokenize.pyi +96 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/pygram.pyi +114 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/pytree.pyi +118 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lib2to3/refactor.pyi +86 -0
- package/bundle/_internal/mypy/typeshed/stdlib/linecache.pyi +18 -0
- package/bundle/_internal/mypy/typeshed/stdlib/locale.pyi +160 -0
- package/bundle/_internal/mypy/typeshed/stdlib/logging/__init__.pyi +674 -0
- package/bundle/_internal/mypy/typeshed/stdlib/logging/config.pyi +141 -0
- package/bundle/_internal/mypy/typeshed/stdlib/logging/handlers.pyi +258 -0
- package/bundle/_internal/mypy/typeshed/stdlib/lzma.pyi +181 -0
- package/bundle/_internal/mypy/typeshed/stdlib/mailbox.pyi +307 -0
- package/bundle/_internal/mypy/typeshed/stdlib/mailcap.pyi +11 -0
- package/bundle/_internal/mypy/typeshed/stdlib/marshal.pyi +51 -0
- package/bundle/_internal/mypy/typeshed/stdlib/math/__init__.pyi +157 -0
- package/bundle/_internal/mypy/typeshed/stdlib/math/integer.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/mimetypes.pyi +56 -0
- package/bundle/_internal/mypy/typeshed/stdlib/mmap.pyi +191 -0
- package/bundle/_internal/mypy/typeshed/stdlib/modulefinder.pyi +68 -0
- package/bundle/_internal/mypy/typeshed/stdlib/msilib/__init__.pyi +177 -0
- package/bundle/_internal/mypy/typeshed/stdlib/msilib/schema.pyi +95 -0
- package/bundle/_internal/mypy/typeshed/stdlib/msilib/sequence.pyi +13 -0
- package/bundle/_internal/mypy/typeshed/stdlib/msilib/text.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/msvcrt.pyi +31 -0
- package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/__init__.pyi +90 -0
- package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/connection.pyi +97 -0
- package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/context.pyi +220 -0
- package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/dummy/__init__.pyi +89 -0
- package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/dummy/connection.pyi +39 -0
- package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/forkserver.pyi +78 -0
- package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/heap.pyi +41 -0
- package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/managers.pyi +390 -0
- package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/pool.pyi +101 -0
- package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/popen_fork.pyi +26 -0
- package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/popen_forkserver.pyi +16 -0
- package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/popen_spawn_posix.pyi +20 -0
- package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/popen_spawn_win32.pyi +30 -0
- package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/process.pyi +57 -0
- package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/queues.pyi +46 -0
- package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/reduction.pyi +95 -0
- package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/resource_sharer.pyi +20 -0
- package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/resource_tracker.pyi +21 -0
- package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/shared_memory.pyi +43 -0
- package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/sharedctypes.pyi +140 -0
- package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/spawn.pyi +32 -0
- package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/synchronize.pyi +63 -0
- package/bundle/_internal/mypy/typeshed/stdlib/multiprocessing/util.pyi +109 -0
- package/bundle/_internal/mypy/typeshed/stdlib/netrc.pyi +23 -0
- package/bundle/_internal/mypy/typeshed/stdlib/nis.pyi +9 -0
- package/bundle/_internal/mypy/typeshed/stdlib/nntplib.pyi +120 -0
- package/bundle/_internal/mypy/typeshed/stdlib/nt.pyi +116 -0
- package/bundle/_internal/mypy/typeshed/stdlib/ntpath.pyi +134 -0
- package/bundle/_internal/mypy/typeshed/stdlib/nturl2path.pyi +6 -0
- package/bundle/_internal/mypy/typeshed/stdlib/numbers.pyi +220 -0
- package/bundle/_internal/mypy/typeshed/stdlib/opcode.pyi +53 -0
- package/bundle/_internal/mypy/typeshed/stdlib/operator.pyi +219 -0
- package/bundle/_internal/mypy/typeshed/stdlib/optparse.pyi +312 -0
- package/bundle/_internal/mypy/typeshed/stdlib/os/__init__.pyi +1878 -0
- package/bundle/_internal/mypy/typeshed/stdlib/os/path.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/ossaudiodev.pyi +132 -0
- package/bundle/_internal/mypy/typeshed/stdlib/pathlib/__init__.pyi +358 -0
- package/bundle/_internal/mypy/typeshed/stdlib/pathlib/types.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/pdb.pyi +275 -0
- package/bundle/_internal/mypy/typeshed/stdlib/pickle.pyi +240 -0
- package/bundle/_internal/mypy/typeshed/stdlib/pickletools.pyi +176 -0
- package/bundle/_internal/mypy/typeshed/stdlib/pipes.pyi +16 -0
- package/bundle/_internal/mypy/typeshed/stdlib/pkgutil.pyi +60 -0
- package/bundle/_internal/mypy/typeshed/stdlib/platform.pyi +100 -0
- package/bundle/_internal/mypy/typeshed/stdlib/plistlib.pyi +84 -0
- package/bundle/_internal/mypy/typeshed/stdlib/poplib.pyi +93 -0
- package/bundle/_internal/mypy/typeshed/stdlib/posix.pyi +427 -0
- package/bundle/_internal/mypy/typeshed/stdlib/posixpath.pyi +230 -0
- package/bundle/_internal/mypy/typeshed/stdlib/pprint.pyi +170 -0
- package/bundle/_internal/mypy/typeshed/stdlib/profile.pyi +31 -0
- package/bundle/_internal/mypy/typeshed/stdlib/profiling/__init__.pyi +3 -0
- package/bundle/_internal/mypy/typeshed/stdlib/profiling/sampling/__init__.pyi +17 -0
- package/bundle/_internal/mypy/typeshed/stdlib/profiling/sampling/collector.pyi +25 -0
- package/bundle/_internal/mypy/typeshed/stdlib/profiling/sampling/gecko_collector.pyi +111 -0
- package/bundle/_internal/mypy/typeshed/stdlib/profiling/sampling/heatmap_collector.pyi +24 -0
- package/bundle/_internal/mypy/typeshed/stdlib/profiling/sampling/jsonl_collector.pyi +15 -0
- package/bundle/_internal/mypy/typeshed/stdlib/profiling/sampling/pstats_collector.pyi +17 -0
- package/bundle/_internal/mypy/typeshed/stdlib/profiling/sampling/stack_collector.pyi +40 -0
- package/bundle/_internal/mypy/typeshed/stdlib/profiling/sampling/string_table.pyi +5 -0
- package/bundle/_internal/mypy/typeshed/stdlib/profiling/tracing.pyi +9 -0
- package/bundle/_internal/mypy/typeshed/stdlib/pstats.pyi +96 -0
- package/bundle/_internal/mypy/typeshed/stdlib/pty.pyi +24 -0
- package/bundle/_internal/mypy/typeshed/stdlib/pwd.pyi +27 -0
- package/bundle/_internal/mypy/typeshed/stdlib/py_compile.pyi +28 -0
- package/bundle/_internal/mypy/typeshed/stdlib/pyclbr.pyi +57 -0
- package/bundle/_internal/mypy/typeshed/stdlib/pydoc.pyi +348 -0
- package/bundle/_internal/mypy/typeshed/stdlib/pydoc_data/__init__.pyi +0 -0
- package/bundle/_internal/mypy/typeshed/stdlib/pydoc_data/module_docs.pyi +3 -0
- package/bundle/_internal/mypy/typeshed/stdlib/pydoc_data/topics.pyi +3 -0
- package/bundle/_internal/mypy/typeshed/stdlib/pyexpat/__init__.pyi +88 -0
- package/bundle/_internal/mypy/typeshed/stdlib/pyexpat/errors.pyi +53 -0
- package/bundle/_internal/mypy/typeshed/stdlib/pyexpat/model.pyi +13 -0
- package/bundle/_internal/mypy/typeshed/stdlib/queue.pyi +55 -0
- package/bundle/_internal/mypy/typeshed/stdlib/quopri.pyi +12 -0
- package/bundle/_internal/mypy/typeshed/stdlib/random.pyi +135 -0
- package/bundle/_internal/mypy/typeshed/stdlib/re.pyi +347 -0
- package/bundle/_internal/mypy/typeshed/stdlib/readline.pyi +39 -0
- package/bundle/_internal/mypy/typeshed/stdlib/reprlib.pyi +64 -0
- package/bundle/_internal/mypy/typeshed/stdlib/resource.pyi +102 -0
- package/bundle/_internal/mypy/typeshed/stdlib/rlcompleter.pyi +9 -0
- package/bundle/_internal/mypy/typeshed/stdlib/runpy.pyi +24 -0
- package/bundle/_internal/mypy/typeshed/stdlib/sched.pyi +34 -0
- package/bundle/_internal/mypy/typeshed/stdlib/secrets.pyi +17 -0
- package/bundle/_internal/mypy/typeshed/stdlib/select.pyi +171 -0
- package/bundle/_internal/mypy/typeshed/stdlib/selectors.pyi +67 -0
- package/bundle/_internal/mypy/typeshed/stdlib/shelve.pyi +110 -0
- package/bundle/_internal/mypy/typeshed/stdlib/shlex.pyi +63 -0
- package/bundle/_internal/mypy/typeshed/stdlib/shutil.pyi +243 -0
- package/bundle/_internal/mypy/typeshed/stdlib/signal.pyi +174 -0
- package/bundle/_internal/mypy/typeshed/stdlib/site.pyi +46 -0
- package/bundle/_internal/mypy/typeshed/stdlib/smtpd.pyi +92 -0
- package/bundle/_internal/mypy/typeshed/stdlib/smtplib.pyi +223 -0
- package/bundle/_internal/mypy/typeshed/stdlib/sndhdr.pyi +14 -0
- package/bundle/_internal/mypy/typeshed/stdlib/socket.pyi +1587 -0
- package/bundle/_internal/mypy/typeshed/stdlib/socketserver.pyi +170 -0
- package/bundle/_internal/mypy/typeshed/stdlib/spwd.pyi +45 -0
- package/bundle/_internal/mypy/typeshed/stdlib/sqlite3/__init__.pyi +510 -0
- package/bundle/_internal/mypy/typeshed/stdlib/sqlite3/dbapi2.pyi +244 -0
- package/bundle/_internal/mypy/typeshed/stdlib/sqlite3/dump.pyi +2 -0
- package/bundle/_internal/mypy/typeshed/stdlib/sre_compile.pyi +12 -0
- package/bundle/_internal/mypy/typeshed/stdlib/sre_constants.pyi +135 -0
- package/bundle/_internal/mypy/typeshed/stdlib/sre_parse.pyi +102 -0
- package/bundle/_internal/mypy/typeshed/stdlib/ssl.pyi +540 -0
- package/bundle/_internal/mypy/typeshed/stdlib/stat.pyi +126 -0
- package/bundle/_internal/mypy/typeshed/stdlib/statistics.pyi +161 -0
- package/bundle/_internal/mypy/typeshed/stdlib/string/__init__.pyi +81 -0
- package/bundle/_internal/mypy/typeshed/stdlib/string/templatelib.pyi +36 -0
- package/bundle/_internal/mypy/typeshed/stdlib/stringprep.pyi +29 -0
- package/bundle/_internal/mypy/typeshed/stdlib/struct.pyi +5 -0
- package/bundle/_internal/mypy/typeshed/stdlib/subprocess.pyi +1484 -0
- package/bundle/_internal/mypy/typeshed/stdlib/sunau.pyi +82 -0
- package/bundle/_internal/mypy/typeshed/stdlib/symtable.pyi +95 -0
- package/bundle/_internal/mypy/typeshed/stdlib/sys/__init__.pyi +538 -0
- package/bundle/_internal/mypy/typeshed/stdlib/sys/__jit.pyi +11 -0
- package/bundle/_internal/mypy/typeshed/stdlib/sys/_monitoring.pyi +69 -0
- package/bundle/_internal/mypy/typeshed/stdlib/sysconfig.pyi +59 -0
- package/bundle/_internal/mypy/typeshed/stdlib/syslog.pyi +58 -0
- package/bundle/_internal/mypy/typeshed/stdlib/tabnanny.pyi +16 -0
- package/bundle/_internal/mypy/typeshed/stdlib/tarfile.pyi +868 -0
- package/bundle/_internal/mypy/typeshed/stdlib/telnetlib.pyi +123 -0
- package/bundle/_internal/mypy/typeshed/stdlib/tempfile.pyi +474 -0
- package/bundle/_internal/mypy/typeshed/stdlib/termios.pyi +303 -0
- package/bundle/_internal/mypy/typeshed/stdlib/textwrap.pyi +103 -0
- package/bundle/_internal/mypy/typeshed/stdlib/this.pyi +2 -0
- package/bundle/_internal/mypy/typeshed/stdlib/threading.pyi +221 -0
- package/bundle/_internal/mypy/typeshed/stdlib/time.pyi +117 -0
- package/bundle/_internal/mypy/typeshed/stdlib/timeit.pyi +46 -0
- package/bundle/_internal/mypy/typeshed/stdlib/tkinter/__init__.pyi +4376 -0
- package/bundle/_internal/mypy/typeshed/stdlib/tkinter/colorchooser.pyi +12 -0
- package/bundle/_internal/mypy/typeshed/stdlib/tkinter/commondialog.pyi +14 -0
- package/bundle/_internal/mypy/typeshed/stdlib/tkinter/constants.pyi +80 -0
- package/bundle/_internal/mypy/typeshed/stdlib/tkinter/dialog.pyi +13 -0
- package/bundle/_internal/mypy/typeshed/stdlib/tkinter/dnd.pyi +19 -0
- package/bundle/_internal/mypy/typeshed/stdlib/tkinter/filedialog.pyi +149 -0
- package/bundle/_internal/mypy/typeshed/stdlib/tkinter/font.pyi +123 -0
- package/bundle/_internal/mypy/typeshed/stdlib/tkinter/messagebox.pyi +98 -0
- package/bundle/_internal/mypy/typeshed/stdlib/tkinter/scrolledtext.pyi +9 -0
- package/bundle/_internal/mypy/typeshed/stdlib/tkinter/simpledialog.pyi +58 -0
- package/bundle/_internal/mypy/typeshed/stdlib/tkinter/tix.pyi +299 -0
- package/bundle/_internal/mypy/typeshed/stdlib/tkinter/ttk.pyi +1434 -0
- package/bundle/_internal/mypy/typeshed/stdlib/token.pyi +166 -0
- package/bundle/_internal/mypy/typeshed/stdlib/tokenize.pyi +201 -0
- package/bundle/_internal/mypy/typeshed/stdlib/tomllib.pyi +27 -0
- package/bundle/_internal/mypy/typeshed/stdlib/trace.pyi +85 -0
- package/bundle/_internal/mypy/typeshed/stdlib/traceback.pyi +293 -0
- package/bundle/_internal/mypy/typeshed/stdlib/tracemalloc.pyi +123 -0
- package/bundle/_internal/mypy/typeshed/stdlib/tty.pyi +29 -0
- package/bundle/_internal/mypy/typeshed/stdlib/turtle.pyi +856 -0
- package/bundle/_internal/mypy/typeshed/stdlib/types.pyi +744 -0
- package/bundle/_internal/mypy/typeshed/stdlib/typing.pyi +1250 -0
- package/bundle/_internal/mypy/typeshed/stdlib/typing_extensions.pyi +749 -0
- package/bundle/_internal/mypy/typeshed/stdlib/unicodedata.pyi +94 -0
- package/bundle/_internal/mypy/typeshed/stdlib/unittest/__init__.pyi +63 -0
- package/bundle/_internal/mypy/typeshed/stdlib/unittest/_log.pyi +29 -0
- package/bundle/_internal/mypy/typeshed/stdlib/unittest/async_case.pyi +24 -0
- package/bundle/_internal/mypy/typeshed/stdlib/unittest/case.pyi +352 -0
- package/bundle/_internal/mypy/typeshed/stdlib/unittest/loader.pyi +55 -0
- package/bundle/_internal/mypy/typeshed/stdlib/unittest/main.pyi +74 -0
- package/bundle/_internal/mypy/typeshed/stdlib/unittest/mock.pyi +555 -0
- package/bundle/_internal/mypy/typeshed/stdlib/unittest/result.pyi +46 -0
- package/bundle/_internal/mypy/typeshed/stdlib/unittest/runner.pyi +93 -0
- package/bundle/_internal/mypy/typeshed/stdlib/unittest/signals.pyi +15 -0
- package/bundle/_internal/mypy/typeshed/stdlib/unittest/suite.pyi +23 -0
- package/bundle/_internal/mypy/typeshed/stdlib/unittest/util.pyi +39 -0
- package/bundle/_internal/mypy/typeshed/stdlib/urllib/__init__.pyi +0 -0
- package/bundle/_internal/mypy/typeshed/stdlib/urllib/error.pyi +29 -0
- package/bundle/_internal/mypy/typeshed/stdlib/urllib/parse.pyi +354 -0
- package/bundle/_internal/mypy/typeshed/stdlib/urllib/request.pyi +447 -0
- package/bundle/_internal/mypy/typeshed/stdlib/urllib/response.pyi +45 -0
- package/bundle/_internal/mypy/typeshed/stdlib/urllib/robotparser.pyi +20 -0
- package/bundle/_internal/mypy/typeshed/stdlib/uu.pyi +12 -0
- package/bundle/_internal/mypy/typeshed/stdlib/uuid.pyi +106 -0
- package/bundle/_internal/mypy/typeshed/stdlib/venv/__init__.pyi +86 -0
- package/bundle/_internal/mypy/typeshed/stdlib/warnings.pyi +146 -0
- package/bundle/_internal/mypy/typeshed/stdlib/wave.pyi +105 -0
- package/bundle/_internal/mypy/typeshed/stdlib/weakref.pyi +217 -0
- package/bundle/_internal/mypy/typeshed/stdlib/webbrowser.pyi +93 -0
- package/bundle/_internal/mypy/typeshed/stdlib/winreg.pyi +137 -0
- package/bundle/_internal/mypy/typeshed/stdlib/winsound.pyi +40 -0
- package/bundle/_internal/mypy/typeshed/stdlib/wsgiref/__init__.pyi +0 -0
- package/bundle/_internal/mypy/typeshed/stdlib/wsgiref/handlers.pyi +91 -0
- package/bundle/_internal/mypy/typeshed/stdlib/wsgiref/headers.pyi +27 -0
- package/bundle/_internal/mypy/typeshed/stdlib/wsgiref/simple_server.pyi +37 -0
- package/bundle/_internal/mypy/typeshed/stdlib/wsgiref/types.pyi +31 -0
- package/bundle/_internal/mypy/typeshed/stdlib/wsgiref/util.pyi +26 -0
- package/bundle/_internal/mypy/typeshed/stdlib/wsgiref/validate.pyi +50 -0
- package/bundle/_internal/mypy/typeshed/stdlib/xdrlib.pyi +57 -0
- package/bundle/_internal/mypy/typeshed/stdlib/xml/__init__.pyi +9 -0
- package/bundle/_internal/mypy/typeshed/stdlib/xml/dom/NodeFilter.pyi +22 -0
- package/bundle/_internal/mypy/typeshed/stdlib/xml/dom/__init__.pyi +101 -0
- package/bundle/_internal/mypy/typeshed/stdlib/xml/dom/domreg.pyi +8 -0
- package/bundle/_internal/mypy/typeshed/stdlib/xml/dom/expatbuilder.pyi +126 -0
- package/bundle/_internal/mypy/typeshed/stdlib/xml/dom/minicompat.pyi +24 -0
- package/bundle/_internal/mypy/typeshed/stdlib/xml/dom/minidom.pyi +693 -0
- package/bundle/_internal/mypy/typeshed/stdlib/xml/dom/pulldom.pyi +109 -0
- package/bundle/_internal/mypy/typeshed/stdlib/xml/dom/xmlbuilder.pyi +82 -0
- package/bundle/_internal/mypy/typeshed/stdlib/xml/etree/ElementInclude.pyi +28 -0
- package/bundle/_internal/mypy/typeshed/stdlib/xml/etree/ElementPath.pyi +42 -0
- package/bundle/_internal/mypy/typeshed/stdlib/xml/etree/ElementTree.pyi +402 -0
- package/bundle/_internal/mypy/typeshed/stdlib/xml/etree/__init__.pyi +0 -0
- package/bundle/_internal/mypy/typeshed/stdlib/xml/etree/cElementTree.pyi +1 -0
- package/bundle/_internal/mypy/typeshed/stdlib/xml/parsers/__init__.pyi +1 -0
- package/bundle/_internal/mypy/typeshed/stdlib/xml/parsers/expat/__init__.pyi +7 -0
- package/bundle/_internal/mypy/typeshed/stdlib/xml/parsers/expat/errors.pyi +1 -0
- package/bundle/_internal/mypy/typeshed/stdlib/xml/parsers/expat/model.pyi +1 -0
- package/bundle/_internal/mypy/typeshed/stdlib/xml/sax/__init__.pyi +42 -0
- package/bundle/_internal/mypy/typeshed/stdlib/xml/sax/_exceptions.pyi +19 -0
- package/bundle/_internal/mypy/typeshed/stdlib/xml/sax/expatreader.pyi +72 -0
- package/bundle/_internal/mypy/typeshed/stdlib/xml/sax/handler.pyi +85 -0
- package/bundle/_internal/mypy/typeshed/stdlib/xml/sax/saxutils.pyi +69 -0
- package/bundle/_internal/mypy/typeshed/stdlib/xml/sax/xmlreader.pyi +94 -0
- package/bundle/_internal/mypy/typeshed/stdlib/xml/utils.pyi +2 -0
- package/bundle/_internal/mypy/typeshed/stdlib/xmlrpc/__init__.pyi +0 -0
- package/bundle/_internal/mypy/typeshed/stdlib/xmlrpc/client.pyi +300 -0
- package/bundle/_internal/mypy/typeshed/stdlib/xmlrpc/server.pyi +149 -0
- package/bundle/_internal/mypy/typeshed/stdlib/xxlimited.pyi +15 -0
- package/bundle/_internal/mypy/typeshed/stdlib/zipapp.pyi +19 -0
- package/bundle/_internal/mypy/typeshed/stdlib/zipfile/__init__.pyi +411 -0
- package/bundle/_internal/mypy/typeshed/stdlib/zipfile/_path/__init__.pyi +87 -0
- package/bundle/_internal/mypy/typeshed/stdlib/zipfile/_path/glob.pyi +26 -0
- package/bundle/_internal/mypy/typeshed/stdlib/zipimport.pyi +44 -0
- package/bundle/_internal/mypy/typeshed/stdlib/zlib.pyi +81 -0
- package/bundle/_internal/mypy/typeshed/stdlib/zoneinfo/__init__.pyi +36 -0
- package/bundle/_internal/mypy/typeshed/stdlib/zoneinfo/_common.pyi +14 -0
- package/bundle/_internal/mypy/typeshed/stdlib/zoneinfo/_tzpath.pyi +13 -0
- package/bundle/_internal/mypy/typeshed/stubs/librt/librt/__init__.pyi +0 -0
- package/bundle/_internal/mypy/typeshed/stubs/librt/librt/base64.pyi +4 -0
- package/bundle/_internal/mypy/typeshed/stubs/librt/librt/internal.pyi +22 -0
- package/bundle/_internal/mypy/typeshed/stubs/librt/librt/random.pyi +22 -0
- package/bundle/_internal/mypy/typeshed/stubs/librt/librt/strings.pyi +61 -0
- package/bundle/_internal/mypy/typeshed/stubs/librt/librt/threading.pyi +16 -0
- package/bundle/_internal/mypy/typeshed/stubs/librt/librt/time.pyi +1 -0
- package/bundle/_internal/mypy/typeshed/stubs/librt/librt/vecs.pyi +24 -0
- package/bundle/_internal/mypy/typeshed/stubs/mypy-extensions/mypy_extensions.pyi +226 -0
- package/bundle/_internal/mypy/typestate.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/typestate.py +334 -0
- package/bundle/_internal/mypy/typetraverser.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/typetraverser.py +166 -0
- package/bundle/_internal/mypy/typevars.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/typevars.py +84 -0
- package/bundle/_internal/mypy/typevartuples.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/typevartuples.py +36 -0
- package/bundle/_internal/mypy/util.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/util.py +1055 -0
- package/bundle/_internal/mypy/version.py +1 -0
- package/bundle/_internal/mypy/visitor.cpython-312-darwin.so +0 -0
- package/bundle/_internal/mypy/visitor.py +639 -0
- package/bundle/_internal/mypy/xml/mypy-html.css +104 -0
- package/bundle/_internal/mypy/xml/mypy-html.xslt +81 -0
- package/bundle/_internal/mypy/xml/mypy-txt.xslt +100 -0
- package/bundle/_internal/mypy/xml/mypy.xsd +50 -0
- package/bundle/_internal/mypy-2.4.1.dist-info/INSTALLER +1 -0
- package/bundle/_internal/mypy-2.4.1.dist-info/METADATA +56 -0
- package/bundle/_internal/mypy-2.4.1.dist-info/RECORD +1814 -0
- package/bundle/_internal/mypy-2.4.1.dist-info/WHEEL +6 -0
- package/bundle/_internal/mypy-2.4.1.dist-info/entry_points.txt +6 -0
- package/bundle/_internal/mypy-2.4.1.dist-info/licenses/LICENSE +264 -0
- package/bundle/_internal/mypy-2.4.1.dist-info/licenses/mypy/typeshed/LICENSE +237 -0
- package/bundle/_internal/mypy-2.4.1.dist-info/top_level.txt +3 -0
- package/bundle/_internal/mypyc/__init__.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_asyncio.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_bisect.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_blake2.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_bz2.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_codecs_cn.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_codecs_hk.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_codecs_iso2022.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_codecs_jp.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_codecs_kr.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_codecs_tw.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_contextvars.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_csv.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_ctypes.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_curses.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_datetime.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_decimal.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_elementtree.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_hashlib.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_heapq.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_json.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_lzma.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_md5.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_multibytecodec.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_multiprocessing.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_opcode.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_pickle.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_posixshmem.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_posixsubprocess.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_queue.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_random.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_scproxy.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_sha1.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_sha2.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_sha3.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_socket.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_sqlite3.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_ssl.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_statistics.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_struct.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/_uuid.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/array.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/binascii.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/fcntl.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/grp.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/math.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/mmap.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/pyexpat.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/readline.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/resource.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/select.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/syslog.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/termios.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/unicodedata.cpython-312-darwin.so +0 -0
- package/bundle/_internal/python3.12/lib-dynload/zlib.cpython-312-darwin.so +0 -0
- package/bundle/_internal/radon/__init__.py +21 -0
- package/bundle/_internal/radon/__main__.py +4 -0
- package/bundle/_internal/radon/cli/__init__.py +433 -0
- package/bundle/_internal/radon/cli/colors.py +49 -0
- package/bundle/_internal/radon/cli/harvest.py +449 -0
- package/bundle/_internal/radon/cli/tools.py +597 -0
- package/bundle/_internal/radon/complexity.py +108 -0
- package/bundle/_internal/radon/contrib/__init__.py +0 -0
- package/bundle/_internal/radon/contrib/flake8.py +72 -0
- package/bundle/_internal/radon/metrics.py +157 -0
- package/bundle/_internal/radon/raw.py +245 -0
- package/bundle/_internal/radon/tests/__init__.py +0 -0
- package/bundle/_internal/radon/tests/conftest.py +31 -0
- package/bundle/_internal/radon/tests/data/__init__.py +5 -0
- package/bundle/_internal/radon/tests/data/no_encoding.py +2 -0
- package/bundle/_internal/radon/tests/data/py3unicode.py +5 -0
- package/bundle/_internal/radon/tests/run.py +14 -0
- package/bundle/_internal/radon/tests/test_cli.py +282 -0
- package/bundle/_internal/radon/tests/test_cli_colors.py +22 -0
- package/bundle/_internal/radon/tests/test_cli_harvest.py +392 -0
- package/bundle/_internal/radon/tests/test_cli_tools.py +616 -0
- package/bundle/_internal/radon/tests/test_complexity_utils.py +118 -0
- package/bundle/_internal/radon/tests/test_complexity_visitor.py +754 -0
- package/bundle/_internal/radon/tests/test_halstead.py +113 -0
- package/bundle/_internal/radon/tests/test_ipynb.py +141 -0
- package/bundle/_internal/radon/tests/test_other_metrics.py +169 -0
- package/bundle/_internal/radon/tests/test_raw.py +467 -0
- package/bundle/_internal/radon/visitors.py +460 -0
- package/bundle/_internal/radon-6.0.1.dist-info/INSTALLER +1 -0
- package/bundle/_internal/radon-6.0.1.dist-info/LICENSE +22 -0
- package/bundle/_internal/radon-6.0.1.dist-info/METADATA +263 -0
- package/bundle/_internal/radon-6.0.1.dist-info/RECORD +64 -0
- package/bundle/_internal/radon-6.0.1.dist-info/WHEEL +6 -0
- package/bundle/_internal/radon-6.0.1.dist-info/entry_points.txt +8 -0
- package/bundle/_internal/radon-6.0.1.dist-info/top_level.txt +1 -0
- package/bundle/_internal/setuptools/_vendor/jaraco/text/Lorem ipsum.txt +2 -0
- package/bundle/_internal/stevedore-5.10.0.dist-info/INSTALLER +1 -0
- package/bundle/_internal/stevedore-5.10.0.dist-info/METADATA +56 -0
- package/bundle/_internal/stevedore-5.10.0.dist-info/RECORD +84 -0
- package/bundle/_internal/stevedore-5.10.0.dist-info/WHEEL +5 -0
- package/bundle/_internal/stevedore-5.10.0.dist-info/entry_points.txt +10 -0
- package/bundle/_internal/stevedore-5.10.0.dist-info/licenses/AUTHORS +76 -0
- package/bundle/_internal/stevedore-5.10.0.dist-info/licenses/LICENSE +202 -0
- package/bundle/_internal/stevedore-5.10.0.dist-info/pbr.json +1 -0
- package/bundle/_internal/stevedore-5.10.0.dist-info/top_level.txt +1 -0
- package/bundle/_internal/tqdm-4.70.1.dist-info/INSTALLER +1 -0
- package/bundle/_internal/tqdm-4.70.1.dist-info/METADATA +1600 -0
- package/bundle/_internal/tqdm-4.70.1.dist-info/RECORD +72 -0
- package/bundle/_internal/tqdm-4.70.1.dist-info/WHEEL +5 -0
- package/bundle/_internal/tqdm-4.70.1.dist-info/entry_points.txt +2 -0
- package/bundle/_internal/tqdm-4.70.1.dist-info/licenses/LICENCE +49 -0
- package/bundle/_internal/tqdm-4.70.1.dist-info/top_level.txt +1 -0
- package/bundle/_internal/yaml/_yaml.cpython-312-darwin.so +0 -0
- package/bundle/gnost +0 -0
- package/package.json +10 -7
|
@@ -0,0 +1,2676 @@
|
|
|
1
|
+
"""Tests for stubs.
|
|
2
|
+
|
|
3
|
+
Verify that various things in stubs are consistent with how things behave at runtime.
|
|
4
|
+
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import argparse
|
|
10
|
+
import collections.abc
|
|
11
|
+
import copy
|
|
12
|
+
import enum
|
|
13
|
+
import functools
|
|
14
|
+
import importlib
|
|
15
|
+
import inspect
|
|
16
|
+
import keyword
|
|
17
|
+
import os
|
|
18
|
+
import pkgutil
|
|
19
|
+
import re
|
|
20
|
+
import struct
|
|
21
|
+
import symtable
|
|
22
|
+
import sys
|
|
23
|
+
import traceback
|
|
24
|
+
import types
|
|
25
|
+
import typing
|
|
26
|
+
import typing_extensions
|
|
27
|
+
import warnings
|
|
28
|
+
from collections import defaultdict
|
|
29
|
+
from collections.abc import Iterator
|
|
30
|
+
from contextlib import redirect_stderr, redirect_stdout
|
|
31
|
+
from functools import singledispatch
|
|
32
|
+
from pathlib import Path
|
|
33
|
+
from typing import Any, Final, Generic, TypeVar, Union, get_origin
|
|
34
|
+
from typing_extensions import is_typeddict
|
|
35
|
+
|
|
36
|
+
import mypy.build
|
|
37
|
+
import mypy.checkexpr
|
|
38
|
+
import mypy.erasetype
|
|
39
|
+
import mypy.modulefinder
|
|
40
|
+
import mypy.nodes
|
|
41
|
+
import mypy.state
|
|
42
|
+
import mypy.subtypes
|
|
43
|
+
import mypy.types
|
|
44
|
+
import mypy.version
|
|
45
|
+
from mypy import nodes
|
|
46
|
+
from mypy.config_parser import parse_config_file
|
|
47
|
+
from mypy.evalexpr import UNKNOWN, evaluate_expression
|
|
48
|
+
from mypy.maptype import map_instance_to_supertype
|
|
49
|
+
from mypy.options import Options
|
|
50
|
+
from mypy.util import FancyFormatter, bytes_to_human_readable_repr, is_dunder, plural_s
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class Missing:
|
|
54
|
+
"""Marker object for things that are missing (from a stub or the runtime)."""
|
|
55
|
+
|
|
56
|
+
def __repr__(self) -> str:
|
|
57
|
+
return "MISSING"
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
MISSING: Final = Missing()
|
|
61
|
+
|
|
62
|
+
T = TypeVar("T")
|
|
63
|
+
MaybeMissing: typing_extensions.TypeAlias = T | Missing
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
class Unrepresentable:
|
|
67
|
+
"""Marker object for unrepresentable parameter defaults."""
|
|
68
|
+
|
|
69
|
+
def __repr__(self) -> str:
|
|
70
|
+
return "<unrepresentable>"
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
UNREPRESENTABLE: Final = Unrepresentable()
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
_formatter: Final = FancyFormatter(sys.stdout, sys.stderr, False)
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def _style(message: str, **kwargs: Any) -> str:
|
|
80
|
+
"""Wrapper around mypy.util for fancy formatting."""
|
|
81
|
+
kwargs.setdefault("color", "none")
|
|
82
|
+
return _formatter.style(message, **kwargs)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _truncate(message: str, length: int) -> str:
|
|
86
|
+
if len(message) > length:
|
|
87
|
+
return message[: length - 3] + "..."
|
|
88
|
+
return message
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class StubtestFailure(Exception):
|
|
92
|
+
pass
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class Error:
|
|
96
|
+
def __init__(
|
|
97
|
+
self,
|
|
98
|
+
object_path: list[str],
|
|
99
|
+
message: str,
|
|
100
|
+
stub_object: MaybeMissing[nodes.Node],
|
|
101
|
+
runtime_object: MaybeMissing[Any],
|
|
102
|
+
*,
|
|
103
|
+
stub_desc: str | None = None,
|
|
104
|
+
runtime_desc: str | None = None,
|
|
105
|
+
) -> None:
|
|
106
|
+
"""Represents an error found by stubtest.
|
|
107
|
+
|
|
108
|
+
:param object_path: Location of the object with the error,
|
|
109
|
+
e.g. ``["module", "Class", "method"]``
|
|
110
|
+
:param message: Error message
|
|
111
|
+
:param stub_object: The mypy node representing the stub
|
|
112
|
+
:param runtime_object: Actual object obtained from the runtime
|
|
113
|
+
:param stub_desc: Specialised description for the stub object, should you wish
|
|
114
|
+
:param runtime_desc: Specialised description for the runtime object, should you wish
|
|
115
|
+
|
|
116
|
+
"""
|
|
117
|
+
self.object_path = object_path
|
|
118
|
+
self.object_desc = ".".join(object_path)
|
|
119
|
+
self.message = message
|
|
120
|
+
self.stub_object = stub_object
|
|
121
|
+
self.runtime_object = runtime_object
|
|
122
|
+
self.stub_desc = stub_desc or str(getattr(stub_object, "type", stub_object))
|
|
123
|
+
|
|
124
|
+
if runtime_desc is None:
|
|
125
|
+
runtime_sig = safe_inspect_signature(runtime_object)
|
|
126
|
+
if runtime_sig is None:
|
|
127
|
+
self.runtime_desc = _truncate(repr(runtime_object), 100)
|
|
128
|
+
else:
|
|
129
|
+
runtime_is_async = inspect.iscoroutinefunction(runtime_object)
|
|
130
|
+
description = describe_runtime_callable(runtime_sig, is_async=runtime_is_async)
|
|
131
|
+
self.runtime_desc = _truncate(description, 100)
|
|
132
|
+
else:
|
|
133
|
+
self.runtime_desc = runtime_desc
|
|
134
|
+
|
|
135
|
+
def is_missing_stub(self) -> bool:
|
|
136
|
+
"""Whether or not the error is for something missing from the stub."""
|
|
137
|
+
return isinstance(self.stub_object, Missing)
|
|
138
|
+
|
|
139
|
+
def is_positional_only_related(self) -> bool:
|
|
140
|
+
"""Whether or not the error is for something being (or not being) positional-only."""
|
|
141
|
+
# TODO: This is hacky, use error codes or something more resilient
|
|
142
|
+
return "should be positional" in self.message
|
|
143
|
+
|
|
144
|
+
def is_disjoint_base_related(self) -> bool:
|
|
145
|
+
"""Whether or not the error is related to @disjoint_base."""
|
|
146
|
+
# TODO: This is hacky, use error codes or something more resilient
|
|
147
|
+
return "@disjoint_base" in self.message
|
|
148
|
+
|
|
149
|
+
def is_private_type_check_only_related(self) -> bool:
|
|
150
|
+
"""Whether or not the error is related to @type_check_only on private types."""
|
|
151
|
+
# TODO: This is hacky, use error codes or something more resilient
|
|
152
|
+
return self.message.endswith('Maybe mark it as "@type_check_only"?')
|
|
153
|
+
|
|
154
|
+
def get_description(self, concise: bool = False) -> str:
|
|
155
|
+
"""Returns a description of the error.
|
|
156
|
+
|
|
157
|
+
:param concise: Whether to return a concise, one-line description
|
|
158
|
+
|
|
159
|
+
"""
|
|
160
|
+
if concise:
|
|
161
|
+
return _style(self.object_desc, bold=True) + " " + self.message
|
|
162
|
+
|
|
163
|
+
stub_line = None
|
|
164
|
+
stub_file = None
|
|
165
|
+
if not isinstance(self.stub_object, Missing):
|
|
166
|
+
stub_line = self.stub_object.line
|
|
167
|
+
stub_node = get_stub(self.object_path[0])
|
|
168
|
+
if stub_node is not None:
|
|
169
|
+
stub_file = stub_node.path or None
|
|
170
|
+
|
|
171
|
+
stub_loc_str = ""
|
|
172
|
+
if stub_file:
|
|
173
|
+
stub_loc_str += f" in file {Path(stub_file)}"
|
|
174
|
+
if stub_line:
|
|
175
|
+
stub_loc_str += f"{':' if stub_file else ' at line '}{stub_line}"
|
|
176
|
+
|
|
177
|
+
runtime_line = None
|
|
178
|
+
runtime_file = None
|
|
179
|
+
if not isinstance(self.runtime_object, Missing):
|
|
180
|
+
try:
|
|
181
|
+
runtime_line = inspect.getsourcelines(self.runtime_object)[1]
|
|
182
|
+
except (OSError, TypeError, SyntaxError):
|
|
183
|
+
pass
|
|
184
|
+
try:
|
|
185
|
+
runtime_file = inspect.getsourcefile(self.runtime_object)
|
|
186
|
+
except TypeError:
|
|
187
|
+
pass
|
|
188
|
+
|
|
189
|
+
runtime_loc_str = ""
|
|
190
|
+
if runtime_file:
|
|
191
|
+
runtime_loc_str += f" in file {Path(runtime_file)}"
|
|
192
|
+
if runtime_line:
|
|
193
|
+
runtime_loc_str += f"{':' if runtime_file else ' at line '}{runtime_line}"
|
|
194
|
+
|
|
195
|
+
output = [
|
|
196
|
+
_style("error: ", color="red", bold=True),
|
|
197
|
+
_style(self.object_desc, bold=True),
|
|
198
|
+
" ",
|
|
199
|
+
self.message,
|
|
200
|
+
"\n",
|
|
201
|
+
"Stub:",
|
|
202
|
+
_style(stub_loc_str, dim=True),
|
|
203
|
+
"\n",
|
|
204
|
+
_style(self.stub_desc + "\n", color="blue", dim=True),
|
|
205
|
+
"Runtime:",
|
|
206
|
+
_style(runtime_loc_str, dim=True),
|
|
207
|
+
"\n",
|
|
208
|
+
_style(self.runtime_desc + "\n", color="blue", dim=True),
|
|
209
|
+
]
|
|
210
|
+
return "".join(output)
|
|
211
|
+
|
|
212
|
+
|
|
213
|
+
# ====================
|
|
214
|
+
# Core logic
|
|
215
|
+
# ====================
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
def silent_import_module(module_name: str) -> types.ModuleType:
|
|
219
|
+
with open(os.devnull, "w") as devnull:
|
|
220
|
+
with warnings.catch_warnings(), redirect_stdout(devnull), redirect_stderr(devnull):
|
|
221
|
+
warnings.simplefilter("ignore")
|
|
222
|
+
runtime = importlib.import_module(module_name)
|
|
223
|
+
# Also run the equivalent of `from module import *`
|
|
224
|
+
# This could have the additional effect of loading not-yet-loaded submodules
|
|
225
|
+
# mentioned in __all__
|
|
226
|
+
__import__(module_name, fromlist=["*"])
|
|
227
|
+
return runtime
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def test_module(module_name: str) -> Iterator[Error]:
|
|
231
|
+
"""Tests a given module's stub against introspecting it at runtime.
|
|
232
|
+
|
|
233
|
+
Requires the stub to have been built already, accomplished by a call to ``build_stubs``.
|
|
234
|
+
|
|
235
|
+
:param module_name: The module to test
|
|
236
|
+
|
|
237
|
+
"""
|
|
238
|
+
stub = get_stub(module_name)
|
|
239
|
+
if stub is None:
|
|
240
|
+
if not is_probably_private(module_name.split(".")[-1]):
|
|
241
|
+
runtime_desc = repr(sys.modules[module_name]) if module_name in sys.modules else "N/A"
|
|
242
|
+
yield Error(
|
|
243
|
+
[module_name], "failed to find stubs", MISSING, None, runtime_desc=runtime_desc
|
|
244
|
+
)
|
|
245
|
+
return
|
|
246
|
+
|
|
247
|
+
try:
|
|
248
|
+
runtime = silent_import_module(module_name)
|
|
249
|
+
except KeyboardInterrupt:
|
|
250
|
+
raise
|
|
251
|
+
except BaseException as e:
|
|
252
|
+
note = ""
|
|
253
|
+
if isinstance(e, ModuleNotFoundError):
|
|
254
|
+
note = " Maybe install the runtime package or alter PYTHONPATH?"
|
|
255
|
+
yield Error(
|
|
256
|
+
[module_name], f"failed to import.{note} {type(e).__name__}: {e}", stub, MISSING
|
|
257
|
+
)
|
|
258
|
+
return
|
|
259
|
+
|
|
260
|
+
with warnings.catch_warnings():
|
|
261
|
+
warnings.simplefilter("ignore")
|
|
262
|
+
try:
|
|
263
|
+
yield from verify(stub, runtime, [module_name])
|
|
264
|
+
except Exception as e:
|
|
265
|
+
bottom_frame = list(traceback.walk_tb(e.__traceback__))[-1][0]
|
|
266
|
+
bottom_module = bottom_frame.f_globals.get("__name__", "")
|
|
267
|
+
# Pass on any errors originating from stubtest or mypy
|
|
268
|
+
# These can occur expectedly, e.g. StubtestFailure
|
|
269
|
+
if bottom_module == "__main__" or bottom_module.split(".")[0] == "mypy":
|
|
270
|
+
raise
|
|
271
|
+
yield Error(
|
|
272
|
+
[module_name],
|
|
273
|
+
f"encountered unexpected error, {type(e).__name__}: {e}",
|
|
274
|
+
stub,
|
|
275
|
+
runtime,
|
|
276
|
+
stub_desc="N/A",
|
|
277
|
+
runtime_desc=(
|
|
278
|
+
"This is most likely the fault of something very dynamic in your library. "
|
|
279
|
+
"It's also possible this is a bug in stubtest.\nIf in doubt, please "
|
|
280
|
+
"open an issue at https://github.com/python/mypy\n\n"
|
|
281
|
+
+ traceback.format_exc().strip()
|
|
282
|
+
),
|
|
283
|
+
)
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
@singledispatch
|
|
287
|
+
def verify(
|
|
288
|
+
stub: MaybeMissing[nodes.Node], runtime: MaybeMissing[Any], object_path: list[str]
|
|
289
|
+
) -> Iterator[Error]:
|
|
290
|
+
"""Entry point for comparing a stub to a runtime object.
|
|
291
|
+
|
|
292
|
+
We use single dispatch based on the type of ``stub``.
|
|
293
|
+
|
|
294
|
+
:param stub: The mypy node representing a part of the stub
|
|
295
|
+
:param runtime: The runtime object corresponding to ``stub``
|
|
296
|
+
|
|
297
|
+
"""
|
|
298
|
+
yield Error(object_path, "is an unknown mypy node", stub, runtime)
|
|
299
|
+
|
|
300
|
+
|
|
301
|
+
def _verify_exported_names(
|
|
302
|
+
object_path: list[str], stub: nodes.MypyFile, runtime_all_as_set: set[str]
|
|
303
|
+
) -> Iterator[Error]:
|
|
304
|
+
# note that this includes the case the stub simply defines `__all__: list[str]`
|
|
305
|
+
assert "__all__" in stub.names
|
|
306
|
+
public_names_in_stub = {m for m, o in stub.names.items() if o.module_public}
|
|
307
|
+
names_in_stub_not_runtime = sorted(public_names_in_stub - runtime_all_as_set)
|
|
308
|
+
names_in_runtime_not_stub = sorted(runtime_all_as_set - public_names_in_stub)
|
|
309
|
+
if not (names_in_runtime_not_stub or names_in_stub_not_runtime):
|
|
310
|
+
return
|
|
311
|
+
yield Error(
|
|
312
|
+
object_path + ["__all__"],
|
|
313
|
+
(
|
|
314
|
+
"names exported from the stub do not correspond to the names exported at runtime. "
|
|
315
|
+
"This is probably due to things being missing from the stub or an inaccurate `__all__` in the stub"
|
|
316
|
+
),
|
|
317
|
+
# Pass in MISSING instead of the stub and runtime objects, as the line numbers aren't very
|
|
318
|
+
# relevant here, and it makes for a prettier error message
|
|
319
|
+
# This means this error will be ignored when using `--ignore-missing-stub`, which is
|
|
320
|
+
# desirable in at least the `names_in_runtime_not_stub` case
|
|
321
|
+
stub_object=MISSING,
|
|
322
|
+
runtime_object=MISSING,
|
|
323
|
+
stub_desc=(f"Names exported in the stub but not at runtime: {names_in_stub_not_runtime}"),
|
|
324
|
+
runtime_desc=(
|
|
325
|
+
f"Names exported at runtime but not in the stub: {names_in_runtime_not_stub}"
|
|
326
|
+
),
|
|
327
|
+
)
|
|
328
|
+
|
|
329
|
+
|
|
330
|
+
@functools.lru_cache
|
|
331
|
+
def _module_symbol_table(runtime: types.ModuleType) -> symtable.SymbolTable | None:
|
|
332
|
+
"""Retrieve the symbol table for the module (or None on failure).
|
|
333
|
+
|
|
334
|
+
1) Use inspect to retrieve the source code of the module
|
|
335
|
+
2) Use symtable to parse the source (and use what symtable knows for its purposes)
|
|
336
|
+
"""
|
|
337
|
+
try:
|
|
338
|
+
source = inspect.getsource(runtime)
|
|
339
|
+
except (OSError, TypeError, SyntaxError):
|
|
340
|
+
return None
|
|
341
|
+
|
|
342
|
+
try:
|
|
343
|
+
return symtable.symtable(source, runtime.__name__, "exec")
|
|
344
|
+
except SyntaxError:
|
|
345
|
+
return None
|
|
346
|
+
|
|
347
|
+
|
|
348
|
+
@verify.register(nodes.MypyFile)
|
|
349
|
+
def verify_mypyfile(
|
|
350
|
+
stub: nodes.MypyFile, runtime: MaybeMissing[types.ModuleType], object_path: list[str]
|
|
351
|
+
) -> Iterator[Error]:
|
|
352
|
+
if isinstance(runtime, Missing):
|
|
353
|
+
yield Error(object_path, "is not present at runtime", stub, runtime)
|
|
354
|
+
return
|
|
355
|
+
if not isinstance(runtime, types.ModuleType):
|
|
356
|
+
# Can possibly happen:
|
|
357
|
+
yield Error(object_path, "is not a module", stub, runtime) # type: ignore[unreachable]
|
|
358
|
+
return
|
|
359
|
+
|
|
360
|
+
runtime_all_as_set: set[str] | None
|
|
361
|
+
|
|
362
|
+
if hasattr(runtime, "__all__"):
|
|
363
|
+
runtime_all_as_set = set(runtime.__all__)
|
|
364
|
+
if "__all__" in stub.names:
|
|
365
|
+
# Only verify the contents of the stub's __all__
|
|
366
|
+
# if the stub actually defines __all__
|
|
367
|
+
yield from _verify_exported_names(object_path, stub, runtime_all_as_set)
|
|
368
|
+
else:
|
|
369
|
+
yield Error(object_path + ["__all__"], "is not present in stub", MISSING, runtime)
|
|
370
|
+
else:
|
|
371
|
+
runtime_all_as_set = None
|
|
372
|
+
|
|
373
|
+
# Check things in the stub
|
|
374
|
+
to_check = {m for m, o in stub.names.items() if not o.module_hidden}
|
|
375
|
+
|
|
376
|
+
def _belongs_to_runtime(r: types.ModuleType, attr: str) -> bool:
|
|
377
|
+
"""Heuristics to determine whether a name originates from another module."""
|
|
378
|
+
obj = getattr(r, attr)
|
|
379
|
+
if isinstance(obj, types.ModuleType):
|
|
380
|
+
return False
|
|
381
|
+
|
|
382
|
+
symbol_table = _module_symbol_table(r)
|
|
383
|
+
if symbol_table is not None:
|
|
384
|
+
try:
|
|
385
|
+
symbol = symbol_table.lookup(attr)
|
|
386
|
+
except KeyError:
|
|
387
|
+
pass
|
|
388
|
+
else:
|
|
389
|
+
if symbol.is_imported():
|
|
390
|
+
# symtable says we got this from another module
|
|
391
|
+
return False
|
|
392
|
+
# But we can't just return True here, because symtable doesn't know about symbols
|
|
393
|
+
# that come from `from module import *`
|
|
394
|
+
if symbol.is_assigned():
|
|
395
|
+
# symtable knows we assigned this symbol in the module
|
|
396
|
+
return True
|
|
397
|
+
|
|
398
|
+
# The __module__ attribute is unreliable for anything except functions and classes,
|
|
399
|
+
# but it's our best guess at this point
|
|
400
|
+
try:
|
|
401
|
+
obj_mod = obj.__module__
|
|
402
|
+
except Exception:
|
|
403
|
+
pass
|
|
404
|
+
else:
|
|
405
|
+
if isinstance(obj_mod, str):
|
|
406
|
+
return bool(obj_mod == r.__name__)
|
|
407
|
+
return True
|
|
408
|
+
|
|
409
|
+
runtime_public_contents = (
|
|
410
|
+
runtime_all_as_set
|
|
411
|
+
if runtime_all_as_set is not None
|
|
412
|
+
else {
|
|
413
|
+
m
|
|
414
|
+
for m in dir(runtime)
|
|
415
|
+
if not is_probably_private(m)
|
|
416
|
+
# Filter out objects that originate from other modules (best effort). Note that in the
|
|
417
|
+
# absence of __all__, we don't have a way to detect explicit / intentional re-exports
|
|
418
|
+
# at runtime
|
|
419
|
+
and _belongs_to_runtime(runtime, m)
|
|
420
|
+
}
|
|
421
|
+
)
|
|
422
|
+
# Check all things declared in module's __all__, falling back to our best guess
|
|
423
|
+
to_check.update(runtime_public_contents)
|
|
424
|
+
to_check.difference_update(IGNORED_MODULE_DUNDERS)
|
|
425
|
+
|
|
426
|
+
for entry in sorted(to_check):
|
|
427
|
+
stub_entry = stub.names[entry].node if entry in stub.names else MISSING
|
|
428
|
+
if entry in stub.names:
|
|
429
|
+
if xref := stub.names[entry].cross_ref:
|
|
430
|
+
orig_module = xref.rsplit(".", 1)[0]
|
|
431
|
+
elif isinstance(stub_entry, nodes.SymbolNode) and (name := stub_entry.fullname):
|
|
432
|
+
orig_module = name.rsplit(".", 1)[0]
|
|
433
|
+
else:
|
|
434
|
+
orig_module = None
|
|
435
|
+
|
|
436
|
+
if orig_module and orig_module != stub.fullname and orig_module in _all_stubs:
|
|
437
|
+
# Skip re-exported names whose defining module will be checked separately.
|
|
438
|
+
continue
|
|
439
|
+
|
|
440
|
+
if isinstance(stub_entry, nodes.MypyFile):
|
|
441
|
+
# Don't recursively check exported modules, since that leads to infinite recursion
|
|
442
|
+
continue
|
|
443
|
+
assert stub_entry is not None
|
|
444
|
+
if (
|
|
445
|
+
is_probably_private(entry)
|
|
446
|
+
and not hasattr(runtime, entry)
|
|
447
|
+
and not isinstance(stub_entry, Missing)
|
|
448
|
+
and not _is_decoratable(stub_entry)
|
|
449
|
+
):
|
|
450
|
+
# Skip private names that don't exist at runtime and which cannot
|
|
451
|
+
# be marked with @type_check_only.
|
|
452
|
+
continue
|
|
453
|
+
try:
|
|
454
|
+
runtime_entry = getattr(runtime, entry, MISSING)
|
|
455
|
+
except Exception:
|
|
456
|
+
# Catch all exceptions in case the runtime raises an unexpected exception
|
|
457
|
+
# from __getattr__ or similar.
|
|
458
|
+
continue
|
|
459
|
+
yield from verify(stub_entry, runtime_entry, object_path + [entry])
|
|
460
|
+
|
|
461
|
+
|
|
462
|
+
def _is_decoratable(stub: nodes.SymbolNode) -> bool:
|
|
463
|
+
if not isinstance(stub, nodes.TypeInfo):
|
|
464
|
+
return False
|
|
465
|
+
if stub.is_newtype:
|
|
466
|
+
return False
|
|
467
|
+
if stub.typeddict_type is not None:
|
|
468
|
+
return all(
|
|
469
|
+
name.isidentifier() and not keyword.iskeyword(name)
|
|
470
|
+
for name in stub.typeddict_type.items.keys()
|
|
471
|
+
)
|
|
472
|
+
return True
|
|
473
|
+
|
|
474
|
+
|
|
475
|
+
def _verify_final(
|
|
476
|
+
stub: nodes.TypeInfo, runtime: type[Any], object_path: list[str]
|
|
477
|
+
) -> Iterator[Error]:
|
|
478
|
+
try:
|
|
479
|
+
|
|
480
|
+
class SubClass(runtime): # type: ignore[misc]
|
|
481
|
+
pass
|
|
482
|
+
|
|
483
|
+
except TypeError:
|
|
484
|
+
# Enum classes are implicitly @final
|
|
485
|
+
if not stub.is_final and not issubclass(runtime, enum.Enum):
|
|
486
|
+
yield Error(
|
|
487
|
+
object_path,
|
|
488
|
+
"cannot be subclassed at runtime, but isn't marked with @final in the stub",
|
|
489
|
+
stub,
|
|
490
|
+
runtime,
|
|
491
|
+
stub_desc=repr(stub),
|
|
492
|
+
)
|
|
493
|
+
except Exception:
|
|
494
|
+
# The class probably wants its subclasses to do something special.
|
|
495
|
+
# Examples: ctypes.Array, ctypes._SimpleCData
|
|
496
|
+
pass
|
|
497
|
+
|
|
498
|
+
# Runtime class might be annotated with `@final`:
|
|
499
|
+
try:
|
|
500
|
+
runtime_final = getattr(runtime, "__final__", False)
|
|
501
|
+
except Exception:
|
|
502
|
+
runtime_final = False
|
|
503
|
+
|
|
504
|
+
if runtime_final and not stub.is_final:
|
|
505
|
+
yield Error(
|
|
506
|
+
object_path,
|
|
507
|
+
"has `__final__` attribute, but isn't marked with @final in the stub",
|
|
508
|
+
stub,
|
|
509
|
+
runtime,
|
|
510
|
+
stub_desc=repr(stub),
|
|
511
|
+
)
|
|
512
|
+
|
|
513
|
+
|
|
514
|
+
SIZEOF_PYOBJECT = struct.calcsize("P")
|
|
515
|
+
|
|
516
|
+
|
|
517
|
+
def _shape_differs(t1: type[object], t2: type[object]) -> bool:
|
|
518
|
+
"""Check whether two types differ in shape.
|
|
519
|
+
|
|
520
|
+
Mirrors the shape_differs() function in typeobject.c in CPython."""
|
|
521
|
+
if sys.version_info >= (3, 12):
|
|
522
|
+
return t1.__basicsize__ != t2.__basicsize__ or t1.__itemsize__ != t2.__itemsize__
|
|
523
|
+
else:
|
|
524
|
+
# CPython had more complicated logic before 3.12:
|
|
525
|
+
# https://github.com/python/cpython/blob/f3c6f882cddc8dc30320d2e73edf019e201394fc/Objects/typeobject.c#L2224
|
|
526
|
+
# We attempt to mirror it here well enough to support the most common cases.
|
|
527
|
+
if t1.__itemsize__ or t2.__itemsize__:
|
|
528
|
+
return t1.__basicsize__ != t2.__basicsize__ or t1.__itemsize__ != t2.__itemsize__
|
|
529
|
+
t_size = t1.__basicsize__
|
|
530
|
+
if not t2.__weakrefoffset__ and t1.__weakrefoffset__ + SIZEOF_PYOBJECT == t_size:
|
|
531
|
+
t_size -= SIZEOF_PYOBJECT
|
|
532
|
+
if not t2.__dictoffset__ and t1.__dictoffset__ + SIZEOF_PYOBJECT == t_size:
|
|
533
|
+
t_size -= SIZEOF_PYOBJECT
|
|
534
|
+
if not t2.__weakrefoffset__ and t2.__weakrefoffset__ == t_size:
|
|
535
|
+
t_size -= SIZEOF_PYOBJECT
|
|
536
|
+
return t_size != t2.__basicsize__
|
|
537
|
+
|
|
538
|
+
|
|
539
|
+
def _is_disjoint_base(typ: type[object]) -> bool:
|
|
540
|
+
"""Return whether a type is a disjoint base at runtime, mirroring CPython's logic in typeobject.c.
|
|
541
|
+
|
|
542
|
+
See PEP 800."""
|
|
543
|
+
if typ is object:
|
|
544
|
+
return True
|
|
545
|
+
base = typ.__base__
|
|
546
|
+
assert base is not None, f"Type {typ} has no base"
|
|
547
|
+
return _shape_differs(typ, base)
|
|
548
|
+
|
|
549
|
+
|
|
550
|
+
def _verify_disjoint_base(
|
|
551
|
+
stub: nodes.TypeInfo, runtime: type[object], object_path: list[str]
|
|
552
|
+
) -> Iterator[Error]:
|
|
553
|
+
is_disjoint_runtime = _is_disjoint_base(runtime)
|
|
554
|
+
# Don't complain about missing @disjoint_base if there are __slots__, because
|
|
555
|
+
# in that case we can infer that it's a disjoint base.
|
|
556
|
+
if (
|
|
557
|
+
is_disjoint_runtime
|
|
558
|
+
and not stub.is_disjoint_base
|
|
559
|
+
and not runtime.__dict__.get("__slots__")
|
|
560
|
+
and not stub.is_final
|
|
561
|
+
and not (stub.is_enum and stub.enum_members)
|
|
562
|
+
):
|
|
563
|
+
yield Error(
|
|
564
|
+
object_path,
|
|
565
|
+
"is a disjoint base at runtime, but isn't marked with @disjoint_base in the stub",
|
|
566
|
+
stub,
|
|
567
|
+
runtime,
|
|
568
|
+
stub_desc=repr(stub),
|
|
569
|
+
)
|
|
570
|
+
elif stub.is_disjoint_base:
|
|
571
|
+
if not is_disjoint_runtime:
|
|
572
|
+
yield Error(
|
|
573
|
+
object_path,
|
|
574
|
+
"is marked with @disjoint_base in the stub, but isn't a disjoint base at runtime",
|
|
575
|
+
stub,
|
|
576
|
+
runtime,
|
|
577
|
+
stub_desc=repr(stub),
|
|
578
|
+
)
|
|
579
|
+
if runtime.__dict__.get("__slots__"):
|
|
580
|
+
yield Error(
|
|
581
|
+
object_path,
|
|
582
|
+
"is marked as @disjoint_base, but also has slots; add __slots__ instead",
|
|
583
|
+
stub,
|
|
584
|
+
runtime,
|
|
585
|
+
stub_desc=repr(stub),
|
|
586
|
+
)
|
|
587
|
+
elif stub.is_final:
|
|
588
|
+
yield Error(
|
|
589
|
+
object_path,
|
|
590
|
+
"is marked as @disjoint_base, but also marked as @final; remove @disjoint_base",
|
|
591
|
+
stub,
|
|
592
|
+
runtime,
|
|
593
|
+
stub_desc=repr(stub),
|
|
594
|
+
)
|
|
595
|
+
elif stub.is_enum and stub.enum_members:
|
|
596
|
+
yield Error(
|
|
597
|
+
object_path,
|
|
598
|
+
"is marked as @disjoint_base, but is an enum with members, which is implicitly final; "
|
|
599
|
+
"remove @disjoint_base",
|
|
600
|
+
stub,
|
|
601
|
+
runtime,
|
|
602
|
+
stub_desc=repr(stub),
|
|
603
|
+
)
|
|
604
|
+
|
|
605
|
+
|
|
606
|
+
def _verify_metaclass(
|
|
607
|
+
stub: nodes.TypeInfo, runtime: type[Any], object_path: list[str], *, is_runtime_typeddict: bool
|
|
608
|
+
) -> Iterator[Error]:
|
|
609
|
+
# We exclude protocols, because of how complex their implementation is in different versions of
|
|
610
|
+
# python. Enums are also hard, as are runtime TypedDicts; ignoring.
|
|
611
|
+
# TODO: check that metaclasses are identical?
|
|
612
|
+
if not stub.is_protocol and not stub.is_enum and not is_runtime_typeddict:
|
|
613
|
+
runtime_metaclass = type(runtime)
|
|
614
|
+
if runtime_metaclass is not type and stub.metaclass_type is None:
|
|
615
|
+
# This means that runtime has a custom metaclass, but a stub does not.
|
|
616
|
+
yield Error(
|
|
617
|
+
object_path,
|
|
618
|
+
"is inconsistent, metaclass differs",
|
|
619
|
+
stub,
|
|
620
|
+
runtime,
|
|
621
|
+
stub_desc="N/A",
|
|
622
|
+
runtime_desc=f"{runtime_metaclass}",
|
|
623
|
+
)
|
|
624
|
+
elif (
|
|
625
|
+
runtime_metaclass is type
|
|
626
|
+
and stub.metaclass_type is not None
|
|
627
|
+
# We ignore extra `ABCMeta` metaclass on stubs, this might be typing hack.
|
|
628
|
+
# We also ignore `builtins.type` metaclass as an implementation detail in mypy.
|
|
629
|
+
and not mypy.types.is_named_instance(
|
|
630
|
+
stub.metaclass_type, ("abc.ABCMeta", "builtins.type")
|
|
631
|
+
)
|
|
632
|
+
):
|
|
633
|
+
# This means that our stub has a metaclass that is not present at runtime.
|
|
634
|
+
yield Error(
|
|
635
|
+
object_path,
|
|
636
|
+
"metaclass mismatch",
|
|
637
|
+
stub,
|
|
638
|
+
runtime,
|
|
639
|
+
stub_desc=f"{stub.metaclass_type.type.fullname}",
|
|
640
|
+
runtime_desc="N/A",
|
|
641
|
+
)
|
|
642
|
+
|
|
643
|
+
|
|
644
|
+
@verify.register(nodes.TypeInfo)
|
|
645
|
+
def verify_typeinfo(
|
|
646
|
+
stub: nodes.TypeInfo,
|
|
647
|
+
runtime: MaybeMissing[type[Any]],
|
|
648
|
+
object_path: list[str],
|
|
649
|
+
*,
|
|
650
|
+
is_alias_target: bool = False,
|
|
651
|
+
) -> Iterator[Error]:
|
|
652
|
+
if stub.is_type_check_only and not is_alias_target:
|
|
653
|
+
# This type only exists in stubs, we only check that the runtime part
|
|
654
|
+
# is missing. Other checks are not required.
|
|
655
|
+
if not isinstance(runtime, Missing):
|
|
656
|
+
yield Error(
|
|
657
|
+
object_path,
|
|
658
|
+
'is marked as "@type_check_only", but also exists at runtime',
|
|
659
|
+
stub,
|
|
660
|
+
runtime,
|
|
661
|
+
stub_desc=repr(stub),
|
|
662
|
+
)
|
|
663
|
+
return
|
|
664
|
+
|
|
665
|
+
if isinstance(runtime, Missing):
|
|
666
|
+
msg = "is not present at runtime"
|
|
667
|
+
if is_probably_private(stub.name):
|
|
668
|
+
msg += '. Maybe mark it as "@type_check_only"?'
|
|
669
|
+
yield Error(object_path, msg, stub, runtime, stub_desc=repr(stub))
|
|
670
|
+
return
|
|
671
|
+
if not isinstance(runtime, type):
|
|
672
|
+
# Yes, some runtime objects can be not types, no way to tell mypy about that.
|
|
673
|
+
yield Error(object_path, "is not a type", stub, runtime, stub_desc=repr(stub)) # type: ignore[unreachable]
|
|
674
|
+
return
|
|
675
|
+
|
|
676
|
+
yield from _verify_final(stub, runtime, object_path)
|
|
677
|
+
yield from _verify_disjoint_base(stub, runtime, object_path)
|
|
678
|
+
is_runtime_typeddict = stub.typeddict_type is not None and is_typeddict(runtime)
|
|
679
|
+
yield from _verify_metaclass(
|
|
680
|
+
stub, runtime, object_path, is_runtime_typeddict=is_runtime_typeddict
|
|
681
|
+
)
|
|
682
|
+
|
|
683
|
+
# Check everything already defined on the stub class itself (i.e. not inherited)
|
|
684
|
+
#
|
|
685
|
+
# Filter out non-identifier names, as these are (hopefully always?) whacky/fictional things
|
|
686
|
+
# (like __mypy-replace or __mypy-post_init, etc.) that don't exist at runtime,
|
|
687
|
+
# and exist purely for internal mypy reasons
|
|
688
|
+
existing_stub_names = {name for name in stub.names if name.isidentifier()}
|
|
689
|
+
to_check = existing_stub_names.copy()
|
|
690
|
+
# Check all public things on the runtime class
|
|
691
|
+
to_check.update(
|
|
692
|
+
m for m in vars(runtime) if not is_probably_private(m) and m not in IGNORABLE_CLASS_DUNDERS
|
|
693
|
+
)
|
|
694
|
+
# Special-case the __init__ method for Protocols and the __new__ method for TypedDicts
|
|
695
|
+
#
|
|
696
|
+
# TODO: On Python <3.11, __init__ methods on Protocol classes
|
|
697
|
+
# are silently discarded and replaced.
|
|
698
|
+
# However, this is not the case on Python 3.11+.
|
|
699
|
+
# Ideally, we'd figure out a good way of validating Protocol __init__ methods on 3.11+.
|
|
700
|
+
if stub.is_protocol:
|
|
701
|
+
to_check.discard("__init__")
|
|
702
|
+
if is_runtime_typeddict:
|
|
703
|
+
to_check.discard("__new__")
|
|
704
|
+
|
|
705
|
+
for entry in sorted(to_check):
|
|
706
|
+
mangled_entry = entry
|
|
707
|
+
if entry.startswith("__") and not entry.endswith("__"):
|
|
708
|
+
mangled_entry = f"_{stub.name.lstrip('_')}{entry}"
|
|
709
|
+
stub_to_verify = next((t.names[entry].node for t in stub.mro if entry in t.names), MISSING)
|
|
710
|
+
assert stub_to_verify is not None
|
|
711
|
+
try:
|
|
712
|
+
try:
|
|
713
|
+
runtime_attr = getattr(runtime, mangled_entry)
|
|
714
|
+
except AttributeError:
|
|
715
|
+
runtime_attr = inspect.getattr_static(runtime, mangled_entry, MISSING)
|
|
716
|
+
except Exception:
|
|
717
|
+
# Catch all exceptions in case the runtime raises an unexpected exception
|
|
718
|
+
# from __getattr__ or similar.
|
|
719
|
+
continue
|
|
720
|
+
|
|
721
|
+
# If it came from the metaclass, consider the runtime_attr to be MISSING
|
|
722
|
+
# for a more accurate message
|
|
723
|
+
if (
|
|
724
|
+
runtime_attr is not MISSING
|
|
725
|
+
and type(runtime) is not runtime
|
|
726
|
+
and getattr(runtime_attr, "__objclass__", None) is type(runtime)
|
|
727
|
+
):
|
|
728
|
+
runtime_attr = MISSING
|
|
729
|
+
|
|
730
|
+
# __setattr__ and __delattr__ on object are a special case,
|
|
731
|
+
# so if we only have these methods inherited from there, pretend that
|
|
732
|
+
# we don't have them. See python/typeshed#7385.
|
|
733
|
+
if (
|
|
734
|
+
entry in ("__setattr__", "__delattr__")
|
|
735
|
+
and runtime_attr is not MISSING
|
|
736
|
+
and runtime is not object
|
|
737
|
+
and getattr(runtime_attr, "__objclass__", None) is object
|
|
738
|
+
):
|
|
739
|
+
runtime_attr = MISSING
|
|
740
|
+
|
|
741
|
+
# Do not error for an object missing from the stub
|
|
742
|
+
# If the runtime object is a types.WrapperDescriptorType object
|
|
743
|
+
# and has a non-special dunder name.
|
|
744
|
+
# The vast majority of these are false positives, unless the stub gives us
|
|
745
|
+
# a reason to expect the method.
|
|
746
|
+
if not (
|
|
747
|
+
isinstance(stub_to_verify, Missing)
|
|
748
|
+
and isinstance(runtime_attr, types.WrapperDescriptorType)
|
|
749
|
+
and is_dunder(mangled_entry, exclude_special=True)
|
|
750
|
+
and not is_expected_dunder(
|
|
751
|
+
mangled_entry, stub=stub, existing_stub_names=existing_stub_names
|
|
752
|
+
)
|
|
753
|
+
):
|
|
754
|
+
yield from verify(stub_to_verify, runtime_attr, object_path + [entry])
|
|
755
|
+
|
|
756
|
+
|
|
757
|
+
def _static_lookup_runtime(object_path: list[str]) -> MaybeMissing[Any]:
|
|
758
|
+
static_runtime = importlib.import_module(object_path[0])
|
|
759
|
+
for entry in object_path[1:]:
|
|
760
|
+
try:
|
|
761
|
+
static_runtime = inspect.getattr_static(static_runtime, entry)
|
|
762
|
+
except AttributeError:
|
|
763
|
+
# This can happen with mangled names, ignore for now.
|
|
764
|
+
# TODO: pass more information about ancestors of nodes/objects to verify, so we don't
|
|
765
|
+
# have to do this hacky lookup. Would be useful in several places.
|
|
766
|
+
return MISSING
|
|
767
|
+
return static_runtime
|
|
768
|
+
|
|
769
|
+
|
|
770
|
+
def _verify_static_class_methods(
|
|
771
|
+
stub: nodes.FuncBase, runtime: Any, static_runtime: MaybeMissing[Any], object_path: list[str]
|
|
772
|
+
) -> Iterator[str]:
|
|
773
|
+
if stub.name in ("__new__", "__init_subclass__", "__class_getitem__"):
|
|
774
|
+
# Special cased by Python, so don't bother checking
|
|
775
|
+
return
|
|
776
|
+
if inspect.isbuiltin(runtime):
|
|
777
|
+
# The isinstance checks don't work reliably for builtins, e.g. datetime.datetime.now, so do
|
|
778
|
+
# something a little hacky that seems to work well
|
|
779
|
+
probably_class_method = isinstance(getattr(runtime, "__self__", None), type)
|
|
780
|
+
if probably_class_method and not stub.is_class:
|
|
781
|
+
yield "runtime is a classmethod but stub is not"
|
|
782
|
+
if not probably_class_method and stub.is_class:
|
|
783
|
+
yield "stub is a classmethod but runtime is not"
|
|
784
|
+
return
|
|
785
|
+
|
|
786
|
+
if static_runtime is MISSING:
|
|
787
|
+
return
|
|
788
|
+
|
|
789
|
+
if isinstance(static_runtime, classmethod) and not stub.is_class:
|
|
790
|
+
yield "runtime is a classmethod but stub is not"
|
|
791
|
+
if not isinstance(static_runtime, classmethod) and stub.is_class:
|
|
792
|
+
yield "stub is a classmethod but runtime is not"
|
|
793
|
+
if isinstance(static_runtime, staticmethod) and not stub.is_static:
|
|
794
|
+
yield "runtime is a staticmethod but stub is not"
|
|
795
|
+
if not isinstance(static_runtime, staticmethod) and stub.is_static:
|
|
796
|
+
yield "stub is a staticmethod but runtime is not"
|
|
797
|
+
|
|
798
|
+
|
|
799
|
+
def _verify_arg_name(
|
|
800
|
+
stub_arg: nodes.Argument, runtime_arg: inspect.Parameter, function_name: str
|
|
801
|
+
) -> Iterator[str]:
|
|
802
|
+
"""Checks whether argument names match."""
|
|
803
|
+
# Ignore exact names for most dunder methods
|
|
804
|
+
if is_dunder(function_name, exclude_special=True):
|
|
805
|
+
return
|
|
806
|
+
|
|
807
|
+
if (
|
|
808
|
+
stub_arg.variable.name == runtime_arg.name
|
|
809
|
+
or stub_arg.variable.name.removeprefix("__") == runtime_arg.name
|
|
810
|
+
):
|
|
811
|
+
return
|
|
812
|
+
|
|
813
|
+
nonspecific_names = {"object", "args"}
|
|
814
|
+
if runtime_arg.name in nonspecific_names:
|
|
815
|
+
return
|
|
816
|
+
|
|
817
|
+
def names_approx_match(a: str, b: str) -> bool:
|
|
818
|
+
a = a.strip("_")
|
|
819
|
+
b = b.strip("_")
|
|
820
|
+
return a.startswith(b) or b.startswith(a) or len(a) == 1 or len(b) == 1
|
|
821
|
+
|
|
822
|
+
# Be more permissive about names matching for positional-only arguments
|
|
823
|
+
if runtime_arg.kind == inspect.Parameter.POSITIONAL_ONLY and names_approx_match(
|
|
824
|
+
stub_arg.variable.name, runtime_arg.name
|
|
825
|
+
):
|
|
826
|
+
return
|
|
827
|
+
# This comes up with namedtuples, so ignore
|
|
828
|
+
if stub_arg.variable.name == "_self":
|
|
829
|
+
return
|
|
830
|
+
yield (
|
|
831
|
+
f'stub parameter "{stub_arg.variable.name}" '
|
|
832
|
+
f'differs from runtime parameter "{runtime_arg.name}"'
|
|
833
|
+
)
|
|
834
|
+
|
|
835
|
+
|
|
836
|
+
def _verify_arg_default_value(
|
|
837
|
+
stub_arg: nodes.Argument, runtime_arg: inspect.Parameter
|
|
838
|
+
) -> Iterator[str]:
|
|
839
|
+
"""Checks whether argument default values are compatible."""
|
|
840
|
+
if runtime_arg.default is not inspect.Parameter.empty:
|
|
841
|
+
if stub_arg.kind.is_required():
|
|
842
|
+
yield (
|
|
843
|
+
f'runtime parameter "{runtime_arg.name}" '
|
|
844
|
+
"has a default value but stub parameter does not"
|
|
845
|
+
)
|
|
846
|
+
else:
|
|
847
|
+
type_context = stub_arg.variable.type
|
|
848
|
+
runtime_type = get_mypy_type_of_runtime_value(
|
|
849
|
+
runtime_arg.default, type_context=type_context
|
|
850
|
+
)
|
|
851
|
+
|
|
852
|
+
# Fallback to the type annotation type if var type is missing. The type annotation
|
|
853
|
+
# is an UnboundType, but I don't know enough to know what the pros and cons here are.
|
|
854
|
+
# UnboundTypes have ugly question marks following them, so default to var type.
|
|
855
|
+
# Note we do this same fallback when constructing signatures in from_overloadedfuncdef
|
|
856
|
+
stub_type = stub_arg.variable.type or stub_arg.type_annotation
|
|
857
|
+
if isinstance(stub_type, mypy.types.TypeVarType):
|
|
858
|
+
stub_type = stub_type.upper_bound
|
|
859
|
+
if (
|
|
860
|
+
runtime_type is not None
|
|
861
|
+
and stub_type is not None
|
|
862
|
+
# Avoid false positives for marker objects
|
|
863
|
+
and type(runtime_arg.default) is not object
|
|
864
|
+
# And ellipsis
|
|
865
|
+
and runtime_arg.default is not ...
|
|
866
|
+
# And sentinels
|
|
867
|
+
and not is_sentinel(runtime_type)
|
|
868
|
+
and not is_subtype_helper(runtime_type, stub_type)
|
|
869
|
+
):
|
|
870
|
+
yield (
|
|
871
|
+
f'runtime parameter "{runtime_arg.name}" '
|
|
872
|
+
f"has a default value of type {runtime_type}, "
|
|
873
|
+
f"which is incompatible with stub parameter type {stub_type}"
|
|
874
|
+
)
|
|
875
|
+
if stub_arg.initializer is not None:
|
|
876
|
+
stub_default = evaluate_expression(stub_arg.initializer)
|
|
877
|
+
if (
|
|
878
|
+
stub_default is not UNKNOWN
|
|
879
|
+
and stub_default is not ...
|
|
880
|
+
and runtime_arg.default is not UNREPRESENTABLE
|
|
881
|
+
):
|
|
882
|
+
defaults_match = True
|
|
883
|
+
# We want the types to match exactly, e.g. in case the stub has
|
|
884
|
+
# True and the runtime has 1 (or vice versa).
|
|
885
|
+
if type(stub_default) is not type(runtime_arg.default):
|
|
886
|
+
defaults_match = False
|
|
887
|
+
else:
|
|
888
|
+
try:
|
|
889
|
+
defaults_match = bool(stub_default == runtime_arg.default)
|
|
890
|
+
except Exception:
|
|
891
|
+
# Exception can be raised in bool dunder method (e.g. numpy arrays)
|
|
892
|
+
# At this point, consider the default to be different, it is probably
|
|
893
|
+
# too complex to put in a stub anyway.
|
|
894
|
+
defaults_match = False
|
|
895
|
+
if not defaults_match:
|
|
896
|
+
yield (
|
|
897
|
+
f'runtime parameter "{runtime_arg.name}" '
|
|
898
|
+
f"has a default value of {runtime_arg.default!r}, "
|
|
899
|
+
f"which is different from stub parameter default {stub_default!r}"
|
|
900
|
+
)
|
|
901
|
+
else:
|
|
902
|
+
if stub_arg.kind.is_optional():
|
|
903
|
+
yield (
|
|
904
|
+
f'stub parameter "{stub_arg.variable.name}" has a default value '
|
|
905
|
+
f"but runtime parameter does not"
|
|
906
|
+
)
|
|
907
|
+
|
|
908
|
+
|
|
909
|
+
def maybe_strip_cls(name: str, args: list[nodes.Argument]) -> list[nodes.Argument]:
|
|
910
|
+
if args and name in ("__init_subclass__", "__class_getitem__"):
|
|
911
|
+
# These are implicitly classmethods. If the stub chooses not to have @classmethod, we
|
|
912
|
+
# should remove the cls argument
|
|
913
|
+
if args[0].variable.name == "cls":
|
|
914
|
+
return args[1:]
|
|
915
|
+
return args
|
|
916
|
+
|
|
917
|
+
|
|
918
|
+
class Signature(Generic[T]):
|
|
919
|
+
def __init__(self) -> None:
|
|
920
|
+
self.pos: list[T] = []
|
|
921
|
+
self.kwonly: dict[str, T] = {}
|
|
922
|
+
self.varpos: T | None = None
|
|
923
|
+
self.varkw: T | None = None
|
|
924
|
+
|
|
925
|
+
def __str__(self) -> str:
|
|
926
|
+
def get_name(arg: Any) -> str:
|
|
927
|
+
if isinstance(arg, inspect.Parameter):
|
|
928
|
+
return arg.name
|
|
929
|
+
if isinstance(arg, nodes.Argument):
|
|
930
|
+
return arg.variable.name
|
|
931
|
+
raise AssertionError
|
|
932
|
+
|
|
933
|
+
def get_type(arg: Any) -> str | None:
|
|
934
|
+
if isinstance(arg, inspect.Parameter):
|
|
935
|
+
return None
|
|
936
|
+
if isinstance(arg, nodes.Argument):
|
|
937
|
+
return str(arg.variable.type or arg.type_annotation)
|
|
938
|
+
raise AssertionError
|
|
939
|
+
|
|
940
|
+
def has_default(arg: Any) -> bool:
|
|
941
|
+
if isinstance(arg, inspect.Parameter):
|
|
942
|
+
return arg.default is not inspect.Parameter.empty
|
|
943
|
+
if isinstance(arg, nodes.Argument):
|
|
944
|
+
return arg.kind.is_optional()
|
|
945
|
+
raise AssertionError
|
|
946
|
+
|
|
947
|
+
def get_desc(arg: Any) -> str:
|
|
948
|
+
arg_type = get_type(arg)
|
|
949
|
+
return (
|
|
950
|
+
get_name(arg)
|
|
951
|
+
+ (f": {arg_type}" if arg_type else "")
|
|
952
|
+
+ (" = ..." if has_default(arg) else "")
|
|
953
|
+
)
|
|
954
|
+
|
|
955
|
+
kw_only = sorted(self.kwonly.values(), key=lambda a: (has_default(a), get_name(a)))
|
|
956
|
+
ret = "def ("
|
|
957
|
+
ret += ", ".join(
|
|
958
|
+
[get_desc(arg) for arg in self.pos]
|
|
959
|
+
+ (["*" + get_name(self.varpos)] if self.varpos else (["*"] if self.kwonly else []))
|
|
960
|
+
+ [get_desc(arg) for arg in kw_only]
|
|
961
|
+
+ (["**" + get_name(self.varkw)] if self.varkw else [])
|
|
962
|
+
)
|
|
963
|
+
ret += ")"
|
|
964
|
+
return ret
|
|
965
|
+
|
|
966
|
+
@staticmethod
|
|
967
|
+
def from_funcitem(stub: nodes.FuncItem) -> Signature[nodes.Argument]:
|
|
968
|
+
stub_sig: Signature[nodes.Argument] = Signature()
|
|
969
|
+
stub_args = maybe_strip_cls(stub.name, stub.arguments)
|
|
970
|
+
for stub_arg in stub_args:
|
|
971
|
+
if stub_arg.kind.is_positional():
|
|
972
|
+
stub_sig.pos.append(stub_arg)
|
|
973
|
+
elif stub_arg.kind.is_named():
|
|
974
|
+
stub_sig.kwonly[stub_arg.variable.name] = stub_arg
|
|
975
|
+
elif stub_arg.kind == nodes.ARG_STAR:
|
|
976
|
+
stub_sig.varpos = stub_arg
|
|
977
|
+
elif stub_arg.kind == nodes.ARG_STAR2:
|
|
978
|
+
if stub_arg.variable.type is not None and isinstance(
|
|
979
|
+
(typed_dict_arg := mypy.types.get_proper_type(stub_arg.variable.type)),
|
|
980
|
+
mypy.types.TypedDictType,
|
|
981
|
+
):
|
|
982
|
+
for key_name, key_type in typed_dict_arg.items.items():
|
|
983
|
+
optional = key_name not in typed_dict_arg.required_keys
|
|
984
|
+
stub_sig.kwonly[key_name] = nodes.Argument(
|
|
985
|
+
nodes.Var(key_name, key_type),
|
|
986
|
+
type_annotation=key_type,
|
|
987
|
+
initializer=nodes.EllipsisExpr() if optional else None,
|
|
988
|
+
kind=nodes.ARG_NAMED_OPT if optional else nodes.ARG_NAMED,
|
|
989
|
+
pos_only=False,
|
|
990
|
+
)
|
|
991
|
+
else:
|
|
992
|
+
stub_sig.varkw = stub_arg
|
|
993
|
+
else:
|
|
994
|
+
raise AssertionError
|
|
995
|
+
return stub_sig
|
|
996
|
+
|
|
997
|
+
@staticmethod
|
|
998
|
+
def from_inspect_signature(signature: inspect.Signature) -> Signature[inspect.Parameter]:
|
|
999
|
+
runtime_sig: Signature[inspect.Parameter] = Signature()
|
|
1000
|
+
for runtime_arg in signature.parameters.values():
|
|
1001
|
+
if runtime_arg.kind in (
|
|
1002
|
+
inspect.Parameter.POSITIONAL_ONLY,
|
|
1003
|
+
inspect.Parameter.POSITIONAL_OR_KEYWORD,
|
|
1004
|
+
):
|
|
1005
|
+
runtime_sig.pos.append(runtime_arg)
|
|
1006
|
+
elif runtime_arg.kind == inspect.Parameter.KEYWORD_ONLY:
|
|
1007
|
+
runtime_sig.kwonly[runtime_arg.name] = runtime_arg
|
|
1008
|
+
elif runtime_arg.kind == inspect.Parameter.VAR_POSITIONAL:
|
|
1009
|
+
runtime_sig.varpos = runtime_arg
|
|
1010
|
+
elif runtime_arg.kind == inspect.Parameter.VAR_KEYWORD:
|
|
1011
|
+
runtime_sig.varkw = runtime_arg
|
|
1012
|
+
else:
|
|
1013
|
+
raise AssertionError
|
|
1014
|
+
return runtime_sig
|
|
1015
|
+
|
|
1016
|
+
@staticmethod
|
|
1017
|
+
def from_overloadedfuncdef(stub: nodes.OverloadedFuncDef) -> Signature[nodes.Argument]:
|
|
1018
|
+
"""Returns a Signature from an OverloadedFuncDef.
|
|
1019
|
+
|
|
1020
|
+
If life were simple, to verify_overloadedfuncdef, we'd just verify_funcitem for each of its
|
|
1021
|
+
items. Unfortunately, life isn't simple and overloads are pretty deceitful. So instead, we
|
|
1022
|
+
try and combine the overload's items into a single signature that is compatible with any
|
|
1023
|
+
lies it might try to tell.
|
|
1024
|
+
|
|
1025
|
+
"""
|
|
1026
|
+
# For most dunder methods, just assume all args are positional-only
|
|
1027
|
+
assume_positional_only = is_dunder(stub.name, exclude_special=True)
|
|
1028
|
+
|
|
1029
|
+
is_arg_pos_only: defaultdict[str, set[bool]] = defaultdict(set)
|
|
1030
|
+
for func in map(_resolve_funcitem_from_decorator, stub.items):
|
|
1031
|
+
assert func is not None, f"Failed to resolve decorated overload of {stub.fullname!r}"
|
|
1032
|
+
args = maybe_strip_cls(stub.name, func.arguments)
|
|
1033
|
+
for index, arg in enumerate(args):
|
|
1034
|
+
if (
|
|
1035
|
+
arg.variable.name.startswith("__")
|
|
1036
|
+
or arg.pos_only
|
|
1037
|
+
or assume_positional_only
|
|
1038
|
+
or arg.variable.name.strip("_") == "self"
|
|
1039
|
+
or (index == 0 and arg.variable.name.strip("_") == "cls")
|
|
1040
|
+
):
|
|
1041
|
+
is_arg_pos_only[arg.variable.name].add(True)
|
|
1042
|
+
else:
|
|
1043
|
+
is_arg_pos_only[arg.variable.name].add(False)
|
|
1044
|
+
|
|
1045
|
+
all_args: dict[str, list[tuple[nodes.Argument, int]]] = {}
|
|
1046
|
+
for func in map(_resolve_funcitem_from_decorator, stub.items):
|
|
1047
|
+
assert func is not None, f"Failed to resolve decorated overload of {stub.fullname!r}"
|
|
1048
|
+
args = maybe_strip_cls(stub.name, func.arguments)
|
|
1049
|
+
for index, arg in enumerate(args):
|
|
1050
|
+
# For positional-only args, we allow overloads to have different names for the same
|
|
1051
|
+
# argument. To accomplish this, we just make up a fake index-based name.
|
|
1052
|
+
# We can only use the index-based name if the argument is always
|
|
1053
|
+
# positional only. Sometimes overloads have an arg as positional-only
|
|
1054
|
+
# in some but not all branches of the overload.
|
|
1055
|
+
name = arg.variable.name
|
|
1056
|
+
if is_arg_pos_only[name] == {True}:
|
|
1057
|
+
name = f"__{index}"
|
|
1058
|
+
|
|
1059
|
+
all_args.setdefault(name, []).append((arg, index))
|
|
1060
|
+
|
|
1061
|
+
def get_position(arg_name: str) -> int:
|
|
1062
|
+
# We just need this to return the positional args in the correct order.
|
|
1063
|
+
return max(index for _, index in all_args[arg_name])
|
|
1064
|
+
|
|
1065
|
+
def get_type(arg_name: str) -> mypy.types.ProperType:
|
|
1066
|
+
with mypy.state.state.strict_optional_set(True):
|
|
1067
|
+
all_types = [
|
|
1068
|
+
arg.variable.type or arg.type_annotation for arg, _ in all_args[arg_name]
|
|
1069
|
+
]
|
|
1070
|
+
return mypy.typeops.make_simplified_union([t for t in all_types if t])
|
|
1071
|
+
|
|
1072
|
+
def get_kind(arg_name: str) -> nodes.ArgKind:
|
|
1073
|
+
kinds = {arg.kind for arg, _ in all_args[arg_name]}
|
|
1074
|
+
if nodes.ARG_STAR in kinds:
|
|
1075
|
+
return nodes.ARG_STAR
|
|
1076
|
+
if nodes.ARG_STAR2 in kinds:
|
|
1077
|
+
return nodes.ARG_STAR2
|
|
1078
|
+
# The logic here is based on two tenets:
|
|
1079
|
+
# 1) If an arg is ever optional (or unspecified), it is optional
|
|
1080
|
+
# 2) If an arg is ever positional, it is positional
|
|
1081
|
+
is_opt = (
|
|
1082
|
+
len(all_args[arg_name]) < len(stub.items)
|
|
1083
|
+
or nodes.ARG_OPT in kinds
|
|
1084
|
+
or nodes.ARG_NAMED_OPT in kinds
|
|
1085
|
+
)
|
|
1086
|
+
is_pos = nodes.ARG_OPT in kinds or nodes.ARG_POS in kinds
|
|
1087
|
+
if is_opt:
|
|
1088
|
+
return nodes.ARG_OPT if is_pos else nodes.ARG_NAMED_OPT
|
|
1089
|
+
return nodes.ARG_POS if is_pos else nodes.ARG_NAMED
|
|
1090
|
+
|
|
1091
|
+
sig: Signature[nodes.Argument] = Signature()
|
|
1092
|
+
for arg_name in sorted(all_args, key=get_position):
|
|
1093
|
+
# example_arg_name gives us a real name (in case we had a fake index-based name)
|
|
1094
|
+
example_arg_name = all_args[arg_name][0][0].variable.name
|
|
1095
|
+
arg = nodes.Argument(
|
|
1096
|
+
nodes.Var(example_arg_name, get_type(arg_name)),
|
|
1097
|
+
type_annotation=None,
|
|
1098
|
+
initializer=None,
|
|
1099
|
+
kind=get_kind(arg_name),
|
|
1100
|
+
pos_only=all(arg.pos_only for arg, _ in all_args[arg_name]),
|
|
1101
|
+
)
|
|
1102
|
+
if arg.kind.is_positional():
|
|
1103
|
+
sig.pos.append(arg)
|
|
1104
|
+
elif arg.kind.is_named():
|
|
1105
|
+
sig.kwonly[arg.variable.name] = arg
|
|
1106
|
+
elif arg.kind == nodes.ARG_STAR:
|
|
1107
|
+
sig.varpos = arg
|
|
1108
|
+
elif arg.kind == nodes.ARG_STAR2:
|
|
1109
|
+
sig.varkw = arg
|
|
1110
|
+
else:
|
|
1111
|
+
raise AssertionError
|
|
1112
|
+
return sig
|
|
1113
|
+
|
|
1114
|
+
|
|
1115
|
+
def _verify_signature(
|
|
1116
|
+
stub: Signature[nodes.Argument],
|
|
1117
|
+
runtime: Signature[inspect.Parameter],
|
|
1118
|
+
function_name: str,
|
|
1119
|
+
warn_runtime_is_object_init: bool = False,
|
|
1120
|
+
) -> Iterator[str]:
|
|
1121
|
+
# Check positional arguments match up
|
|
1122
|
+
for stub_arg, runtime_arg in zip(stub.pos, runtime.pos):
|
|
1123
|
+
yield from _verify_arg_name(stub_arg, runtime_arg, function_name)
|
|
1124
|
+
yield from _verify_arg_default_value(stub_arg, runtime_arg)
|
|
1125
|
+
if (
|
|
1126
|
+
runtime_arg.kind == inspect.Parameter.POSITIONAL_ONLY
|
|
1127
|
+
and not stub_arg.pos_only
|
|
1128
|
+
and not stub_arg.variable.name.startswith("__")
|
|
1129
|
+
and stub_arg.variable.name.strip("_") != "self"
|
|
1130
|
+
and stub_arg.variable.name.strip("_") != "cls"
|
|
1131
|
+
):
|
|
1132
|
+
yield (
|
|
1133
|
+
f'stub parameter "{stub_arg.variable.name}" should be positional-only '
|
|
1134
|
+
f'(add "/", e.g. "{runtime_arg.name}, /")'
|
|
1135
|
+
)
|
|
1136
|
+
if (
|
|
1137
|
+
runtime_arg.kind != inspect.Parameter.POSITIONAL_ONLY
|
|
1138
|
+
and (stub_arg.pos_only or stub_arg.variable.name.startswith("__"))
|
|
1139
|
+
and not runtime_arg.name.startswith("__")
|
|
1140
|
+
and stub_arg.variable.name.strip("_") != "self"
|
|
1141
|
+
and stub_arg.variable.name.strip("_") != "cls"
|
|
1142
|
+
and not is_dunder(function_name, exclude_special=True) # noisy for dunder methods
|
|
1143
|
+
):
|
|
1144
|
+
yield (
|
|
1145
|
+
f'stub parameter "{stub_arg.variable.name}" should be positional or keyword '
|
|
1146
|
+
'(remove "/")'
|
|
1147
|
+
)
|
|
1148
|
+
|
|
1149
|
+
# Check unmatched positional args
|
|
1150
|
+
if len(stub.pos) > len(runtime.pos):
|
|
1151
|
+
# There are cases where the stub exhaustively lists out the extra parameters the function
|
|
1152
|
+
# would take through *args. Hence, a) if runtime accepts *args, we don't check whether the
|
|
1153
|
+
# runtime has all of the stub's parameters, b) below, we don't enforce that the stub takes
|
|
1154
|
+
# *args, since runtime logic may prevent arbitrary arguments from actually being accepted.
|
|
1155
|
+
if runtime.varpos is None:
|
|
1156
|
+
for stub_arg in stub.pos[len(runtime.pos) :]:
|
|
1157
|
+
# If the variable is in runtime.kwonly, it's just mislabelled as not a
|
|
1158
|
+
# keyword-only argument
|
|
1159
|
+
if stub_arg.variable.name not in runtime.kwonly:
|
|
1160
|
+
msg = f'runtime does not have parameter "{stub_arg.variable.name}"'
|
|
1161
|
+
if runtime.varkw is not None:
|
|
1162
|
+
msg += ". Maybe you forgot to make it keyword-only in the stub?"
|
|
1163
|
+
elif warn_runtime_is_object_init:
|
|
1164
|
+
msg += ". You may need to write stubs for __new__ instead of __init__."
|
|
1165
|
+
yield msg
|
|
1166
|
+
else:
|
|
1167
|
+
yield f'stub parameter "{stub_arg.variable.name}" is not keyword-only'
|
|
1168
|
+
if stub.varpos is not None:
|
|
1169
|
+
yield f'runtime does not have *args parameter "{stub.varpos.variable.name}"'
|
|
1170
|
+
elif len(stub.pos) < len(runtime.pos):
|
|
1171
|
+
for runtime_arg in runtime.pos[len(stub.pos) :]:
|
|
1172
|
+
if runtime_arg.name not in stub.kwonly:
|
|
1173
|
+
if not _is_private_parameter(runtime_arg):
|
|
1174
|
+
yield f'stub does not have parameter "{runtime_arg.name}"'
|
|
1175
|
+
else:
|
|
1176
|
+
yield f'runtime parameter "{runtime_arg.name}" is not keyword-only'
|
|
1177
|
+
|
|
1178
|
+
# Checks involving *args
|
|
1179
|
+
if len(stub.pos) <= len(runtime.pos) or runtime.varpos is None:
|
|
1180
|
+
if stub.varpos is None and runtime.varpos is not None:
|
|
1181
|
+
yield f'stub does not have *args parameter "{runtime.varpos.name}"'
|
|
1182
|
+
if stub.varpos is not None and runtime.varpos is None:
|
|
1183
|
+
yield f'runtime does not have *args parameter "{stub.varpos.variable.name}"'
|
|
1184
|
+
|
|
1185
|
+
# Check keyword-only args
|
|
1186
|
+
for arg in sorted(set(stub.kwonly) & set(runtime.kwonly)):
|
|
1187
|
+
stub_arg, runtime_arg = stub.kwonly[arg], runtime.kwonly[arg]
|
|
1188
|
+
yield from _verify_arg_name(stub_arg, runtime_arg, function_name)
|
|
1189
|
+
yield from _verify_arg_default_value(stub_arg, runtime_arg)
|
|
1190
|
+
|
|
1191
|
+
# Check unmatched keyword-only args
|
|
1192
|
+
if runtime.varkw is None or not set(runtime.kwonly).issubset(set(stub.kwonly)):
|
|
1193
|
+
# There are cases where the stub exhaustively lists out the extra parameters the function
|
|
1194
|
+
# would take through **kwargs. Hence, a) if runtime accepts **kwargs (and the stub hasn't
|
|
1195
|
+
# exhaustively listed out params), we don't check whether the runtime has all of the stub's
|
|
1196
|
+
# parameters, b) below, we don't enforce that the stub takes **kwargs, since runtime logic
|
|
1197
|
+
# may prevent arbitrary keyword arguments from actually being accepted.
|
|
1198
|
+
for arg in sorted(set(stub.kwonly) - set(runtime.kwonly)):
|
|
1199
|
+
if arg in {runtime_arg.name for runtime_arg in runtime.pos}:
|
|
1200
|
+
# Don't report this if we've reported it before
|
|
1201
|
+
if arg not in {runtime_arg.name for runtime_arg in runtime.pos[len(stub.pos) :]}:
|
|
1202
|
+
yield f'runtime parameter "{arg}" is not keyword-only'
|
|
1203
|
+
else:
|
|
1204
|
+
msg = f'runtime does not have parameter "{arg}"'
|
|
1205
|
+
if warn_runtime_is_object_init:
|
|
1206
|
+
msg += ". You may need to write stubs for __new__ instead of __init__."
|
|
1207
|
+
yield msg
|
|
1208
|
+
|
|
1209
|
+
for arg in sorted(set(runtime.kwonly) - set(stub.kwonly)):
|
|
1210
|
+
if arg in {stub_arg.variable.name for stub_arg in stub.pos}:
|
|
1211
|
+
# Don't report this if we've reported it before
|
|
1212
|
+
if not (
|
|
1213
|
+
runtime.varpos is None
|
|
1214
|
+
and arg in {stub_arg.variable.name for stub_arg in stub.pos[len(runtime.pos) :]}
|
|
1215
|
+
):
|
|
1216
|
+
yield f'stub parameter "{arg}" is not keyword-only'
|
|
1217
|
+
else:
|
|
1218
|
+
if not _is_private_parameter(runtime.kwonly[arg]):
|
|
1219
|
+
yield f'stub does not have parameter "{arg}"'
|
|
1220
|
+
|
|
1221
|
+
# Checks involving **kwargs
|
|
1222
|
+
if stub.varkw is None and runtime.varkw is not None:
|
|
1223
|
+
# As mentioned above, don't enforce that the stub takes **kwargs.
|
|
1224
|
+
# Also check against positional parameters, to avoid a nitpicky message when an argument
|
|
1225
|
+
# isn't marked as keyword-only
|
|
1226
|
+
stub_pos_names = {stub_arg.variable.name for stub_arg in stub.pos}
|
|
1227
|
+
# Ideally we'd do a strict subset check, but in practice the errors from that aren't useful
|
|
1228
|
+
if not set(runtime.kwonly).issubset(set(stub.kwonly) | stub_pos_names):
|
|
1229
|
+
yield f'stub does not have **kwargs parameter "{runtime.varkw.name}"'
|
|
1230
|
+
if stub.varkw is not None and runtime.varkw is None:
|
|
1231
|
+
yield f'runtime does not have **kwargs parameter "{stub.varkw.variable.name}"'
|
|
1232
|
+
|
|
1233
|
+
|
|
1234
|
+
def _is_private_parameter(arg: inspect.Parameter) -> bool:
|
|
1235
|
+
return (
|
|
1236
|
+
arg.name.startswith("_")
|
|
1237
|
+
and not arg.name.startswith("__")
|
|
1238
|
+
and arg.default is not inspect.Parameter.empty
|
|
1239
|
+
)
|
|
1240
|
+
|
|
1241
|
+
|
|
1242
|
+
@verify.register(nodes.FuncItem)
|
|
1243
|
+
def verify_funcitem(
|
|
1244
|
+
stub: nodes.FuncItem, runtime: MaybeMissing[Any], object_path: list[str]
|
|
1245
|
+
) -> Iterator[Error]:
|
|
1246
|
+
if isinstance(runtime, Missing):
|
|
1247
|
+
yield Error(object_path, "is not present at runtime", stub, runtime)
|
|
1248
|
+
return
|
|
1249
|
+
|
|
1250
|
+
if not is_probably_a_function(runtime):
|
|
1251
|
+
yield Error(object_path, "is not a function", stub, runtime)
|
|
1252
|
+
if not callable(runtime):
|
|
1253
|
+
return
|
|
1254
|
+
|
|
1255
|
+
# Look the object up statically, to avoid binding by the descriptor protocol
|
|
1256
|
+
static_runtime = _static_lookup_runtime(object_path)
|
|
1257
|
+
|
|
1258
|
+
if isinstance(stub, nodes.FuncDef):
|
|
1259
|
+
for error_text in _verify_abstract_status(stub, runtime):
|
|
1260
|
+
yield Error(object_path, error_text, stub, runtime)
|
|
1261
|
+
for error_text in _verify_final_method(stub, runtime, static_runtime):
|
|
1262
|
+
yield Error(object_path, error_text, stub, runtime)
|
|
1263
|
+
|
|
1264
|
+
for message in _verify_static_class_methods(stub, runtime, static_runtime, object_path):
|
|
1265
|
+
yield Error(object_path, "is inconsistent, " + message, stub, runtime)
|
|
1266
|
+
|
|
1267
|
+
signature = safe_inspect_signature(runtime)
|
|
1268
|
+
runtime_is_coroutine = inspect.iscoroutinefunction(runtime)
|
|
1269
|
+
|
|
1270
|
+
if signature:
|
|
1271
|
+
stub_sig = Signature.from_funcitem(stub)
|
|
1272
|
+
runtime_sig = Signature.from_inspect_signature(signature)
|
|
1273
|
+
runtime_sig_desc = describe_runtime_callable(signature, is_async=runtime_is_coroutine)
|
|
1274
|
+
stub_desc = str(stub_sig)
|
|
1275
|
+
else:
|
|
1276
|
+
runtime_sig_desc, stub_desc = None, None
|
|
1277
|
+
|
|
1278
|
+
# Don't raise an error if the stub is a coroutine, but the runtime isn't.
|
|
1279
|
+
# That results in false positives.
|
|
1280
|
+
# See https://github.com/python/typeshed/issues/7344
|
|
1281
|
+
if runtime_is_coroutine and not stub.is_coroutine:
|
|
1282
|
+
yield Error(
|
|
1283
|
+
object_path,
|
|
1284
|
+
'is an "async def" function at runtime, but not in the stub',
|
|
1285
|
+
stub,
|
|
1286
|
+
runtime,
|
|
1287
|
+
stub_desc=stub_desc,
|
|
1288
|
+
runtime_desc=runtime_sig_desc,
|
|
1289
|
+
)
|
|
1290
|
+
|
|
1291
|
+
if not signature:
|
|
1292
|
+
return
|
|
1293
|
+
|
|
1294
|
+
for message in _verify_signature(
|
|
1295
|
+
stub_sig,
|
|
1296
|
+
runtime_sig,
|
|
1297
|
+
function_name=stub.name,
|
|
1298
|
+
warn_runtime_is_object_init=runtime is object.__init__,
|
|
1299
|
+
):
|
|
1300
|
+
yield Error(
|
|
1301
|
+
object_path,
|
|
1302
|
+
"is inconsistent, " + message,
|
|
1303
|
+
stub,
|
|
1304
|
+
runtime,
|
|
1305
|
+
runtime_desc=runtime_sig_desc,
|
|
1306
|
+
)
|
|
1307
|
+
|
|
1308
|
+
|
|
1309
|
+
@verify.register(Missing)
|
|
1310
|
+
def verify_missing(
|
|
1311
|
+
stub: Missing, runtime: MaybeMissing[Any], object_path: list[str]
|
|
1312
|
+
) -> Iterator[Error]:
|
|
1313
|
+
if runtime is MISSING:
|
|
1314
|
+
return
|
|
1315
|
+
yield Error(object_path, "is not present in stub", stub, runtime)
|
|
1316
|
+
|
|
1317
|
+
|
|
1318
|
+
@verify.register(nodes.Var)
|
|
1319
|
+
def verify_var(
|
|
1320
|
+
stub: nodes.Var, runtime: MaybeMissing[Any], object_path: list[str]
|
|
1321
|
+
) -> Iterator[Error]:
|
|
1322
|
+
if isinstance(runtime, Missing):
|
|
1323
|
+
# Don't always yield an error here, because we often can't find instance variables
|
|
1324
|
+
if len(object_path) <= 2:
|
|
1325
|
+
yield Error(object_path, "is not present at runtime", stub, runtime)
|
|
1326
|
+
return
|
|
1327
|
+
|
|
1328
|
+
if (
|
|
1329
|
+
stub.is_initialized_in_class
|
|
1330
|
+
and is_read_only_property(runtime)
|
|
1331
|
+
and (stub.is_settable_property or not stub.is_property)
|
|
1332
|
+
):
|
|
1333
|
+
yield Error(object_path, "is read-only at runtime but not in the stub", stub, runtime)
|
|
1334
|
+
|
|
1335
|
+
runtime_type = get_mypy_type_of_runtime_value(runtime, type_context=stub.type)
|
|
1336
|
+
note = ""
|
|
1337
|
+
if (
|
|
1338
|
+
runtime_type is not None
|
|
1339
|
+
and stub.type is not None
|
|
1340
|
+
and not is_subtype_helper(runtime_type, stub.type)
|
|
1341
|
+
):
|
|
1342
|
+
should_error = True
|
|
1343
|
+
# Avoid errors when defining enums, since runtime_type is the enum itself, but we'd
|
|
1344
|
+
# annotate it with the type of runtime.value
|
|
1345
|
+
if isinstance(runtime, enum.Enum):
|
|
1346
|
+
runtime_type = get_mypy_type_of_runtime_value(runtime.value)
|
|
1347
|
+
if runtime_type is not None and is_subtype_helper(runtime_type, stub.type):
|
|
1348
|
+
should_error = False
|
|
1349
|
+
# We always allow setting the stub value to Ellipsis (...), but use
|
|
1350
|
+
# _value_ type as a fallback if given. If a member is ... and _value_
|
|
1351
|
+
# type is given, all runtime types should be assignable to _value_.
|
|
1352
|
+
proper_type = mypy.types.get_proper_type(stub.type)
|
|
1353
|
+
if (
|
|
1354
|
+
isinstance(proper_type, mypy.types.Instance)
|
|
1355
|
+
and proper_type.type.fullname in mypy.types.ELLIPSIS_TYPE_NAMES
|
|
1356
|
+
):
|
|
1357
|
+
value_t = stub.info.get("_value_")
|
|
1358
|
+
if value_t is None or value_t.type is None or runtime_type is None:
|
|
1359
|
+
should_error = False
|
|
1360
|
+
elif is_subtype_helper(runtime_type, value_t.type):
|
|
1361
|
+
should_error = False
|
|
1362
|
+
else:
|
|
1363
|
+
note = " (incompatible '_value_')"
|
|
1364
|
+
|
|
1365
|
+
if should_error:
|
|
1366
|
+
yield Error(
|
|
1367
|
+
object_path,
|
|
1368
|
+
f"variable differs from runtime type {runtime_type}{note}",
|
|
1369
|
+
stub,
|
|
1370
|
+
runtime,
|
|
1371
|
+
)
|
|
1372
|
+
elif stub.final_value is not None and stub.final_value != runtime:
|
|
1373
|
+
yield Error(
|
|
1374
|
+
object_path,
|
|
1375
|
+
"is inconsistent, stub value for Final var differs from runtime value",
|
|
1376
|
+
stub,
|
|
1377
|
+
runtime,
|
|
1378
|
+
stub_desc=repr(stub.final_value),
|
|
1379
|
+
)
|
|
1380
|
+
|
|
1381
|
+
|
|
1382
|
+
@verify.register(nodes.OverloadedFuncDef)
|
|
1383
|
+
def verify_overloadedfuncdef(
|
|
1384
|
+
stub: nodes.OverloadedFuncDef, runtime: MaybeMissing[Any], object_path: list[str]
|
|
1385
|
+
) -> Iterator[Error]:
|
|
1386
|
+
# TODO: support `@type_check_only` decorator
|
|
1387
|
+
if isinstance(runtime, Missing):
|
|
1388
|
+
yield Error(object_path, "is not present at runtime", stub, runtime)
|
|
1389
|
+
return
|
|
1390
|
+
|
|
1391
|
+
if stub.is_property:
|
|
1392
|
+
# Any property with a setter is represented as an OverloadedFuncDef
|
|
1393
|
+
if is_read_only_property(runtime):
|
|
1394
|
+
yield Error(object_path, "is read-only at runtime but not in the stub", stub, runtime)
|
|
1395
|
+
return
|
|
1396
|
+
|
|
1397
|
+
if not is_probably_a_function(runtime):
|
|
1398
|
+
yield Error(object_path, "is not a function", stub, runtime)
|
|
1399
|
+
if not callable(runtime):
|
|
1400
|
+
return
|
|
1401
|
+
|
|
1402
|
+
# mypy doesn't allow overloads where one overload is abstract but another isn't,
|
|
1403
|
+
# so it should be okay to just check whether the first overload is abstract or not.
|
|
1404
|
+
#
|
|
1405
|
+
# TODO: Mypy *does* allow properties where e.g. the getter is abstract but the setter is not;
|
|
1406
|
+
# and any property with a setter is represented as an OverloadedFuncDef internally;
|
|
1407
|
+
# not sure exactly what (if anything) we should do about that.
|
|
1408
|
+
first_part = stub.items[0]
|
|
1409
|
+
if isinstance(first_part, nodes.Decorator) and first_part.is_overload:
|
|
1410
|
+
for msg in _verify_abstract_status(first_part.func, runtime):
|
|
1411
|
+
yield Error(object_path, msg, stub, runtime)
|
|
1412
|
+
|
|
1413
|
+
# Look the object up statically, to avoid binding by the descriptor protocol
|
|
1414
|
+
static_runtime = _static_lookup_runtime(object_path)
|
|
1415
|
+
|
|
1416
|
+
for message in _verify_static_class_methods(stub, runtime, static_runtime, object_path):
|
|
1417
|
+
yield Error(object_path, "is inconsistent, " + message, stub, runtime)
|
|
1418
|
+
|
|
1419
|
+
# TODO: Should call _verify_final_method here,
|
|
1420
|
+
# but overloaded final methods in stubs cause a stubtest crash: see #14950
|
|
1421
|
+
|
|
1422
|
+
signature = safe_inspect_signature(runtime)
|
|
1423
|
+
if not signature:
|
|
1424
|
+
return
|
|
1425
|
+
|
|
1426
|
+
stub_sig = Signature.from_overloadedfuncdef(stub)
|
|
1427
|
+
runtime_sig = Signature.from_inspect_signature(signature)
|
|
1428
|
+
|
|
1429
|
+
for message in _verify_signature(
|
|
1430
|
+
stub_sig,
|
|
1431
|
+
runtime_sig,
|
|
1432
|
+
function_name=stub.name,
|
|
1433
|
+
warn_runtime_is_object_init=runtime is object.__init__,
|
|
1434
|
+
):
|
|
1435
|
+
# TODO: This is a little hacky, but the addition here is super useful
|
|
1436
|
+
if "has a default value of type" in message:
|
|
1437
|
+
message += (
|
|
1438
|
+
". This is often caused by overloads failing to account for explicitly passing "
|
|
1439
|
+
"in the default value."
|
|
1440
|
+
)
|
|
1441
|
+
yield Error(
|
|
1442
|
+
object_path,
|
|
1443
|
+
"is inconsistent, " + message,
|
|
1444
|
+
stub,
|
|
1445
|
+
runtime,
|
|
1446
|
+
stub_desc=(str(stub.type)) + f"\nInferred signature: {stub_sig}",
|
|
1447
|
+
runtime_desc="def " + str(signature),
|
|
1448
|
+
)
|
|
1449
|
+
|
|
1450
|
+
|
|
1451
|
+
@verify.register(nodes.TypeVarExpr)
|
|
1452
|
+
def verify_typevarexpr(
|
|
1453
|
+
stub: nodes.TypeVarExpr, runtime: MaybeMissing[Any], object_path: list[str]
|
|
1454
|
+
) -> Iterator[Error]:
|
|
1455
|
+
if isinstance(runtime, Missing):
|
|
1456
|
+
# We seem to insert these typevars into NamedTuple stubs, but they
|
|
1457
|
+
# don't exist at runtime. Just ignore!
|
|
1458
|
+
if stub.name == "_NT":
|
|
1459
|
+
return
|
|
1460
|
+
yield Error(object_path, "is not present at runtime", stub, runtime)
|
|
1461
|
+
return
|
|
1462
|
+
if not isinstance(runtime, TypeVar):
|
|
1463
|
+
yield Error(object_path, "is not a TypeVar", stub, runtime)
|
|
1464
|
+
return
|
|
1465
|
+
|
|
1466
|
+
|
|
1467
|
+
@verify.register(nodes.ParamSpecExpr)
|
|
1468
|
+
def verify_paramspecexpr(
|
|
1469
|
+
stub: nodes.ParamSpecExpr, runtime: MaybeMissing[Any], object_path: list[str]
|
|
1470
|
+
) -> Iterator[Error]:
|
|
1471
|
+
if isinstance(runtime, Missing):
|
|
1472
|
+
yield Error(object_path, "is not present at runtime", stub, runtime)
|
|
1473
|
+
return
|
|
1474
|
+
maybe_paramspec_types = (
|
|
1475
|
+
getattr(typing, "ParamSpec", None),
|
|
1476
|
+
getattr(typing_extensions, "ParamSpec", None),
|
|
1477
|
+
)
|
|
1478
|
+
paramspec_types = tuple(t for t in maybe_paramspec_types if t is not None)
|
|
1479
|
+
if not paramspec_types or not isinstance(runtime, paramspec_types):
|
|
1480
|
+
yield Error(object_path, "is not a ParamSpec", stub, runtime)
|
|
1481
|
+
return
|
|
1482
|
+
|
|
1483
|
+
|
|
1484
|
+
def _is_django_cached_property(runtime: Any) -> bool: # pragma: no cover
|
|
1485
|
+
# This is a special case for
|
|
1486
|
+
# https://docs.djangoproject.com/en/5.2/ref/utils/#django.utils.functional.cached_property
|
|
1487
|
+
# This is needed in `django-stubs` project:
|
|
1488
|
+
# https://github.com/typeddjango/django-stubs
|
|
1489
|
+
if type(runtime).__name__ != "cached_property":
|
|
1490
|
+
return False
|
|
1491
|
+
try:
|
|
1492
|
+
return bool(runtime.func)
|
|
1493
|
+
except Exception:
|
|
1494
|
+
return False
|
|
1495
|
+
|
|
1496
|
+
|
|
1497
|
+
def _verify_readonly_property(stub: nodes.Decorator, runtime: Any) -> Iterator[str]:
|
|
1498
|
+
assert stub.func.is_property
|
|
1499
|
+
if isinstance(runtime, property):
|
|
1500
|
+
yield from _verify_final_method(stub.func, runtime.fget, MISSING)
|
|
1501
|
+
return
|
|
1502
|
+
if isinstance(runtime, functools.cached_property):
|
|
1503
|
+
yield from _verify_final_method(stub.func, runtime.func, MISSING)
|
|
1504
|
+
return
|
|
1505
|
+
if _is_django_cached_property(runtime):
|
|
1506
|
+
yield from _verify_final_method(stub.func, runtime.func, MISSING)
|
|
1507
|
+
return
|
|
1508
|
+
if inspect.isdatadescriptor(runtime):
|
|
1509
|
+
# It's enough like a property...
|
|
1510
|
+
return
|
|
1511
|
+
# Sometimes attributes pretend to be properties, for instance, to express that they
|
|
1512
|
+
# are read only. So allowlist if runtime_type matches the return type of stub.
|
|
1513
|
+
runtime_type = get_mypy_type_of_runtime_value(runtime)
|
|
1514
|
+
func_type = (
|
|
1515
|
+
stub.func.type.ret_type if isinstance(stub.func.type, mypy.types.CallableType) else None
|
|
1516
|
+
)
|
|
1517
|
+
if (
|
|
1518
|
+
runtime_type is not None
|
|
1519
|
+
and func_type is not None
|
|
1520
|
+
and is_subtype_helper(runtime_type, func_type)
|
|
1521
|
+
):
|
|
1522
|
+
return
|
|
1523
|
+
yield "is inconsistent, cannot reconcile @property on stub with runtime object"
|
|
1524
|
+
|
|
1525
|
+
|
|
1526
|
+
def _verify_abstract_status(stub: nodes.FuncDef, runtime: Any) -> Iterator[str]:
|
|
1527
|
+
stub_abstract = stub.abstract_status == nodes.IS_ABSTRACT
|
|
1528
|
+
runtime_abstract = getattr(runtime, "__isabstractmethod__", False)
|
|
1529
|
+
# The opposite can exist: some implementations omit `@abstractmethod` decorators
|
|
1530
|
+
if runtime_abstract and not stub_abstract:
|
|
1531
|
+
item_type = "property" if stub.is_property else "method"
|
|
1532
|
+
yield f"is inconsistent, runtime {item_type} is abstract but stub is not"
|
|
1533
|
+
|
|
1534
|
+
|
|
1535
|
+
def _verify_final_method(
|
|
1536
|
+
stub: nodes.FuncDef, runtime: Any, static_runtime: MaybeMissing[Any]
|
|
1537
|
+
) -> Iterator[str]:
|
|
1538
|
+
if stub.is_final:
|
|
1539
|
+
return
|
|
1540
|
+
if getattr(runtime, "__final__", False) or (
|
|
1541
|
+
static_runtime is not MISSING and getattr(static_runtime, "__final__", False)
|
|
1542
|
+
):
|
|
1543
|
+
yield "is decorated with @final at runtime, but not in the stub"
|
|
1544
|
+
|
|
1545
|
+
|
|
1546
|
+
def _resolve_funcitem_from_decorator(dec: nodes.OverloadPart) -> nodes.FuncItem | None:
|
|
1547
|
+
"""Returns a FuncItem that corresponds to the output of the decorator.
|
|
1548
|
+
|
|
1549
|
+
Returns None if we can't figure out what that would be. For convenience, this function also
|
|
1550
|
+
accepts FuncItems.
|
|
1551
|
+
"""
|
|
1552
|
+
if isinstance(dec, nodes.FuncItem):
|
|
1553
|
+
return dec
|
|
1554
|
+
if dec.func.is_property:
|
|
1555
|
+
return None
|
|
1556
|
+
|
|
1557
|
+
def apply_decorator_to_funcitem(
|
|
1558
|
+
decorator: nodes.Expression, func: nodes.FuncItem
|
|
1559
|
+
) -> nodes.FuncItem | None:
|
|
1560
|
+
if (
|
|
1561
|
+
isinstance(decorator, nodes.CallExpr)
|
|
1562
|
+
and isinstance(decorator.callee, nodes.RefExpr)
|
|
1563
|
+
and decorator.callee.fullname in mypy.types.DEPRECATED_TYPE_NAMES
|
|
1564
|
+
):
|
|
1565
|
+
return func
|
|
1566
|
+
if not isinstance(decorator, nodes.RefExpr):
|
|
1567
|
+
return None
|
|
1568
|
+
if not decorator.fullname:
|
|
1569
|
+
# Happens with namedtuple
|
|
1570
|
+
return None
|
|
1571
|
+
if (
|
|
1572
|
+
decorator.fullname in ("builtins.staticmethod", "abc.abstractmethod")
|
|
1573
|
+
or decorator.fullname in mypy.types.OVERLOAD_NAMES
|
|
1574
|
+
or decorator.fullname in mypy.types.OVERRIDE_DECORATOR_NAMES
|
|
1575
|
+
or decorator.fullname in mypy.types.FINAL_DECORATOR_NAMES
|
|
1576
|
+
):
|
|
1577
|
+
return func
|
|
1578
|
+
if decorator.fullname == "builtins.classmethod":
|
|
1579
|
+
if func.arguments[0].variable.name not in ("_cls", "cls", "mcs", "metacls"):
|
|
1580
|
+
raise StubtestFailure(
|
|
1581
|
+
f"unexpected class parameter name {func.arguments[0].variable.name!r} "
|
|
1582
|
+
f"in {dec.fullname}"
|
|
1583
|
+
)
|
|
1584
|
+
# FuncItem is written so that copy.copy() actually works, even when compiled
|
|
1585
|
+
ret = copy.copy(func)
|
|
1586
|
+
# Remove the cls argument, since it's not present in inspect.signature of classmethods
|
|
1587
|
+
ret.arguments = ret.arguments[1:]
|
|
1588
|
+
return ret
|
|
1589
|
+
# Just give up on any other decorators. After excluding properties, we don't run into
|
|
1590
|
+
# anything else when running on typeshed's stdlib.
|
|
1591
|
+
return None
|
|
1592
|
+
|
|
1593
|
+
func: nodes.FuncItem = dec.func
|
|
1594
|
+
for decorator in dec.original_decorators:
|
|
1595
|
+
resulting_func = apply_decorator_to_funcitem(decorator, func)
|
|
1596
|
+
if resulting_func is None:
|
|
1597
|
+
# We couldn't figure out how to apply the decorator by transforming nodes, so try to
|
|
1598
|
+
# reconstitute a FuncDef from the resulting type of the decorator
|
|
1599
|
+
# This is worse because e.g. we lose the values of defaults
|
|
1600
|
+
dec_type = mypy.types.get_proper_type(dec.type)
|
|
1601
|
+
callable_type = None
|
|
1602
|
+
if isinstance(dec_type, mypy.types.Instance):
|
|
1603
|
+
callable_type = mypy.subtypes.find_member(
|
|
1604
|
+
"__call__", dec_type, dec_type, is_operator=True
|
|
1605
|
+
)
|
|
1606
|
+
elif isinstance(dec_type, mypy.types.CallableType):
|
|
1607
|
+
callable_type = dec_type
|
|
1608
|
+
|
|
1609
|
+
callable_type = mypy.types.get_proper_type(callable_type)
|
|
1610
|
+
if isinstance(callable_type, mypy.types.CallableType):
|
|
1611
|
+
return _resolve_funcitem_from_callable_type(dec, callable_type)
|
|
1612
|
+
return None
|
|
1613
|
+
|
|
1614
|
+
func = resulting_func
|
|
1615
|
+
return func
|
|
1616
|
+
|
|
1617
|
+
|
|
1618
|
+
def _resolve_funcitem_from_callable_type(
|
|
1619
|
+
dec: nodes.Decorator, typ: mypy.types.CallableType
|
|
1620
|
+
) -> nodes.FuncDef | None:
|
|
1621
|
+
if (
|
|
1622
|
+
typ.arg_kinds == [nodes.ARG_STAR, nodes.ARG_STAR2]
|
|
1623
|
+
and (var_arg := typ.var_arg()) is not None
|
|
1624
|
+
and isinstance(mypy.types.get_proper_type(var_arg.typ), mypy.types.AnyType)
|
|
1625
|
+
and (var_kwarg := typ.kw_arg()) is not None
|
|
1626
|
+
and isinstance(mypy.types.get_proper_type(var_kwarg.typ), mypy.types.AnyType)
|
|
1627
|
+
):
|
|
1628
|
+
# There isn't a FuncDef we can invent corresponding to a Callable[..., T]
|
|
1629
|
+
return None
|
|
1630
|
+
|
|
1631
|
+
args: list[nodes.Argument] = []
|
|
1632
|
+
for i, (arg_type, arg_kind, arg_name) in enumerate(
|
|
1633
|
+
zip(typ.arg_types, typ.arg_kinds, typ.arg_names, strict=True)
|
|
1634
|
+
):
|
|
1635
|
+
var_name = arg_name if arg_name is not None else f"__arg{i}"
|
|
1636
|
+
var = nodes.Var(var_name, arg_type)
|
|
1637
|
+
pos_only = arg_name is None and arg_kind == nodes.ARG_POS
|
|
1638
|
+
args.append(
|
|
1639
|
+
nodes.Argument(
|
|
1640
|
+
variable=var,
|
|
1641
|
+
type_annotation=arg_type,
|
|
1642
|
+
initializer=None, # CallableType doesn't store the values of defaults
|
|
1643
|
+
kind=arg_kind,
|
|
1644
|
+
pos_only=pos_only,
|
|
1645
|
+
)
|
|
1646
|
+
)
|
|
1647
|
+
|
|
1648
|
+
if dec.func.is_class:
|
|
1649
|
+
if not args:
|
|
1650
|
+
return None
|
|
1651
|
+
# Munge classmethods, similar to logic in _resolve_funcitem_from_decorator
|
|
1652
|
+
if args[0].variable.name not in ("_cls", "cls", "mcs", "metacls"):
|
|
1653
|
+
return None
|
|
1654
|
+
args.pop(0)
|
|
1655
|
+
|
|
1656
|
+
ret = nodes.FuncDef(name=typ.name or "", arguments=args, body=nodes.Block([]), typ=typ)
|
|
1657
|
+
ret.is_class = dec.func.is_class
|
|
1658
|
+
return ret
|
|
1659
|
+
|
|
1660
|
+
|
|
1661
|
+
@verify.register(nodes.Decorator)
|
|
1662
|
+
def verify_decorator(
|
|
1663
|
+
stub: nodes.Decorator, runtime: MaybeMissing[Any], object_path: list[str]
|
|
1664
|
+
) -> Iterator[Error]:
|
|
1665
|
+
if stub.func.is_type_check_only:
|
|
1666
|
+
# This function only exists in stubs, we only check that the runtime part
|
|
1667
|
+
# is missing. Other checks are not required.
|
|
1668
|
+
if not isinstance(runtime, Missing):
|
|
1669
|
+
yield Error(
|
|
1670
|
+
object_path,
|
|
1671
|
+
'is marked as "@type_check_only", but also exists at runtime',
|
|
1672
|
+
stub,
|
|
1673
|
+
runtime,
|
|
1674
|
+
stub_desc=repr(stub),
|
|
1675
|
+
)
|
|
1676
|
+
return
|
|
1677
|
+
|
|
1678
|
+
if isinstance(runtime, Missing):
|
|
1679
|
+
yield Error(object_path, "is not present at runtime", stub, runtime)
|
|
1680
|
+
return
|
|
1681
|
+
if stub.func.is_property:
|
|
1682
|
+
for message in _verify_readonly_property(stub, runtime):
|
|
1683
|
+
yield Error(object_path, message, stub, runtime)
|
|
1684
|
+
for message in _verify_abstract_status(stub.func, runtime):
|
|
1685
|
+
yield Error(object_path, message, stub, runtime)
|
|
1686
|
+
return
|
|
1687
|
+
|
|
1688
|
+
func = _resolve_funcitem_from_decorator(stub)
|
|
1689
|
+
if func is not None:
|
|
1690
|
+
yield from verify(func, runtime, object_path)
|
|
1691
|
+
|
|
1692
|
+
|
|
1693
|
+
@verify.register(nodes.TypeAlias)
|
|
1694
|
+
def verify_typealias(
|
|
1695
|
+
stub: nodes.TypeAlias, runtime: MaybeMissing[Any], object_path: list[str]
|
|
1696
|
+
) -> Iterator[Error]:
|
|
1697
|
+
stub_target = mypy.types.get_proper_type(stub.target)
|
|
1698
|
+
stub_desc = f"Type alias for {stub_target}"
|
|
1699
|
+
if isinstance(runtime, Missing):
|
|
1700
|
+
yield Error(object_path, "is not present at runtime", stub, runtime, stub_desc=stub_desc)
|
|
1701
|
+
return
|
|
1702
|
+
runtime_origin = get_origin(runtime) or runtime
|
|
1703
|
+
if isinstance(stub_target, mypy.types.Instance):
|
|
1704
|
+
if not isinstance(runtime_origin, type):
|
|
1705
|
+
yield Error(
|
|
1706
|
+
object_path,
|
|
1707
|
+
"is inconsistent, runtime is not a type",
|
|
1708
|
+
stub,
|
|
1709
|
+
runtime,
|
|
1710
|
+
stub_desc=stub_desc,
|
|
1711
|
+
)
|
|
1712
|
+
return
|
|
1713
|
+
|
|
1714
|
+
stub_origin = stub_target.type
|
|
1715
|
+
# Do our best to figure out the fullname of the runtime object...
|
|
1716
|
+
runtime_name: object
|
|
1717
|
+
try:
|
|
1718
|
+
runtime_name = runtime_origin.__qualname__
|
|
1719
|
+
except AttributeError:
|
|
1720
|
+
runtime_name = getattr(runtime_origin, "__name__", MISSING)
|
|
1721
|
+
if isinstance(runtime_name, str):
|
|
1722
|
+
runtime_module: object = getattr(runtime_origin, "__module__", MISSING)
|
|
1723
|
+
if isinstance(runtime_module, str):
|
|
1724
|
+
if runtime_module == "collections.abc" or (
|
|
1725
|
+
runtime_module == "re" and runtime_name in {"Match", "Pattern"}
|
|
1726
|
+
):
|
|
1727
|
+
runtime_module = "typing"
|
|
1728
|
+
runtime_fullname = f"{runtime_module}.{runtime_name}"
|
|
1729
|
+
if re.fullmatch(rf"_?{re.escape(stub_origin.fullname)}", runtime_fullname):
|
|
1730
|
+
# Okay, we're probably fine.
|
|
1731
|
+
return
|
|
1732
|
+
|
|
1733
|
+
# Okay, either we couldn't construct a fullname
|
|
1734
|
+
# or the fullname of the stub didn't match the fullname of the runtime.
|
|
1735
|
+
# Fallback to a full structural check of the runtime vis-a-vis the stub.
|
|
1736
|
+
yield from verify_typeinfo(stub_origin, runtime_origin, object_path, is_alias_target=True)
|
|
1737
|
+
return
|
|
1738
|
+
if isinstance(stub_target, mypy.types.UnionType):
|
|
1739
|
+
# complain if runtime is not a Union or UnionType
|
|
1740
|
+
if runtime_origin is not Union and not isinstance(runtime, types.UnionType):
|
|
1741
|
+
yield Error(object_path, "is not a Union", stub, runtime, stub_desc=str(stub_target))
|
|
1742
|
+
# could check Union contents here...
|
|
1743
|
+
return
|
|
1744
|
+
if isinstance(stub_target, mypy.types.TupleType):
|
|
1745
|
+
if tuple not in getattr(runtime_origin, "__mro__", ()):
|
|
1746
|
+
yield Error(
|
|
1747
|
+
object_path, "is not a subclass of tuple", stub, runtime, stub_desc=stub_desc
|
|
1748
|
+
)
|
|
1749
|
+
# could check Tuple contents here...
|
|
1750
|
+
return
|
|
1751
|
+
if isinstance(stub_target, mypy.types.CallableType):
|
|
1752
|
+
if runtime_origin is not collections.abc.Callable:
|
|
1753
|
+
yield Error(
|
|
1754
|
+
object_path, "is not a type alias for Callable", stub, runtime, stub_desc=stub_desc
|
|
1755
|
+
)
|
|
1756
|
+
# could check Callable contents here...
|
|
1757
|
+
return
|
|
1758
|
+
if isinstance(stub_target, mypy.types.AnyType):
|
|
1759
|
+
return
|
|
1760
|
+
yield Error(object_path, "is not a recognised type alias", stub, runtime, stub_desc=stub_desc)
|
|
1761
|
+
|
|
1762
|
+
|
|
1763
|
+
# ====================
|
|
1764
|
+
# Helpers
|
|
1765
|
+
# ====================
|
|
1766
|
+
|
|
1767
|
+
|
|
1768
|
+
IGNORED_MODULE_DUNDERS: Final = frozenset(
|
|
1769
|
+
{
|
|
1770
|
+
"__file__",
|
|
1771
|
+
"__doc__",
|
|
1772
|
+
"__name__",
|
|
1773
|
+
"__builtins__",
|
|
1774
|
+
"__package__",
|
|
1775
|
+
"__cached__",
|
|
1776
|
+
"__loader__",
|
|
1777
|
+
"__spec__",
|
|
1778
|
+
"__annotations__",
|
|
1779
|
+
"__conditional_annotations__", # 3.14+
|
|
1780
|
+
"__annotate__",
|
|
1781
|
+
"__path__", # mypy adds __path__ to packages, but C packages don't have it
|
|
1782
|
+
"__getattr__", # resulting behaviour might be typed explicitly
|
|
1783
|
+
# Created by `warnings.warn`, does not make much sense to have in stubs:
|
|
1784
|
+
"__warningregistry__",
|
|
1785
|
+
# TODO: remove the following from this list
|
|
1786
|
+
"__author__",
|
|
1787
|
+
"__version__",
|
|
1788
|
+
"__copyright__",
|
|
1789
|
+
}
|
|
1790
|
+
)
|
|
1791
|
+
|
|
1792
|
+
IGNORABLE_CLASS_DUNDERS: Final = frozenset(
|
|
1793
|
+
{
|
|
1794
|
+
# Special attributes
|
|
1795
|
+
"__dict__",
|
|
1796
|
+
"__annotations__",
|
|
1797
|
+
"__annotate__",
|
|
1798
|
+
"__annotations_cache__",
|
|
1799
|
+
"__annotate_func__",
|
|
1800
|
+
"__text_signature__",
|
|
1801
|
+
"__weakref__",
|
|
1802
|
+
"__hash__",
|
|
1803
|
+
"__getattr__", # resulting behaviour might be typed explicitly
|
|
1804
|
+
"__setattr__", # defining this on a class can cause worse type checking
|
|
1805
|
+
"__vectorcalloffset__", # undocumented implementation detail of the vectorcall protocol
|
|
1806
|
+
"__firstlineno__",
|
|
1807
|
+
"__static_attributes__",
|
|
1808
|
+
"__classdictcell__",
|
|
1809
|
+
# isinstance/issubclass hooks that type-checkers don't usually care about
|
|
1810
|
+
"__instancecheck__",
|
|
1811
|
+
"__subclasshook__",
|
|
1812
|
+
"__subclasscheck__",
|
|
1813
|
+
# python2 only magic methods:
|
|
1814
|
+
"__cmp__",
|
|
1815
|
+
"__nonzero__",
|
|
1816
|
+
"__unicode__",
|
|
1817
|
+
"__div__",
|
|
1818
|
+
# cython methods
|
|
1819
|
+
"__pyx_vtable__",
|
|
1820
|
+
# Pickle methods
|
|
1821
|
+
"__setstate__",
|
|
1822
|
+
"__getstate__",
|
|
1823
|
+
"__getnewargs__",
|
|
1824
|
+
"__getinitargs__",
|
|
1825
|
+
"__reduce_ex__",
|
|
1826
|
+
"__reduce__",
|
|
1827
|
+
"__slotnames__", # Cached names of slots added by `copyreg` module.
|
|
1828
|
+
# ctypes weirdness
|
|
1829
|
+
"__ctype_be__",
|
|
1830
|
+
"__ctype_le__",
|
|
1831
|
+
"__ctypes_from_outparam__",
|
|
1832
|
+
# mypy limitations
|
|
1833
|
+
"__abstractmethods__", # Classes with metaclass=ABCMeta inherit this attribute
|
|
1834
|
+
"__new_member__", # If an enum defines __new__, the method is renamed as __new_member__
|
|
1835
|
+
"__dataclass_fields__", # Generated by dataclasses
|
|
1836
|
+
"__dataclass_params__", # Generated by dataclasses
|
|
1837
|
+
"__doc__", # mypy's semanal for namedtuples assumes this is str, not Optional[str]
|
|
1838
|
+
# Added to all protocol classes on 3.12+ (or if using typing_extensions.Protocol)
|
|
1839
|
+
"__protocol_attrs__",
|
|
1840
|
+
"__callable_proto_members_only__",
|
|
1841
|
+
"__non_callable_proto_members__",
|
|
1842
|
+
# typing implementation details, consider removing some of these:
|
|
1843
|
+
"__parameters__",
|
|
1844
|
+
"__origin__",
|
|
1845
|
+
"__args__",
|
|
1846
|
+
"__orig_bases__",
|
|
1847
|
+
"__final__", # Has a specialized check
|
|
1848
|
+
# Consider removing __slots__?
|
|
1849
|
+
"__slots__",
|
|
1850
|
+
}
|
|
1851
|
+
)
|
|
1852
|
+
|
|
1853
|
+
|
|
1854
|
+
PAIRED_DUNDERS: Final = (
|
|
1855
|
+
("__add__", "__radd__"),
|
|
1856
|
+
("__sub__", "__rsub__"),
|
|
1857
|
+
("__mul__", "__rmul__"),
|
|
1858
|
+
("__matmul__", "__rmatmul__"),
|
|
1859
|
+
("__truediv__", "__rtruediv__"),
|
|
1860
|
+
("__floordiv__", "__rfloordiv__"),
|
|
1861
|
+
("__mod__", "__rmod__"),
|
|
1862
|
+
("__divmod__", "__rdivmod__"),
|
|
1863
|
+
("__pow__", "__rpow__"),
|
|
1864
|
+
("__lshift__", "__rlshift__"),
|
|
1865
|
+
("__rshift__", "__rrshift__"),
|
|
1866
|
+
("__and__", "__rand__"),
|
|
1867
|
+
("__xor__", "__rxor__"),
|
|
1868
|
+
("__or__", "__ror__"),
|
|
1869
|
+
("__lt__", "__gt__"),
|
|
1870
|
+
("__le__", "__ge__"),
|
|
1871
|
+
("__enter__", "__exit__"),
|
|
1872
|
+
)
|
|
1873
|
+
|
|
1874
|
+
|
|
1875
|
+
def is_expected_dunder(name: str, *, stub: nodes.TypeInfo, existing_stub_names: set[str]) -> bool:
|
|
1876
|
+
"""
|
|
1877
|
+
Return `True` if we would reasonably "expect" this dunder to be present in the stub,
|
|
1878
|
+
given the presence of other dunders that are already in the stub.
|
|
1879
|
+
|
|
1880
|
+
For example, if the stub has `__add__`, we would expect it to also have `__radd__`,
|
|
1881
|
+
and vice versa.
|
|
1882
|
+
|
|
1883
|
+
We use this to inform our heuristics regarding whether a diagnostic complaining about
|
|
1884
|
+
a missing dunder method is likely to be a false positive or not. In many cases where
|
|
1885
|
+
a runtime dunder is an instance of `WrapperDesriptorType`, the runtime dunder will
|
|
1886
|
+
not actually be callable at runtime, so it's too noisy to complain about them in
|
|
1887
|
+
general. If we would reasonably *expect* the dunder to be present in the stub, however,
|
|
1888
|
+
it may be worth complaining about the missing dunder even if the dunder at runtime is
|
|
1889
|
+
a `WrapperDescriptorType`.
|
|
1890
|
+
"""
|
|
1891
|
+
if any(
|
|
1892
|
+
(name == left and right in existing_stub_names)
|
|
1893
|
+
or (name == right and left in existing_stub_names)
|
|
1894
|
+
for left, right in PAIRED_DUNDERS
|
|
1895
|
+
):
|
|
1896
|
+
return True
|
|
1897
|
+
|
|
1898
|
+
if name == "__le__" and {"__lt__", "__eq__"}.issubset(existing_stub_names):
|
|
1899
|
+
return True
|
|
1900
|
+
if name == "__ge__" and {"__gt__", "__eq__"}.issubset(existing_stub_names):
|
|
1901
|
+
return True
|
|
1902
|
+
|
|
1903
|
+
if (name in ("__or__", "__ror__") and stub.has_base("typing.Mapping")) or (
|
|
1904
|
+
name in ("__mul__", "__rmul__") and stub.has_base("typing.Sequence")
|
|
1905
|
+
):
|
|
1906
|
+
return True
|
|
1907
|
+
|
|
1908
|
+
# In-place syntax such as `*=` and `|=` can work with immutable types (for example,
|
|
1909
|
+
# tuples or frozensets), but generally delegates to the non-in-place dunder in
|
|
1910
|
+
# these cases. The in-place dunders themselves are generally only defined for
|
|
1911
|
+
# mutable types.
|
|
1912
|
+
return (name == "__ior__" and stub.has_base("typing.MutableMapping")) or (
|
|
1913
|
+
name == "__imul__" and stub.has_base("typing.MutableSequence")
|
|
1914
|
+
)
|
|
1915
|
+
|
|
1916
|
+
|
|
1917
|
+
def is_probably_private(name: str) -> bool:
|
|
1918
|
+
return name.startswith("_") and not is_dunder(name)
|
|
1919
|
+
|
|
1920
|
+
|
|
1921
|
+
def is_probably_a_function(runtime: Any) -> bool:
|
|
1922
|
+
return (
|
|
1923
|
+
isinstance(
|
|
1924
|
+
runtime,
|
|
1925
|
+
(
|
|
1926
|
+
types.FunctionType,
|
|
1927
|
+
types.BuiltinFunctionType,
|
|
1928
|
+
types.MethodType,
|
|
1929
|
+
types.BuiltinMethodType,
|
|
1930
|
+
),
|
|
1931
|
+
)
|
|
1932
|
+
or (inspect.ismethoddescriptor(runtime) and callable(runtime))
|
|
1933
|
+
or (isinstance(runtime, types.MethodWrapperType) and callable(runtime))
|
|
1934
|
+
)
|
|
1935
|
+
|
|
1936
|
+
|
|
1937
|
+
def is_read_only_property(runtime: object) -> bool:
|
|
1938
|
+
return isinstance(runtime, property) and runtime.fset is None and runtime.fdel is None
|
|
1939
|
+
|
|
1940
|
+
|
|
1941
|
+
def safe_inspect_signature(runtime: Any) -> inspect.Signature | None:
|
|
1942
|
+
if (
|
|
1943
|
+
hasattr(runtime, "__name__")
|
|
1944
|
+
and runtime.__name__ == "__init__"
|
|
1945
|
+
and hasattr(runtime, "__text_signature__")
|
|
1946
|
+
and runtime.__text_signature__ == "($self, /, *args, **kwargs)"
|
|
1947
|
+
and hasattr(runtime, "__objclass__")
|
|
1948
|
+
and hasattr(runtime.__objclass__, "__text_signature__")
|
|
1949
|
+
and runtime.__objclass__.__text_signature__ is not None
|
|
1950
|
+
):
|
|
1951
|
+
# This is an __init__ method with the generic C-class signature.
|
|
1952
|
+
# In this case, the underlying class often has a better signature,
|
|
1953
|
+
# which we can convert into an __init__ signature by adding in the
|
|
1954
|
+
# self parameter.
|
|
1955
|
+
try:
|
|
1956
|
+
s = inspect.signature(runtime.__objclass__)
|
|
1957
|
+
|
|
1958
|
+
parameter_kind: inspect._ParameterKind = inspect.Parameter.POSITIONAL_OR_KEYWORD
|
|
1959
|
+
if s.parameters:
|
|
1960
|
+
first_parameter = next(iter(s.parameters.values()))
|
|
1961
|
+
if first_parameter.kind == inspect.Parameter.POSITIONAL_ONLY:
|
|
1962
|
+
parameter_kind = inspect.Parameter.POSITIONAL_ONLY
|
|
1963
|
+
return s.replace(
|
|
1964
|
+
parameters=[inspect.Parameter("self", parameter_kind), *s.parameters.values()]
|
|
1965
|
+
)
|
|
1966
|
+
except Exception:
|
|
1967
|
+
pass
|
|
1968
|
+
|
|
1969
|
+
if (
|
|
1970
|
+
hasattr(runtime, "__name__")
|
|
1971
|
+
and runtime.__name__ == "__new__"
|
|
1972
|
+
and hasattr(runtime, "__text_signature__")
|
|
1973
|
+
and runtime.__text_signature__ == "($type, *args, **kwargs)"
|
|
1974
|
+
and hasattr(runtime, "__self__")
|
|
1975
|
+
and hasattr(runtime.__self__, "__text_signature__")
|
|
1976
|
+
and runtime.__self__.__text_signature__ is not None
|
|
1977
|
+
):
|
|
1978
|
+
# This is a __new__ method with the generic C-class signature.
|
|
1979
|
+
# In this case, the underlying class often has a better signature,
|
|
1980
|
+
# which we can convert into a __new__ signature by adding in the
|
|
1981
|
+
# cls parameter.
|
|
1982
|
+
|
|
1983
|
+
# If the attached class has a valid __init__, skip recovering a
|
|
1984
|
+
# signature for this __new__ method.
|
|
1985
|
+
has_init = False
|
|
1986
|
+
if (
|
|
1987
|
+
hasattr(runtime.__self__, "__init__")
|
|
1988
|
+
and hasattr(runtime.__self__.__init__, "__objclass__")
|
|
1989
|
+
and runtime.__self__.__init__.__objclass__ is runtime.__self__
|
|
1990
|
+
):
|
|
1991
|
+
has_init = True
|
|
1992
|
+
|
|
1993
|
+
if not has_init:
|
|
1994
|
+
try:
|
|
1995
|
+
s = inspect.signature(runtime.__self__)
|
|
1996
|
+
parameter_kind = inspect.Parameter.POSITIONAL_OR_KEYWORD
|
|
1997
|
+
if s.parameters:
|
|
1998
|
+
first_parameter = next(iter(s.parameters.values()))
|
|
1999
|
+
if first_parameter.kind == inspect.Parameter.POSITIONAL_ONLY:
|
|
2000
|
+
parameter_kind = inspect.Parameter.POSITIONAL_ONLY
|
|
2001
|
+
return s.replace(
|
|
2002
|
+
parameters=[inspect.Parameter("cls", parameter_kind), *s.parameters.values()]
|
|
2003
|
+
)
|
|
2004
|
+
except Exception:
|
|
2005
|
+
pass
|
|
2006
|
+
|
|
2007
|
+
try:
|
|
2008
|
+
try:
|
|
2009
|
+
return inspect.signature(runtime)
|
|
2010
|
+
except ValueError:
|
|
2011
|
+
if (
|
|
2012
|
+
hasattr(runtime, "__text_signature__")
|
|
2013
|
+
and "<unrepresentable>" in runtime.__text_signature__
|
|
2014
|
+
):
|
|
2015
|
+
# Try to fix up the signature. Workaround for
|
|
2016
|
+
# https://github.com/python/cpython/issues/87233
|
|
2017
|
+
sig = runtime.__text_signature__.replace("<unrepresentable>", "...")
|
|
2018
|
+
sig = inspect._signature_fromstr(inspect.Signature, runtime, sig) # type: ignore[attr-defined]
|
|
2019
|
+
assert isinstance(sig, inspect.Signature)
|
|
2020
|
+
new_params = [
|
|
2021
|
+
(
|
|
2022
|
+
parameter.replace(default=UNREPRESENTABLE)
|
|
2023
|
+
if parameter.default is ...
|
|
2024
|
+
else parameter
|
|
2025
|
+
)
|
|
2026
|
+
for parameter in sig.parameters.values()
|
|
2027
|
+
]
|
|
2028
|
+
return sig.replace(parameters=new_params)
|
|
2029
|
+
else:
|
|
2030
|
+
raise
|
|
2031
|
+
except Exception:
|
|
2032
|
+
# inspect.signature throws ValueError all the time
|
|
2033
|
+
# catch RuntimeError because of https://bugs.python.org/issue39504
|
|
2034
|
+
# catch TypeError because of https://github.com/python/typeshed/pull/5762
|
|
2035
|
+
# catch AttributeError because of inspect.signature(_curses.window.border)
|
|
2036
|
+
return None
|
|
2037
|
+
|
|
2038
|
+
|
|
2039
|
+
def describe_runtime_callable(signature: inspect.Signature, *, is_async: bool) -> str:
|
|
2040
|
+
return f'{"async " if is_async else ""}def {signature}'
|
|
2041
|
+
|
|
2042
|
+
|
|
2043
|
+
class _TypeCheckOnlyBaseMapper(mypy.types.TypeTranslator):
|
|
2044
|
+
"""Rewrites @type_check_only instances to the nearest runtime-visible base class."""
|
|
2045
|
+
|
|
2046
|
+
def visit_instance(self, t: mypy.types.Instance, /) -> mypy.types.Type:
|
|
2047
|
+
instance = mypy.types.get_proper_type(super().visit_instance(t))
|
|
2048
|
+
assert isinstance(instance, mypy.types.Instance)
|
|
2049
|
+
|
|
2050
|
+
if instance.type.is_type_check_only:
|
|
2051
|
+
# find the nearest non-@type_check_only base class
|
|
2052
|
+
for base_info in instance.type.mro[1:]:
|
|
2053
|
+
if not base_info.is_type_check_only:
|
|
2054
|
+
return map_instance_to_supertype(instance, base_info)
|
|
2055
|
+
|
|
2056
|
+
msg = f"all base classes of {instance.type.fullname!r} are @type_check_only"
|
|
2057
|
+
assert False, msg
|
|
2058
|
+
|
|
2059
|
+
return instance
|
|
2060
|
+
|
|
2061
|
+
def visit_type_alias_type(self, t: mypy.types.TypeAliasType, /) -> mypy.types.Type:
|
|
2062
|
+
return t
|
|
2063
|
+
|
|
2064
|
+
|
|
2065
|
+
_TYPE_CHECK_ONLY_BASE_MAPPER = _TypeCheckOnlyBaseMapper()
|
|
2066
|
+
|
|
2067
|
+
|
|
2068
|
+
def _relax_type_check_only_type(typ: mypy.types.ProperType) -> mypy.types.ProperType:
|
|
2069
|
+
return mypy.types.get_proper_type(typ.accept(_TYPE_CHECK_ONLY_BASE_MAPPER))
|
|
2070
|
+
|
|
2071
|
+
|
|
2072
|
+
def is_subtype_helper(left: mypy.types.Type, right: mypy.types.Type) -> bool:
|
|
2073
|
+
"""Checks whether ``left`` is a subtype of ``right``."""
|
|
2074
|
+
left = _relax_type_check_only_type(mypy.types.get_proper_type(left))
|
|
2075
|
+
right = _relax_type_check_only_type(mypy.types.get_proper_type(right))
|
|
2076
|
+
if (
|
|
2077
|
+
isinstance(left, mypy.types.LiteralType)
|
|
2078
|
+
and isinstance(left.value, int)
|
|
2079
|
+
and left.value in (0, 1)
|
|
2080
|
+
and mypy.types.is_named_instance(right, "builtins.bool")
|
|
2081
|
+
):
|
|
2082
|
+
# Pretend Literal[0, 1] is a subtype of bool to avoid unhelpful errors.
|
|
2083
|
+
return True
|
|
2084
|
+
|
|
2085
|
+
if isinstance(right, mypy.types.TypedDictType) and mypy.types.is_named_instance(
|
|
2086
|
+
left, "builtins.dict"
|
|
2087
|
+
):
|
|
2088
|
+
# Special case checks against TypedDicts
|
|
2089
|
+
return True
|
|
2090
|
+
|
|
2091
|
+
with mypy.state.state.strict_optional_set(True):
|
|
2092
|
+
return mypy.subtypes.is_subtype(left, right)
|
|
2093
|
+
|
|
2094
|
+
|
|
2095
|
+
def is_sentinel(runtime: mypy.types.Type) -> bool:
|
|
2096
|
+
"""Checks whether ``runtime`` is the type of a ``sentinel()`` marker object."""
|
|
2097
|
+
runtime = mypy.types.get_proper_type(runtime)
|
|
2098
|
+
return isinstance(runtime, mypy.types.Instance) and runtime.type.fullname in (
|
|
2099
|
+
"builtins.sentinel",
|
|
2100
|
+
"typing_extensions.sentinel",
|
|
2101
|
+
# typing_extensions 4.14.0-4.15.x defined the class as `Sentinel`, with
|
|
2102
|
+
# no lowercase alias; the rename (and `Sentinel = sentinel` alias)
|
|
2103
|
+
# landed in 4.16.0.
|
|
2104
|
+
"typing_extensions.Sentinel",
|
|
2105
|
+
)
|
|
2106
|
+
|
|
2107
|
+
|
|
2108
|
+
def get_mypy_node_for_name(module: str, type_name: str) -> mypy.nodes.SymbolNode | None:
|
|
2109
|
+
stub = get_stub(module)
|
|
2110
|
+
if stub is None:
|
|
2111
|
+
return None
|
|
2112
|
+
if type_name not in stub.names:
|
|
2113
|
+
return None
|
|
2114
|
+
return stub.names[type_name].node
|
|
2115
|
+
|
|
2116
|
+
|
|
2117
|
+
def get_mypy_type_of_runtime_value(
|
|
2118
|
+
runtime: Any, type_context: mypy.types.Type | None = None
|
|
2119
|
+
) -> mypy.types.Type | None:
|
|
2120
|
+
"""Returns a mypy type object representing the type of ``runtime``.
|
|
2121
|
+
|
|
2122
|
+
Returns None if we can't find something that works.
|
|
2123
|
+
|
|
2124
|
+
"""
|
|
2125
|
+
if runtime is None:
|
|
2126
|
+
return mypy.types.NoneType()
|
|
2127
|
+
if isinstance(runtime, property):
|
|
2128
|
+
# Give up on properties to avoid issues with things that are typed as attributes.
|
|
2129
|
+
return None
|
|
2130
|
+
|
|
2131
|
+
def anytype() -> mypy.types.AnyType:
|
|
2132
|
+
return mypy.types.AnyType(mypy.types.TypeOfAny.unannotated)
|
|
2133
|
+
|
|
2134
|
+
if isinstance(
|
|
2135
|
+
runtime,
|
|
2136
|
+
(types.FunctionType, types.BuiltinFunctionType, types.MethodType, types.BuiltinMethodType),
|
|
2137
|
+
):
|
|
2138
|
+
builtins = get_stub("builtins")
|
|
2139
|
+
assert builtins is not None
|
|
2140
|
+
type_info = builtins.names["function"].node
|
|
2141
|
+
assert isinstance(type_info, nodes.TypeInfo)
|
|
2142
|
+
fallback = mypy.types.Instance(type_info, [anytype()])
|
|
2143
|
+
signature = safe_inspect_signature(runtime)
|
|
2144
|
+
if signature:
|
|
2145
|
+
arg_types = []
|
|
2146
|
+
arg_kinds = []
|
|
2147
|
+
arg_names = []
|
|
2148
|
+
for arg in signature.parameters.values():
|
|
2149
|
+
arg_types.append(anytype())
|
|
2150
|
+
arg_names.append(
|
|
2151
|
+
None if arg.kind == inspect.Parameter.POSITIONAL_ONLY else arg.name
|
|
2152
|
+
)
|
|
2153
|
+
no_default = arg.default is inspect.Parameter.empty
|
|
2154
|
+
if arg.kind == inspect.Parameter.POSITIONAL_ONLY:
|
|
2155
|
+
arg_kinds.append(nodes.ARG_POS if no_default else nodes.ARG_OPT)
|
|
2156
|
+
elif arg.kind == inspect.Parameter.POSITIONAL_OR_KEYWORD:
|
|
2157
|
+
arg_kinds.append(nodes.ARG_POS if no_default else nodes.ARG_OPT)
|
|
2158
|
+
elif arg.kind == inspect.Parameter.KEYWORD_ONLY:
|
|
2159
|
+
arg_kinds.append(nodes.ARG_NAMED if no_default else nodes.ARG_NAMED_OPT)
|
|
2160
|
+
elif arg.kind == inspect.Parameter.VAR_POSITIONAL:
|
|
2161
|
+
arg_kinds.append(nodes.ARG_STAR)
|
|
2162
|
+
elif arg.kind == inspect.Parameter.VAR_KEYWORD:
|
|
2163
|
+
arg_kinds.append(nodes.ARG_STAR2)
|
|
2164
|
+
else:
|
|
2165
|
+
raise AssertionError
|
|
2166
|
+
else:
|
|
2167
|
+
arg_types = [anytype(), anytype()]
|
|
2168
|
+
arg_kinds = [nodes.ARG_STAR, nodes.ARG_STAR2]
|
|
2169
|
+
arg_names = [None, None]
|
|
2170
|
+
|
|
2171
|
+
return mypy.types.CallableType(
|
|
2172
|
+
arg_types,
|
|
2173
|
+
arg_kinds,
|
|
2174
|
+
arg_names,
|
|
2175
|
+
ret_type=anytype(),
|
|
2176
|
+
fallback=fallback,
|
|
2177
|
+
is_ellipsis_args=True,
|
|
2178
|
+
)
|
|
2179
|
+
|
|
2180
|
+
skip_type_object_type = False
|
|
2181
|
+
if type_context:
|
|
2182
|
+
# Don't attempt to process the type object when context is generic
|
|
2183
|
+
# This is related to issue #3737
|
|
2184
|
+
type_context = mypy.types.get_proper_type(type_context)
|
|
2185
|
+
# Callable types with a generic return value
|
|
2186
|
+
if isinstance(type_context, mypy.types.CallableType):
|
|
2187
|
+
if isinstance(type_context.ret_type, mypy.types.TypeVarType):
|
|
2188
|
+
skip_type_object_type = True
|
|
2189
|
+
# Type[x] where x is generic
|
|
2190
|
+
if isinstance(type_context, mypy.types.TypeType):
|
|
2191
|
+
if isinstance(type_context.item, mypy.types.TypeVarType):
|
|
2192
|
+
skip_type_object_type = True
|
|
2193
|
+
|
|
2194
|
+
if isinstance(runtime, type) and not skip_type_object_type:
|
|
2195
|
+
# Try and look up a stub for the runtime object itself
|
|
2196
|
+
# The logic here is similar to ExpressionChecker.analyze_ref_expr
|
|
2197
|
+
type_info = get_mypy_node_for_name(runtime.__module__, runtime.__name__)
|
|
2198
|
+
if isinstance(type_info, nodes.TypeInfo):
|
|
2199
|
+
result = mypy.typeops.type_object_type(type_info)
|
|
2200
|
+
if mypy.checkexpr.is_type_type_context(type_context):
|
|
2201
|
+
# This is the type in a type[] expression, so substitute type
|
|
2202
|
+
# variables with Any.
|
|
2203
|
+
result = mypy.erasetype.erase_typevars(result)
|
|
2204
|
+
return result
|
|
2205
|
+
|
|
2206
|
+
# Try and look up a stub for the runtime object's type
|
|
2207
|
+
type_info = get_mypy_node_for_name(type(runtime).__module__, type(runtime).__name__)
|
|
2208
|
+
if type_info is None:
|
|
2209
|
+
return None
|
|
2210
|
+
if isinstance(type_info, nodes.Var):
|
|
2211
|
+
return type_info.type
|
|
2212
|
+
if not isinstance(type_info, nodes.TypeInfo):
|
|
2213
|
+
return None
|
|
2214
|
+
|
|
2215
|
+
if isinstance(runtime, tuple):
|
|
2216
|
+
# Special case tuples so we construct a valid mypy.types.TupleType
|
|
2217
|
+
optional_items = [get_mypy_type_of_runtime_value(v) for v in runtime]
|
|
2218
|
+
items = [(i if i is not None else anytype()) for i in optional_items]
|
|
2219
|
+
fallback = mypy.types.Instance(type_info, [anytype()])
|
|
2220
|
+
return mypy.types.TupleType(items, fallback)
|
|
2221
|
+
|
|
2222
|
+
fallback = mypy.types.Instance(type_info, [anytype() for _ in type_info.type_vars])
|
|
2223
|
+
if type(runtime) != runtime.__class__:
|
|
2224
|
+
# Since `__class__` is redefined for an instance, we can't trust
|
|
2225
|
+
# its `isinstance` checks, it can be dynamic. See #20919
|
|
2226
|
+
return fallback
|
|
2227
|
+
|
|
2228
|
+
value: bool | int | str
|
|
2229
|
+
if isinstance(runtime, enum.Enum) and isinstance(runtime.name, str):
|
|
2230
|
+
value = runtime.name
|
|
2231
|
+
elif isinstance(runtime, bytes):
|
|
2232
|
+
value = bytes_to_human_readable_repr(runtime)
|
|
2233
|
+
elif isinstance(runtime, (bool, int, str)):
|
|
2234
|
+
value = runtime
|
|
2235
|
+
else:
|
|
2236
|
+
return fallback
|
|
2237
|
+
|
|
2238
|
+
return mypy.types.LiteralType(value=value, fallback=fallback)
|
|
2239
|
+
|
|
2240
|
+
|
|
2241
|
+
# ====================
|
|
2242
|
+
# Build and entrypoint
|
|
2243
|
+
# ====================
|
|
2244
|
+
|
|
2245
|
+
|
|
2246
|
+
_all_stubs: dict[str, nodes.MypyFile] = {}
|
|
2247
|
+
|
|
2248
|
+
|
|
2249
|
+
def build_stubs(modules: list[str], options: Options, find_submodules: bool = False) -> list[str]:
|
|
2250
|
+
"""Uses mypy to construct stub objects for the given modules.
|
|
2251
|
+
|
|
2252
|
+
This sets global state that ``get_stub`` can access.
|
|
2253
|
+
|
|
2254
|
+
Returns all modules we might want to check. If ``find_submodules`` is False, this is equal
|
|
2255
|
+
to ``modules``.
|
|
2256
|
+
|
|
2257
|
+
:param modules: List of modules to build stubs for.
|
|
2258
|
+
:param options: Mypy options for finding and building stubs.
|
|
2259
|
+
:param find_submodules: Whether to attempt to find submodules of the given modules as well.
|
|
2260
|
+
|
|
2261
|
+
"""
|
|
2262
|
+
data_dir = mypy.build.default_data_dir()
|
|
2263
|
+
search_path = mypy.modulefinder.compute_search_paths([], options, data_dir)
|
|
2264
|
+
find_module_cache = mypy.modulefinder.FindModuleCache(
|
|
2265
|
+
search_path, fscache=None, options=options
|
|
2266
|
+
)
|
|
2267
|
+
|
|
2268
|
+
all_modules = []
|
|
2269
|
+
sources = []
|
|
2270
|
+
for module in modules:
|
|
2271
|
+
all_modules.append(module)
|
|
2272
|
+
if not find_submodules:
|
|
2273
|
+
module_path = find_module_cache.find_module(module)
|
|
2274
|
+
if not isinstance(module_path, str):
|
|
2275
|
+
# test_module will yield an error later when it can't find stubs
|
|
2276
|
+
continue
|
|
2277
|
+
sources.append(mypy.modulefinder.BuildSource(module_path, module, None))
|
|
2278
|
+
else:
|
|
2279
|
+
found_sources = find_module_cache.find_modules_recursive(module)
|
|
2280
|
+
sources.extend(found_sources)
|
|
2281
|
+
# find submodules via mypy
|
|
2282
|
+
all_modules.extend(s.module for s in found_sources if s.module not in all_modules)
|
|
2283
|
+
# find submodules via pkgutil
|
|
2284
|
+
try:
|
|
2285
|
+
runtime = silent_import_module(module)
|
|
2286
|
+
all_modules.extend(
|
|
2287
|
+
m.name
|
|
2288
|
+
for m in pkgutil.walk_packages(runtime.__path__, runtime.__name__ + ".")
|
|
2289
|
+
if m.name not in all_modules
|
|
2290
|
+
)
|
|
2291
|
+
except KeyboardInterrupt:
|
|
2292
|
+
raise
|
|
2293
|
+
except BaseException:
|
|
2294
|
+
pass
|
|
2295
|
+
|
|
2296
|
+
if sources:
|
|
2297
|
+
try:
|
|
2298
|
+
res = mypy.build.build(sources=sources, options=options)
|
|
2299
|
+
except mypy.errors.CompileError as e:
|
|
2300
|
+
raise StubtestFailure(f"failed mypy compile:\n{e}") from e
|
|
2301
|
+
if res.errors:
|
|
2302
|
+
raise StubtestFailure("mypy build errors:\n" + "\n".join(res.errors))
|
|
2303
|
+
|
|
2304
|
+
global _all_stubs
|
|
2305
|
+
_all_stubs = res.files
|
|
2306
|
+
|
|
2307
|
+
return all_modules
|
|
2308
|
+
|
|
2309
|
+
|
|
2310
|
+
def get_stub(module: str) -> nodes.MypyFile | None:
|
|
2311
|
+
"""Returns a stub object for the given module, if we've built one."""
|
|
2312
|
+
return _all_stubs.get(module)
|
|
2313
|
+
|
|
2314
|
+
|
|
2315
|
+
def get_typeshed_stdlib_modules(
|
|
2316
|
+
custom_typeshed_dir: str | None, version_info: tuple[int, int] | None = None
|
|
2317
|
+
) -> set[str]:
|
|
2318
|
+
"""Returns a list of stdlib modules in typeshed (for current Python version)."""
|
|
2319
|
+
stdlib_py_versions = mypy.modulefinder.load_stdlib_py_versions(custom_typeshed_dir)
|
|
2320
|
+
if version_info is None:
|
|
2321
|
+
version_info = sys.version_info[0:2]
|
|
2322
|
+
|
|
2323
|
+
def exists_in_version(module: str) -> bool:
|
|
2324
|
+
assert version_info is not None
|
|
2325
|
+
parts = module.split(".")
|
|
2326
|
+
for i in range(len(parts), 0, -1):
|
|
2327
|
+
current_module = ".".join(parts[:i])
|
|
2328
|
+
if current_module in stdlib_py_versions:
|
|
2329
|
+
minver, maxver = stdlib_py_versions[current_module]
|
|
2330
|
+
return version_info >= minver and (maxver is None or version_info <= maxver)
|
|
2331
|
+
return False
|
|
2332
|
+
|
|
2333
|
+
if custom_typeshed_dir:
|
|
2334
|
+
typeshed_dir = Path(custom_typeshed_dir)
|
|
2335
|
+
else:
|
|
2336
|
+
typeshed_dir = Path(mypy.build.default_data_dir()) / "typeshed"
|
|
2337
|
+
stdlib_dir = typeshed_dir / "stdlib"
|
|
2338
|
+
|
|
2339
|
+
modules: set[str] = set()
|
|
2340
|
+
for path in stdlib_dir.rglob("*.pyi"):
|
|
2341
|
+
if path.stem == "__init__":
|
|
2342
|
+
path = path.parent
|
|
2343
|
+
module = ".".join(path.relative_to(stdlib_dir).parts[:-1] + (path.stem,))
|
|
2344
|
+
if exists_in_version(module):
|
|
2345
|
+
modules.add(module)
|
|
2346
|
+
return modules
|
|
2347
|
+
|
|
2348
|
+
|
|
2349
|
+
def get_importable_stdlib_modules() -> set[str]:
|
|
2350
|
+
"""Return all importable stdlib modules at runtime."""
|
|
2351
|
+
importable_stdlib_modules: set[str] = set()
|
|
2352
|
+
for module_name in sys.stdlib_module_names:
|
|
2353
|
+
if module_name in ANNOYING_STDLIB_MODULES:
|
|
2354
|
+
continue
|
|
2355
|
+
|
|
2356
|
+
try:
|
|
2357
|
+
runtime = silent_import_module(module_name)
|
|
2358
|
+
except ImportError:
|
|
2359
|
+
continue
|
|
2360
|
+
else:
|
|
2361
|
+
importable_stdlib_modules.add(module_name)
|
|
2362
|
+
|
|
2363
|
+
try:
|
|
2364
|
+
# some stdlib modules (e.g. `nt`) don't have __path__ set...
|
|
2365
|
+
runtime_path = runtime.__path__
|
|
2366
|
+
runtime_name = runtime.__name__
|
|
2367
|
+
except AttributeError:
|
|
2368
|
+
continue
|
|
2369
|
+
|
|
2370
|
+
for submodule in pkgutil.walk_packages(runtime_path, runtime_name + "."):
|
|
2371
|
+
submodule_name = submodule.name
|
|
2372
|
+
|
|
2373
|
+
# There are many annoying *.__main__ stdlib modules,
|
|
2374
|
+
# and including stubs for them isn't really that useful anyway:
|
|
2375
|
+
# tkinter.__main__ opens a tkinter windows; unittest.__main__ raises SystemExit; etc.
|
|
2376
|
+
#
|
|
2377
|
+
# The idlelib.* submodules are similarly annoying in opening random tkinter windows,
|
|
2378
|
+
# and we're unlikely to ever add stubs for idlelib in typeshed
|
|
2379
|
+
# (see discussion in https://github.com/python/typeshed/pull/9193)
|
|
2380
|
+
#
|
|
2381
|
+
# test.* modules do weird things like raising exceptions in __del__ methods,
|
|
2382
|
+
# leading to unraisable exceptions being logged to the terminal
|
|
2383
|
+
# as a warning at the end of the stubtest run
|
|
2384
|
+
if submodule_name.endswith(".__main__") or submodule_name.startswith(
|
|
2385
|
+
("idlelib.", "test.")
|
|
2386
|
+
):
|
|
2387
|
+
continue
|
|
2388
|
+
|
|
2389
|
+
try:
|
|
2390
|
+
silent_import_module(submodule_name)
|
|
2391
|
+
except KeyboardInterrupt:
|
|
2392
|
+
raise
|
|
2393
|
+
# importing multiprocessing.popen_forkserver on Windows raises AttributeError...
|
|
2394
|
+
# some submodules also appear to raise SystemExit as well on some Python versions
|
|
2395
|
+
# (not sure exactly which)
|
|
2396
|
+
except BaseException:
|
|
2397
|
+
continue
|
|
2398
|
+
else:
|
|
2399
|
+
importable_stdlib_modules.add(submodule_name)
|
|
2400
|
+
|
|
2401
|
+
return importable_stdlib_modules
|
|
2402
|
+
|
|
2403
|
+
|
|
2404
|
+
def get_allowlist_entries(allowlist_file: str) -> Iterator[str]:
|
|
2405
|
+
def strip_comments(s: str) -> str:
|
|
2406
|
+
try:
|
|
2407
|
+
return s[: s.index("#")].strip()
|
|
2408
|
+
except ValueError:
|
|
2409
|
+
return s.strip()
|
|
2410
|
+
|
|
2411
|
+
with open(allowlist_file) as f:
|
|
2412
|
+
for line in f:
|
|
2413
|
+
entry = strip_comments(line)
|
|
2414
|
+
if entry:
|
|
2415
|
+
yield entry
|
|
2416
|
+
|
|
2417
|
+
|
|
2418
|
+
class _Arguments:
|
|
2419
|
+
modules: list[str]
|
|
2420
|
+
concise: bool
|
|
2421
|
+
ignore_missing_stub: bool
|
|
2422
|
+
ignore_positional_only: bool
|
|
2423
|
+
ignore_disjoint_bases: bool
|
|
2424
|
+
strict_type_check_only: bool
|
|
2425
|
+
allowlist: list[str]
|
|
2426
|
+
generate_allowlist: bool
|
|
2427
|
+
ignore_unused_allowlist: bool
|
|
2428
|
+
mypy_config_file: str | None
|
|
2429
|
+
custom_typeshed_dir: str | None
|
|
2430
|
+
check_typeshed: bool
|
|
2431
|
+
version: str
|
|
2432
|
+
show_traceback: bool
|
|
2433
|
+
pdb: bool
|
|
2434
|
+
|
|
2435
|
+
|
|
2436
|
+
# typeshed added a stub for __main__, but that causes stubtest to check itself
|
|
2437
|
+
ANNOYING_STDLIB_MODULES: Final = frozenset({"antigravity", "this", "__main__", "_ios_support"})
|
|
2438
|
+
|
|
2439
|
+
|
|
2440
|
+
def test_stubs(args: _Arguments, use_builtins_fixtures: bool = False) -> int:
|
|
2441
|
+
"""This is stubtest! It's time to test the stubs!"""
|
|
2442
|
+
# Load the allowlist. This is a series of strings corresponding to Error.object_desc
|
|
2443
|
+
# Values in the dict will store whether we used the allowlist entry or not.
|
|
2444
|
+
allowlist = {
|
|
2445
|
+
entry: False
|
|
2446
|
+
for allowlist_file in args.allowlist
|
|
2447
|
+
for entry in get_allowlist_entries(allowlist_file)
|
|
2448
|
+
}
|
|
2449
|
+
allowlist_regexes = {entry: re.compile(entry) for entry in allowlist}
|
|
2450
|
+
|
|
2451
|
+
# If we need to generate an allowlist, we store Error.object_desc for each error here.
|
|
2452
|
+
generated_allowlist = set()
|
|
2453
|
+
|
|
2454
|
+
modules = args.modules
|
|
2455
|
+
if args.check_typeshed:
|
|
2456
|
+
if args.modules:
|
|
2457
|
+
print(
|
|
2458
|
+
_style("error:", color="red", bold=True),
|
|
2459
|
+
"cannot pass both --check-typeshed and a list of modules",
|
|
2460
|
+
)
|
|
2461
|
+
return 1
|
|
2462
|
+
typeshed_modules = get_typeshed_stdlib_modules(args.custom_typeshed_dir)
|
|
2463
|
+
runtime_modules = get_importable_stdlib_modules()
|
|
2464
|
+
modules = sorted((typeshed_modules | runtime_modules) - ANNOYING_STDLIB_MODULES)
|
|
2465
|
+
|
|
2466
|
+
if not modules:
|
|
2467
|
+
print(_style("error:", color="red", bold=True), "no modules to check")
|
|
2468
|
+
return 1
|
|
2469
|
+
|
|
2470
|
+
options = Options()
|
|
2471
|
+
options.incremental = False
|
|
2472
|
+
options.custom_typeshed_dir = args.custom_typeshed_dir
|
|
2473
|
+
if options.custom_typeshed_dir:
|
|
2474
|
+
options.abs_custom_typeshed_dir = os.path.abspath(options.custom_typeshed_dir)
|
|
2475
|
+
options.config_file = args.mypy_config_file
|
|
2476
|
+
options.use_builtins_fixtures = use_builtins_fixtures
|
|
2477
|
+
options.show_traceback = args.show_traceback
|
|
2478
|
+
options.pdb = args.pdb
|
|
2479
|
+
options.pos_only_special_methods = False
|
|
2480
|
+
|
|
2481
|
+
if options.config_file:
|
|
2482
|
+
|
|
2483
|
+
def set_strict_flags() -> None: # not needed yet
|
|
2484
|
+
return
|
|
2485
|
+
|
|
2486
|
+
parse_config_file(options, set_strict_flags, options.config_file, sys.stdout, sys.stderr)
|
|
2487
|
+
|
|
2488
|
+
def error_callback(msg: str) -> typing.NoReturn:
|
|
2489
|
+
print(_style("error:", color="red", bold=True), msg)
|
|
2490
|
+
sys.exit(1)
|
|
2491
|
+
|
|
2492
|
+
def warning_callback(msg: str) -> None:
|
|
2493
|
+
print(_style("warning:", color="yellow", bold=True), msg)
|
|
2494
|
+
|
|
2495
|
+
options.process_error_codes(error_callback=error_callback)
|
|
2496
|
+
options.process_incomplete_features(
|
|
2497
|
+
error_callback=error_callback, warning_callback=warning_callback
|
|
2498
|
+
)
|
|
2499
|
+
options.process_strict_bytes()
|
|
2500
|
+
|
|
2501
|
+
try:
|
|
2502
|
+
modules = build_stubs(modules, options, find_submodules=not args.check_typeshed)
|
|
2503
|
+
except StubtestFailure as stubtest_failure:
|
|
2504
|
+
print(
|
|
2505
|
+
_style("error:", color="red", bold=True),
|
|
2506
|
+
f"not checking stubs due to {stubtest_failure}",
|
|
2507
|
+
)
|
|
2508
|
+
return 1
|
|
2509
|
+
|
|
2510
|
+
exit_code = 0
|
|
2511
|
+
error_count = 0
|
|
2512
|
+
for module in modules:
|
|
2513
|
+
for error in test_module(module):
|
|
2514
|
+
# Filter errors
|
|
2515
|
+
if args.ignore_missing_stub and error.is_missing_stub():
|
|
2516
|
+
continue
|
|
2517
|
+
if args.ignore_positional_only and error.is_positional_only_related():
|
|
2518
|
+
continue
|
|
2519
|
+
if args.ignore_disjoint_bases and error.is_disjoint_base_related():
|
|
2520
|
+
continue
|
|
2521
|
+
if not args.strict_type_check_only and error.is_private_type_check_only_related():
|
|
2522
|
+
continue
|
|
2523
|
+
if error.object_desc in allowlist:
|
|
2524
|
+
allowlist[error.object_desc] = True
|
|
2525
|
+
continue
|
|
2526
|
+
is_allowlisted = False
|
|
2527
|
+
for w in allowlist:
|
|
2528
|
+
if allowlist_regexes[w].fullmatch(error.object_desc):
|
|
2529
|
+
allowlist[w] = True
|
|
2530
|
+
is_allowlisted = True
|
|
2531
|
+
break
|
|
2532
|
+
if is_allowlisted:
|
|
2533
|
+
continue
|
|
2534
|
+
|
|
2535
|
+
# We have errors, so change exit code, and output whatever necessary
|
|
2536
|
+
exit_code = 1
|
|
2537
|
+
if args.generate_allowlist:
|
|
2538
|
+
generated_allowlist.add(error.object_desc)
|
|
2539
|
+
continue
|
|
2540
|
+
safe_print(error.get_description(concise=args.concise))
|
|
2541
|
+
error_count += 1
|
|
2542
|
+
|
|
2543
|
+
# Print unused allowlist entries
|
|
2544
|
+
if not args.ignore_unused_allowlist:
|
|
2545
|
+
for w in allowlist:
|
|
2546
|
+
# Don't consider an entry unused if it regex-matches the empty string
|
|
2547
|
+
# This lets us allowlist errors that don't manifest at all on some systems
|
|
2548
|
+
if not allowlist[w] and not allowlist_regexes[w].fullmatch(""):
|
|
2549
|
+
exit_code = 1
|
|
2550
|
+
error_count += 1
|
|
2551
|
+
print(f"note: unused allowlist entry {w}")
|
|
2552
|
+
|
|
2553
|
+
# Print the generated allowlist
|
|
2554
|
+
if args.generate_allowlist:
|
|
2555
|
+
for e in sorted(generated_allowlist):
|
|
2556
|
+
print(e)
|
|
2557
|
+
exit_code = 0
|
|
2558
|
+
elif not args.concise:
|
|
2559
|
+
if error_count:
|
|
2560
|
+
print(
|
|
2561
|
+
_style(
|
|
2562
|
+
f"Found {error_count} error{plural_s(error_count)}"
|
|
2563
|
+
f" (checked {len(modules)} module{plural_s(modules)})",
|
|
2564
|
+
color="red",
|
|
2565
|
+
bold=True,
|
|
2566
|
+
)
|
|
2567
|
+
)
|
|
2568
|
+
else:
|
|
2569
|
+
print(
|
|
2570
|
+
_style(
|
|
2571
|
+
f"Success: no issues found in {len(modules)} module{plural_s(modules)}",
|
|
2572
|
+
color="green",
|
|
2573
|
+
bold=True,
|
|
2574
|
+
)
|
|
2575
|
+
)
|
|
2576
|
+
|
|
2577
|
+
return exit_code
|
|
2578
|
+
|
|
2579
|
+
|
|
2580
|
+
def safe_print(text: str) -> None:
|
|
2581
|
+
"""Print a text replacing chars not representable in stdout encoding."""
|
|
2582
|
+
# If `sys.stdout` encoding is not the same as out (usually UTF8) string,
|
|
2583
|
+
# if may cause painful crashes. I don't want to reconfigure `sys.stdout`
|
|
2584
|
+
# to do `errors = "replace"` as that sounds scary.
|
|
2585
|
+
out_encoding = sys.stdout.encoding
|
|
2586
|
+
if out_encoding is not None:
|
|
2587
|
+
# Can be None if stdout is replaced (including our own tests). This should be
|
|
2588
|
+
# safe to omit if the actual stream doesn't care about encoding.
|
|
2589
|
+
text = text.encode(out_encoding, errors="replace").decode(out_encoding, errors="replace")
|
|
2590
|
+
print(text)
|
|
2591
|
+
|
|
2592
|
+
|
|
2593
|
+
def parse_options(args: list[str]) -> _Arguments:
|
|
2594
|
+
parser = argparse.ArgumentParser(
|
|
2595
|
+
description="Compares stubs to objects introspected from the runtime."
|
|
2596
|
+
)
|
|
2597
|
+
parser.add_argument("modules", nargs="*", help="Modules to test")
|
|
2598
|
+
parser.add_argument(
|
|
2599
|
+
"--concise",
|
|
2600
|
+
action="store_true",
|
|
2601
|
+
help="Makes stubtest's output more concise, one line per error",
|
|
2602
|
+
)
|
|
2603
|
+
parser.add_argument(
|
|
2604
|
+
"--ignore-missing-stub",
|
|
2605
|
+
action="store_true",
|
|
2606
|
+
help="Ignore errors for stub missing things that are present at runtime",
|
|
2607
|
+
)
|
|
2608
|
+
parser.add_argument(
|
|
2609
|
+
"--ignore-positional-only",
|
|
2610
|
+
action="store_true",
|
|
2611
|
+
help="Ignore errors for whether an argument should or shouldn't be positional-only",
|
|
2612
|
+
)
|
|
2613
|
+
# TODO: Remove once PEP 800 is accepted
|
|
2614
|
+
parser.add_argument(
|
|
2615
|
+
"--ignore-disjoint-bases",
|
|
2616
|
+
action="store_true",
|
|
2617
|
+
help="Disable checks for PEP 800 @disjoint_base classes",
|
|
2618
|
+
)
|
|
2619
|
+
parser.add_argument(
|
|
2620
|
+
"--strict-type-check-only",
|
|
2621
|
+
action="store_true",
|
|
2622
|
+
help="Require @type_check_only on private types that are not present at runtime",
|
|
2623
|
+
)
|
|
2624
|
+
parser.add_argument(
|
|
2625
|
+
"--allowlist",
|
|
2626
|
+
"--whitelist",
|
|
2627
|
+
action="append",
|
|
2628
|
+
metavar="FILE",
|
|
2629
|
+
default=[],
|
|
2630
|
+
help=(
|
|
2631
|
+
"Use file as an allowlist. Can be passed multiple times to combine multiple "
|
|
2632
|
+
"allowlists. Allowlists can be created with --generate-allowlist. Allowlists "
|
|
2633
|
+
"support regular expressions."
|
|
2634
|
+
),
|
|
2635
|
+
)
|
|
2636
|
+
parser.add_argument(
|
|
2637
|
+
"--generate-allowlist",
|
|
2638
|
+
"--generate-whitelist",
|
|
2639
|
+
action="store_true",
|
|
2640
|
+
help="Print an allowlist (to stdout) to be used with --allowlist",
|
|
2641
|
+
)
|
|
2642
|
+
parser.add_argument(
|
|
2643
|
+
"--ignore-unused-allowlist",
|
|
2644
|
+
"--ignore-unused-whitelist",
|
|
2645
|
+
action="store_true",
|
|
2646
|
+
help="Ignore unused allowlist entries",
|
|
2647
|
+
)
|
|
2648
|
+
parser.add_argument(
|
|
2649
|
+
"--mypy-config-file",
|
|
2650
|
+
metavar="FILE",
|
|
2651
|
+
help=("Use specified mypy config file to determine mypy plugins and mypy path"),
|
|
2652
|
+
)
|
|
2653
|
+
parser.add_argument(
|
|
2654
|
+
"--custom-typeshed-dir", metavar="DIR", help="Use the custom typeshed in DIR"
|
|
2655
|
+
)
|
|
2656
|
+
parser.add_argument(
|
|
2657
|
+
"--check-typeshed", action="store_true", help="Check all stdlib modules in typeshed"
|
|
2658
|
+
)
|
|
2659
|
+
parser.add_argument(
|
|
2660
|
+
"--version", action="version", version="%(prog)s " + mypy.version.__version__
|
|
2661
|
+
)
|
|
2662
|
+
parser.add_argument("--pdb", action="store_true", help="Invoke pdb on fatal error")
|
|
2663
|
+
parser.add_argument(
|
|
2664
|
+
"--show-traceback", "--tb", action="store_true", help="Show traceback on fatal error"
|
|
2665
|
+
)
|
|
2666
|
+
|
|
2667
|
+
return parser.parse_args(args, namespace=_Arguments())
|
|
2668
|
+
|
|
2669
|
+
|
|
2670
|
+
def main() -> int:
|
|
2671
|
+
mypy.util.check_python_version("stubtest")
|
|
2672
|
+
return test_stubs(parse_options(sys.argv[1:]))
|
|
2673
|
+
|
|
2674
|
+
|
|
2675
|
+
if __name__ == "__main__":
|
|
2676
|
+
sys.exit(main())
|