Skip to content

Commit 8ca7d74

Browse files
committed
Adding support for None FlatStore values.
1 parent 8c31dba commit 8ca7d74

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

intercom/lib/flat_store.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,11 @@ def __init__(self, *args, **kwargs):
1212
def __setitem__(self, key, value):
1313
if not (
1414
isinstance(value, numbers.Real) or
15-
isinstance(value, six.string_types)
15+
isinstance(value, six.string_types) or
16+
value is None
1617
):
1718
raise ValueError(
18-
"custom data only allows string and real number values")
19+
"custom data only allows None, string and real number values")
1920
if not isinstance(key, six.string_types):
2021
raise ValueError("custom data only allows string keys")
2122
super(FlatStore, self).__setitem__(key, value)

tests/unit/lib/test_flat_store.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,9 @@ def it_sets_and_merges_valid_entries(self):
3535
data = FlatStore(a=1, b=2)
3636
eq_(data["a"], 1)
3737
eq_(data["b"], 2)
38+
39+
@istest
40+
def it_sets_null_entries(self):
41+
data = FlatStore()
42+
data["a"] = None
43+
eq_(data["a"], None)

0 commit comments

Comments
 (0)