Default type for built-in ExceptionGroup
Hi,
I've ran into this issue with pyright: Input:
def a() -> None:
ex: ExceptionGroup[ValueError] = ExceptionGroup("", [ValueError("a"), ValueError("b")])
raise ex
try:
a()
except ExceptionGroup as e:
print(all(isinstance(exc, ValueError) for exc in e.exceptions))
pyright error:
test.py:8:26 - error: Type of "e" is partially unknown
Type of "e" is "ExceptionGroup[Unknown]" (reportUnknownVariableType)
After talking to @erictraut, he directed me here to propose the built-in ExceptionGroup to have Exeception has a default type.
Here is the pyright discussion.
Here are his quotes:
With PEP 696 now officially accepted, the maintainers of typeshed could specify that the type parameter for
ExceptionGroupdefaults toException. In that case, pyright will no longer assumeUnknownin this case. If that sounds like a good solution, please file a request (or submit a PR) in the typeshed project.
and
The change would involve a change to this line.
I'm not sure on how to make the changes my self and I don't even know if they should be made at all.
Thanks a lot!