# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/03_guards.ipynb.

# %% auto 0
__all__ = ['Guarded', 'guard_type']

# %% ../nbs/03_guards.ipynb 4
from typing import Any, Optional
from typing import Type, TypeVar, TypeGuard

# %% ../nbs/03_guards.ipynb 6
Guarded = TypeVar("Guarded")

def guard_type(
    instance: Any, cls: Type[Guarded], message: Optional[str] = None
) -> TypeGuard[Guarded]:  
    message = message or f"instance={instance!r}, cls={cls!r}"
    assert isinstance(instance, cls), message
    return True
