INNER CODE UNIT · Python

_is_v2_model

phillipdupuis/pydantic-to-typescript · pydantic2ts/cli/script.py:89

def _is_v2_model(obj: Any) -> bool:
    """
    Return true if an object is a 'concrete' pydantic V2 model.
    """
    if not v2.enabled:
        return False
    elif not inspect.isclass(obj):
        return False
    elif obj is v2.BaseModel:
        return False
    elif not issubclass(obj, v2.BaseModel):
        return False
    generic_metadata = getattr(obj, "__pydantic_generic_metadata__", {})
    generic_parameters = generic_metadata.get("parameters")
    return not generic_parameters


def _is_pydantic_model(obj: Any) -> bool:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…