-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
addressed in next versionIssue is fixed and will appear in next published versionIssue is fixed and will appear in next published versionbugSomething isn't workingSomething isn't workingspec compliance
Description
Pyright does not currently perform proper subtyping checks for TypeIs and TypeGuard. In particular, it treats TypeIs[x] as equivalent to bool when performing subtyping checks. TypeIs[x] should be considered a subtype of bool, and TypeIs[x] should be considered a subtype of TypeIs[y] only if x is a subtype of y.
This can be demonstrated in this code, where the Any input to is_dataclass should cause the overload logic to resolve both overloads rather than the first.
import dataclasses
from typing import reveal_type
def func(x: Any) -> None:
if dataclasses.is_dataclass(x) and isinstance(x, object):
reveal_type(x)
print(dataclasses.asdict(x))This is related to this discussion.
Metadata
Metadata
Assignees
Labels
addressed in next versionIssue is fixed and will appear in next published versionIssue is fixed and will appear in next published versionbugSomething isn't workingSomething isn't workingspec compliance