Skip to content
This repository has been archived by the owner on Jul 29, 2020. It is now read-only.

Commit

Permalink
Add pre-commit hooks and lint codebase to match
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaoming committed Oct 23, 2016
1 parent 517d7e9 commit 511ee38
Show file tree
Hide file tree
Showing 83 changed files with 152 additions and 190 deletions.
16 changes: 16 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
- repo: git://github.com/pre-commit/pre-commit-hooks
sha: 97b88d9610bcc03982ddac33caba98bb2b751f5f
hooks:
- id: trailing-whitespace
- id: flake8
args:
- --exclude=*/*migrations/*, testproject/testproject/settings/*
- id: check-added-large-files
- id: debug-statements
- id: end-of-file-fixer
- repo: git://github.com/FalconSocial/pre-commit-python-sorter
sha: d044ff27300a6dc8b1a56cd22552e3a810dc6f49
hooks:
- id: python-import-sorter
args:
- --silent-overwrite
11 changes: 6 additions & 5 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,13 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

import sys
import os
import sys

import django
import eggplant
from django.db.models.fields.files import FileDescriptor
from djmoney.models.fields import MoneyFieldProxy

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
Expand All @@ -29,16 +34,13 @@

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "eggplant_project.settings.docs")

import django
django.setup()


# Hacks for the autodoc introspector

from django.db.models.fields.files import FileDescriptor
FileDescriptor.__get__ = lambda self, *args, **kwargs: self

from djmoney.models.fields import MoneyFieldProxy
MoneyFieldProxy.__get__ = lambda self, *args, **kwargs: self


Expand Down Expand Up @@ -79,7 +81,6 @@
sys.path = [path] + sys.path
sys.path = [os.path.join(path, 'dbbackup')] + sys.path

import eggplant

# General information about the project.
project = 'Eggplant'
Expand Down
2 changes: 1 addition & 1 deletion eggplant/accounts/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
from django.db import migrations, models


class Migration(migrations.Migration):
Expand Down
2 changes: 1 addition & 1 deletion eggplant/accounts/migrations/0002_account_department.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
from django.db import migrations, models


class Migration(migrations.Migration):
Expand Down
2 changes: 1 addition & 1 deletion eggplant/accounts/migrations/0003_account_user_profiles.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
from django.db import migrations, models


class Migration(migrations.Migration):
Expand Down
3 changes: 0 additions & 3 deletions eggplant/accounts/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
from django.test import TestCase

# Create your tests here.
9 changes: 1 addition & 8 deletions eggplant/accounts/urls.py
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
from django.conf.urls import url

from . import views


urlpatterns = [

]
urlpatterns = []
3 changes: 0 additions & 3 deletions eggplant/accounts/views.py
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
from django.shortcuts import render

# Create your views here.
2 changes: 1 addition & 1 deletion eggplant/core/static/css/bootstrap-datepicker3.min.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion eggplant/core/static/css/eggplant.css
Original file line number Diff line number Diff line change
Expand Up @@ -217,4 +217,4 @@ select.form-control.money-widget {
.language-chooser ul.nav > li.active > a
{
background-color: rgb(138, 34, 98);
}
}
2 changes: 1 addition & 1 deletion eggplant/core/static/js/bootstrap-datepicker.min.js

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions eggplant/core/tests.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from django.conf import settings
from django.test import TestCase

from django.test.client import RequestFactory
from eggplant.core.utils import generate_upload_path

from .context_processors import coop_vars
from django.test.client import RequestFactory


class UtilsTestCase(TestCase):
Expand Down
4 changes: 2 additions & 2 deletions eggplant/core/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from functools import wraps
import os
import uuid
from functools import wraps

from django.conf import settings
from django.contrib.sites.models import Site
Expand Down Expand Up @@ -38,4 +38,4 @@ def wrapper(*args, **kwargs):
if kwargs.get('raw'):
return
signal_handler(*args, **kwargs)
return wrapper
return wrapper
4 changes: 0 additions & 4 deletions eggplant/dashboard/admin.py
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@
# -*- coding: utf-8 -*-
from django.contrib import admin

# Register your models here.
3 changes: 1 addition & 2 deletions eggplant/dashboard/tests.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# -*- coding: utf-8 -*-
from django.test import TestCase

from django.core.urlresolvers import reverse
from django.test import TestCase


class TestDashboard(TestCase):
Expand Down
5 changes: 2 additions & 3 deletions eggplant/dashboard/views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from django.shortcuts import render
from django.contrib.auth.decorators import login_required

import logging

from django.contrib.auth.decorators import login_required
from django.shortcuts import render

log = logging.getLogger(__file__)

Expand Down
2 changes: 1 addition & 1 deletion eggplant/departments/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
from django.db import migrations, models


class Migration(migrations.Migration):
Expand Down
2 changes: 1 addition & 1 deletion eggplant/departments/migrations/0002_auto_20151027_1817.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
from django.db import migrations, models


class Migration(migrations.Migration):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% extends 'eggplant/departments/department_base.html' %}

{% block department_content %}
{% endblock %}
{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
{% for department in departments %}
<a href="{% url 'eggplant:departments:detail' department.slug %}">{{ department.name }}</a><br />
{% endfor %}
{% endblock %}
{% endblock %}
5 changes: 2 additions & 3 deletions eggplant/departments/tests.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from django.test import TestCase

# Create your tests here.
from eggplant.factories import DepartmentFactory, UserFactory, \
DepartmentAdministratorFactory, AccountFactory
from eggplant.factories import (AccountFactory, DepartmentAdministratorFactory,
DepartmentFactory, UserFactory)
from eggplant.profiles.models import UserProfile


Expand Down
4 changes: 2 additions & 2 deletions eggplant/departments/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.conf.urls import url
from django.views.generic import ListView, DetailView, CreateView, UpdateView, \
DeleteView
from django.views.generic import (CreateView, DeleteView, DetailView, ListView,
UpdateView)

from .models import Department

Expand Down
3 changes: 1 addition & 2 deletions eggplant/departments/views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from django.views.generic import ListView

from eggplant.core.views import LoginRequiredMixin
from eggplant.departments.models import Department
from eggplant.profiles.models import UserProfile
from eggplant.core.views import LoginRequiredMixin


class DepartmentProfiles(LoginRequiredMixin, ListView):
Expand Down
4 changes: 2 additions & 2 deletions eggplant/factories.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# coding: utf8
import factory
from django.conf import settings
from django.db.models.signals import post_save
from django.contrib.auth import get_user_model
import factory
from django.db.models.signals import post_save


class UserFactory(factory.DjangoModelFactory):
Expand Down
5 changes: 2 additions & 3 deletions eggplant/invitations/auth_backends.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import logging

from allauth.account.models import EmailConfirmation
from django.contrib.auth import get_user_model
from django.contrib.auth.backends import ModelBackend
from allauth.account.models import EmailConfirmation

from eggplant.profiles.models import UserProfile


log = logging.getLogger(__name__)


Expand Down
3 changes: 1 addition & 2 deletions eggplant/invitations/forms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django import forms

from captcha.fields import ReCaptchaField
from django import forms

from .models import DepartmentInvitation

Expand Down
3 changes: 2 additions & 1 deletion eggplant/invitations/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
import uuid

from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ Thank you for signing up as a member of the {{department}} department of {{coop_

Please click the following link to confirm you email address and fill out your membership details:
{{invite_url}}{% endblocktrans %}
{% endblock %}
{% endblock %}
5 changes: 2 additions & 3 deletions eggplant/invitations/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@
from django.core.urlresolvers import reverse
from django.test import TestCase
from eggplant.accounts.models import Account

from eggplant.core.utils import absolute_url_reverse
from eggplant.factories import UserFactory, DepartmentFactory, \
AccountCategoryFactory, DepartmentInvitationFactory
from eggplant.factories import (AccountCategoryFactory, DepartmentFactory,
DepartmentInvitationFactory, UserFactory)
from eggplant.profiles.models import UserProfile

from .models import DepartmentInvitation
Expand Down
3 changes: 1 addition & 2 deletions eggplant/invitations/utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from django.contrib.auth import get_user_model

from allauth.account.models import EmailAddress, EmailConfirmation
from django.contrib.auth import get_user_model


def create_verified_user(invitation):
Expand Down
13 changes: 7 additions & 6 deletions eggplant/invitations/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,15 @@
from django.conf import settings
from django.contrib import messages
from django.contrib.auth import authenticate, login
from django.contrib.auth.decorators import permission_required, login_required
from django.contrib.auth.decorators import login_required, permission_required
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.db import transaction
from django.shortcuts import redirect, get_object_or_404, render

from django.shortcuts import get_object_or_404, redirect, render
from eggplant.accounts.models import Account
from eggplant.invitations.forms import (AcceptInvitationForm,
DepartmentInvitationForm)
from eggplant.invitations.models import DepartmentInvitation
from eggplant.invitations.forms import AcceptInvitationForm, \
DepartmentInvitationForm
from eggplant.invitations.utils import create_verified_user

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -50,7 +49,9 @@ def do_accept_invitation(request, invitation):
return user


def accept_invitation(request, verification_key):
# TODO: Fails McCabe test, C901 'accept_invitation' is too complex (11)
# Refactor into FormView
def accept_invitation(request, verification_key): # NOQA
"""Accept invitation."""
if request.user.is_authenticated():
msg = "You are already logged-in"
Expand Down
9 changes: 3 additions & 6 deletions eggplant/market/admin.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
from django.conf import settings
from django.contrib import admin
from django.contrib.admin.sites import AlreadyRegistered


from .models.inventory import Product, ProductCategory, ProductTax
from .models.cart import Basket
from .models import Payment, GetPaidPayment

from getpaid.admin import PaymentAdmin

from .models import GetPaidPayment, Payment
from .models.cart import Basket
from .models.inventory import Product, ProductCategory, ProductTax

try:
admin.site.register(GetPaidPayment, PaymentAdmin)
Expand Down
7 changes: 3 additions & 4 deletions eggplant/market/filters.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from django.utils.safestring import mark_safe
from django.forms.widgets import flatatt
import django_filters
from django.db.models.fields import BLANK_CHOICE_DASH
from django.forms.widgets import flatatt
from django.utils.encoding import force_text
from django.utils.http import urlencode
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext as _

import django_filters

from .models.inventory import Product, ProductCategory


Expand Down
3 changes: 1 addition & 2 deletions eggplant/market/forms.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from django import forms
from django.forms import ModelForm
from djmoney.settings import CURRENCY_CHOICES
from eggplant.core.widgets import MoneyWidget

from .models.inventory import Product
from eggplant.core.widgets import MoneyWidget


class BasketItemForm(forms.Form):
Expand Down
7 changes: 4 additions & 3 deletions eggplant/market/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
import djmoney.models.fields
import django.utils.timezone
from decimal import Decimal

import django.utils.timezone
import djmoney.models.fields
from django.conf import settings
from django.db import migrations, models


class Migration(migrations.Migration):
Expand Down
Loading

0 comments on commit 511ee38

Please sign in to comment.