René's URL Explorer Experiment


Title: [question] Proper way to implement `ExceptionGroup.derive` method with the existing overloads? · Issue #9922 · python/typeshed · GitHub

Open Graph Title: [question] Proper way to implement `ExceptionGroup.derive` method with the existing overloads? · Issue #9922 · python/typeshed

X Title: [question] Proper way to implement `ExceptionGroup.derive` method with the existing overloads? · Issue #9922 · python/typeshed

Description: Good afternoon, I was working to implement some custom exception groups in an application that I work on and have had a really hard time getting the types for the derive function to work correctly. Based on reading the documentation link...

Open Graph Description: Good afternoon, I was working to implement some custom exception groups in an application that I work on and have had a really hard time getting the types for the derive function to work correctly....

X Description: Good afternoon, I was working to implement some custom exception groups in an application that I work on and have had a really hard time getting the types for the derive function to work correctly....

Opengraph URL: https://github.com/python/typeshed/issues/9922

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"[question] Proper way to implement `ExceptionGroup.derive` method with the existing overloads?","articleBody":"Good afternoon,\r\n\r\nI was working to implement some custom exception groups in an application that I work on and have had a really hard time getting the types for the `derive` function to work correctly. Based on reading the documentation linked below, `derive` is a required method when overriding an exception group to return an instance of it's own class.\r\n\r\n## Reference\r\nhttps://docs.python.org/3/library/exceptions.html#BaseExceptionGroup.derive\r\n\r\n## Reproduction / Example\r\nTo reproduce this error, I'll use the example shows in the BaseExceptionGroup page, but with type hints:\r\n\r\n```python\r\nfrom __future__ import annotations\r\n\r\nfrom collections.abc import Sequence\r\nfrom typing import TypeVar\r\n\r\n_ExceptionT_co = TypeVar(\"_ExceptionT_co\", bound=Exception, covariant=True)\r\n_ExceptionT = TypeVar(\"_ExceptionT\", bound=Exception)\r\n\r\n\r\nclass MyGroup(ExceptionGroup[_ExceptionT_co]):\r\n    def derive(self, excs: Sequence[_ExceptionT]) -> MyGroup[_ExceptionT]:\r\n        return MyGroup(self.message, excs)\r\n```\r\n\r\nMypy output:\r\n\r\n```\r\n❯ mypy ~/Desktop/example.py\r\n/Users/kkirsche/Desktop/example.py:11: error: Signature of \"derive\" incompatible with supertype \"BaseExceptionGroup\"  [override]\r\n/Users/kkirsche/Desktop/example.py:11: note:      Superclass:\r\n/Users/kkirsche/Desktop/example.py:11: note:          @overload\r\n/Users/kkirsche/Desktop/example.py:11: note:          def [_ExceptionT \u003c: Exception] derive(self, Sequence[_ExceptionT], /) -> ExceptionGroup[_ExceptionT]\r\n/Users/kkirsche/Desktop/example.py:11: note:          @overload\r\n/Users/kkirsche/Desktop/example.py:11: note:          def [_BaseExceptionT \u003c: BaseException] derive(self, Sequence[_BaseExceptionT], /) -> BaseExceptionGroup[_BaseExceptionT]\r\n/Users/kkirsche/Desktop/example.py:11: note:      Subclass:\r\n/Users/kkirsche/Desktop/example.py:11: note:          def [_ExceptionT \u003c: Exception] derive(self, excs: Sequence[_ExceptionT]) -> MyGroup[_ExceptionT]\r\nFound 1 error in 1 file (checked 1 source file)\r\n```\r\n\r\nGiven that this is working off an exception group rather than a base exception  group, I'm unclear on what the proper way to fix this would be and was wondering if the team here was able to provide an example that satisfies mypy / typeshed's overrides for `BaseExceptionGroup`'s `derive` function.\r\n\r\n## Thoughts\r\n\r\nWould it potentially make sense to add a derive method to `ExceptionGroup` which returns `Self` rather than a hardcoded `ExceptionGroup`? This seems to align with how the documentation describes using this behavior, but I'm not confident I understand fully to submit a pull request with recommended change(s).\r\n\r\nThanks for your time and help, hope you all are having a great day.","author":{"url":"https://github.com/kkirsche","@type":"Person","name":"kkirsche"},"datePublished":"2023-03-22T17:54:38Z","url":"https://github.com/python/typeshed/issues/9922"}

