# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/04_prot.ipynb.

# %% auto 0
__all__ = ['Proto', 'Alias', 'Not', 'Opt']

# %% ../nbs/04_prot.ipynb 6
import os, inspect
from functools import wraps

# %% ../nbs/04_prot.ipynb 8
from typing import (
    Any, Set, Dict, List, Self, Tuple, Union, ClassVar, Generic,
    Literal, _LiteralGenericAlias, 
    Callable, Iterable, Optional, 
    Protocol, _ProtocolMeta,
    get_args, get_origin, runtime_checkable, 
    Type, TypeVar, TypeAlias, TypeGuard,  ParamSpec,
)


from types import NoneType 

# %% ../nbs/04_prot.ipynb 10
#| export


# %% ../nbs/04_prot.ipynb 12
#| export


# %% ../nbs/04_prot.ipynb 14
from .type import (T, P, Types, TypeLike, Guard, GuardFunc, StrFactory, StrBool)
from ptyp.util import (
    args2strs, typescsv, typesusv,
    guardtype,
    guardname, guarddocs, guardanns, setguardattrs,
    classname, qualname, settypes
)

from ptyp.grds import (
    guard,
    tset, tlist, tdict, ttype, ttuple, tunion, tliteral, tgeneric, tclassvar,
    eqtype, eqlist, eqtuple, equnion, eqliteral,
    isstrbytes, notstrbytes, isstrq, notiterstr, allsame,
    aliascheck
)

from ptyp.meta import (
    ProtocolBaseMeta, ProtocolMeta, AliasMeta, NotMeta, OptionalMeta
)

# %% ../nbs/04_prot.ipynb 16
@runtime_checkable
class Proto(Protocol, metaclass=ProtocolMeta):
    @classmethod
    def __init_subclass__(cls, *args, types: Types = tuple(), attrs: dict = dict(), **kwargs) -> None:
        super().__init_subclass__()
        kwds = cls.default_kwds(**attrs)
        cls.settypes(*types, **kwds)
        cls.setattrs(attrs)

@runtime_checkable
class Alias(Protocol, metaclass=AliasMeta):
    @classmethod
    def __init_subclass__(cls, *args, types: Types = tuple(), attrs: dict = dict(), **kwargs) -> None:
        super().__init_subclass__()
        kwds = cls.default_kwds(**attrs)
        cls.settypes(*types, **kwds)
        cls.setattrs(attrs)

@runtime_checkable
class Not(Protocol, metaclass=NotMeta):
    @classmethod
    def __init_subclass__(cls, *args, types: Types = tuple(), attrs: dict = dict(), **kwargs) -> None:
        super().__init_subclass__()
        kwds = cls.default_kwds(**attrs)
        cls.settypes(*types, **kwds)
        cls.setattrs(attrs)


@runtime_checkable
class Opt(Protocol, metaclass=OptionalMeta):
    @classmethod
    def __init_subclass__(cls, *args, types: Types = tuple(), attrs: dict = dict(), **kwargs) -> None:
        super().__init_subclass__()
        kwds = cls.default_kwds(**attrs)
        cls.settypes(*types, **kwds)
        cls.setattrs(attrs)
