Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

UNSET values in repr are extremely verbose #825

forest-benchling started this conversation in Feature request
Discussion options

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

You must be logged in to vote

Replies: 3 comments

Comment options

Relevant PEP is still a draft, so, we'll be stuck with UNSET for a long time

You must be logged in to vote
0 replies
Comment options

Maybe it's possible to rely on pydantics unset?

You must be logged in to vote
0 replies
Comment options

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"
You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or improvement
Converted from issue

This discussion was converted from issue #463 on August 13, 2023 01:59.

AltStyle によって変換されたページ (->オリジナル) /