Title: Return types for `(Base)ExceptionGroup.derive()`, `.subgroup()`, and `.split()` should not use `Self` · Issue #9219 · python/typeshed · GitHub
Open Graph Title: Return types for `(Base)ExceptionGroup.derive()`, `.subgroup()`, and `.split()` should not use `Self` · Issue #9219 · python/typeshed
X Title: Return types for `(Base)ExceptionGroup.derive()`, `.subgroup()`, and `.split()` should not use `Self` · Issue #9219 · python/typeshed
Description: In the following stubs, each use of Self in a return type is incorrect: typeshed/stdlib/builtins.pyi Lines 1947 to 1959 in c626137 @overload def subgroup( self, __condition: type[_BaseExceptionT] | tuple[type[_BaseExceptionT], ...] ) -> ...
Open Graph Description: In the following stubs, each use of Self in a return type is incorrect: typeshed/stdlib/builtins.pyi Lines 1947 to 1959 in c626137 @overload def subgroup( self, __condition: type[_BaseExceptionT] |...
X Description: In the following stubs, each use of Self in a return type is incorrect: typeshed/stdlib/builtins.pyi Lines 1947 to 1959 in c626137 @overload def subgroup( self, __condition: type[_BaseExceptionT] |...
Opengraph URL: https://github.com/python/typeshed/issues/9219
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Return types for `(Base)ExceptionGroup.derive()`, `.subgroup()`, and `.split()` should not use `Self`","articleBody":"In the following stubs, each use of `Self` in a return type is incorrect:\r\n\r\nhttps://github.com/python/typeshed/blob/c6261372d7a43c71600de07ecfdf0692f74d6d85/stdlib/builtins.pyi#L1947-L1959\r\n\r\nThis is because [`.derive()` must be manually overridden to return custom subtypes](https://docs.python.org/3/library/exceptions.html#BaseExceptionGroup.derive), in which case the child class should *also* manually update the type annotations on `.subgroup()` and `.split()`[^1]. For example:\r\n\r\n```python\r\nclass MyGroup(ExceptionGroup):\r\n pass\r\n\r\nexcs = [Exception(\"oops\")]\r\nmg = MyGroup(\"msg\", excs)\r\nassert type(mg.derive(excs)) == ExceptionGroup # *not* the Self type!\r\n```\r\n\r\n[^1]: since I don't know of a way to express \"that other method's return-type\" in an annotation\r\n\r\nDiscovered via https://github.com/agronholm/exceptiongroup/pull/40#discussion_r1024633541; if accepted here we should make sure to fix the backport too.","author":{"url":"https://github.com/Zac-HD","@type":"Person","name":"Zac-HD"},"datePublished":"2022-11-17T00:48:52Z","url":"https://github.com/python/typeshed/issues/9219"}
| 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:dddca912-e892-e4e7-7ec2-63eb6280b9e1 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8898:1DA187:30DD8AF:409F8AC:6B002BD0 |
| html-safe-nonce | 7e9e65026e32459cae2d7438a109a44f169a320aef1103dfa7bf5afaa6f58b11 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4ODk4OjFEQTE4NzozMEREOEFGOjQwOUY4QUM6NkIwMDJCRDAiLCJ2aXNpdG9yX2lkIjoiMjA5NDM3OTQyODYwNjkxMzQ4OCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 79a570d7afa78dcb943c8db729bf64f736b0939b8da605956c4511cf4fc4567f |
| hovercard-subject-tag | issue:1452513763 |
| 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/9219/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e9380070a0f133e94c10a976b75a1b36fc9c72ce3504c701eadb45246cb41dc9/python/typeshed/issues/9219 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e9380070a0f133e94c10a976b75a1b36fc9c72ce3504c701eadb45246cb41dc9/python/typeshed/issues/9219 |
| og:image:alt | In the following stubs, each use of Self in a return type is incorrect: typeshed/stdlib/builtins.pyi Lines 1947 to 1959 in c626137 @overload def subgroup( self, __condition: type[_BaseExceptionT] |... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Zac-HD |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| 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 | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width