
    g
                        d dl mZ d dlZd dlZd dlmZmZ d dlmZm	Z	m
Z
mZmZmZ d dlZddZddZddZej$                  dk  rdd	Zndd
ZddZddZddZ G d d      Z e       Z e
d      ZddZy)    )annotationsN)datetimetimezone)	AnnotatedAnyTypeVarUnionget_args
get_originc                    t        | t        j                        r| j                  } t	        |       }t        |      rt        |       S | fS )zhExtract the arguments of a Union type if `response_type` is a union, otherwise return the original type.)
isinstancetyping_extensionsTypeAliasType	__value__r   origin_is_unionr
   )tporigins     J/var/www/openai/venv/lib/python3.12/site-packages/pydantic_graph/_utils.pyget_union_argsr      s@     "'556\\^Fv|u    c                v    t        |       }|t        u s|t        j                  u rt        |       ^}}||fS | g fS )zStrip `Annotated` from the type if present.

    Returns:
        `(tp argument, ())` if not annotated, otherwise `(stripped type, annotations)`.
    )r   r   r   r
   )r   r   inner_tpargss       r   unpack_annotatedr      sC     ^Ff(9(C(CC"2,4~2vr   c                X    | t         j                  u ryt        t         dd      x}r| |u S y)zCheck if a type is `Never`.TNeverNF)r   r   getattr)r   typing_nevers     r   is_neverr   &   s7    	$$$ !2GTB	B	B\!!r   )   
   c                    | t         u S N)r	   r   s    r   r   r   3   s    U{r   c                :    | t         u xs | t        j                  u S r#   )r	   types	UnionTyper$   s    r   r   r   8   s    U{3bEOO33r   c                b    t        |       dk(  r| d   S dj                  | dd       dz   | d   z   S )z.Join with a comma and 'and' for the last item.   r   z, Nz, and )lenjoin)itemss    r   	comma_andr.   <   s;    
5zQQx yys$x/%);;r   c                    | K| j                   x}r<|j                  j                  j                  d      rt	        |      S |j
                  S yy)zAttempt to get the namespace where the graph was defined.

    If the graph is defined with generics `Graph[a, b]` then another frame is inserted, and we have to skip that
    to get the correct namespace.
    Nz
/typing.py)f_backf_codeco_filenameendswithget_parent_namespacef_locals)framebacks     r   r4   r4   E   sP     <<4{{&&//=+D11}}$	   r   c                 J    t        j                  t        j                        S )N)tz)r   nowr   utc r   r   now_utcr=   S   s    <<8<<((r   c                      e Zd ZdZy)UnsetzUA singleton to represent an unset value.

    Copied from pydantic_ai/_utils.py.
    N)__name__
__module____qualname____doc__r<   r   r   r?   r?   W   s    
 	r   r?   Tc                    | t         uS r#   )UNSET)
t_or_unsets    r   is_setrH   d   s    U""r   )r   r   returnztuple[Any, ...])r   r   rI   ztuple[Any, list[Any]])r   r   rI   bool)r   ztype[Any] | NonerI   rJ   )r-   z	list[str]rI   str)r6   ztypes.FrameType | NonerI   zdict[str, Any] | None)rI   r   )rG   z	T | UnsetrI   ztyping_extensions.TypeGuard[T])
__future__r   _annotationssysr&   r   r   typingr   r   r   r	   r
   r   r   r   r   r   version_infor   r.   r4   r=   r?   rF   rD   rH   r<   r   r   <module>rQ      ss    2 
  ' G G 
 g
4<%)	 	 	CL#r   