
:mod:`cloup.constraints.conditions`
===================================

.. py:module:: cloup.constraints.conditions

.. autoapi-nested-parse::

   This modules contains predicates with an associated description that you can use
   as conditions of conditional constraints (see :class:`cloup.constraints.If`).

   Predicates should be treated as immutable objects, even though immutability
   is not (at the moment) enforced.





                              
Classes
-------

.. autosummary::

   ~cloup.constraints.conditions.Predicate
   ~cloup.constraints.conditions.Not
   ~cloup.constraints.conditions.IsSet
   ~cloup.constraints.conditions.AllSet
   ~cloup.constraints.conditions.AnySet
   ~cloup.constraints.conditions.Equal


Attributes
----------

.. autoapisummary::

   cloup.constraints.conditions.P

                                           
Contents
--------
.. py:data:: P

.. py:class:: Predicate

   Bases: :py:obj:`abc.ABC`


   A ``Callable`` that takes a ``click.Context`` and returns a boolean, with an
   associated description. Meant to be used as condition in a conditional
   constraint (see :class:`~cloup.constraints.If`).


   .. py:method:: description(ctx)
      :abstractmethod:


      Succinct description of the predicate (alias: `desc`).



   .. py:method:: negated_description(ctx)

      Succinct description of the negation of this predicate (alias: `neg_desc`).



   .. py:method:: desc(ctx)

      Short alias for :meth:`description`.



   .. py:method:: neg_desc(ctx)

      Short alias for :meth:`negated_description`.



   .. py:method:: negated()


   .. py:method:: __call__(ctx)
      :abstractmethod:


      Evaluate the predicate on the given context.



   .. py:method:: __invert__()


   .. py:method:: __or__(other)


   .. py:method:: __and__(other)


   .. py:method:: __repr__()


   .. py:method:: __eq__(other)


.. py:class:: Not(predicate)

   Bases: :py:obj:`Predicate`, :py:obj:`Generic`\ [\ :py:obj:`P`\ ]


   Logical NOT of a predicate.


   .. py:attribute:: predicate


   .. py:method:: description(ctx)

      Succinct description of the predicate (alias: `desc`).



   .. py:method:: negated_description(ctx)

      Succinct description of the negation of this predicate (alias: `neg_desc`).



   .. py:method:: __call__(ctx)

      Evaluate the predicate on the given context.



   .. py:method:: __invert__()


   .. py:method:: __repr__()


.. py:class:: IsSet(param_name)

   Bases: :py:obj:`Predicate`


   True if the parameter is set.


   .. py:attribute:: param_name


   .. py:method:: description(ctx)

      Succinct description of the predicate (alias: `desc`).



   .. py:method:: negated_description(ctx)

      Succinct description of the negation of this predicate (alias: `neg_desc`).



   .. py:method:: __call__(ctx)

      Evaluate the predicate on the given context.



   .. py:method:: __and__(other)


   .. py:method:: __or__(other)


.. py:class:: AllSet(*param_names)

   Bases: :py:obj:`Predicate`


   True if all listed parameters are set.

   .. versionadded:: 0.8.0


   .. py:attribute:: param_names


   .. py:method:: negated_description(ctx)

      Succinct description of the negation of this predicate (alias: `neg_desc`).



   .. py:method:: description(ctx)

      Succinct description of the predicate (alias: `desc`).



   .. py:method:: __call__(ctx)

      Evaluate the predicate on the given context.



   .. py:method:: __and__(other)


.. py:class:: AnySet(*param_names)

   Bases: :py:obj:`Predicate`


   True if any of the listed parameters is set.

   .. versionadded:: 0.8.0


   .. py:attribute:: param_names


   .. py:method:: negated_description(ctx)

      Succinct description of the negation of this predicate (alias: `neg_desc`).



   .. py:method:: description(ctx)

      Succinct description of the predicate (alias: `desc`).



   .. py:method:: __call__(ctx)

      Evaluate the predicate on the given context.



   .. py:method:: __or__(other)


.. py:class:: Equal(param_name, value)

   Bases: :py:obj:`Predicate`


   True if the parameter value equals ``value``.


   .. py:attribute:: param_name


   .. py:attribute:: value


   .. py:method:: description(ctx)

      Succinct description of the predicate (alias: `desc`).



   .. py:method:: negated_description(ctx)

      Succinct description of the negation of this predicate (alias: `neg_desc`).



   .. py:method:: __call__(ctx)

      Evaluate the predicate on the given context.




                                         