class documentation

class Tuple(CompositeParamType):

View In Hierarchy

The default behavior of Click is to apply a type on a value directly. This works well in most cases, except for when nargs is set to a fixed count and different types should be used for different items. In this case the Tuple type can be used. This type can only be used if nargs is set to a fixed number.

For more information see :ref:`tuple-type`.

This can be selected by using a Python tuple literal as a type.

Parameters
typesa list of types that should be used for the tuple items.
Method __init__ Undocumented
Method convert Convert the value to the correct type. This is not called if the value is None (the missing value).
Method to​_info​_dict Gather information that could be useful for a tool generating user-facing documentation.
Instance Variable types Undocumented
Property arity Undocumented
Property name Undocumented

Inherited from CompositeParamType:

Class Variable is​_composite Undocumented

Inherited from ParamType (via CompositeParamType):

Method __call__ Undocumented
Method fail Helper method to fail with an invalid value message.
Method get​_metavar Returns the metavar default for this param if it provides one.
Method get​_missing​_message Optionally might return extra information about a missing parameter.
Method shell​_complete No summary
Method split​_envvar​_value Given a value from an environment variable this splits it up into small chunks depending on the defined envvar list splitter.
Class Variable envvar​_list​_splitter Undocumented
def __init__(self, types):

Undocumented

Parameters
types:t.Sequence[t.Union[t.Type, ParamType]]Undocumented
def convert(self, value, param, ctx):

Convert the value to the correct type. This is not called if the value is None (the missing value).

This must accept string values from the command line, as well as values that are already the correct type. It may also convert other compatible types.

The param and ctx arguments may be None in certain situations, such as when converting prompt input.

If the value cannot be converted, call fail with a descriptive message.

Parameters
value:t.AnyThe value to convert.
param:t.Optional[Parameter]The parameter that is using this type to convert its value. May be None.
ctx:t.Optional[Context]The current context that arrived at this value. May be None.
Returns
t.AnyUndocumented
def to_info_dict(self):

Gather information that could be useful for a tool generating user-facing documentation.

Use click.Context.to_info_dict to traverse the entire CLI structure.

New in version 8.0.
Returns
t.Dict[str, t.Any]Undocumented
types =

Undocumented

@property
arity: int =

Undocumented

@property
name: str =

Undocumented