
    RPf                        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    R/var/www/fastapitest/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                  R    e Zd Z e       Zd	dZd
dZddZddZddZ	d
dZ
d
dZy)Representationc                      j                   }|s&t         d      r j                  j                         } fd|D        }|D cg c]  \  }}|	||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>/   s     <1!WT1%&<s   )	__slots__hasattrr   keys)r   attrs_namesattrsavs   `    r   __repr_args__zRepresentation.__repr_args__%   sV     nnwtZ8--,,.K<<#(:41aAMA:::s   
AA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__2   s    ~~&&&r   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>7   s+     e1	T!W!AaU|Ces   !#)joinr*   )r   join_strs     r   __repr_str__zRepresentation.__repr_str__6   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   Nr0   ,r   ))r-   r*   )r   fmtkwargsnamevalues        r   
__pretty__zRepresentation.__pretty__9   sk       "S((--/ 	KD%Sj e*IG	 	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   r<   
field_reprs      r   __rich_repr__zRepresentation.__rich_repr__F   s9      $ 2 2 4 	'D*|  J&&		's   ')c                $    | j                  d      S )N )r4   r   s    r   __str__zRepresentation.__str__N   s      %%r   c                L    | j                          d| j                  d       dS )Nr6   , r9   )r-   r4   r   s    r   r   zRepresentation.__repr__Q   s+    $$&'q):):4)@(ACCr   N)r   r   r   )r3   r   r   r   )r:   ztyping.Callable[[Any], Any]r;   r   r   z!typing.Generator[Any, None, None])r   r   )r   r   r   tupler#   r*   r-   r4   r>   rA   rD   r   r   r   r   r   r      s0     I;'f'&Dr   r   c                @   t        | t        j                        r| j                  S | du ryt        | t              rt        |       S t        | 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                  |       t        j(                  k(  r3dj!                  t#        t
        t        j&                  |                   }n2dj!                  t#        t$        t        j&                  |                   }	 | j*                   d| dS t        | t              r| j*                  S t        |       j/                  dd      j/                  d	d      S # t,        $ r t        |       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...rF   zUnion[][ztyping. ztyping_extensions.)
isinstancetypesFunctionTyper   r   r1   typing_extensionsTypeAliasTyper   r   typing_baseWithArgsTypestyper,   origin_is_union
get_originr2   mapdisplay_as_typeget_argsLiteralr   AttributeErrorreplace)objargss     r   rW   rW   U   s   
 #u))*||		C	(Cy	C*88	93xcM55}7R7RTXYZmm$$%6%A%A#%FGyy_.?.H.H.MNOvQ	C44	5'',0A0I0II99S'8'A'A#'FGHD99S2C2L2LS2QRSD	&&'qa00 
C	Cy  B/778LbQQ  	s8O	s   -H HH)r\   r   r   r   )r   
__future__r   _annotationsrM   typingr   rO   rK   r   TYPE_CHECKINGr   __annotations__r   r   r
   r   rW   r   r   r   <module>rc      s]    @ 2     	,UH)UT / 
 6D 6Dr Rr   