Skip to content

Commit

Permalink
remove all occurences of six
Browse files Browse the repository at this point in the history
  • Loading branch information
jrief committed May 4, 2020
1 parent 8ed7959 commit 8629507
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 34 deletions.
3 changes: 1 addition & 2 deletions shop/admin/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from django.contrib import admin
from django.contrib.auth import get_user_model
from django.forms import fields, models, widgets
from django.utils import six
from django.utils.translation import ugettext_lazy as _

from django_fsm import RETURN_VALUE
Expand Down Expand Up @@ -43,7 +42,7 @@ def __init__(self, *args, **kwargs):
def get_transition_choices(self):
choices = OrderedDict()
for transition in OrderModel.get_all_transitions():
if isinstance(transition.target, six.string_types):
if isinstance(transition.target, str):
choices[transition.target] = OrderModel.get_transition_name(transition.target)
elif isinstance(transition.target, RETURN_VALUE):
for target in transition.target.allowed_states:
Expand Down
5 changes: 2 additions & 3 deletions shop/deferred.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from django.core.exceptions import ImproperlyConfigured
from django.db.models.base import ModelBase
from django.db import models
from django.utils import six
from django.utils.functional import LazyObject, empty
from polymorphic.models import PolymorphicModelBase

Expand All @@ -15,7 +14,7 @@ def __init__(self, to, **kwargs):
try:
self.abstract_model = to._meta.object_name
except AttributeError:
assert isinstance(to, six.string_types), "%s(%r) is invalid. First parameter must be either a model or a model name" % (self.__class__.__name__, to)
assert isinstance(to, str), "%s(%r) is invalid. First parameter must be either a model or a model name" % (self.__class__.__name__, to)
self.abstract_model = to
self.options = dict(**kwargs)

Expand Down Expand Up @@ -60,7 +59,7 @@ def __init__(self, to, **kwargs):
try:
self.abstract_through_model = through._meta.object_name
except AttributeError:
assert isinstance(through, six.string_types), ('%s(%r) is invalid. '
assert isinstance(through, str), ('%s(%r) is invalid. '
'Through parameter must be either a model or a model name'
% (self.__class__.__name__, through))
self.abstract_through_model = through
Expand Down
9 changes: 2 additions & 7 deletions shop/models/fields.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import enum
import six
from django.conf import settings
from django.db import models
from django.utils.encoding import force_text
Expand Down Expand Up @@ -30,7 +29,7 @@ def deconstruct(self):

class ChoiceEnumMeta(enum.EnumMeta):
def __call__(cls, value, *args, **kwargs):
if isinstance(value, string_types):
if isinstance(value, str):
try:
value = cls.__members__[value]
except KeyError:
Expand All @@ -39,11 +38,7 @@ def __call__(cls, value, *args, **kwargs):

def __new__(metacls, classname, bases, classdict):
labels = {}
if six.PY2:
member_names = [k for k in classdict.keys() if k not in ['__module__', '__str__', '__doc__']]
else:
member_names = classdict._member_names
for key in member_names:
for key in classdict._member_names:
source_value = classdict[key]
if isinstance(source_value, (list, tuple)):
try:
Expand Down
1 change: 0 additions & 1 deletion shop/models/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from django.db import models
from django.db.models.aggregates import Sum
from django.db.models.functions import Coalesce
from django.utils import six
from django.utils import timezone
from django.utils.encoding import force_text
from django.utils.translation import ugettext_lazy as _
Expand Down
12 changes: 2 additions & 10 deletions shop/money/money_maker.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from decimal import Decimal, InvalidOperation
from django.conf import settings
from django.utils import six
from django.utils.formats import get_format
from django.utils.translation import get_language
from cms.utils.helpers import classproperty
Expand Down Expand Up @@ -33,8 +32,6 @@ def __str__(self):
vals.update(amount=Decimal.__str__(Decimal.quantize(self, self._cents)))
except InvalidOperation:
raise ValueError("Can not represent {} as Money type.".format(self.__repr__()))
if six.PY2:
return u'{:f}'.format(self)
return '{:f}'.format(self)

def __repr__(self):
Expand Down Expand Up @@ -182,13 +179,8 @@ def __ge__(self, other, context=None):
def __deepcopy__(self, memo):
return self.__class__(self._cents)

if six.PY2:
def __nonzero__(self):
return Decimal.__nonzero__(self) and not self.is_nan()

if six.PY3:
def __bool__(self):
return Decimal.__bool__(self) and not self.is_nan()
def __bool__(self):
return Decimal.__bool__(self) and not self.is_nan()

@classproperty
def currency(cls):
Expand Down
6 changes: 0 additions & 6 deletions shop/rest/money.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from django.utils import six

from rest_framework import renderers
from rest_framework import serializers
from rest_framework.utils import encoders
Expand All @@ -11,8 +9,6 @@ class JSONEncoder(encoders.JSONEncoder):

def default(self, obj):
if isinstance(obj, AbstractMoney):
if six.PY2:
return u'{:f}'.format(obj)
return '{:f}'.format(obj)
return super(JSONEncoder, self).default(obj)

Expand All @@ -29,6 +25,4 @@ def __init__(self, *args, **kwargs):
super(MoneyField, self).__init__(*args, **kwargs)

def to_representation(self, obj):
if six.PY2:
return u'{:f}'.format(obj)
return '{:f}'.format(obj)
4 changes: 1 addition & 3 deletions shop/serializers/bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
from django.template import TemplateDoesNotExist
from django.template.loader import select_template
from django.utils.html import strip_spaces_between_tags
from django.utils import six
from django.utils.safestring import mark_safe, SafeText
from django.utils.translation import get_language_from_request
from rest_framework import serializers

from shop.conf import app_settings
from shop.models.customer import CustomerModel
from shop.models.product import ProductModel
Expand Down Expand Up @@ -50,8 +50,6 @@ def __init__(self, *args, **kwargs):
def get_price(self, product):
price = product.get_price(self.context['request'])
# TODO: check if this can be simplified using str(product.get_price(...))
if six.PY2:
return u'{:f}'.format(price)
return '{:f}'.format(price)

def render_html(self, product, postfix):
Expand Down
3 changes: 1 addition & 2 deletions shop/templatetags/shop_search_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from django.contrib.auth.models import AnonymousUser
from django.http.request import HttpRequest
from django.utils.html import strip_tags
from django.utils.six import string_types
from sekizai.context_processors import sekizai

register = template.Library()
Expand Down Expand Up @@ -34,7 +33,7 @@ def _get_value(self, context, editable=True, **kwargs):
placeholder = kwargs.get('placeholder')
if not placeholder:
return ''
if isinstance(placeholder, string_types):
if isinstance(placeholder, str):
placeholder = Placeholder.objects.get(slot=placeholder)
content = renderer.render_placeholder(
placeholder=placeholder,
Expand Down

0 comments on commit 8629507

Please sign in to comment.