o
    㥵is                     @  s   d dl mZ d dlZd dlmZ d dlmZmZmZm	Z	m
Z
mZ d dlmZ ededZd!ddZd"ddZd#ddZd$ddZd%ddZd&dd ZdS )'    )annotationsN)Path)AnyAsyncGenerator	AwaitableCallable	GeneratorTypeVar)	TypeGuard
_ClassType)bound__clsr   __classreturnTypeGuard[_ClassType]c                 C  s   t | to	t| |S )N)
isinstancetype
issubclass)r   r    r   E/home/ubuntu/.local/lib/python3.10/site-packages/kui/utils/inspect.pysafe_issubclass   s   r   callr   #TypeGuard[Callable[..., Awaitable]]c                 C  s4   t | r
t | S t | rdS t t| dd S )NF__call__)inspect	isroutineiscoroutinefunctionisclassgetattrr   r   r   r   is_coroutine_callable   s
   


r    (TypeGuard[Callable[..., AsyncGenerator]]c                 C      t | rdS t t| dd S NTr   )r   isasyncgenfunctionr   r   r   r   r   is_async_gen_callable      
r%   #TypeGuard[Callable[..., Generator]]c                 C  r"   r#   )r   isgeneratorfunctionr   r   r   r   r   is_gen_callable   r&   r)   handlerc                 C  sd   t | ds
t | dr0| }t | dr| j}nt | dr| j}|| u r$	 | S |} t | ds
t | ds
| S )z$
    Get handler's raw handler.
    __wrapped____raw_handler__)hasattrr+   r,   )r*   new_handlerr   r   r   get_raw_handler$   s   

r/   objectstrc                 C  sL   t t|  }zd|t    }W |S  ty%   | }Y |S w )z 
    Get object's filepath.
    z./)r   r   getfileabsoluterelative_tocwdas_posix
ValueError)r0   pathfilepathr   r   r   get_object_filepath8   s   
r:   )r   r   r   r   r   r   )r   r   r   r   )r   r   r   r!   )r   r   r   r'   )r*   r   r   r   )r0   r   r   r1   )
__future__r   r   pathlibr   typingr   r   r   r   r   r	   typing_extensionsr
   r   r   r   r    r%   r)   r/   r:   r   r   r   r   <module>   s     




