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.
ぱっと理解するのにオススメ