Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

add (Base)ExceptionGroup#6655

Merged
JelleZijlstra merged 2 commits into
python:masterpython/typeshed:masterfrom
JelleZijlstra:pep654JelleZijlstra/typeshed:pep654Copy head branch name to clipboard
Dec 22, 2021
Merged

add (Base)ExceptionGroup#6655
JelleZijlstra merged 2 commits into
python:masterpython/typeshed:masterfrom
JelleZijlstra:pep654JelleZijlstra/typeshed:pep654Copy head branch name to clipboard

Conversation

@JelleZijlstra

Copy link
Copy Markdown
Member

Fixes #6632

@github-actions

This comment has been minimized.

@srittau srittau left a comment

Copy link
Copy Markdown
Collaborator

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.

Comment thread stdlib/builtins.pyi Outdated
Co-authored-by: Sebastian Rittau <srittau@rittau.biz>
@github-actions

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member Author

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

@agronholm

Copy link
Copy Markdown
Contributor

Done: #6895

@agronholm

Copy link
Copy Markdown
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

Morty Proxy This is a proxified and sanitized view of the page, visit original site.