ci: disable pylint's bad-continuation to please black

This commit is contained in:
Jens Langhammer 2019-12-31 13:17:35 +01:00
parent 4ebbc6f065
commit 74b2b26a20
4 changed files with 14 additions and 63 deletions

View File

@ -1,6 +1,6 @@
[MASTER]
disable=redefined-outer-name,arguments-differ,no-self-use,cyclic-import,fixme,locally-disabled,unpacking-non-sequence,too-many-ancestors,too-many-branches,too-few-public-methods,import-outside-toplevel
disable=redefined-outer-name,arguments-differ,no-self-use,cyclic-import,fixme,locally-disabled,unpacking-non-sequence,too-many-ancestors,too-many-branches,too-few-public-methods,import-outside-toplevel,bad-continuation
load-plugins=pylint_django,pylint.extensions.bad_builtin
extension-pkg-whitelist=lxml
const-rgx=[a-zA-Z0-9_]{1,40}$

View File

@ -13,8 +13,8 @@ class TagModelForm(forms.ModelForm):
tags = instance.tags if instance else {}
# Make sure all predefined tags exist in tags, and set default if they don't
predefined_tags = (
self._meta.model().get_predefined_tags()
) # pylint: disable=no-member
self._meta.model().get_predefined_tags() # pylint: disable=no-member
)
for key, value in predefined_tags.items():
if key not in tags:
tags[key] = value

View File

@ -1,51 +0,0 @@
"""passbook decorators"""
from time import time as timestamp
from django.conf import settings
from django.shortcuts import redirect
from django.urls import reverse
from django.utils.functional import wraps
from django.utils.http import urlencode
RE_AUTH_KEY = getattr(settings, "RE_AUTH_KEY", "passbook_require_re_auth_done")
RE_AUTH_MARGAIN = getattr(settings, "RE_AUTH_MARGAIN", 300)
def reauth_required(view_function):
"""Decorator to force a re-authentication before continuing"""
@wraps(view_function)
def wrap(*args, **kwargs):
"""check if user just authenticated or not"""
request = args[0] if args else None
# Check if user is authenticated at all
if not request or not request.user or not request.user.is_authenticated:
return redirect(reverse("account-login"))
now = timestamp()
if RE_AUTH_KEY in request.session and request.session[RE_AUTH_KEY] < (
now - RE_AUTH_MARGAIN
):
# Timestamp in session but expired
del request.session[RE_AUTH_KEY]
if RE_AUTH_KEY not in request.session:
# Timestamp not in session, force user to reauth
return redirect(
reverse("account-reauth") + "?" + urlencode({"next": request.path})
)
if (
RE_AUTH_KEY in request.session
and request.session[RE_AUTH_KEY] >= (now - RE_AUTH_MARGAIN)
and request.session[RE_AUTH_KEY] <= now
):
# Timestamp in session and valid
return view_function(*args, **kwargs)
# This should never be reached, just return False
return False # pragma: no cover
return wrap

View File

@ -3,6 +3,7 @@ from hashlib import md5
from urllib.parse import urlencode
from django import template
from django.template import Context
from django.apps import apps
from django.db.models import Model
from django.utils.html import escape
@ -15,9 +16,10 @@ register = template.Library()
@register.simple_tag(takes_context=True)
def back(context):
def back(context: Context) -> str:
"""Return a link back (either from GET paramter or referer."""
if "request" not in context:
return ""
request = context.get("request")
url = ""
if "HTTP_REFERER" in request.META:
@ -33,25 +35,25 @@ def back(context):
@register.filter("fieldtype")
def fieldtype(field):
"""Return classname"""
# if issubclass(field.__class__, CastableModel):
# field = field.cast()
if isinstance(field.__class__, Model) or issubclass(field.__class__, Model):
return field._meta.verbose_name
return field.__class__.__name__
@register.simple_tag(takes_context=True)
def title(context, *title):
def title(context: Context, *title) -> str:
"""Return either just branding or title - branding"""
branding = CONFIG.y("passbook.branding", "passbook")
if not title:
return branding
if "request" not in context:
return ""
resolver_match = context.request.resolver_match
if not resolver_match:
return ""
# Include App Title in title
app = ""
if (
context.request.resolver_match
and context.request.resolver_match.namespace != ""
):
if resolver_match.namespace != "":
dj_app = None
namespace = context.request.resolver_match.namespace.split(":")[0]
# New label (App URL Namespace == App Label)