lint(minor): fix all remaining pylint and prospector errors

This commit is contained in:
Langhammer, Jens 2019-10-01 11:08:56 +02:00
parent 84768c0ec6
commit 7bff2734aa
5 changed files with 11 additions and 16 deletions

View File

@ -204,8 +204,8 @@ class RequestHandler:
def _set_content_type(self, proxy_response): def _set_content_type(self, proxy_response):
content_type = proxy_response.headers.get('Content-Type') content_type = proxy_response.headers.get('Content-Type')
if not content_type: if not content_type:
content_type = (mimetypes.guess_type(self.request.path)[0] or content_type = (mimetypes.guess_type(self.request.path)
self.app_gw.default_content_type) [0] or self.app_gw.default_content_type)
proxy_response.headers['Content-Type'] = content_type proxy_response.headers['Content-Type'] = content_type
# LOGGER.debug("Proxy response CONTENT-TYPE: %s", # LOGGER.debug("Proxy response CONTENT-TYPE: %s",
# proxy_response.headers['Content-Type']) # proxy_response.headers['Content-Type'])

View File

@ -77,7 +77,7 @@ class TestFactorAuthentication(TestCase):
request.user = AnonymousUser() request.user = AnonymousUser()
middleware = SessionMiddleware() middleware = SessionMiddleware()
middleware.process_request(request) middleware.process_request(request)
request.session.save() request.session.save() # pylint: disable=no-member
request.session[AuthenticationView.SESSION_PENDING_USER] = self.user.pk request.session[AuthenticationView.SESSION_PENDING_USER] = self.user.pk
response = AuthenticationView.as_view()(request) response = AuthenticationView.as_view()(request)
@ -93,7 +93,7 @@ class TestFactorAuthentication(TestCase):
request.user = AnonymousUser() request.user = AnonymousUser()
middleware = SessionMiddleware() middleware = SessionMiddleware()
middleware.process_request(request) middleware.process_request(request)
request.session.save() request.session.save() # pylint: disable=no-member
request.session[AuthenticationView.SESSION_PENDING_USER] = self.user.pk request.session[AuthenticationView.SESSION_PENDING_USER] = self.user.pk
response = AuthenticationView.as_view()(request) response = AuthenticationView.as_view()(request)
@ -111,7 +111,7 @@ class TestFactorAuthentication(TestCase):
request.user = AnonymousUser() request.user = AnonymousUser()
middleware = SessionMiddleware() middleware = SessionMiddleware()
middleware.process_request(request) middleware.process_request(request)
request.session.save() request.session.save() # pylint: disable=no-member
request.session[AuthenticationView.SESSION_PENDING_USER] = self.user.pk request.session[AuthenticationView.SESSION_PENDING_USER] = self.user.pk
response = AuthenticationView.as_view()(request) response = AuthenticationView.as_view()(request)
@ -127,7 +127,7 @@ class TestFactorAuthentication(TestCase):
middleware.process_request(request) middleware.process_request(request)
for key, value in session_copy: for key, value in session_copy:
request.session[key] = value request.session[key] = value
request.session.save() request.session.save() # pylint: disable=no-member
response = AuthenticationView.as_view()(request) response = AuthenticationView.as_view()(request)
self.assertEqual(response.status_code, 302) self.assertEqual(response.status_code, 302)
self.assertEqual(response.url, reverse('passbook_core:overview')) self.assertEqual(response.url, reverse('passbook_core:overview'))

View File

@ -143,9 +143,6 @@ class ConfigLoader:
CONFIG = ConfigLoader() CONFIG = ConfigLoader()
# pylint: disable=unused-argument
def signal_handler(sender, **_): def signal_handler(sender, **_):
"""Add all loaded config files to autoreload watcher""" """Add all loaded config files to autoreload watcher"""
for path in CONFIG.loaded_file: for path in CONFIG.loaded_file:

View File

@ -32,8 +32,7 @@ def reauth_required(view_function):
if RE_AUTH_KEY not in request.session: if RE_AUTH_KEY not in request.session:
# Timestamp not in session, force user to reauth # Timestamp not in session, force user to reauth
return redirect(reverse('account-reauth') + '?' + return redirect(reverse('account-reauth') + '?' + urlencode({'next': request.path}))
urlencode({'next': request.path}))
if RE_AUTH_KEY in request.session and \ if RE_AUTH_KEY in request.session and \
request.session[RE_AUTH_KEY] >= (now - RE_AUTH_MARGAIN) and \ request.session[RE_AUTH_KEY] >= (now - RE_AUTH_MARGAIN) and \

View File

@ -120,9 +120,9 @@ class OAuthClient(BaseOAuthClient):
"Parse token and secret from raw token response." "Parse token and secret from raw token response."
if raw_token is None: if raw_token is None:
return (None, None) return (None, None)
qs = parse_qs(raw_token) query_string = parse_qs(raw_token)
token = qs.get('oauth_token', [None])[0] token = query_string.get('oauth_token', [None])[0]
secret = qs.get('oauth_token_secret', [None])[0] secret = query_string.get('oauth_token_secret', [None])[0]
return (token, secret) return (token, secret)
def request(self, method, url, **kwargs): def request(self, method, url, **kwargs):
@ -217,8 +217,7 @@ class OAuth2Client(BaseOAuthClient):
try: try:
token_data = json.loads(raw_token) token_data = json.loads(raw_token)
except ValueError: except ValueError:
qs = parse_qs(raw_token) token = parse_qs(raw_token).get('access_token', [None])[0]
token = qs.get('access_token', [None])[0]
else: else:
token = token_data.get('access_token', None) token = token_data.get('access_token', None)
return (token, None) return (token, None)