Title: unpack dataclasses/types or subsets of them to act as typed dict · Issue #12906 · python/mypy · GitHub
Open Graph Title: unpack dataclasses/types or subsets of them to act as typed dict · Issue #12906 · python/mypy
X Title: unpack dataclasses/types or subsets of them to act as typed dict · Issue #12906 · python/mypy
Description: Feature often times helper methods take all the fields or subsets of the fields of a type/dataclass in coordination with #4441 @dataclass class MyModel: id: uuid name: str hostname: str memory_size: int and i want to declare helpers like...
Open Graph Description: Feature often times helper methods take all the fields or subsets of the fields of a type/dataclass in coordination with #4441 @dataclass class MyModel: id: uuid name: str hostname: str memory_size...
X Description: Feature often times helper methods take all the fields or subsets of the fields of a type/dataclass in coordination with #4441 @dataclass class MyModel: id: uuid name: str hostname: str memory_size...
Opengraph URL: https://github.com/python/mypy/issues/12906
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"unpack dataclasses/types or subsets of them to act as typed dict ","articleBody":"**Feature**\r\n\r\noften times helper methods take all the fields or subsets of the fields of a type/dataclass\r\n\r\nin coordination with #4441 \r\n\r\n```python\r\n@dataclass\r\nclass MyModel:\r\n id: uuid\r\n name: str\r\n hostname: str\r\n memory_size: int\r\n```\r\n\r\nand i want to declare helpers like\r\n\r\n```python\r\n# bad names\r\nMagic = SubsetTypedDict(MyModel, exclude=[\"id\"], total=False)\r\n\r\ndef wait_for_update(model_or_id: Model|uuid, **kw: Magic) -> Model:\r\n ...\r\n```\r\n\r\n\r\n** context **\r\n\r\nspin out of #4441, based on [my comment](https://github.com/python/mypy/issues/4441#issuecomment-1110894776) and [the suggestion in](https://github.com/python/mypy/issues/4441#issuecomment-1140563711)\r\n\r\n","author":{"url":"https://github.com/RonnyPfannschmidt","@type":"Person","name":"RonnyPfannschmidt"},"datePublished":"2022-05-30T07:02:57Z","url":"https://github.com/python/mypy/issues/12906"}
| 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:a26107b7-76f7-e2a4-c275-b281730f366f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BAF0:B7CF9:EC04F4:13B808D:6B005729 |
| html-safe-nonce | 7e48f48904d5db40b1998f57fdb89d61dc54e9188834ca4b78b98b6685d2dfe2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCQUYwOkI3Q0Y5OkVDMDRGNDoxM0I4MDhEOjZCMDA1NzI5IiwidmlzaXRvcl9pZCI6IjYyMDIwNTMwNzA2NjMyMTA3OTMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d8d36aed6fb74d4884b4c5adec86d8fa6791013b5d8b20d9c8cae00f903b04b0 |
| hovercard-subject-tag | issue:1252286102 |
| 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/12906/issue_layout |
| twitter:image | https://opengraph.githubassets.com/78c810e84fa29542cf6d9dddd010a1c12c96a8cc57ed002ee759481c4f310cb5/python/mypy/issues/12906 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/78c810e84fa29542cf6d9dddd010a1c12c96a8cc57ed002ee759481c4f310cb5/python/mypy/issues/12906 |
| og:image:alt | Feature often times helper methods take all the fields or subsets of the fields of a type/dataclass in coordination with #4441 @dataclass class MyModel: id: uuid name: str hostname: str memory_size... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | RonnyPfannschmidt |
| hostname | github.com |
| expected-hostname | github.com |
| None | f420f4996e6b1ff1ccd6d7683f8134f4b5f0f8a50124c210dbfe7490e5644abb |
| 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 | 26e00df917aba0f128135dc073ea0c5e33a70d40 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width