Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pyright should narrow except* to ExceptionGroup with non-base exceptions #9466

Closed
erictraut opened this issue Nov 14, 2024 · 1 comment
Closed
Labels
addressed in next version Issue is fixed and will appear in next published version enhancement request New feature or request

Comments

@erictraut
Copy link
Collaborator

Discussed in #9455

Originally posted by jakkdl November 13, 2024
It was changed from ExceptionGroup to BaseExceptionGroup in microsoft/pylance-release#4183
Related typeshed issue python/typeshed#12972

I'm not 100% if the typeshed issue will resolve except* handling in pyright, in case it would then we can directly resolve/close this. But in case it's hard-coded to always be BaseExceptionGroup and won't be changed by typeshed messing with __new__ then you might want to fix it right away.

repro:

from typing import reveal_type
try:
    raise ExceptionGroup("", [ValueError()])
except* ValueError as e:
    reveal_type(e)
$ python repro.py
Runtime type is 'ExceptionGroup'
$ pyright repro.py
  repro.py:5:17 - information: Type of "e" is "BaseExceptionGroup[ValueError]"
0 errors, 0 warnings, 1 information 
```</div>
@erictraut erictraut added the enhancement request New feature or request label Nov 14, 2024
erictraut added a commit that referenced this issue Nov 14, 2024
…e runtime. If a non-base exception is targeted, the inferred type is now `ExceptionGroup` rather than `BaseExceptionGroup`. This addresses #9466.
erictraut added a commit that referenced this issue Nov 14, 2024
…e runtime. If a non-base exception is targeted, the inferred type is now `ExceptionGroup` rather than `BaseExceptionGroup`. This addresses #9466. (#9467)
@erictraut erictraut added the addressed in next version Issue is fixed and will appear in next published version label Nov 14, 2024
@erictraut
Copy link
Collaborator Author

This is addressed in pyright 1.1.390.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addressed in next version Issue is fixed and will appear in next published version enhancement request New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant