Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce flake8 checks in PR workflow #519

3 changes: 1 addition & 2 deletions .flake8
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
[flake8]
per-file-ignores =
volunteer_planner/settings/*.py: F403, F405,
volunteer_planner/settings/__init__.py: F403,
volunteer_planner/settings/*.py: F401, F403, F405,

max-line-length = 88
3 changes: 0 additions & 3 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ jobs:
uses: actions/checkout@v2
- name: flake8 Lint
uses: py-actions/flake8@v2
continue-on-error: true
- name: Succeed until flake8 is enforced
run: exit 0

pytest:
name: Unit Tests
Expand Down
2 changes: 1 addition & 1 deletion accounts/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def _session_data(self, obj):
try:
user = User.objects.get(id=decoded.get(key))
_session_data += " (" + user.username + ")"
except Exception as e:
except Exception:
pass
_session_data += "<br/>"
return format_html(_session_data)
Expand Down
2 changes: 1 addition & 1 deletion accounts/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class AccountsConfig(AppConfig):
verbose_name = _("Accounts")

def ready(self):
import accounts.signals
from . import signals # noqa


class RegistrationConfig(AppConfig):
Expand Down
2 changes: 1 addition & 1 deletion accounts/forms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django import forms
from registration.forms import RegistrationFormUniqueEmail
from django.utils.text import gettext_lazy as _
from registration.forms import RegistrationFormUniqueEmail


class RegistrationForm(RegistrationFormUniqueEmail):
Expand Down
5 changes: 2 additions & 3 deletions accounts/management/commands/clean_expired.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# coding=utf-8
from django.conf import settings
from django.core.management.base import BaseCommand

from datetime import date, timedelta

from django.conf import settings
from django.core.management.base import BaseCommand
from registration.models import RegistrationProfile


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

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


class Migration(migrations.Migration):
Expand Down
7 changes: 3 additions & 4 deletions accounts/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

from django.urls import re_path


from .views import (
user_account_detail,
AccountUpdateView,
AccountDeleteView,
account_delete_final,
AccountDeleteView,
AccountUpdateView,
shift_list_active,
shift_list_done,
user_account_detail,
)

urlpatterns = [
Expand Down
14 changes: 6 additions & 8 deletions accounts/views.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
import random
import string
from datetime import date, datetime, timedelta

from django.contrib.admin.models import DELETION, LogEntry
from django.contrib.auth import logout
from django.contrib.auth import logout, models
from django.contrib.auth.decorators import login_required
from django.contrib.contenttypes.models import ContentType
from django.db import transaction
from django.shortcuts import render
from django.contrib.auth.decorators import login_required
from django.views.generic.edit import UpdateView
from django.urls import reverse_lazy
from django.contrib.auth import models

from datetime import date, datetime, timedelta
from django.views.generic.edit import UpdateView

from volunteer_planner.utils import LoginRequiredMixin
from scheduler.models import ShiftHelper
from accounts.models import UserAccount
from scheduler.models import ShiftHelper
from volunteer_planner.utils import LoginRequiredMixin


@login_required()
Expand Down
2 changes: 1 addition & 1 deletion blueprint/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 blueprint/migrations/0002_needblueprint_slots.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 blueprint/migrations/0003_auto_20151003_2033.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 blueprint/migrations/0003_auto_20151006_1341.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 blueprint/migrations/0004_merge.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


class Migration(migrations.Migration):
Expand Down
2 changes: 1 addition & 1 deletion blueprint/migrations/0005_demolish_blueprints.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


class Migration(migrations.Migration):
Expand Down
2 changes: 1 addition & 1 deletion common/management/commands/check_db_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def handle(self, *args, **options):
db_conn = connections["default"]
for i in range(0, options["count"]):
try:
c = db_conn.cursor()
db_conn.cursor()
success = True
break
except OperationalError as e:
Expand Down
1 change: 0 additions & 1 deletion common/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# coding=utf-8
from django.db import models

# Create your models here.
13 changes: 7 additions & 6 deletions common/static_file_compressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import io
import re
import shutil
from importlib import import_module

from django.contrib.staticfiles.storage import StaticFilesStorage
from importlib import import_module


class CompressedStaticFilesStorage(StaticFilesStorage):
Expand All @@ -15,7 +15,7 @@ class CompressedStaticFilesStorage(StaticFilesStorage):
def __init__(self, location=None, base_url=None, *args, **kwargs):
super().__init__(location, base_url, *args, **kwargs)
for ext in self.EXTENSIONS:
self.EXT_LOOKUP[ext] = re.compile(".*\.{}\Z".format(ext))
self.EXT_LOOKUP[ext] = re.compile(r".*\.{}\Z".format(ext))

def post_process(self, paths, dry_run=False, **kwargs):
processing_files = []
Expand All @@ -36,9 +36,10 @@ def _post_process(self, name, path, ext, dry_run):
func = getattr(self, func_name)
if func:
processed = func(path)
except AttributeError as e:
except AttributeError:
processed = False
except io.UnsupportedOperation as e:
except io.UnsupportedOperation:
# raise explicitly
raise

return name, path, processed
Expand Down Expand Up @@ -70,7 +71,7 @@ def _generic_minify(path, module, func):
__class__._gzip(path)

return True
except:
except Exception:
return False

@staticmethod
Expand All @@ -79,5 +80,5 @@ def _gzip(path):
with open(path, "rb") as f_in:
with gzip.open("{}.gz".format(path), "wb") as f_out:
shutil.copyfileobj(f_in, f_out)
except:
except Exception:
pass
7 changes: 5 additions & 2 deletions common/templatetags/volunteer_stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def get_volunteer_number():
@register.simple_tag
def get_volunteer_deleted_number():
"""
Returns the number of deleted volunteer accounts (accounts are inactive and anonymized)
Returns the number of deleted volunteer accounts.

Accounts are inactive and anonymized.
"""
return User.objects.filter(is_active=False).count()

Expand All @@ -42,7 +44,8 @@ def get_volunteer_hours():
"""
Returns the number of total volunteer hours worked.
"""
finished_shifts = Shift.objects.filter(starting_time__lte=timezone.now()).annotate(
now = timezone.now()
finished_shifts = Shift.objects.filter(starting_time__lte=now).annotate(
slots_done=Count("helpers")
)
delta = timedelta()
Expand Down
1 change: 0 additions & 1 deletion common/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# coding=utf-8
from django.shortcuts import render

# Create your views here.
3 changes: 1 addition & 2 deletions content/admin.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# coding: utf-8
from django.conf import settings

from django.contrib import admin
from django.contrib.flatpages.admin import FlatPageAdmin
from django.contrib.flatpages.models import FlatPage
from django.utils.html import format_html
from django.utils.translation import gettext_lazy as _

from . import models, forms
from . import forms, models


class FlatPageStyleInline(admin.StackedInline):
Expand Down
2 changes: 1 addition & 1 deletion content/forms.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# coding: utf-8
from ckeditor.widgets import CKEditorWidget
from django.contrib.flatpages.forms import FlatpageForm
from django import forms
from django.contrib.flatpages.forms import FlatpageForm

from content.models import FlatPageTranslation

Expand Down
2 changes: 1 addition & 1 deletion content/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 content/migrations/0002_add_greek_language.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
4 changes: 2 additions & 2 deletions content/models.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# coding: utf-8

from django.db import models
from django.utils.translation import gettext_lazy as _
from django.conf import settings
from django.contrib.flatpages.models import FlatPage
from django.db import models
from django.utils.translation import gettext_lazy as _


class FlatPageExtraStyle(models.Model):
Expand Down
2 changes: 0 additions & 2 deletions content/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
from django.test import TestCase

# Create your tests here.
5 changes: 2 additions & 3 deletions content/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
from django.contrib.flatpages.models import FlatPage
from django.contrib.flatpages.views import render_flatpage
from django.contrib.sites.shortcuts import get_current_site
from django.http import Http404, HttpResponse, HttpResponsePermanentRedirect
from django.http import Http404, HttpResponsePermanentRedirect
from django.shortcuts import get_object_or_404
from django.template import loader
from django.utils.safestring import mark_safe
from django.views.decorators.csrf import csrf_protect

from content.models import FlatPageTranslation

DEFAULT_TEMPLATE = "flatpages/default.html"
Expand Down
8 changes: 2 additions & 6 deletions locale/ar/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: volunteer-planner.org\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-21 16:52+0100\n"
"POT-Creation-Date: 2022-03-25 11:54+0100\n"
"PO-Revision-Date: 2022-03-15 17:56+0000\n"
"Last-Translator: Christoph Meißner\n"
"Language-Team: Arabic (http://www.transifex.com/coders4help/volunteer-planner/language/ar/)\n"
Expand Down Expand Up @@ -687,11 +687,7 @@ msgid "Facilities do not match."
msgstr ""

#, python-brace-format
msgid "\"{task.name}\" belongs to facility \"{task.facility.name}\", but shift takes place at \"{facility.name}\"."
msgstr ""

#, python-brace-format
msgid "\"{workplace.name}\" is at \"{workplace.facility.name}\" but shift takes place at \"{facility.name}\"."
msgid "\"{object.name}\" belongs to facility \"{object.facility.name}\", but shift takes place at \"{facility.name}\"."
msgstr ""

msgid "No start time given."
Expand Down
8 changes: 2 additions & 6 deletions locale/bg/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ msgid ""
msgstr ""
"Project-Id-Version: volunteer-planner.org\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-22 10:26+0100\n"
"POT-Creation-Date: 2022-03-25 11:54+0100\n"
"PO-Revision-Date: 2022-03-15 17:56+0000\n"
"Last-Translator: Christoph Meißner\n"
"Language-Team: Bulgarian (http://www.transifex.com/coders4help/volunteer-planner/language/bg/)\n"
Expand Down Expand Up @@ -683,11 +683,7 @@ msgid "Facilities do not match."
msgstr ""

#, python-brace-format
msgid "\"{task.name}\" belongs to facility \"{task.facility.name}\", but shift takes place at \"{facility.name}\"."
msgstr ""

#, python-brace-format
msgid "\"{workplace.name}\" is at \"{workplace.facility.name}\" but shift takes place at \"{facility.name}\"."
msgid "\"{object.name}\" belongs to facility \"{object.facility.name}\", but shift takes place at \"{facility.name}\"."
msgstr ""

msgid "No start time given."
Expand Down
8 changes: 2 additions & 6 deletions locale/cs/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: volunteer-planner.org\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2022-03-23 00:36+0100\n"
"POT-Creation-Date: 2022-03-25 11:54+0100\n"
"PO-Revision-Date: 2022-03-15 17:56+0000\n"
"Last-Translator: Christoph Meißner\n"
"Language-Team: Czech (http://www.transifex.com/coders4help/volunteer-planner/language/cs/)\n"
Expand Down Expand Up @@ -700,11 +700,7 @@ msgid "Facilities do not match."
msgstr ""

#, python-brace-format
msgid "\"{task.name}\" belongs to facility \"{task.facility.name}\", but shift takes place at \"{facility.name}\"."
msgstr ""

#, python-brace-format
msgid "\"{workplace.name}\" is at \"{workplace.facility.name}\" but shift takes place at \"{facility.name}\"."
msgid "\"{object.name}\" belongs to facility \"{object.facility.name}\", but shift takes place at \"{facility.name}\"."
msgstr ""

msgid "No start time given."
Expand Down
Loading