-
-
Notifications
You must be signed in to change notification settings - Fork 263
UNSET values in repr are extremely verbose
#825
-
Is your feature request related to a problem? Please describe.
When printing out models, we often get extremely verbose strings, such as:
CustomEntityUpdate(entity_registry_id=<benchling_api_client.types.Unset object at
0x10453d2b0>, author_ids=<benchling_api_client.types.Unset object at 0x10453d2b0>,
aliases=<benchling_api_client.types.Unset object at 0x10453d2b0>, custom_fields=
<benchling_api_client.types.Unset object at 0x10453d2b0>,
fields=Fields(additional_properties={'Request 1': Field(value='test_plate',
display_value=<benchling_api_client.types.Unset object at 0x10453d2b0>, is_multi=
<benchling_api_client.types.Unset object at 0x10453d2b0>, text_value=
<benchling_api_client.types.Unset object at 0x10453d2b0>, type=
<benchling_api_client.types.Unset object at 0x10453d2b0>), 'Request 2':
Field(value='test_plate', display_value=<benchling_api_client.types.Unset object at
0x10453d2b0>, is_multi=<benchling_api_client.types.Unset object at 0x10453d2b0>,
text_value=<benchling_api_client.types.Unset object at 0x10453d2b0>, type=
<benchling_api_client.types.Unset object at 0x10453d2b0>), 'Request 3':
Field(value='test_plate', display_value=<benchling_api_client.types.Unset object at
0x10453d2b0>, is_multi=<benchling_api_client.types.Unset object at 0x10453d2b0>,
text_value=<benchling_api_client.types.Unset object at 0x10453d2b0>, type=
<benchling_api_client.types.Unset object at 0x10453d2b0>)}), folder_id=
<benchling_api_client.types.Unset object at 0x10453d2b0>, name=
<benchling_api_client.types.Unset object at 0x10453d2b0>, schema_id=
<benchling_api_client.types.Unset object at 0x10453d2b0>)
This makes debugging much more challenging.
Describe the solution you'd like
Ideally it would print
CustomEntityUpdate(fields=Fields(additional_properties={'Request 1':
Field(value='test_plate'), 'Request 2': Field(value='test_plate'), 'Request 3':
Field(value='test_plate')}))
Describe alternatives you've considered
It would also be an improvement if the repr of UNSET itself was shortened. I know @dbanty mentioned a PEP a while back that would allow us to make it a sentinel.
Additional context
cc @GitOnUp
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 2
Replies: 3 comments
-
Relevant PEP is still a draft, so, we'll be stuck with UNSET for a long time
Beta Was this translation helpful? Give feedback.
All reactions
-
Maybe it's possible to rely on pydantics unset?
Beta Was this translation helpful? Give feedback.
All reactions
-
A sentinal will be useful later, but defining __repr__ would be better than the current state. Can we do this for now?
class Unset: def __bool__(self) -> Literal[False]: return False def __str__(self) -> str: return "<UNSET>" def __repr__(self) -> str: return "UNSET"
Beta Was this translation helpful? Give feedback.