Skip to content

Commit bdc3e01

Browse files
Add check for empty/None values. (#20)
Add check for empty/None values. Co-authored-by: Anubhav Singh <anubhav.singh@logicmonitor.com>
1 parent dfdc2ae commit bdc3e01

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

logicmonitor_data_sdk/api/metrics.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ def send_metrics(self, **kwargs): # noqa: E501
105105
raise TypeError(
106106
"Got an unexpected keyword argument '%s' to method SendMetrics" % key
107107
)
108+
if val is None:
109+
raise ValueError(
110+
"Key '%s' should NOT be None" % key
111+
)
108112
params[key] = val
109113
del params['kwargs']
110114
del params['self']

logicmonitor_data_sdk/models/datasource.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,8 @@ def id(self):
152152

153153
@id.setter
154154
def id(self, id):
155-
if id is not None and id < 0:
156-
raise ValueError("DataSource Id {%s} should not be negative." % id)
155+
if id is not None and (type(id) is not int or id < 0):
156+
raise ValueError("DataSource Id {%s} should not be negative, empty or of type string." % id)
157157
self._id = id
158158

159159
@property

0 commit comments

Comments
 (0)