mirror of
https://github.com/astral-sh/ruff.git
synced 2025-08-03 18:28:24 +00:00
[ty] Fix more generics-related TODOs (#18062)
This commit is contained in:
parent
8104b1e83b
commit
0590b38214
3 changed files with 39 additions and 21 deletions
|
@ -22,9 +22,7 @@ except* BaseException as e:
|
|||
try:
|
||||
help()
|
||||
except* OSError as e:
|
||||
# TODO: more precise would be `ExceptionGroup[OSError]` --Alex
|
||||
# (needs homogeneous tuples + generics)
|
||||
reveal_type(e) # revealed: BaseExceptionGroup[BaseException]
|
||||
reveal_type(e) # revealed: ExceptionGroup[OSError]
|
||||
```
|
||||
|
||||
## `except*` with multiple exceptions
|
||||
|
@ -33,9 +31,7 @@ except* OSError as e:
|
|||
try:
|
||||
help()
|
||||
except* (TypeError, AttributeError) as e:
|
||||
# TODO: more precise would be `ExceptionGroup[TypeError | AttributeError]` --Alex
|
||||
# (needs homogeneous tuples + generics)
|
||||
reveal_type(e) # revealed: BaseExceptionGroup[BaseException]
|
||||
reveal_type(e) # revealed: ExceptionGroup[TypeError | AttributeError]
|
||||
```
|
||||
|
||||
## `except*` with mix of `Exception`s and `BaseException`s
|
||||
|
@ -44,8 +40,7 @@ except* (TypeError, AttributeError) as e:
|
|||
try:
|
||||
help()
|
||||
except* (KeyboardInterrupt, AttributeError) as e:
|
||||
# TODO: more precise would be `BaseExceptionGroup[KeyboardInterrupt | AttributeError]` --Alex
|
||||
reveal_type(e) # revealed: BaseExceptionGroup[BaseException]
|
||||
reveal_type(e) # revealed: BaseExceptionGroup[KeyboardInterrupt | AttributeError]
|
||||
```
|
||||
|
||||
## Invalid `except*` handlers
|
||||
|
@ -54,10 +49,10 @@ except* (KeyboardInterrupt, AttributeError) as e:
|
|||
try:
|
||||
help()
|
||||
except* 3 as e: # error: [invalid-exception-caught]
|
||||
reveal_type(e) # revealed: BaseExceptionGroup[BaseException]
|
||||
reveal_type(e) # revealed: BaseExceptionGroup[Unknown]
|
||||
|
||||
try:
|
||||
help()
|
||||
except* (AttributeError, 42) as e: # error: [invalid-exception-caught]
|
||||
reveal_type(e) # revealed: BaseExceptionGroup[BaseException]
|
||||
reveal_type(e) # revealed: BaseExceptionGroup[AttributeError | Unknown]
|
||||
```
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue