Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ git:

matrix:
include:
- python: '2.7'
- python: '3.6'
after_success:
- bash sonar-scanner.sh
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
'pyyaml>=5.1',
'future>=0.15.2',
'docopt>=0.6.2',
'six>=1.10.0',
'enum34;python_version<"3.4"',
'futures>=3.0.5;python_version<"3"'
]
Expand Down
7 changes: 3 additions & 4 deletions splitio/api/telemetry.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Telemetry API Module."""
import logging

import six
from future.utils import raise_from

from splitio.api import APIException, headers_from_metadata
Expand Down Expand Up @@ -39,7 +38,7 @@ def _build_latencies(latencies):
"""
return [
{'name': name, 'latencies': latencies_list}
for name, latencies_list in six.iteritems(latencies)
for name, latencies_list in latencies.items()
]

def flush_latencies(self, latencies):
Expand Down Expand Up @@ -77,7 +76,7 @@ def _build_gauges(gauges):
"""
return [
{'name': name, 'value': value}
for name, value in six.iteritems(gauges)
for name, value in gauges.items()
]

def flush_gauges(self, gauges):
Expand Down Expand Up @@ -115,7 +114,7 @@ def _build_counters(counters):
"""
return [
{'name': name, 'delta': value}
for name, value in six.iteritems(counters)
for name, value in counters.items()
]

def flush_counters(self, counters):
Expand Down
3 changes: 1 addition & 2 deletions splitio/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import logging
import time
import six
from splitio.engine.evaluator import Evaluator, CONTROL
from splitio.engine.splitters import Splitter
from splitio.models.impressions import Impression, Label
Expand Down Expand Up @@ -309,7 +308,7 @@ def get_treatments(self, key, features, attributes=None):
"""
with_config = self._make_evaluations(key, features, attributes, 'get_treatments',
self._METRIC_GET_TREATMENTS)
return {feature: result[0] for (feature, result) in six.iteritems(with_config)}
return {feature: result[0] for (feature, result) in with_config.items()}

def _build_impression( # pylint: disable=too-many-arguments
self,
Expand Down
16 changes: 7 additions & 9 deletions splitio/client/input_validator.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import re
import math

import six

from splitio.api import APIException
from splitio.client.key import Key
from splitio.engine.evaluator import CONTROL
Expand Down Expand Up @@ -53,7 +51,7 @@ def _check_is_string(value, name, operation):
:return: The result of validation
:rtype: True|False
"""
if isinstance(value, six.string_types) is False:
if isinstance(value, str) is False:
_LOGGER.error(
'%s: you passed an invalid %s, %s must be a non-empty string.',
operation, name, name
Expand Down Expand Up @@ -121,7 +119,7 @@ def _check_can_convert(value, name, operation):
:return: The result of validation
:rtype: None|string
"""
if isinstance(value, six.string_types):
if isinstance(value, str):
return value
else:
# check whether if isnan and isinf are really necessary
Expand Down Expand Up @@ -173,7 +171,7 @@ def _check_valid_object_key(key, name, operation):
'%s: you passed a null %s, %s must be a non-empty string.',
operation, name, name)
return None
if isinstance(key, six.string_types):
if isinstance(key, str):
if not _check_string_not_empty(key, name, operation):
return None
key_str = _check_can_convert(key, name, operation)
Expand Down Expand Up @@ -515,8 +513,8 @@ def valid_properties(properties):

valid_properties = dict()

for property, element in six.iteritems(properties):
if not isinstance(property, six.string_types): # Exclude property if is not string
for property, element in properties.items():
if not isinstance(property, str): # Exclude property if is not string
continue

valid_properties[property] = None
Expand All @@ -525,14 +523,14 @@ def valid_properties(properties):
if element is None:
continue

if not isinstance(element, six.string_types) and not isinstance(element, Number) \
if not isinstance(element, str) and not isinstance(element, Number) \
and not isinstance(element, bool):
_LOGGER.warning('Property %s is of invalid type. Setting value to None', element)
element = None

valid_properties[property] = element

if isinstance(element, six.string_types):
if isinstance(element, str):
size += len(element)

if size > MAX_PROPERTIES_LENGTH_BYTES:
Expand Down
4 changes: 1 addition & 3 deletions splitio/client/listener.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import abc

from six import add_metaclass
from future.utils import raise_from


Expand Down Expand Up @@ -56,8 +55,7 @@ def log_impression(self, impression, attributes=None):
exc
)

@add_metaclass(abc.ABCMeta) #pylint: disable=too-few-public-methods
class ImpressionListener(object):
class ImpressionListener(object, metaclass=abc.ABCMeta):
"""Impression listener interface."""

@abc.abstractmethod
Expand Down
3 changes: 1 addition & 2 deletions splitio/engine/evaluator.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Split evaluator module."""
import logging
import six
from splitio.models.grammar.condition import ConditionType
from splitio.models.impressions import Label

Expand Down Expand Up @@ -135,7 +134,7 @@ def evaluate_features(self, features, matching_key, bucketing_key, attributes=No
return {
feature: self._evaluate_treatment(feature, matching_key,
bucketing_key, attributes, split)
for (feature, split) in six.iteritems(self._split_storage.fetch_many(features))
for (feature, split) in self._split_storage.fetch_many(features).items()
}

def _get_treatment_for_split(self, split, matching_key, bucketing_key, attributes=None):
Expand Down
3 changes: 0 additions & 3 deletions splitio/engine/hashfns/murmur3py.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
from __future__ import absolute_import, division, print_function, \
unicode_literals

from six.moves import range


def murmur32_py(key, seed=0x0):
"""
Pure python implementation of murmur32 hash.
Expand Down
4 changes: 1 addition & 3 deletions splitio/engine/impressions.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
from collections import defaultdict, namedtuple
from enum import Enum

import six

from splitio.models.impressions import Impression
from splitio.engine.hashfns import murmur_128
from splitio.engine.cache.lru import SimpleLruCache
Expand Down Expand Up @@ -151,7 +149,7 @@ def pop_all(self):
self._data = defaultdict(lambda: 0)

return [Counter.CountPerFeature(k.feature, k.timeframe, v)
for (k, v) in six.iteritems(old)]
for (k, v) in old.items()]


class Manager(object): # pylint:disable=too-few-public-methods
Expand Down
3 changes: 1 addition & 2 deletions splitio/models/grammar/condition.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from enum import Enum
from future.utils import python_2_unicode_compatible
import six

from splitio.models.grammar import matchers
from splitio.models.grammar import partitions
Expand Down Expand Up @@ -103,7 +102,7 @@ def to_json(self):
'label': self._label,
'matcherGroup': {
'combiner': next(
(k, v) for k, v in six.iteritems(_MATCHER_COMBINERS) if v == self._combiner
(k, v) for k, v in _MATCHER_COMBINERS.items() if v == self._combiner
)[0],
'matchers': [m.to_json() for m in self.matchers]
},
Expand Down
5 changes: 1 addition & 4 deletions splitio/models/grammar/matchers/base.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
"""Abstract matcher module."""
import abc

from six import add_metaclass

from splitio.client.key import Key


@add_metaclass(abc.ABCMeta)
class Matcher(object):
class Matcher(object, metaclass=abc.ABCMeta):
"""Matcher abstract class."""

def __init__(self, raw_matcher):
Expand Down
3 changes: 1 addition & 2 deletions splitio/models/grammar/matchers/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import json
from future.utils import python_2_unicode_compatible
from six import string_types

from splitio.models.grammar.matchers.base import Matcher

Expand Down Expand Up @@ -85,7 +84,7 @@ def _match(self, key, attributes=None, context=None):
return False
if isinstance(matching_data, bool):
decoded = matching_data
elif isinstance(matching_data, string_types):
elif isinstance(matching_data, str):
try:
decoded = json.loads(matching_data.lower())
if not isinstance(decoded, bool):
Expand Down
3 changes: 1 addition & 2 deletions splitio/models/grammar/matchers/numeric.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

import logging
from future.utils import python_2_unicode_compatible
from six import string_types

from splitio.models.grammar.matchers.base import Matcher
from splitio.models import datatypes
Expand Down Expand Up @@ -32,7 +31,7 @@ def ensure_int(cls, data):
if isinstance(data, numbers.Integral) and not isinstance(data, bool):
return data

if not isinstance(data, string_types):
if not isinstance(data, str):
_LOGGER.error('Cannot convert %s to int. Failing.', type(data))
return None

Expand Down
9 changes: 4 additions & 5 deletions splitio/models/grammar/matchers/string.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import json
import re
from future.utils import python_2_unicode_compatible
from six import string_types

from splitio.models.grammar.matchers.base import Matcher

Expand All @@ -31,7 +30,7 @@ def ensure_string(cls, data):
if data is None: # Failed to fetch attribute. no need to convert.
return None

if isinstance(data, string_types):
if isinstance(data, str):
return data

_LOGGER.warning(
Expand Down Expand Up @@ -120,7 +119,7 @@ def _match(self, key, attributes=None, context=None):
matching_data = Sanitizer.ensure_string(self._get_matcher_input(key, attributes))
if matching_data is None:
return False
return (isinstance(key, string_types) and
return (isinstance(key, str) and
any(matching_data.startswith(s) for s in self._whitelist))

def _add_matcher_specific_properties_to_json(self):
Expand Down Expand Up @@ -168,7 +167,7 @@ def _match(self, key, attributes=None, context=None):
matching_data = Sanitizer.ensure_string(self._get_matcher_input(key, attributes))
if matching_data is None:
return False
return (isinstance(key, string_types) and
return (isinstance(key, str) and
any(matching_data.endswith(s) for s in self._whitelist))

def _add_matcher_specific_properties_to_json(self):
Expand Down Expand Up @@ -216,7 +215,7 @@ def _match(self, key, attributes=None, context=None):
matching_data = Sanitizer.ensure_string(self._get_matcher_input(key, attributes))
if matching_data is None:
return False
return (isinstance(matching_data, string_types) and
return (isinstance(matching_data, str) and
any(s in matching_data for s in self._whitelist))

def _add_matcher_specific_properties_to_json(self):
Expand Down
15 changes: 5 additions & 10 deletions splitio/push/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
from enum import Enum

from future.utils import raise_from
from six import add_metaclass

from splitio.util.decorators import abstract_property
from splitio.util import utctime_ms
Expand Down Expand Up @@ -51,12 +50,11 @@ class EventParsingException(Exception):
pass


@add_metaclass(abc.ABCMeta) #pylint:disable=too-few-public-methods
class BaseEvent(object):
class BaseEvent(object, metaclass=abc.ABCMeta):
"""Base event that reqiures subclasses tu have a type."""

@abstract_property
def event_type(self): #pylint:disable=no-self-use
def event_type(self): # pylint:disable=no-self-use
"""
Return the event type.

Expand Down Expand Up @@ -92,7 +90,7 @@ def __init__(self, code, status_code, message, href):
self._timestamp = utctime_ms()

@property
def event_type(self): #pylint:disable=no-self-use
def event_type(self): # pylint:disable=no-self-use
"""
Return the event type.

Expand Down Expand Up @@ -160,7 +158,6 @@ def should_be_ignored(self):
"""
return self._code < 40000 or self._code > 49999


def is_retryable(self):
"""
Return whether this error is retryable or not.
Expand All @@ -176,8 +173,7 @@ def __str__(self):
(self.code, self.status_code, self.message, self.href)


@add_metaclass(abc.ABCMeta)
class BaseMessage(BaseEvent):
class BaseMessage(BaseEvent, metaclass=abc.ABCMeta):
"""Message type event."""

def __init__(self, channel, timestamp):
Expand Down Expand Up @@ -282,8 +278,7 @@ def __str__(self):
return "Occupancy - channel=%s, publishers=%d" % (self.channel, self.publishers)


@add_metaclass(abc.ABCMeta)
class BaseUpdate(BaseMessage):
class BaseUpdate(BaseMessage, metaclass=abc.ABCMeta):
"""Split data update notification."""

def __init__(self, channel, timestamp, change_number):
Expand Down
4 changes: 1 addition & 3 deletions splitio/push/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

from queue import Queue

from six import raise_from

from splitio.push.parser import UpdateType
from splitio.push.splitworker import SplitWorker
from splitio.push.segmentworker import SegmentWorker
Expand Down Expand Up @@ -83,7 +81,7 @@ def handle(self, event):
try:
handle = self._handlers[event.update_type]
except KeyError as exc:
raise_from('no handler for notification type: %s' % event.update_type, exc)
raise Exception('no handler for notification type: %s' % event.update_type) from exc

handle(event)

Expand Down
Loading