benchling-sdk 1.23.0a4__py3-none-any.whl → 1.23.0a5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
benchling_sdk/errors.py CHANGED
@@ -98,9 +98,11 @@ class RegistrationError(Exception):
98
98
  @classmethod
99
99
  def from_task(cls, task: AsyncTask) -> RegistrationError:
100
100
  """Create a RegistrationError from a failed AsyncTask."""
101
- task_errors = unset_as_none(task.errors)
101
+ task_errors = unset_as_none(lambda: task.errors)
102
102
  errors_dict: Dict[Any, Any] = task_errors.to_dict() if task_errors else dict() # type: ignore
103
- return cls(message=unset_as_none(task.message), errors=errors_dict, task_status=task.status)
103
+ return cls(
104
+ message=unset_as_none(lambda: task.message), errors=errors_dict, task_status=task.status
105
+ )
104
106
 
105
107
  def __str__(self):
106
108
  return repr(self)
@@ -1,6 +1,7 @@
1
1
  from dataclasses import dataclass
2
- from typing import Any, Dict, Iterable, Optional, Type, TypeVar, Union
2
+ from typing import Any, Callable, Dict, Iterable, Optional, Type, TypeVar, Union
3
3
 
4
+ from benchling_api_client.v2.stable.extensions import NotPresentError
4
5
  from benchling_api_client.v2.types import UNSET, Unset
5
6
  from dataclasses_json import DataClassJsonMixin
6
7
 
@@ -83,11 +84,12 @@ def custom_fields(source: Dict[str, Any]) -> CustomFields:
83
84
  return CustomFields.from_dict(source)
84
85
 
85
86
 
86
- def unset_as_none(source: Union[Unset, None, T]) -> Optional[T]:
87
- """Given a value that may be UNSET, produces an Optional[] where UNSET will be treated as None."""
88
- if source is UNSET:
87
+ def unset_as_none(attr_fn: Callable[[], T]) -> Optional[T]:
88
+ """Given an attribute accessor that may raise a NotPresentError, produces an Optional[] where the NotPresentError will be treated as None."""
89
+ try:
90
+ return attr_fn()
91
+ except NotPresentError:
89
92
  return None
90
- return source # type: ignore
91
93
 
92
94
 
93
95
  def schema_fields_query_param(schema_fields: Optional[Dict[str, Any]]) -> Optional[SchemaFieldsQueryParam]:
@@ -108,8 +108,8 @@ class TaskHelper(AsyncTaskLink, Generic[ResponseT]):
108
108
  response = cast(ResponseT, EMPTY_TASK_RESPONSE)
109
109
  else:
110
110
  response = self._response_decoder(task.response.to_dict())
111
- errors = None if task.status != AsyncTaskStatus.FAILED else unset_as_none(task.errors)
112
- message = None if task.status != AsyncTaskStatus.FAILED else unset_as_none(task.message)
111
+ errors = None if task.status != AsyncTaskStatus.FAILED else unset_as_none(lambda: task.errors)
112
+ message = None if task.status != AsyncTaskStatus.FAILED else unset_as_none(lambda:task.message)
113
113
  return TaskCompletion(
114
114
  success=task.status == AsyncTaskStatus.SUCCEEDED,
115
115
  errors=errors, # type: ignore
@@ -221,7 +221,7 @@ class PlateService(BaseService):
221
221
  )
222
222
 
223
223
  def results_extractor(body: PlatesPaginatedList) -> Optional[List[Plate]]:
224
- return unset_as_none(body.plates)
224
+ return unset_as_none(lambda: body.plates)
225
225
 
226
226
  return PageIterator(api_call, results_extractor)
227
227
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: benchling-sdk
3
- Version: 1.23.0a4
3
+ Version: 1.23.0a5
4
4
  Summary: SDK for interacting with the Benchling Platform.
5
5
  License: Apache-2.0
6
6
  Author: Benchling Support
@@ -30,7 +30,7 @@ benchling_sdk/auth/client_credentials_oauth2.py,sha256=fGpQkAmGSYua_kclIhNfHXf6P
30
30
  benchling_sdk/benchling.py,sha256=4HMstGQKfiEpA3U1s7sgUdx1bLKOj41UQxTCyQ5qufU,31779
31
31
  benchling_sdk/docs/__init__.py,sha256=ySHo76PzLndmXOVWrF80VjB5Pi48G82CCQNdzUEzbCY,38
32
32
  benchling_sdk/docs/__main__.py,sha256=1ZlGXdn2gHGC0fAuan5i54mh35VkDf5mhY9VeKNyCRA,244
33
- benchling_sdk/errors.py,sha256=84w3iJjguMmr9ba4YvsK9gfJIJTSBXlKeRIuhN0fstE,8264
33
+ benchling_sdk/errors.py,sha256=mzhwiuxfGJoikxz8ttC4ZmiNvcj72MAgCoWsKZ4C2EQ,8302
34
34
  benchling_sdk/helpers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
35
35
  benchling_sdk/helpers/client_helpers.py,sha256=qAl_Cm8BsUK7-LnNXAR5MEWH3lK2XOv7PzD2Pak6xMk,994
36
36
  benchling_sdk/helpers/constants.py,sha256=dIJ83Qa4grP0n1NixmGNXsh-lK2VG-ioPpBd_AYBmlw,1094
