diff --git a/manage.py b/manage.py index 60bc8e75a7b..4440fb1010e 100755 --- a/manage.py +++ b/manage.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -from __future__ import unicode_literals - +#!/usr/bin/env python3 import os import sys diff --git a/saleor/__init__.py b/saleor/__init__.py index 8968e52b161..189a7551ac1 100644 --- a/saleor/__init__.py +++ b/saleor/__init__.py @@ -1,4 +1,3 @@ -from __future__ import absolute_import, unicode_literals from .celeryconf import app as celery_app __all__ = ['celery_app'] diff --git a/saleor/cart/__init__.py b/saleor/cart/__init__.py index faef746e0bc..66c4c2bff87 100644 --- a/saleor/cart/__init__.py +++ b/saleor/cart/__init__.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - import logging from django.utils.translation import pgettext_lazy diff --git a/saleor/cart/context_processors.py b/saleor/cart/context_processors.py index b738e722eea..8804f2a0bf6 100644 --- a/saleor/cart/context_processors.py +++ b/saleor/cart/context_processors.py @@ -1,6 +1,4 @@ """Cart-related context processors.""" -from __future__ import unicode_literals - from .utils import get_cart_from_request diff --git a/saleor/cart/forms.py b/saleor/cart/forms.py index 6c5ccea10e4..4c7e036ec2b 100644 --- a/saleor/cart/forms.py +++ b/saleor/cart/forms.py @@ -1,6 +1,4 @@ """Cart-related forms and fields.""" -from __future__ import unicode_literals - from django import forms from django.conf import settings from django.core.exceptions import NON_FIELD_ERRORS, ObjectDoesNotExist diff --git a/saleor/cart/models.py b/saleor/cart/models.py index 6d8b877b984..fa98e5565ea 100644 --- a/saleor/cart/models.py +++ b/saleor/cart/models.py @@ -1,6 +1,4 @@ """Cart-related ORM models.""" -from __future__ import unicode_literals - from collections import namedtuple from decimal import Decimal from uuid import uuid4 @@ -8,7 +6,7 @@ from django.conf import settings from django.core.validators import MaxValueValidator, MinValueValidator from django.db import models -from django.utils.encoding import python_2_unicode_compatible, smart_str +from django.utils.encoding import smart_str from django.utils.timezone import now from django.utils.translation import pgettext_lazy from django_prices.models import PriceField @@ -243,7 +241,6 @@ def partition(self): return partition(self.lines.all(), grouper, ProductGroup) -@python_2_unicode_compatible class CartLine(models.Model, ItemLine): """A single cart line. diff --git a/saleor/cart/urls.py b/saleor/cart/urls.py index d404d848900..4292f7fb9cb 100644 --- a/saleor/cart/urls.py +++ b/saleor/cart/urls.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf.urls import url from . import views diff --git a/saleor/cart/utils.py b/saleor/cart/utils.py index efb5f72f691..0b39a76407a 100644 --- a/saleor/cart/utils.py +++ b/saleor/cart/utils.py @@ -1,6 +1,4 @@ """Cart-related utility functions.""" -from __future__ import unicode_literals - from datetime import timedelta from functools import wraps from uuid import UUID diff --git a/saleor/cart/views.py b/saleor/cart/views.py index d9232801f0e..5dbc2fbe454 100644 --- a/saleor/cart/views.py +++ b/saleor/cart/views.py @@ -1,6 +1,4 @@ """Cart-related views.""" -from __future__ import unicode_literals - from django.http import JsonResponse from django.shortcuts import get_object_or_404, redirect, render from django.template.response import TemplateResponse diff --git a/saleor/celeryconf.py b/saleor/celeryconf.py index f8350457184..9e7d547855c 100644 --- a/saleor/celeryconf.py +++ b/saleor/celeryconf.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - import os from celery import Celery from django.conf import settings diff --git a/saleor/checkout/core.py b/saleor/checkout/core.py index a954bee7faf..7c25028bb33 100644 --- a/saleor/checkout/core.py +++ b/saleor/checkout/core.py @@ -1,6 +1,4 @@ """Checkout session state management.""" -from __future__ import unicode_literals - from datetime import date from functools import wraps @@ -26,7 +24,7 @@ STORAGE_SESSION_KEY = 'checkout_storage' -class Checkout(object): +class Checkout: """Represents a checkout session. This object acts a temporary storage for the entire checkout session. An diff --git a/saleor/checkout/forms.py b/saleor/checkout/forms.py index b8118266bb1..4d11583673a 100644 --- a/saleor/checkout/forms.py +++ b/saleor/checkout/forms.py @@ -1,6 +1,4 @@ """Checkout-related forms.""" -from __future__ import unicode_literals - from django import forms from django.utils.safestring import mark_safe from django.utils.translation import pgettext_lazy diff --git a/saleor/checkout/urls.py b/saleor/checkout/urls.py index 4a9aec0e574..a4c4ba92dd5 100644 --- a/saleor/checkout/urls.py +++ b/saleor/checkout/urls.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf.urls import url from . import views diff --git a/saleor/checkout/views/__init__.py b/saleor/checkout/views/__init__.py index c5f281a16ae..68c059af724 100644 --- a/saleor/checkout/views/__init__.py +++ b/saleor/checkout/views/__init__.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.shortcuts import redirect from django.template.response import TemplateResponse diff --git a/saleor/checkout/views/discount.py b/saleor/checkout/views/discount.py index 7ed47165e15..fdbc28dc430 100644 --- a/saleor/checkout/views/discount.py +++ b/saleor/checkout/views/discount.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from datetime import date from functools import wraps diff --git a/saleor/checkout/views/shipping.py b/saleor/checkout/views/shipping.py index b392a27751f..13d8dc6441d 100644 --- a/saleor/checkout/views/shipping.py +++ b/saleor/checkout/views/shipping.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.shortcuts import redirect from django.template.response import TemplateResponse diff --git a/saleor/checkout/views/summary.py b/saleor/checkout/views/summary.py index e261d804c6e..ec0ed52ffaf 100644 --- a/saleor/checkout/views/summary.py +++ b/saleor/checkout/views/summary.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.contrib import messages from django.shortcuts import redirect from django.template.response import TemplateResponse diff --git a/saleor/checkout/views/validators.py b/saleor/checkout/views/validators.py index 7c75b348f19..95fa3020e38 100644 --- a/saleor/checkout/views/validators.py +++ b/saleor/checkout/views/validators.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from functools import wraps from django.core.exceptions import ValidationError diff --git a/saleor/core/__init__.py b/saleor/core/__init__.py index d38f3038eb8..51c03d17718 100644 --- a/saleor/core/__init__.py +++ b/saleor/core/__init__.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf import settings from django.core.checks import register, Warning diff --git a/saleor/core/analytics.py b/saleor/core/analytics.py index 2cceac8cb13..faedc9cb22f 100644 --- a/saleor/core/analytics.py +++ b/saleor/core/analytics.py @@ -1,10 +1,6 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - import uuid import google_measurement_protocol as ga -import six from django.conf import settings FINGERPRINT_PARTS = [ @@ -20,10 +16,6 @@ def get_client_id(request): parts = [request.META.get(key, '') for key in FINGERPRINT_PARTS] name = '_'.join(parts) - # In Python2 name is unicode type - # We encode it to avoid UnicodeDecodeError in uuid package - if six.PY2: - name = name.encode('utf-8') return uuid.uuid5(UUID_NAMESPACE, name) diff --git a/saleor/core/context_processors.py b/saleor/core/context_processors.py index 7caae02ded0..48820dbc88a 100644 --- a/saleor/core/context_processors.py +++ b/saleor/core/context_processors.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - import json from django.conf import settings diff --git a/saleor/core/filters.py b/saleor/core/filters.py index b3a186121c2..e1641616cca 100644 --- a/saleor/core/filters.py +++ b/saleor/core/filters.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals from django_filters import FilterSet diff --git a/saleor/core/management/commands/populatedb.py b/saleor/core/management/commands/populatedb.py index 76d14fd99c8..2863e1542fb 100644 --- a/saleor/core/management/commands/populatedb.py +++ b/saleor/core/management/commands/populatedb.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.core.management import call_command from django.core.management.base import BaseCommand from django.conf import settings diff --git a/saleor/core/middleware.py b/saleor/core/middleware.py index cb7ae447096..c551f632634 100644 --- a/saleor/core/middleware.py +++ b/saleor/core/middleware.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - import logging from django.conf import settings diff --git a/saleor/core/permissions.py b/saleor/core/permissions.py index 674e6afb535..093869518ca 100644 --- a/saleor/core/permissions.py +++ b/saleor/core/permissions.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals from django.contrib.auth.models import Permission diff --git a/saleor/core/sitemaps.py b/saleor/core/sitemaps.py index a7641cc893a..2258d8d189d 100644 --- a/saleor/core/sitemaps.py +++ b/saleor/core/sitemaps.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.contrib.sitemaps import Sitemap from ..product.models import Category, Product diff --git a/saleor/core/storages.py b/saleor/core/storages.py index dcf99d14ab0..780059a01e1 100644 --- a/saleor/core/storages.py +++ b/saleor/core/storages.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf import settings from storages.backends.s3boto3 import S3Boto3Storage diff --git a/saleor/core/templatetags/attributes.py b/saleor/core/templatetags/attributes.py index e806d4e769b..88c825a5970 100644 --- a/saleor/core/templatetags/attributes.py +++ b/saleor/core/templatetags/attributes.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.template import Library from ...product.utils import get_attributes_display_map diff --git a/saleor/core/templatetags/jsonld.py b/saleor/core/templatetags/jsonld.py index f312555ee28..7296ae6ac28 100644 --- a/saleor/core/templatetags/jsonld.py +++ b/saleor/core/templatetags/jsonld.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - import json from django.template import Library diff --git a/saleor/core/templatetags/markdown.py b/saleor/core/templatetags/markdown.py index 870edfa3ce9..9b49ff26f74 100644 --- a/saleor/core/templatetags/markdown.py +++ b/saleor/core/templatetags/markdown.py @@ -1,5 +1,3 @@ -from __future__ import absolute_import, unicode_literals - from django import template from django.utils.safestring import mark_safe from markdown import markdown as format_markdown diff --git a/saleor/core/templatetags/materializecss.py b/saleor/core/templatetags/materializecss.py index 35097f71176..4bd534e44f8 100644 --- a/saleor/core/templatetags/materializecss.py +++ b/saleor/core/templatetags/materializecss.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django import forms from django.template.loader import get_template from django import template diff --git a/saleor/core/templatetags/shop.py b/saleor/core/templatetags/shop.py index ba5e8940bcb..3fe46bb7dea 100644 --- a/saleor/core/templatetags/shop.py +++ b/saleor/core/templatetags/shop.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals try: from itertools import zip_longest except ImportError: @@ -50,7 +49,7 @@ def get_sort_by_toggle(context, field): # enable ascending sort # new_sort_by is used to construct a link with already toggled # sort_by value - new_sort_by = u'-%s' % field + new_sort_by = '-%s' % field sorting_icon = static('/images/arrow_up_icon.svg') is_active = True else: diff --git a/saleor/core/templatetags/status.py b/saleor/core/templatetags/status.py index d3b620f4883..3af375c8f48 100644 --- a/saleor/core/templatetags/status.py +++ b/saleor/core/templatetags/status.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.template import Library from payments import PaymentStatus diff --git a/saleor/core/templatetags/version.py b/saleor/core/templatetags/version.py index c6760f6837c..85a0ccf7126 100644 --- a/saleor/core/templatetags/version.py +++ b/saleor/core/templatetags/version.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.template import Library from saleor import __version__ diff --git a/saleor/core/urls.py b/saleor/core/urls.py index 946446e7161..13c8cbf0ad3 100644 --- a/saleor/core/urls.py +++ b/saleor/core/urls.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf.urls import url from . import views diff --git a/saleor/core/utils/__init__.py b/saleor/core/utils/__init__.py index ac0f11e88f0..5da3ce782a8 100644 --- a/saleor/core/utils/__init__.py +++ b/saleor/core/utils/__init__.py @@ -1,6 +1,3 @@ -# coding: utf-8 -from __future__ import unicode_literals - import decimal from json import JSONEncoder diff --git a/saleor/core/utils/filters.py b/saleor/core/utils/filters.py index 5027229be65..6f2c73f8340 100644 --- a/saleor/core/utils/filters.py +++ b/saleor/core/utils/filters.py @@ -1,6 +1,3 @@ -from __future__ import unicode_literals - - def get_sort_by_choices(filter_set): return [(choice[0], choice[1].lower()) for choice in filter_set.filters['sort_by'].field.choices[1::2]] diff --git a/saleor/core/utils/form_renderer.py b/saleor/core/utils/form_renderer.py index 01d97ce12a9..0690b3e2f18 100644 --- a/saleor/core/utils/form_renderer.py +++ b/saleor/core/utils/form_renderer.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from bootstrap3.renderers import FormRenderer as BaseFormRenderer diff --git a/saleor/core/utils/random_data.py b/saleor/core/utils/random_data.py index a33a1edec75..d3a316a38f6 100644 --- a/saleor/core/utils/random_data.py +++ b/saleor/core/utils/random_data.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - import itertools import os import random @@ -10,7 +8,6 @@ from django.contrib.auth.models import Group, Permission from django.core.files import File from django.template.defaultfilters import slugify -from django.utils.six import moves from faker import Factory from faker.providers import BaseProvider from payments import PaymentStatus @@ -19,14 +16,13 @@ from ...discount.models import Sale, Voucher from ...order import OrderStatus from ...order.models import DeliveryGroup, Order, OrderLine, Payment -from ...product.models import (AttributeChoiceValue, Category, Product, - ProductAttribute, ProductClass, ProductImage, - ProductVariant, Stock, StockLocation) +from ...product.models import ( + AttributeChoiceValue, Category, Product, ProductAttribute, ProductClass, + ProductImage, ProductVariant, Stock, StockLocation) from ...shipping.models import ANY_COUNTRY, ShippingMethod from ...userprofile.models import Address, User from ...userprofile.utils import store_user_address - fake = Factory.create() STOCK_LOCATION = 'default' @@ -188,9 +184,10 @@ def get_variant_combinations(product): for attr in product.product_class.variant_attributes.all()} all_combinations = itertools.product(*variant_attr_map.values()) - return [{str(attr_value.attribute.pk): str(attr_value.pk) - for attr_value in combination} - for combination in all_combinations] + return [ + {str(attr_value.attribute.pk): str(attr_value.pk) + for attr_value in combination} + for combination in all_combinations] def get_price_override(schema, combinations_num, current_price): @@ -221,7 +218,7 @@ def create_products_by_class(product_class, schema, prices = get_price_override( schema, len(variant_combinations), product.price) - variants_with_prices = moves.zip_longest( + variants_with_prices = itertools.zip_longest( variant_combinations, prices) for i, variant_price in enumerate(variants_with_prices, start=1337): diff --git a/saleor/core/views.py b/saleor/core/views.py index 90e13056d3e..2fa0bb2f73d 100644 --- a/saleor/core/views.py +++ b/saleor/core/views.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.template.response import TemplateResponse from django.contrib import messages from django.utils.translation import pgettext_lazy diff --git a/saleor/dashboard/category/filters.py b/saleor/dashboard/category/filters.py index 3a5814467e4..973f9592470 100644 --- a/saleor/dashboard/category/filters.py +++ b/saleor/dashboard/category/filters.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.utils.translation import pgettext_lazy from django_filters import CharFilter, OrderingFilter diff --git a/saleor/dashboard/category/forms.py b/saleor/dashboard/category/forms.py index 418c4e56b2e..c72283f02c5 100644 --- a/saleor/dashboard/category/forms.py +++ b/saleor/dashboard/category/forms.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django import forms from django.shortcuts import get_object_or_404 from django.utils.translation import pgettext_lazy diff --git a/saleor/dashboard/category/urls.py b/saleor/dashboard/category/urls.py index d0d00ecafcf..cbd866f6694 100644 --- a/saleor/dashboard/category/urls.py +++ b/saleor/dashboard/category/urls.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf.urls import url from . import views diff --git a/saleor/dashboard/category/views.py b/saleor/dashboard/category/views.py index 0b22d3dfcaa..a38191cc080 100644 --- a/saleor/dashboard/category/views.py +++ b/saleor/dashboard/category/views.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf import settings from django.contrib import messages from django.contrib.auth.decorators import permission_required diff --git a/saleor/dashboard/customer/filters.py b/saleor/dashboard/customer/filters.py index 940843384bb..b3ed86b5394 100644 --- a/saleor/dashboard/customer/filters.py +++ b/saleor/dashboard/customer/filters.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django import forms from django.db.models import Q from django.utils.translation import pgettext_lazy diff --git a/saleor/dashboard/customer/urls.py b/saleor/dashboard/customer/urls.py index 5601ee82437..f9f565f988f 100644 --- a/saleor/dashboard/customer/urls.py +++ b/saleor/dashboard/customer/urls.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf.urls import url from . import views diff --git a/saleor/dashboard/customer/views.py b/saleor/dashboard/customer/views.py index d4d50932898..8e68210028b 100644 --- a/saleor/dashboard/customer/views.py +++ b/saleor/dashboard/customer/views.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf import settings from django.contrib import messages from django.contrib.auth.decorators import permission_required diff --git a/saleor/dashboard/discount/filters.py b/saleor/dashboard/discount/filters.py index 661d7054550..fc7d3d667c9 100644 --- a/saleor/dashboard/discount/filters.py +++ b/saleor/dashboard/discount/filters.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django import forms from django.db.models import Q from django.utils.translation import pgettext_lazy diff --git a/saleor/dashboard/discount/forms.py b/saleor/dashboard/discount/forms.py index 9954c98f070..0c827e3fa20 100644 --- a/saleor/dashboard/discount/forms.py +++ b/saleor/dashboard/discount/forms.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - import uuid from django import forms diff --git a/saleor/dashboard/discount/urls.py b/saleor/dashboard/discount/urls.py index 295da439d3e..9bb704cf417 100644 --- a/saleor/dashboard/discount/urls.py +++ b/saleor/dashboard/discount/urls.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf.urls import url from . import views diff --git a/saleor/dashboard/discount/views.py b/saleor/dashboard/discount/views.py index 33f548067f6..b921eb0153f 100644 --- a/saleor/dashboard/discount/views.py +++ b/saleor/dashboard/discount/views.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf import settings from django.contrib import messages from django.contrib.auth.decorators import permission_required diff --git a/saleor/dashboard/group/filters.py b/saleor/dashboard/group/filters.py index f767987dd59..62b0d391720 100644 --- a/saleor/dashboard/group/filters.py +++ b/saleor/dashboard/group/filters.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.contrib.auth.models import Group from django.utils.translation import pgettext_lazy from django_filters import ( diff --git a/saleor/dashboard/group/forms.py b/saleor/dashboard/group/forms.py index 0bb139f1da6..5e117d0a693 100644 --- a/saleor/dashboard/group/forms.py +++ b/saleor/dashboard/group/forms.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django import forms from django.contrib.auth.models import Group diff --git a/saleor/dashboard/group/urls.py b/saleor/dashboard/group/urls.py index 7106f852f3f..aecaee38ff3 100644 --- a/saleor/dashboard/group/urls.py +++ b/saleor/dashboard/group/urls.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf.urls import url from . import views diff --git a/saleor/dashboard/group/views.py b/saleor/dashboard/group/views.py index 5037b05cc9e..52048fc659a 100644 --- a/saleor/dashboard/group/views.py +++ b/saleor/dashboard/group/views.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf import settings from django.contrib import messages from django.contrib.auth.decorators import permission_required diff --git a/saleor/dashboard/order/filters.py b/saleor/dashboard/order/filters.py index cd9ed1ae265..e59ffb91d8c 100644 --- a/saleor/dashboard/order/filters.py +++ b/saleor/dashboard/order/filters.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django import forms from django.db.models import Q from django.utils.translation import pgettext_lazy diff --git a/saleor/dashboard/order/forms.py b/saleor/dashboard/order/forms.py index 14253eb22d4..b996cbeef85 100644 --- a/saleor/dashboard/order/forms.py +++ b/saleor/dashboard/order/forms.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django import forms from django.conf import settings from django.core.validators import MinValueValidator, MaxValueValidator diff --git a/saleor/dashboard/order/urls.py b/saleor/dashboard/order/urls.py index 7b492157dbd..3b6cc4e7f58 100644 --- a/saleor/dashboard/order/urls.py +++ b/saleor/dashboard/order/urls.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf.urls import url from . import views diff --git a/saleor/dashboard/order/utils.py b/saleor/dashboard/order/utils.py index 5dd2f892c37..60b9d484001 100644 --- a/saleor/dashboard/order/utils.py +++ b/saleor/dashboard/order/utils.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf import settings from django.contrib.sites.shortcuts import get_current_site from django.template.loader import get_template diff --git a/saleor/dashboard/order/views.py b/saleor/dashboard/order/views.py index 1227559f620..edb1b24d01a 100644 --- a/saleor/dashboard/order/views.py +++ b/saleor/dashboard/order/views.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf import settings from django.contrib import messages from django.contrib.auth.decorators import permission_required diff --git a/saleor/dashboard/product/__init__.py b/saleor/dashboard/product/__init__.py index a5781e208e0..d4262839e1a 100644 --- a/saleor/dashboard/product/__init__.py +++ b/saleor/dashboard/product/__init__.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.utils.translation import pgettext_lazy diff --git a/saleor/dashboard/product/filters.py b/saleor/dashboard/product/filters.py index f487cbeed0c..682d580d5bb 100644 --- a/saleor/dashboard/product/filters.py +++ b/saleor/dashboard/product/filters.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django import forms from django.utils.translation import pgettext_lazy from django_filters import ( diff --git a/saleor/dashboard/product/forms.py b/saleor/dashboard/product/forms.py index 53029a406ae..70ac05a339e 100644 --- a/saleor/dashboard/product/forms.py +++ b/saleor/dashboard/product/forms.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django import forms from django.db.models import Count from django.forms.models import ModelChoiceIterator diff --git a/saleor/dashboard/product/urls.py b/saleor/dashboard/product/urls.py index cd4bd9ba7d9..7365b5f5905 100644 --- a/saleor/dashboard/product/urls.py +++ b/saleor/dashboard/product/urls.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf.urls import url from . import views diff --git a/saleor/dashboard/product/views.py b/saleor/dashboard/product/views.py index 4056ddd7694..134037256de 100644 --- a/saleor/dashboard/product/views.py +++ b/saleor/dashboard/product/views.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf import settings from django.contrib import messages from django.contrib.auth.decorators import permission_required diff --git a/saleor/dashboard/product/widgets.py b/saleor/dashboard/product/widgets.py index 9ff491e218b..27b261cecd5 100644 --- a/saleor/dashboard/product/widgets.py +++ b/saleor/dashboard/product/widgets.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.forms import MultiWidget, HiddenInput from versatileimagefield.widgets import (ClearableFileInputWithImagePreview, SizedImageCenterpointWidgetMixIn) diff --git a/saleor/dashboard/search/forms.py b/saleor/dashboard/search/forms.py index a4622bc8eba..12f737e003c 100644 --- a/saleor/dashboard/search/forms.py +++ b/saleor/dashboard/search/forms.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from ...search.backends import picker from ...search.forms import SearchForm diff --git a/saleor/dashboard/search/urls.py b/saleor/dashboard/search/urls.py index 3e848e07164..939a9ef8d6b 100644 --- a/saleor/dashboard/search/urls.py +++ b/saleor/dashboard/search/urls.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf.urls import url from . import views diff --git a/saleor/dashboard/search/views.py b/saleor/dashboard/search/views.py index 9f2b9b61566..e970c495a79 100644 --- a/saleor/dashboard/search/views.py +++ b/saleor/dashboard/search/views.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf import settings from django.http import Http404 from django.shortcuts import render diff --git a/saleor/dashboard/shipping/filters.py b/saleor/dashboard/shipping/filters.py index d150b49f5f4..f7e22ad6fbb 100644 --- a/saleor/dashboard/shipping/filters.py +++ b/saleor/dashboard/shipping/filters.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.utils.translation import pgettext_lazy from django_filters import ( CharFilter, ChoiceFilter, OrderingFilter, RangeFilter) diff --git a/saleor/dashboard/shipping/forms.py b/saleor/dashboard/shipping/forms.py index f62aceea91c..d1093664d25 100644 --- a/saleor/dashboard/shipping/forms.py +++ b/saleor/dashboard/shipping/forms.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django import forms from ...shipping.models import ShippingMethod, ShippingMethodCountry diff --git a/saleor/dashboard/shipping/urls.py b/saleor/dashboard/shipping/urls.py index 56deae66751..e654c354bad 100644 --- a/saleor/dashboard/shipping/urls.py +++ b/saleor/dashboard/shipping/urls.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf.urls import url from . import views diff --git a/saleor/dashboard/shipping/views.py b/saleor/dashboard/shipping/views.py index f7a7b75d042..059cba44b61 100644 --- a/saleor/dashboard/shipping/views.py +++ b/saleor/dashboard/shipping/views.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf import settings from django.contrib import messages from django.contrib.auth.decorators import permission_required diff --git a/saleor/dashboard/sites/forms.py b/saleor/dashboard/sites/forms.py index 3892dab8c68..b586d376538 100644 --- a/saleor/dashboard/sites/forms.py +++ b/saleor/dashboard/sites/forms.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django import forms from django.contrib.sites.models import Site diff --git a/saleor/dashboard/sites/urls.py b/saleor/dashboard/sites/urls.py index 63ae93051b8..6da80b38a62 100644 --- a/saleor/dashboard/sites/urls.py +++ b/saleor/dashboard/sites/urls.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf.urls import url from . import views diff --git a/saleor/dashboard/sites/views.py b/saleor/dashboard/sites/views.py index 1444d1b44ea..57d81668038 100644 --- a/saleor/dashboard/sites/views.py +++ b/saleor/dashboard/sites/views.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.contrib import messages from django.contrib.auth.decorators import permission_required from django.contrib.sites.models import Site diff --git a/saleor/dashboard/staff/emails.py b/saleor/dashboard/staff/emails.py index 02243b197ce..f85f3289876 100644 --- a/saleor/dashboard/staff/emails.py +++ b/saleor/dashboard/staff/emails.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from celery import shared_task from django.conf import settings from django.contrib.auth.tokens import default_token_generator diff --git a/saleor/dashboard/staff/filters.py b/saleor/dashboard/staff/filters.py index 10fd1107a1c..5ea35dc770d 100644 --- a/saleor/dashboard/staff/filters.py +++ b/saleor/dashboard/staff/filters.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django import forms from django.contrib.auth.models import Group from django.utils.translation import pgettext_lazy diff --git a/saleor/dashboard/staff/forms.py b/saleor/dashboard/staff/forms.py index d9fecb29559..1cedcce935e 100644 --- a/saleor/dashboard/staff/forms.py +++ b/saleor/dashboard/staff/forms.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django import forms from ...userprofile.models import User diff --git a/saleor/dashboard/staff/urls.py b/saleor/dashboard/staff/urls.py index 5a33cc4464c..5ef027d5bcc 100644 --- a/saleor/dashboard/staff/urls.py +++ b/saleor/dashboard/staff/urls.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf.urls import url from . import views diff --git a/saleor/dashboard/staff/views.py b/saleor/dashboard/staff/views.py index 25c1ef8863b..1badb2ae63a 100644 --- a/saleor/dashboard/staff/views.py +++ b/saleor/dashboard/staff/views.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf import settings from django.contrib import messages from django.contrib.auth.decorators import permission_required diff --git a/saleor/dashboard/templatetags/chips.py b/saleor/dashboard/templatetags/chips.py index b22eb2e3da7..6d63eada4f5 100644 --- a/saleor/dashboard/templatetags/chips.py +++ b/saleor/dashboard/templatetags/chips.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.template.defaultfilters import yesno from django.utils.translation import pgettext_lazy diff --git a/saleor/dashboard/templatetags/utils.py b/saleor/dashboard/templatetags/utils.py index 64ac5965973..d2451c102be 100644 --- a/saleor/dashboard/templatetags/utils.py +++ b/saleor/dashboard/templatetags/utils.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django import forms from django.template import Library from django_filters.fields import RangeField diff --git a/saleor/dashboard/urls.py b/saleor/dashboard/urls.py index 50229538200..a285b7d0a95 100644 --- a/saleor/dashboard/urls.py +++ b/saleor/dashboard/urls.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf.urls import url, include from . import views as core_views diff --git a/saleor/dashboard/views.py b/saleor/dashboard/views.py index 39a38c55337..42a72ca09c3 100644 --- a/saleor/dashboard/views.py +++ b/saleor/dashboard/views.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf import settings from django.contrib.admin.views.decorators import \ staff_member_required as _staff_member_required diff --git a/saleor/dashboard/widgets.py b/saleor/dashboard/widgets.py index 455d5eaafe6..aa2818d84e0 100644 --- a/saleor/dashboard/widgets.py +++ b/saleor/dashboard/widgets.py @@ -1,9 +1,7 @@ -from __future__ import unicode_literals -from django_filters.widgets import RangeWidget -from django_prices.widgets import PriceInput - from django import forms from django.conf import settings +from django_filters.widgets import RangeWidget +from django_prices.widgets import PriceInput class DateRangeWidget(RangeWidget): diff --git a/saleor/data_feeds/google_merchant.py b/saleor/data_feeds/google_merchant.py index 94e273cf3ce..1dde6c8c9f8 100644 --- a/saleor/data_feeds/google_merchant.py +++ b/saleor/data_feeds/google_merchant.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - import gzip import csv @@ -7,7 +5,6 @@ from django.contrib.sites.models import Site from django.contrib.syndication.views import add_domain from django.core.files.storage import default_storage -from django.utils import six from django.utils.encoding import smart_text from ..discount.models import Sale @@ -221,9 +218,6 @@ def update_feed(file_path=FILE_PATH): module as FILE_PATH. """ with default_storage.open(file_path, 'wb') as output_file: - if six.PY3: - output = gzip.open(output_file, 'wt') - else: - output = gzip.GzipFile(fileobj=output_file, mode='w') + output = gzip.open(output_file, 'wt') write_feed(output) output.close() diff --git a/saleor/data_feeds/management/commands/update_feeds.py b/saleor/data_feeds/management/commands/update_feeds.py index 8fda5e78cff..2eea346da39 100644 --- a/saleor/data_feeds/management/commands/update_feeds.py +++ b/saleor/data_feeds/management/commands/update_feeds.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.core.management import BaseCommand from ...google_merchant import update_feed diff --git a/saleor/data_feeds/urls.py b/saleor/data_feeds/urls.py index 3932b21af5e..bf67b240e23 100644 --- a/saleor/data_feeds/urls.py +++ b/saleor/data_feeds/urls.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf.urls import url from django.views.generic.base import RedirectView diff --git a/saleor/discount/forms.py b/saleor/discount/forms.py index a739cbf38bc..3590b39e55f 100644 --- a/saleor/discount/forms.py +++ b/saleor/discount/forms.py @@ -1,11 +1,10 @@ -from __future__ import unicode_literals - from datetime import date + from django import forms from django.utils.encoding import smart_text from django.utils.translation import pgettext_lazy -from .models import Voucher, NotApplicable +from .models import NotApplicable, Voucher class VoucherField(forms.ModelChoiceField): diff --git a/saleor/discount/models.py b/saleor/discount/models.py index 347b125f732..683f9232f19 100644 --- a/saleor/discount/models.py +++ b/saleor/discount/models.py @@ -1,12 +1,10 @@ -from __future__ import unicode_literals - from datetime import date from decimal import Decimal from django.conf import settings from django.db import models from django.db.models import F -from django.utils.encoding import python_2_unicode_compatible, smart_text +from django.utils.encoding import smart_text from django.utils.translation import pgettext, pgettext_lazy from django_countries import countries from django_prices.models import PriceField @@ -49,7 +47,6 @@ def decrease_usage(self, voucher): voucher.save(update_fields=['used']) -@python_2_unicode_compatible class Voucher(models.Model): APPLY_TO_ONE_PRODUCT = 'one' @@ -264,7 +261,6 @@ def get_discount_for_checkout(self, checkout): raise NotImplementedError('Unknown discount type') -@python_2_unicode_compatible class Sale(models.Model): FIXED = 'fixed' PERCENTAGE = 'percentage' diff --git a/saleor/discount/templatetags/voucher.py b/saleor/discount/templatetags/voucher.py index 6aebb34162b..0a9d42410f7 100644 --- a/saleor/discount/templatetags/voucher.py +++ b/saleor/discount/templatetags/voucher.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django import template from django_prices.templatetags.prices_i18n import gross from prices import Price diff --git a/saleor/graphql/api.py b/saleor/graphql/api.py index 4c631681dc7..b6b2e912f8e 100644 --- a/saleor/graphql/api.py +++ b/saleor/graphql/api.py @@ -1,22 +1,20 @@ -from __future__ import unicode_literals - import functools -import graphene import operator from django.db.models import Q +from django_prices.templatetags import prices_i18n +import graphene from graphene import relay -from graphene_django import DjangoObjectType, DjangoConnectionField +from graphene_django import DjangoConnectionField, DjangoObjectType from graphene_django.debug import DjangoDebug -from django_prices.templatetags import prices_i18n -from ..product.models import (AttributeChoiceValue, Category, Product, - ProductAttribute, ProductImage, ProductVariant) -from ..product.utils import get_availability, products_for_api +from ..product.models import ( + AttributeChoiceValue, Category, Product, ProductAttribute, ProductImage, + ProductVariant) from ..product.templatetags.product_images import product_first_image +from ..product.utils import get_availability, products_for_api from .scalars import AttributesFilterScalar -from .utils import (CategoryAncestorsCache, DjangoPkInterface) - +from .utils import CategoryAncestorsCache, DjangoPkInterface CONTEXT_CACHE_NAME = '__cache__' CACHE_ANCESTORS = 'ancestors' diff --git a/saleor/graphql/scalars.py b/saleor/graphql/scalars.py index fa46af62875..b9b767644a5 100644 --- a/saleor/graphql/scalars.py +++ b/saleor/graphql/scalars.py @@ -1,6 +1,3 @@ -from __future__ import unicode_literals - -from django.utils import six from graphene.types import Scalar from graphql.language import ast @@ -16,7 +13,7 @@ def parse_literal(node): @staticmethod def parse_value(value): - if isinstance(value, six.string_types): + if isinstance(value, str): splitted = value.split(":") if len(splitted) == 2: return tuple(splitted) diff --git a/saleor/graphql/utils.py b/saleor/graphql/utils.py index 14a0055a17a..90f185e8d81 100644 --- a/saleor/graphql/utils.py +++ b/saleor/graphql/utils.py @@ -1,11 +1,8 @@ -from __future__ import unicode_literals - -import graphene - from django.shortcuts import _get_queryset +import graphene -class CategoryAncestorsCache(object): +class CategoryAncestorsCache: """ Cache used to store ancestors of a category in GraphQL context in order to reduce number of database queries. Categories of the same tree depth level diff --git a/saleor/order/__init__.py b/saleor/order/__init__.py index 35a0f4b13bb..40c7f0f3588 100644 --- a/saleor/order/__init__.py +++ b/saleor/order/__init__.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.utils.translation import pgettext_lazy diff --git a/saleor/order/emails.py b/saleor/order/emails.py index d8cd39a801b..3cb91fb6773 100644 --- a/saleor/order/emails.py +++ b/saleor/order/emails.py @@ -1,9 +1,7 @@ -from __future__ import unicode_literals - -from templated_email import send_templated_mail +from celery import shared_task from django.conf import settings from django.contrib.sites.models import Site -from celery import shared_task +from templated_email import send_templated_mail CONFIRM_ORDER_TEMPLATE = 'order/confirm_order' CONFIRM_PAYMENT_TEMPLATE = 'order/payment/confirm_payment' diff --git a/saleor/order/forms.py b/saleor/order/forms.py index 5eb2ac4f1d7..0691c356880 100644 --- a/saleor/order/forms.py +++ b/saleor/order/forms.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django import forms from django.conf import settings from django.utils.translation import pgettext_lazy diff --git a/saleor/order/models.py b/saleor/order/models.py index 2c380bf433b..8e29687630b 100644 --- a/saleor/order/models.py +++ b/saleor/order/models.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from decimal import Decimal from uuid import uuid4 @@ -8,7 +6,6 @@ from django.core.validators import MaxValueValidator, MinValueValidator from django.db import models from django.urls import reverse -from django.utils.encoding import python_2_unicode_compatible from django.utils.timezone import now from django.utils.translation import pgettext_lazy from django_prices.models import PriceField @@ -24,7 +21,6 @@ from ..userprofile.models import Address -@python_2_unicode_compatible class Order(models.Model, ItemSet): status = models.CharField( pgettext_lazy('Order field', 'order status'), @@ -247,7 +243,6 @@ def can_edit_lines(self): return self.status not in {OrderStatus.CANCELLED, OrderStatus.SHIPPED} -@python_2_unicode_compatible class OrderLine(models.Model, ItemLine): delivery_group = models.ForeignKey( DeliveryGroup, related_name='lines', editable=False, @@ -262,7 +257,7 @@ class OrderLine(models.Model, ItemLine): product_sku = models.CharField( pgettext_lazy('Ordered line field', 'sku'), max_length=32) stock_location = models.CharField( - pgettext_lazy('OrderLine field', 'stock location'), max_length=100, + pgettext_lazy('Ordered line field', 'stock location'), max_length=100, default='') stock = models.ForeignKey( 'product.Stock', on_delete=models.SET_NULL, null=True, @@ -277,11 +272,6 @@ class OrderLine(models.Model, ItemLine): pgettext_lazy('Ordered line field', 'unit price (gross)'), max_digits=12, decimal_places=4) - class Meta: - verbose_name = pgettext_lazy('Ordered line model', 'Ordered line') - verbose_name_plural = pgettext_lazy( - 'Ordered line model', 'Ordered lines') - def __str__(self): return self.product_name @@ -353,7 +343,6 @@ def get_captured_price(self): return Price(self.captured_amount, currency=self.currency) -@python_2_unicode_compatible class OrderHistoryEntry(models.Model): date = models.DateTimeField( pgettext_lazy('Order history entry field', 'last history change'), @@ -382,7 +371,6 @@ def __str__(self): 'OrderHistoryEntry for Order #%d') % self.order.pk -@python_2_unicode_compatible class OrderNote(models.Model): user = models.ForeignKey( settings.AUTH_USER_MODEL, on_delete=models.CASCADE) diff --git a/saleor/order/urls.py b/saleor/order/urls.py index f67133ff3b0..5a1668ae50d 100644 --- a/saleor/order/urls.py +++ b/saleor/order/urls.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf.urls import url from ..core import TOKEN_PATTERN diff --git a/saleor/order/utils.py b/saleor/order/utils.py index 7c127015d08..3b56a85833a 100644 --- a/saleor/order/utils.py +++ b/saleor/order/utils.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from functools import wraps from django.conf import settings diff --git a/saleor/order/views.py b/saleor/order/views.py index ca543f72499..14db0e18109 100644 --- a/saleor/order/views.py +++ b/saleor/order/views.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - import logging from django.conf import settings diff --git a/saleor/product/__init__.py b/saleor/product/__init__.py index 4d990f56d6c..df767e1f528 100644 --- a/saleor/product/__init__.py +++ b/saleor/product/__init__.py @@ -1,9 +1,7 @@ -from __future__ import unicode_literals - from django.utils.translation import pgettext_lazy -class ProductAvailabilityStatus(object): +class ProductAvailabilityStatus: NOT_PUBLISHED = 'not-published' VARIANTS_MISSSING = 'variants-missing' NOT_CARRIED = 'not-carried' @@ -32,7 +30,7 @@ def get_display(status): raise NotImplementedError('Unknown status: %s' % status) -class VariantAvailabilityStatus(object): +class VariantAvailabilityStatus: AVAILABLE = 'available' NOT_CARRIED = 'not-carried' OUT_OF_STOCK = 'out-of-stock' diff --git a/saleor/product/filters.py b/saleor/product/filters.py index fed1d4bb15b..9ad4abf23f2 100644 --- a/saleor/product/filters.py +++ b/saleor/product/filters.py @@ -1,17 +1,13 @@ -from __future__ import unicode_literals from collections import OrderedDict -from django_filters import ( - MultipleChoiceFilter, RangeFilter, OrderingFilter) from django.forms import CheckboxSelectMultiple, ValidationError from django.utils.translation import pgettext_lazy - +from django_filters import MultipleChoiceFilter, OrderingFilter, RangeFilter from django_prices.models import PriceField from ..core.filters import SortedFilterSet from .models import Product, ProductAttribute - SORT_BY_FIELDS = { 'name': pgettext_lazy('Product list sorting option', 'name'), 'price': pgettext_lazy('Product list sorting option', 'price')} diff --git a/saleor/product/forms.py b/saleor/product/forms.py index 235c35c8a96..057b0aff40e 100644 --- a/saleor/product/forms.py +++ b/saleor/product/forms.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - import json from django import forms diff --git a/saleor/product/models.py b/saleor/product/models.py index 6a4460dbabb..8aec8a9047a 100644 --- a/saleor/product/models.py +++ b/saleor/product/models.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - import datetime from decimal import Decimal @@ -9,8 +7,7 @@ from django.db import models from django.db.models import F, Max, Q from django.urls import reverse -from django.utils import six -from django.utils.encoding import python_2_unicode_compatible, smart_text +from django.utils.encoding import smart_text from django.utils.text import slugify from django.utils.translation import pgettext_lazy from django_prices.models import Price, PriceField @@ -25,7 +22,6 @@ from .utils import get_attributes_display_map -@python_2_unicode_compatible class Category(MPTTModel): name = models.CharField( pgettext_lazy('Category field', 'name'), max_length=128) @@ -71,7 +67,6 @@ def set_is_hidden_descendants(self, is_hidden): self.get_descendants().update(is_hidden=is_hidden) -@python_2_unicode_compatible class ProductClass(models.Model): name = models.CharField( pgettext_lazy('Product class field', 'name'), max_length=128) @@ -109,7 +104,6 @@ def get_available_products(self): is_published=True) -@python_2_unicode_compatible class Product(models.Model, ItemRange): product_class = models.ForeignKey( ProductClass, related_name='products', @@ -216,7 +210,6 @@ def get_gross_price_range(self, **kwargs): return PriceRange(min(grosses), max(grosses)) -@python_2_unicode_compatible class ProductVariant(models.Model, Item): sku = models.CharField( pgettext_lazy('Product variant field', 'SKU'), max_length=32, @@ -290,7 +283,7 @@ def display_variant(self, attributes=None): return ', '.join( ['%s: %s' % (smart_text(attributes.get(id=int(key))), smart_text(value)) - for (key, value) in six.iteritems(values)]) + for (key, value) in values.items()]) else: return smart_text(self.sku) @@ -318,7 +311,6 @@ def get_cost_price(self): return stock.cost_price -@python_2_unicode_compatible class StockLocation(models.Model): name = models.CharField( pgettext_lazy('Stock location field', 'location'), max_length=100) @@ -351,7 +343,6 @@ def decrease_stock(self, stock, quantity): stock.save(update_fields=['quantity', 'quantity_allocated']) -@python_2_unicode_compatible class Stock(models.Model): variant = models.ForeignKey( ProductVariant, related_name='stock', @@ -384,7 +375,6 @@ def quantity_available(self): return max(self.quantity - self.quantity_allocated, 0) -@python_2_unicode_compatible class ProductAttribute(models.Model): slug = models.SlugField( pgettext_lazy('Product attribute field', 'internal name'), @@ -406,7 +396,6 @@ def has_values(self): return self.values.exists() -@python_2_unicode_compatible class AttributeChoiceValue(models.Model): name = models.CharField( pgettext_lazy('Attribute choice value field', 'display name'), diff --git a/saleor/product/templatetags/discount.py b/saleor/product/templatetags/discount.py index dba3c03e170..33359da5915 100644 --- a/saleor/product/templatetags/discount.py +++ b/saleor/product/templatetags/discount.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django import template register = template.Library() diff --git a/saleor/product/templatetags/price_ranges.py b/saleor/product/templatetags/price_ranges.py index 58cfd748b34..67c4c5853dd 100644 --- a/saleor/product/templatetags/price_ranges.py +++ b/saleor/product/templatetags/price_ranges.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django import template register = template.Library() diff --git a/saleor/product/templatetags/product_images.py b/saleor/product/templatetags/product_images.py index 7ff1663fa65..ea7319a3986 100644 --- a/saleor/product/templatetags/product_images.py +++ b/saleor/product/templatetags/product_images.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - import logging import re import warnings diff --git a/saleor/product/urls.py b/saleor/product/urls.py index eb4150d1f16..792a3322de1 100644 --- a/saleor/product/urls.py +++ b/saleor/product/urls.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf.urls import url from . import views diff --git a/saleor/product/utils.py b/saleor/product/utils.py index 9201bed978e..721a444fb55 100644 --- a/saleor/product/utils.py +++ b/saleor/product/utils.py @@ -1,9 +1,6 @@ -from __future__ import unicode_literals - from collections import defaultdict, namedtuple from prices import Price, PriceRange -from six import iteritems from django.conf import settings from django.contrib.auth.models import AnonymousUser @@ -195,7 +192,7 @@ def get_variant_picker_data(product, discounts=None, local_currency=None): 'schemaData': schema_data} data['variants'].append(variant_data) - for variant_key, variant_value in iteritems(variant.attributes): + for variant_key, variant_value in variant.attributes.items(): filter_available_variants[int(variant_key)].append( int(variant_value)) diff --git a/saleor/product/views.py b/saleor/product/views.py index 4a0530c6049..8d5e20d130c 100644 --- a/saleor/product/views.py +++ b/saleor/product/views.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - import datetime import json diff --git a/saleor/registration/backends/__init__.py b/saleor/registration/backends/__init__.py index fd44a9a4d4a..fd80fb2eb59 100644 --- a/saleor/registration/backends/__init__.py +++ b/saleor/registration/backends/__init__.py @@ -1,9 +1,7 @@ -from __future__ import unicode_literals - from ...site.utils import get_authorization_key_for_backend -class BaseBackend(object): +class BaseBackend: def get_key_and_secret(self): """Return tuple with Consumer Key and Consumer Secret for current service provider. Must return (key, secret), order *must* be respected. diff --git a/saleor/registration/backends/facebook.py b/saleor/registration/backends/facebook.py index 5e4e904be05..b372ac016e5 100644 --- a/saleor/registration/backends/facebook.py +++ b/saleor/registration/backends/facebook.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from social_core.backends.facebook import FacebookOAuth2 from . import BaseBackend diff --git a/saleor/registration/backends/google.py b/saleor/registration/backends/google.py index ff813900858..6c8e205b957 100644 --- a/saleor/registration/backends/google.py +++ b/saleor/registration/backends/google.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from social_core.backends.google import GoogleOAuth2 from . import BaseBackend diff --git a/saleor/registration/forms.py b/saleor/registration/forms.py index 0dbcf517fa0..f7ac59d83df 100644 --- a/saleor/registration/forms.py +++ b/saleor/registration/forms.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django import forms from django.contrib.auth import forms as django_forms from django.http.request import HttpRequest diff --git a/saleor/registration/urls.py b/saleor/registration/urls.py index 60e4501dc60..76b132d5e68 100644 --- a/saleor/registration/urls.py +++ b/saleor/registration/urls.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf.urls import url from django.contrib.auth import views as django_views diff --git a/saleor/registration/views.py b/saleor/registration/views.py index 7bc8556281a..80248a4dea8 100644 --- a/saleor/registration/views.py +++ b/saleor/registration/views.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf import settings from django.contrib import auth, messages from django.contrib.auth import views as django_views diff --git a/saleor/search/backends/elasticsearch.py b/saleor/search/backends/elasticsearch.py index 62a908cd742..e78dbb5099c 100644 --- a/saleor/search/backends/elasticsearch.py +++ b/saleor/search/backends/elasticsearch.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals from . import elasticsearch_dashboard, elasticsearch_storefront diff --git a/saleor/search/backends/elasticsearch_dashboard.py b/saleor/search/backends/elasticsearch_dashboard.py index 59cbf70163f..cf5b0c32c84 100644 --- a/saleor/search/backends/elasticsearch_dashboard.py +++ b/saleor/search/backends/elasticsearch_dashboard.py @@ -1,8 +1,7 @@ -from __future__ import unicode_literals - -from ..documents import ProductDocument, OrderDocument, UserDocument from elasticsearch_dsl.query import MultiMatch +from ..documents import OrderDocument, ProductDocument, UserDocument + def _search_products(phrase): prod_query = MultiMatch( diff --git a/saleor/search/backends/elasticsearch_storefront.py b/saleor/search/backends/elasticsearch_storefront.py index 3dd363c71c2..63f2b530884 100644 --- a/saleor/search/backends/elasticsearch_storefront.py +++ b/saleor/search/backends/elasticsearch_storefront.py @@ -1,6 +1,5 @@ -from __future__ import unicode_literals - from elasticsearch_dsl.query import MultiMatch + from ..documents import ProductDocument diff --git a/saleor/search/backends/picker.py b/saleor/search/backends/picker.py index 732bb5ab834..11abd885db7 100644 --- a/saleor/search/backends/picker.py +++ b/saleor/search/backends/picker.py @@ -1,7 +1,5 @@ -from __future__ import unicode_literals - -from django.utils.module_loading import import_module from django.conf import settings +from django.utils.module_loading import import_module def pick_backend(): diff --git a/saleor/search/backends/postgresql.py b/saleor/search/backends/postgresql.py index 020da0c9039..70d1fd37eb1 100644 --- a/saleor/search/backends/postgresql.py +++ b/saleor/search/backends/postgresql.py @@ -1,5 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals from . import postgresql_dashboard, postgresql_storefront diff --git a/saleor/search/backends/test_elasticsearch_dashboard.py b/saleor/search/backends/test_elasticsearch_dashboard.py index 0e79a3af2e9..33c3e143467 100644 --- a/saleor/search/backends/test_elasticsearch_dashboard.py +++ b/saleor/search/backends/test_elasticsearch_dashboard.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals from . import elasticsearch_dashboard PHRASE = 'You can go to the west' diff --git a/saleor/search/backends/test_elasticsearch_storefront.py b/saleor/search/backends/test_elasticsearch_storefront.py index a8d3f40ed63..eef5ed8bc63 100644 --- a/saleor/search/backends/test_elasticsearch_storefront.py +++ b/saleor/search/backends/test_elasticsearch_storefront.py @@ -1,4 +1,3 @@ -from __future__ import unicode_literals from . import elasticsearch_storefront PHRASE = 'How fortunate man with none' diff --git a/saleor/search/documents.py b/saleor/search/documents.py index ef4a260df8b..2f07490c96e 100644 --- a/saleor/search/documents.py +++ b/saleor/search/documents.py @@ -1,11 +1,9 @@ -from __future__ import unicode_literals - from django_elasticsearch_dsl import DocType, Index, fields from elasticsearch_dsl import analyzer, token_filter + +from ..order.models import Order from ..product.models import Product from ..userprofile.models import User -from ..order.models import Order - storefront = Index('storefront') storefront.settings(number_of_shards=1, number_of_replicas=0) diff --git a/saleor/search/forms.py b/saleor/search/forms.py index f581f4ed09e..d0459ec2095 100644 --- a/saleor/search/forms.py +++ b/saleor/search/forms.py @@ -1,7 +1,6 @@ -from __future__ import unicode_literals - from django import forms from django.utils.translation import pgettext + from .backends import picker diff --git a/saleor/search/urls.py b/saleor/search/urls.py index 163425966d8..049326b7ac8 100644 --- a/saleor/search/urls.py +++ b/saleor/search/urls.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf.urls import url from . import views diff --git a/saleor/search/views.py b/saleor/search/views.py index d740d02b85c..bb723c3dc7a 100644 --- a/saleor/search/views.py +++ b/saleor/search/views.py @@ -1,11 +1,10 @@ -from __future__ import unicode_literals - -from django.core.paginator import Paginator, InvalidPage from django.conf import settings +from django.core.paginator import InvalidPage, Paginator from django.http import Http404 from django.shortcuts import render + +from ..product.utils import products_with_availability, products_with_details from .forms import SearchForm -from ..product.utils import products_with_details, products_with_availability def paginate_results(results, get_data, paginate_by=settings.PAGINATE_BY): diff --git a/saleor/settings.py b/saleor/settings.py index e7145948b5b..8f8bd3fdbc2 100644 --- a/saleor/settings.py +++ b/saleor/settings.py @@ -1,12 +1,10 @@ -from __future__ import unicode_literals - import ast import os.path import dj_database_url import dj_email_url -import django_cache_url from django.contrib.messages import constants as messages +import django_cache_url def get_list(text): diff --git a/saleor/shipping/models.py b/saleor/shipping/models.py index c0800a2e6f8..9887654af7e 100644 --- a/saleor/shipping/models.py +++ b/saleor/shipping/models.py @@ -1,23 +1,19 @@ -from __future__ import absolute_import, unicode_literals from itertools import groupby from operator import itemgetter from django.conf import settings from django.db import models from django.db.models import Q -from django.utils.encoding import python_2_unicode_compatible from django.utils.translation import pgettext_lazy +from django_countries import countries from django_prices.models import PriceField from prices import PriceRange -from django_countries import countries - ANY_COUNTRY = '' ANY_COUNTRY_DISPLAY = pgettext_lazy('Country choice', 'Rest of World') COUNTRY_CODE_CHOICES = [(ANY_COUNTRY, ANY_COUNTRY_DISPLAY)] + list(countries) -@python_2_unicode_compatible class ShippingMethod(models.Model): name = models.CharField( @@ -77,7 +73,6 @@ def unique_for_country_code(self, country_code): return self.filter(id__in=ids) -@python_2_unicode_compatible class ShippingMethodCountry(models.Model): country_code = models.CharField( diff --git a/saleor/shipping/utils.py b/saleor/shipping/utils.py index c4490b6879d..0ae8b475311 100644 --- a/saleor/shipping/utils.py +++ b/saleor/shipping/utils.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from prices import PriceRange from .models import ShippingMethodCountry diff --git a/saleor/site/__init__.py b/saleor/site/__init__.py index 89831584308..2739f52689d 100644 --- a/saleor/site/__init__.py +++ b/saleor/site/__init__.py @@ -1,6 +1,3 @@ -from __future__ import unicode_literals - - class AuthenticationBackends: GOOGLE = 'google-oauth2' FACEBOOK = 'facebook' diff --git a/saleor/site/context_processors.py b/saleor/site/context_processors.py index 377e493d37b..569735d3eab 100644 --- a/saleor/site/context_processors.py +++ b/saleor/site/context_processors.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.contrib.sites.shortcuts import get_current_site diff --git a/saleor/site/models.py b/saleor/site/models.py index 731b3c05f1a..8d5c6f47c72 100644 --- a/saleor/site/models.py +++ b/saleor/site/models.py @@ -1,8 +1,5 @@ -from __future__ import unicode_literals - from django.contrib.sites.models import Site from django.db import models -from django.utils.encoding import python_2_unicode_compatible from django.utils.translation import pgettext_lazy from . import AuthenticationBackends @@ -11,7 +8,6 @@ patch_contrib_sites() -@python_2_unicode_compatible class SiteSettings(models.Model): site = models.OneToOneField( Site, related_name='settings', on_delete=models.CASCADE) @@ -37,7 +33,6 @@ def available_backends(self): return self.authorizationkey_set.values_list('name', flat=True) -@python_2_unicode_compatible class AuthorizationKey(models.Model): site_settings = models.ForeignKey(SiteSettings, on_delete=models.CASCADE) name = models.CharField( diff --git a/saleor/site/patch_sites.py b/saleor/site/patch_sites.py index 3bc432cf28b..4c514d1fc02 100644 --- a/saleor/site/patch_sites.py +++ b/saleor/site/patch_sites.py @@ -3,8 +3,6 @@ multiple instances of the application server, we're patching it with a thread-safe structure and methods that use it underneath. ''' -from __future__ import unicode_literals - import threading from django.contrib.sites.models import Site, SiteManager diff --git a/saleor/site/utils.py b/saleor/site/utils.py index 4f6d1f2fa7d..14ed56048b2 100644 --- a/saleor/site/utils.py +++ b/saleor/site/utils.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf import settings from .models import AuthorizationKey diff --git a/saleor/urls.py b/saleor/urls.py index 0a802e52e08..7b18642fa05 100644 --- a/saleor/urls.py +++ b/saleor/urls.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf import settings from django.conf.urls import url, include from django.conf.urls.static import static diff --git a/saleor/userprofile/forms.py b/saleor/userprofile/forms.py index 395b9924b6e..fc9f83ebdc9 100644 --- a/saleor/userprofile/forms.py +++ b/saleor/userprofile/forms.py @@ -1,6 +1,3 @@ -# encoding: utf-8 -from __future__ import unicode_literals - from django.conf import settings from django.contrib.auth import forms as django_forms, update_session_auth_hash from phonenumbers.phonenumberutil import country_code_for_region diff --git a/saleor/userprofile/i18n.py b/saleor/userprofile/i18n.py index b64c408c185..d3d4784d0f7 100644 --- a/saleor/userprofile/i18n.py +++ b/saleor/userprofile/i18n.py @@ -1,18 +1,15 @@ -from __future__ import unicode_literals - from collections import defaultdict -import i18naddress from django import forms from django.forms.forms import BoundField -from django_countries.data import COUNTRIES from django.utils.translation import pgettext_lazy +from django_countries.data import COUNTRIES +import i18naddress from phonenumber_field.formfields import PhoneNumberField from .models import Address -from .widgets import PhonePrefixWidget from .validators import validate_possible_number - +from .widgets import PhonePrefixWidget COUNTRY_FORMS = {} UNKNOWN_COUNTRIES = set() diff --git a/saleor/userprofile/impersonate.py b/saleor/userprofile/impersonate.py index e392b37e426..85ad614038a 100644 --- a/saleor/userprofile/impersonate.py +++ b/saleor/userprofile/impersonate.py @@ -1,6 +1,4 @@ # Module used to config django-impersonate app -from __future__ import unicode_literals - from .models import User diff --git a/saleor/userprofile/management/commands/changepassword.py b/saleor/userprofile/management/commands/changepassword.py index e43724d7b2b..3be84aa9672 100644 --- a/saleor/userprofile/management/commands/changepassword.py +++ b/saleor/userprofile/management/commands/changepassword.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.contrib.auth.management.commands.changepassword import Command __all__ = ['Command'] diff --git a/saleor/userprofile/management/commands/createsuperuser.py b/saleor/userprofile/management/commands/createsuperuser.py index 2df38527986..a9fef1a16b7 100644 --- a/saleor/userprofile/management/commands/createsuperuser.py +++ b/saleor/userprofile/management/commands/createsuperuser.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.contrib.auth.management.commands.createsuperuser import Command __all__ = ['Command'] diff --git a/saleor/userprofile/models.py b/saleor/userprofile/models.py index 28eeefc1d79..0ffbb61733a 100644 --- a/saleor/userprofile/models.py +++ b/saleor/userprofile/models.py @@ -1,11 +1,8 @@ -from __future__ import unicode_literals - from django.contrib.auth.models import ( AbstractBaseUser, BaseUserManager, PermissionsMixin) from django.db import models from django.forms.models import model_to_dict from django.utils import timezone -from django.utils.encoding import python_2_unicode_compatible from django.utils.translation import pgettext_lazy from django_countries.fields import Country, CountryField from phonenumber_field.modelfields import PhoneNumberField @@ -50,7 +47,6 @@ def store_address(self, user, address): return address -@python_2_unicode_compatible class Address(models.Model): first_name = models.CharField( pgettext_lazy('Address field', 'given name'), diff --git a/saleor/userprofile/templatetags/i18n_address_tags.py b/saleor/userprofile/templatetags/i18n_address_tags.py index 8372c539a5f..060d2f16df5 100644 --- a/saleor/userprofile/templatetags/i18n_address_tags.py +++ b/saleor/userprofile/templatetags/i18n_address_tags.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django import template from django.utils.safestring import mark_safe from django.utils.translation import pgettext diff --git a/saleor/userprofile/urls.py b/saleor/userprofile/urls.py index 9a460956ced..e24992429e8 100644 --- a/saleor/userprofile/urls.py +++ b/saleor/userprofile/urls.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.conf.urls import url from . import views diff --git a/saleor/userprofile/utils.py b/saleor/userprofile/utils.py index fcbf3f347bf..1048fa42cc2 100644 --- a/saleor/userprofile/utils.py +++ b/saleor/userprofile/utils.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from .models import Address diff --git a/saleor/userprofile/views.py b/saleor/userprofile/views.py index 10037d49e1d..ded93a1f2bc 100755 --- a/saleor/userprofile/views.py +++ b/saleor/userprofile/views.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.contrib import messages from django.contrib.auth.decorators import login_required from django.http import HttpResponseRedirect diff --git a/saleor/wsgi/__init__.py b/saleor/wsgi/__init__.py index 5ad2564cdc5..3d04e8426dc 100644 --- a/saleor/wsgi/__init__.py +++ b/saleor/wsgi/__init__.py @@ -13,8 +13,6 @@ framework. """ -from __future__ import unicode_literals - import os os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'saleor.settings') diff --git a/saleor/wsgi/health_check.py b/saleor/wsgi/health_check.py index 4738139a844..48229cf78e9 100644 --- a/saleor/wsgi/health_check.py +++ b/saleor/wsgi/health_check.py @@ -1,6 +1,3 @@ -from __future__ import unicode_literals - - def health_check(application, health_url): def health_check_wrapper(environ, start_response): if environ.get('PATH_INFO') == health_url: diff --git a/tests/conftest.py b/tests/conftest.py index f7461956c7f..fb73e5b5bee 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,31 +1,26 @@ -# coding: utf-8 -from __future__ import unicode_literals - from decimal import Decimal -import pytest - from io import BytesIO -from PIL import Image -from django.contrib.sites.models import Site -from django.core.files.uploadedfile import SimpleUploadedFile +import pytest from django.contrib.auth.models import AnonymousUser, Group, Permission +from django.contrib.sites.models import Site from django.core.files import File +from django.core.files.uploadedfile import SimpleUploadedFile from django.utils.encoding import smart_text +from PIL import Image from mock import MagicMock - from saleor.cart import utils from saleor.cart.models import Cart from saleor.checkout.core import Checkout -from saleor.discount.models import Voucher, Sale -from saleor.order.models import Order, OrderLine, DeliveryGroup +from saleor.discount.models import Sale, Voucher +from saleor.order.models import DeliveryGroup, Order, OrderLine from saleor.order.utils import recalculate_order from saleor.product.models import ( AttributeChoiceValue, Category, Product, ProductAttribute, ProductClass, - ProductVariant, ProductImage, Stock, StockLocation) + ProductImage, ProductVariant, Stock, StockLocation) from saleor.shipping.models import ShippingMethod -from saleor.site.models import SiteSettings, AuthorizationKey +from saleor.site.models import AuthorizationKey, SiteSettings from saleor.userprofile.models import Address, User diff --git a/tests/dashboard/test_customer.py b/tests/dashboard/test_customer.py index 02d60ec6567..b2b3fe64466 100644 --- a/tests/dashboard/test_customer.py +++ b/tests/dashboard/test_customer.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.urls import reverse from saleor.userprofile.models import User diff --git a/tests/dashboard/test_group.py b/tests/dashboard/test_group.py index 8baec6058f4..2f862c39b63 100644 --- a/tests/dashboard/test_group.py +++ b/tests/dashboard/test_group.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.contrib.auth.models import Group from django.urls import reverse diff --git a/tests/dashboard/test_order.py b/tests/dashboard/test_order.py index 514aaae0e3b..2ecd784263c 100644 --- a/tests/dashboard/test_order.py +++ b/tests/dashboard/test_order.py @@ -1,19 +1,17 @@ -from __future__ import unicode_literals - from decimal import Decimal -import pytest from django.urls import reverse +import pytest +from tests.utils import get_redirect_location, get_url_path from saleor.dashboard.order.forms import ChangeQuantityForm, MoveLinesForm from saleor.order import OrderStatus from saleor.order.models import ( - DeliveryGroup, Order, OrderLine, OrderHistoryEntry) + DeliveryGroup, Order, OrderHistoryEntry, OrderLine) from saleor.order.utils import ( add_variant_to_existing_lines, change_order_line_quantity, fill_group_with_partition, remove_empty_groups) from saleor.product.models import ProductVariant, Stock, StockLocation -from tests.utils import get_redirect_location, get_url_path @pytest.mark.integration diff --git a/tests/dashboard/test_permissions.py b/tests/dashboard/test_permissions.py index 663d28b60e3..2a350c7e467 100644 --- a/tests/dashboard/test_permissions.py +++ b/tests/dashboard/test_permissions.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.urls import reverse from saleor.userprofile.models import User diff --git a/tests/dashboard/test_product.py b/tests/dashboard/test_product.py index cb68b0185a5..6cc9390cfa9 100644 --- a/tests/dashboard/test_product.py +++ b/tests/dashboard/test_product.py @@ -1,15 +1,12 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - -import json from io import BytesIO +import json -import pytest +from PIL import Image from django.conf import settings from django.core.files.uploadedfile import SimpleUploadedFile from django.urls import reverse from django.utils.encoding import smart_text -from PIL import Image +import pytest from saleor.dashboard.product import ProductBulkAction from saleor.dashboard.product.forms import ( @@ -261,7 +258,7 @@ def test_attribute_choice_value_delete(color_attribute, admin_client): def test_get_formfield_name_with_unicode_characters(db): text_attribute = ProductAttribute.objects.create( - slug=u'ąęαβδηθλμπ', name=u'ąęαβδηθλμπ') + slug='ąęαβδηθλμπ', name='ąęαβδηθλμπ') assert text_attribute.get_formfield_name() == 'attribute-ąęαβδηθλμπ' @@ -579,7 +576,7 @@ def test_product_list_filters_is_published( def test_product_list_filters_no_results(admin_client, product_list): - data = {'price_1': [u''], 'price_0': [''], 'is_featured': [''], + data = {'price_1': [''], 'price_0': [''], 'is_featured': [''], 'name': ['BADTest'], 'sort_by': [''], 'is_published': ['']} url = reverse('dashboard:product-list') diff --git a/tests/dashboard/test_shipping.py b/tests/dashboard/test_shipping.py index 17cda09c608..9f4eab4dc6a 100644 --- a/tests/dashboard/test_shipping.py +++ b/tests/dashboard/test_shipping.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.urls import reverse from saleor.shipping.models import ShippingMethod, ShippingMethodCountry diff --git a/tests/dashboard/test_site_settings.py b/tests/dashboard/test_site_settings.py index 60fa19c9924..f3fd75069c9 100644 --- a/tests/dashboard/test_site_settings.py +++ b/tests/dashboard/test_site_settings.py @@ -1,11 +1,9 @@ -from __future__ import unicode_literals - -import pytest from django.contrib.sites.models import Site from django.db.utils import IntegrityError from django.test.client import RequestFactory from django.urls import reverse from django.utils.encoding import smart_text +import pytest from saleor.dashboard.sites.forms import SiteForm, SiteSettingsForm from saleor.site import utils diff --git a/tests/dashboard/test_staff.py b/tests/dashboard/test_staff.py index 0e686eca14e..02b7a8a985b 100644 --- a/tests/dashboard/test_staff.py +++ b/tests/dashboard/test_staff.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.contrib.auth.tokens import default_token_generator from django.contrib.sites.models import Site from django.core import mail diff --git a/tests/dashboard/test_utils.py b/tests/dashboard/test_utils.py index 54f67827a88..cee28ff8db9 100644 --- a/tests/dashboard/test_utils.py +++ b/tests/dashboard/test_utils.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.test.client import RequestFactory from django.urls import reverse diff --git a/tests/settings.py b/tests/settings.py index ff3a80f7d49..2dc615e6aa0 100644 --- a/tests/settings.py +++ b/tests/settings.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - # pylint: disable=W0401, W0614 from saleor.settings import * # noqa diff --git a/tests/test_asynchronous_tasks.py b/tests/test_asynchronous_tasks.py index 17e7466522a..468cd11959f 100644 --- a/tests/test_asynchronous_tasks.py +++ b/tests/test_asynchronous_tasks.py @@ -1,10 +1,9 @@ -from __future__ import unicode_literals - import celery -import pytest import mock -from saleor.order.emails import (send_order_confirmation, - send_payment_confirmation) +import pytest + +from saleor.order.emails import ( + send_order_confirmation, send_payment_confirmation) @celery.shared_task diff --git a/tests/test_cart.py b/tests/test_cart.py index 22fb632bdcf..fe9d2102e03 100644 --- a/tests/test_cart.py +++ b/tests/test_cart.py @@ -1,9 +1,6 @@ -from __future__ import unicode_literals - import json from uuid import uuid4 -import pytest from django.contrib.auth.models import AnonymousUser from django.core import signing from django.core.exceptions import ObjectDoesNotExist @@ -12,6 +9,7 @@ from django_babel.templatetags.babel import currencyfmt from mock import MagicMock, Mock from prices import Price +import pytest from satchless.item import InsufficientStock from saleor.cart import CartStatus, forms, utils diff --git a/tests/test_checkout.py b/tests/test_checkout.py index 2e368a29f45..e00736dd540 100644 --- a/tests/test_checkout.py +++ b/tests/test_checkout.py @@ -1,10 +1,8 @@ -from __future__ import unicode_literals - -import pytest from django.conf import settings from django.contrib.auth.models import AnonymousUser from mock import MagicMock, Mock from prices import Price +import pytest from satchless.item import InsufficientStock from saleor.checkout import views @@ -123,9 +121,9 @@ def test_checkout_shipping_address_setter(): checkout.shipping_address = address assert checkout._shipping_address == address assert checkout.storage['shipping_address'] == { - 'city': u'', 'city_area': u'', 'company_name': u'', 'country': '', 'phone': u'', - 'country_area': u'', 'first_name': 'Jan', 'id': None, 'last_name': 'Kowalski', - 'postal_code': u'', 'street_address_1': u'', 'street_address_2': u''} + 'city': '', 'city_area': '', 'company_name': '', 'country': '', 'phone': '', + 'country_area': '', 'first_name': 'Jan', 'id': None, 'last_name': 'Kowalski', + 'postal_code': '', 'street_address_1': '', 'street_address_2': ''} @pytest.mark.parametrize('shipping_address, shipping_method, value', [ diff --git a/tests/test_checkout_integration.py b/tests/test_checkout_integration.py index 3dca671af12..149b9ed7f2a 100644 --- a/tests/test_checkout_integration.py +++ b/tests/test_checkout_integration.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.urls import reverse from payments import FraudStatus, PaymentStatus diff --git a/tests/test_core.py b/tests/test_core.py index f1b963874e1..459d60efee2 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -1,7 +1,5 @@ -from __future__ import unicode_literals - -import pytest from mock import Mock +import pytest from saleor.core.utils import ( Country, create_superuser, get_country_by_ip, get_currency_for_country, diff --git a/tests/test_data_feeds.py b/tests/test_data_feeds.py index 8eccc314010..cfddfccd732 100644 --- a/tests/test_data_feeds.py +++ b/tests/test_data_feeds.py @@ -1,23 +1,13 @@ -from __future__ import unicode_literals - import csv - -from mock import Mock, patch - -from django.utils import six -from django.utils.encoding import smart_text -if six.PY3: - from io import StringIO -else: - from StringIO import StringIO +from io import StringIO from django.contrib.sites.models import Site +from django.utils.encoding import smart_text +from mock import Mock, patch +from saleor.data_feeds.google_merchant import ( + get_feed_items, item_attributes, item_google_product_category, write_feed) from saleor.product.models import AttributeChoiceValue, Category -from saleor.data_feeds.google_merchant import (get_feed_items, - item_attributes, - item_google_product_category, - write_feed) def test_saleor_feed_items(product_in_stock): diff --git a/tests/test_discounts.py b/tests/test_discounts.py index 1fa5dd89625..5c528d1a26d 100644 --- a/tests/test_discounts.py +++ b/tests/test_discounts.py @@ -1,18 +1,16 @@ -from __future__ import unicode_literals - from datetime import date, datetime, timedelta from decimal import Decimal + from freezegun import freeze_time -import pytest from mock import Mock from prices import FixedDiscount, FractionalDiscount, Price +import pytest from saleor.cart.utils import get_category_variants_and_prices from saleor.checkout.core import Checkout from saleor.discount.forms import CheckoutDiscountForm from saleor.discount.models import NotApplicable, Sale, Voucher -from saleor.product.models import Category -from saleor.product.models import Product, ProductVariant +from saleor.product.models import Category, Product, ProductVariant @pytest.mark.parametrize('limit, value', [ diff --git a/tests/test_elasticsearch.py b/tests/test_elasticsearch.py index 01e5c243a5c..188bc6e2fca 100644 --- a/tests/test_elasticsearch.py +++ b/tests/test_elasticsearch.py @@ -1,11 +1,9 @@ -from __future__ import unicode_literals - from decimal import Decimal from django.core.urlresolvers import reverse +from elasticsearch_dsl.connections import connections import pytest -from elasticsearch_dsl.connections import connections from saleor.order.models import Order from saleor.product.models import Product from saleor.userprofile.models import User diff --git a/tests/test_emails.py b/tests/test_emails.py index 5c1930c1faa..88a80bf8a86 100644 --- a/tests/test_emails.py +++ b/tests/test_emails.py @@ -1,8 +1,7 @@ -from __future__ import unicode_literals from django.conf import settings +import mock import saleor.order.emails as emails -import mock EMAIL = "foo@bar.com" SITE_NAME = 'mirumee.com' diff --git a/tests/test_graphql.py b/tests/test_graphql.py index 8e4d20129f9..f06b29d5413 100644 --- a/tests/test_graphql.py +++ b/tests/test_graphql.py @@ -1,6 +1,5 @@ -from __future__ import unicode_literals - import json + import pytest from saleor.product.models import Category, ProductAttribute diff --git a/tests/test_impersonation.py b/tests/test_impersonation.py index d66b3d8cd42..81da3af852d 100644 --- a/tests/test_impersonation.py +++ b/tests/test_impersonation.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.core.urlresolvers import reverse from saleor.userprofile.models import User diff --git a/tests/test_order.py b/tests/test_order.py index d7d35fe0dcb..dde1d0a95d4 100644 --- a/tests/test_order.py +++ b/tests/test_order.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from prices import Price from saleor.cart.models import Cart diff --git a/tests/test_payment.py b/tests/test_payment.py index 591afb9c75b..0a8fa296fe2 100644 --- a/tests/test_payment.py +++ b/tests/test_payment.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from prices import Price from saleor.order.models import Payment diff --git a/tests/test_postgresql_search.py b/tests/test_postgresql_search.py index aee71295e38..dcb1d25694c 100644 --- a/tests/test_postgresql_search.py +++ b/tests/test_postgresql_search.py @@ -1,6 +1,3 @@ -# -*- coding: utf-8 -*- -from __future__ import unicode_literals - from saleor.product.models import Product from saleor.order.models import Order from saleor.userprofile.models import Address, User diff --git a/tests/test_product.py b/tests/test_product.py index f243b761f57..875d6efd71f 100644 --- a/tests/test_product.py +++ b/tests/test_product.py @@ -1,12 +1,11 @@ -from __future__ import unicode_literals - import datetime import json -import pytest from django.urls import reverse from django.utils.encoding import smart_text from mock import Mock +import pytest +from tests.utils import filter_products_by_attribute from saleor.cart import CartStatus, utils from saleor.cart.models import Cart @@ -16,7 +15,6 @@ get_attributes_display_map, get_availability, get_product_availability_status, get_variant_availability_status, get_variant_picker_data) -from tests.utils import filter_products_by_attribute @pytest.fixture() diff --git a/tests/test_product_tags.py b/tests/test_product_tags.py index b29b2c0f759..89e8bd9cdbd 100644 --- a/tests/test_product_tags.py +++ b/tests/test_product_tags.py @@ -1,9 +1,9 @@ -from __future__ import unicode_literals - from django.contrib.staticfiles.templatetags.staticfiles import static from mock import Mock + from saleor.product.templatetags.product_images import ( - choose_placeholder, get_thumbnail,product_first_image) + choose_placeholder, get_thumbnail, product_first_image) + def test_get_thumbnail(): instance = Mock() diff --git a/tests/test_registration.py b/tests/test_registration.py index 8b688b5251d..b80e2cc1505 100644 --- a/tests/test_registration.py +++ b/tests/test_registration.py @@ -1,9 +1,7 @@ -from __future__ import unicode_literals - -import pytest from django.contrib.auth import get_user_model from django.contrib.auth.models import AnonymousUser from django.urls import reverse +import pytest from saleor.registration.backends import BaseBackend from saleor.registration.forms import LoginForm, SignupForm diff --git a/tests/test_sitemap.py b/tests/test_sitemap.py index 3d6b28c4ea8..e8b82334aee 100644 --- a/tests/test_sitemap.py +++ b/tests/test_sitemap.py @@ -1,5 +1,3 @@ -from __future__ import unicode_literals - from django.contrib.sites.models import Site from django.urls import reverse diff --git a/tests/test_userprofile.py b/tests/test_userprofile.py index 7baaf9d01f6..51d86044000 100644 --- a/tests/test_userprofile.py +++ b/tests/test_userprofile.py @@ -1,21 +1,14 @@ -# encoding: utf-8 -from __future__ import unicode_literals - -try: - # Python 3 - from urllib.parse import urlencode -except ImportError: - # Python 2 - from urllib import urlencode +from urllib.parse import urlencode import i18naddress import pytest from django.core.exceptions import ValidationError from django.http import QueryDict -from saleor.userprofile import forms, models, i18n +from saleor.userprofile import forms, i18n, models from saleor.userprofile.validators import validate_possible_number + @pytest.fixture def billing_address(db): return models.Address.objects.create( diff --git a/tests/utils.py b/tests/utils.py index 04fb8af7e22..fc08dc7903b 100644 --- a/tests/utils.py +++ b/tests/utils.py @@ -1,9 +1,4 @@ -from __future__ import unicode_literals - -try: - from urllib.parse import urlparse -except ImportError: - from urlparse import urlparse +from urllib.parse import urlparse from django.db.models import Q from django.utils.encoding import smart_text