trycast() works beautifully at runtime. There's just one problem:
I can't actually spell the types in the function signature for trycast(...)!
You might think it would be:
T = TypeVar('T')
def trycast(type: Type[T], value: object) -> Optional[T]: ...