HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/attr/__pycache__/converters.cpython-312.pyc
�

��`���j�dZddlmZmZmZddlmZddlmZm	Z	m
Z
esddlZddlZgd�Z
d�Zedfd	�Zy)
z
Commonly useful converters.
�)�absolute_import�division�print_function�)�PY2)�NOTHING�Factory�pipeN)r
�optional�default_if_nonec����fd�}ts�d}	tj��}|r�t|jj��}|rV|djtjjur-tj|dj|jd<|jtjjur*tj|j|jd<|S#ttf$rY��wxYw)aO
    A converter that allows an attribute to be optional. An optional attribute
    is one which can be set to ``None``.

    Type annotations will be inferred from the wrapped converter's, if it
    has any.

    :param callable converter: the converter that is used for non-``None``
        values.

    .. versionadded:: 17.1.0
    c���|�y�|�S�N�)�val�	converters ��1/usr/lib/python3/dist-packages/attr/converters.py�optional_converterz$optional.<locals>.optional_converter%s����;����~��Nrr�return)r�inspect�	signature�
ValueError�	TypeError�list�
parameters�values�
annotation�	Parameter�empty�typing�Optional�__annotations__�return_annotation�	Signature)rr�sig�paramss`   rrrs�����
���	��#�#�I�.�C���#�.�.�/�/�1�2�F��&��)�.�.�g�6G�6G�6M�6M�M�<B�O�O��1�I�(�(�=�"�2�2�5�9��$�$�G�,=�,=�,C�,C�C�?E����)�)�@�"�2�2�8�<�����I�&�	��	�s�C4�4D�Dc�����tur
|�td���tur
|�td��|�t|��t�t�r�jrtd���fd�}|S�fd�}|S)a�
    A converter that allows to replace ``None`` values by *default* or the
    result of *factory*.

    :param default: Value to be used if ``None`` is passed. Passing an instance
       of `attr.Factory` is supported, however the ``takes_self`` option
       is *not*.
    :param callable factory: A callable that takes no parameters whose result
       is used if ``None`` is passed.

    :raises TypeError: If **neither** *default* or *factory* is passed.
    :raises TypeError: If **both** *default* and *factory* are passed.
    :raises ValueError: If an instance of `attr.Factory` is passed with
       ``takes_self=True``.

    .. versionadded:: 18.2.0
    z(Must pass either `default` or `factory`.z5Must pass either `default` or `factory` but not both.z1`takes_self` is not supported by default_if_none.c�,��|�|S�j�Sr)�factory�r�defaults �r�default_if_none_converterz2default_if_none.<locals>.default_if_none_converteras������
��?�?�$�$rc���|�|S�Srrr+s �rr-z2default_if_none.<locals>.default_if_none_converteris������
��Nr)rrr	�
isinstance�
takes_selfr)r,r*r-s`  rrr>s����$�'��g�o��B�C�C��g��'�"5��C�
�	
����'�"���'�7�#�����C��
�	%�%�$�
	�%�$r)�__doc__�
__future__rrr�_compatr�_makerr	r
rr!�__all__rrrrr�<module>r6s@���A�@��)�)������$�N$�T�1%r