U
    bx                     @   s   d Z ddlmZ ddlmZ ddlmZ ddlmZ	 ddl
mZmZmZmZmZ ddlmZ dd	d	d	d	d
dd
dd	ddd
d	dd
d	d	d	d
dddZeZeed
d	dZed	d
d	d
d	d	d	dd	d	d	dddZd
d	d	dddZd
d	dddZd	S )zr
These are Python 3.6+-only and keyword-only APIs that call `attr.s` and
`attr.ib` with different default values.
    )partial   )setters)asdict)astuple)NOTHING_frozen_setattrs_ng_default_on_setattrattribattrs)UnannotatedAttributeErrorNTF)thesereprhashinitslotsfrozenweakref_slotstrauto_attribskw_only
cache_hashauto_exceqorderauto_detectgetstate_setstate
on_setattrfield_transformer
match_argsc                   sX   	
fdd fdd}| dkrL|S || S dS )a  
    Define an ``attrs`` class.

    Differences to the classic `attr.s` that it uses underneath:

    - Automatically detect whether or not *auto_attribs* should be `True`
      (c.f. *auto_attribs* parameter).
    - If *frozen* is `False`, run converters and validators when setting an
      attribute by default.
    - *slots=True* (see :term:`slotted classes` for potentially surprising
      behaviors)
    - *auto_exc=True*
    - *auto_detect=True*
    - *order=False*
    - *match_args=True*
    - Some options that were only relevant on Python 2 or were kept around for
      backwards-compatibility have been removed.

    Please note that these are all defaults and you can change them as you
    wish.

    :param Optional[bool] auto_attribs: If set to `True` or `False`, it behaves
       exactly like `attr.s`. If left `None`, `attr.s` will try to guess:

       1. If any attributes are annotated and no unannotated `attrs.fields`\ s
          are found, it assumes *auto_attribs=True*.
       2. Otherwise it assumes *auto_attribs=False* and tries to collect
          `attrs.fields`\ s.

    For now, please refer to `attr.s` for the rest of the parameters.

    .. versionadded:: 20.1.0
    .. versionchanged:: 21.3.0 Converters are also run ``on_setattr``.
    c                    s2   t | |	 d
dS )NT)	maybe_clsr   r   r   r   r   r   r   r   r   r   r   r   r   r   r   Zcollect_by_mror   r   r   r   )r   )clsr   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r    2/tmp/pip-unpacked-wheel-9rkxrohn/attr/_next_gen.pydo_itR   s.    zdefine.<locals>.do_itc                    s   dt jfk}dkr"dkr"t| jD ]$}|jtkr(|rBtdt j qNq( dk	r`|  S z| dW S  tk
r   | d Y S X dS )z
        Making this a wrapper ensures this code runs during class creation.

        We also ensure that frozen-ness of classes is inherited.
        NFz@Frozen classes can't use on_setattr (frozen-ness was inherited).T)r   ZNO_OPr	   	__bases____setattr__r   
ValueErrorr   )r!   Zhad_on_setattrZbase_cls)r   r$   r   r   r"   r#   wrapk   s"    


zdefine.<locals>.wrapNr"   )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$   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r#   define   s
    :.%r)   )r   r   defaultZ	validatorr   r   r   metadata	converterfactoryr   r   r   r   c                 C   s    t | |||||||||	|
|dS )zx
    Identical to `attr.ib`, except keyword-only and with some arguments
    removed.

    .. versionadded:: 20.1.0
    r*   )r
   r*   r"   r"   r#   field   s    r/   )recursefiltervalue_serializerc                C   s   t | |||ddS )z
    Same as `attr.asdict`, except that collections types are always retained
    and dict is always used as *dict_factory*.

    .. versionadded:: 21.3.0
    T)instr0   r1   r2   retain_collection_types)_asdict)r3   r0   r1   r2   r"   r"   r#   r      s    r   )r0   r1   c                C   s   t | ||ddS )z
    Same as `attr.astuple`, except that collections types are always retained
    and `tuple` is always used as the *tuple_factory*.

    .. versionadded:: 21.3.0
    T)r3   r0   r1   r4   )_astuple)r3   r0   r1   r"   r"   r#   r      s       r   )N)__doc__	functoolsr    r   Z_funcsr   r5   r   r6   _maker   r   r	   r
   r   
exceptionsr   r)   Zmutabler   r/   r"   r"   r"   r#   <module>   sZ    ~%