Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Pep8

Michal Ociepkae4ad5a37bb34
diff --git a/cart/urls.py b/cart/urls.py
index 07f2f9d3c9..5342435410 100644
--- a/cart/urls.py
+++ b/cart/urls.py
@@ -4,4 +4,3 @@ from django.conf.urls import patterns, url
urlpatterns = patterns('cart.views',
url(r'^$', 'index', name='index'),
)
-
diff --git a/checkout/models.py b/checkout/models.py
index 71a8362390..e69de29bb2 100644
--- a/checkout/models.py
+++ b/checkout/models.py
@@ -1,3 +0,0 @@
-from django.db import models
-
-# Create your models here.
diff --git a/checkout/tests/__init__.py b/checkout/tests.py
similarity index 98%
rename from checkout/tests/__init__.py
rename to checkout/tests.py
index 08a528d079..7b6a86a313 100644
--- a/checkout/tests/__init__.py
+++ b/checkout/tests.py
@@ -1,5 +1,6 @@
-from ..steps import BaseShippingStep, BillingAddressStep, ShippingStep
+from . import BillingAddressStep, ShippingStep
from checkout import Checkout
+from checkout.steps import BaseShippingStep
from delivery import DummyShipping
from django.test import TestCase
from mock import MagicMock, patch
diff --git a/checkout/urls.py b/checkout/urls.py
index dea50eb5b6..9eabdc99a3 100644
--- a/checkout/urls.py
+++ b/checkout/urls.py
@@ -5,4 +5,3 @@ urlpatterns = patterns('checkout.views',
url(r'^$', 'details', kwargs={'step': None}, name='index'),
url(r'^(?P<step>[a-z0-9-]+)/$', 'details', name='details')
)
-
diff --git a/delivery/__init__.py b/delivery/__init__.py
index 635d2b3275..eae220c2c0 100644
--- a/delivery/__init__.py
+++ b/delivery/__init__.py
@@ -20,7 +20,8 @@ class DummyShipping(BaseDelivery):
def get_price_per_item(self, **kwargs):
weight = sum(line.product.weight for line in self.group)
qty = sum(line.quantity for line in self.group)
- return Price(qty*weight, currency=settings.SATCHLESS_DEFAULT_CURRENCY)
+ return Price(qty * weight,
+ currency=settings.SATCHLESS_DEFAULT_CURRENCY)
class DigitalDelivery(BaseDelivery):
diff --git a/order/models.py b/order/models.py
index 828425153c..96276b76d5 100644
--- a/order/models.py
+++ b/order/models.py
@@ -69,6 +69,11 @@ class Order(models.Model, ItemSet):
total = self.get_total()
return total_paid >= total.gross
+ def get_user_email(self):
+ if self.user:
+ return self.user.email
+ return self.anonymous_user_email
+
def __iter__(self):
return iter(self.groups.all())
@@ -78,11 +83,6 @@ class Order(models.Model, ItemSet):
def __unicode__(self):
return u'#%d' % (self.id, )
- def get_user_email(self):
- if self.user:
- return self.user.email
- return self.anonymous_user_email
-
@property
def billing_full_name(self):
return u'%s %s' % (self.billing_first_name, self.billing_last_name)
@@ -187,8 +187,8 @@ class OrderedItem(models.Model, ItemLine):
return Price(net=self.unit_price_net, gross=self.unit_price_gross,
currency=settings.SATCHLESS_DEFAULT_CURRENCY)
- def get_quantity(self):
- return self.quantity
-
def __unicode__(self):
return self.product_name
+
+ def get_quantity(self):
+ return self.quantity
diff --git a/product/forms.py b/product/forms.py
index c8e0012aef..40bd41698b 100644
--- a/product/forms.py
+++ b/product/forms.py
@@ -1,5 +1,6 @@
from cart.forms import AddToCartForm
+
class ProductForm(AddToCartForm):
pass
diff --git a/product/urls.py b/product/urls.py
index d00a4cc5e5..df08b1a015 100644
--- a/product/urls.py
+++ b/product/urls.py
@@ -6,4 +6,3 @@ urlpatterns = patterns('product.views',
url(r'^(?P<slug>[a-z0-9-]+?)-(?P<product_id>[0-9]+)/$', 'details',
name='details'),
)
-
diff --git a/registration/models.py b/registration/models.py
index 4eff0a2a79..4b8fe86d9c 100644
--- a/registration/models.py
+++ b/registration/models.py
@@ -30,7 +30,7 @@ class UniqueTokenManager(models.Manager): # this might end up in `utils`
def create(self, **kwargs):
assert self.token_field not in kwargs, u'Token field already filled.'
- for x in xrange(100):
+ for _x in xrange(100):
token = get_random_string(self.token_length)
conflict_filter = {self.token_field: token}
conflict = self.get_query_set().filter(**conflict_filter)
@@ -42,16 +42,17 @@ class UniqueTokenManager(models.Manager): # this might end up in `utils`
class AbstractToken(models.Model):
- class Meta:
- abstract = True
-
TOKEN_LENGTH = 32
token = models.CharField(max_length=TOKEN_LENGTH, unique=True)
valid_until = models.DateTimeField(
default=lambda: now() + timedelta(settings.ACCOUNT_ACTIVATION_DAYS))
- objects = UniqueTokenManager(token_field='token', token_length=TOKEN_LENGTH)
+ objects = UniqueTokenManager(token_field='token',
+ token_length=TOKEN_LENGTH)
+
+ class Meta:
+ abstract = True
class EmailConfirmationRequest(AbstractToken):
diff --git a/registration/tests.py b/registration/tests.py
index 293e0f4539..2a6e24cb84 100644
--- a/registration/tests.py
+++ b/registration/tests.py
@@ -31,7 +31,7 @@ class LoginUrlsTestCase(TestCase):
facebook_login_url = URL(facebook_client.get_login_uri())
query = facebook_login_url.query_params()
callback_url = URL(query['redirect_uri'][0])
- func, args, kwargs = resolve(callback_url.path())
+ func, _args, kwargs = resolve(callback_url.path())
self.assertEquals(func, oauth_callback)
self.assertEquals(kwargs['service'], FACEBOOK)
self.assertEqual(query['scope'][0], FacebookClient.scope)
@@ -43,7 +43,7 @@ class LoginUrlsTestCase(TestCase):
google_login_url = URL(google_client.get_login_uri())
params = google_login_url.query_params()
callback_url = URL(params['redirect_uri'][0])
- func, args, kwargs = resolve(callback_url.path())
+ func, _args, kwargs = resolve(callback_url.path())
self.assertEquals(func, oauth_callback)
self.assertEquals(kwargs['service'], GOOGLE)
self.assertIn(params['scope'][0], GoogleClient.scope)
@@ -115,7 +115,7 @@ class AccessTokenTestCase(BaseCommunicationTestCase):
self.requests_mock.post.return_value = self.access_token_response
def test_token_is_obtained_on_construction(self):
- """OAuth2 client asks for access token if temporary code is available"""
+ """OAuth2 client asks for access token if interim code is available"""
self.access_token_response.status_code = sentinel.ok
TestClient(local_host='http://localhost', code=sentinel.code)
self.requests_mock.post.assert_called_once()
@@ -219,8 +219,9 @@ class CallbackTestCase(TestCase):
user = self.form.get_authenticated_user()
self.assertEquals(self.authenticate_mock.mock_calls,
- [call(service=sentinel.service, username=sentinel.id),
- call(user=sentinel.user)])
+ [call(service=sentinel.service,
+ username=sentinel.id),
+ call(user=sentinel.user)])
external_data_mock.objects.create.assert_called_once_with(
service=sentinel.service, username=sentinel.id, user=sentinel.user)
self.assertEquals(user, sentinel.authed_user)
diff --git a/registration/views.py b/registration/views.py
index 24182045ce..603c9f6e61 100644
--- a/registration/views.py
+++ b/registration/views.py
@@ -2,12 +2,11 @@ from urllib import urlencode
from django.conf import settings
from django.contrib import messages
-from django.contrib.auth import (
- login as auth_login,
- logout as auth_logout,
- get_user_model)
+from django.contrib.auth import (login as auth_login, logout as auth_logout,
+ get_user_model)
from django.contrib.auth.decorators import login_required
-from django.contrib.auth.views import login as django_login_view, password_change
+from django.contrib.auth.views import (login as django_login_view,
+ password_change)
from django.core.urlresolvers import reverse
from django.shortcuts import redirect
from django.template.response import TemplateResponse
diff --git a/userprofile/models.py b/userprofile/models.py
index 65b290b746..0cecfef251 100644
--- a/userprofile/models.py
+++ b/userprofile/models.py
@@ -90,8 +90,8 @@ class UserManager(BaseUserManager):
is_active=True, **extra_fields):
'Creates a User with the given username, email and password'
email = UserManager.normalize_email(email)
- user = self.model(
- email=email, is_active=is_active, is_staff=is_staff, **extra_fields)
+ user = self.model(email=email, is_active=is_active,
+ is_staff=is_staff, **extra_fields)
if password:
user.set_password(password)
user.save()