HEX
Server: Apache
System: Linux pdx1-shared-a1-38 6.6.104-grsec-jammy+ #3 SMP Tue Sep 16 00:28:11 UTC 2025 x86_64
User: mmickelson (3396398)
PHP: 8.1.31
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/mercurial/thirdparty/attr/__pycache__/validators.cpython-310.pyc
o

�]Lbn�@s�dZddlmZmZmZddlmZmZmZm	Z	gd�Z
edddd�Gd	d
�d
e��Zdd�Z
edddd�Gd
d�de��Zdd�Zedddd�Gdd�de��Zdd�Zedddd�Gdd�de��Zdd�ZdS)z
Commonly useful validators.
�)�absolute_import�division�print_function�)�attr�
attributes�and_�
_AndValidator)r�in_�instance_of�optional�providesFT)�repr�slots�hashc@�"eZdZe�Zdd�Zdd�ZdS)�_InstanceOfValidatorcCs4t||j�stdj|j|j|j|d�||j|��dS)�P
        We use a callable class to be able to change the ``__repr__``.
        z?'{name}' must be {type!r} (got {value!r} that is a {actual!r}).)�name�type�actual�valueN)�
isinstancer�	TypeError�formatr�	__class__��self�instrr�r�F/usr/lib/python3/dist-packages/mercurial/thirdparty/attr/validators.py�__call__s
���z_InstanceOfValidator.__call__cC�dj|jd�S)Nz)<instance_of validator for type {type!r}>�r)rr�rrrr �__repr__$���z_InstanceOfValidator.__repr__N)�__name__�
__module__�__qualname__rrr!r%rrrr rs
rcC�t|�S)a�
    A validator that raises a :exc:`TypeError` if the initializer is called
    with a wrong type for this particular attribute (checks are perfomed using
    :func:`isinstance` therefore it's also valid to pass a tuple of types).

    :param type: The type to check for.
    :type type: type or tuple of types

    :raises TypeError: With a human readable error message, the attribute
        (of type :class:`attr.Attribute`), the expected type, and the value it
        got.
    )rr#rrr r+�
rc@r)�_ProvidesValidatorcCs0|j�|�stdj|j|j|d�||j|��dS)rz<'{name}' must provide {interface!r} which {value!r} doesn't.)r�	interfacerN)r-�
providedByrrrrrrr r!?s���z_ProvidesValidator.__call__cCr")Nz0<provides validator for interface {interface!r}>�r-)rr-r$rrr r%Kr&z_ProvidesValidator.__repr__N)r'r(r)rr-r!r%rrrr r,;sr,cCr*)a
    A validator that raises a :exc:`TypeError` if the initializer is called
    with an object that does not provide the requested *interface* (checks are
    performed using ``interface.providedBy(value)`` (see `zope.interface
    <https://zopeinterface.readthedocs.io/en/latest/>`_).

    :param zope.interface.Interface interface: The interface to check for.

    :raises TypeError: With a human readable error message, the attribute
        (of type :class:`attr.Attribute`), the expected interface, and the
        value it got.
    )r,r/rrr r
Rr+r
c@r)�_OptionalValidatorcCs|durdS|�|||�dS)N��	validatorrrrr r!fsz_OptionalValidator.__call__cCsdjt|j�d�S)Nz'<optional validator for {what} or None>)�what)rrr2r$rrr r%ls
��z_OptionalValidator.__repr__N)r'r(r)rr2r!r%rrrr r0bsr0cCst|t�rtt|��St|�S)a�
    A validator that makes an attribute optional.  An optional attribute is one
    which can be set to ``None`` in addition to satisfying the requirements of
    the sub-validator.

    :param validator: A validator (or a list of validators) that is used for
        non-``None`` values.
    :type validator: callable or :class:`list` of callables.

    .. versionadded:: 15.1.0
    .. versionchanged:: 17.1.0 *validator* can be a list of validators.
    )r�listr0r	r1rrr rss

rc@r)�_InValidatorcCs&||jvrtdj|j|j|d���dS)Nz/'{name}' must be in {options!r} (got {value!r}))r�optionsr)r6�
ValueErrorrrrrrr r!�s
���z_InValidator.__call__cCr")Nz(<in_ validator with options {options!r}>�r6)rr6r$rrr r%�r&z_InValidator.__repr__N)r'r(r)rr6r!r%rrrr r5�sr5cCr*)a�
    A validator that raises a :exc:`ValueError` if the initializer is called
    with a value that does not belong in the options provided.  The check is
    performed using ``value in options``.

    :param options: Allowed options.
    :type options: list, tuple, :class:`enum.Enum`, ...

    :raises ValueError: With a human readable error message, the attribute (of
       type :class:`attr.Attribute`), the expected options, and the value it
       got.

    .. versionadded:: 17.1.0
    )r5r8rrr r
�sr
N)�__doc__�
__future__rrr�_makerrrr	�__all__�objectrrr,r
r0rr5r
rrrr �<module>s