Title: New semantic analyzer: crash on assignment to sqlalchemy @hybrid_property · Issue #7044 · python/mypy · GitHub
Open Graph Title: New semantic analyzer: crash on assignment to sqlalchemy @hybrid_property · Issue #7044 · python/mypy
X Title: New semantic analyzer: crash on assignment to sqlalchemy @hybrid_property · Issue #7044 · python/mypy
Description: I'm testing out the new semantic analyzer, but it crashes on my codebase. Trying to assign to a SQLAlchemy @hybrid_property) results in a Cannot assign to a method error followed by a crash. Here's a fairly minimal reproduction for it: f...
Open Graph Description: I'm testing out the new semantic analyzer, but it crashes on my codebase. Trying to assign to a SQLAlchemy @hybrid_property) results in a Cannot assign to a method error followed by a crash. Here's...
X Description: I'm testing out the new semantic analyzer, but it crashes on my codebase. Trying to assign to a SQLAlchemy @hybrid_property) results in a Cannot assign to a method error followed by a crash. He...
Opengraph URL: https://github.com/python/mypy/issues/7044
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"New semantic analyzer: crash on assignment to sqlalchemy @hybrid_property","articleBody":"I'm testing out the new semantic analyzer, but it crashes on my codebase. Trying to assign to a [SQLAlchemy `@hybrid_property`](https://docs.sqlalchemy.org/en/13/orm/extensions/hybrid.html)) results in a `Cannot assign to a method` error followed by a crash.\r\n\r\nHere's a fairly minimal reproduction for it:\r\n\r\n```python3\r\nfrom sqlalchemy import Base, Column, String\r\nfrom sqlalchemy.ext.hybrid import hybrid_property\r\n\r\nclass FirstNameOnly(Base):\r\n first_name = Column(String)\r\n\r\n @hybrid_property\r\n def name(self) -> str:\r\n return self.first_name\r\n\r\n @name.setter # type: ignore\r\n def name(self, value: str) -> None:\r\n self.first_name = value\r\n\r\n def __init__(self, name: str):\r\n self.name = name\r\n```\r\n\r\nThe `# type: ignore` comment on the setter is a workaround for this issue I reported last year: https://github.com/python/mypy/issues/4430\r\n\r\nHere's the full output:\r\n\r\n```\r\n(tildes) vagrant@ubuntu-xenial:/opt/tildes$ mypy --new-semantic-analyzer --show-traceback test_mypy.py \r\ntest_mypy.py:16: error: Cannot assign to a method\r\ntest_mypy.py:16: error: INTERNAL ERROR -- Please try using mypy master on Github:\r\nhttps://mypy.rtfd.io/en/latest/common_issues.html#using-development-mypy-build\r\nPlease report a bug at https://github.com/python/mypy/issues\r\nversion: 0.720+dev.48916e63403645730a584d6898fbe925d513a841\r\nTraceback (most recent call last):\r\n File \"/opt/venvs/tildes/bin/mypy\", line 10, in \u003cmodule>\r\n sys.exit(console_entry())\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/__main__.py\", line 8, in console_entry\r\n main(None, sys.stdout, sys.stderr)\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/main.py\", line 83, in main\r\n res = build.build(sources, options, None, flush_errors, fscache, stdout, stderr)\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/build.py\", line 164, in build\r\n result = _build(sources, options, alt_lib_path, flush_errors, fscache, stdout, stderr)\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/build.py\", line 224, in _build\r\n graph = dispatch(sources, manager, stdout)\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/build.py\", line 2567, in dispatch\r\n process_graph(graph, manager)\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/build.py\", line 2880, in process_graph\r\n process_stale_scc(graph, scc, manager)\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/build.py\", line 2987, in process_stale_scc\r\n graph[id].type_check_first_pass()\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/build.py\", line 2096, in type_check_first_pass\r\n self.type_checker().check_first_pass()\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/checker.py\", line 281, in check_first_pass\r\n self.accept(d)\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/checker.py\", line 392, in accept\r\n stmt.accept(self)\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/nodes.py\", line 913, in accept\r\n return visitor.visit_class_def(self)\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/checker.py\", line 1596, in visit_class_def\r\n self.accept(defn.defs)\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/checker.py\", line 392, in accept\r\n stmt.accept(self)\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/nodes.py\", line 978, in accept\r\n return visitor.visit_block(self)\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/checker.py\", line 1785, in visit_block\r\n self.accept(s)\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/checker.py\", line 392, in accept\r\n stmt.accept(self)\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/nodes.py\", line 655, in accept\r\n return visitor.visit_func_def(self)\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/checker.py\", line 703, in visit_func_def\r\n self._visit_func_def(defn)\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/checker.py\", line 707, in _visit_func_def\r\n self.check_func_item(defn, name=defn.name())\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/checker.py\", line 769, in check_func_item\r\n self.check_func_def(defn, typ, name)\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/checker.py\", line 935, in check_func_def\r\n self.accept(item.body)\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/checker.py\", line 392, in accept\r\n stmt.accept(self)\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/nodes.py\", line 978, in accept\r\n return visitor.visit_block(self)\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/checker.py\", line 1785, in visit_block\r\n self.accept(s)\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/checker.py\", line 392, in accept\r\n stmt.accept(self)\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/nodes.py\", line 1036, in accept\r\n return visitor.visit_assignment_stmt(self)\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/checker.py\", line 1793, in visit_assignment_stmt\r\n self.check_assignment(s.lvalues[-1], s.rvalue, s.type is None, s.new_syntax)\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/checker.py\", line 1834, in check_assignment\r\n lvalue_type, index_lvalue, inferred = self.check_lvalue(lvalue)\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/checker.py\", line 2479, in check_lvalue\r\n True)\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/checkexpr.py\", line 1766, in analyze_ordinary_member_access\r\n in_literal_context=self.is_literal_context())\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/checkmember.py\", line 103, in analyze_member_access\r\n result = _analyze_member_access(name, typ, mx, override_info)\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/checkmember.py\", line 117, in _analyze_member_access\r\n return analyze_instance_member_access(name, typ, mx, override_info)\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/checkmember.py\", line 179, in analyze_instance_member_access\r\n signature = function_type(method, mx.builtin_type('builtins.function'))\r\n File \"/opt/venvs/tildes/lib/python3.7/site-packages/mypy/types.py\", line 2188, in function_type\r\n assert isinstance(func, mypy.nodes.FuncItem), str(func)\r\nAssertionError: OverloadedFuncDef:7(\r\n Decorator:11(\r\n Var(name)\r\n MemberExpr:11(\r\n NameExpr(name [test_mypy.FirstNameOnly.name])\r\n setter)\r\n FuncDef:12(\r\n name\r\n Args(\r\n Var(self)\r\n Var(value))\r\n def (self: test_mypy.FirstNameOnly, value: builtins.str)\r\n Block:12(\r\n AssignmentStmt:13(\r\n MemberExpr:13(\r\n NameExpr(self [l])\r\n first_name)\r\n NameExpr(value [l]))))))\r\n```","author":{"url":"https://github.com/Deimos","@type":"Person","name":"Deimos"},"datePublished":"2019-06-22T01:25:37Z","url":"https://github.com/python/mypy/issues/7044"}
| 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:589d0b3c-231f-9b2c-6487-7d2a4d785bcb |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8B2E:C5FC2:2031A62:2A866E6:6B004725 |
| html-safe-nonce | 7c9acfd2fc478173b898e9917f9d4b49b50770be84d926124e17aa903d579fa7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QjJFOkM1RkMyOjIwMzFBNjI6MkE4NjZFNjo2QjAwNDcyNSIsInZpc2l0b3JfaWQiOiIyMzUwOTc4MTA5MzU3OTY3MTQxIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | a3b499073ef148029def9e75acbb909f72ec76dbc60d035019962d538da09619 |
| hovercard-subject-tag | issue:459418367 |
| 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/7044/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ca2257c9bd627b1983e97909885d9ca760ff87d84b61f0e47d146ce9263ad931/python/mypy/issues/7044 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ca2257c9bd627b1983e97909885d9ca760ff87d84b61f0e47d146ce9263ad931/python/mypy/issues/7044 |
| og:image:alt | I'm testing out the new semantic analyzer, but it crashes on my codebase. Trying to assign to a SQLAlchemy @hybrid_property) results in a Cannot assign to a method error followed by a crash. Here's... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Deimos |
| 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 | canary-2 |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width