Title: Overriding definition such as type alias in a subclass causes a crash · Issue #5425 · python/mypy · GitHub
Open Graph Title: Overriding definition such as type alias in a subclass causes a crash · Issue #5425 · python/mypy
X Title: Overriding definition such as type alias in a subclass causes a crash · Issue #5425 · python/mypy
Description: The following program crashes on both mypy 0.620 and the latest version on master: from typing import Any, Callable class Parent: foo = Callable[..., int] class Child(Parent): def foo(self, val: int) -> int: return val * 2 (In this case,...
Open Graph Description: The following program crashes on both mypy 0.620 and the latest version on master: from typing import Any, Callable class Parent: foo = Callable[..., int] class Child(Parent): def foo(self, val: in...
X Description: The following program crashes on both mypy 0.620 and the latest version on master: from typing import Any, Callable class Parent: foo = Callable[..., int] class Child(Parent): def foo(self, val: in...
Opengraph URL: https://github.com/python/mypy/issues/5425
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Overriding definition such as type alias in a subclass causes a crash","articleBody":"The following program crashes on both mypy 0.620 and the latest version on master:\r\n\r\n```python\r\nfrom typing import Any, Callable\r\n\r\nclass Parent:\r\n foo = Callable[..., int] \r\n\r\nclass Child(Parent):\r\n def foo(self, val: int) -> int:\r\n return val * 2\r\n```\r\n\r\n(In this case, I meant to do `foo: Callable[..., int]`.)\r\n\r\nHere's the traceback:\r\n\r\n```\r\ntest.py:13: error: INTERNAL ERROR -- please report a bug at https://github.com/python/mypy/\r\nissues version: 0.630+dev-1222c9637b673bcca6218a943cd4b88b8749b0ad\r\nTraceback (most recent call last):\r\n File \"C:\\Python3.6\\lib\\runpy.py\", line 193, in _run_module_as_main\r\n \"__main__\", mod_spec)\r\n File \"C:\\Python3.6\\lib\\runpy.py\", line 85, in _run_code\r\n exec(code, run_globals)\r\n File \"C:\\Users\\Michael\\Dropbox\\mypy\\mypy\\__main__.py\", line 11, in \u003cmodule>\r\n main(None)\r\n File \"C:\\Users\\Michael\\Dropbox\\mypy\\mypy\\main.py\", line 91, in main\r\n res = type_check_only(sources, bin_dir, options, flush_errors, fscache) # noqa\r\n File \"C:\\Users\\Michael\\Dropbox\\mypy\\mypy\\main.py\", line 148, in type_check_only\r\n fscache=fscache)\r\n File \"C:\\Users\\Michael\\Dropbox\\mypy\\mypy\\build.py\", line 177, in build\r\n flush_errors, fscache)\r\n File \"C:\\Users\\Michael\\Dropbox\\mypy\\mypy\\build.py\", line 350, in _build\r\n graph = dispatch(sources, manager)\r\n File \"C:\\Users\\Michael\\Dropbox\\mypy\\mypy\\build.py\", line 2572, in dispatch\r\n process_graph(graph, manager)\r\n File \"C:\\Users\\Michael\\Dropbox\\mypy\\mypy\\build.py\", line 2866, in process_graph\r\n process_stale_scc(graph, scc, manager)\r\n File \"C:\\Users\\Michael\\Dropbox\\mypy\\mypy\\build.py\", line 2989, in process_stale_scc\r\n graph[id].type_check_first_pass()\r\n File \"C:\\Users\\Michael\\Dropbox\\mypy\\mypy\\build.py\", line 2162, in type_check_first_pass\r\n self.type_checker().check_first_pass()\r\n File \"C:\\Users\\Michael\\Dropbox\\mypy\\mypy\\checker.py\", line 253, in check_first_pass\r\n self.accept(d)\r\n File \"C:\\Users\\Michael\\Dropbox\\mypy\\mypy\\checker.py\", line 352, in accept\r\n stmt.accept(self)\r\n File \"C:\\Users\\Michael\\Dropbox\\mypy\\mypy\\nodes.py\", line 808, in accept\r\n return visitor.visit_class_def(self)\r\n File \"C:\\Users\\Michael\\Dropbox\\mypy\\mypy\\checker.py\", line 1389, in visit_class_def\r\n self.accept(defn.defs)\r\n File \"C:\\Users\\Michael\\Dropbox\\mypy\\mypy\\checker.py\", line 352, in accept\r\n stmt.accept(self)\r\n File \"C:\\Users\\Michael\\Dropbox\\mypy\\mypy\\nodes.py\", line 873, in accept\r\n return visitor.visit_block(self)\r\n File \"C:\\Users\\Michael\\Dropbox\\mypy\\mypy\\checker.py\", line 1535, in visit_block\r\n self.accept(s)\r\n File \"C:\\Users\\Michael\\Dropbox\\mypy\\mypy\\checker.py\", line 352, in accept\r\n stmt.accept(self)\r\n File \"C:\\Users\\Michael\\Dropbox\\mypy\\mypy\\nodes.py\", line 591, in accept\r\n return visitor.visit_func_def(self)\r\n File \"C:\\Users\\Michael\\Dropbox\\mypy\\mypy\\checker.py\", line 663, in visit_func_def\r\n self._visit_func_def(defn)\r\n File \"C:\\Users\\Michael\\Dropbox\\mypy\\mypy\\checker.py\", line 674, in _visit_func_def\r\n self.check_method_override(defn)\r\n File \"C:\\Users\\Michael\\Dropbox\\mypy\\mypy\\checker.py\", line 1200, in check_method_override\r\n self.check_method_or_accessor_override_for_base(defn, base)\r\n File \"C:\\Users\\Michael\\Dropbox\\mypy\\mypy\\checker.py\", line 1210, in check_method_or_accessor_override_for_base\r\n self.check_method_override_for_base_with_name(defn, name, base)\r\n File \"C:\\Users\\Michael\\Dropbox\\mypy\\mypy\\checker.py\", line 1254, in check_method_override_for_base_with_name\r\n assert False, str(base_attr.node)\r\nAssertionError: \u003cmypy.nodes.TypeAlias object at 0x000002139F12C588>\r\ntest.py:13: : note: use --pdb to drop into pdb\r\n```\r\n\r\nI did a cursory skim of the existing crash issues, but maybe this is already a known issue? If so, feel free to close.","author":{"url":"https://github.com/Michael0x2a","@type":"Person","name":"Michael0x2a"},"datePublished":"2018-08-07T07:04:36Z","url":"https://github.com/python/mypy/issues/5425"}
| 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:a957e22d-b497-51cd-3088-40270a007024 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | AA54:184B81:24EFB3F:3035E7D:6AFFF875 |
| html-safe-nonce | c4cace5abfb925b6a9941bc0fbfae8e2900121f5d1d891e640c26fe1c465d850 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBQTU0OjE4NEI4MToyNEVGQjNGOjMwMzVFN0Q6NkFGRkY4NzUiLCJ2aXNpdG9yX2lkIjoiODUxODM2NTU1MjI4NzE1MjI0NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 141e1e337a858fa6468f7a562915c8f1387692db74d0c8a74780aa4d7f442873 |
| hovercard-subject-tag | issue:348193185 |
| 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/5425/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7aac25caa59280418b2a2e53fc499409737a4c5a69f9c2a6f534974fd78149c7/python/mypy/issues/5425 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7aac25caa59280418b2a2e53fc499409737a4c5a69f9c2a6f534974fd78149c7/python/mypy/issues/5425 |
| og:image:alt | The following program crashes on both mypy 0.620 and the latest version on master: from typing import Any, Callable class Parent: foo = Callable[..., int] class Child(Parent): def foo(self, val: in... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Michael0x2a |
| hostname | github.com |
| expected-hostname | github.com |
| None | 0a0d8686a27478df474dd7415776a7a080cde8838b3cd92ea7601187572e5729 |
| 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 | 16a11879678aaf97e2a42c33ee70830aa084fa37 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width