cloup.constraints._support

Classes summary

cloup.constraints._support.BoundConstraintSpec(…)

Create new instance of BoundConstraintSpec(constraint, params)

cloup.constraints._support.BoundConstraint(…)

Create new instance of BoundConstraint(constraint, params)

cloup.constraints._support.ConstraintMixin(*args)

Provides support to constraints.

Functions Summary

cloup.constraints._support.constraint(…)

Registers a constraint.

Contents

class cloup.constraints._support.BoundConstraintSpec[source]

Bases: typing.NamedTuple

Typed version of namedtuple.

Usage in Python versions >= 3.6:

class Employee(NamedTuple):
    name: str
    id: int

This is equivalent to:

Employee = collections.namedtuple('Employee', ['name', 'id'])

The resulting class has an extra __annotations__ attribute, giving a dict that maps field names to types. (The field names are also in the _fields attribute, which is part of the namedtuple API.) Alternative equivalent keyword syntax is also accepted:

Employee = NamedTuple('Employee', name=str, id=int)

In Python versions <= 3.5 use:

Employee = NamedTuple('Employee', [('name', str), ('id', int)])
Parameters
constraint :Constraint
params :Sequence[str]
cloup.constraints._support.constraint(constr: cloup.constraints._core.Constraint, params: Iterable[str])[source]

Registers a constraint.

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

Bases: typing.NamedTuple

Typed version of namedtuple.

Usage in Python versions >= 3.6:

class Employee(NamedTuple):
    name: str
    id: int

This is equivalent to:

Employee = collections.namedtuple('Employee', ['name', 'id'])

The resulting class has an extra __annotations__ attribute, giving a dict that maps field names to types. (The field names are also in the _fields attribute, which is part of the namedtuple API.) Alternative equivalent keyword syntax is also accepted:

Employee = NamedTuple('Employee', name=str, id=int)

In Python versions <= 3.5 use:

Employee = NamedTuple('Employee', [('name', str), ('id', int)])
Parameters
constraint :Constraint
params :Sequence[Parameter]
check_consistency(self)[source]
check_values(self, ctx: click.Context)[source]
get_help_record(self, ctx: click.Context) → Optional[Tuple[str, str]][source]
class cloup.constraints._support.ConstraintMixin(*args, constraints: Sequence[BoundConstraintSpec] = (), show_constraints: bool = False, **kwargs)[source]

Provides support to constraints.

Parameters
parse_args(self, ctx, args)[source]
get_param_by_name(self, name: str)click.Parameter[source]
get_params_by_name(self, names: Iterable[str]) → List[Parameter][source]
format_constraints(self, ctx, formatter)None[source]
format_help(self, ctx, formatter: click.HelpFormatter)None[source]