cloup.constraints._support
¶
Classes summary¶
Create new instance of BoundConstraintSpec(constraint, params) |
|
Create new instance of BoundConstraint(constraint, params) |
|
Provides support to constraints. |
Functions Summary¶
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 (cloup.constraints._core.Constraint) –
params (Sequence[str]) –
-
constraint
:Constraint¶
-
params
:Sequence[str]¶
-
cloup.constraints._support.
constraint
(constr: cloup.constraints._core.Constraint, params: Iterable[str])[source]¶ Registers a constraint.
- Parameters
constr (cloup.constraints._core.Constraint) –
params (Iterable[str]) –
-
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 (cloup.constraints._core.Constraint) –
params (Sequence[click.core.Parameter]) –
-
constraint
:Constraint¶
-
params
:Sequence[Parameter]¶
-
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
constraints (Sequence[cloup.constraints._support.BoundConstraintSpec]) –
show_constraints (bool) –
-
get_param_by_name
(self, name: str) → click.Parameter[source]¶
-
format_help
(self, ctx, formatter: click.HelpFormatter) → None[source]¶