cloup.constraints._support

Classes

BoundConstraintSpec(constraint, params)

A NamedTuple storing a Constraint and the names of the parameters if has check.

BoundConstraint(constraint, params)

Internal utility NamedTuple that represents a Constraint bound to a collection of Parameter instances.

ConstraintMixin(*args[, constraints, …])

Provides support to constraints.

Functions

constraint(constr, params)

Registers a constraint.

ensure_constraints_support(command)

Contents

class cloup.constraints._support.BoundConstraintSpec[source]

Bases: NamedTuple

A NamedTuple storing a Constraint and the names of the parameters if has check.

Parameters
constraint :cloup.constraints._core.Constraint
params :Sequence[str]
cloup.constraints._support.constraint(constr, params)[source]

Registers a constraint.

Parameters
class cloup.constraints._support.BoundConstraint[source]

Bases: NamedTuple

Internal utility NamedTuple that represents a Constraint bound to a collection of Parameter instances. Note: this is not a subclass of Constraint.

Parameters
constraint :cloup.constraints._core.Constraint
params :Sequence[click.Parameter]
check_consistency(self)[source]
check_values(self, ctx)[source]
Parameters

ctx (click.Context) –

get_help_record(self, ctx)[source]
Parameters

ctx (click.Context) –

Return type

Optional[Tuple[str, str]]

class cloup.constraints._support.ConstraintMixin(*args, constraints=(), show_constraints=None, **kwargs)[source]

Provides support to constraints.

Parameters
parse_args(self, ctx, args)[source]
get_param_by_name(self, name)[source]
Parameters

name (str) –

Return type

click.Parameter

get_params_by_name(self, names)[source]
Parameters

names (Iterable[str]) –

Return type

Sequence[click.Parameter]

format_constraints(self, ctx, formatter)[source]
Return type

None

format_help(self, ctx, formatter)[source]
Parameters

formatter (click.HelpFormatter) –

Return type

None

cloup.constraints._support.ensure_constraints_support(command)[source]
Return type

cloup.constraints._support.ConstraintMixin