trycast icon indicating copy to clipboard operation
trycast copied to clipboard

Use TypeIs instead of TypeGuard

Open davidfstr opened this issue 2 months ago • 0 comments

The isassignable API is currently:

def isassignable(
    value: object,
    tp: TypeForm[T]† | TypeFormString[T]‡,
    /, *, eval: bool = True
) -> TypeGuard[T]: ...

Alter it to return a TypeIs[T] instead, so that type narrowing happens as expected in the negative case, when isassignable returns False.

This change could potentially break API users, so should be marked as a major/breaking change.

davidfstr avatar Dec 09 '25 13:12 davidfstr