Files
exo/shared/utils.py
Arbion Halili e1894bc106 refactor: A Lot
2025-07-07 20:19:08 +01:00

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