@@ -41,8 +41,8 @@ benchling_sdk/helpers/package_helpers.py,sha256=JLDDdlOwz6_BgP5j157u0qX-Mtb7ZkzX
41
41
  benchling_sdk/helpers/pagination_helpers.py,sha256=Dewy1OxAO0ZdJOGuEPyJGkjU8Hu8iFNWob-z0riMNOs,7745
42
42
  benchling_sdk/helpers/response_helpers.py,sha256=vtmb9lEEKy3dRFre3Q0R4XaLBEaS_rruxtwPvpepPUw,613
43
43
  benchling_sdk/helpers/retry_helpers.py,sha256=Kxd4EqEXB4W833SPfi3cjpDtDDsFyTjY1zw7_mPKz84,2806
44
- benchling_sdk/helpers/serialization_helpers.py,sha256=xXAMRR9lpjeJ09FCNBWSdcu5RZQtu8-ALwn1Nfq9e1A,3677
45
- benchling_sdk/helpers/task_helpers.py,sha256=8Q-lT7vywMv2xNn2eJrtkrueA_UEJp0RZt5sHjz7K40,7504
44
+ benchling_sdk/helpers/serialization_helpers.py,sha256=s8HABBv_S65tYyz-UDJUBnfd9IX9qjjphnJHzs59bcg,3799
45
+ benchling_sdk/helpers/task_helpers.py,sha256=IqFFiWvhFL6rDuBMGm7SGCmU728ZDRWqJxVIVqJZQdc,7519
46
46
  benchling_sdk/helpers/transaction_manager.py,sha256=HcSDsgGK7Rb93bgv6fpb4HvQUT-tqP0lXgVa_bWCDh4,3663
47
47
  benchling_sdk/models/__init__.py,sha256=9x3I2KY_4wrOpIoIO6GabNn5Jn0O_i2V1mQKoQfwm9o,397325
48
48
  benchling_sdk/models/webhooks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -104,7 +104,7 @@ benchling_sdk/services/v2/stable/monomer_service.py,sha256=4BjIz3he2l73scDHGjEze
104
104
  benchling_sdk/services/v2/stable/nucleotide_alignments_service.py,sha256=y6PJLOayljM6MSW8vBGcaKc_WA7W-t11pqfeyhVXWUg,6424
105
105
  benchling_sdk/services/v2/stable/oligo_service.py,sha256=8lupHABhAZ6Jk6-1z0i8w8dklt9AXP-Ns0fIBBbUMLk,12349
106
106
  benchling_sdk/services/v2/stable/organization_service.py,sha256=v-Zd2FG9w8LAuNHq0f2MpreCJ-w3sZyzVU3H4VOov4g,8420
107
- benchling_sdk/services/v2/stable/plate_service.py,sha256=TqCUO9SyaEIoaoDvFk63X-ohvt6zFsXBjb6xflq0a4I,13399
107
+ benchling_sdk/services/v2/stable/plate_service.py,sha256=wyRZhoEJfVeiizbE_t8IgEyq9A-2MA-fJU9FbkOqLpI,13407
108
108
  benchling_sdk/services/v2/stable/printer_service.py,sha256=XhXCwbNAamndWLuHn9UE2ehkkl6vCN5hhxBUvr93Uzk,1181
109
109
  benchling_sdk/services/v2/stable/project_service.py,sha256=Mb3ibiOQJ3uRnJLoDLYgPgrFE80N1bdYQz9LwpbrMtg,4140
110
110
  benchling_sdk/services/v2/stable/registry_service.py,sha256=nwTK4T3qnTS9g613qGYwN_TQPtGUmrha-whWnyQh5m0,4732
@@ -125,7 +125,7 @@ benchling_sdk/services/v2/v2_alpha_service.py,sha256=5lbUv8r_6bRIrV32ZaD8UsZ7xGJ
125
125
  benchling_sdk/services/v2/v2_beta_service.py,sha256=DjmOIZSURH1Q3oAGWnXgQohEiHOOLek3mIoS-wE9YnY,5664
126
126
  benchling_sdk/services/v2/v2_stable_service.py,sha256=X6S55gZJpWSdYZp7vDszanv-r6jDGtPHMV-uJFsn4tc,31365
127
127
  benchling_sdk/services/v2_service.py,sha256=77N3-9YYrgjMUmEQviwPav_nrrUjg7AJppuQmwI5JoM,3092
128
- benchling_sdk-1.23.0a4.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
129
- benchling_sdk-1.23.0a4.dist-info/METADATA,sha256=Sk7FnnL-P9Tgb3xQAN7FJxx_xYlColkJ31QdPaSqbUw,2008
130
- benchling_sdk-1.23.0a4.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
131
- benchling_sdk-1.23.0a4.dist-info/RECORD,,
128
+ benchling_sdk-1.23.0a5.dist-info/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
129
+ benchling_sdk-1.23.0a5.dist-info/METADATA,sha256=zyTTi14biy8mqnMWytd9HRqV0XDkv08pl4HE2Mg_5ek,2008
130
+ benchling_sdk-1.23.0a5.dist-info/WHEEL,sha256=d2fvjOD7sXsVzChCqf0Ty0JbHKBaLYwDbGQDwQTnJ50,88
131
+ benchling_sdk-1.23.0a5.dist-info/RECORD,,