U
    g                     @   s   U d Z ddlmZmZmZmZ ededZededZG dd dee Z	e	dZ
e	d ed	< e	d
Ze	e ed< e	dZe	e ed< e	dZe	e ed< e	dZe	e ed< e	dZe	e ed< dS )a  This module contains the DefaultValue class.

.. versionchanged:: 20.0
   Previously, the contents of this module were available through the (no longer existing)
   module ``telegram._utils.helpers``.

Warning:
    Contents of this module are intended to be used internally by the library and *not* by the
    user. Changes to this module are not considered breaking changes and may not be documented in
    the changelog.
    )GenericTypeVarUnionoverloadDVType)boundOTc                   @   s   e Zd ZdZdZedddZedddZe	ddd	Z
e	dd
dZeededddZeeeedddZeeedf edddZdS )DefaultValueau  Wrapper for immutable default arguments that allows to check, if the default value was set
    explicitly. Usage::

        default_one = DefaultValue(1)
        def f(arg=default_one):
            if arg is default_one:
                print('`arg` is the default')
                arg = arg.value
            else:
                print('`arg` was set explicitly')
            print(f'`arg` = {str(arg)}')

    This yields::

        >>> f()
        `arg` is the default
        `arg` = 1
        >>> f(1)
        `arg` was set explicitly
        `arg` = 1
        >>> f(2)
        `arg` was set explicitly
        `arg` = 2

    Also allows to evaluate truthiness::

        default = DefaultValue(value)
        if default:
            ...

    is equivalent to::

        default = DefaultValue(value)
        if value:
            ...

    ``repr(DefaultValue(value))`` returns ``repr(value)`` and ``str(DefaultValue(value))`` returns
    ``f'DefaultValue({value})'``.

    Args:
        value (:class:`object`): The value of the default argument
    Attributes:
        value (:class:`object`): The value of the default argument

    valuec                 C   s
   || _ d S Nr
   )selfr    r   @/tmp/pip-unpacked-wheel-swnnwir2/telegram/_utils/defaultvalue.py__init__U   s    zDefaultValue.__init__)returnc                 C   s
   t | jS r   )boolr   r   r   r   r   __bool__X   s    zDefaultValue.__bool__c                 C   s   d| j  dS )NzDefaultValue()r
   r   r   r   r   __str__\   s    zDefaultValue.__str__c                 C   s
   t | jS r   )reprr   r   r   r   r   __repr__`   s    zDefaultValue.__repr__zDefaultValue[OT])objr   c                 C   s   d S r   r   r   r   r   r   	get_valuec   s    zDefaultValue.get_valuec                 C   s   d S r   r   r   r   r   r   r   g   s    c                 C   s   t | tr| jS | S )zShortcut for::

            return obj.value if isinstance(obj, DefaultValue) else obj

        Args:
            obj (:obj:`object`): The object to process

        Returns:
            Same type as input, or the value of the input: The value
        )
isinstancer	   r   r   r   r   r   r   k   s    N)__name__
__module____qualname____doc__	__slots__r   r   r   r   strr   r   r   staticmethodr   r   r   r   r   r   r   r	   $   s   .r	   NDEFAULT_NONEFDEFAULT_FALSETDEFAULT_TRUE   
DEFAULT_20z	127.0.0.1
DEFAULT_IPP   
DEFAULT_80)r    typingr   r   r   r   objectr   r   r	   r$   __annotations__r%   r   r&   r(   intr)   r"   r+   r   r   r   r   <module>   s   V