
    vKg                     R    S r SSKrSSKJr  SSK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Factorypipe)default_if_noneoptionalr   to_boolc                   ^  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'   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" U 5      $ N )val	converters    O/var/www/highfloat_scraper/venv/lib/python3.13/site-packages/attr/converters.pyoptional_converter$optional.<locals>.optional_converter%   s    ;~    r   return)r   get_first_param_typetypingOptional__annotations__get_return_type)r   r   xtrtrts   `    r   r	   r	      sp    
 y
)C  "A4:OOA4F**51				B	7=r7J**84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_converter2default_if_none.<locals>.default_if_none_convertera   s    
??$$r   c                    > U b  U $ T$ r   r   r!   s    r   r#   r$   i   s    
Nr   )r   	TypeErrorr   
isinstance
takes_self
ValueError)r"   r    msgr#   s   `   r   r   r   7   s    4 'go8ng'"5En'"'7##EC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
   r   sJ    8 #siik
;;
==*3'
2C
S/r   )__doc__r   _compatr   _maker   r   r   __all__r	   r   r
   r   r   r   <module>r=      s7   
  ) ) )B $T 8%v%r   