ó
    Eñi  ã                   óV   • S r SSKrSSKJr  SSKJrJrJrJr  / SQr	S r
\S4S jrS	 rg)
z
Commonly useful converters.
é    Né   )Ú_AnnotationExtractor)ÚNOTHINGÚ	ConverterÚFactoryÚpipe)Údefault_if_noneÚoptionalr   Úto_boolc                 ó~  ^ • [        T [        5      (       a  U 4S jnOU 4S jn[        T 5      nUR                  5       nU(       a   [        R
                  U   UR                  S'   UR                  5       nU(       a   [        R
                  U   UR                  S'   [        T [        5      (       a  [        USSS9$ U$ )a;  
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.

Args:
    converter (typing.Callable):
        the converter that is used for non-`None` values.

.. versionadded:: 17.1.0
c                 ó   >• U c  g T" XU5      $ ©N© )ÚvalÚinstÚfieldÚ	converters      €ÚL/home/mande/repo/quber/.venv/lib/python3.13/site-packages/attr/converters.pyÚoptional_converterÚ$optional.<locals>.optional_converter&   s   ø€ Ø‰{ØÙ˜S¨Ó.Ð.ó    c                 ó   >• U c  g T" U 5      $ r   r   )r   r   s    €r   r   r   -   s   ø€ Ø‰{ØÙ˜S“>Ð!r   r   ÚreturnT)Ú
takes_selfÚtakes_field)Ú
isinstancer   r   Úget_first_param_typeÚtypingÚOptionalÚ__annotations__Úget_return_type)r   r   ÚxtrÚtÚrts   `    r   r
   r
      s¡   ø€ ô �)œY×'Ñ'ö	/õ	"ô
 ˜yÓ
)€Cà× Ñ Ó"€AÞÜ4:·O±OÀAÑ4FÐ×*Ñ*¨5Ñ1à	×	Ñ	Ó	€BÞ	Ü7=·±ÀrÑ7JÐ×*Ñ*¨8Ñ4ä�)œY×'Ñ'ÜÐ+¸È$ÑOÐOàÐr   c                 ó
  ^ • T [         L a  Uc  Sn[        U5      eT [         La  Ub  Sn[        U5      eUb  [        U5      m [        T [        5      (       a&  T R                  (       a  Sn[        U5      eU 4S jnU$ U 4S jnU$ )a–  
A converter that allows to replace `None` values by *default* or the result
of *factory*.

Args:
    default:
        Value to be used if `None` is passed. Passing an instance of
        `attrs.Factory` is supported, however the ``takes_self`` option is
        *not*.

    factory (typing.Callable):
        A callable that takes no parameters whose result is used if `None`
        is passed.

Raises:
    TypeError: If **neither** *default* or *factory* is passed.

    TypeError: If **both** *default* and *factory* are passed.

    ValueError:
        If an instance of `attrs.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                 ó.   >• U b  U $ TR                  5       $ r   )Úfactory©r   Údefaults    €r   Údefault_if_none_converterÚ2default_if_none.<locals>.default_if_none_converterl   s   ø€ Ø‰Ø�
à—?‘?Ó$Ð$r   c                 ó   >• U b  U $ T$ r   r   r(   s    €r   r*   r+   t   s   ø€ Ø‰Ø�
àˆNr   )r   Ú	TypeErrorr   r   r   Ú
ValueError)r)   r'   Úmsgr*   s   `   r   r	   r	   B   s‹   ø€ ð4 ”'Ò˜g™oØ8ˆÜ˜‹nÐà”gÒ 'Ñ"5ØEˆÜ˜‹nÐàÑÜ˜'Ó"ˆä�'œ7×#Ñ#Ø××ØEˆCÜ˜S“/Ð!õ	%ð %Ð$õ	ð %Ð$r   c                 óŠ   • [        U [        5      (       a  U R                  5       n U S;   a  gU S;   a  gSU < 3n[        U5      e)a„  
Convert "boolean" strings (for example, from environment variables) to real
booleans.

Values mapping to `True`:

- ``True``
- ``"true"`` / ``"t"``
- ``"yes"`` / ``"y"``
- ``"on"``
- ``"1"``
- ``1``

Values mapping to `False`:

- ``False``
- ``"false"`` / ``"f"``
- ``"no"`` / ``"n"``
- ``"off"``
- ``"0"``
- ``0``

Raises:
    ValueError: For any other value.

.. versionadded:: 21.3.0
)TÚtruer#   ÚyesÚyÚonÚ1r   T)FÚfalseÚfÚnoÚnÚoffÚ0r   FzCannot convert value to bool: )r   ÚstrÚlowerr.   )r   r/   s     r   r   r   }   sJ   € ô8 �#”s×ÑØ�i‰i‹kˆà
Ð;Ó;ØØ
Ð=Ó=Øà*¨3©'Ð
2€CÜ
�S‹/Ðr   )Ú__doc__r   Ú_compatr   Ú_maker   r   r   r   Ú__all__r
   r	   r   r   r   r   Ú<module>rB      s7   ðñó å )ß 4Ó 4ò€ò*ðZ $¨Tô 8%óv%r   