o
    wiy                     @  sz   U d dl mZ d dlmZmZmZ ddlmZmZ er!ddl	m
Z
 edeg df f Zdaded	< dddZdddZdS )    )annotations)TYPE_CHECKINGUnionCallable   )ClientNotRegisteredErrorClientAlreadyRegisteredErrorPrismar
   NzRegisteredClient | None_registered_clientclientRegisteredClientreturnNonec                 C  sP   ddl m} tdurt t| |s$t| s$td| d| d|  d| adS )zRegister a client instance to be retrieved by `get_client()`

    This function _must_ only be called once, preferrably as soon as possible
    to avoid any potentially confusing errors with threads or processes.
    r   r	   NzExpected either a z' instance or a function that returns a z	 but got z	 instead.)r   r
   r   r   
isinstancecallable	TypeError)r   r
    r   G/home/app/Keep/.python/lib/python3.10/site-packages/prisma/_registry.pyregister   s   r   c                  C  sX   ddl m}  t}|du rt dt|| r|S | }t|| s*td| d|  d|S )zGet the registered client instance

    Raises errors.ClientNotRegisteredError() if no client instance has been registered.
    r   r	   NzRegistered function returned z instead of a z
 instance.)r   r
   r   r   r   r   )r
   
registeredr   r   r   r   
get_client$   s   

r   )r   r   r   r   )r   r
   )
__future__r   typingr   r   r   errorsr   r   r   r
   r   r   __annotations__r   r   r   r   r   r   <module>   s    
