Skip to content

BaseExceptionGroup should return ExceptionGroup if initialized with non-base exceptions #12972

Open
@jakkdl

Description

@jakkdl

When initializing a BaseExceptionGroup with non-base exceptions the stdlib (and the backport) will in fact return an ExceptionGroup. The typing in neither of typeshed nor the backport currently supports this.

from typing_extensions import reveal_type

x = BaseExceptionGroup('', [ValueError()])
reveal_type(x)
$ python foo.py
Runtime type is 'ExceptionGroup'
$ mypy foo.py 
foo.py:30: note: Revealed type is "builtins.BaseExceptionGroup[builtins.ValueError]"
$ pyright foo.py 
foo.py
  foo.py:30:13 - information: Type of "x" is "BaseExceptionGroup[ValueError]"

I have vague recollections that trying to do this was hard-to-impossible, but I currently cannot find any related issues.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions