o
    Ti                     @   s   d dl m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 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 )    )Callable)datetime)Enum)Any	ParamSpecTypeVarget_args   )is_subclass)	ConverterUnstructureHook)identityc                 C   s   t | tstd|  | S )NzExpected datetime, got )
isinstancer   	Exception)v_ r   K/home/ubuntu/.local/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 )zAn 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>.   s    
z:literals_with_enums_unstructure_factory.<locals>.<genexpr>)allr   r   unstructure)r#   r$   r   r(   r   'literals_with_enums_unstructure_factory&   s
   r,   N)F)collections.abcr   r   enumr   typingr   r   r   r   _compatr
   
convertersr   r   fnsr   r   r   r   r   boolr"   r,   r   r   r   r   <module>   s&    4	