-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Fix typings of ExceptionGroup and BaseExceptionGroup
#9230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Ok, pyright has only 10 problems: I will add a version guard later on. |
This comment has been minimized.
This comment has been minimized.
|
Looks like we need some other solution for unused |
This comment has been minimized.
This comment has been minimized.
|
|
||
| # `BaseExceptionGroup` can work with `Exception`: | ||
| beg2 = BaseExceptionGroup("x", [ValueError()]) | ||
| # FIXME: this is not right, runtime returns `ExceptionGroup` instance instead, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be doable by overriding __new__ (python/mypy#7188), did you try that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have three cases:
BaseExceptionGroup.__new__can returnBaseExceptionGroupfor_BaseExceptionT_coBaseExceptionGroup.__new__can returnExceptionGroupfor_ExceptionT_coBaseExceptionGroup.__new__can return custom subclass
Either the first two work or the third one. Suggestions are welcome
|
I have an idea for how to fix the test cases on mypy; I'll get to work on a fix. For flake8: would an alternative fix be to have |
This comment has been minimized.
This comment has been minimized.
|
@AlexWaygood, thank you, flake8 idea worked! |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
|
Hooray, CI is finally green 🎉 |
|
I really hope this is correct now! Ping me in case of any problems. |
There are a lot of things going on in this PR:
Selftype, because of howCimplementation workssplitandsubgrouprequireSelfargument to be in callable, because of howCimplementation worksBaseExceptionGroupto and fromExceptionGroupare supported. But not all of themThis is a very complex PR. I would love to provide any of my help to the reviewers.