FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

add (Base)ExceptionGroup by JelleZijlstra · Pull Request #6655 · python/typeshed · GitHub

Repository navigation

add (Base)ExceptionGroup - #6655

Merged
JelleZijlstra merged 2 commits into
python:masterfrom
JelleZijlstra:pep654
Dec 22, 2021
Merged

JelleZijlstra merged 2 commits into
python:masterfrom
JelleZijlstra:pep654

Conversation

Copy link
Copy Markdown
Member

Fixes #6632

This comment has been minimized.

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.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

One question below, but LGTM.

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

Copy link
Copy Markdown
Contributor

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

JelleZijlstra merged commit b045381 into python:master Dec 22, 2021
JelleZijlstra deleted the pep654 branch December 22, 2021 15:56

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.

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.

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.

Copy link
Copy Markdown
Member Author

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

Copy link
Copy Markdown
Contributor

Done: #6895

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.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL