Skip to content

Commit 0a0b6d0

Browse files
author
Matias Melograno
committed
code improvements
1 parent cedbd77 commit 0a0b6d0

File tree

4 files changed

+348
-326
lines changed

4 files changed

+348
-326
lines changed

splitio/clients.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from splitio.metrics import SDK_GET_TREATMENT
1111
from splitio.splits import ConditionType
1212
from splitio.events import Event
13-
from splitio.input_validator import InputValidator
13+
from . import input_validator
1414
from splitio.key import Key
1515

1616

@@ -66,13 +66,12 @@ def get_treatment(self, key, feature, attributes=None):
6666

6767
start = int(round(time.time() * 1000))
6868

69-
input_validator = InputValidator()
7069
matching_key, bucketing_key = input_validator.validate_key(key)
7170
feature = input_validator.validate_feature_name(feature)
7271

73-
if ((matching_key is None and bucketing_key is None) or (feature is None)):
72+
if (matching_key is None and bucketing_key is None) or feature is None:
7473
impression = self._build_impression(matching_key, feature, CONTROL, Label.EXCEPTION,
75-
0, None, start)
74+
0, bucketing_key, start)
7675
self._record_stats(impression, start, SDK_GET_TREATMENT)
7776
return CONTROL
7877

@@ -238,7 +237,6 @@ def track(self, key, traffic_type, event_type, value=None):
238237
239238
:rtype: bool
240239
"""
241-
input_validator = InputValidator()
242240
key = input_validator.validate_track_key(key)
243241
event_type = input_validator.validate_event_type(event_type)
244242
traffic_type = input_validator.validate_traffic_type(traffic_type)
@@ -296,11 +294,10 @@ def get_treatment(self, key, feature, attributes=None):
296294
:param attributes: (Optional) attributes associated with the user key
297295
:type attributes: dict
298296
"""
299-
input_validator = InputValidator()
300297
matching_key, bucketing_key = input_validator.validate_key(key)
301298
feature = input_validator.validate_feature_name(feature)
302299

303-
if ((matching_key is None and bucketing_key is None) or feature is None):
300+
if (matching_key is None and bucketing_key is None) or feature is None:
304301
return CONTROL
305302

306303
try:

0 commit comments

Comments
 (0)