typing.TypeGuard
In short, the form def foo(arg: TypeA) -> TypeGuard[TypeB]: ..., means that if foo(arg) returns True, then arg narrows from TypeA to TypeB.
Using -> TypeGuard tells the static type checker that for a given function:
The return value is a boolean.
If the return value is True, the type of its argument is the type inside TypeGuard.
TypeIs requires the narrowed type to be a subtype of the input type, while TypeGuard does not.
「TypeIsは狭められた型(入力した型のサブタイプ)を必要とするが、TypeGuardは必要としない」
ぱっと理解するのにオススメ