-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Fix typings of ExceptionGroup
and BaseExceptionGroup
#9230
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # 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 returnBaseExceptionGroup
for_BaseExceptionT_co
BaseExceptionGroup.__new__
can returnExceptionGroup
for_ExceptionT_co
BaseExceptionGroup.__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:
Self
type, because of howC
implementation workssplit
andsubgroup
requireSelf
argument to be in callable, because of howC
implementation worksBaseExceptionGroup
to and fromExceptionGroup
are supported. But not all of themThis is a very complex PR. I would love to provide any of my help to the reviewers.