o
    i                     @  s\  d dl mZ d dlZd dlZd dlZd dlmZmZm	Z	m
Z
 d dlmZ d dlmZ d dlmZ d dlmZmZmZ d dlZd dlZd dlmZmZ ejd	d
Zeeej  G dd dZ e  Z!	 edZ"d+ddZ#d,ddZ$edZ%edZ&dd Z'd-d d!Z(zd d"l)m*Z* W n e+y   G d#d$ d$e,Z*Y nw erej-Z.dS ed.d)d*Z.dS )/    )annotationsN)	AwaitableCallable	GeneratorSequence)contextmanager)partial)Path)TYPE_CHECKINGAnyTypeVar)	ParamSpecTypeIszpydantic-evals)
otel_scopec                   @  s   e Zd ZdZdS )UnsetzA singleton to represent an unset value.

    Used to distinguish between explicitly set `None` values and values that were never set.

    Copied from pydantic_ai/_utils.py.
    N)__name__
__module____qualname____doc__ r   r   [/var/www/html/karishye-ai-python/venv/lib/python3.10/site-packages/pydantic_evals/_utils.pyr      s    r   T
t_or_unset	T | Unsetreturn	TypeIs[T]c                 C  s   | t uS )a  Check if a value is set (not the UNSET singleton).

    Args:
        t_or_unset: The value to check, which may be the UNSET singleton or a regular value.

    Returns:
        True if the value is not UNSET, narrowing the type to T in a type-aware way.
    )UNSET)r   r   r   r   is_set%   s   	r   funcCallable[..., Any]strc              
     sf   d	 fdd z | j W S  ty2 } ztt| ddr,t| j dW  Y d}~S |d}~ww )
a  Get the name of a function, unwrapping partials and decorators.

    Args:
        func: The function to get the name of.

    Returns:
        The name of the function.

    Raises:
        AttributeError: If the function doesn't have a __name__ attribute and isn't a method.
    fr   r   c                   s   t | tr
 | jS t| S )zFUnwraps f, also unwrapping partials, for the sake of getting f's name.)
isinstancer   r   inspectunwrap)r!   _unwrapr   r   r&   >   s   


z,get_unwrapped_function_name.<locals>._unwrap__call__Nz	.__call__)r!   r   r   r   )r   AttributeErrorr#   ismethodgetattrtyper   )r   er   r%   r   get_unwrapped_function_name1   s   r-   _P_Rc                  C  s6   zt  } W | S  ty   t  } t |  Y | S w )N)asyncioget_event_loopRuntimeErrornew_event_loopset_event_loop)
event_loopr   r   r   r1   R   s   
r1   tasks$Sequence[Callable[[], Awaitable[T]]]list[T]c              	     s   dgt |   d
 fdd	}t 4 I dH }t| D ]\}}|||| qW d  I dH   S 1 I dH s9w   Y   S )zRun multiple awaitable callables concurrently using an AnyIO task group.

    Args:
        tasks: A list of no-argument callables that return awaitable objects.

    Returns:
        A list of results in the same order as the input tasks.
    NtskCallable[[], Awaitable[T]]indexintr   Nonec                   s   |  I dH  |< dS )zHHelper function to run a task and store the result in the correct index.Nr   )r9   r;   resultsr   r   	_run_taskf   s   z$task_group_gather.<locals>._run_task)r9   r:   r;   r<   r   r=   )lenanyiocreate_task_group	enumerate
start_soon)r6   r@   tgitaskr   r>   r   task_group_gather[   s   	rI   )LogfireNotConfiguredWarningc                   @  s   e Zd ZdS )rJ   N)r   r   r   r   r   r   r   rJ   x   s    rJ   argsr   kwargs.Generator[logfire_api.LogfireSpan, None, None]c               	   o  s    t  3 t jdtd tj| i |}|V  W d   n1 s#w   Y  W d   dS W d   dS 1 s;w   Y  dS )zCCreate a Logfire span without warning if logfire is not configured.ignore)categoryN)warningscatch_warningsfilterwarningsrJ   _logfirespan)rK   rL   rT   r   r   r   logfire_span   s   
"rU   )r   r   r   r   )r   r   r   r    )r6   r7   r   r8   )rK   r   rL   r   r   rM   )/
__future__r   _annotationsr0   r#   rP   collections.abcr   r   r   r   
contextlibr   	functoolsr   pathlibr	   typingr
   r   r   rB   logfire_apityping_extensionsr   r   LogfirerS   add_non_user_code_prefix__file__parentabsoluter   r   r   r   r-   r.   r/   r1   rI   logfire._internal.configrJ   ImportErrorUserWarningrT   rU   r   r   r   r   <module>   sB    


	
