You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add __repr__ for ConditionBase and its subclasses.
Use Case
When writing unit tests using Stubber the error messages are hard to read because if one of the parameter is a ConditionBase we can't see what kind of expression we tried to match on. For example, if we have this in a test:
A failure will say something like "FilterExpression expected conditions.And, got conditions.And" because Python's default __repr__ only outputs the class name and not the fields so Attr('Type').eq('X') & Attr('Type').eq('Y') and Attr('Type').eq('X') & Attr('Type').eq('Z') pretty-prints exactly the same.
Proposed Solution
Add __repr__ implementations to the classes derived from
The string should contain the operator name recursively print the operands. I don't particularly care if it looks like "And(Attr('Type').eq('X'), Attr('Type').eq('Y'))" or something prettier like "Type = X AND Type = Y".
Maybe it can be done using the existing get_expression().
Other Information
No response
Acknowledgements
I may be able to implement this feature request
This feature might incur a breaking change
SDK version used
1.26.81
Environment details (OS name and version, etc.)
Mac/Linux
The text was updated successfully, but these errors were encountered:
Hello and thanks for the feature request. Similar issues have been opened in the past, for example: #3259. The author of that issue also created a PR (#3254) and the initial feedback there was that the logging could be improved using __repr__. However there is now a feature freeze on updates to boto3 resources (see: https://boto3.amazonaws.com/v1/documentation/api/latest/guide/resources.html). For that reason I don't think this will get prioritized.
Describe the feature
Add
__repr__
forConditionBase
and its subclasses.Use Case
When writing unit tests using
Stubber
the error messages are hard to read because if one of the parameter is aConditionBase
we can't see what kind of expression we tried to match on. For example, if we have this in a test:A failure will say something like "
FilterExpression
expectedconditions.And
, gotconditions.And
" because Python's default__repr__
only outputs the class name and not the fields soAttr('Type').eq('X') & Attr('Type').eq('Y')
andAttr('Type').eq('X') & Attr('Type').eq('Z')
pretty-prints exactly the same.Proposed Solution
Add
__repr__
implementations to the classes derived fromboto3/boto3/dynamodb/conditions.py
Line 25 in 3d48469
The string should contain the operator name recursively print the operands. I don't particularly care if it looks like
"And(Attr('Type').eq('X'), Attr('Type').eq('Y'))"
or something prettier like"Type = X AND Type = Y"
.Maybe it can be done using the existing
get_expression()
.Other Information
No response
Acknowledgements
SDK version used
1.26.81
Environment details (OS name and version, etc.)
Mac/Linux
The text was updated successfully, but these errors were encountered: