diplomat.processing.type_casters.SingletonConvertibleTypeCaster

class diplomat.processing.type_casters.SingletonConvertibleTypeCaster[source]

Bases: ConvertibleTypeCaster

__init__()[source]

Methods

__init__()

to_metavar()

Convert this type to a CLI-Friendly format for display on the command line as a metavar.

to_type_hint()

Abstract method: Convert this typecaster instance to a regular type hint.

__call__(arg: Any) T

Must be implemented by subclasses. Cast a value to this type.

Parameters:

arg – The value to be casted.

Returns:

The converted value, correctly converted to this type.

Raises:

ValueError – If the passed value can’t be properly converted to this type.

to_metavar() str

Convert this type to a CLI-Friendly format for display on the command line as a metavar.

Returns:

A string, the CLI Friendly format for this type.

to_type_hint() Type

Abstract method: Convert this typecaster instance to a regular type hint.

Returns:

A type from the typing module or primitive, being the underlying type this typecaster converts values to and represents.