# AUTOGENERATED! DO NOT EDIT! File to edit: ../nbs/02_insp.ipynb.

# %% auto 0
__all__ = ['isp', 'isself', 'ispself', 'ispcls', 'isempty', 'ispempty', 'iskwonly', 'ispkwonly']

# %% ../nbs/02_insp.ipynb 4
from inspect import Parameter
from typing import Literal, TypeGuard

# %% ../nbs/02_insp.ipynb 7
def isp(p: Parameter) -> TypeGuard[Parameter]:
    '''Check if parameter is of type `Parameter`.'''
    return isinstance(p, Parameter)

# %% ../nbs/02_insp.ipynb 9
# NOTE: not sure if this is the same as `isinstance(x, Self)`
def isself(x) -> TypeGuard[Literal['self']]:
    '''Check if `x` is `"self"`.'''
    return x == 'self' 

# %% ../nbs/02_insp.ipynb 11
def ispself(p: Parameter) -> TypeGuard[Parameter]:
    '''Check if `p: Parameter` has `name = "self"`.'''
    return isp(p) and isself(p.name)

def ispcls(p: Parameter) -> TypeGuard[Parameter]:
    '''Check if `p: Parameter` has `name = "cls"`.'''
    return isp(p) and p.name == 'cls'

# %% ../nbs/02_insp.ipynb 13
def isempty(x) -> TypeGuard[Parameter.empty]:
    '''Check if `x` is `Parameter.empty`.'''
    return x == Parameter.empty

def ispempty(p: Parameter) -> TypeGuard[Parameter.empty]:
    '''Check if `p: Parameter` is of type `Parameter.empty`.'''
    return isp(p) and isempty(p.default)

# %% ../nbs/02_insp.ipynb 15
def iskwonly(x) -> TypeGuard[Parameter.KEYWORD_ONLY]:
    '''Check if `x` is `Parameter.KEYWORD_ONLY`.'''
    return x == Parameter.KEYWORD_ONLY

def ispkwonly(p: Parameter) -> TypeGuard[Parameter.KEYWORD_ONLY]:
    '''Check if `p: Parameter` is of type `Parameter.KEYWORD_ONLY`.'''
    return isp(p) and iskwonly(p.kind)
