From 54dbba62abf86a7b37bbfd3675fabea3c118ad2c Mon Sep 17 00:00:00 2001 From: Jacob Rief Date: Tue, 5 May 2020 01:08:52 +0200 Subject: [PATCH] replace six.with_metaclass against Python3 spelling --- shop/models/address.py | 6 ++---- shop/models/cart.py | 7 ++++--- shop/models/customer.py | 3 +-- shop/models/delivery.py | 6 +++--- shop/models/fields.py | 2 +- shop/models/order.py | 7 +++---- shop/models/product.py | 2 +- shop/models/related.py | 5 ++--- 8 files changed, 17 insertions(+), 21 deletions(-) diff --git a/shop/models/address.py b/shop/models/address.py index ce39595f6..7f72cf0b4 100644 --- a/shop/models/address.py +++ b/shop/models/address.py @@ -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 _ @@ -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: @@ -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: diff --git a/shop/models/cart.py b/shop/models/cart.py index 49550d0d4..132d4c544 100644 --- a/shop/models/cart.py +++ b/shop/models/cart.py @@ -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 @@ -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 @@ -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. """ diff --git a/shop/models/customer.py b/shop/models/customer.py index cf8f7ff64..a286ad4d6 100644 --- a/shop/models/customer.py +++ b/shop/models/customer.py @@ -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 @@ -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. diff --git a/shop/models/delivery.py b/shop/models/delivery.py index 8a78bbc5d..ca89a3518 100644 --- a/shop/models/delivery.py +++ b/shop/models/delivery.py @@ -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. """ @@ -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. diff --git a/shop/models/fields.py b/shop/models/fields.py index b0d769fe6..49b98d63c 100644 --- a/shop/models/fields.py +++ b/shop/models/fields.py @@ -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: diff --git a/shop/models/order.py b/shop/models/order.py index a8a716035..6136f576c 100644 --- a/shop/models/order.py +++ b/shop/models/order.py @@ -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 @@ -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, @@ -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. """ @@ -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. """ diff --git a/shop/models/product.py b/shop/models/product.py index 65a4667da..c9ab1c688 100644 --- a/shop/models/product.py +++ b/shop/models/product.py @@ -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 diff --git a/shop/models/related.py b/shop/models/related.py index e0ccb6dbb..1d09ada4c 100644 --- a/shop/models/related.py +++ b/shop/models/related.py @@ -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 @@ -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. @@ -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. """