U
    g                     @   s   d Z ddlmZmZmZmZ ddlmZ ddlm	Z	m
Z
 eeeeedddZdefeeeeeeeeeee
f ee egd	f ed
	ddZdeeeeed	dddZd	S )zThis module contains functionality used for transition warnings issued by this library.

It was created to prevent circular imports that would be caused by creating the warnings
inside warnings.py.

.. versionadded:: 20.2
    )AnyCallableTypeUnion)warn)PTBDeprecationWarningPTBUserWarning)deprecated_namenew_nameobject_typebot_api_versionreturnc                 C   s*   d| d|  d| d| d| d|  dS )zBuilds a warning message for the transition in API when an object is renamed.

    Returns a warning message that can be used in `warn` function.
    zThe z 'z' was renamed to 'z' in Bot API z. We recommend using 'z' instead of ''. r	   r
   r   r   r   r   G/tmp/pip-unpacked-wheel-swnnwir2/telegram/_utils/warnings_transition.py!build_deprecation_warning_message    s    (r      N)	deprecated_argnew_argdeprecated_arg_namenew_arg_namer   ptb_version
stacklevelwarn_callbackr   c           	   
   C   sp   | r:|r:| |kr:t ||d|d}td| d| d| | rl|t|d| d| d| d	|d
 d | S |S )a  A helper function for the transition in API when argument is renamed.

    Checks the `deprecated_arg` and `new_arg` objects; warns if non-None `deprecated_arg` object
    was passed. Returns `new_arg` object (either the one originally passed by the user or the one
    that user passed as `deprecated_arg`).

    Raises `ValueError` if both `deprecated_arg` and `new_arg` objects were passed, and they are
    different.
    Z	parameterr   z"You passed different entities as 'z' and 'z'. Bot API z renamed the argument '' to 'r      r   )r   
ValueErrorr   )	r   r   r   r   r   r   r   r   Zbase_messager   r   r   (warn_about_deprecated_arg_return_new_arg3   s(    r    )deprecated_attr_namenew_attr_namer   r   r   r   c              
   C   s.   t t|d| d|  d| d|d d dS )zA helper function for the transition in API when attribute is renamed. Call from properties.

    The properties replace deprecated attributes in classes and issue these deprecation warnings.
    r   z renamed the attribute 'r   r   r   r   N)r   r   )r!   r"   r   r   r   r   r   r   &warn_about_deprecated_attr_in_property`   s    r#   )r   )__doc__typingr   r   r   r   Ztelegram._utils.warningsr   Ztelegram.warningsr   r   strr   intWarningr    r#   r   r   r   r   <module>   s>   2 