File size: 189 Bytes
c19ca42
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
from typing import Type, TypeVar

T = TypeVar("T")


def checked_cast(t: Type[T], value) -> T:
    assert isinstance(value, t), f"Value is {type(value)}, must be type {t}"
    return value