react-profiling0
react-import-mapreact,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-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:05410c06-06a2-a678-72f0-9f27a2c5e2ba
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idC738:3A13A0:23E3506:30B3CBE:6B002F6B
html-safe-nonce95fdb8e352f49922e301510074a92d9c7aa117a4c99bc8296e7a351f907cf93a
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDNzM4OjNBMTNBMDoyM0UzNTA2OjMwQjNDQkU6NkIwMDJGNkIiLCJ2aXNpdG9yX2lkIjoiNTYwMzcxNjM2NjI5NDA2OTA5OSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9
visitor-hmacfda7f9959d1a762f873d0a6a2663441374f2e351075596d901cd328ac967f7ea
hovercard-subject-tagissue:1636244902
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/typeshed/9922/issue_layout
twitter:imagehttps://opengraph.githubassets.com/eb85efb3e877f795843cf6b8cf97107c7e348577a86da82b3acabafc5f0658cd/python/typeshed/issues/9922
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/eb85efb3e877f795843cf6b8cf97107c7e348577a86da82b3acabafc5f0658cd/python/typeshed/issues/9922
og:image:altGood afternoon, I was working to implement some custom exception groups in an application that I work on and have had a really hard time getting the types for the derive function to work correctly....
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamekkirsche
hostnamegithub.com
expected-hostnamegithub.com
None7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0
turbo-cache-controlno-preview
go-importgithub.com/python/typeshed git https://github.com/python/typeshed.git
octolytics-dimension-user_id1525981
octolytics-dimension-user_loginpython
octolytics-dimension-repository_id31696383
octolytics-dimension-repository_nwopython/typeshed
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id31696383
octolytics-dimension-repository_network_root_nwopython/typeshed
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releasef3f3a43ca095cdea3abbb394112e971f9fdb94fa
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/python/typeshed/issues/9922#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Ftypeshed%2Fissues%2F9922
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fpython%2Ftypeshed%2Fissues%2F9922
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=python%2Ftypeshed
Reloadhttps://github.com/python/typeshed/issues/9922
Reloadhttps://github.com/python/typeshed/issues/9922
Reloadhttps://github.com/python/typeshed/issues/9922
pythonhttps://github.com/python
typeshedhttps://github.com/python/typeshed
Codehttps://github.com/python/typeshed
Issues196 (196)https://github.com/python/typeshed/issues
Pull requests251 (251)https://github.com/python/typeshed/pulls
Actionshttps://github.com/python/typeshed/actions
Security and qualityhttps://github.com/python/typeshed/security
Insightshttps://github.com/python/typeshed/insights
https://github.com/python/typeshed
New issuehttps://github.com/login?return_to=https://github.com/python/typeshed/issues/9922
New issuehttps://github.com/login?return_to=https://github.com/python/typeshed/issues/9922
[question] Proper way to implement ExceptionGroup.derive method with the existing overloads?https://github.com/python/typeshed/issues/9922#top
https://github.com/kkirsche
kkirschehttps://github.com/kkirsche
on Mar 22, 2023https://github.com/python/typeshed/issues/9922#issue-1636244902
https://docs.python.org/3/library/exceptions.html#BaseExceptionGroup.derivehttps://docs.python.org/3/library/exceptions.html#BaseExceptionGroup.derive
AlexWaygoodhttps://github.com/AlexWaygood
questionhttps://github.com/python/typeshed/issues?q=state%3Aopen%20label%3A%22question%22
on Mar 22, 2023https://github.com/python/typeshed/issues/9922#event-8820099109
https://github.com/AlexWaygood
AlexWaygoodhttps://github.com/AlexWaygood
on Mar 22, 2023https://github.com/python/typeshed/issues/9922#issuecomment-1480292428
@sobolevnhttps://github.com/sobolevn
https://github.com/sobolevn
sobolevnhttps://github.com/sobolevn
on Mar 26, 2023https://github.com/python/typeshed/issues/9922#issuecomment-1484037267
https://github.com/kkirsche
kkirschehttps://github.com/kkirsche
on Mar 26, 2023https://github.com/python/typeshed/issues/9922#issuecomment-1484050472
https://docs.python.org/3/library/exceptions.html#BaseExceptionGroup.derivehttps://docs.python.org/3/library/exceptions.html#BaseExceptionGroup.derive
https://github.com/sobolevn
sobolevnhttps://github.com/sobolevn
on Mar 26, 2023https://github.com/python/typeshed/issues/9922#issuecomment-1484067706
https://github.com/kkirsche
kkirschehttps://github.com/kkirsche
on Mar 26, 2023https://github.com/python/typeshed/issues/9922#issuecomment-1484156069
https://github.com/sobolevn
sobolevnhttps://github.com/sobolevn
on Mar 27, 2023https://github.com/python/typeshed/issues/9922#issuecomment-1484745975
https://github.com/kkirsche
kkirschehttps://github.com/kkirsche
on Mar 28, 2023https://github.com/python/typeshed/issues/9922#issuecomment-1486962742
ExceptionGrouphttps://github.com/python/typeshed/blob/main/stdlib/builtins.pyi#L2053
BaseExceptionGrouphttps://github.com/python/typeshed/blob/main/stdlib/builtins.pyi#L2015
https://github.com/PIG208
PIG208https://github.com/PIG208
on Aug 4, 2023https://github.com/python/typeshed/issues/9922#issuecomment-1666015748
AlexWaygoodhttps://github.com/AlexWaygood
on Aug 4, 2023https://github.com/python/typeshed/issues/9922#event-10012064368
srittauhttps://github.com/srittau
questionhttps://github.com/python/typeshed/issues?q=state%3Aopen%20label%3A%22question%22
on Mar 23, 2024https://github.com/python/typeshed/issues/9922#event-12224201222
Sign up for freehttps://github.com/signup?return_to=https://github.com/python/typeshed/issues/9922
Sign in to commenthttps://github.com/login?return_to=https://github.com/python/typeshed/issues/9922
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.