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.

classmethod 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.

classmethod 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.

classmethod 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.

classmethod 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.

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

Convert optional str to optional int.

class IsoDateTimeScalar¶

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

Iso Date Time Scalar.

Turn a ISO 8601 date time string into datetime. Benchling fields use RFC 3339, unlike app config date times.

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

Convert optional str to optional datetime.

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.

classmethod 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 classmethod 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.

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

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

scalar_definition_from_field_type(field_type: FieldType) → ScalarDefinition¶

Scalar Definition From Field Type.

Returns a ScalarDefinition for parsing a typed value given a field type. Assumes TextScalar (string) for any types not specifically enumerated.