Title: Crash when using Optional[TypedDictType] · Issue #7149 · python/mypy · GitHub
Open Graph Title: Crash when using Optional[TypedDictType] · Issue #7149 · python/mypy
X Title: Crash when using Optional[TypedDictType] · Issue #7149 · python/mypy
Description: Mypy crashes when type checking this code: from typing import Union from mypy_extensions import TypedDict class A(TypedDict): x: int d: Union[A, None] d.update({'x': 1}) Here's the traceback: ... File "/Users/jukka/src/mypy/mypy/checker....
Open Graph Description: Mypy crashes when type checking this code: from typing import Union from mypy_extensions import TypedDict class A(TypedDict): x: int d: Union[A, None] d.update({'x': 1}) Here's the traceback: ... F...
X Description: Mypy crashes when type checking this code: from typing import Union from mypy_extensions import TypedDict class A(TypedDict): x: int d: Union[A, None] d.update({'x': 1}) Here's the trac...
Opengraph URL: https://github.com/python/mypy/issues/7149
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Crash when using Optional[TypedDictType]","articleBody":"Mypy crashes when type checking this code:\r\n\r\n```py\r\nfrom typing import Union\r\nfrom mypy_extensions import TypedDict\r\n\r\nclass A(TypedDict):\r\n x: int\r\n\r\nd: Union[A, None]\r\nd.update({'x': 1})\r\n```\r\n\r\nHere's the traceback:\r\n\r\n```\r\n...\r\n File \"/Users/jukka/src/mypy/mypy/checker.py\", line 281, in check_first_pass\r\n self.accept(d)\r\n File \"/Users/jukka/src/mypy/mypy/checker.py\", line 392, in accept\r\n stmt.accept(self)\r\n File \"/Users/jukka/src/mypy/mypy/nodes.py\", line 1002, in accept\r\n return visitor.visit_expression_stmt(self)\r\n File \"/Users/jukka/src/mypy/mypy/checker.py\", line 2788, in visit_expression_stmt\r\n self.expr_checker.accept(s.expr, allow_none_return=True, always_allow_any=True)\r\n File \"/Users/jukka/src/mypy/mypy/checkexpr.py\", line 3351, in accept\r\n typ = self.visit_call_expr(node, allow_none_return=True)\r\n File \"/Users/jukka/src/mypy/mypy/checkexpr.py\", line 234, in visit_call_expr\r\n return self.visit_call_expr_inner(e, allow_none_return=allow_none_return)\r\n File \"/Users/jukka/src/mypy/mypy/checkexpr.py\", line 307, in visit_call_expr_inner\r\n object_type, member)\r\n File \"/Users/jukka/src/mypy/mypy/checkexpr.py\", line 660, in check_call_expr_with_callee_type\r\n return self.check_union_call_expr(e, object_type, member)\r\n File \"/Users/jukka/src/mypy/mypy/checkexpr.py\", line 682, in check_union_call_expr\r\n item_object_type))\r\n File \"/Users/jukka/src/mypy/mypy/checkexpr.py\", line 657, in check_call_expr_with_callee_type\r\n callable_name, callee_type, e.args, e.arg_kinds, e, e.arg_names, object_type)\r\n File \"/Users/jukka/src/mypy/mypy/checkexpr.py\", line 630, in transform_callee_type\r\n callee, args, arg_kinds, context, arg_names, object_type, signature_hook)\r\n File \"/Users/jukka/src/mypy/mypy/checkexpr.py\", line 594, in apply_method_signature_hook\r\n MethodSigContext(object_type, formal_arg_exprs, callee, context, self.chk))\r\n File \"/Users/jukka/src/mypy/mypy/plugins/default.py\", line 325, in typed_dict_update_signature_callback\r\n assert isinstance(arg_type, TypedDictType)\r\nAssertionError:\r\n```\r\n\r\nThe plugin hook gets the union type as the argument, even though it should probably only get the TypedDict type. The bug was introduced in #6560.\r\n\r\ncc @ilevkivskyi ","author":{"url":"https://github.com/JukkaL","@type":"Person","name":"JukkaL"},"datePublished":"2019-07-04T15:35:31Z","url":"https://github.com/python/mypy/issues/7149"}
| 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:54041d40-187b-09a9-be0d-56963d05fcf3 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E942:2A0045:307C26B:40117CF:6B002C3D |
| html-safe-nonce | 60dd1a5c09cf15b4e232bdd67f32afa0bbdf101c5793e07812d931574e461280 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFOTQyOjJBMDA0NTozMDdDMjZCOjQwMTE3Q0Y6NkIwMDJDM0QiLCJ2aXNpdG9yX2lkIjoiMzQ4NjI3MjYzODY4NTI5MzYyOSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | cb11128f40075799b9d6416e6f4e42fc1c9ecf6f32fb3a29f6cb92a03144c40c |
| hovercard-subject-tag | issue:464323582 |
| 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/7149/issue_layout |
| twitter:image | https://opengraph.githubassets.com/515f73790aed68b2bdf9da98473256a5c12c7cd37a83074e3bf9da269fa903f0/python/mypy/issues/7149 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/515f73790aed68b2bdf9da98473256a5c12c7cd37a83074e3bf9da269fa903f0/python/mypy/issues/7149 |
| og:image:alt | Mypy crashes when type checking this code: from typing import Union from mypy_extensions import TypedDict class A(TypedDict): x: int d: Union[A, None] d.update({'x': 1}) Here's the traceback: ... F... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | JukkaL |
| 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