mirror of
https://github.com/exo-explore/exo.git
synced 2026-02-07 12:43:52 -05:00
Co-authored-by: Alex Cheema <alexcheema123@gmail.com> Co-authored-by: Seth Howes <sethshowes@gmail.com> Co-authored-by: Matt Beton <matthew.beton@gmail.com> Co-authored-by: Andrei Cravtov <the.andrei.cravtov@gmail.com>
10 lines
274 B
Python
10 lines
274 B
Python
from typing import Any, Type, TypeVar
|
|
|
|
T = TypeVar("T")
|
|
|
|
|
|
def ensure_type(obj: Any, expected_type: Type[T]) -> T: # type: ignore
|
|
if not isinstance(obj, expected_type):
|
|
raise TypeError(f"Expected {expected_type}, got {type(obj)}") # type: ignore
|
|
return obj
|