Skip to content

Commit

Permalink
replace six.with_metaclass against Python3 spelling
Browse files Browse the repository at this point in the history
  • Loading branch information
jrief committed May 4, 2020
1 parent e27fde9 commit 54dbba6
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 21 deletions.
6 changes: 2 additions & 4 deletions shop/models/address.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
"""
Holds all the information relevant to the client (addresses for instance)
"""
from six import with_metaclass

from django.db import models
from django.template.loader import select_template
from django.utils.translation import ugettext_lazy as _
Expand Down Expand Up @@ -54,7 +52,7 @@ def as_text(self):
return template.render({'address': self})


class BaseShippingAddress(with_metaclass(deferred.ForeignKeyBuilder, BaseAddress)):
class BaseShippingAddress(BaseAddress, metaclass=deferred.ForeignKeyBuilder):
address_type = 'shipping'

class Meta:
Expand All @@ -63,7 +61,7 @@ class Meta:
ShippingAddressModel = deferred.MaterializedModel(BaseShippingAddress)


class BaseBillingAddress(with_metaclass(deferred.ForeignKeyBuilder, BaseAddress)):
class BaseBillingAddress(BaseAddress, metaclass=deferred.ForeignKeyBuilder):
address_type = 'billing'

class Meta:
Expand Down
7 changes: 4 additions & 3 deletions shop/models/cart.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from six import with_metaclass
import warnings
from collections import OrderedDict

from django.core import checks
from django.db import models
from django.utils.translation import ugettext_lazy as _

from shop import deferred
from shop.models.fields import JSONField
from shop.models.customer import CustomerModel
Expand Down Expand Up @@ -61,7 +62,7 @@ def filter_watch_items(self, cart, request):
return watch_items


class BaseCartItem(with_metaclass(deferred.ForeignKeyBuilder, models.Model)):
class BaseCartItem(models.Model, metaclass=deferred.ForeignKeyBuilder):
"""
This is a holder for the quantity of items in the cart and, obviously, a
pointer to the actual Product being purchased
Expand Down Expand Up @@ -169,7 +170,7 @@ def get_or_create_from_request(self, request):
return request._cached_cart


class BaseCart(with_metaclass(deferred.ForeignKeyBuilder, models.Model)):
class BaseCart(models.Model, metaclass=deferred.ForeignKeyBuilder):
"""
The fundamental part of a shopping cart.
"""
Expand Down
3 changes: 1 addition & 2 deletions shop/models/customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
from django.utils.encoding import python_2_unicode_compatible
from django.utils.functional import SimpleLazyObject
from django.utils.translation import ugettext_lazy as _
from django.utils.six import with_metaclass

from shop import deferred
from shop.models.fields import JSONField
Expand Down Expand Up @@ -178,7 +177,7 @@ def get_or_create_from_request(self, request):


@python_2_unicode_compatible
class BaseCustomer(with_metaclass(deferred.ForeignKeyBuilder, models.Model)):
class BaseCustomer(models.Model, metaclass=deferred.ForeignKeyBuilder):
"""
Base class for shop customers.
Expand Down
6 changes: 3 additions & 3 deletions shop/models/delivery.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from six import with_metaclass
from django.core import checks
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _

from shop import deferred
from shop.models.order import BaseOrder, BaseOrderItem, OrderItemModel
from shop.modifiers.pool import cart_modifiers_pool


@python_2_unicode_compatible
class BaseDelivery(with_metaclass(deferred.ForeignKeyBuilder, models.Model)):
class BaseDelivery(models.Model, metaclass=deferred.ForeignKeyBuilder):
"""
Shipping provider to keep track on each delivery.
"""
Expand Down Expand Up @@ -84,7 +84,7 @@ def get_number(self):
DeliveryModel = deferred.MaterializedModel(BaseDelivery)


class BaseDeliveryItem(with_metaclass(deferred.ForeignKeyBuilder, models.Model)):
class BaseDeliveryItem(models.Model, metaclass=deferred.ForeignKeyBuilder):
"""
Abstract base class to keep track on the delivered quantity for each ordered item. Since the
quantity can be any numerical value, it has to be defined by the class implementing this model.
Expand Down
2 changes: 1 addition & 1 deletion shop/models/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def default(cls):


@python_2_unicode_compatible
class ChoiceEnum(six.with_metaclass(ChoiceEnumMeta, enum.Enum)):
class ChoiceEnum(enum.Enum, metaclass=ChoiceEnumMeta):
"""
Utility class to handle choices in Django model and/or form fields.
Usage:
Expand Down
7 changes: 3 additions & 4 deletions shop/models/order.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from decimal import Decimal
import logging
from urllib.parse import urljoin
from six import with_metaclass

from django.core import checks
from django.core.exceptions import ImproperlyConfigured
Expand Down Expand Up @@ -138,7 +137,7 @@ def add_to_auto_transitions(cls, base):


@python_2_unicode_compatible
class BaseOrder(with_metaclass(WorkflowMixinMetaclass, models.Model)):
class BaseOrder(models.Model, metaclass=WorkflowMixinMetaclass):
"""
An Order is the "in process" counterpart of the shopping cart, which freezes the state of the
cart on the moment of purchase. It also holds stuff like the shipping and billing addresses,
Expand Down Expand Up @@ -414,7 +413,7 @@ def status_name(self):


@python_2_unicode_compatible
class OrderPayment(with_metaclass(deferred.ForeignKeyBuilder, models.Model)):
class OrderPayment(models.Model, metaclass=deferred.ForeignKeyBuilder):
"""
A model to hold received payments for a given order.
"""
Expand Down Expand Up @@ -455,7 +454,7 @@ def __str__(self):


@python_2_unicode_compatible
class BaseOrderItem(with_metaclass(deferred.ForeignKeyBuilder, models.Model)):
class BaseOrderItem(models.Model, metaclass=deferred.ForeignKeyBuilder):
"""
An item for an order.
"""
Expand Down
2 changes: 1 addition & 1 deletion shop/models/product.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def perform_meta_model_check(cls, Model):
raise NotImplementedError(msg.format(cls.__name__))


class BaseProduct(six.with_metaclass(PolymorphicProductMetaclass, PolymorphicModel)):
class BaseProduct(PolymorphicModel, metaclass=PolymorphicProductMetaclass):
"""
An abstract basic product model for the shop. It is intended to be overridden by one or
more polymorphic models, adding all the fields and relations, required to describe this
Expand Down
5 changes: 2 additions & 3 deletions shop/models/related.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.db import models
from django.utils.six import with_metaclass
from django.utils.translation import ugettext_lazy as _

from filer.fields import image
Expand All @@ -10,7 +9,7 @@
from shop.models.product import BaseProduct


class BaseProductPage(with_metaclass(deferred.ForeignKeyBuilder, models.Model)):
class BaseProductPage(models.Model, metaclass=deferred.ForeignKeyBuilder):
"""
ManyToMany relation from the polymorphic Product to the CMS Page.
This in practice is the category.
Expand All @@ -34,7 +33,7 @@ class Meta:
ProductPageModel = deferred.MaterializedModel(BaseProductPage)


class BaseProductImage(with_metaclass(deferred.ForeignKeyBuilder, models.Model)):
class BaseProductImage(models.Model, metaclass=deferred.ForeignKeyBuilder):
"""
ManyToMany relation from the polymorphic Product to a set of images.
"""
Expand Down

0 comments on commit 54dbba6

Please sign in to comment.