1 2 3 4 5 6 7 8 9 10 11 12
from typing import Any, Type, TypeGuard, TypeVar from pydantic import BaseModel T = TypeVar("T", bound=BaseModel) def is_basemodel_subclass(model: Any) -> bool: try: return issubclass(model, BaseModel) except TypeError: return False