o
    "“i÷  ã                   @   s
  d dl Z d dlmZ d dlmZ d dlmZmZmZmZ ddl	m
Z
 ddlmZmZ ddlmZ e jdd… d	k r@d d
lmZ nd d
lmZ dd„ ZedƒZedƒZdeeef deedef geeef f fdd„Zddededefdd„Zdededefdd„ZdS )é    N)Údatetime)ÚEnum)ÚAnyÚCallableÚTypeVarÚget_argsé   )Úis_subclass)Ú	ConverterÚUnstructureHook)Úidentity)é   é
   )Ú	ParamSpecc                 C   s   t | tƒstd| › �ƒ‚| S )NzExpected datetime, got )Ú
isinstancer   Ú	Exception)ÚvÚ_© r   úW/var/www/html/premium_crap/venv/lib/python3.10/site-packages/cattrs/preconf/__init__.pyÚvalidate_datetime   s   
r   ÚTÚPr   Úreturn.c                 C   s&   dt dtf dt ttf fdd„}|S )z1Wrap a `Converter` `__init__` in a type-safe way.Úx.r   c                 S   s   | S ©Nr   )r   r   r   r   Úimpl   s   zwrap.<locals>.impl)r   r   r   )r   r   r   r   r   Úwrap   s   "r   FÚtypeÚinclude_bare_enumsc                 C   s4   t | tƒot | ttfƒp|o|  ¡ dd… t ¡ kS )z8Is this a string or int enum that can be passed through?é   N)r	   r   ÚstrÚintÚmro)r   r   r   r   r   Úis_primitive_enum#   s   
þr$   ÚtypÚ	converterc                    s$   t ‡ fdd„t| ƒD ƒƒrtS ˆ jS )zÌAn unstructure hook factory for literals containing enums.

    If all contained enums can be passed through (their unstructure hook is `identity`),
    the entire literal can also be passed through.
    c                 3   s"   � | ]}ˆ   t|ƒ¡tkV  qd S r   )Úget_unstructure_hookr   r   )Ú.0Úarg©r&   r   r   Ú	<genexpr>3   s   € 
ÿz:literals_with_enums_unstructure_factory.<locals>.<genexpr>)Úallr   r   Úunstructure)r%   r&   r   r*   r   Ú'literals_with_enums_unstructure_factory+   s
   ÿr.   )F)Úsysr   Úenumr   Útypingr   r   r   r   Ú_compatr	   Ú
convertersr
   r   Úfnsr   Úversion_infoÚtyping_extensionsr   r   r   r   r   Úboolr$   r.   r   r   r   r   Ú<module>   s,    4	ÿÿþ