o
    $6dr                     @  s   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
r0dZded	< d
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)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                   @  s   e Zd ZdZdddZdS )	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.
    returnstrc                 C  s   t | S N)r
   self r   oC:\Users\jesus\OneDrive\Desktop\erpjis_fastapi\backend\jisbackend\Lib\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                   @  sX   e Zd Ze 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   c                   s>    j }|st dr j } fdd|D }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                 S  s    g | ]\}}|d ur||fqS r   r   r   avr   r   r   
<listcomp>0   s     z0Representation.__repr_args__.<locals>.<listcomp>)	__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__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   7   s   0 z.Representation.__repr_str__.<locals>.<genexpr>)joinr$   )r   r'   r   r   r   __repr_str__6   s   zRepresentation.__repr_str__fmttyping.Callable[[Any], Any]kwargsr   !typing.Generator[Any, None, None]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   Nr(   ,r   ))r&   r$   )r   r,   r.   namevaluer   r   r   
__pretty__9   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   r4   Z
field_reprr   r   r   __rich_repr__F   s   zRepresentation.__rich_repr__c                 C  s
   |  dS )N )r+   r   r   r   r   __str__N   s   
zRepresentation.__str__c                 C  s   |    d| d dS )Nr0   , r3   )r&   r+   r   r   r   r   r   Q   s   zRepresentation.__repr__N)r	   r   r   )r'   r
   r	   r
   )r,   r-   r.   r   r	   r/   )r	   r   )r   r   r   tupler    r$   r&   r+   r6   r7   r9   r   r   r   r   r   r      s    





r   objr   r	   r
   c                 C  s   t | tjr	| jS | du rdS t | trt| S t | tjtjt	fs%| j
} tt| r>dttt| }d| dS t | tjrXdttt| }| j d| dS t | t	r`| jS t| ddd	dS )
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...r:   zUnion[][ztyping. ztyping_extensions.)
isinstancetypesFunctionTyper   r   r)   r   Ztyping_baseZWithArgsTypestyper%   Zorigin_is_uniontyping_extensions
get_originr*   mapdisplay_as_typeget_argsr   replace)r<   argsr   r   r   rG   U   s"   

rG   )r<   r   r	   r
   )r   
__future__r   Z_annotationsrA   typingr   rD   r?   r   TYPE_CHECKINGr   __annotations__r   r
   r   r   rG   r   r   r   r   <module>   s    
	9