@@ -22,7 +22,7 @@ class User:
22
22
Usually corresponding to a user of your application.
23
23
"""
24
24
25
- def __init__ (self , attrs : Dict [str , str ] = None ,
25
+ def __init__ (self , attrs : Dict [str , any ] = None ,
26
26
stable_rollout_key : str = None ):
27
27
"""Creates a new FeatureProbe User.
28
28
@@ -33,9 +33,9 @@ def __init__(self, attrs: Dict[str, str] = None,
33
33
self ._key = stable_rollout_key
34
34
else :
35
35
self ._key = str (int (time .time () * 10 ** 6 ))
36
- self ._attrs = attrs or {}
36
+ self ._attrs = { k : str ( v ) for k , v in ( attrs or {}). items () }
37
37
38
- def __setitem__ (self , key : str , value : str ):
38
+ def __setitem__ (self , key : str , value : any ):
39
39
"""Alias for :func:`~featureprobe.User.with_attr`.
40
40
41
41
Usage::
@@ -45,7 +45,7 @@ def __setitem__(self, key: str, value: str):
45
45
>>> user.with_attr('key1', 'value1')
46
46
>>> user['key2'] = 'value2'
47
47
"""
48
- self ._attrs [key ] = value
48
+ self ._attrs [key ] = str ( value )
49
49
50
50
def __getitem__ (self , attr : str ):
51
51
"""Gets the value of specified attribute.
@@ -92,7 +92,7 @@ def attrs(self, attrs: Dict[str, str]):
92
92
"""Sets (replace the original attributes) multiple attributes to a FeatureProbe User"""
93
93
self ._attrs = attrs
94
94
95
- def with_attr (self , key : str , value : str ) -> "User" :
95
+ def with_attr (self , key : str , value : any ) -> "User" :
96
96
"""Adds an attribute to the user.
97
97
98
98
:param key: Attribute key / name.
@@ -104,7 +104,7 @@ def with_attr(self, key: str, value: str) -> "User":
104
104
>>> import featureprobe as fp
105
105
>>> user = fp.User('unique id').with_attr('key1', 'value1').with_attr('key2', 'value2')
106
106
"""
107
- self ._attrs [key ] = value
107
+ self ._attrs [key ] = str ( value )
108
108
return self
109
109
110
110
def has_attr (self , attr : str ) -> bool :
0 commit comments