
    ,YHh                        d dl mZ d dlmZ d dlmZ d dlmZ d dlmZ d dlm	Z	 d dl
mZ d dl
mZ d d	l
mZ d d
lZd dlmZ d dlmZ erd dlmZ  ed      Z ed      ZdZddZddZdd
d
d	 	 	 	 	 	 	 	 	 ddZy
)    )annotations)Callable)Sequence)wraps)	Parameter)	signature)Any)TYPE_CHECKING)TypeVarN)_validate_two_version)_validate_version)	ParamSpec_P_Ta1  Positional arguments {deprecated_positional_arg_names} in {func_name}() have been deprecated since v{d_ver}. They will be replaced with the corresponding keyword arguments in v{r_ver}, so please use the keyword specification instead. See https://github.com/optuna/optuna/releases/tag/v{d_ver} for details.c                    t        |       j                  }|j                         D cg c]=  \  }}|j                  t        j
                  k(  r|j                  |j                  k(  r|? }}}|S c c}}w N)r   
parametersitemsdefaultr   emptykindPOSITIONAL_OR_KEYWORD)funcparamsnameppositional_arg_namess        X/var/www/html/planif/env/lib/python3.12/site-packages/optuna/_convert_positional_args.py_get_positional_arg_namesr   !   si    t_''F ||~D!99	'AFFa6M6M,M 	 
  s   AA0c                P    t        ||       D ci c]  \  }}||
 }}}|S c c}}w r   )zip)previous_positional_arg_namesargsvalarg_nameinferred_kwargss        r   _infer_kwargsr'   +   s1    :=dDa:bchx}cOc ds   "   )warning_stackleveldeprecated_versionremoved_versionc                     <t        d      t        d      t               t               t               d fd}|S )a  Convert positional arguments to keyword arguments.

    Args:
        previous_positional_arg_names:
            List of names previously given as positional arguments.
        warning_stacklevel:
            Level of the stack trace where decorated function locates.
        deprecated_version:
            The version in which the use of positional arguments is deprecated.
        removed_version:
            The version in which the use of positional arguments will be removed.
    zFdeprecated_version must not be None when removed_version is specified.zFremoved_version must not be None when deprecated_version is specified.c                    t              j                  t        t               j                              s1J t               dt        t               j                                t	               d fd       }|S )Nz is not a subset of c            	        g }t              }t        	g|  }t        |      t        |      kD  rnt        |      t        |      z
  }|j	                  j
                   d| d       s
r2|j	                  t        j                  	j
                  
             |r+t        j                  dj                  |      t               t        |       t        	      kD  r0t        j
                   dt        	       dt        |        d      t        |      j                  |      }t        |      rt        j
                   d	| d
      |j                  |        di |S )Nz() got zQ as positional arguments but they were expected to be given as keyword arguments.)deprecated_positional_arg_names	func_named_verr_ver
)
stacklevelz	() takes z positional arguments but z were given.z%() got multiple values for arguments . )r   r'   lensetappend__name___DEPRECATION_WARNING_TEMPLATEformatwarningswarnjoinFutureWarning	TypeErrorintersectionupdate)r#   kwargswarning_messagesr   r&   expected_kwdsduplicated_kwdsr*   r   r"   r+   r)   s          r   converter_wrapperzOconvert_positional_args.<locals>.converter_decorator.<locals>.converter_wrapperY   s{   !#<T#B +,IQDQO?#c*>&?? #O 4s;O7P P ''}}oW]O <O O
 &$++5<<<Y&*mm"4"1	 =   II./K] 4y3<==}}oYs3P/Q.R S&&)$i[> 
 "&k66GO?#  }}o%J?J[[\]  MM/*>&>!    )r#   r	   rD   r	   returnz'_T')r8   issubsetr   r   r   )r   rH   r*   r"   r+   r)   s   ` r   converter_decoratorz4convert_positional_args.<locals>.converter_decoratorR   s    01::3y?Y?Y;Z[ 	
012 3IdO../02	
[
 
t,	" ,	" 
,	"\ ! rI   )r   'Callable[_P, _T]'rJ   rM   )
ValueErrorr   r   )r"   r)   r*   r+   rL   s   ```` r   convert_positional_argsrO   0   so    ( %)D%X  "X  	,-/*0/B6! 6!p rI   )r   rM   rJ   z	list[str])r"   Sequence[str]r#   r	   rJ   zdict[str, Any])
r"   rP   r)   intr*   
str | Noner+   rR   rJ   z0'Callable[[Callable[_P, _T]], Callable[_P, _T]]')
__future__r   collections.abcr   r   	functoolsr   inspectr   r   typingr	   r
   r   r=   optuna._deprecatedr   optuna._experimentalr   typing_extensionsr   r   r   r;   r   r'   rO   r6   rI   r   <module>r[      s    " $ $         4 2 +	4B	BN    %)"&Z#0Z Z #	Z
  Z 6ZrI   