Title: Dictionary accepting Mapping in a merge operation · Issue #11264 · python/typeshed · GitHub
Open Graph Title: Dictionary accepting Mapping in a merge operation · Issue #11264 · python/typeshed
X Title: Dictionary accepting Mapping in a merge operation · Issue #11264 · python/typeshed
Description: Hi. I would like to propose that a dictionary accepts a mapping to the or operation. Something like: class dict(MutableMapping[_KT, _VT]): ... @overload def __or__(self, __value: Mapping[_KT, _VT]) -> dict[_KT, _VT]: ... @overload def __...
Open Graph Description: Hi. I would like to propose that a dictionary accepts a mapping to the or operation. Something like: class dict(MutableMapping[_KT, _VT]): ... @overload def __or__(self, __value: Mapping[_KT, _VT])...
X Description: Hi. I would like to propose that a dictionary accepts a mapping to the or operation. Something like: class dict(MutableMapping[_KT, _VT]): ... @overload def __or__(self, __value: Mapping[_KT, _VT])...
Opengraph URL: https://github.com/python/typeshed/issues/11264
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Dictionary accepting Mapping in a merge operation","articleBody":"Hi. I would like to propose that a dictionary accepts a mapping to the __or__ operation. Something like:\r\n```python\r\nclass dict(MutableMapping[_KT, _VT]):\r\n ...\r\n @overload\r\n def __or__(self, __value: Mapping[_KT, _VT]) -> dict[_KT, _VT]: ...\r\n @overload\r\n def __or__(self, __value: Mapping[_T1, _T2]) -> dict[_KT | _T1, _VT | _T2]: ...\r\n```\r\n\r\nIt would be useful in scenarios like the following:\r\n```python\r\nfrom collections.abc import Mapping\r\nfrom typing import cast\r\n\r\na = cast(Mapping[str, int], {\"a\": 1})\r\n{\"b\": 2} | a\r\n```\r\nAt this point, pyright complains with `# error: Operator \"|\" not supported for types \"dict[str, int]\" and \"Mapping[str, int]\"`. \r\nI referenced this problem in this [issue](https://github.com/microsoft/pyright/issues/6941). Thanks.","author":{"url":"https://github.com/jzazo","@type":"Person","name":"jzazo"},"datePublished":"2024-01-09T19:08:22Z","url":"https://github.com/python/typeshed/issues/11264"}
| 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:6790e1d7-919a-1548-805a-4a3e65d7790f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B8C0:43251:16E4874:1E75FAA:6B00290F |
| html-safe-nonce | f13b5eaefee4dfefae1a83b2f0d72dd8de2258c2882799959030b24becf74f14 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOEMwOjQzMjUxOjE2RTQ4NzQ6MUU3NUZBQTo2QjAwMjkwRiIsInZpc2l0b3JfaWQiOiI4NjE5MTY0MDA2NjEzMDAyNTEyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | c1b2c5759f809fefbcc6e26c3e5f9bf6ee98d507e790660d17bfba2b58f02d1c |
| hovercard-subject-tag | issue:2072993252 |
| 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/typeshed/11264/issue_layout |
| twitter:image | https://opengraph.githubassets.com/80c857e914d8e7b9b6579041c7a4d1f3fbc515f0faf149f359585e0f6b41d128/python/typeshed/issues/11264 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/80c857e914d8e7b9b6579041c7a4d1f3fbc515f0faf149f359585e0f6b41d128/python/typeshed/issues/11264 |
| og:image:alt | Hi. I would like to propose that a dictionary accepts a mapping to the or operation. Something like: class dict(MutableMapping[_KT, _VT]): ... @overload def __or__(self, __value: Mapping[_KT, _VT])... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jzazo |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4eb4cba0d69f045374ac15de9666d22b0961e1d555cc3824f36b7734c00c78e0 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/typeshed git https://github.com/python/typeshed.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 31696383 |
| octolytics-dimension-repository_nwo | python/typeshed |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 31696383 |
| octolytics-dimension-repository_network_root_nwo | python/typeshed |
| 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 | 44c658b24abf00491fb7ae5f56d42c9f38cbeab2 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width