benchling_sdk.apps.config.scalars module¶

class BoolScalar¶

Bases: benchling_sdk.apps.config.scalars.ScalarDefinition[bool]

Bool Scalar.

Turn a Boolean-like string value into bool. Any permutation of “true” - case insensitive - is interpreted as True. Any other non-empty string is False.

from_str(value: Optional[str]) → Optional[bool]¶

Convert optional str to optional bool.

class DateScalar¶

Bases: benchling_sdk.apps.config.scalars.ScalarDefinition[datetime.date]

Date Scalar.

Turn an ISO formatted date like YYYY-MM-dd into a date.

from_str(value: Optional[str]) → Optional[date]¶

Convert optional str to optional date.

class DateTimeScalar¶

Bases: benchling_sdk.apps.config.scalars.ScalarDefinition[datetime.datetime]

Date Time Scalar.

Turn a date time string into datetime.

static expected_format() → str¶

Return the expected date mask for parsing string to datetime.

from_str(value: Optional[str]) → Optional[datetime]¶

Convert optional str to optional datetime.

class FloatScalar¶

Bases: benchling_sdk.apps.config.scalars.ScalarDefinition[float]

Float Scalar.

Turn a string into float. Assumes the string, if not empty, is a valid floating point.

from_str(value: Optional[str]) → Optional[float]¶

Convert optional str to optional float.

class IntScalar¶

Bases: benchling_sdk.apps.config.scalars.ScalarDefinition[int]

Int Scalar.

Turn a string into int. Assumes the string, if not empty, is a valid integer.

from_str(value: Optional[str]) → Optional[int]¶

Convert optional str to optional int.

class JsonScalar¶

Bases: benchling_sdk.apps.config.scalars.ScalarDefinition[Union[Dict[str, Any], List[Any], str, int, float, bool]]

Json Scalar.

Turn a string into JSON. Assumes the string is a valid JSON string.

from_str(value: Optional[str]) → Optional[Union[Dict[str, Any], List[Any], str, int, float, bool]]¶

Convert optional str to optional JsonType.

class ScalarDefinition¶

Bases: abc.ABC, Generic[benchling_sdk.apps.config.scalars.ScalarType]

Scalar definition.

Map how ScalarConfigTypes values can be converted into corresponding Python types.

abstract from_str(value: Optional[str]) → Optional[benchling_sdk.apps.config.scalars.ScalarType]¶

From string.

Given an optional string value of scalar configuration, produce an Optional instance of the specific ScalarType. For instance, converting str to int.

Used when coercing Python types from string values in API responses.

classmethod init()¶

Init.

class SecureTextScalar¶

Bases: benchling_sdk.apps.config.scalars.TextScalar

Secure Text Scalar.

Text is already a string, so no conversion is performed.

class TextScalar¶

Bases: benchling_sdk.apps.config.scalars.ScalarDefinition[str]

Text Scalar.

Text is already a string, so no conversion is performed.

from_str(value: Optional[str]) → Optional[str]¶

Convert optional str to optional str. Implemented to appease ScalarDefinition contract.