BaseExceptionGroup should return ExceptionGroup if initialized with non-base exceptions
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.1k
- Forks
- 2.1k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 82
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the BaseExceptionGroup definitions in typeshed and the backport, then compare their constructor typing with the runtime behavior shown in the issue. Check the examples with mypy and pyright; done means both type checkers can infer ExceptionGroup[ValueError] when only non-base exceptions are passed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100