
    g`                        U d Z ddlmZ ddlZddlZddlmZ ddlZddlm	Z	 ej                  rdZded	<   d
Zded<    G d de      Z G d d      ZddZy)z:Tools to provide pretty/human-readable display of objects.    )annotationsN)Any   )_typing_extraz'typing.Iterable[tuple[str | None, Any]]ztyping_extensions.TypeAliasReprArgszJtyping.Iterable[Any | tuple[Any] | tuple[str, Any] | tuple[str, Any, Any]]RichReprResultc                      e Zd ZdZddZy)	PlainReprzString class where repr doesn't include quotes. Useful with Representation when you want to return a string
    representation of something that is valid (or pseudo-valid) python.
    c                    t        |       S N)strselfs    M/var/www/openai/venv/lib/python3.12/site-packages/pydantic/_internal/_repr.py__repr__zPlainRepr.__repr__   s    4y    Nreturnr   )__name__
__module____qualname____doc__r    r   r   r
   r
      s    r   r
   c                  P    e Zd ZdZddZddZddZddZddZddZ	ddZ
dd	Zy
)Representationr   c                      j                   }|s&t         d      r j                  j                         } fd|D        }|D cg c]!  \  }}|	|| ur|n j	                  |      f# c}}S c c}}w )a-  Returns the attributes to show in __str__, __repr__, and __pretty__ this is generally overridden.

        Can either return:
        * name - value pairs, e.g.: `[('foo_name', 'foo'), ('bar_name', ['b', 'a', 'r'])]`
        * or, just values, e.g.: `[(None, 'foo'), (None, ['b', 'a', 'r'])]`
        __dict__c              3  :   K   | ]  }|t        |      f  y wr   )getattr).0sr   s     r   	<genexpr>z/Representation.__repr_args__.<locals>.<genexpr>0   s     <1!WT1%&s   )	__slots__hasattrr   keys__repr_recursion__)r   attrs_namesattrsavs   `    r   __repr_args__zRepresentation.__repr_args__&   sr     nnwtZ8--,,.K<<TYkTYDAq]^]j$AD,C,CA,FGTYkkks   
A0A0c                .    | j                   j                  S )z/Name of the instance's class, used in __repr__.)	__class__r   r   s    r   __repr_name__zRepresentation.__repr_name__3   s    ~~&&&r   c                L    dt        |      j                   dt        |       dS )z8Returns the string representation of a recursive object.z<Recursion on z	 with id=>)typer   id)r   objects     r   r&   z!Representation.__repr_recursion__7   s(      V 5 56i6
|1MMr   c                N    |j                  d | j                         D              S )Nc              3  J   K   | ]  \  }}|t        |      n| d|  y w)N=)repr)r    r)   r*   s      r   r"   z.Representation.__repr_str__.<locals>.<genexpr>=   s.     ePd1	T!W!AaU|CPds   !#)joinr+   )r   join_strs     r   __repr_str__zRepresentation.__repr_str__<   s!    }}ePTPbPbPdeeer   c              +     K   | j                         dz    d | j                         D ]   \  }}||dz     ||       d d " d d yw)	zRUsed by devtools (https://python-devtools.helpmanual.io/) to pretty print objects.(r   Nr6   ,r   ))r.   r+   )r   fmtkwargsnamevalues        r   
__pretty__zRepresentation.__pretty__?   sf       "S((--/KD%Sj e*IG 0 	s   AAc              #  V   K   | j                         D ]  \  }}|| ||f  yw)zYUsed by Rich (https://rich.readthedocs.io/en/stable/pretty.html) to pretty print objects.N)r+   )r   rB   
field_reprs      r   __rich_repr__zRepresentation.__rich_repr__L   s4      $ 2 2 4D*|  J&&	 !5s   ')c                $    | j                  d      S )N )r:   r   s    r   __str__zRepresentation.__str__T   s      %%r   c                L    | j                          d| j                  d       dS )Nr<   , r?   )r.   r:   r   s    r   r   zRepresentation.__repr__W   s+    $$&'q):):4)@(ACCr   N)r   r   r   )r3   r   r   r   )r9   r   r   r   )r@   ztyping.Callable[[Any], Any]rA   r   r   z!typing.Generator[Any, None, None])r   r   )r   r   r   r#   r+   r.   r&   r:   rD   rG   rJ   r   r   r   r   r   r      s5     Il'N
f'&Dr   r   c                   t        | t        j                  t        j                  f      r| j                  S | du ryt        | t
              rt        |       S t        | t        j                        st        j                  |       rt        |       S t        | t        j                  t        j                  t        f      s| j                  } t        j                   t#        j$                  |             r8dj'                  t)        t*        t#        j,                  |                   }d| dS t        | t        j                        rt        j.                  |       r3dj'                  t)        t        t#        j,                  |                   }n2dj'                  t)        t*        t#        j,                  |                   }	 | j0                   d| dS t        | t              r| j0                  S t        |       j5                  dd      j5                  d	d      S # t2        $ r. t        |       j5                  dd      j5                  d	d      cY S w xY w)
zPretty representation of a type, should be as close as possible to the original type definition string.

    Takes some logic from `typing._type_repr`.
    .z...rL   zUnion[][ztyping. ztyping_extensions.)
isinstancetypesFunctionTypeBuiltinFunctionTyper   r   r7   typing
ForwardRefr   is_type_alias_typer   typing_baseWithArgsTypesr1   r-   origin_is_uniontyping_extensions
get_originr8   mapdisplay_as_typeget_args
is_literalr   AttributeErrorreplace)objargss     r   r^   r^   [   s   
 #**E,E,EFG||		C	(Cy	C**	+}/O/OPS/T3xcM55}7R7RTXYZmm$$%6%A%A#%FGyy_.?.H.H.MNOvQ	C44	5##C(99S'8'A'A#'FGHD99S2C2L2LS2QRSD	U&&'qa00 
C	Cy  B/778LbQQ  	Us8##Ir2::;OQSTT	Us   H 4II)rc   r   r   r   )r   
__future__r   _annotationsrR   rU   r   r[   rP   r   TYPE_CHECKINGr   __annotations__r   r   r
   r   r^   r   r   r   <module>ri      s]    @ 2     	,UH)UT / 
 ;D ;D| Rr   