Title: Subtype of mapping is not compatible type in `.update()` method · Issue #10970 · python/mypy · GitHub
Open Graph Title: Subtype of mapping is not compatible type in `.update()` method · Issue #10970 · python/mypy
X Title: Subtype of mapping is not compatible type in `.update()` method · Issue #10970 · python/mypy
Description: async def psubscribe(self, *args: ChannelT, **kwargs: PubSubHandler): new_patterns: Dict[ChannelT, Optional[PubSubHandler]] = dict.fromkeys(args) new_patterns.update(kwargs) This code (taken from aioredis) produces this error: error: Arg...
Open Graph Description: async def psubscribe(self, *args: ChannelT, **kwargs: PubSubHandler): new_patterns: Dict[ChannelT, Optional[PubSubHandler]] = dict.fromkeys(args) new_patterns.update(kwargs) This code (taken from a...
X Description: async def psubscribe(self, *args: ChannelT, **kwargs: PubSubHandler): new_patterns: Dict[ChannelT, Optional[PubSubHandler]] = dict.fromkeys(args) new_patterns.update(kwargs) This code (taken from a...
Opengraph URL: https://github.com/python/mypy/issues/10970
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Subtype of mapping is not compatible type in `.update()` method","articleBody":"```\r\n async def psubscribe(self, *args: ChannelT, **kwargs: PubSubHandler):\r\n new_patterns: Dict[ChannelT, Optional[PubSubHandler]] = dict.fromkeys(args)\r\n new_patterns.update(kwargs)\r\n```\r\n\r\nThis code (taken from aioredis) produces this error:\r\n`error: Argument 1 to \"update\" of \"dict\" has incompatible type \"Dict[str, Callable[[Dict[str, str]], None]]\"; expected \"Mapping[Union[bytes, str, memoryview], Optional[Callable[[Dict[str, str]], None]]]\" [arg-type]`\r\n\r\nBut, the types are compatible as the keys and values are part of the expected union, I can't think of any operation that would make this unsafe. I understand it could be unsafe if the expectation was `MutableMapping`, as the function might assign any of the unioned types, but for `Mapping` this looks completely safe to me.","author":{"url":"https://github.com/Dreamsorcerer","@type":"Person","name":"Dreamsorcerer"},"datePublished":"2021-08-11T18:33:22Z","url":"https://github.com/python/mypy/issues/10970"}
| 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:b0b9d036-0eb3-aa42-4640-88a0decb73e8 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | C17C:2C0A92:3149CDD:411F572:6B002D77 |
| html-safe-nonce | 23babba5473fdea1b7a96ed9006dc4a2112ed1fad8457e54c2ec6e92fc5dc4f5 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMTdDOjJDMEE5MjozMTQ5Q0REOjQxMUY1NzI6NkIwMDJENzciLCJ2aXNpdG9yX2lkIjoiODQwMTQxOTQyMTA4NzcwNjQ4NyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 1d602e87f6b700c6de7f62ae62717bdaec049ff87ec1b465bd37e4d7029ffe5c |
| hovercard-subject-tag | issue:967224443 |
| 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/10970/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1991c50dd9b37d0e3aececfeeedc5cafe54f3567c1fffd1141e2dc6307925857/python/mypy/issues/10970 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1991c50dd9b37d0e3aececfeeedc5cafe54f3567c1fffd1141e2dc6307925857/python/mypy/issues/10970 |
| og:image:alt | async def psubscribe(self, *args: ChannelT, **kwargs: PubSubHandler): new_patterns: Dict[ChannelT, Optional[PubSubHandler]] = dict.fromkeys(args) new_patterns.update(kwargs) This code (taken from a... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Dreamsorcerer |
| 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