Skip to content

add (Base)ExceptionGroup #6655

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

Merged
merged 2 commits into from
Dec 22, 2021
Merged

add (Base)ExceptionGroup #6655

merged 2 commits into from
Dec 22, 2021

Conversation

JelleZijlstra
Copy link
Member

Fixes #6632

@github-actions

This comment has been minimized.

Copy link
Collaborator

@srittau srittau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One question below, but LGTM.

Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
@github-actions
Copy link
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@JelleZijlstra JelleZijlstra merged commit b045381 into python:master Dec 22, 2021
@JelleZijlstra JelleZijlstra deleted the pep654 branch December 22, 2021 15:56
@agronholm
Copy link
Contributor

A couple questions:

  1. Why is the second argument to ExceptionGroup named differently than that of BaseExceptionGroup? This definition makes it look like it could be passed as a keyword argument, which it can't be.
  2. Why is the return type of the exceptions property typed as a Sequence when it always returns a tuple, regardless of the type of the initial exceptions sequence?

I'm happy to submit a follow-up PR to fix these.

@JelleZijlstra
Copy link
Member Author

@agronholm good catch about the exceptions argument. They should both be positional-only.

I think I used Sequence because the PEP (https://www.python.org/dev/peps/pep-0654/#exceptiongroup-and-baseexceptiongroup) says it's a sequence, but you're right that we prefer concrete types like tuple in typeshed.

@agronholm
Copy link
Contributor

The PEP doesn't really define the exceptions property but it is mentioned there. The constructor argument __exceptions is correct here, as it can be any sequence, but the implementation turns it into a tuple in the getter of exceptions.

@JelleZijlstra
Copy link
Member Author

Yes, the summary is that you're right on both counts :) Feel free to submit a PR!

@agronholm
Copy link
Contributor

Done: #6895

@agronholm
Copy link
Contributor

I noticed another issue: BaseExceptionGroup and ExceptionGroup are actually generic, but this is not reflected in the stubs. Thankfully tuple is covariant so there is no conflict in the exceptions property. I'll send another PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add new builtin exception types from Python 3.11 - BaseExceptionGroup & ExceptionGroup
3 participants