Title: Internal error appearing only with looser settings than defaults · Issue #9493 · python/mypy · GitHub
Open Graph Title: Internal error appearing only with looser settings than defaults · Issue #9493 · python/mypy
X Title: Internal error appearing only with looser settings than defaults · Issue #9493 · python/mypy
Description: Bug Report mypy crashes with an internal error when scanning the arviz open-source project on the current master branch when using a custom (I believe purely looser) configuration than mypy's default: [mypy] no_implicit_optional = False ...
Open Graph Description: Bug Report mypy crashes with an internal error when scanning the arviz open-source project on the current master branch when using a custom (I believe purely looser) configuration than mypy's defau...
X Description: Bug Report mypy crashes with an internal error when scanning the arviz open-source project on the current master branch when using a custom (I believe purely looser) configuration than mypy's d...
Opengraph URL: https://github.com/python/mypy/issues/9493
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Internal error appearing only with looser settings than defaults","articleBody":"**Bug Report**\r\n\r\n`mypy` crashes with an internal error when scanning the `arviz` [open-source project](https://github.com/arviz-devs/arviz) on the current `master` branch when using a custom (I believe purely looser) configuration than `mypy`'s default:\r\n```\r\n[mypy]\r\nno_implicit_optional = False\r\nstrict_optional = False\r\nwarn_redundant_casts = False\r\ncheck_untyped_defs = False\r\ndisallow_untyped_calls = False\r\ndisallow_incomplete_defs = False\r\ndisallow_untyped_defs = False\r\ndisallow_untyped_decorators = False\r\nignore_missing_imports = True\r\n```\r\n\r\nRunning with `mypy`'s defaults does not result in a crash, and `mypy` I believe correctly reports many violations.\r\n\r\nI found this while building `typing_copilot`, an [open-source tool](https://github.com/obi1kenobi/typing-copilot) to make it easier to start using mypy in large codebases. The tool is able to find the strictest possible `mypy` configuration that produces no errors, and therefore enables a ratcheting workflow:\r\n- Use `typing_copilot` to initially find the strictest passing configuration, set that as your starting `mypy.ini` file\r\n- Use `mypy` in a CI environment to prevent regressions.\r\n- Use `typing_copilot` to tighten the `mypy.ini` as your type coverage improves.\r\n- Use `typing_copilot` in a CI environment to enforce that any time `mypy.ini` could be tightened, it actually **gets tightened**.\r\n\r\nSadly, this issue is preventing that initial search for the strictest passing configuration from working, since the configuration which causes the error is the loosest configuration supported by `typing_copilot` and therefore represents the \"starting point\" of the search.\r\n\r\nHere's a link to the corresponding issue in its repo: https://github.com/obi1kenobi/typing-copilot/issues/1\r\n\r\n**To Reproduce**\r\n\r\n1. Clone the `arviz` project repo and check out the `master` branch (commit hash `24ce65a44d8b48eb9377fdee38246d059ce3d201` at time of writing).\r\n2. Make a `virtualenv`, install the project's dependencies from the several `requirements.txt` files. Ensure you have `xarray==0.16.1` installed, since that dependency appears to play a part in the error.\r\n3. Place the configuration given above into a file called `custom_mypy.ini`.\r\n4. Run `mypy --config-file ./custom_mypy.ini -p arviz --show-traceback` and observe `mypy` crash with an internal error.\r\n5. Then run `mypy -p arviz --show-traceback` (i.e. using the default configuration) and observe that `mypy` does not crash.\r\n\r\n**Expected Behavior**\r\n\r\nI did not expect `mypy` to crash, and I especially was surprised to see that *loosening* `mypy` configuration makes it crash.\r\n\r\n**Actual Behavior**\r\n\r\nWhen run with the custom config, `mypy` crashes with the following traceback:\r\n```\r\n/my/code/path/arviz/venv/lib/python3.8/site-packages/xarray/core/dataarray.py:2040: error: INTERNAL ERROR -- Please try using mypy master on Github:\r\nhttps://mypy.rtfd.io/en/latest/common_issues.html#using-a-development-mypy-build\r\nPlease report a bug at https://github.com/python/mypy/issues\r\nversion: 0.790+dev.0b4a2c9d8edb57e2b61219c96eefe010073a5c14\r\nTraceback (most recent call last):\r\n File \"/my/code/path/arviz/venv/bin/mypy\", line 8, in \u003cmodule>\r\n sys.exit(console_entry())\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/__main__.py\", line 11, in console_entry\r\n main(None, sys.stdout, sys.stderr)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/main.py\", line 90, in main\r\n res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/build.py\", line 180, in build\r\n result = _build(\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/build.py\", line 254, in _build\r\n graph = dispatch(sources, manager, stdout)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/build.py\", line 2630, in dispatch\r\n process_graph(graph, manager)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/build.py\", line 2953, in process_graph\r\n process_stale_scc(graph, scc, manager)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/build.py\", line 3051, in process_stale_scc\r\n graph[id].type_check_first_pass()\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/build.py\", line 2111, in type_check_first_pass\r\n self.type_checker().check_first_pass()\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/checker.py\", line 294, in check_first_pass\r\n self.accept(d)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/checker.py\", line 401, in accept\r\n stmt.accept(self)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/nodes.py\", line 940, in accept\r\n return visitor.visit_class_def(self)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/checker.py\", line 1723, in visit_class_def\r\n self.accept(defn.defs)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/checker.py\", line 401, in accept\r\n stmt.accept(self)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/nodes.py\", line 1005, in accept\r\n return visitor.visit_block(self)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/checker.py\", line 1972, in visit_block\r\n self.accept(s)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/checker.py\", line 401, in accept\r\n stmt.accept(self)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/nodes.py\", line 677, in accept\r\n return visitor.visit_func_def(self)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/checker.py\", line 726, in visit_func_def\r\n self._visit_func_def(defn)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/checker.py\", line 730, in _visit_func_def\r\n self.check_func_item(defn, name=defn.name)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/checker.py\", line 792, in check_func_item\r\n self.check_func_def(defn, typ, name)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/checker.py\", line 975, in check_func_def\r\n self.accept(item.body)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/checker.py\", line 401, in accept\r\n stmt.accept(self)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/nodes.py\", line 1005, in accept\r\n return visitor.visit_block(self)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/checker.py\", line 1972, in visit_block\r\n self.accept(s)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/checker.py\", line 401, in accept\r\n stmt.accept(self)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/nodes.py\", line 1196, in accept\r\n return visitor.visit_if_stmt(self)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/checker.py\", line 3255, in visit_if_stmt\r\n self.accept(b)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/checker.py\", line 401, in accept\r\n stmt.accept(self)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/nodes.py\", line 1005, in accept\r\n return visitor.visit_block(self)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/checker.py\", line 1972, in visit_block\r\n self.accept(s)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/checker.py\", line 401, in accept\r\n stmt.accept(self)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/nodes.py\", line 1130, in accept\r\n return visitor.visit_for_stmt(self)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/checker.py\", line 3478, in visit_for_stmt\r\n iterator_type, item_type = self.analyze_iterable_item_type(s.expr)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/checker.py\", line 3511, in analyze_iterable_item_type\r\n return iterator, echk.check_method_call_by_name(nextmethod, iterator, [], [], expr)[0]\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/checkexpr.py\", line 2346, in check_method_call_by_name\r\n method_type = analyze_member_access(method, base_type, context, False, False, True,\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/checkmember.py\", line 126, in analyze_member_access\r\n result = _analyze_member_access(name, typ, mx, override_info)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/checkmember.py\", line 143, in _analyze_member_access\r\n return analyze_instance_member_access(name, typ, mx, override_info)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/checkmember.py\", line 225, in analyze_instance_member_access\r\n return analyze_member_var_access(name, typ, info, mx)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/checkmember.py\", line 379, in analyze_member_var_access\r\n return analyze_var(name, v, itype, info, mx, implicit=implicit)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/checkmember.py\", line 581, in analyze_var\r\n dispatched_type = meet.meet_types(mx.original_type, itype)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/meet.py\", line 50, in meet_types\r\n return t.accept(TypeMeetVisitor(s))\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/types.py\", line 833, in accept\r\n return visitor.visit_instance(self)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/meet.py\", line 497, in visit_instance\r\n args.append(self.meet(ta, sia))\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/meet.py\", line 647, in meet\r\n return meet_types(s, t)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/meet.py\", line 50, in meet_types\r\n return t.accept(TypeMeetVisitor(s))\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/types.py\", line 1386, in accept\r\n return visitor.visit_tuple_type(self)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/meet.py\", line 584, in visit_tuple_type\r\n return TupleType(items, tuple_fallback(t))\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/typeops.py\", line 44, in tuple_fallback\r\n return Instance(info, [join_type_list(typ.items)])\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/join.py\", line 531, in join_type_list\r\n joined = join_types(joined, t)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/join.py\", line 105, in join_types\r\n return t.accept(TypeJoinVisitor(s))\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/types.py\", line 833, in accept\r\n return visitor.visit_instance(self)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/join.py\", line 158, in visit_instance\r\n nominal = join_instances(t, self.s)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/join.py\", line 371, in join_instances\r\n elif t.type.bases and is_subtype_ignoring_tvars(t, s):\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/subtypes.py\", line 143, in is_subtype_ignoring_tvars\r\n return is_subtype(left, right, ignore_type_params=True)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/subtypes.py\", line 93, in is_subtype\r\n return _is_subtype(left, right,\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/subtypes.py\", line 135, in _is_subtype\r\n return left.accept(SubtypeVisitor(orig_right,\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/types.py\", line 833, in accept\r\n return visitor.visit_instance(self)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/subtypes.py\", line 264, in visit_instance\r\n if right.type.is_protocol and is_protocol_implementation(left, right):\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/subtypes.py\", line 550, in is_protocol_implementation\r\n is_compat = is_subtype(subtype, supertype, ignore_pos_arg_names=ignore_names)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/subtypes.py\", line 93, in is_subtype\r\n return _is_subtype(left, right,\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/subtypes.py\", line 135, in _is_subtype\r\n return left.accept(SubtypeVisitor(orig_right,\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/types.py\", line 1825, in accept\r\n return visitor.visit_partial_type(self)\r\n File \"/my/code/path/arviz/venv/lib/python3.8/site-packages/mypy/subtypes.py\", line 468, in visit_partial_type\r\n raise RuntimeError\r\nRuntimeError: \r\n/my/code/path/arviz/venv/lib/python3.8/site-packages/xarray/core/dataarray.py:2040: : note: use --pdb to drop into pdb\r\n``` \r\n\r\n**Your Environment**\r\n\r\n- Mypy version used: current `master` -- `0.790+dev.0b4a2c9d8edb57e2b61219c96eefe010073a5c14`\r\n- Mypy command-line flags: `--config-file ./custom_mypy.ini -p arviz --show-traceback`\r\n- Mypy configuration options from `mypy.ini` (and other config files): See top of issue post\r\n- Python version used: 3.8.2\r\n- Operating system and version: Ubuntu 20.04 LTS running under Windows Subsystem for Linux 2\r\n\r\nI'm not familiar with the `mypy` codebase, but I'd love to help in any way I can since this is blocking my progress on `typing_copilot`, which I hope will be a tool useful to anyone seeking to start using `mypy` in a large existing Python codebase. ","author":{"url":"https://github.com/obi1kenobi","@type":"Person","name":"obi1kenobi"},"datePublished":"2020-09-27T04:38:07Z","url":"https://github.com/python/mypy/issues/9493"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:be59536b-31ce-fd78-294b-593948c7f2e1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | D926:302FC:61CC88:82A879:6B003434 |
| html-safe-nonce | cadef935a7c5b2166cf1a55e6228ab01b9c67a756d091944b210b238af2864f1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJEOTI2OjMwMkZDOjYxQ0M4ODo4MkE4Nzk6NkIwMDM0MzQiLCJ2aXNpdG9yX2lkIjoiMTk0NTA5NjY3MzMxOTQ2NjAzNiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | ebea65011a3083b53a19cf974465c67abff5d4134117c8c309ca12e2404e6aaa |
| hovercard-subject-tag | issue:709665630 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/mypy/9493/issue_layout |
| twitter:image | https://opengraph.githubassets.com/8e44afd7c6d915c5e9049fa35d7b906b8ac9b4a6ff3610355582f2a012ec280c/python/mypy/issues/9493 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/8e44afd7c6d915c5e9049fa35d7b906b8ac9b4a6ff3610355582f2a012ec280c/python/mypy/issues/9493 |
| og:image:alt | Bug Report mypy crashes with an internal error when scanning the arviz open-source project on the current master branch when using a custom (I believe purely looser) configuration than mypy's defau... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | obi1kenobi |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/mypy git https://github.com/python/mypy.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 7053637 |
| octolytics-dimension-repository_nwo | python/mypy |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 7053637 |
| octolytics-dimension-repository_network_root_nwo | python/mypy |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width