o
    ¨Ýju  ã                   @  sø   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mZ ddlZddlmZ ddlmZ dd	lmZ erfe	eedB ef  Zd
ed< e	eee B eeef B eeeef B  Zd
ed< G dd„ deƒZG dd„ dƒZddd„ZdS )z:Tools to provide pretty/human-readable display of objects.é    )ÚannotationsN)ÚCallableÚ
CollectionÚ	GeneratorÚIterable)ÚTYPE_CHECKINGÚAnyÚ
ForwardRefÚ	TypeAliasÚcast)Útyping_objects)Úis_union_originé   )Ú_typing_extrar
   ÚReprArgsÚRichReprResultc                   @  s   e Zd ZdZddd„ZdS )Ú	PlainReprz¸String 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.
    ÚreturnÚstrc                 C  s   t | ƒS ©N)r   ©Úself© r   úS/var/www/html/chatgpt/venv/lib/python3.10/site-packages/pydantic/_internal/_repr.pyÚ__repr__   s   zPlainRepr.__repr__N©r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   r   r      s    r   c                   @  s`   e Zd ZdZddd„Zddd„Zd dd„Zd!dd„Zd"dd„Zd#dd„Z	ddd„Z
ddd„ZdS )$ÚRepresentationr   r   r   c                   sL   t tt ˆ jƒ}|stˆ dƒrˆ j ¡ }‡ fdd„|D ƒ}‡ fdd„|D ƒS )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  s   � | ]
}|t ˆ |ƒfV  qd S r   )Úgetattr)Ú.0Úsr   r   r   Ú	<genexpr>/   s   € z/Representation.__repr_args__.<locals>.<genexpr>c                   s2   g | ]\}}|d ur||ˆ ur|nˆ   |¡f‘qS r   )Ú__repr_recursion__©r#   ÚaÚvr   r   r   Ú
<listcomp>0   s   2 z0Representation.__repr_args__.<locals>.<listcomp>)r   r   r   Ú	__slots__Úhasattrr!   Úkeys)r   Zattrs_namesÚattrsr   r   r   Ú__repr_args__%   s
   
zRepresentation.__repr_args__r   c                 C  s   | j jS )z/Name of the instance's class, used in __repr__.)Ú	__class__r   r   r   r   r   Ú__repr_name__2   s   zRepresentation.__repr_name__Úobjectr   c                 C  s   dt |ƒj› dt|ƒ› d�S )z8Returns the string representation of a recursive object.z<Recursion on z	 with id=ú>)Útyper   Úid)r   r2   r   r   r   r&   6   s   z!Representation.__repr_recursion__Újoin_strc                 C  s   |  dd„ |  ¡ D ƒ¡S )Nc                 s  s2   � | ]\}}|d u rt |ƒn|› d|›�V  qd S )Nú=)Úreprr'   r   r   r   r%   <   s   €0 z.Representation.__repr_str__.<locals>.<genexpr>)Újoinr/   )r   r6   r   r   r   Ú__repr_str__;   s   zRepresentation.__repr_str__ÚfmtúCallable[[Any], Any]ÚkwargsúGenerator[Any]c                 k  s`   � |   ¡ d V  dV  |  ¡ D ]\}}|dur|d V  ||ƒV  dV  dV  qdV  dV  dS )	zRUsed by devtools (https://python-devtools.helpmanual.io/) to pretty print objects.ú(r   Nr7   ú,r   éÿÿÿÿú))r1   r/   )r   r;   r=   ÚnameÚvaluer   r   r   Ú
__pretty__>   s   €


zRepresentation.__pretty__r   c                 c  s2   � |   ¡ D ]\}}|du r|V  q||fV  qdS )zYUsed by Rich (https://rich.readthedocs.io/en/stable/pretty.html) to pretty print objects.N)r/   )r   rC   Z
field_reprr   r   r   Ú__rich_repr__K   s   €üzRepresentation.__rich_repr__c                 C  s
   |   d¡S )Nú )r:   r   r   r   r   Ú__str__S   s   
zRepresentation.__str__c                 C  s   |   ¡ › d|  d¡› d�S )Nr?   ú, rB   )r1   r:   r   r   r   r   r   V   s   zRepresentation.__repr__N)r   r   r   )r2   r   r   r   )r6   r   r   r   )r;   r<   r=   r   r   r>   )r   r   )r   r   r   r+   r/   r1   r&   r:   rE   rF   rH   r   r   r   r   r   r       s    






r    Úobjr   r   r   c                 C  sN  t | tjtjfƒr| jS | du rdS t | tƒrt| ƒS t | tƒs%t 	| ¡r)t
| ƒS t | tjtjtfƒs6| j} tt | ¡ƒrNd ttt | ¡ƒ¡}d|› d�S t | tjƒr“t t | ¡¡rhd ttt | ¡ƒ¡}nd ttt | ¡ƒ¡}z
| j› d|› d�W S  ty’   t
| ƒ dd¡ d	d¡ Y S w t | tƒr›| jS t| ƒ dd¡ d	d¡S )
zœPretty representation of a type, should be as close as possible to the original type definition string.

    Takes some logic from `typing._type_repr`.
    .z...rI   zUnion[ú]ú[ztyping.Ú ztyping_extensions.)Ú
isinstanceÚtypesÚFunctionTypeÚBuiltinFunctionTyper   r    r8   r	   r   Zis_typealiastyper   r   Ztyping_baseZWithArgsTypesr4   r0   r   Útyping_extensionsÚ
get_originr9   ÚmapÚdisplay_as_typeÚget_argsZ
is_literalr   ÚAttributeErrorÚreplace)rJ   Úargsr   r   r   rU   Z   s2   
ÿ
rU   )rJ   r   r   r   )r   Ú
__future__r   Z_annotationsrO   Úcollections.abcr   r   r   r   Útypingr   r   r	   r
   r   rR   Ztyping_inspectionr   Ztyping_inspection.introspectionr   rM   r   Útupler   r   Ú__annotations__r   r   r    rU   r   r   r   r   Ú<module>   s    2	=