UNSET and unset type undefined in SDK

Abby P
Abby P
  • Updated

Issue/background

When entities are created via API and a field value is not defined, Benchling assigns it a specific value type called "UNSET". This is to differentiate unset values from values set to zero, null, NA, or none.

Per our documentation (https://docs.benchling.com/docs/common-sdk-interactions-and-examples), there is a function called `unset_as_none`. If encountering issues with this data type, be sure you are importing the following below:

 

Environment

SDK

 

Cause

Missing import statement (highlighted below) that defines Unset and UNSET

from typing import Union
from benchling_sdk.helpers.serialization_helpers import unset_as_none
from benchling_api_client.types import Unset, UNSET

sample_value: Union[Unset, None, int] = UNSET
optional_value = unset_as_none(sample_value)# optional_value will be None

 

Resolution steps

Include `from benchling_api_client.types import Unset, UNSET`

Was this article helpful?

Have more questions? Submit a request