Your IP : 3.144.3.235


Current Path : /opt/alt/python37/lib/python3.7/site-packages/attr/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib/python3.7/site-packages/attr/__pycache__/converters.cpython-37.pyc

B

�.`��@spdZddlmZmZmZddlmZddlmZm	Z	m
Z
esLddlZddlZddd	gZ
d
d�Zedfdd	�ZdS)z
Commonly useful converters.
�)�absolute_import�division�print_function�)�PY2)�NOTHING�Factory�pipeNr	�optional�default_if_nonec	s��fdd�}ts�d}yt���}Wnttfk
r:YnX|r�t|j���}|rz|djtj	j
k	rztj|dj|j
d<|jtjj
k	r�tj|j|j
d<|S)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
    cs|dkrdS�|�S)N�)�val)�	converterr�@/opt/alt/python37/lib/python3.7/site-packages/attr/converters.py�optional_converter%sz$optional.<locals>.optional_converterNrr
�return)r�inspect�	signature�
ValueError�	TypeError�list�
parameters�values�
annotation�	Parameter�empty�typing�Optional�__annotations__�return_annotation�	Signature)rr�sig�paramsr)rrr
s csv�tkr|dkrtd���tk	r0|dk	r0td��|dk	r@t|��t�t�rf�jrXtd���fdd�}n�fdd�}|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
    Nz(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.cs|dk	r|S���S)N)�factory)r
)�defaultrr�default_if_none_converterasz2default_if_none.<locals>.default_if_none_convertercs|dk	r|S�S)Nr)r
)r$rrr%is)rrr�
isinstanceZ
takes_selfr)r$r#r%r)r$rr>s
)�__doc__�
__future__rrr�_compatr�_makerrr	rr�__all__r
rrrrr�<module>s'

?>