
    h4                    "   U d Z ddlmZ ddlZddlmZmZmZm	Z	 ddl
mZmZmZmZ ddlZddlmZ ddlmZ ddlmZ d	d
lmZ er3e	eedz  ef      Zded<   e	eee   z  eeef   z  eeeef   z     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)Callable
Collection	GeneratorIterable)TYPE_CHECKINGAny
ForwardRefcast)	TypeAlias)typing_objects)is_union_origin   )_typing_extrar   ReprArgs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    =D:\jyotish\venv\Lib\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                    t        t        t            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>1   s     <1!WT1%&s   )r   r   r   	__slots__hasattrr'   keys__repr_recursion__)r   attrs_namesattrsavs   `    r   __repr_args__zRepresentation.__repr_args__'   s}     :c?DNN;wtZ8--,,.K<<TYkTYDAq]^]j$AD,C,CA,FGTYkkks   
B&B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__4   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   r0   z!Representation.__repr_recursion__8   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*   r3   r4   s      r   r,   z.Representation.__repr_str__.<locals>.<genexpr>>   s.     ePd1	T!W!AaU|CPds   !#)joinr5   )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   Nr@   ,r   ))r8   r5   )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)r5   )r   rL   
field_reprs      r   __rich_repr__zRepresentation.__rich_repr__M   s4      $ 2 2 4D*|  J&&	 !5s   ')c                $    | j                  d      S )N )rD   r   s    r   __str__zRepresentation.__str__U   s      %%r   c                L    | j                          d| j                  d       dS )NrF   , rI   )r8   rD   r   s    r   r   zRepresentation.__repr__X   s+    $$&'q):):4)@(ACCr   N)r   r   r   )r=   r	   r   r   )rC   r   r   r   )rJ   zCallable[[Any], Any]rK   r	   r   zGenerator[Any])r   r   )r   r    r!   r-   r5   r8   r0   rD   rN   rQ   rT   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              st        j                  |       rt        |       S t        | t        j                  t        j                  t        f      s| j                  } t!        t#        j$                  |             r8dj'                  t)        t*        t#        j,                  |                   }d| dS t        | t        j                        rt        j.                  t#        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...rV   zUnion[][ztyping. ztyping_extensions.)
isinstancetypesFunctionTypeBuiltinFunctionTyper   r%   rA   r
   r   is_typealiastyper   r   typing_baseWithArgsTypesr;   r7   r   typing_extensions
get_originrB   mapdisplay_as_typeget_args
is_literalr!   AttributeErrorreplace)objargss     r   re   re   \   s   
 #**E,E,EFG||		C	(Cy	C	$(G(G(L3xcM55}7R7RTXYZmm(33C89yy_.?.H.H.MNOvQ	C44	5$$%6%A%A#%FG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)rj   r	   r   r   )r"   
__future__r   _annotationsr\   collections.abcr   r   r   r   typingr   r	   r
   r   rb   r   typing_inspectionr   typing_inspection.introspectionr   rZ   r   tupler   r   __annotations__r   r   r%   re   r#   r   r   <module>rt      s    @ 2  E E 7 7  ' , ; "5tS#9:Hi: (uSz)9E#s(O)KeTWY\^aTaNb)b cNIc :D :Dz Rr   