
    ii                        d dl mZ d dl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 dZ e	d          Z ed	          Zed
         Zdddddd%dZddddddd&dZddddddd'd$ZdS )(    )annotationsNwraps)AnyCallableLiteralTypeVar)warn)	ParamSpec)check_for_deprecated_parameters
deprecatedwarn_deprecationTP)	functionmethodclassmethod	attributepropertydefaultclass	parameterimportF)
removal_inalternativeinfopendingversionstrdeprecated_namekindDeprecatedKindr   
str | Noner   r   r   boolreturnNonec                  g }|dk    rd}n	|dv rd}nd}|r|                     | d| d|           n|                     | d| d|           |                    d	|  d
| d|pd f           |r|                     d|d           |r|                     |           d                    |          }	|rt          nt          }
t          |	|
d           dS )a  Warn about a call to a (soon to be) deprecated function.

    Args:
        version: Polyfactory version where the deprecation will occur.
        deprecated_name: Name of the deprecated function.
        removal_in: Polyfactory version where the deprecated function will be removed.
        alternative: Name of a function that should be used instead.
        info: Additional information.
        pending: Use ``PendingDeprecationWarning`` instead of ``DeprecationWarning``.
        kind: Type of the deprecated thing.
    r   z	Import of>   r   r   zCall tozUse of z awaiting deprecation z deprecated zDeprecated in polyfactory zThis z will be removed in zthe next major versionzUse z insteadz.    )
stacklevelN)appendextendjoinPendingDeprecationWarningDeprecationWarningr
   )r   r    r!   r   r   r   r   partsaccess_typetextwarning_classs              u/var/www/development/aibuddy-work/election-extract/venv/lib/python3.11/site-packages/polyfactory/utils/deprecation.pyr   r      sM   * Ex!	'	'	' MUUdUU/UUVVVVKKKKKKLLL	LL222VDVVj.T<TVV	
    53K333444 T99UD18P-->PM}++++++    )r   r   r   r   r!   ?Literal['function', 'method', 'classmethod', 'property'] | None*Callable[[Callable[P, T]], Callable[P, T]]c               (     d fd}|S )a  Create a decorator wrapping a function, method or property with a warning call about a (pending) deprecation.

    Args:
        version: Polyfactory version where the deprecation will occur.
        removal_in: Polyfactory version where the deprecated function will be removed.
        alternative: Name of a function that should be used instead.
        info: Additional information.
        pending: Use ``PendingDeprecationWarning`` instead of ``DeprecationWarning``.
        kind: Type of the deprecated callable. If ``None``, will use ``inspect`` to figure
            out if it's a function or method.

    Returns:
        A decorator wrapping the function call with a warning
    funcCallable[P, T]r%   c           	     L     t                     d fd            }|S )	NargsP.argskwargsP.kwargsr%   r   c                 z    t          j        pt          j                  rdnd            | i |S )Nr   r   r   r    r   r   r   r   r!   )r   __name__inspectismethod)	r<   r>   r   r9   r   r!   r   r   r   s	     r4   wrappedz.deprecated.<locals>.decorator.<locals>.wrappedb   sa     $'%Q'*:4*@*@Phhj    4((((r5   )r<   r=   r>   r?   r%   r   r   )r9   rE   r   r   r!   r   r   r   s   ` r4   	decoratorzdeprecated.<locals>.decoratora   sW    	t
	) 
	) 
	) 
	) 
	) 
	) 
	) 
	) 
	) 
	) 
	) 

	) r5   )r9   r:   r%   r:    )r   r   r   r   r   r!   rF   s   `````` r4   r   r   I   sG    0            r5   )default_valuer   r   r   r   
parameterstuple[tuple[str, Any], ...]rH   r   c          
     P    |D ]"\  }}||k    rt          | |||||d           #dS )a  Warn about a call to a (soon to be) deprecated argument to a function.

    Args:
        version: Polyfactory version where the deprecation will occur.
        parameters: Parameters to trigger warning if used.
        default_value: Default value for parameter to detect if supplied or not.
        removal_in: Polyfactory version where the deprecated function will be removed.
        alternative: Name of a function that should be used instead.
        info: Additional information.
        pending: Use ``PendingDeprecationWarning`` instead of ``DeprecationWarning``.
        kind: Type of the deprecated callable. If ``None``, will use ``inspect`` to figure
            out if it's a function or method.
    r   rA   N)r   )	r   rI   rH   r   r   r   r   parameter_namevalues	            r4   r   r   t   sa    . ", 
 
M!!*#!	
 	
 	
 	
 	
	
 
r5   )r   r   r    r   r!   r"   r   r#   r   r#   r   r#   r   r$   r%   r&   )r   r   r   r#   r   r#   r   r#   r   r$   r!   r6   r%   r7   )r   r   rI   rJ   rH   r   r   r#   r   r#   r   r#   r   r$   r%   r&   )
__future__r   rC   	functoolsr   typingr   r   r   r	   warningsr
   typing_extensionsr   __all__r   r   r"   r   r   r   rG   r5   r4   <module>rT      s>   " " " " " "        2 2 2 2 2 2 2 2 2 2 2 2       ' ' ' ' ' '
O GCLLIcNNk ""2, 2, 2, 2, 2, 2,p ""LP( ( ( ( ( (^ !"#
 #
 #
 #
 #
 #
 #
 #
r5   