mirror of
https://github.com/astral-sh/ruff.git
synced 2025-11-25 22:29:02 +00:00
[ty]: Consider a class with a dynamic element in its MRO assignable to any subtype of type (#18205)
This commit is contained in:
parent
4fad15805b
commit
fb589730ef
4 changed files with 54 additions and 0 deletions
|
|
@ -62,6 +62,20 @@ def foo(
|
|||
reveal_type(i) # revealed: BaseException
|
||||
```
|
||||
|
||||
We do not emit an `invalid-exception-caught` if a class is caught that has `Any` or `Unknown` in its
|
||||
MRO, as the dynamic element in the MRO could materialize to some subclass of `BaseException`:
|
||||
|
||||
```py
|
||||
from compat import BASE_EXCEPTION_CLASS # error: [unresolved-import] "Cannot resolve imported module `compat`"
|
||||
|
||||
class Error(BASE_EXCEPTION_CLASS): ...
|
||||
|
||||
try:
|
||||
...
|
||||
except Error as err:
|
||||
...
|
||||
```
|
||||
|
||||
## Invalid exception handlers
|
||||
|
||||
```py
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue