Skip to content

Commit 1226d2b

Browse files
committed
polishing
1 parent 0e2f13c commit 1226d2b

File tree

2 files changed

+24
-22
lines changed

2 files changed

+24
-22
lines changed

splitio/client/config.py

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -180,26 +180,28 @@ def sanitize(sdk_key, config):
180180
return processed
181181

182182
def _sanitize_fallback_config(config, processed):
183-
if config.get('fallbackTreatments') is not None:
184-
if not isinstance(config['fallbackTreatments'], FallbackTreatmentsConfiguration):
185-
_LOGGER.warning('Config: fallbackTreatments parameter should be of `FallbackTreatmentsConfiguration` class.')
186-
processed['fallbackTreatments'] = None
187-
return processed
188-
189-
sanitized_global_fallback_treatment = config['fallbackTreatments'].global_fallback_treatment
190-
if config['fallbackTreatments'].global_fallback_treatment is not None and not validate_fallback_treatment(config['fallbackTreatments'].global_fallback_treatment):
191-
_LOGGER.warning('Config: global fallbacktreatment parameter is discarded.')
192-
sanitized_global_fallback_treatment = None
193-
194-
sanitized_flag_fallback_treatments = {}
195-
if config['fallbackTreatments'].by_flag_fallback_treatment is not None:
196-
for feature_name in config['fallbackTreatments'].by_flag_fallback_treatment.keys():
197-
if not validate_regex_name(feature_name) or not validate_fallback_treatment(config['fallbackTreatments'].by_flag_fallback_treatment[feature_name]):
198-
_LOGGER.warning('Config: fallback treatment parameter for feature flag %s is discarded.', feature_name)
199-
continue
200-
201-
sanitized_flag_fallback_treatments[feature_name] = config['fallbackTreatments'].by_flag_fallback_treatment[feature_name]
202-
203-
processed['fallbackTreatments'] = FallbackTreatmentsConfiguration(sanitized_global_fallback_treatment, sanitized_flag_fallback_treatments)
183+
if config.get('fallbackTreatments') is None:
184+
return processed
185+
186+
if not isinstance(config['fallbackTreatments'], FallbackTreatmentsConfiguration):
187+
_LOGGER.warning('Config: fallbackTreatments parameter should be of `FallbackTreatmentsConfiguration` class.')
188+
processed['fallbackTreatments'] = None
189+
return processed
190+
191+
sanitized_global_fallback_treatment = config['fallbackTreatments'].global_fallback_treatment
192+
if config['fallbackTreatments'].global_fallback_treatment is not None and not validate_fallback_treatment(config['fallbackTreatments'].global_fallback_treatment):
193+
_LOGGER.warning('Config: global fallbacktreatment parameter is discarded.')
194+
sanitized_global_fallback_treatment = None
195+
196+
sanitized_flag_fallback_treatments = {}
197+
if config['fallbackTreatments'].by_flag_fallback_treatment is not None:
198+
for feature_name in config['fallbackTreatments'].by_flag_fallback_treatment.keys():
199+
if not validate_regex_name(feature_name) or not validate_fallback_treatment(config['fallbackTreatments'].by_flag_fallback_treatment[feature_name]):
200+
_LOGGER.warning('Config: fallback treatment parameter for feature flag %s is discarded.', feature_name)
201+
continue
202+
203+
sanitized_flag_fallback_treatments[feature_name] = config['fallbackTreatments'].by_flag_fallback_treatment[feature_name]
204+
205+
processed['fallbackTreatments'] = FallbackTreatmentsConfiguration(sanitized_global_fallback_treatment, sanitized_flag_fallback_treatments)
204206

205207
return processed

splitio/engine/evaluator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def eval_with_context(self, key, bucketing, feature_name, attrs, ctx):
6464
else:
6565
label, _treatment = self._check_prerequisites(feature, bucketing, key, attrs, ctx, label, _treatment)
6666
label, _treatment = self._get_treatment(feature, bucketing, key, attrs, ctx, label, _treatment)
67-
config = feature.get_configurations_for(_treatment) if feature else None
67+
config = feature.get_configurations_for(_treatment)
6868

6969
return {
7070
'treatment': _treatment,

0 commit comments

Comments
 (0)