Closed rsokl closed 1 month ago
Pyright's behavior is correct here, so I don't consider this a bug. For comparison, mypy's behavior is the same.
The is_dataclass(x)
call uses TypeIs
, and it narrows the type to type[DataclassInstance]. The
not isinstance(x, type)call narrows this type to
Never`.
If you change the annotation for x
from Any
to object
, it will work as you intend.
Checking if object is an instance of a dataclass type leads to unreachable code
I think this regression started in 1.1.366