File tree 1 file changed +12
-3
lines changed
1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change 51
51
)
52
52
53
53
54
+ def _valid_ddb_number (value ):
55
+ try :
56
+ DYNAMODB_CONTEXT .create_decimal (float (value ))
57
+ except Exception :
58
+ return False
59
+ else :
60
+ return True
61
+
62
+
54
63
ddb_string = text (
55
64
min_size = 1 ,
56
65
max_size = MAX_ITEM_BYTES
60
69
61
70
def _ddb_fraction_to_decimal (val ):
62
71
"""Hypothesis does not support providing a custom Context, so working around that."""
63
- return DYNAMODB_CONTEXT . create_decimal ( Decimal (val .numerator ) / Decimal (val .denominator ) )
72
+ return Decimal (val .numerator ) / Decimal (val .denominator )
64
73
65
74
66
75
_ddb_positive_numbers = fractions (
67
76
min_value = POSITIVE_NUMBER_RANGE .min ,
68
77
max_value = POSITIVE_NUMBER_RANGE .max
69
- ).map (_ddb_fraction_to_decimal )
78
+ ).map (_ddb_fraction_to_decimal ). filter ( _valid_ddb_number )
70
79
_ddb_negative_numbers = fractions (
71
80
min_value = NEGATIVE_NUMBER_RANGE .min ,
72
81
max_value = NEGATIVE_NUMBER_RANGE .max
73
- ).map (_ddb_fraction_to_decimal )
82
+ ).map (_ddb_fraction_to_decimal ). filter ( _valid_ddb_number )
74
83
75
84
ddb_number = _ddb_negative_numbers | just (Decimal ('0' )) | _ddb_positive_numbers
76
85
ddb_number_set = sets (ddb_number , min_size = 1 )
You can’t perform that action at this time.
0 commit comments