Skip to content

Commit

Permalink
Address most flake8 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
callahad committed Feb 10, 2020
1 parent a60c67e commit 3e40fb7
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 19 deletions.
6 changes: 6 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ exclude = **/migrations/**
max-line-length=88
ignore = E203, E501, W503

# Allow star imports in config files:
per-file-ignores =
kuma/settings/local.py:F403,F405
kuma/settings/prod.py:F403,F405
kuma/settings/testing.py:F403,F405

# flake8-import-order settings
import-order-style=edited
application-import-names=kuma,pages,utils
16 changes: 8 additions & 8 deletions kuma/core/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def _wrapped_view(request, *args, **kwargs):

def logout_required(redirect):
"""Requires that the user *not* be logged in."""
redirect_func = lambda u: u.is_authenticated
redirect_func = lambda u: u.is_authenticated # noqa: E731
if hasattr(redirect, "__call__"):
return user_access_decorator(
redirect_func,
Expand All @@ -103,10 +103,10 @@ def login_required(
):
"""Requires that the user is logged in."""
if only_active:
redirect_func = lambda u: not (u.is_authenticated and u.is_active)
redirect_func = lambda u: not (u.is_authenticated and u.is_active) # noqa: E731
else:
redirect_func = lambda u: not u.is_authenticated
redirect_url_func = lambda: login_url
redirect_func = lambda u: not u.is_authenticated # noqa: E731
redirect_url_func = lambda: login_url # noqa: E731
return user_access_decorator(
redirect_func, redirect_field=redirect, redirect_url_func=redirect_url_func
)(func)
Expand All @@ -117,12 +117,12 @@ def permission_required(
):
"""A replacement for django.contrib.auth.decorators.permission_required
that doesn't ask authenticated users to log in."""
redirect_func = lambda u: not u.is_authenticated
redirect_func = lambda u: not u.is_authenticated # noqa: E731
if only_active:
deny_func = lambda u: not (u.is_active and u.has_perm(perm))
deny_func = lambda u: not (u.is_active and u.has_perm(perm)) # noqa: E731
else:
deny_func = lambda u: not u.has_perm(perm)
redirect_url_func = lambda: login_url
deny_func = lambda u: not u.has_perm(perm) # noqa: E731
redirect_url_func = lambda: login_url # noqa: E731

return user_access_decorator(
redirect_func,
Expand Down
6 changes: 3 additions & 3 deletions kuma/core/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ def set_language(request):
return response


handler403 = lambda request, exception=None: _error_page(request, 403)
handler404 = lambda request, exception=None: _error_page(request, 404)
handler500 = lambda request, exception=None: _error_page(request, 500)
handler403 = lambda request, exception=None: _error_page(request, 403) # noqa: E731
handler404 = lambda request, exception=None: _error_page(request, 404) # noqa: E731
handler500 = lambda request, exception=None: _error_page(request, 500) # noqa: E731


@never_cache
Expand Down
2 changes: 1 addition & 1 deletion kuma/settings/local.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .common import * # noqa
from .common import *

# Settings for Docker Development
# TODO: Use environment to override, not settings picker
Expand Down
2 changes: 1 addition & 1 deletion kuma/settings/prod.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .common import * # noqa
from .common import *

ATTACHMENT_HOST = config("ATTACHMENT_HOST", default="mdn.mozillademos.org")
ALLOW_ROBOTS = config("ALLOW_ROBOTS", default=True, cast=bool)
Expand Down
2 changes: 1 addition & 1 deletion kuma/settings/testing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .local import * # noqa
from .local import *

DEBUG = False
ENABLE_RESTRICTIONS_BY_HOST = False
Expand Down
1 change: 0 additions & 1 deletion kuma/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@

from .forms import UserBanForm, UserDeleteForm, UserEditForm, UserRecoveryEmailForm
from .models import User, UserBan

# we have to import the signup form here due to allauth's odd form subclassing
# that requires providing a base form class (see ACCOUNT_SIGNUP_FORM_CLASS)
from .signup import SignupForm
Expand Down
2 changes: 1 addition & 1 deletion kuma/wiki/kumascript.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def macro_sources(force_lowercase_keys=False):
# Ensure Normal Form C used on GitHub
normalize_key = normalize = partial(unicodedata.normalize, "NFC")
if force_lowercase_keys:
normalize_key = lambda x: normalize(x).lower()
normalize_key = lambda x: normalize(x).lower() # noqa: E731
return {
normalize_key(md["name"]): normalize(md["filename"]) for md in macros_raw
}
Expand Down
6 changes: 3 additions & 3 deletions kuma/wiki/views/__init__.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import logging

from . import (
from . import ( # noqa: F401
akismet_revision,
code,
create,
delete,
document,
edit, # noqa
edit,
legacy,
list,
misc,
revision,
translate,
) # noqa
)

log = logging.getLogger("kuma.wiki.views")

0 comments on commit 3e40fb7

Please sign in to comment.