a
     dX>                     @   s  d dl Z d dlZd dlZd dlZd dlZd dlmZmZmZm	Z	m
Z
mZmZ d dlmZ d dlmZ d dlmZ d+ddZdd	 Zed
fddZed
fd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ed
fdd Zd!d" Z d#d$ Z!d%d& Z"d'd( Z#d)d* Z$dS ),    N)curryis_valid_argsis_partial_argsis_aritynum_required_argshas_varargshas_keywords)builtins)raisesTc                 C   sB   |  dsd|  } |rd}nd}i }td| |f t | |d S )N(z(%s)z1raise ValueError("function should not be called")zreturn Truezdef func%s:
    %sfunc)
startswithexecglobals)Zparam_stringraise_if_calledbodyd r   f/var/www/html/stable-diffusion-webui/venv/lib/python3.9/site-packages/toolz/tests/test_inspect_args.py	make_func   s    
r   c                      s  t d tt fddsJ tt fdds4J t ddd   sJJ tt fdds`J t ddd  d	sxJ  d	d
sJ  d	dsJ  d	ddsJ tt fddsJ t ddd  d	sJ  d	d
sJ  d	dsJ  d	ddsJ tt fddsJ d S )N c                      s     S Nr   r   fr   r   <lambda>       z test_make_func.<locals>.<lambda>c                      s    dS N   r   r   r   r   r   r      r   F)r   c                      s    dS r   r   r   r   r   r   r       r   zx, y=1r   x   r   yc                      s    dddS Nr   r       r   r   r   r   r   r   '   r   z(x, y=1)c                      s    dddS r#   r   r   r   r   r   r   .   r   )r   r
   
ValueError	TypeErrorr   r   r   r   test_make_func   s$    
r'   Fc                    s  |   fdd} t d}| |s$J | |ddu s6J | |dddu sJJ t d}| ||u sbJ | |dspJ | |ddsJ | |ddddu sJ | |ddd	du sJ | |dddu sJ | |ddd
du sJ t d}| |sJ | |dsJ | |dds
J | |ddddu s"J | |ddd	du s:J | |dddu sPJ | |ddd
du shJ t d}| |s~J | |dsJ | |ddsJ | |dddu sJ t d}| |sJ | |ddsJ | |ddd
sJ | |ddu sJ t d}| ||u s J | |ds0J | |ddsBJ | |ddsTJ | |ddddu slJ | |ddd	du sJ t d}| ||u sJ | |dsJ | |ddsJ | |ddsJ | |ddddsJ | |dddd	du sJ t d}| ||u sJ | |d|u s0J | |ddsBJ | |ddd|u sZJ | |ddddu srJ | |dddddu sJ | |dddddu sJ | ddu sJ d S )Nc                    s    | ||S r   r   r   argskwargsZorig_check_validr   r   r   3   r   ztest_is_valid.<locals>.<lambda>r   r   Fr   r   r    r"   r!   zx=1*args**kwargszx, *argszx, y=1, **kwargsr$   r   r"   zza, b, c=3, d=4)c)eb)r   check_valid
incompleter   r   r+   r   test_is_valid1   sn    r8   c                    s  |   fdd} t d}| ||u s(J | |ds6J | |ddsFJ | |dddsXJ | |dddu slJ | |ddd	du sJ t d
}| ||u sJ | |dsJ | |ddsJ | |dddsJ | |ddddsJ | |ddsJ | |ddd	du sJ t d}| |sJ | |ddu s0J | |ddsBJ | |dd	du sXJ t d}| ||u srJ | |d|u sJ | |dd|u sJ | |dddsJ | |dddsJ | |dddu sJ | |ddd	du sJ | |dddddu sJ t d}| ||u s&J | |ddd	|u s>J | |ddsPJ | |dddsdJ | |dddsxJ | |ddddsJ | |dddddu sJ | |dddddu sJ t d}| ||u sJ | |d|u sJ | |dddsJ t d}| ||u sJ | |d|u s2J | |dd|u sHJ | |dddd|u sbJ | |dddddszJ | |ddddddddd
|u sJ t d}| ||u sJ | |d|u sJ | |dd|u sJ | |ddsJ t d}| ||u sJ | |d|u s"J | |dd|u s8J | |ddsJJ d|_| |du sbJ G d d! d!t}| }| |d u sJ d S )"Nc                    s    | ||S r   r   r(   r+   r   r   r   v   r   z#test_is_valid_py3.<locals>.<lambda>z	x, *, y=1r   r   r    r,   Fr0   zx, *args, y=1z*, y=1zx, *, yr!   )r"   r0   zx=1, *, y, z=3r$   r/   zw, x=2, *args, y, z=4z%a, b, c=3, d=4, *args, e=5, f=6, g, h   )g   )r;   h         	   za: int, b: floatr3   z(a: int, b: float) -> float"   c                   @   s    e Zd Zdd Zedd ZdS )z+test_is_valid_py3.<locals>.RaisesValueErrorc                 S   s   d S r   r   selfr   r   r   __call__   s    z4test_is_valid_py3.<locals>.RaisesValueError.__call__c                 S   s   t dd S NzTesting Python 3.4r%   rC   r   r   r   __signature__   s    z9test_is_valid_py3.<locals>.RaisesValueError.__signature__N__name__
__module____qualname__rE   propertyrH   r   r   r   r   RaisesValueError   s   rN   )r   rH   object)r6   r7   r   rN   r   r+   r   test_is_valid_py3t   s    $rP   c                   C   s   t tdd ttdd d S NTr6   r7   )r8   r   rP   r   r   r   r   test_is_partial   s    rS   c                  C   sZ   ddd} t j| dd}t|dd t|dd t j| dd}t|dd t|dd d S )NTc                 S   s   zvt | |i | t | g|R  f i | t | fi ||  t | g|R i |  t| tdd srW d S |W S  ty   Y dS  ty   Y dS 0 d S )Nc                   S   s   d S r   r   r   r   r   r   r      r   z:test_is_valid_curry.<locals>.check_curry.<locals>.<lambda>TF)r   
isinstancetyper%   r&   )r   r)   r*   r7   r   r   r   check_curry   s    z(test_is_valid_curry.<locals>.check_curry)r7   rR   F)T)	functoolspartialr8   rP   )rV   r6   r   r   r   test_is_valid_curry   s    
rY   c                  C   s   ddd} t | di sJ t | di s*J t | ddd is>J t | ddd idu sVJ t| di sfJ t| di svJ t| ddd isJ t| ddd idu sJ d S )Nc                 S   s   d S r   r   r   r   r   r   r      s    ztest_func_keyword.<locals>.fr   r   r   F)N)r   r   r   r   r   r   test_func_keyword   s    
r[   c                  C   s   t ddu sJ t tsJ t tddu s0J t tddu sDJ t tdsTJ t tddu shJ t tdsxJ t tddu sJ t td	du sJ td} d
| _t | du sJ G dd dt}| } t | d u sJ d S )Nr   Fr   zx, y, zr-   r.   zx, y, *args, **kwargsz	x, y, z=1zx, y, z=1, **kwargsrB   c                   @   s    e Zd Zdd Zedd ZdS )z/test_has_unknown_args.<locals>.RaisesValueErrorc                 S   s   d S r   r   rC   r   r   r   rE     s    z8test_has_unknown_args.<locals>.RaisesValueError.__call__c                 S   s   t dd S rF   rG   rC   r   r   r   rH     s    z=test_has_unknown_args.<locals>.RaisesValueError.__signature__NrI   r   r   r   r   rN     s   rN   )r   mapr   rH   rO   )r   rN   r   r   r   test_has_unknown_args   s    r]   c                   C   s   t dd dksJ t dd dks(J t dd dks<J t dd dksPJ t dd d	ksdJ t td	kstJ t td u sJ d S )
Nc                   S   s   d S r   r   r   r   r   r   r     r   z(test_num_required_args.<locals>.<lambda>r   c                 S   s   d S r   r   r   r   r   r   r     r   r   c                 W   s   d S r   r   r   r)   r   r   r   r     r   c                 [   s   d S r   r   r   r*   r   r   r   r     r   c                 _   s   d S r   r   )r   r"   r)   r*   r   r   r   r     r   r    )r   r\   dictr   r   r   r   test_num_required_args  s    ra   c                   C   s   t dd du sJ t dd du s(J t ddds:J t dd sJJ t tsVJ t tsbJ t tsnJ t tdu s~J t td u sJ d S )	Nc                   S   s   d S r   r   r   r   r   r   r     r   z#test_has_keywords.<locals>.<lambda>Fc                 S   s   d S r   r   r   r   r   r   r     r   r   c                 S   s   d S r   r   r   r   r   r   r     r   c                  [   s   d S r   r   r*   r   r   r   r     r   )r   )r   intsortedmaxr\   	bytearrayr   r   r   r   test_has_keywords  s    rg   c                   C   sX   t dd du sJ t dd s$J t dd du s8J t tsDJ t td u sTJ d S )Nc                   S   s   d S r   r   r   r   r   r   r   %  r   z"test_has_varargs.<locals>.<lambda>Fc                  W   s   d S r   r   )r)   r   r   r   r   &  r   c                  [   s   d S r   r   rb   r   r   r   r   '  r   )r   r\   re   r   r   r   r   test_has_varargs$  s
    rh   c                   C   s   t ddd sJ t ddd du s(J t ddd s:J t dd	d sLJ t dd
d du sbJ t ddd du sxJ t dtsJ t dtdu sJ t dtd u sJ d S )Nr   c                   S   s   d S r   r   r   r   r   r   r   -  r   ztest_is_arity.<locals>.<lambda>r   c                   S   s   d S r   r   r   r   r   r   r   .  r   Fc                 S   s   d S r   r   r   r   r   r   r   /  r   r$   c                 S   s   d S r   r   r/   r   r   r   r   0  r   c                 W   s   d S r   r   r^   r   r   r   r   1  r   c                 [   s   d S r   r   r_   r   r   r   r   2  r   r    )r   allr\   ranger   r   r   r   test_is_arity,  s    rk   c                    s  |   fdd} t td}| |s*J | |ds8J | |ddsHJ | |dddsZJ | |dddddu srJ | |d	d
du sJ | |dsJ | |ddsJ | |dddsJ | |dddddu sJ | |ddddu sJ | |dddsJ | |ddddu sJ | |dddds6J | |dddsLJ | |dddddsfJ | |dddddu sJ t jtdddd}| |du sJ | |dddu sJ t td}| |sJ | |dsJ | |ddsJ | |dddsJ | |dddds,J | |dddddsFJ | |ddddddsbJ | |ddsvJ | |ddddu sJ | |ddddsJ d S )Nc                    s    | ||S r   r   )Z_funcr)   r*   r+   r   r   r   :  r   z1test_introspect_curry_valid_py3.<locals>.<lambda>	x, y, z=0r   r    r$   r>   FT)Zinvalid_keywordr   r,   r9   zx, y, *args, zr   )toolzr   r   r5   r   r+   r   test_introspect_curry_valid_py38  sD    rn   c                   C   s   t tdd d S rQ   )rn   r   r   r   r   r   !test_introspect_curry_partial_py3`  s    ro   c                  C   sr  t td} t| dksJ td| s,J t| du s<J t| du sLJ t td} t| dksjJ td| du s|J td| du sJ t| du sJ t| sJ t td} t| dksJ td| du sJ td| du sJ td| du sJ td| du sJ t| du s$J t| s2J t td	} t| dksRJ t| s`J t| snJ d S )
Nr   r   Fr   r   rl   r    r$   z*args, **kwargs)rm   r   r   r   r   r   r   r   r   r   r   test_introspect_curry_py3d  s.    rp   c               	      s  t tttttjtjtjtjg	} t	   fdd}|t d |t d |t d |t d  fdd}i }| D ]J}|j
}t| D ]2\}}||||r||vrg ||< || | qql|rg }t| D ](\}}	d	|d
t|	}
||
 qd}t|d| d S )Nc                    s   t | |r t| | d S r   )hasattraddgetattr)modattrZdenylistr   r   add_denylist  s    
z5test_introspect_builtin_modules.<locals>.add_denylist
basestringZNoneType__metaclass__Zsequenceiteratorc                    s   | dr| dsdS | ds,|dr0dS zt|trBW dS W n tyV   Y n0 z6t|o|jd uo| |jv ot|di duo| vW S  ty   Y dS 0 d S )N___FZ__pyx_unpickle_Z	_cython__r   T)	r   endswith
issubclassBaseExceptionr&   callablerK   r   AttributeError)modnamenamer   rv   r   r   
is_missing  s*    

z3test_introspect_builtin_modules.<locals>.is_missingz
{}:
    {}z
    z4Missing introspection for the following callables:

z

)r	   rW   	itertoolsoperatorrm   Z	functoolzZ	itertoolzZ	dicttoolzZrecipessetrJ   varsitemsappendrd   formatjoinAssertionError)Zmodsrw   r   missingrt   r   r   r   messagesnamesmsgmessager   rv   r   test_introspect_builtin_modules  s2    




r   c                  C   s   G dd dt } | dd }t|}|tjtdtjjtdtjjgdksVJ t| du sfJ td	d
d fftj	| < t| dksJ tj	| = d S )Nc                   @   s(   e Zd Zdd Zdd Zedd ZdS )z-test_inspect_signature_property.<locals>.AddXc                 S   s
   || _ d S r   rZ   rD   r   r   r   r   __init__  s    z6test_inspect_signature_property.<locals>.AddX.__init__c                 _   s   || j |i | S r   rZ   )rD   addxr)   r*   r   r   r   rE     s    z6test_inspect_signature_property.<locals>.AddX.__call__c                 S   sD   t | j}t|j }t jj}t d|}|g| }|j|dS )Nr   
parameters)	inspect	signaturer   listr   values	ParameterPOSITIONAL_OR_KEYWORDreplace)rD   sigparamskindZnewparamr   r   r   rH     s    
z;test_inspect_signature_property.<locals>.AddX.__signature__N)rJ   rK   rL   r   rE   rM   rH   r   r   r   r   AddX  s   r   c                 S   s   | S r   r   r   r   r   r   r     r   z1test_inspect_signature_property.<locals>.<lambda>r   r   r   Fr   c                 S   s   d S r   r   rZ   r   r   r   r     r   r   )
rO   r   r   	Signaturer   r   r   _sigs
expand_sig
signatures)r   r   r   r   r   r   test_inspect_signature_property  s    
r   c                  C   sv   G dd dt } dd }| |}t|t|ks8J t| d u sHJ tddd fftj| < t| dksrJ d S )Nc                   @   s(   e Zd Zdd Zdd Zedd ZdS )z.test_inspect_wrapped_property.<locals>.Wrappedc                 S   s
   || _ d S r   rZ   r   r   r   r   r     s    z7test_inspect_wrapped_property.<locals>.Wrapped.__init__c                 _   s   | j |i |S r   rZ   )rD   r)   r*   r   r   r   rE     s    z7test_inspect_wrapped_property.<locals>.Wrapped.__call__c                 S   s   | j S r   rZ   rC   r   r   r   __wrapped__  s    z:test_inspect_wrapped_property.<locals>.Wrapped.__wrapped__N)rJ   rK   rL   r   rE   rM   r   r   r   r   r   Wrapped  s   r   c                 S   s   | S r   r   r   r   r   r   r     r   z/test_inspect_wrapped_property.<locals>.<lambda>r   c                 S   s   d S r   r   rZ   r   r   r   r     r   r   )rO   r   r   r   r   r   r   )r   r   wrappedr   r   r   test_inspect_wrapped_property  s    r   )T)%rW   r   r   r   rm   Ztoolz.functoolzr   r   r   r   r   r   r   Ztoolz._signaturesr	   Z_signaturesr   Ztoolz.utilsr
   r   r'   r8   rP   rS   rY   r[   r]   ra   rg   rh   rk   rn   ro   rp   r   r   r   r   r   r   r   <module>   s4   $
CV
(3!